diff --git a/package-lock.json b/package-lock.json index 9198c2fa..8db0f7d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -218,9 +218,9 @@ "dev": true }, "@babel/runtime": { - "version": "7.22.3", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.3.tgz", - "integrity": "sha512-XsDuspWKLUsxwCp6r7EhsExHtYfbe5oAGQ19kqngTdCPUoPQzOPdUbD/pB9PJiwb2ptYKQDjSJT3R6dC+EPqfQ==", + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.5.tgz", + "integrity": "sha512-ecjvYlnAaZ/KVneE/OdKYBYfgXV3Ptu6zQWmgEF7vwKhQnvVS6bjMD2XYgj+SNvQ1GfK/pjgokfPkC/2CO8CuA==", "requires": { "regenerator-runtime": "^0.13.11" } @@ -296,13 +296,13 @@ } }, "@diplodoc/client": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/@diplodoc/client/-/client-0.0.6.tgz", - "integrity": "sha512-7Qd1f+MMcnZi6wn6o6/70U5GEJe/ZdsFR/hpEwVft5c0WGVRcrUaNepKYpwHTPkJ5Xd7bbPGywW6gvg8Fr7lzQ==", + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/@diplodoc/client/-/client-0.0.7.tgz", + "integrity": "sha512-ctCDJtWedl/jYqOjyRwFM45G2bPQeo6mkwY7IN/0lJ5A+nUP8GYDNGvSureh2fXc0bXk8PEVolJi/Y6wUyHCZA==", "requires": { "@diplodoc/mermaid-extension": "^0.0.5", "@diplodoc/openapi-extension": "^1.2.3", - "@doc-tools/components": "^2.8.0", + "@doc-tools/components": "^2.8.2", "@doc-tools/transform": "^3.0.2", "@gravity-ui/uikit": "^4.14.0", "react": "^18.2.0", @@ -310,23 +310,18 @@ "url": "^0.11.0" }, "dependencies": { - "@diplodoc/mermaid-extension": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/@diplodoc/mermaid-extension/-/mermaid-extension-0.0.5.tgz", - "integrity": "sha512-1MbXYTkz8fO+JMWk65YYaVo6h3BBS3WJBhGCA2TEqVCCQbIv+Nc+iV/tJT5TrqUl6ybkfJlbZ57Qkvuv3zB2qw==", - "requires": { - "mermaid": "^10.0.2", - "react": ">=16", - "ts-dedent": "^2.2.0" - } + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==" }, "url": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", - "integrity": "sha512-kbailJa29QrtXnxgq+DdCEGlbTeYM2eJUxsz6vjZavrCYPMIFHMKQmSKYAIuUK2i7hgPm28a8piX5NTUtM/LKQ==", + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/url/-/url-0.11.1.tgz", + "integrity": "sha512-rWS3H04/+mzzJkv0eZ7vEDGiQbgquI1fGfOad6zKvgYQi1SzMmhl7c/DdRGxhaWrVH6z0qWITo8rpnxK/RfEhA==", "requires": { - "punycode": "1.3.2", - "querystring": "0.2.0" + "punycode": "^1.4.1", + "qs": "^6.11.0" } } } @@ -404,9 +399,9 @@ } }, "@doc-tools/components": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/@doc-tools/components/-/components-2.8.1.tgz", - "integrity": "sha512-M1bJjGrlAss+Nv0/9o7udQ0SYk7ByXqiL/csP87gl27qew90PJ04+v3tETsf+Y+nKA31z+arttmLn4NZ/fqyxQ==", + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/@doc-tools/components/-/components-2.8.2.tgz", + "integrity": "sha512-JiM+Bjn1QXav9rYFQge6pMlp0FQJrizIXYironYibaVIgx/R4wwLrEGSdISpFqtM0YfsI8TyChoqrnVxUa4vgA==", "requires": { "@gravity-ui/uikit": "^4.3.0", "@popperjs/core": "^2.11.2", @@ -684,46 +679,39 @@ "resolved": "https://registry.npmjs.org/@gravity-ui/i18n/-/i18n-1.1.0.tgz", "integrity": "sha512-Ck+LNE1S2GGaMKMijIYWogiM/tYk0wHPlqLrhZmzp6P5keIu8YnPDeIlwAzq4eYVSrtTudLmshFB9QmYAeLryQ==" }, + "@gravity-ui/icons": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@gravity-ui/icons/-/icons-2.2.0.tgz", + "integrity": "sha512-CsYg+Dj08Yp1eGKux7c+sm7HSPJRDvDBjyOHnL6UR19QM+HCpdGiyrR2VVBvYadwm2eOeX4JNSn+vMPrqsmJdg==" + }, "@gravity-ui/uikit": { - "version": "4.15.1", - "resolved": "https://registry.npmjs.org/@gravity-ui/uikit/-/uikit-4.15.1.tgz", - "integrity": "sha512-iP4HzLZ+FnyIsQLdzj4jzRLOqwY6MGJYufXlIcXixqo2xUTTHsQGQ3VLr8CxOwAAPCql5Qc2843H9s3khVAiEQ==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@gravity-ui/uikit/-/uikit-4.21.2.tgz", + "integrity": "sha512-5Bh4JMJRTk67+IxkOropKkyhZe9oNWDuD7Z3aRWN0wQliDXuLTq70+M+5rJ+V/8Q3jli6LmRedvFPOTffcfFqQ==", "requires": { "@gravity-ui/i18n": "^1.1.0", - "@popperjs/core": "2.11.6", - "bem-cn-lite": "4.0.0", + "@gravity-ui/icons": "^2.2.0", + "@popperjs/core": "^2.11.8", + "bem-cn-lite": "^4.1.0", "blueimp-md5": "^2.19.0", - "focus-trap": "7.4.0", - "lodash": "4.17.21", - "react-copy-to-clipboard": "5.1.0", - "react-popper": "2.3.0", + "focus-trap": "^7.4.3", + "lodash": "^4.17.21", + "react-copy-to-clipboard": "^5.1.0", + "react-popper": "^2.3.0", "react-sortable-hoc": "2.0.0", "react-transition-group": "^4.4.5", - "react-virtualized-auto-sizer": "1.0.7", - "react-window": "1.8.8", - "resize-observer-polyfill": "1.5.1", - "tabbable": "6.1.1", - "tslib": "2.3.1", - "utility-types": "3.10.0" + "react-virtualized-auto-sizer": "^1.0.20", + "react-window": "^1.8.9", + "resize-observer-polyfill": "^1.5.1", + "tabbable": "^6.1.2", + "tslib": "^2.5.3", + "utility-types": "^3.10.0" }, "dependencies": { - "@popperjs/core": { - "version": "2.11.6", - "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.6.tgz", - "integrity": "sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==" - }, - "bem-cn-lite": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/bem-cn-lite/-/bem-cn-lite-4.0.0.tgz", - "integrity": "sha512-ylyWbX63PqhJvm9xGcLAoiKYi87T5g4r5g6sx0dZHcvCtgYvnOWvVTZOQp+uB2DF8ZXsejnPkySvzKnsQhuOAg==", - "requires": { - "bem-cn": "^3.0.1" - } - }, "tslib": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz", - "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==" + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.0.tgz", + "integrity": "sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA==" } } }, @@ -2861,11 +2849,11 @@ "dev": true }, "focus-trap": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/focus-trap/-/focus-trap-7.4.0.tgz", - "integrity": "sha512-yI7FwUqU4TVb+7t6PaQ3spT/42r/KLEi8mtdGoQo2li/kFzmu9URmalTvw7xCCJtSOyhBxscvEAmvjeN9iHARg==", + "version": "7.4.3", + "resolved": "https://registry.npmjs.org/focus-trap/-/focus-trap-7.4.3.tgz", + "integrity": "sha512-BgSSbK4GPnS2VbtZ50VtOv1Sti6DIkj3+LkVjiWMNjLeAp1SH1UlLx3ULu/DCu4vq5R4/uvTm+zrvsMsuYmGLg==", "requires": { - "tabbable": "^6.1.1" + "tabbable": "^6.1.2" } }, "follow-redirects": { @@ -4106,13 +4094,12 @@ "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==" }, "object-inspect": { "version": "1.12.3", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz", - "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==", - "dev": true + "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==" }, "observable-fns": { "version": "0.6.1", @@ -4281,6 +4268,14 @@ "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=" }, + "qs": { + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz", + "integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==", + "requires": { + "side-channel": "^1.0.4" + } + }, "querystring": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", @@ -4388,14 +4383,14 @@ } }, "react-virtualized-auto-sizer": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/react-virtualized-auto-sizer/-/react-virtualized-auto-sizer-1.0.7.tgz", - "integrity": "sha512-Mxi6lwOmjwIjC1X4gABXMJcKHsOo0xWl3E3ugOgufB8GJU+MqrtY35aBuvCYv/razQ1Vbp7h1gWJjGjoNN5pmA==" + "version": "1.0.20", + "resolved": "https://registry.npmjs.org/react-virtualized-auto-sizer/-/react-virtualized-auto-sizer-1.0.20.tgz", + "integrity": "sha512-OdIyHwj4S4wyhbKHOKM1wLSj/UDXm839Z3Cvfg2a9j+He6yDa6i5p0qQvEiCnyQlGO/HyfSnigQwuxvYalaAXA==" }, "react-window": { - "version": "1.8.8", - "resolved": "https://registry.npmjs.org/react-window/-/react-window-1.8.8.tgz", - "integrity": "sha512-D4IiBeRtGXziZ1n0XklnFGu7h9gU684zepqyKzgPNzrsrk7xOCxni+TCckjg2Nr/DiaEEGVVmnhYSlT2rB47dQ==", + "version": "1.8.9", + "resolved": "https://registry.npmjs.org/react-window/-/react-window-1.8.9.tgz", + "integrity": "sha512-+Eqx/fj1Aa5WnhRfj9dJg4VYATGwIUP2ItwItiJ6zboKWA6EX3lYDAXfGF2hyNqplEprhbtjbipiADEcwQ823Q==", "requires": { "@babel/runtime": "^7.0.0", "memoize-one": ">=3.1.1 <6" @@ -4636,6 +4631,16 @@ } } }, + "side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "requires": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + } + }, "signal-exit": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.6.tgz", @@ -4815,9 +4820,9 @@ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==" }, "tabbable": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.1.1.tgz", - "integrity": "sha512-4kl5w+nCB44EVRdO0g/UGoOp3vlwgycUVtkk/7DPyeLZUCuNFFKCFG6/t/DgHLrUPHjrZg6s5tNm+56Q2B0xyg==" + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.2.0.tgz", + "integrity": "sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==" }, "table": { "version": "5.4.6", diff --git a/package.json b/package.json index 3de99497..00353080 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ }, "dependencies": { "@apidevtools/swagger-parser": "^10.1.0", - "@diplodoc/client": "0.0.6", + "@diplodoc/client": "0.0.7", "@diplodoc/markdown-translation": "^0.12.0", "@diplodoc/mermaid-extension": "0.0.5", "@diplodoc/openapi-extension": "^1.2.7", diff --git a/scripts/build.cli.js b/scripts/build.cli.js index b3e1ab5d..384f449f 100644 --- a/scripts/build.cli.js +++ b/scripts/build.cli.js @@ -1,8 +1,18 @@ const esbuild = require('esbuild'); +const shell = require('shelljs'); + +const client = require('./client'); const {version, dependencies} = require('../package.json'); -const {target} = require('../tsconfig.json').compilerOptions; +const {compilerOptions: {target}} = require('../tsconfig.json'); + const diplodocExtensions = Object.keys(dependencies).filter((name) => name.startsWith('@diplodoc')); +for (const [type, path] of Object.entries(client.src)) { + const dst = client.dst[type]; + + shell.cp('-f', path, dst); +} + const commonConfig = { tsconfig: './tsconfig.json', packages: 'external', diff --git a/scripts/client.js b/scripts/client.js new file mode 100644 index 00000000..21d8ce1b --- /dev/null +++ b/scripts/client.js @@ -0,0 +1,21 @@ +const path = require('path'); + +const CLIENT_PATH = path.dirname(require.resolve('@diplodoc/client')); +const BUILD_PATH = 'build'; +const BUNDLE_JS_FILENAME = 'app.client.js'; +const BUNDLE_CSS_FILENAME = 'app.client.css'; + +const src = (target) => path.resolve(CLIENT_PATH, target); +const dst = (target) => path.resolve(BUILD_PATH, target); + + +module.exports = { + dst: { + js: dst(BUNDLE_JS_FILENAME), + css: dst(BUNDLE_CSS_FILENAME), + }, + src: { + js: src(BUNDLE_JS_FILENAME), + css: src(BUNDLE_CSS_FILENAME), + }, +}; diff --git a/src/steps/processAssets.ts b/src/steps/processAssets.ts index 3e3f3c61..dc769343 100644 --- a/src/steps/processAssets.ts +++ b/src/steps/processAssets.ts @@ -1,8 +1,7 @@ import walkSync from 'walk-sync'; -import {resolve} from 'path'; import shell from 'shelljs'; -import {BUNDLE_JS_FILENAME, BUNDLE_CSS_FILENAME, BUILD_FOLDER_PATH} from '../constants'; +import client from '../../scripts/client'; import {ArgvService} from '../services'; import {copyFiles} from '../utils'; @@ -28,11 +27,10 @@ export function processAssets(outputBundlePath: string) { copyFiles(inputFolderPath, outputFolderPath, assetFilePath); - const src = (file: string) => resolve(BUILD_FOLDER_PATH, file); - const dst = (file: string) => resolve(outputBundlePath, file); - /* Copy js bundle to user' output folder */ shell.mkdir('-p', outputBundlePath); - shell.cp(src(BUNDLE_JS_FILENAME), dst(BUNDLE_JS_FILENAME)); - shell.cp(src(BUNDLE_CSS_FILENAME), dst(BUNDLE_CSS_FILENAME)); + + for (const path of Object.values(client.dst)) { + shell.cp(path, outputBundlePath); + } } diff --git a/src/steps/processPages.ts b/src/steps/processPages.ts index 9bbec2a3..5feb2996 100644 --- a/src/steps/processPages.ts +++ b/src/steps/processPages.ts @@ -58,7 +58,7 @@ export async function processPages(outputBundlePath: string): Promise { })); if (singlePage) { - await saveSinglePages(outputBundlePath); + await saveSinglePages(); } } @@ -97,10 +97,9 @@ function getPathData( return pathData; } -async function saveSinglePages(outputBundlePath: string) { +async function saveSinglePages() { const { input: inputFolderPath, - output: outputFolderPath, lang, resources, } = ArgvService.getConfig(); @@ -133,13 +132,10 @@ async function saveSinglePages(outputBundlePath: string) { lang: lang || Lang.RU, }; - const outputTocDir = resolve(outputFolderPath, relative(inputFolderPath, tocDir)); - const relativeOutputBundlePath = relative(outputTocDir, outputBundlePath); - // Save the full single page for viewing locally const singlePageFn = join(tocDir, SINGLE_PAGE_FILENAME); const singlePageDataFn = join(tocDir, SINGLE_PAGE_DATA_FILENAME); - const singlePageContent = generateStaticMarkup(pageData, relativeOutputBundlePath); + const singlePageContent = generateStaticMarkup(pageData); writeFileSync(singlePageFn, singlePageContent); writeFileSync(singlePageDataFn, JSON.stringify(pageData)); diff --git a/src/utils/markup.ts b/src/utils/markup.ts index 7a612f22..f81f0cba 100644 --- a/src/utils/markup.ts +++ b/src/utils/markup.ts @@ -1,17 +1,18 @@ import {platform} from 'process'; -import {BUNDLE_JS_FILENAME, BUNDLE_CSS_FILENAME, CUSTOM_STYLE, Platforms, ResourceType} from '../constants'; +import {CUSTOM_STYLE, Platforms, ResourceType} from '../constants'; import {SinglePageResult, Resources} from '../models'; import {ArgvService, PluginService} from '../services'; import {preprocessPageHtmlForSinglePage} from './singlePage'; import {render, DocInnerProps, DocPageData} from '@diplodoc/client'; +import client from '../../scripts/client'; export interface TitleMeta { title?: string; } export type Meta = TitleMeta & Resources; -export function generateStaticMarkup(props: DocInnerProps, pathToBundle: string): string { +export function generateStaticMarkup(props: DocInnerProps): string { const {title: metaTitle, style, script} = props.data.meta as Meta || {}; const {title: tocTitle} = props.data.toc; const {title: pageTitle} = props.data; @@ -40,7 +41,7 @@ export function generateStaticMarkup(props: DocInnerProps, pathToBu height: 100vh; } - + ${PluginService.getHeadContent()} ${resources} @@ -50,7 +51,7 @@ export function generateStaticMarkup(props: DocInnerProps, pathToBu window.STATIC_CONTENT = ${staticContent} window.__DATA__ = ${JSON.stringify(props)}; - + `;