chore: add script "copy-doc-assets"
This commit is contained in:
parent
41d3fc7c1f
commit
6007ca46f7
1 changed files with 29 additions and 0 deletions
29
packages/ui/scripts/copy-doc-assets.js
Normal file
29
packages/ui/scripts/copy-doc-assets.js
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
|
import { globby } from 'globby';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
const monoDocsRoot = fileURLToPath(new URL('../../../docs', import.meta.url));
|
||||||
|
const localDocsRoot = fileURLToPath(new URL('../docs', import.meta.url));
|
||||||
|
|
||||||
|
async function copyDocAssets() {
|
||||||
|
// Folders generated by Rocket
|
||||||
|
const oldDestinations = await globby([`${monoDocsRoot}/**/**/*.{js,cjs,mjs}`]);
|
||||||
|
|
||||||
|
for (const oldDestination of oldDestinations) {
|
||||||
|
const relPath = oldDestination.replace(monoDocsRoot, '');
|
||||||
|
|
||||||
|
// don't handle private folders and Rocket specifics
|
||||||
|
if (relPath.startsWith('/_') || oldDestination.endsWith('11tydata.cjs')) {
|
||||||
|
// eslint-disable-next-line no-continue
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const newDestination = `${localDocsRoot}${relPath}`;
|
||||||
|
|
||||||
|
await fs.promises.mkdir(path.dirname(newDestination), { recursive: true });
|
||||||
|
fs.promises.copyFile(oldDestination, newDestination);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
copyDocAssets();
|
||||||
Loading…
Reference in a new issue