From e73cf48cc86ada3070f2da1a825b61a9bdc2e014 Mon Sep 17 00:00:00 2001 From: martyanov-av Date: Thu, 14 Nov 2024 16:42:37 +0300 Subject: [PATCH] feat: update @diplodoc/translation & run schema build on postinstall --- package-lock.json | 12 ++++++------ package.json | 5 +++-- scripts/build.cli.js | 4 ---- scripts/generate-pc-schema.js | 10 +++------- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index dd3a8ea1..91f71159 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,10 +7,11 @@ "": { "name": "@diplodoc/cli", "version": "4.44.1", + "hasInstallScript": true, "license": "MIT", "dependencies": { "@diplodoc/client": "^3.1.8", - "@diplodoc/translation": "^1.4.3", + "@diplodoc/translation": "^1.5.0", "katex": "^0.16.9", "shelljs": "0.8.5", "threads": "1.7.0", @@ -2349,10 +2350,9 @@ } }, "node_modules/@diplodoc/translation": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/@diplodoc/translation/-/translation-1.4.4.tgz", - "integrity": "sha512-vrT966AjWgHjI7W7mJ/2h+j0i1O/rM6dkEbdawZSBfFenOzBbbcqEeb1zipm+f7SUcSr9wACzlzcD3rF+pGRZw==", - "license": "MIT", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@diplodoc/translation/-/translation-1.5.0.tgz", + "integrity": "sha512-iyrClFHdtRfxz6hEVnF0s74HZgoFUXYB8merlQ4LGriJNpNM83BmAnMhOo6HJjFfIndykznnWaJDWWhZkYj81g==", "dependencies": { "@cospired/i18n-iso-languages": "^4.1.0", "@diplodoc/lint": "^1.1.3", @@ -2360,6 +2360,7 @@ "@diplodoc/transform": "^4.10.0", "@shellscape/i18n-iso-countries": "^7.5.0-shellscape.v1", "ajv": "^8.12.0", + "ajv-keywords": "^5.1.0", "cheerio": "^1.0.0-rc.12", "domhandler": "^5.0.3", "fast-xml-parser": "^4.1.3", @@ -4789,7 +4790,6 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-5.1.0.tgz", "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", - "dev": true, "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.3" diff --git a/package.json b/package.json index 5a00a744..f4c1cfaf 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "prepublishOnly": "npm run lint && npm run build", "start": "node build/index.js", "test": "vitest", - "typecheck": "tsc --noEmit" + "typecheck": "tsc --noEmit", + "postinstall": "node scripts/generate-pc-schema.js" }, "husky": { "hooks": { @@ -54,7 +55,7 @@ }, "dependencies": { "@diplodoc/client": "^3.1.8", - "@diplodoc/translation": "^1.4.3", + "@diplodoc/translation": "^1.5.0", "katex": "^0.16.9", "shelljs": "0.8.5", "threads": "1.7.0", diff --git a/scripts/build.cli.js b/scripts/build.cli.js index f096d37a..6c700b16 100644 --- a/scripts/build.cli.js +++ b/scripts/build.cli.js @@ -3,8 +3,6 @@ const esbuild = require('esbuild'); const tsPaths = require('./ts-paths'); const shell = require('shelljs'); -const generatePageConstuctorSchema = require('./generate-pc-schema'); - const SEARCH_API = require.resolve('@diplodoc/search-extension/worker'); const SEARCH_LANGS = require.resolve('@diplodoc/search-extension/worker/langs'); const CLIENT_PATH = dirname(require.resolve('@diplodoc/client/manifest')); @@ -49,8 +47,6 @@ const builds = [ [['src/workers/linter/index.ts'], 'build/linter.js'], ]; -generatePageConstuctorSchema(); - Promise.all(builds.map(([entries, outfile]) => { const currentConfig = { ...commonConfig, diff --git a/scripts/generate-pc-schema.js b/scripts/generate-pc-schema.js index f6c4fc8e..d9487fc7 100644 --- a/scripts/generate-pc-schema.js +++ b/scripts/generate-pc-schema.js @@ -18,11 +18,7 @@ function replaceField(obj, oldFieldName, newFieldName, newFieldValue) { return obj; } -function generatePageConstuctorSchema() { - const schema = generateDefaultSchema(); - const modifiedSchema = replaceField(schema, 'contentType', 'translate', 'md'); +const schema = generateDefaultSchema(); +const modifiedSchema = replaceField(schema, 'contentType', 'translate', 'md'); - fs.writeFileSync('schemas/page-constructor-schema.json', JSON.stringify(modifiedSchema, null, 2)); -} - -module.exports = generatePageConstuctorSchema; +fs.writeFileSync('schemas/page-constructor-schema.json', JSON.stringify(modifiedSchema, null, 2));