forked from aris-creator/jancok
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepareSFUIRepoClone.js
85 lines (77 loc) · 1.92 KB
/
prepareSFUIRepoClone.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
74
75
76
77
78
79
80
81
82
83
84
85
/**
* Setup SFUI develop branch and locally publish dependencies
*/
const execa = require("execa");
const path = require("path");
const fs = require("fs-extra");
const tempDir = path.resolve(__dirname, "../temp");
const repoDir = `${tempDir}/storefront-ui`;
const vuePackageDir = `${repoDir}/packages/vue`;
const sharedPackageDir = `${repoDir}/packages/shared`;
const themeDir = path.resolve(__dirname, "../packages/default-theme");
const createIndexScriptPath = `${vuePackageDir}/scripts/create-index-files.js`;
const setScssScriptPath = `${vuePackageDir}/scripts/set-styles-variables-root-path.js`;
async function run() {
/**
* Clone develop SFUI
*/
if (fs.existsSync(repoDir)) {
fs.removeSync(repoDir);
}
await execa(
"git",
[
"clone",
"--single-branch",
"--branch",
"develop",
"https://github.com/DivanteLtd/storefront-ui",
repoDir
],
{
stdio: "inherit"
}
);
/**
* Init repo
*/
await execa("yarn", [], {
stdio: "inherit",
cwd: repoDir
});
// When script added
// await execa("yarn", ["prepublish"], {
// stdio: "inherit",
// cwd: vuePackageDir
// });
// else
const { createIndexFiles } = require(createIndexScriptPath);
const { setStylesVariablesRootPath } = require(setScssScriptPath);
function runPrePublish() {
createIndexFiles();
setStylesVariablesRootPath();
}
runPrePublish();
// Publish shared pashage
await execa("npx", ["yalc", "publish"], {
stdio: "inherit",
cwd: sharedPackageDir
});
// Publish vue package
await execa("npx", ["yalc", "publish"], {
stdio: "inherit",
cwd: vuePackageDir
});
/**
* Add vue and shared package into theme
*/
await execa("npx", ["yalc", "add", "@storefront-ui/vue"], {
stdio: "inherit",
cwd: themeDir
});
await execa("npx", ["yalc", "add", "@storefront-ui/shared"], {
stdio: "inherit",
cwd: themeDir
});
}
run();