@cabloy/module-glob 5.1.12 → 5.2.1
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.d.ts +3 -4
- package/dist/index.js +49 -73
- package/dist/interface.d.ts +1 -2
- package/dist/interface.js +1 -3
- package/dist/meta.d.ts +2 -3
- package/dist/meta.js +1 -6
- package/package.json +14 -20
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export * from './interface.
|
|
1
|
+
import type { IModule, ISuite } from '@cabloy/module-info';
|
|
2
|
+
import type { IModuleGlobOptions } from './interface.ts';
|
|
3
|
+
export * from './interface.ts';
|
|
4
4
|
export declare function glob(options: IModuleGlobOptions): Promise<{
|
|
5
5
|
suites: Record<string, ISuite>;
|
|
6
6
|
modules: Record<string, IModule>;
|
|
7
7
|
modulesArray: IModule[];
|
|
8
8
|
}>;
|
|
9
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,33 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.glob = void 0;
|
|
21
|
-
const path_1 = __importDefault(require("path"));
|
|
22
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
23
|
-
const semver_1 = __importDefault(require("semver"));
|
|
24
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
25
|
-
const boxen_1 = __importDefault(require("boxen"));
|
|
26
|
-
const egg_born_utils_1 = __importDefault(require("egg-born-utils"));
|
|
27
|
-
const meta_js_1 = require("./meta.js");
|
|
28
|
-
const module_info_1 = require("@cabloy/module-info");
|
|
29
|
-
const utils_1 = require("@cabloy/utils");
|
|
30
|
-
__exportStar(require("./interface.js"), exports);
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { parseInfoPro, } from '@cabloy/module-info';
|
|
3
|
+
import { checkMeta } from '@cabloy/utils';
|
|
4
|
+
import boxen from 'boxen';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import fse from 'fs-extra';
|
|
7
|
+
import { globbySync } from 'globby';
|
|
8
|
+
import semver from 'semver';
|
|
9
|
+
import { getPathsMeta } from "./meta.js";
|
|
10
|
+
export * from "./interface.js";
|
|
31
11
|
const SymbolModuleOrdering = Symbol('SymbolModuleOrdering');
|
|
32
12
|
const boxenOptions = {
|
|
33
13
|
padding: 1,
|
|
@@ -37,7 +17,7 @@ const boxenOptions = {
|
|
|
37
17
|
borderStyle: 'round',
|
|
38
18
|
};
|
|
39
19
|
// type: front/backend
|
|
40
|
-
async function glob(options) {
|
|
20
|
+
export async function glob(options) {
|
|
41
21
|
const { projectPath, disabledModules, disabledSuites, log, projectMode, meta } = options;
|
|
42
22
|
// context
|
|
43
23
|
const context = {
|
|
@@ -60,7 +40,7 @@ async function glob(options) {
|
|
|
60
40
|
disabledSuites: __getDisabledSuites(disabledSuites),
|
|
61
41
|
meta,
|
|
62
42
|
//
|
|
63
|
-
pathsMeta:
|
|
43
|
+
pathsMeta: getPathsMeta(projectMode),
|
|
64
44
|
};
|
|
65
45
|
// parse suites
|
|
66
46
|
const suites = __parseSuites(context, projectPath);
|
|
@@ -92,7 +72,6 @@ async function glob(options) {
|
|
|
92
72
|
// suitesVendor: context.suitesVendor,
|
|
93
73
|
};
|
|
94
74
|
}
|
|
95
|
-
exports.glob = glob;
|
|
96
75
|
function getPackageModuleNode(projectMode) {
|
|
97
76
|
return ['zova', 'vona'].includes(projectMode) ? `${projectMode}Module` : 'cabloyModule';
|
|
98
77
|
}
|
|
@@ -101,7 +80,7 @@ async function __loadPackage(context, modules) {
|
|
|
101
80
|
const modulesArray = [];
|
|
102
81
|
for (const moduleName in modules) {
|
|
103
82
|
const module = modules[moduleName];
|
|
104
|
-
promises.push(
|
|
83
|
+
promises.push(fse.readFile(module.pkg));
|
|
105
84
|
modulesArray.push(moduleName);
|
|
106
85
|
}
|
|
107
86
|
const modulesPackage = await Promise.all(promises);
|
|
@@ -143,7 +122,7 @@ function __pushModule(context, modules, moduleRelativeName) {
|
|
|
143
122
|
return false;
|
|
144
123
|
// check meta
|
|
145
124
|
const capabilities = module.package.zovaModule?.capabilities ?? module.package.vonaModule?.capabilities;
|
|
146
|
-
if (context.meta && capabilities && !
|
|
125
|
+
if (context.meta && capabilities && !checkMeta(capabilities.meta, context.meta))
|
|
147
126
|
return false;
|
|
148
127
|
// ordering
|
|
149
128
|
if (module[SymbolModuleOrdering])
|
|
@@ -176,16 +155,14 @@ function __orderDependencies(context, modules, module, moduleRelativeName) {
|
|
|
176
155
|
for (const key in dependencies) {
|
|
177
156
|
const subModule = modules[key];
|
|
178
157
|
if (!subModule) {
|
|
179
|
-
const message =
|
|
180
|
-
|
|
181
|
-
chalk_1.default.keyword('cyan')(`module ${key} not exists`);
|
|
182
|
-
console.log('\n' + (0, boxen_1.default)(message, boxenOptions) + '\n');
|
|
158
|
+
const message = `${chalk.keyword('orange')(`module ${moduleRelativeName} disabled`)}, because ${chalk.keyword('cyan')(`module ${key} not exists`)}`;
|
|
159
|
+
console.log(`\n${boxen(message, boxenOptions)}\n`);
|
|
183
160
|
enabled = false; // process.exit(0);
|
|
184
161
|
continue;
|
|
185
162
|
}
|
|
186
163
|
const subModuleVersion = dependencies[key];
|
|
187
|
-
if (
|
|
188
|
-
console.warn(
|
|
164
|
+
if (semver.lt(subModule.package.version, subModuleVersion)) {
|
|
165
|
+
console.warn(chalk.cyan(`module ${key} is old`));
|
|
189
166
|
process.exit(0);
|
|
190
167
|
}
|
|
191
168
|
if (!__pushModule(context, modules, key)) {
|
|
@@ -197,18 +174,18 @@ function __orderDependencies(context, modules, module, moduleRelativeName) {
|
|
|
197
174
|
function __parseModules(context, projectPath) {
|
|
198
175
|
const modules = {};
|
|
199
176
|
for (const __path of context.pathsMeta.modules) {
|
|
200
|
-
const
|
|
201
|
-
const
|
|
202
|
-
|
|
177
|
+
const fileNames = globbySync(`${__path.prefix}*/package.json`, { cwd: projectPath });
|
|
178
|
+
for (const fileName of fileNames) {
|
|
179
|
+
const filePkg = path.join(projectPath, fileName);
|
|
203
180
|
// name
|
|
204
|
-
const name =
|
|
181
|
+
const name = fileName.split('/').slice(-2)[0];
|
|
205
182
|
// check if '-' prefix exists
|
|
206
183
|
if (name.substring(0, 1) === '-') {
|
|
207
184
|
// skip
|
|
208
185
|
continue;
|
|
209
186
|
}
|
|
210
187
|
// info
|
|
211
|
-
const info =
|
|
188
|
+
const info = parseInfoPro(name, context.options.projectMode, 'module');
|
|
212
189
|
if (!info) {
|
|
213
190
|
throw new Error(`module name is not valid: ${name}`);
|
|
214
191
|
}
|
|
@@ -220,7 +197,7 @@ function __parseModules(context, projectPath) {
|
|
|
220
197
|
info.node_modules = __path.node_modules;
|
|
221
198
|
info.originalName = name;
|
|
222
199
|
// resource
|
|
223
|
-
const root =
|
|
200
|
+
const root = path.dirname(filePkg);
|
|
224
201
|
const module = {
|
|
225
202
|
name,
|
|
226
203
|
info,
|
|
@@ -255,27 +232,27 @@ function __logModules(context, log) {
|
|
|
255
232
|
if (!log)
|
|
256
233
|
return;
|
|
257
234
|
// log
|
|
258
|
-
console.log(
|
|
235
|
+
console.log(chalk.yellow('\n=== Local Modules ==='));
|
|
259
236
|
for (const key in context.modulesLocal) {
|
|
260
|
-
console.log(
|
|
237
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
261
238
|
}
|
|
262
|
-
console.log(
|
|
239
|
+
console.log(chalk.yellow('\n=== Global Modules ==='));
|
|
263
240
|
for (const key in context.modulesGlobal) {
|
|
264
|
-
console.log(
|
|
241
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
265
242
|
}
|
|
266
|
-
console.log(
|
|
243
|
+
console.log(chalk.yellow('\n=== Monkey Modules ==='));
|
|
267
244
|
for (const key in context.modulesMonkey) {
|
|
268
|
-
console.log(
|
|
245
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
269
246
|
}
|
|
270
|
-
console.log(
|
|
247
|
+
console.log(chalk.yellow('\n=== Sync Modules ==='));
|
|
271
248
|
for (const key in context.modulesSync) {
|
|
272
|
-
console.log(
|
|
249
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
273
250
|
}
|
|
274
|
-
console.log(
|
|
251
|
+
console.log(chalk.yellow('\n=== Icon Modules ==='));
|
|
275
252
|
for (const key in context.modulesIcon) {
|
|
276
|
-
console.log(
|
|
253
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
277
254
|
}
|
|
278
|
-
console.log(
|
|
255
|
+
console.log(chalk.keyword('orange')(`\n=== Total Modules: ${context.modulesArray.length} ===`));
|
|
279
256
|
// console.log('\n');
|
|
280
257
|
}
|
|
281
258
|
function __logSuites(context, log) {
|
|
@@ -291,15 +268,15 @@ function __logSuites(context, log) {
|
|
|
291
268
|
if (!log)
|
|
292
269
|
return;
|
|
293
270
|
// log
|
|
294
|
-
console.log(
|
|
271
|
+
console.log(chalk.yellow('\n=== Local Suites ==='));
|
|
295
272
|
for (const key in context.suitesLocal) {
|
|
296
|
-
console.log(
|
|
273
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
297
274
|
}
|
|
298
|
-
console.log(
|
|
275
|
+
console.log(chalk.yellow('\n=== Vendor Suites ==='));
|
|
299
276
|
for (const key in context.suitesVendor) {
|
|
300
|
-
console.log(
|
|
277
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
301
278
|
}
|
|
302
|
-
console.log(
|
|
279
|
+
console.log(chalk.keyword('orange')(`\n=== Total Suites: ${Object.keys(context.suites).length} ===`));
|
|
303
280
|
console.log('\n');
|
|
304
281
|
}
|
|
305
282
|
function __getDisabledModules(disabledModules) {
|
|
@@ -327,18 +304,18 @@ function __getDisabledSuites(disabledSuites) {
|
|
|
327
304
|
function __parseSuites(context, projectPath) {
|
|
328
305
|
const suites = {};
|
|
329
306
|
for (const __path of context.pathsMeta.suites) {
|
|
330
|
-
const
|
|
331
|
-
const
|
|
332
|
-
|
|
307
|
+
const fileNames = globbySync(`${__path.prefix}*/package.json`, { cwd: projectPath });
|
|
308
|
+
for (const fileName of fileNames) {
|
|
309
|
+
const filePkg = path.join(projectPath, fileName);
|
|
333
310
|
// name
|
|
334
|
-
const name =
|
|
311
|
+
const name = fileName.split('/').slice(-2)[0];
|
|
335
312
|
// check if '-' prefix exists
|
|
336
313
|
if (name.substring(0, 1) === '-') {
|
|
337
314
|
// skip
|
|
338
315
|
continue;
|
|
339
316
|
}
|
|
340
317
|
// info
|
|
341
|
-
const info =
|
|
318
|
+
const info = parseInfoPro(name, context.options.projectMode, 'suite');
|
|
342
319
|
if (!info) {
|
|
343
320
|
throw new Error(`suite name is not valid: ${name}`);
|
|
344
321
|
}
|
|
@@ -350,7 +327,7 @@ function __parseSuites(context, projectPath) {
|
|
|
350
327
|
info.node_modules = __path.node_modules;
|
|
351
328
|
info.originalName = name;
|
|
352
329
|
// suite
|
|
353
|
-
const root =
|
|
330
|
+
const root = path.dirname(filePkg);
|
|
354
331
|
const suite = {
|
|
355
332
|
name,
|
|
356
333
|
info,
|
|
@@ -365,8 +342,8 @@ function __parseSuites(context, projectPath) {
|
|
|
365
342
|
// ok
|
|
366
343
|
return suites;
|
|
367
344
|
}
|
|
368
|
-
const __suite_pattern1 = /src\/suite\/([
|
|
369
|
-
const __suite_pattern2 = /src\/suite-vendor\/([
|
|
345
|
+
const __suite_pattern1 = /src\/suite\/([^/]+)\/modules/;
|
|
346
|
+
const __suite_pattern2 = /src\/suite-vendor\/([^/]+)\/modules/;
|
|
370
347
|
function __bindSuitesModules(suites, modules) {
|
|
371
348
|
for (const moduleName in modules) {
|
|
372
349
|
const module = modules[moduleName];
|
|
@@ -414,9 +391,8 @@ function _checkSuiteValid(context, suites, suiteRelativeName) {
|
|
|
414
391
|
return false;
|
|
415
392
|
// check meta
|
|
416
393
|
const capabilities = suite.package.zovaModule?.capabilities ?? suite.package.vonaModule?.capabilities;
|
|
417
|
-
if (context.meta && capabilities && !
|
|
394
|
+
if (context.meta && capabilities && !checkMeta(capabilities.meta, context.meta))
|
|
418
395
|
return false;
|
|
419
396
|
// ok
|
|
420
397
|
return true;
|
|
421
398
|
}
|
|
422
|
-
//# sourceMappingURL=index.js.map
|
package/dist/interface.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IModule, ISuite, TypeProjectMode } from '@cabloy/module-info';
|
|
1
|
+
import type { IModule, ISuite, TypeProjectMode } from '@cabloy/module-info';
|
|
2
2
|
export interface IModuleGlobOptions {
|
|
3
3
|
projectMode: TypeProjectMode;
|
|
4
4
|
projectPath: string;
|
|
@@ -35,4 +35,3 @@ export interface IModuleGlobPathsMeta {
|
|
|
35
35
|
suites: IModuleGlobPathMetaItem[];
|
|
36
36
|
modules: IModuleGlobPathMetaItem[];
|
|
37
37
|
}
|
|
38
|
-
//# sourceMappingURL=interface.d.ts.map
|
package/dist/interface.js
CHANGED
package/dist/meta.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { TypeProjectMode } from '@cabloy/module-info';
|
|
2
|
-
import { IModuleGlobPathsMeta } from './interface.
|
|
1
|
+
import type { TypeProjectMode } from '@cabloy/module-info';
|
|
2
|
+
import type { IModuleGlobPathsMeta } from './interface.ts';
|
|
3
3
|
export declare function getPathsMeta(projectMode: TypeProjectMode): IModuleGlobPathsMeta;
|
|
4
|
-
//# sourceMappingURL=meta.d.ts.map
|
package/dist/meta.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPathsMeta = void 0;
|
|
4
1
|
const __pathSuites = [
|
|
5
2
|
{
|
|
6
3
|
prefix: 'src/suite/',
|
|
@@ -29,7 +26,7 @@ const __pathsModules = [
|
|
|
29
26
|
vendor: true,
|
|
30
27
|
},
|
|
31
28
|
];
|
|
32
|
-
function getPathsMeta(projectMode) {
|
|
29
|
+
export function getPathsMeta(projectMode) {
|
|
33
30
|
let brand;
|
|
34
31
|
let mode;
|
|
35
32
|
if (['zova', 'vona'].includes(projectMode)) {
|
|
@@ -60,5 +57,3 @@ function getPathsMeta(projectMode) {
|
|
|
60
57
|
};
|
|
61
58
|
return pathsMeta;
|
|
62
59
|
}
|
|
63
|
-
exports.getPathsMeta = getPathsMeta;
|
|
64
|
-
//# sourceMappingURL=meta.js.map
|
package/package.json
CHANGED
|
@@ -1,42 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cabloy/module-glob",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "5.2.1",
|
|
4
5
|
"description": "cabloy module-glob",
|
|
5
6
|
"publishConfig": {
|
|
6
7
|
"access": "public"
|
|
7
8
|
},
|
|
9
|
+
"author": "zhennann",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"framework",
|
|
12
|
+
"cabloy"
|
|
13
|
+
],
|
|
8
14
|
"exports": {
|
|
9
15
|
".": {
|
|
10
16
|
"types": [
|
|
11
17
|
"./src/index.ts",
|
|
12
18
|
"./dist/index.d.ts"
|
|
13
19
|
],
|
|
14
|
-
"
|
|
15
|
-
"require": "./dist/index.js",
|
|
16
|
-
"default": "./src/index.ts"
|
|
20
|
+
"default": "./dist/index.js"
|
|
17
21
|
},
|
|
18
22
|
"./package.json": "./package.json"
|
|
19
23
|
},
|
|
20
24
|
"files": [
|
|
21
|
-
"dist
|
|
22
|
-
"dist/**/*.d.ts"
|
|
25
|
+
"dist"
|
|
23
26
|
],
|
|
24
|
-
"keywords": [
|
|
25
|
-
"egg",
|
|
26
|
-
"egg-born",
|
|
27
|
-
"framework",
|
|
28
|
-
"cabloy"
|
|
29
|
-
],
|
|
30
|
-
"author": "zhennann",
|
|
31
27
|
"dependencies": {
|
|
32
28
|
"boxen": "^4.2.0",
|
|
33
29
|
"chalk": "^3.0.0",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"scripts": {
|
|
40
|
-
"lint": "eslint ."
|
|
30
|
+
"fs-extra": "^11.3.0",
|
|
31
|
+
"globby": "^14.1.0",
|
|
32
|
+
"semver": "^7.7.1",
|
|
33
|
+
"@cabloy/module-info": "^1.3.4",
|
|
34
|
+
"@cabloy/utils": "^1.0.9"
|
|
41
35
|
}
|
|
42
36
|
}
|