@windwalker-io/core 4.2.4 → 4.2.6
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/LICENSE +19 -19
- package/dist/debugger/debugger-BOPm1u5O.js +2 -0
- package/dist/debugger/debugger.js +16 -17
- package/dist/debugger/vue-animate.min-DEk1PxEb.js +2 -0
- package/dist/debugger-console.css +1 -6
- package/dist/next.js +38 -37
- package/package.json +2 -2
- package/src/asset-bundler.mjs +114 -114
- package/src/debugger/types/global.d.js +2 -2
- package/src/index.mjs +10 -11
- package/src/legacy/4.0/js-sync.mjs +74 -74
- package/src/next/fusion/index.ts +2 -2
- package/src/next/fusion/plugins/assets.ts +29 -29
- package/src/next/fusion/plugins/index.ts +3 -3
- package/src/next/fusion/plugins/systemjs.ts +66 -66
- package/src/next/fusion/processors/cloneAssets.ts +81 -81
- package/src/next/fusion/processors/cssModulize.ts +128 -127
- package/src/next/fusion/processors/index.ts +4 -4
- package/src/next/fusion/processors/installVendors.ts +184 -178
- package/src/next/fusion/processors/jsModulize.ts +306 -300
- package/src/next/index.ts +2 -2
- package/src/next/utilities/asset-sync.ts +47 -47
- package/src/next/utilities/crypto.ts +11 -11
- package/src/next/utilities/fs.ts +61 -61
- package/src/next/utilities/index.ts +5 -5
- package/src/next/utilities/modules.ts +17 -17
- package/dist/debugger/debugger-ChQADeB6.js +0 -2
- package/dist/debugger/vue-animate.min-BkEL-t1R.js +0 -9
|
@@ -1,127 +1,128 @@
|
|
|
1
|
-
import { type ConfigBuilder, css, type ProcessorInterface, type ProcessorPreview } from '@windwalker-io/fusion-next';
|
|
2
|
-
import { WatchTask } from '@windwalker-io/fusion-next/src/types';
|
|
3
|
-
import fg from 'fast-glob';
|
|
4
|
-
import fs from 'fs-extra';
|
|
5
|
-
import { parse } from 'node-html-parser';
|
|
6
|
-
import { normalize, resolve } from 'node:path';
|
|
7
|
-
import { findModules, findPackages, stripUrlQuery } from '../../utilities';
|
|
8
|
-
|
|
9
|
-
export function cssModulize(entry: string, dest: string) {
|
|
10
|
-
return new CssModulizeProcessor(css(entry, dest));
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface CssModulizeDeepOptions {
|
|
14
|
-
mergeCss?: boolean;
|
|
15
|
-
parseBlades?: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function cssModulizeDeep(stage: string, entry: string, dest: string, options: CssModulizeDeepOptions = {}) {
|
|
19
|
-
const processor = cssModulize(entry, dest);
|
|
20
|
-
|
|
21
|
-
if (options.mergeCss ?? true) {
|
|
22
|
-
processor.mergeCss(findModules(`${stage}/**/assets/*.scss`));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (options.parseBlades ?? true) {
|
|
26
|
-
processor.parseBlades(
|
|
27
|
-
findModules(`${stage}/**/*.blade.php`),
|
|
28
|
-
findPackages('views/**/*.blade.php'),
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return processor;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
class CssModulizeProcessor implements ProcessorInterface {
|
|
36
|
-
|
|
37
|
-
constructor(
|
|
38
|
-
protected processor: ReturnType<typeof css>,
|
|
39
|
-
protected bladePatterns: string[] = [],
|
|
40
|
-
protected cssPatterns: string[] = []
|
|
41
|
-
) {
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
parseBlades(...bladePatterns: (string[] | string)[]) {
|
|
46
|
-
this.bladePatterns = this.bladePatterns.concat(bladePatterns.flat());
|
|
47
|
-
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
mergeCss(...css: (string[] | string)[]) {
|
|
52
|
-
this.cssPatterns = this.cssPatterns.concat(css.flat());
|
|
53
|
-
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
config(taskName: string, builder: ConfigBuilder) {
|
|
58
|
-
const tasks = this.processor.config(taskName, builder);
|
|
59
|
-
const task = tasks[0];
|
|
60
|
-
const inputFile = resolve(task.input);
|
|
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
|
-
.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
1
|
+
import { type ConfigBuilder, css, type ProcessorInterface, type ProcessorPreview } from '@windwalker-io/fusion-next';
|
|
2
|
+
import { WatchTask } from '@windwalker-io/fusion-next/src/types';
|
|
3
|
+
import fg from 'fast-glob';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import { parse } from 'node-html-parser';
|
|
6
|
+
import { normalize, resolve } from 'node:path';
|
|
7
|
+
import { findModules, findPackages, stripUrlQuery } from '../../utilities';
|
|
8
|
+
|
|
9
|
+
export function cssModulize(entry: string, dest: string) {
|
|
10
|
+
return new CssModulizeProcessor(css(entry, dest));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface CssModulizeDeepOptions {
|
|
14
|
+
mergeCss?: boolean;
|
|
15
|
+
parseBlades?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function cssModulizeDeep(stage: string, entry: string, dest: string, options: CssModulizeDeepOptions = {}) {
|
|
19
|
+
const processor = cssModulize(entry, dest);
|
|
20
|
+
|
|
21
|
+
if (options.mergeCss ?? true) {
|
|
22
|
+
processor.mergeCss(findModules(`${stage}/**/assets/*.scss`));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (options.parseBlades ?? true) {
|
|
26
|
+
processor.parseBlades(
|
|
27
|
+
findModules(`${stage}/**/*.blade.php`),
|
|
28
|
+
findPackages('views/**/*.blade.php'),
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return processor;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
class CssModulizeProcessor implements ProcessorInterface {
|
|
36
|
+
|
|
37
|
+
constructor(
|
|
38
|
+
protected processor: ReturnType<typeof css>,
|
|
39
|
+
protected bladePatterns: string[] = [],
|
|
40
|
+
protected cssPatterns: string[] = []
|
|
41
|
+
) {
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
parseBlades(...bladePatterns: (string[] | string)[]) {
|
|
46
|
+
this.bladePatterns = this.bladePatterns.concat(bladePatterns.flat());
|
|
47
|
+
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
mergeCss(...css: (string[] | string)[]) {
|
|
52
|
+
this.cssPatterns = this.cssPatterns.concat(css.flat());
|
|
53
|
+
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
config(taskName: string, builder: ConfigBuilder) {
|
|
58
|
+
const tasks = this.processor.config(taskName, builder);
|
|
59
|
+
const task = tasks[0];
|
|
60
|
+
const inputFile = resolve(task.input);
|
|
61
|
+
|
|
62
|
+
builder.loadCallbacks.push((src, options) => {
|
|
63
|
+
const file = stripUrlQuery(src);
|
|
64
|
+
|
|
65
|
+
if (normalize(file) === inputFile) {
|
|
66
|
+
// get blade styles and add watches
|
|
67
|
+
const bladeFiles = fg.globSync(this.bladePatterns);
|
|
68
|
+
|
|
69
|
+
for (const file of bladeFiles) {
|
|
70
|
+
const realpath = resolve(file).replace(/\\/g, '/');
|
|
71
|
+
builder.addWatch(realpath, {
|
|
72
|
+
file: realpath,
|
|
73
|
+
moduleFile: inputFile,
|
|
74
|
+
updateType: 'css-update',
|
|
75
|
+
} satisfies WatchTask);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const patterns = fg.globSync(
|
|
79
|
+
this.cssPatterns.map((v) => resolve(v))
|
|
80
|
+
.map(v => v.replace(/\\/g, '/'))
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const imports = patterns
|
|
84
|
+
.map((pattern) => `@import "${pattern}";`)
|
|
85
|
+
.concat(this.parseStylesFromBlades(bladeFiles))
|
|
86
|
+
.join('\n');
|
|
87
|
+
|
|
88
|
+
let main = fs.readFileSync(file, 'utf-8');
|
|
89
|
+
|
|
90
|
+
main += `\n\n${imports}\n`;
|
|
91
|
+
|
|
92
|
+
return main;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
parseStylesFromBlades(files: string[]) {
|
|
100
|
+
return files.map((file) => {
|
|
101
|
+
const bladeText = fs.readFileSync(file, 'utf8');
|
|
102
|
+
|
|
103
|
+
const html = parse(bladeText);
|
|
104
|
+
|
|
105
|
+
return html.querySelectorAll('style[type][data-macro],script[type][data-macro]')
|
|
106
|
+
.filter(
|
|
107
|
+
(el) => ['text/scss', 'text/css'].includes(el.getAttribute('type') || '')
|
|
108
|
+
)
|
|
109
|
+
.map((el) => {
|
|
110
|
+
const scope = el.getAttribute('data-scope');
|
|
111
|
+
|
|
112
|
+
if (scope) {
|
|
113
|
+
return `${scope} {
|
|
114
|
+
${el.innerHTML}
|
|
115
|
+
}`;
|
|
116
|
+
} else {
|
|
117
|
+
return el.innerHTML;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
})
|
|
121
|
+
.filter((c) => c.length > 0)
|
|
122
|
+
.flat();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
preview(): ProcessorPreview[] {
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { cssModulize, cssModulizeDeep, type CssModulizeDeepOptions } from './cssModulize';
|
|
2
|
-
export { jsModulize, jsModulizeDeep, type JsModulizeOptions, type JsModulizeDeepOptions } from './jsModulize';
|
|
3
|
-
export { installVendors } from './installVendors';
|
|
4
|
-
export { cloneAssets } from './cloneAssets';
|
|
1
|
+
export { cssModulize, cssModulizeDeep, type CssModulizeDeepOptions } from './cssModulize';
|
|
2
|
+
export { jsModulize, jsModulizeDeep, type JsModulizeOptions, type JsModulizeDeepOptions } from './jsModulize';
|
|
3
|
+
export { installVendors } from './installVendors';
|
|
4
|
+
export { cloneAssets } from './cloneAssets';
|
|
@@ -1,178 +1,184 @@
|
|
|
1
|
-
import { callbackAfterBuild, copyGlob, symlink } from '@windwalker-io/fusion-next';
|
|
2
|
-
import fs from 'fs-extra';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { loadJson } from '../../utilities';
|
|
5
|
-
|
|
6
|
-
export function installVendors(
|
|
7
|
-
npmVendors: string[] = [],
|
|
8
|
-
to: string = 'www/assets/vendor',
|
|
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
|
-
dirs.
|
|
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
|
-
//
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
.map((
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
1
|
+
import fusion, { callbackAfterBuild, copyGlob, symlink, builder } from '@windwalker-io/fusion-next';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { loadJson } from '../../utilities';
|
|
5
|
+
|
|
6
|
+
export function installVendors(
|
|
7
|
+
npmVendors: string[] = [],
|
|
8
|
+
to: string = 'www/assets/vendor',
|
|
9
|
+
) {
|
|
10
|
+
builder.merge({
|
|
11
|
+
build: {
|
|
12
|
+
manifest: false
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return callbackAfterBuild(() => findAndInstall(npmVendors, to));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
enum InstallAction {
|
|
20
|
+
LINK = 'Link',
|
|
21
|
+
COPY = 'Copy',
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function findAndInstall(npmVendors: string[] = [], to = 'www/assets/vendor') {
|
|
25
|
+
const root = to;
|
|
26
|
+
let vendors = npmVendors;
|
|
27
|
+
const action = process.env.INSTALL_VENDOR === 'hard' ? InstallAction.COPY : InstallAction.LINK;
|
|
28
|
+
|
|
29
|
+
console.log("");
|
|
30
|
+
|
|
31
|
+
if (!fs.existsSync(root)) {
|
|
32
|
+
fs.mkdirSync(root);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const dirs = fs.readdirSync(root, { withFileTypes: true })
|
|
36
|
+
.filter(d => d.isDirectory())
|
|
37
|
+
.map(dir => path.join(root, dir.name));
|
|
38
|
+
|
|
39
|
+
dirs.unshift(root);
|
|
40
|
+
|
|
41
|
+
dirs.forEach((dir) => {
|
|
42
|
+
deleteExists(dir);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const composerJsons = getInstalledComposerVendors()
|
|
46
|
+
.map((cv) => `vendor/${cv}/composer.json`)
|
|
47
|
+
.map((file) => loadJson(file))
|
|
48
|
+
.filter((composerJson) => composerJson?.extra?.windwalker != null);
|
|
49
|
+
|
|
50
|
+
// Install npm vendors
|
|
51
|
+
vendors = findNpmVendors(composerJsons).concat(vendors);
|
|
52
|
+
vendors = [...new Set(vendors)];
|
|
53
|
+
|
|
54
|
+
for (const vendor of vendors) {
|
|
55
|
+
const source = `node_modules/${vendor}/`;
|
|
56
|
+
if (fs.existsSync(source)) {
|
|
57
|
+
console.log(`[${action} NPM] node_modules/${vendor}/ => ${root}/${vendor}/`);
|
|
58
|
+
doInstall(source, `${root}/${vendor}/`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Install composer packages assets
|
|
63
|
+
for (const composerJson of composerJsons) {
|
|
64
|
+
const vendorName = composerJson.name;
|
|
65
|
+
|
|
66
|
+
let assets = composerJson?.extra?.windwalker?.assets?.link;
|
|
67
|
+
|
|
68
|
+
if (!assets) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!assets.endsWith('/')) {
|
|
73
|
+
assets += '/';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (fs.existsSync(`vendor/${vendorName}/${assets}`)) {
|
|
77
|
+
console.log(`[${action} Composer] vendor/${vendorName}/${assets} => ${root}/${vendorName}/`);
|
|
78
|
+
doInstall(`vendor/${vendorName}/${assets}`, `${root}/${vendorName}/`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Install legacy packages assets
|
|
83
|
+
// legacyComposerVendors.forEach((vendorName) => {
|
|
84
|
+
// console.log(vendorName, fs.existsSync(`vendor/${vendorName}/assets`));
|
|
85
|
+
// if (fs.existsSync(`vendor/${vendorName}/assets`)) {
|
|
86
|
+
// console.log(`[${action} Composer] vendor/${vendorName}/assets/ => ${root}/${vendorName}/`);
|
|
87
|
+
// doInstall(`vendor/${vendorName}/assets/`, `${root}/${vendorName}/`);
|
|
88
|
+
// }
|
|
89
|
+
// });
|
|
90
|
+
|
|
91
|
+
// Install local saved vendors
|
|
92
|
+
const staticVendorDir = 'resources/assets/vendor/';
|
|
93
|
+
|
|
94
|
+
if (fs.existsSync(staticVendorDir)) {
|
|
95
|
+
const staticVendors = fs.readdirSync(staticVendorDir);
|
|
96
|
+
|
|
97
|
+
for (const staticVendor of staticVendors) {
|
|
98
|
+
if (staticVendor.startsWith('@')) {
|
|
99
|
+
const subVendors = fs.readdirSync(staticVendorDir + staticVendor);
|
|
100
|
+
|
|
101
|
+
for (const subVendor of subVendors) {
|
|
102
|
+
const subVendorName = staticVendor + '/' + subVendor;
|
|
103
|
+
const source = staticVendorDir + subVendorName + '/';
|
|
104
|
+
|
|
105
|
+
if (fs.existsSync(source)) {
|
|
106
|
+
console.log(`[${action} Local] resources/assets/vendor/${subVendorName}/ => ${root}/${subVendorName}/`);
|
|
107
|
+
doInstall(source, `${root}/${subVendorName}/`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
let source = staticVendorDir + staticVendor;
|
|
112
|
+
|
|
113
|
+
if (fs.existsSync(source)) {
|
|
114
|
+
console.log(`[${action} Local] resources/assets/vendor/${staticVendor}/ => ${root}/${staticVendor}/`);
|
|
115
|
+
doInstall(source, `${root}/${staticVendor}/`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async function doInstall(source: string, dest: string) {
|
|
123
|
+
if (process.env.INSTALL_VENDOR === 'hard') {
|
|
124
|
+
await copyGlob(source + '/**/*', dest);
|
|
125
|
+
} else {
|
|
126
|
+
await symlink(source, dest);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function findNpmVendors(composerJsons: any[] = []) {
|
|
131
|
+
const pkg = path.resolve(process.cwd(), 'package.json');
|
|
132
|
+
const pkgJson = loadJson(pkg);
|
|
133
|
+
|
|
134
|
+
let vendors = Object.keys(pkgJson.devDependencies || {})
|
|
135
|
+
.concat(Object.keys(pkgJson.dependencies || {}))
|
|
136
|
+
.map(id => `node_modules/${id}/package.json`)
|
|
137
|
+
.map((file) => loadJson(file))
|
|
138
|
+
.filter(pkgJson => pkgJson?.windwalker != null)
|
|
139
|
+
.map(pkgJson => pkgJson?.windwalker.vendors || [])
|
|
140
|
+
.flat();
|
|
141
|
+
|
|
142
|
+
const vendorsFromComposer = composerJsons
|
|
143
|
+
.map((composerJson) => {
|
|
144
|
+
return [
|
|
145
|
+
...composerJson?.extra?.windwalker?.asset_vendors || [],
|
|
146
|
+
...composerJson?.extra?.windwalker?.assets?.exposes || [],
|
|
147
|
+
...Object.keys(composerJson?.extra?.windwalker?.assets?.vendors || {})
|
|
148
|
+
];
|
|
149
|
+
})
|
|
150
|
+
.flat();
|
|
151
|
+
|
|
152
|
+
return [...new Set(vendors.concat(vendorsFromComposer))];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function getInstalledComposerVendors() {
|
|
156
|
+
const composerFile = path.resolve(process.cwd(), 'composer.json');
|
|
157
|
+
const composerJson = loadJson(composerFile);
|
|
158
|
+
|
|
159
|
+
return [
|
|
160
|
+
...new Set(
|
|
161
|
+
Object.keys(composerJson['require'] || {})
|
|
162
|
+
.concat(Object.keys(composerJson['require-dev'] || {}))
|
|
163
|
+
)
|
|
164
|
+
];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function deleteExists(dir: string) {
|
|
168
|
+
if (!fs.existsSync(dir)) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const subDirs = fs.readdirSync(dir, { withFileTypes: true });
|
|
173
|
+
|
|
174
|
+
for (const subDir of subDirs) {
|
|
175
|
+
if (subDir.isSymbolicLink() || subDir.isFile()) {
|
|
176
|
+
fs.unlinkSync(path.join(dir, subDir.name));
|
|
177
|
+
} else if (subDir.isDirectory()) {
|
|
178
|
+
deleteExists(path.join(dir, subDir.name));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
fs.rmdirSync(dir);
|
|
183
|
+
}
|
|
184
|
+
|