@windwalker-io/core 4.2.3 → 4.2.5
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 +11 -11
- package/dist/debugger/vue-animate.min-CgShoK26.js +9 -0
- package/dist/next.js +2 -2
- 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 +127 -127
- package/src/next/fusion/processors/index.ts +4 -4
- package/src/next/fusion/processors/installVendors.ts +178 -178
- package/src/next/fusion/processors/jsModulize.ts +300 -296
- 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,178 +1,178 @@
|
|
|
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
|
-
return callbackAfterBuild(() => findAndInstall(npmVendors, to));
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
enum InstallAction {
|
|
14
|
-
LINK = 'Link',
|
|
15
|
-
COPY = 'Copy',
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export async function findAndInstall(npmVendors: string[] = [], to = 'www/assets/vendor') {
|
|
19
|
-
const root = to;
|
|
20
|
-
let vendors = npmVendors;
|
|
21
|
-
const action = process.env.INSTALL_VENDOR === 'hard' ? InstallAction.COPY : InstallAction.LINK;
|
|
22
|
-
|
|
23
|
-
console.log("");
|
|
24
|
-
|
|
25
|
-
if (!fs.existsSync(root)) {
|
|
26
|
-
fs.mkdirSync(root);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const dirs = fs.readdirSync(root, { withFileTypes: true })
|
|
30
|
-
.filter(d => d.isDirectory())
|
|
31
|
-
.map(dir => path.join(root, dir.name));
|
|
32
|
-
|
|
33
|
-
dirs.unshift(root);
|
|
34
|
-
|
|
35
|
-
dirs.forEach((dir) => {
|
|
36
|
-
deleteExists(dir);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const composerJsons = getInstalledComposerVendors()
|
|
40
|
-
.map((cv) => `vendor/${cv}/composer.json`)
|
|
41
|
-
.map((file) => loadJson(file))
|
|
42
|
-
.filter((composerJson) => composerJson?.extra?.windwalker != null);
|
|
43
|
-
|
|
44
|
-
// Install npm vendors
|
|
45
|
-
vendors = findNpmVendors(composerJsons).concat(vendors);
|
|
46
|
-
vendors = [...new Set(vendors)];
|
|
47
|
-
|
|
48
|
-
for (const vendor of vendors) {
|
|
49
|
-
const source = `node_modules/${vendor}/`;
|
|
50
|
-
if (fs.existsSync(source)) {
|
|
51
|
-
console.log(`[${action} NPM] node_modules/${vendor}/ => ${root}/${vendor}/`);
|
|
52
|
-
doInstall(source, `${root}/${vendor}/`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Install composer packages assets
|
|
57
|
-
for (const composerJson of composerJsons) {
|
|
58
|
-
const vendorName = composerJson.name;
|
|
59
|
-
|
|
60
|
-
let assets = composerJson?.extra?.windwalker?.assets?.link;
|
|
61
|
-
|
|
62
|
-
if (!assets) {
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (!assets.endsWith('/')) {
|
|
67
|
-
assets += '/';
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (fs.existsSync(`vendor/${vendorName}/${assets}`)) {
|
|
71
|
-
console.log(`[${action} Composer] vendor/${vendorName}/${assets} => ${root}/${vendorName}/`);
|
|
72
|
-
doInstall(`vendor/${vendorName}/${assets}`, `${root}/${vendorName}/`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Install legacy packages assets
|
|
77
|
-
// legacyComposerVendors.forEach((vendorName) => {
|
|
78
|
-
// console.log(vendorName, fs.existsSync(`vendor/${vendorName}/assets`));
|
|
79
|
-
// if (fs.existsSync(`vendor/${vendorName}/assets`)) {
|
|
80
|
-
// console.log(`[${action} Composer] vendor/${vendorName}/assets/ => ${root}/${vendorName}/`);
|
|
81
|
-
// doInstall(`vendor/${vendorName}/assets/`, `${root}/${vendorName}/`);
|
|
82
|
-
// }
|
|
83
|
-
// });
|
|
84
|
-
|
|
85
|
-
// Install local saved vendors
|
|
86
|
-
const staticVendorDir = 'resources/assets/vendor/';
|
|
87
|
-
|
|
88
|
-
if (fs.existsSync(staticVendorDir)) {
|
|
89
|
-
const staticVendors = fs.readdirSync(staticVendorDir);
|
|
90
|
-
|
|
91
|
-
for (const staticVendor of staticVendors) {
|
|
92
|
-
if (staticVendor.startsWith('@')) {
|
|
93
|
-
const subVendors = fs.readdirSync(staticVendorDir + staticVendor);
|
|
94
|
-
|
|
95
|
-
for (const subVendor of subVendors) {
|
|
96
|
-
const subVendorName = staticVendor + '/' + subVendor;
|
|
97
|
-
const source = staticVendorDir + subVendorName + '/';
|
|
98
|
-
|
|
99
|
-
if (fs.existsSync(source)) {
|
|
100
|
-
console.log(`[${action} Local] resources/assets/vendor/${subVendorName}/ => ${root}/${subVendorName}/`);
|
|
101
|
-
doInstall(source, `${root}/${subVendorName}/`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
} else {
|
|
105
|
-
let source = staticVendorDir + staticVendor;
|
|
106
|
-
|
|
107
|
-
if (fs.existsSync(source)) {
|
|
108
|
-
console.log(`[${action} Local] resources/assets/vendor/${staticVendor}/ => ${root}/${staticVendor}/`);
|
|
109
|
-
doInstall(source, `${root}/${staticVendor}/`);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
async function doInstall(source: string, dest: string) {
|
|
117
|
-
if (process.env.INSTALL_VENDOR === 'hard') {
|
|
118
|
-
await copyGlob(source + '/**/*', dest);
|
|
119
|
-
} else {
|
|
120
|
-
await symlink(source, dest);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function findNpmVendors(composerJsons: any[] = []) {
|
|
125
|
-
const pkg = path.resolve(process.cwd(), 'package.json');
|
|
126
|
-
const pkgJson = loadJson(pkg);
|
|
127
|
-
|
|
128
|
-
let vendors = Object.keys(pkgJson.devDependencies || {})
|
|
129
|
-
.concat(Object.keys(pkgJson.dependencies || {}))
|
|
130
|
-
.map(id => `node_modules/${id}/package.json`)
|
|
131
|
-
.map((file) => loadJson(file))
|
|
132
|
-
.filter(pkgJson => pkgJson?.windwalker != null)
|
|
133
|
-
.map(pkgJson => pkgJson?.windwalker.vendors || [])
|
|
134
|
-
.flat();
|
|
135
|
-
|
|
136
|
-
const vendorsFromComposer = composerJsons
|
|
137
|
-
.map((composerJson) => {
|
|
138
|
-
return [
|
|
139
|
-
...composerJson?.extra?.windwalker?.asset_vendors || [],
|
|
140
|
-
...composerJson?.extra?.windwalker?.assets?.exposes || [],
|
|
141
|
-
...Object.keys(composerJson?.extra?.windwalker?.assets?.vendors || {})
|
|
142
|
-
];
|
|
143
|
-
})
|
|
144
|
-
.flat();
|
|
145
|
-
|
|
146
|
-
return [...new Set(vendors.concat(vendorsFromComposer))];
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function getInstalledComposerVendors() {
|
|
150
|
-
const composerFile = path.resolve(process.cwd(), 'composer.json');
|
|
151
|
-
const composerJson = loadJson(composerFile);
|
|
152
|
-
|
|
153
|
-
return [
|
|
154
|
-
...new Set(
|
|
155
|
-
Object.keys(composerJson['require'] || {})
|
|
156
|
-
.concat(Object.keys(composerJson['require-dev'] || {}))
|
|
157
|
-
)
|
|
158
|
-
];
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function deleteExists(dir: string) {
|
|
162
|
-
if (!fs.existsSync(dir)) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const subDirs = fs.readdirSync(dir, { withFileTypes: true });
|
|
167
|
-
|
|
168
|
-
for (const subDir of subDirs) {
|
|
169
|
-
if (subDir.isSymbolicLink() || subDir.isFile()) {
|
|
170
|
-
fs.unlinkSync(path.join(dir, subDir.name));
|
|
171
|
-
} else if (subDir.isDirectory()) {
|
|
172
|
-
deleteExists(path.join(dir, subDir.name));
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
fs.rmdirSync(dir);
|
|
177
|
-
}
|
|
178
|
-
|
|
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
|
+
return callbackAfterBuild(() => findAndInstall(npmVendors, to));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
enum InstallAction {
|
|
14
|
+
LINK = 'Link',
|
|
15
|
+
COPY = 'Copy',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function findAndInstall(npmVendors: string[] = [], to = 'www/assets/vendor') {
|
|
19
|
+
const root = to;
|
|
20
|
+
let vendors = npmVendors;
|
|
21
|
+
const action = process.env.INSTALL_VENDOR === 'hard' ? InstallAction.COPY : InstallAction.LINK;
|
|
22
|
+
|
|
23
|
+
console.log("");
|
|
24
|
+
|
|
25
|
+
if (!fs.existsSync(root)) {
|
|
26
|
+
fs.mkdirSync(root);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const dirs = fs.readdirSync(root, { withFileTypes: true })
|
|
30
|
+
.filter(d => d.isDirectory())
|
|
31
|
+
.map(dir => path.join(root, dir.name));
|
|
32
|
+
|
|
33
|
+
dirs.unshift(root);
|
|
34
|
+
|
|
35
|
+
dirs.forEach((dir) => {
|
|
36
|
+
deleteExists(dir);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const composerJsons = getInstalledComposerVendors()
|
|
40
|
+
.map((cv) => `vendor/${cv}/composer.json`)
|
|
41
|
+
.map((file) => loadJson(file))
|
|
42
|
+
.filter((composerJson) => composerJson?.extra?.windwalker != null);
|
|
43
|
+
|
|
44
|
+
// Install npm vendors
|
|
45
|
+
vendors = findNpmVendors(composerJsons).concat(vendors);
|
|
46
|
+
vendors = [...new Set(vendors)];
|
|
47
|
+
|
|
48
|
+
for (const vendor of vendors) {
|
|
49
|
+
const source = `node_modules/${vendor}/`;
|
|
50
|
+
if (fs.existsSync(source)) {
|
|
51
|
+
console.log(`[${action} NPM] node_modules/${vendor}/ => ${root}/${vendor}/`);
|
|
52
|
+
doInstall(source, `${root}/${vendor}/`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Install composer packages assets
|
|
57
|
+
for (const composerJson of composerJsons) {
|
|
58
|
+
const vendorName = composerJson.name;
|
|
59
|
+
|
|
60
|
+
let assets = composerJson?.extra?.windwalker?.assets?.link;
|
|
61
|
+
|
|
62
|
+
if (!assets) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!assets.endsWith('/')) {
|
|
67
|
+
assets += '/';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (fs.existsSync(`vendor/${vendorName}/${assets}`)) {
|
|
71
|
+
console.log(`[${action} Composer] vendor/${vendorName}/${assets} => ${root}/${vendorName}/`);
|
|
72
|
+
doInstall(`vendor/${vendorName}/${assets}`, `${root}/${vendorName}/`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Install legacy packages assets
|
|
77
|
+
// legacyComposerVendors.forEach((vendorName) => {
|
|
78
|
+
// console.log(vendorName, fs.existsSync(`vendor/${vendorName}/assets`));
|
|
79
|
+
// if (fs.existsSync(`vendor/${vendorName}/assets`)) {
|
|
80
|
+
// console.log(`[${action} Composer] vendor/${vendorName}/assets/ => ${root}/${vendorName}/`);
|
|
81
|
+
// doInstall(`vendor/${vendorName}/assets/`, `${root}/${vendorName}/`);
|
|
82
|
+
// }
|
|
83
|
+
// });
|
|
84
|
+
|
|
85
|
+
// Install local saved vendors
|
|
86
|
+
const staticVendorDir = 'resources/assets/vendor/';
|
|
87
|
+
|
|
88
|
+
if (fs.existsSync(staticVendorDir)) {
|
|
89
|
+
const staticVendors = fs.readdirSync(staticVendorDir);
|
|
90
|
+
|
|
91
|
+
for (const staticVendor of staticVendors) {
|
|
92
|
+
if (staticVendor.startsWith('@')) {
|
|
93
|
+
const subVendors = fs.readdirSync(staticVendorDir + staticVendor);
|
|
94
|
+
|
|
95
|
+
for (const subVendor of subVendors) {
|
|
96
|
+
const subVendorName = staticVendor + '/' + subVendor;
|
|
97
|
+
const source = staticVendorDir + subVendorName + '/';
|
|
98
|
+
|
|
99
|
+
if (fs.existsSync(source)) {
|
|
100
|
+
console.log(`[${action} Local] resources/assets/vendor/${subVendorName}/ => ${root}/${subVendorName}/`);
|
|
101
|
+
doInstall(source, `${root}/${subVendorName}/`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
let source = staticVendorDir + staticVendor;
|
|
106
|
+
|
|
107
|
+
if (fs.existsSync(source)) {
|
|
108
|
+
console.log(`[${action} Local] resources/assets/vendor/${staticVendor}/ => ${root}/${staticVendor}/`);
|
|
109
|
+
doInstall(source, `${root}/${staticVendor}/`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function doInstall(source: string, dest: string) {
|
|
117
|
+
if (process.env.INSTALL_VENDOR === 'hard') {
|
|
118
|
+
await copyGlob(source + '/**/*', dest);
|
|
119
|
+
} else {
|
|
120
|
+
await symlink(source, dest);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function findNpmVendors(composerJsons: any[] = []) {
|
|
125
|
+
const pkg = path.resolve(process.cwd(), 'package.json');
|
|
126
|
+
const pkgJson = loadJson(pkg);
|
|
127
|
+
|
|
128
|
+
let vendors = Object.keys(pkgJson.devDependencies || {})
|
|
129
|
+
.concat(Object.keys(pkgJson.dependencies || {}))
|
|
130
|
+
.map(id => `node_modules/${id}/package.json`)
|
|
131
|
+
.map((file) => loadJson(file))
|
|
132
|
+
.filter(pkgJson => pkgJson?.windwalker != null)
|
|
133
|
+
.map(pkgJson => pkgJson?.windwalker.vendors || [])
|
|
134
|
+
.flat();
|
|
135
|
+
|
|
136
|
+
const vendorsFromComposer = composerJsons
|
|
137
|
+
.map((composerJson) => {
|
|
138
|
+
return [
|
|
139
|
+
...composerJson?.extra?.windwalker?.asset_vendors || [],
|
|
140
|
+
...composerJson?.extra?.windwalker?.assets?.exposes || [],
|
|
141
|
+
...Object.keys(composerJson?.extra?.windwalker?.assets?.vendors || {})
|
|
142
|
+
];
|
|
143
|
+
})
|
|
144
|
+
.flat();
|
|
145
|
+
|
|
146
|
+
return [...new Set(vendors.concat(vendorsFromComposer))];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function getInstalledComposerVendors() {
|
|
150
|
+
const composerFile = path.resolve(process.cwd(), 'composer.json');
|
|
151
|
+
const composerJson = loadJson(composerFile);
|
|
152
|
+
|
|
153
|
+
return [
|
|
154
|
+
...new Set(
|
|
155
|
+
Object.keys(composerJson['require'] || {})
|
|
156
|
+
.concat(Object.keys(composerJson['require-dev'] || {}))
|
|
157
|
+
)
|
|
158
|
+
];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function deleteExists(dir: string) {
|
|
162
|
+
if (!fs.existsSync(dir)) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const subDirs = fs.readdirSync(dir, { withFileTypes: true });
|
|
167
|
+
|
|
168
|
+
for (const subDir of subDirs) {
|
|
169
|
+
if (subDir.isSymbolicLink() || subDir.isFile()) {
|
|
170
|
+
fs.unlinkSync(path.join(dir, subDir.name));
|
|
171
|
+
} else if (subDir.isDirectory()) {
|
|
172
|
+
deleteExists(path.join(dir, subDir.name));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
fs.rmdirSync(dir);
|
|
177
|
+
}
|
|
178
|
+
|