@cabloy/module-glob 5.1.11 → 5.2.0
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 +54 -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);
|
|
@@ -112,6 +91,11 @@ async function __loadPackage(context, modules) {
|
|
|
112
91
|
const moduleNode = getPackageModuleNode(context.options.projectMode);
|
|
113
92
|
const capabilities = module.package[moduleNode]?.capabilities;
|
|
114
93
|
module.info.capabilities = capabilities;
|
|
94
|
+
module.info.onionsMeta = {
|
|
95
|
+
onions: module.package[moduleNode]?.onions,
|
|
96
|
+
metas: module.package[moduleNode]?.metas,
|
|
97
|
+
onionsConfig: module.package[moduleNode]?.onionsConfig,
|
|
98
|
+
};
|
|
115
99
|
}
|
|
116
100
|
}
|
|
117
101
|
function __orderModules(context, modules) {
|
|
@@ -138,7 +122,7 @@ function __pushModule(context, modules, moduleRelativeName) {
|
|
|
138
122
|
return false;
|
|
139
123
|
// check meta
|
|
140
124
|
const capabilities = module.package.zovaModule?.capabilities ?? module.package.vonaModule?.capabilities;
|
|
141
|
-
if (context.meta && capabilities && !
|
|
125
|
+
if (context.meta && capabilities && !checkMeta(capabilities.meta, context.meta))
|
|
142
126
|
return false;
|
|
143
127
|
// ordering
|
|
144
128
|
if (module[SymbolModuleOrdering])
|
|
@@ -171,16 +155,14 @@ function __orderDependencies(context, modules, module, moduleRelativeName) {
|
|
|
171
155
|
for (const key in dependencies) {
|
|
172
156
|
const subModule = modules[key];
|
|
173
157
|
if (!subModule) {
|
|
174
|
-
const message =
|
|
175
|
-
|
|
176
|
-
chalk_1.default.keyword('cyan')(`module ${key} not exists`);
|
|
177
|
-
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`);
|
|
178
160
|
enabled = false; // process.exit(0);
|
|
179
161
|
continue;
|
|
180
162
|
}
|
|
181
163
|
const subModuleVersion = dependencies[key];
|
|
182
|
-
if (
|
|
183
|
-
console.warn(
|
|
164
|
+
if (semver.lt(subModule.package.version, subModuleVersion)) {
|
|
165
|
+
console.warn(chalk.cyan(`module ${key} is old`));
|
|
184
166
|
process.exit(0);
|
|
185
167
|
}
|
|
186
168
|
if (!__pushModule(context, modules, key)) {
|
|
@@ -192,18 +174,18 @@ function __orderDependencies(context, modules, module, moduleRelativeName) {
|
|
|
192
174
|
function __parseModules(context, projectPath) {
|
|
193
175
|
const modules = {};
|
|
194
176
|
for (const __path of context.pathsMeta.modules) {
|
|
195
|
-
const
|
|
196
|
-
const
|
|
197
|
-
|
|
177
|
+
const fileNames = globbySync(`${__path.prefix}*/package.json`, { cwd: projectPath });
|
|
178
|
+
for (const fileName of fileNames) {
|
|
179
|
+
const filePkg = path.join(projectPath, fileName);
|
|
198
180
|
// name
|
|
199
|
-
const name =
|
|
181
|
+
const name = fileName.split('/').slice(-2)[0];
|
|
200
182
|
// check if '-' prefix exists
|
|
201
183
|
if (name.substring(0, 1) === '-') {
|
|
202
184
|
// skip
|
|
203
185
|
continue;
|
|
204
186
|
}
|
|
205
187
|
// info
|
|
206
|
-
const info =
|
|
188
|
+
const info = parseInfoPro(name, context.options.projectMode, 'module');
|
|
207
189
|
if (!info) {
|
|
208
190
|
throw new Error(`module name is not valid: ${name}`);
|
|
209
191
|
}
|
|
@@ -215,7 +197,7 @@ function __parseModules(context, projectPath) {
|
|
|
215
197
|
info.node_modules = __path.node_modules;
|
|
216
198
|
info.originalName = name;
|
|
217
199
|
// resource
|
|
218
|
-
const root =
|
|
200
|
+
const root = path.dirname(filePkg);
|
|
219
201
|
const module = {
|
|
220
202
|
name,
|
|
221
203
|
info,
|
|
@@ -250,27 +232,27 @@ function __logModules(context, log) {
|
|
|
250
232
|
if (!log)
|
|
251
233
|
return;
|
|
252
234
|
// log
|
|
253
|
-
console.log(
|
|
235
|
+
console.log(chalk.yellow('\n=== Local Modules ==='));
|
|
254
236
|
for (const key in context.modulesLocal) {
|
|
255
|
-
console.log(
|
|
237
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
256
238
|
}
|
|
257
|
-
console.log(
|
|
239
|
+
console.log(chalk.yellow('\n=== Global Modules ==='));
|
|
258
240
|
for (const key in context.modulesGlobal) {
|
|
259
|
-
console.log(
|
|
241
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
260
242
|
}
|
|
261
|
-
console.log(
|
|
243
|
+
console.log(chalk.yellow('\n=== Monkey Modules ==='));
|
|
262
244
|
for (const key in context.modulesMonkey) {
|
|
263
|
-
console.log(
|
|
245
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
264
246
|
}
|
|
265
|
-
console.log(
|
|
247
|
+
console.log(chalk.yellow('\n=== Sync Modules ==='));
|
|
266
248
|
for (const key in context.modulesSync) {
|
|
267
|
-
console.log(
|
|
249
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
268
250
|
}
|
|
269
|
-
console.log(
|
|
251
|
+
console.log(chalk.yellow('\n=== Icon Modules ==='));
|
|
270
252
|
for (const key in context.modulesIcon) {
|
|
271
|
-
console.log(
|
|
253
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
272
254
|
}
|
|
273
|
-
console.log(
|
|
255
|
+
console.log(chalk.keyword('orange')(`\n=== Total Modules: ${context.modulesArray.length} ===`));
|
|
274
256
|
// console.log('\n');
|
|
275
257
|
}
|
|
276
258
|
function __logSuites(context, log) {
|
|
@@ -286,15 +268,15 @@ function __logSuites(context, log) {
|
|
|
286
268
|
if (!log)
|
|
287
269
|
return;
|
|
288
270
|
// log
|
|
289
|
-
console.log(
|
|
271
|
+
console.log(chalk.yellow('\n=== Local Suites ==='));
|
|
290
272
|
for (const key in context.suitesLocal) {
|
|
291
|
-
console.log(
|
|
273
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
292
274
|
}
|
|
293
|
-
console.log(
|
|
275
|
+
console.log(chalk.yellow('\n=== Vendor Suites ==='));
|
|
294
276
|
for (const key in context.suitesVendor) {
|
|
295
|
-
console.log(
|
|
277
|
+
console.log(chalk.cyan(`> ${key}`));
|
|
296
278
|
}
|
|
297
|
-
console.log(
|
|
279
|
+
console.log(chalk.keyword('orange')(`\n=== Total Suites: ${Object.keys(context.suites).length} ===`));
|
|
298
280
|
console.log('\n');
|
|
299
281
|
}
|
|
300
282
|
function __getDisabledModules(disabledModules) {
|
|
@@ -322,18 +304,18 @@ function __getDisabledSuites(disabledSuites) {
|
|
|
322
304
|
function __parseSuites(context, projectPath) {
|
|
323
305
|
const suites = {};
|
|
324
306
|
for (const __path of context.pathsMeta.suites) {
|
|
325
|
-
const
|
|
326
|
-
const
|
|
327
|
-
|
|
307
|
+
const fileNames = globbySync(`${__path.prefix}*/package.json`, { cwd: projectPath });
|
|
308
|
+
for (const fileName of fileNames) {
|
|
309
|
+
const filePkg = path.join(projectPath, fileName);
|
|
328
310
|
// name
|
|
329
|
-
const name =
|
|
311
|
+
const name = fileName.split('/').slice(-2)[0];
|
|
330
312
|
// check if '-' prefix exists
|
|
331
313
|
if (name.substring(0, 1) === '-') {
|
|
332
314
|
// skip
|
|
333
315
|
continue;
|
|
334
316
|
}
|
|
335
317
|
// info
|
|
336
|
-
const info =
|
|
318
|
+
const info = parseInfoPro(name, context.options.projectMode, 'suite');
|
|
337
319
|
if (!info) {
|
|
338
320
|
throw new Error(`suite name is not valid: ${name}`);
|
|
339
321
|
}
|
|
@@ -345,7 +327,7 @@ function __parseSuites(context, projectPath) {
|
|
|
345
327
|
info.node_modules = __path.node_modules;
|
|
346
328
|
info.originalName = name;
|
|
347
329
|
// suite
|
|
348
|
-
const root =
|
|
330
|
+
const root = path.dirname(filePkg);
|
|
349
331
|
const suite = {
|
|
350
332
|
name,
|
|
351
333
|
info,
|
|
@@ -360,8 +342,8 @@ function __parseSuites(context, projectPath) {
|
|
|
360
342
|
// ok
|
|
361
343
|
return suites;
|
|
362
344
|
}
|
|
363
|
-
const __suite_pattern1 = /src\/suite\/([
|
|
364
|
-
const __suite_pattern2 = /src\/suite-vendor\/([
|
|
345
|
+
const __suite_pattern1 = /src\/suite\/([^/]+)\/modules/;
|
|
346
|
+
const __suite_pattern2 = /src\/suite-vendor\/([^/]+)\/modules/;
|
|
365
347
|
function __bindSuitesModules(suites, modules) {
|
|
366
348
|
for (const moduleName in modules) {
|
|
367
349
|
const module = modules[moduleName];
|
|
@@ -409,9 +391,8 @@ function _checkSuiteValid(context, suites, suiteRelativeName) {
|
|
|
409
391
|
return false;
|
|
410
392
|
// check meta
|
|
411
393
|
const capabilities = suite.package.zovaModule?.capabilities ?? suite.package.vonaModule?.capabilities;
|
|
412
|
-
if (context.meta && capabilities && !
|
|
394
|
+
if (context.meta && capabilities && !checkMeta(capabilities.meta, context.meta))
|
|
413
395
|
return false;
|
|
414
396
|
// ok
|
|
415
397
|
return true;
|
|
416
398
|
}
|
|
417
|
-
//# 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.0",
|
|
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.1",
|
|
34
|
+
"@cabloy/utils": "^1.0.3"
|
|
41
35
|
}
|
|
42
36
|
}
|