-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpull.js
45 lines (39 loc) · 1.29 KB
/
pull.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Save this script as 'updateDocs.mjs'
import fs from "fs";
import fsExtra from "fs-extra";
import path from "path";
import { execSync } from "child_process";
import { fileURLToPath } from "url";
// Get __dirname equivalent in ES Modules
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
try {
// Pull the latest changes for the 'ui' submodule
console.log("Updating submodule ui/ to the latest version...");
execSync("git submodule update --remote ui/", { stdio: "inherit" });
// Remove the 'docs/' folder if it exists
const docsPath = path.join(__dirname, "docs");
if (fs.existsSync(docsPath)) {
console.log("Removing existing docs/ folder...");
fs.rmSync(docsPath, { recursive: true, force: true });
}
// Copy 'ui/apps/www/content/docs/components/' to 'docs/'
console.log("Copying ui/apps/www/content/docs/components/ to docs/...");
const srcPath = path.join(
__dirname,
"ui",
"apps",
"www",
"content",
"docs",
"components"
);
if (!fs.existsSync(srcPath)) {
throw new Error(`Source path does not exist: ${srcPath}`);
}
fsExtra.copySync(srcPath, docsPath);
console.log("Operation completed successfully.");
} catch (error) {
console.error("An error occurred:", error.message);
process.exit(1);
}