@cabloy/module-glob 5.2.34 → 5.2.36
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/dist/index.js +394 -345
- package/package.json +4 -5
- package/dist/interface.js +0 -1
- package/dist/meta.js +0 -59
package/dist/index.js
CHANGED
|
@@ -1,398 +1,447 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { parseInfoPro
|
|
2
|
+
import { parseInfoPro } from '@cabloy/module-info';
|
|
3
3
|
import { checkMeta } from '@cabloy/utils';
|
|
4
4
|
import boxen from 'boxen';
|
|
5
5
|
import chalk from 'chalk';
|
|
6
6
|
import fse from 'fs-extra';
|
|
7
7
|
import { globbySync } from 'globby';
|
|
8
8
|
import semver from 'semver';
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
|
|
10
|
+
const __pathSuites = [{
|
|
11
|
+
prefix: 'src/suite/',
|
|
12
|
+
vendor: false
|
|
13
|
+
}, {
|
|
14
|
+
prefix: 'src/suite-vendor/',
|
|
15
|
+
vendor: true
|
|
16
|
+
}];
|
|
17
|
+
const __pathsModules = [{
|
|
18
|
+
prefix: 'src/module/',
|
|
19
|
+
vendor: false
|
|
20
|
+
}, {
|
|
21
|
+
prefix: 'src/suite/*/modules/',
|
|
22
|
+
vendor: false
|
|
23
|
+
}, {
|
|
24
|
+
prefix: 'src/module-vendor/',
|
|
25
|
+
vendor: true
|
|
26
|
+
}, {
|
|
27
|
+
prefix: 'src/suite-vendor/*/modules/',
|
|
28
|
+
vendor: true
|
|
29
|
+
}];
|
|
30
|
+
function getPathsMeta(projectMode) {
|
|
31
|
+
let brand;
|
|
32
|
+
let mode;
|
|
33
|
+
if (['zova', 'vona'].includes(projectMode)) {
|
|
34
|
+
brand = projectMode;
|
|
35
|
+
mode = '';
|
|
36
|
+
} else {
|
|
37
|
+
brand = 'cabloy';
|
|
38
|
+
mode = `-${projectMode}`;
|
|
39
|
+
}
|
|
40
|
+
const suites = __pathSuites.concat([{
|
|
41
|
+
prefix: `node_modules/${brand}-suite${mode}-`,
|
|
42
|
+
vendor: true,
|
|
43
|
+
node_modules: true
|
|
44
|
+
}]);
|
|
45
|
+
const modules = __pathsModules.concat([{
|
|
46
|
+
prefix: `node_modules/${brand}-module${mode}-`,
|
|
47
|
+
vendor: true,
|
|
48
|
+
node_modules: true
|
|
49
|
+
}]);
|
|
50
|
+
const pathsMeta = {
|
|
51
|
+
suites,
|
|
52
|
+
modules
|
|
53
|
+
};
|
|
54
|
+
return pathsMeta;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* eslint-disable no-console */
|
|
58
|
+
|
|
11
59
|
const SymbolModuleOrdering = Symbol('SymbolModuleOrdering');
|
|
12
60
|
const boxenOptions = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
61
|
+
padding: 1,
|
|
62
|
+
margin: 1,
|
|
63
|
+
align: 'center',
|
|
64
|
+
borderColor: 'yellow',
|
|
65
|
+
borderStyle: 'round'
|
|
18
66
|
};
|
|
67
|
+
|
|
19
68
|
// type: front/backend
|
|
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
|
-
|
|
69
|
+
async function glob(options) {
|
|
70
|
+
const {
|
|
71
|
+
projectPath,
|
|
72
|
+
disabledModules,
|
|
73
|
+
disabledSuites,
|
|
74
|
+
log,
|
|
75
|
+
projectMode,
|
|
76
|
+
meta
|
|
77
|
+
} = options;
|
|
78
|
+
// context
|
|
79
|
+
const context = {
|
|
80
|
+
options,
|
|
81
|
+
suites: {},
|
|
82
|
+
modules: {},
|
|
83
|
+
modulesArray: [],
|
|
84
|
+
modulesLast: [],
|
|
85
|
+
//
|
|
86
|
+
modulesLocal: {},
|
|
87
|
+
modulesGlobal: {},
|
|
88
|
+
modulesMonkey: {},
|
|
89
|
+
modulesSync: {},
|
|
90
|
+
modulesIcon: {},
|
|
91
|
+
//
|
|
92
|
+
suitesLocal: {},
|
|
93
|
+
suitesVendor: {},
|
|
94
|
+
//
|
|
95
|
+
disabledModules: __getDisabledModules(disabledModules),
|
|
96
|
+
disabledSuites: __getDisabledSuites(disabledSuites),
|
|
97
|
+
meta,
|
|
98
|
+
//
|
|
99
|
+
pathsMeta: getPathsMeta(projectMode)
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// parse suites
|
|
103
|
+
const suites = __parseSuites(context, projectPath);
|
|
104
|
+
// parse modules
|
|
105
|
+
const modules = __parseModules(context, projectPath);
|
|
106
|
+
// load package
|
|
107
|
+
await __loadPackage(context, suites);
|
|
108
|
+
await __loadPackage(context, modules);
|
|
109
|
+
// bind suites modules
|
|
110
|
+
__bindSuitesModules(suites, modules);
|
|
111
|
+
|
|
112
|
+
// check suites
|
|
113
|
+
__checkSuites(context, suites);
|
|
114
|
+
|
|
115
|
+
// order
|
|
116
|
+
__orderModules(context, modules);
|
|
117
|
+
|
|
118
|
+
// log
|
|
119
|
+
__logModules(context, log);
|
|
120
|
+
__logSuites(context, log);
|
|
121
|
+
|
|
122
|
+
// ok
|
|
123
|
+
return {
|
|
124
|
+
suites: context.suites,
|
|
125
|
+
modules: context.modules,
|
|
126
|
+
modulesArray: context.modulesArray
|
|
127
|
+
//
|
|
128
|
+
// modulesLocal: context.modulesLocal,
|
|
129
|
+
// modulesGlobal: context.modulesGlobal,
|
|
130
|
+
// modulesMonkey: context.modulesMonkey,
|
|
131
|
+
//
|
|
132
|
+
// suitesLocal: context.suitesLocal,
|
|
133
|
+
// suitesVendor: context.suitesVendor,
|
|
134
|
+
};
|
|
74
135
|
}
|
|
75
136
|
function getPackageModuleNode(projectMode) {
|
|
76
|
-
|
|
137
|
+
return ['zova', 'vona'].includes(projectMode) ? `${projectMode}Module` : 'cabloyModule';
|
|
77
138
|
}
|
|
78
139
|
async function __loadPackage(context, modules) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
140
|
+
const promises = [];
|
|
141
|
+
const modulesArray = [];
|
|
142
|
+
for (const moduleName in modules) {
|
|
143
|
+
const module = modules[moduleName];
|
|
144
|
+
promises.push(fse.readFile(module.pkg));
|
|
145
|
+
modulesArray.push(moduleName);
|
|
146
|
+
}
|
|
147
|
+
const modulesPackage = await Promise.all(promises);
|
|
148
|
+
for (let i = 0; i < modulesPackage.length; i++) {
|
|
149
|
+
const moduleName = modulesArray[i];
|
|
150
|
+
const module = modules[moduleName];
|
|
151
|
+
module.package = JSON.parse(modulesPackage[i].toString());
|
|
152
|
+
const moduleNode = getPackageModuleNode(context.options.projectMode);
|
|
153
|
+
const capabilities = module.package[moduleNode]?.capabilities;
|
|
154
|
+
module.info.capabilities = capabilities;
|
|
155
|
+
module.info.onionsMeta = {
|
|
156
|
+
onions: module.package[moduleNode]?.onions,
|
|
157
|
+
metas: module.package[moduleNode]?.metas,
|
|
158
|
+
onionsConfig: module.package[moduleNode]?.onionsConfig
|
|
159
|
+
};
|
|
160
|
+
}
|
|
100
161
|
}
|
|
101
162
|
function __orderModules(context, modules) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
// combine last
|
|
113
|
-
for (const module of context.modulesLast) {
|
|
114
|
-
context.modulesArray.push(module);
|
|
163
|
+
// 'a-version' first
|
|
164
|
+
if (modules['a-version']) {
|
|
165
|
+
__pushModule(context, modules, 'a-version');
|
|
166
|
+
}
|
|
167
|
+
// others
|
|
168
|
+
for (const key in modules) {
|
|
169
|
+
if (key !== 'a-version') {
|
|
170
|
+
__pushModule(context, modules, key);
|
|
115
171
|
}
|
|
172
|
+
}
|
|
173
|
+
// combine last
|
|
174
|
+
for (const module of context.modulesLast) {
|
|
175
|
+
context.modulesArray.push(module);
|
|
176
|
+
}
|
|
116
177
|
}
|
|
117
178
|
function __pushModule(context, modules, moduleRelativeName) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return true;
|
|
179
|
+
// module
|
|
180
|
+
const module = modules[moduleRelativeName];
|
|
181
|
+
// check if disable
|
|
182
|
+
if (context.disabledModules[moduleRelativeName]) return false;
|
|
183
|
+
// check meta
|
|
184
|
+
const capabilities = module.package.zovaModule?.capabilities ?? module.package.vonaModule?.capabilities;
|
|
185
|
+
if (context.meta && capabilities && !checkMeta(capabilities.meta, context.meta)) return false;
|
|
186
|
+
|
|
187
|
+
// ordering
|
|
188
|
+
if (module[SymbolModuleOrdering]) return true;
|
|
189
|
+
module[SymbolModuleOrdering] = true;
|
|
190
|
+
|
|
191
|
+
// dependencies
|
|
192
|
+
if (!__orderDependencies(context, modules, module, moduleRelativeName)) {
|
|
193
|
+
context.disabledModules[moduleRelativeName] = true;
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// push this
|
|
198
|
+
context.modules[moduleRelativeName] = module;
|
|
199
|
+
const moduleNode = getPackageModuleNode(context.options.projectMode);
|
|
200
|
+
if (module.package && module.package[moduleNode] && module.package[moduleNode].last === true) {
|
|
201
|
+
context.modulesLast.push(module);
|
|
202
|
+
} else {
|
|
203
|
+
context.modulesArray.push(module);
|
|
204
|
+
}
|
|
205
|
+
return true;
|
|
146
206
|
}
|
|
147
207
|
function __orderDependencies(context, modules, module, moduleRelativeName) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (!__pushModule(context, modules, key)) {
|
|
169
|
-
enabled = false;
|
|
170
|
-
}
|
|
208
|
+
if (context.options.disableCheckDependencies) return true;
|
|
209
|
+
const moduleNode = getPackageModuleNode(context.options.projectMode);
|
|
210
|
+
if (!module.package[moduleNode] || !module.package[moduleNode].dependencies) return true;
|
|
211
|
+
let enabled = true;
|
|
212
|
+
const dependencies = module.package[moduleNode].dependencies;
|
|
213
|
+
for (const key in dependencies) {
|
|
214
|
+
const subModule = modules[key];
|
|
215
|
+
if (!subModule) {
|
|
216
|
+
const message = `${chalk.keyword('orange')(`module ${moduleRelativeName} disabled`)}, because ${chalk.keyword('cyan')(`module ${key} not exists`)}`;
|
|
217
|
+
console.log(`\n${boxen(message, boxenOptions)}\n`);
|
|
218
|
+
enabled = false; // process.exit(0);
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
const subModuleVersion = dependencies[key];
|
|
222
|
+
if (semver.lt(subModule.package.version, subModuleVersion)) {
|
|
223
|
+
console.warn(chalk.cyan(`module ${key} is old`));
|
|
224
|
+
process.exit(0);
|
|
225
|
+
}
|
|
226
|
+
if (!__pushModule(context, modules, key)) {
|
|
227
|
+
enabled = false;
|
|
171
228
|
}
|
|
172
|
-
|
|
229
|
+
}
|
|
230
|
+
return enabled;
|
|
173
231
|
}
|
|
174
232
|
function __parseModules(context, projectPath) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
233
|
+
const modules = {};
|
|
234
|
+
for (const __path of context.pathsMeta.modules) {
|
|
235
|
+
const fileNames = globbySync(`${__path.prefix}*/package.json`, {
|
|
236
|
+
cwd: projectPath
|
|
237
|
+
});
|
|
238
|
+
for (const fileName of fileNames) {
|
|
239
|
+
const filePkg = path.join(projectPath, fileName);
|
|
240
|
+
// name
|
|
241
|
+
const name = fileName.split('/').slice(-2)[0];
|
|
242
|
+
// check if '-' prefix exists
|
|
243
|
+
if (name.substring(0, 1) === '-') {
|
|
244
|
+
// skip
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
// info
|
|
248
|
+
const info = parseInfoPro(name, context.options.projectMode, 'module');
|
|
249
|
+
if (!info) {
|
|
250
|
+
throw new Error(`module name is not valid: ${name}`);
|
|
251
|
+
}
|
|
252
|
+
// check if exists
|
|
253
|
+
if (modules[info.relativeName]) continue;
|
|
254
|
+
// info
|
|
255
|
+
info.vendor = __path.vendor;
|
|
256
|
+
info.node_modules = __path.node_modules;
|
|
257
|
+
info.originalName = name;
|
|
258
|
+
// resource
|
|
259
|
+
const root = path.dirname(filePkg);
|
|
260
|
+
const module = {
|
|
261
|
+
name,
|
|
262
|
+
info,
|
|
263
|
+
root,
|
|
264
|
+
pkg: filePkg
|
|
265
|
+
};
|
|
266
|
+
// record
|
|
267
|
+
modules[info.relativeName] = module;
|
|
210
268
|
}
|
|
211
|
-
|
|
269
|
+
}
|
|
270
|
+
return modules;
|
|
212
271
|
}
|
|
213
272
|
function __logModules(context, log) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
if (module.info.capabilities?.sync) {
|
|
220
|
-
context.modulesSync[relativeName] = module;
|
|
221
|
-
}
|
|
222
|
-
if (module.info.capabilities?.icon) {
|
|
223
|
-
context.modulesIcon[relativeName] = module;
|
|
224
|
-
}
|
|
225
|
-
if (module.info.node_modules) {
|
|
226
|
-
context.modulesGlobal[relativeName] = module;
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
context.modulesLocal[relativeName] = module;
|
|
230
|
-
}
|
|
273
|
+
for (const module of context.modulesArray) {
|
|
274
|
+
const relativeName = module.info.relativeName;
|
|
275
|
+
if (module.info.capabilities?.monkey) {
|
|
276
|
+
context.modulesMonkey[relativeName] = module;
|
|
231
277
|
}
|
|
232
|
-
if (
|
|
233
|
-
|
|
234
|
-
// log
|
|
235
|
-
console.log(chalk.yellow('\n=== Local Modules ==='));
|
|
236
|
-
for (const key in context.modulesLocal) {
|
|
237
|
-
console.log(chalk.cyan(`> ${key}`));
|
|
278
|
+
if (module.info.capabilities?.sync) {
|
|
279
|
+
context.modulesSync[relativeName] = module;
|
|
238
280
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
console.log(chalk.cyan(`> ${key}`));
|
|
281
|
+
if (module.info.capabilities?.icon) {
|
|
282
|
+
context.modulesIcon[relativeName] = module;
|
|
242
283
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
284
|
+
if (module.info.node_modules) {
|
|
285
|
+
context.modulesGlobal[relativeName] = module;
|
|
286
|
+
} else {
|
|
287
|
+
context.modulesLocal[relativeName] = module;
|
|
246
288
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
289
|
+
}
|
|
290
|
+
if (!log) return;
|
|
291
|
+
// log
|
|
292
|
+
console.log(chalk.yellow('\n=== Local Modules ==='));
|
|
293
|
+
for (const key in context.modulesLocal) {
|
|
294
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
295
|
+
}
|
|
296
|
+
console.log(chalk.yellow('\n=== Global Modules ==='));
|
|
297
|
+
for (const key in context.modulesGlobal) {
|
|
298
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
299
|
+
}
|
|
300
|
+
console.log(chalk.yellow('\n=== Monkey Modules ==='));
|
|
301
|
+
for (const key in context.modulesMonkey) {
|
|
302
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
303
|
+
}
|
|
304
|
+
console.log(chalk.yellow('\n=== Sync Modules ==='));
|
|
305
|
+
for (const key in context.modulesSync) {
|
|
306
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
307
|
+
}
|
|
308
|
+
console.log(chalk.yellow('\n=== Icon Modules ==='));
|
|
309
|
+
for (const key in context.modulesIcon) {
|
|
310
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
311
|
+
}
|
|
312
|
+
console.log(chalk.keyword('orange')(`\n=== Total Modules: ${context.modulesArray.length} ===`));
|
|
313
|
+
// console.log('\n');
|
|
257
314
|
}
|
|
258
315
|
function __logSuites(context, log) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
context.suitesLocal[suiteName] = suite;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
if (!log)
|
|
269
|
-
return;
|
|
270
|
-
// log
|
|
271
|
-
console.log(chalk.yellow('\n=== Local Suites ==='));
|
|
272
|
-
for (const key in context.suitesLocal) {
|
|
273
|
-
console.log(chalk.cyan(`> ${key}`));
|
|
316
|
+
for (const suiteName in context.suites) {
|
|
317
|
+
const suite = context.suites[suiteName];
|
|
318
|
+
if (suite.info.vendor) {
|
|
319
|
+
context.suitesVendor[suiteName] = suite;
|
|
320
|
+
} else {
|
|
321
|
+
context.suitesLocal[suiteName] = suite;
|
|
274
322
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
console.log(
|
|
323
|
+
}
|
|
324
|
+
if (!log) return;
|
|
325
|
+
// log
|
|
326
|
+
console.log(chalk.yellow('\n=== Local Suites ==='));
|
|
327
|
+
for (const key in context.suitesLocal) {
|
|
328
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
329
|
+
}
|
|
330
|
+
console.log(chalk.yellow('\n=== Vendor Suites ==='));
|
|
331
|
+
for (const key in context.suitesVendor) {
|
|
332
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
333
|
+
}
|
|
334
|
+
console.log(chalk.keyword('orange')(`\n=== Total Suites: ${Object.keys(context.suites).length} ===`));
|
|
335
|
+
console.log('\n');
|
|
281
336
|
}
|
|
282
337
|
function __getDisabledModules(disabledModules) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
return disabledModulesMap;
|
|
338
|
+
const disabledModulesMap = {};
|
|
339
|
+
if (!disabledModules) return disabledModulesMap;
|
|
340
|
+
if (typeof disabledModules === 'string') disabledModules = disabledModules.split(',');
|
|
341
|
+
for (const moduleName of disabledModules) {
|
|
342
|
+
disabledModulesMap[moduleName] = true;
|
|
343
|
+
}
|
|
344
|
+
return disabledModulesMap;
|
|
292
345
|
}
|
|
293
346
|
function __getDisabledSuites(disabledSuites) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
return disabledSuitesMap;
|
|
347
|
+
const disabledSuitesMap = {};
|
|
348
|
+
if (!disabledSuites) return disabledSuitesMap;
|
|
349
|
+
if (typeof disabledSuites === 'string') disabledSuites = disabledSuites.split(',');
|
|
350
|
+
for (const suiteName of disabledSuites) {
|
|
351
|
+
disabledSuitesMap[suiteName] = true;
|
|
352
|
+
}
|
|
353
|
+
return disabledSuitesMap;
|
|
303
354
|
}
|
|
304
355
|
function __parseSuites(context, projectPath) {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
356
|
+
const suites = {};
|
|
357
|
+
for (const __path of context.pathsMeta.suites) {
|
|
358
|
+
const fileNames = globbySync(`${__path.prefix}*/package.json`, {
|
|
359
|
+
cwd: projectPath
|
|
360
|
+
});
|
|
361
|
+
for (const fileName of fileNames) {
|
|
362
|
+
const filePkg = path.join(projectPath, fileName);
|
|
363
|
+
// name
|
|
364
|
+
const name = fileName.split('/').slice(-2)[0];
|
|
365
|
+
// check if '-' prefix exists
|
|
366
|
+
if (name.substring(0, 1) === '-') {
|
|
367
|
+
// skip
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
// info
|
|
371
|
+
const info = parseInfoPro(name, context.options.projectMode, 'suite');
|
|
372
|
+
if (!info) {
|
|
373
|
+
throw new Error(`suite name is not valid: ${name}`);
|
|
374
|
+
}
|
|
375
|
+
// check if exists
|
|
376
|
+
if (suites[info.relativeName]) continue;
|
|
377
|
+
// info
|
|
378
|
+
info.vendor = __path.vendor;
|
|
379
|
+
info.node_modules = __path.node_modules;
|
|
380
|
+
info.originalName = name;
|
|
381
|
+
// suite
|
|
382
|
+
const root = path.dirname(filePkg);
|
|
383
|
+
const suite = {
|
|
384
|
+
name,
|
|
385
|
+
info,
|
|
386
|
+
root,
|
|
387
|
+
pkg: filePkg,
|
|
388
|
+
modules: []
|
|
389
|
+
};
|
|
390
|
+
// record
|
|
391
|
+
suites[info.relativeName] = suite;
|
|
341
392
|
}
|
|
342
|
-
|
|
343
|
-
|
|
393
|
+
}
|
|
394
|
+
// ok
|
|
395
|
+
return suites;
|
|
344
396
|
}
|
|
345
397
|
const __suite_pattern1 = /src\/suite\/([^/]+)\/modules/;
|
|
346
398
|
const __suite_pattern2 = /src\/suite-vendor\/([^/]+)\/modules/;
|
|
347
399
|
function __bindSuitesModules(suites, modules) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
}
|
|
355
|
-
if (!res)
|
|
356
|
-
continue;
|
|
357
|
-
// suiteName
|
|
358
|
-
const suiteName = res[1];
|
|
359
|
-
const suite = suites[suiteName];
|
|
360
|
-
if (!suite) {
|
|
361
|
-
// means disabled
|
|
362
|
-
delete modules[moduleName];
|
|
363
|
-
}
|
|
364
|
-
else {
|
|
365
|
-
// bind
|
|
366
|
-
module.suite = suiteName;
|
|
367
|
-
suite.modules.push(moduleName);
|
|
368
|
-
}
|
|
400
|
+
for (const moduleName in modules) {
|
|
401
|
+
const module = modules[moduleName];
|
|
402
|
+
// check
|
|
403
|
+
let res = module.root.match(__suite_pattern1);
|
|
404
|
+
if (!res) {
|
|
405
|
+
res = module.root.match(__suite_pattern2);
|
|
369
406
|
}
|
|
407
|
+
if (!res) continue;
|
|
408
|
+
// suiteName
|
|
409
|
+
const suiteName = res[1];
|
|
410
|
+
const suite = suites[suiteName];
|
|
411
|
+
if (!suite) {
|
|
412
|
+
// means disabled
|
|
413
|
+
delete modules[moduleName];
|
|
414
|
+
} else {
|
|
415
|
+
// bind
|
|
416
|
+
module.suite = suiteName;
|
|
417
|
+
suite.modules.push(moduleName);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
370
420
|
}
|
|
371
421
|
function __checkSuites(context, suites) {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
}
|
|
383
|
-
}
|
|
422
|
+
for (const key in suites) {
|
|
423
|
+
const suite = suites[key];
|
|
424
|
+
// check if disable
|
|
425
|
+
if (_checkSuiteValid(context, suites, key)) {
|
|
426
|
+
context.suites[key] = suite;
|
|
427
|
+
} else {
|
|
428
|
+
// disabledModules
|
|
429
|
+
for (const moduleName of suite.modules) {
|
|
430
|
+
context.disabledModules[moduleName] = true;
|
|
431
|
+
}
|
|
384
432
|
}
|
|
433
|
+
}
|
|
385
434
|
}
|
|
386
435
|
function _checkSuiteValid(context, suites, suiteRelativeName) {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
// ok
|
|
397
|
-
return true;
|
|
436
|
+
// suite
|
|
437
|
+
const suite = suites[suiteRelativeName];
|
|
438
|
+
// check if disable
|
|
439
|
+
if (context.disabledSuites[suiteRelativeName]) return false;
|
|
440
|
+
// check meta
|
|
441
|
+
const capabilities = suite.package.zovaModule?.capabilities ?? suite.package.vonaModule?.capabilities;
|
|
442
|
+
if (context.meta && capabilities && !checkMeta(capabilities.meta, context.meta)) return false;
|
|
443
|
+
// ok
|
|
444
|
+
return true;
|
|
398
445
|
}
|
|
446
|
+
|
|
447
|
+
export { glob };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cabloy/module-glob",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.2.
|
|
4
|
+
"version": "5.2.36",
|
|
5
5
|
"description": "cabloy module-glob",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@cabloy/module-info": "^1.3.
|
|
29
|
-
"@cabloy/utils": "^
|
|
28
|
+
"@cabloy/module-info": "^1.3.32",
|
|
29
|
+
"@cabloy/utils": "^2.0.1",
|
|
30
30
|
"boxen": "^4.2.0",
|
|
31
31
|
"chalk": "^3.0.0",
|
|
32
32
|
"fs-extra": "^11.3.0",
|
|
@@ -35,8 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"gitHead": "0eab9dc4a5622caffe89e7b1b3f02c08ccbc4c4b",
|
|
37
37
|
"scripts": {
|
|
38
|
-
"lint": "eslint .",
|
|
39
38
|
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
40
|
-
"tsc:publish": "npm run clean && tsc"
|
|
39
|
+
"tsc:publish": "npm run clean && vona :bin:buildGeneral && tsc"
|
|
41
40
|
}
|
|
42
41
|
}
|
package/dist/interface.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/meta.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
const __pathSuites = [
|
|
2
|
-
{
|
|
3
|
-
prefix: 'src/suite/',
|
|
4
|
-
vendor: false,
|
|
5
|
-
},
|
|
6
|
-
{
|
|
7
|
-
prefix: 'src/suite-vendor/',
|
|
8
|
-
vendor: true,
|
|
9
|
-
},
|
|
10
|
-
];
|
|
11
|
-
const __pathsModules = [
|
|
12
|
-
{
|
|
13
|
-
prefix: 'src/module/',
|
|
14
|
-
vendor: false,
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
prefix: 'src/suite/*/modules/',
|
|
18
|
-
vendor: false,
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
prefix: 'src/module-vendor/',
|
|
22
|
-
vendor: true,
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
prefix: 'src/suite-vendor/*/modules/',
|
|
26
|
-
vendor: true,
|
|
27
|
-
},
|
|
28
|
-
];
|
|
29
|
-
export function getPathsMeta(projectMode) {
|
|
30
|
-
let brand;
|
|
31
|
-
let mode;
|
|
32
|
-
if (['zova', 'vona'].includes(projectMode)) {
|
|
33
|
-
brand = projectMode;
|
|
34
|
-
mode = '';
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
brand = 'cabloy';
|
|
38
|
-
mode = `-${projectMode}`;
|
|
39
|
-
}
|
|
40
|
-
const suites = __pathSuites.concat([
|
|
41
|
-
{
|
|
42
|
-
prefix: `node_modules/${brand}-suite${mode}-`,
|
|
43
|
-
vendor: true,
|
|
44
|
-
node_modules: true,
|
|
45
|
-
},
|
|
46
|
-
]);
|
|
47
|
-
const modules = __pathsModules.concat([
|
|
48
|
-
{
|
|
49
|
-
prefix: `node_modules/${brand}-module${mode}-`,
|
|
50
|
-
vendor: true,
|
|
51
|
-
node_modules: true,
|
|
52
|
-
},
|
|
53
|
-
]);
|
|
54
|
-
const pathsMeta = {
|
|
55
|
-
suites,
|
|
56
|
-
modules,
|
|
57
|
-
};
|
|
58
|
-
return pathsMeta;
|
|
59
|
-
}
|