-
Notifications
You must be signed in to change notification settings - Fork 2
/
docs.js
73 lines (61 loc) · 1.52 KB
/
docs.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const { argv } = require("yargs");
const copyfiles = require("copyfiles");
const { exec } = require("child_process");
const sitePath = stripTrailingSlash(argv.sitePath);
const siteAssetsPath = `${sitePath}/src/assets`;
function start() {
copyMarkdownFiles();
}
function onMarkDownCopied() {
console.log("INFO: Component documenation copied");
buildListOfDocs();
}
function onListOfDocsBuilt() {
console.log("INFO: Component documenation list built");
copyDists();
}
function onDistsCopied() {
console.log("INFO: Dist folders copied");
copyLoaders();
}
function onLoadersCopied() {
console.log("INFO: Loader folders copied");
console.log("SUCCESS: Site documentation built.");
}
function copyMarkdownFiles() {
copyfiles(
["packages/components/**/*.story.md", `${siteAssetsPath}/docs`],
true,
onMarkDownCopied
);
}
function buildListOfDocs() {
exec(
`ls ${siteAssetsPath}/docs > ${siteAssetsPath}/docs/components-list.txt`,
(err, stdout, stderr) => {
if (err) {
console.error(err);
} else {
onListOfDocsBuilt();
}
}
);
}
function copyDists() {
copyfiles(
["packages/components/**/dist/**", `${siteAssetsPath}/libs/syz`],
{ up: 2, exclude: "**/node_modules/**" },
onDistsCopied
);
}
function copyLoaders() {
copyfiles(
["packages/components/**/loader/**", `${siteAssetsPath}/libs/syz`],
{ up: 2, exclude: "**/node_modules/**" },
onLoadersCopied
);
}
function stripTrailingSlash(path) {
return path.replace(/\/+$/, "");
}
start();