@windwalker-io/core 4.0.6 → 4.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/install-vendors.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import fs from 'fs';
|
|
|
14
14
|
export async function installVendors(npmVendors, composerVendors = [], to = 'www/assets/vendor') {
|
|
15
15
|
const root = to;
|
|
16
16
|
let vendors = npmVendors;
|
|
17
|
+
const action = process.env.INSTALL_VENDOR === 'hard' ? 'Copy' : 'Link';
|
|
17
18
|
|
|
18
19
|
if (!fs.existsSync(root)) {
|
|
19
20
|
fs.mkdirSync(root);
|
|
@@ -26,7 +27,7 @@ export async function installVendors(npmVendors, composerVendors = [], to = 'www
|
|
|
26
27
|
dirs.unshift(root);
|
|
27
28
|
|
|
28
29
|
dirs.forEach((dir) => {
|
|
29
|
-
|
|
30
|
+
deleteExists(dir);
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
vendors = findVendors().concat(vendors);
|
|
@@ -34,20 +35,28 @@ export async function installVendors(npmVendors, composerVendors = [], to = 'www
|
|
|
34
35
|
|
|
35
36
|
vendors.forEach((vendor) => {
|
|
36
37
|
if (fs.existsSync(`node_modules/${vendor}/`)) {
|
|
37
|
-
console.log(`[
|
|
38
|
-
|
|
38
|
+
console.log(`[${action} NPM] node_modules/${vendor}/ => ${root}/${vendor}/`);
|
|
39
|
+
doInstall(`node_modules/${vendor}/`, `${root}/${vendor}/`);
|
|
39
40
|
}
|
|
40
41
|
});
|
|
41
42
|
|
|
42
43
|
composerVendors.forEach((vendor) => {
|
|
43
44
|
if (fs.existsSync(`vendor/${vendor}/assets`)) {
|
|
44
|
-
console.log(`[
|
|
45
|
-
|
|
45
|
+
console.log(`[${action} Composer] vendor/${vendor}/assets => ${root}/${vendor}/`);
|
|
46
|
+
doInstall(`vendor/${vendor}/assets/`, `${root}/${vendor}/`);
|
|
46
47
|
}
|
|
47
48
|
});
|
|
48
49
|
|
|
49
|
-
console.log(`[
|
|
50
|
-
|
|
50
|
+
console.log(`[${action} Local] resources/assets/vendor/**/* => ${root}/`);
|
|
51
|
+
doInstall('resources/assets/vendor/*', `${root}/`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function doInstall(source, dest) {
|
|
55
|
+
if (process.env.INSTALL_VENDOR === 'hard') {
|
|
56
|
+
copy(source + '/**/*', dest);
|
|
57
|
+
} else {
|
|
58
|
+
src(source).pipe(symlink(dest));
|
|
59
|
+
}
|
|
51
60
|
}
|
|
52
61
|
|
|
53
62
|
function findVendors() {
|
|
@@ -66,13 +75,20 @@ function findVendors() {
|
|
|
66
75
|
return [ ...new Set(vendors) ];
|
|
67
76
|
}
|
|
68
77
|
|
|
69
|
-
function
|
|
70
|
-
|
|
71
|
-
|
|
78
|
+
function deleteExists(dir) {
|
|
79
|
+
if (!fs.existsSync(dir)) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const subDirs = fs.readdirSync(dir, { withFileTypes: true });
|
|
72
84
|
|
|
73
|
-
|
|
74
|
-
|
|
85
|
+
subDirs.forEach((subDir) => {
|
|
86
|
+
if (subDir.isSymbolicLink() || subDir.isFile()) {
|
|
87
|
+
fs.unlinkSync(path.join(dir, subDir.name));
|
|
88
|
+
} else if (subDir.isDirectory()) {
|
|
89
|
+
deleteExists(path.join(dir, subDir.name));
|
|
90
|
+
}
|
|
75
91
|
});
|
|
76
92
|
|
|
77
|
-
fs.
|
|
93
|
+
fs.rmdirSync(dir);
|
|
78
94
|
}
|