Skip to content

Commit ae43af0

Browse files
committed
feat: implement native fs
1 parent 60893de commit ae43af0

3 files changed

Lines changed: 7 additions & 9 deletions

File tree

scripts/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
},
1111
"devDependencies": {
1212
"@jest/globals": "29.7.0",
13-
"@types/fs-extra": "11.0.4",
1413
"@types/jest": "29.5.12",
15-
"fs-extra": "11.2.0",
1614
"jest": "29.7.0",
1715
"jest-environment-node": "29.7.0",
1816
"ts-jest": "29.1.2",

scripts/src/copyStaticTo.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Docusaurus only serves static assets from each site's own /static directory,
44
// so shared fonts/images must be copied explicitly into each site.
55

6-
import fs from "fs-extra";
6+
import fs from "fs";
77
import path from "path";
88

99
// Simple path resolution: scripts/src -> repo root -> packages/common-config/static/common
@@ -28,10 +28,10 @@ if (!fs.existsSync(from)) {
2828
}
2929

3030
// Ensure the target directory exists (create it if it doesn't)
31-
fs.ensureDirSync(toPath);
31+
fs.mkdirSync(toPath, { recursive: true });
3232

3333
try {
34-
fs.copySync(from, toPath, { overwrite: true });
34+
fs.cpSync(from, toPath, { recursive: true, force: true });
3535
console.log(`✅ Copied static assets to ${toPath}`);
3636
} catch (error) {
3737
console.error(`❌ Failed to copy static assets: ${error}`);

scripts/src/create-handbook.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Usage: ts-node scripts/create-handbook.ts <site-name>
44
*/
55

6-
import fs from "fs-extra";
6+
import fs from "fs";
77
import path from "path";
88

99
// Simple path resolution: scripts/src -> repo root -> sites
@@ -35,14 +35,14 @@ if (fs.existsSync(targetDir)) {
3535

3636
try {
3737
// 1. Copy template to new site
38-
fs.copySync(TEMPLATE_DIR, targetDir);
38+
fs.cpSync(TEMPLATE_DIR, targetDir, { recursive: true });
3939

4040
// 2. Update package.json with the new site name and correct copy-static script
4141
const packageJsonPath = path.join(targetDir, "package.json");
42-
const packageJson = fs.readJsonSync(packageJsonPath);
42+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
4343
packageJson.name = `${siteName}`;
4444
packageJson.scripts["copy-static"] = `pnpm --filter @handbook/scripts copy-static sites/${siteName}/static/common`;
45-
fs.writeJsonSync(packageJsonPath, packageJson, { spaces: 2 });
45+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
4646

4747
console.log(`✅ Created new handbook site: ${siteName}`);
4848
console.log(`📁 Location: ${targetDir}`);

0 commit comments

Comments
 (0)