wormajs 0.0.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/LICENSE +21 -0
- package/README.md +49 -0
- package/dist/bin/actions.js +245 -0
- package/dist/bin/cli.js +27 -0
- package/dist/bin/progressRenderer.js +47 -0
- package/dist/bin/renderer.js +551 -0
- package/dist/bin/theme.js +26 -0
- package/dist/config.js +19 -0
- package/dist/constant.js +162 -0
- package/dist/core/WorkerPool.js +102 -0
- package/dist/core/loader/astLoader/generates/array.js +34 -0
- package/dist/core/loader/astLoader/generates/enum.js +61 -0
- package/dist/core/loader/astLoader/generates/group.js +41 -0
- package/dist/core/loader/astLoader/generates/index.js +71 -0
- package/dist/core/loader/astLoader/generates/interface.js +59 -0
- package/dist/core/loader/astLoader/generates/simple.js +67 -0
- package/dist/core/loader/astLoader/generates/tuple.js +54 -0
- package/dist/core/loader/astLoader/generates/type.js +2 -0
- package/dist/core/loader/astLoader/generates/utils.js +86 -0
- package/dist/core/loader/astLoader/helper.js +21 -0
- package/dist/core/loader/astLoader/index.js +24 -0
- package/dist/core/loader/astLoader/normalize/index.js +70 -0
- package/dist/core/loader/astLoader/normalize/normalizer.js +69 -0
- package/dist/core/loader/astLoader/normalize/rules/convertTypeArray.js +68 -0
- package/dist/core/loader/astLoader/normalize/rules/handleEmptyType.js +8 -0
- package/dist/core/loader/astLoader/normalize/rules/inferType.js +43 -0
- package/dist/core/loader/astLoader/normalize/rules/mergeAnyOf.js +45 -0
- package/dist/core/loader/astLoader/normalize/rules/normalizeCombiningKeywords.js +26 -0
- package/dist/core/loader/astLoader/normalize/rules/normalizeEnum.js +38 -0
- package/dist/core/loader/astLoader/normalize/rules/normalizeNullType.js +24 -0
- package/dist/core/loader/astLoader/normalize/rules/removeRedundantKeywords.js +27 -0
- package/dist/core/loader/astLoader/normalize/rules/simplifySingleType.js +8 -0
- package/dist/core/loader/astLoader/normalize/rules/validateSchema.js +14 -0
- package/dist/core/loader/astLoader/parsers/array.js +28 -0
- package/dist/core/loader/astLoader/parsers/enum.js +49 -0
- package/dist/core/loader/astLoader/parsers/forward/array.js +12 -0
- package/dist/core/loader/astLoader/parsers/forward/enum.js +10 -0
- package/dist/core/loader/astLoader/parsers/forward/group.js +12 -0
- package/dist/core/loader/astLoader/parsers/forward/index.js +20 -0
- package/dist/core/loader/astLoader/parsers/forward/object.js +12 -0
- package/dist/core/loader/astLoader/parsers/forward/tuple.js +11 -0
- package/dist/core/loader/astLoader/parsers/forward/type.js +2 -0
- package/dist/core/loader/astLoader/parsers/group.js +50 -0
- package/dist/core/loader/astLoader/parsers/index.js +66 -0
- package/dist/core/loader/astLoader/parsers/object.js +44 -0
- package/dist/core/loader/astLoader/parsers/reference.js +41 -0
- package/dist/core/loader/astLoader/parsers/simple.js +48 -0
- package/dist/core/loader/astLoader/parsers/tuple.js +36 -0
- package/dist/core/loader/astLoader/parsers/type.js +2 -0
- package/dist/core/loader/astLoader/parsers/utils.js +58 -0
- package/dist/core/loader/callingCodeLoader/helper.js +183 -0
- package/dist/core/loader/callingCodeLoader/index.js +40 -0
- package/dist/core/loader/index.js +20 -0
- package/dist/core/loader/schemaLoader/index.js +101 -0
- package/dist/core/loader/standardLoader/helper.js +142 -0
- package/dist/core/loader/standardLoader/index.js +38 -0
- package/dist/core/loader/standardLoader/standards.js +105 -0
- package/dist/core/parser/index.js +18 -0
- package/dist/core/parser/openApiParser/helper.js +165 -0
- package/dist/core/parser/openApiParser/index.js +14 -0
- package/dist/core/parser/templateParser/helper.js +333 -0
- package/dist/core/parser/templateParser/index.js +314 -0
- package/dist/core/workerPool/index.js +6 -0
- package/dist/core/workerPool/poolManager.js +45 -0
- package/dist/core/workerPool/swagger2Worker.js +24 -0
- package/dist/core/workerPool/worker.js +61 -0
- package/dist/createConfig.js +37 -0
- package/dist/defineConfig.js +6 -0
- package/dist/functions/getAutoTemplateType.js +37 -0
- package/dist/functions/getFrameworkTag.js +18 -0
- package/dist/functions/prepareConfig.js +41 -0
- package/dist/functions/readWormaRc.js +155 -0
- package/dist/functions/wormaJson.js +232 -0
- package/dist/generate.js +84 -0
- package/dist/helper/PluginDriver.js +98 -0
- package/dist/helper/comment.js +88 -0
- package/dist/helper/config/ConfigHelper.js +79 -0
- package/dist/helper/config/ConfigManager.js +88 -0
- package/dist/helper/config/GeneratorHelper.js +343 -0
- package/dist/helper/config/index.js +19 -0
- package/dist/helper/config/type.js +2 -0
- package/dist/helper/config/zType.js +170 -0
- package/dist/helper/document/index.js +160 -0
- package/dist/helper/index.js +23 -0
- package/dist/helper/logger/index.js +76 -0
- package/dist/helper/progress.js +66 -0
- package/dist/helper/template/index.js +475 -0
- package/dist/index.js +33 -0
- package/dist/plugins/createPlugin.js +30 -0
- package/dist/plugins/index.js +34 -0
- package/dist/plugins/presets/aiDoc.js +173 -0
- package/dist/plugins/presets/apifox.js +56 -0
- package/dist/plugins/presets/filterApi.js +129 -0
- package/dist/plugins/presets/importType.js +49 -0
- package/dist/plugins/presets/payloadModifier/hepler.js +195 -0
- package/dist/plugins/presets/payloadModifier/index.js +122 -0
- package/dist/plugins/presets/payloadModifier/type.js +2 -0
- package/dist/plugins/presets/platform.js +73 -0
- package/dist/plugins/presets/rename.js +209 -0
- package/dist/plugins/presets/tagModifier.js +104 -0
- package/dist/plugins/presets/utils.js +36 -0
- package/dist/readConfig.js +92 -0
- package/dist/resolveWorkspaces.js +83 -0
- package/dist/template/index.js +180 -0
- package/dist/template/presets/ai-doc/SKILL.md.handlebars +29 -0
- package/dist/template/presets/ai-doc/references/{tag}/{api}.md.handlebars +54 -0
- package/dist/template/presets/alova/common/#index.cjs.handlebars +12 -0
- package/dist/template/presets/alova/common/components.d.cts.handlebars +1 -0
- package/dist/template/presets/alova/common/helper.cjs.handlebars +13 -0
- package/dist/template/presets/alova/common/services/#index.cjs.handlebars +13 -0
- package/dist/template/presets/alova/common/services/{tag}.cjs.handlebars +28 -0
- package/dist/template/presets/alova/common/services/{tag}.d.cts.handlebars +15 -0
- package/dist/template/presets/alova/common/typed.d.cts.handlebars +1 -0
- package/dist/template/presets/alova/module/#index.js.handlebars +12 -0
- package/dist/template/presets/alova/module/components.d.ts.handlebars +1 -0
- package/dist/template/presets/alova/module/helper.js.handlebars +11 -0
- package/dist/template/presets/alova/module/services/#index.js.handlebars +9 -0
- package/dist/template/presets/alova/module/services/{tag}.d.ts.handlebars +15 -0
- package/dist/template/presets/alova/module/services/{tag}.js.handlebars +21 -0
- package/dist/template/presets/alova/module/typed.d.ts.handlebars +1 -0
- package/dist/template/presets/alova/partials/api-jsdoc.handlebars +44 -0
- package/dist/template/presets/alova/partials/build-payload-body.handlebars +22 -0
- package/dist/template/presets/alova/partials/comment.handlebars +19 -0
- package/dist/template/presets/alova/partials/components-body.handlebars +4 -0
- package/dist/template/presets/alova/partials/dts-extra-config.handlebars +8 -0
- package/dist/template/presets/alova/partials/dts-fn-declare.handlebars +1 -0
- package/dist/template/presets/alova/partials/extract-responded.handlebars +11 -0
- package/dist/template/presets/alova/partials/stateshook-import.handlebars +9 -0
- package/dist/template/presets/alova/partials/stateshook-option.handlebars +9 -0
- package/dist/template/presets/alova/partials/typed-body.handlebars +43 -0
- package/dist/template/presets/alova/typescript/#index.ts.handlebars +14 -0
- package/dist/template/presets/alova/typescript/components.d.ts.handlebars +1 -0
- package/dist/template/presets/alova/typescript/helper.ts.handlebars +9 -0
- package/dist/template/presets/alova/typescript/services/#index.ts.handlebars +9 -0
- package/dist/template/presets/alova/typescript/services/{tag}.ts.handlebars +35 -0
- package/dist/template/presets/alova/typescript/typed.ts.handlebars +1 -0
- package/dist/template/presets/alova-globals/common/#index.cjs.handlebars +41 -0
- package/dist/template/presets/alova-globals/common/apiDefinitions.cjs.handlebars +12 -0
- package/dist/template/presets/alova-globals/common/createApis.cjs.handlebars +48 -0
- package/dist/template/presets/alova-globals/common/globals.d.cts.handlebars +2 -0
- package/dist/template/presets/alova-globals/module/#index.js.handlebars +2 -0
- package/dist/template/presets/alova-globals/module/apiDefinitions.js.handlebars +12 -0
- package/dist/template/presets/alova-globals/module/createApis.js.handlebars +44 -0
- package/dist/template/presets/alova-globals/module/globals.d.ts.handlebars +2 -0
- package/dist/template/presets/alova-globals/partials/comment.handlebars +19 -0
- package/dist/template/presets/alova-globals/partials/createApis-proxy-js.handlebars +55 -0
- package/dist/template/presets/alova-globals/partials/globals-d-ts.handlebars +148 -0
- package/dist/template/presets/alova-globals/partials/index-esm.handlebars +38 -0
- package/dist/template/presets/alova-globals/partials/withConfigType-jsdoc.handlebars +22 -0
- package/dist/template/presets/alova-globals/typescript/#index.ts.handlebars +2 -0
- package/dist/template/presets/alova-globals/typescript/apiDefinitions.ts.handlebars +12 -0
- package/dist/template/presets/alova-globals/typescript/createApis.ts.handlebars +99 -0
- package/dist/template/presets/alova-globals/typescript/globals.d.ts.handlebars +2 -0
- package/dist/template/presets/axios/common/#index.cjs.handlebars +22 -0
- package/dist/template/presets/axios/common/components.d.cts.handlebars +1 -0
- package/dist/template/presets/axios/common/helper.cjs.handlebars +27 -0
- package/dist/template/presets/axios/common/services/#index.cjs.handlebars +13 -0
- package/dist/template/presets/axios/common/services/{tag}.cjs.handlebars +28 -0
- package/dist/template/presets/axios/common/services/{tag}.d.cts.handlebars +11 -0
- package/dist/template/presets/axios/module/#index.js.handlebars +20 -0
- package/dist/template/presets/axios/module/components.d.ts.handlebars +1 -0
- package/dist/template/presets/axios/module/helper.js.handlebars +25 -0
- package/dist/template/presets/axios/module/services/#index.js.handlebars +9 -0
- package/dist/template/presets/axios/module/services/{tag}.d.ts.handlebars +11 -0
- package/dist/template/presets/axios/module/services/{tag}.js.handlebars +20 -0
- package/dist/template/presets/axios/partials/api-jsdoc.handlebars +44 -0
- package/dist/template/presets/axios/partials/comment.handlebars +19 -0
- package/dist/template/presets/axios/partials/components-body.handlebars +4 -0
- package/dist/template/presets/axios/partials/dts-fn-declare.handlebars +1 -0
- package/dist/template/presets/axios/partials/dts-types.handlebars +7 -0
- package/dist/template/presets/axios/typescript/#index.ts.handlebars +20 -0
- package/dist/template/presets/axios/typescript/components.d.ts.handlebars +1 -0
- package/dist/template/presets/axios/typescript/helper.ts.handlebars +28 -0
- package/dist/template/presets/axios/typescript/services/#index.ts.handlebars +9 -0
- package/dist/template/presets/axios/typescript/services/{tag}.ts.handlebars +31 -0
- package/dist/template/presets/config/common/worma.config.js.handlebars +9 -0
- package/dist/template/presets/config/module/worma.config.js.handlebars +9 -0
- package/dist/template/presets/config/partials/generator-content.handlebars +45 -0
- package/dist/template/presets/config/typescript/worma.config.ts.handlebars +9 -0
- package/dist/template/presets/fetch/common/#index.cjs.handlebars +17 -0
- package/dist/template/presets/fetch/common/FetchClient.cjs.handlebars +48 -0
- package/dist/template/presets/fetch/common/components.d.cts.handlebars +1 -0
- package/dist/template/presets/fetch/common/helper.cjs.handlebars +27 -0
- package/dist/template/presets/fetch/common/services/#index.cjs.handlebars +13 -0
- package/dist/template/presets/fetch/common/services/{tag}.cjs.handlebars +23 -0
- package/dist/template/presets/fetch/common/services/{tag}.d.cts.handlebars +10 -0
- package/dist/template/presets/fetch/module/#index.js.handlebars +15 -0
- package/dist/template/presets/fetch/module/FetchClient.js.handlebars +46 -0
- package/dist/template/presets/fetch/module/components.d.ts.handlebars +1 -0
- package/dist/template/presets/fetch/module/helper.js.handlebars +25 -0
- package/dist/template/presets/fetch/module/services/#index.js.handlebars +9 -0
- package/dist/template/presets/fetch/module/services/{tag}.d.ts.handlebars +10 -0
- package/dist/template/presets/fetch/module/services/{tag}.js.handlebars +15 -0
- package/dist/template/presets/fetch/partials/api-jsdoc.handlebars +44 -0
- package/dist/template/presets/fetch/partials/comment.handlebars +19 -0
- package/dist/template/presets/fetch/partials/components-body.handlebars +4 -0
- package/dist/template/presets/fetch/partials/dts-fn-declare.handlebars +1 -0
- package/dist/template/presets/fetch/partials/dts-types.handlebars +7 -0
- package/dist/template/presets/fetch/typescript/#index.ts.handlebars +15 -0
- package/dist/template/presets/fetch/typescript/FetchClient.ts.handlebars +59 -0
- package/dist/template/presets/fetch/typescript/components.d.ts.handlebars +1 -0
- package/dist/template/presets/fetch/typescript/helper.ts.handlebars +28 -0
- package/dist/template/presets/fetch/typescript/services/#index.ts.handlebars +9 -0
- package/dist/template/presets/fetch/typescript/services/{tag}.ts.handlebars +25 -0
- package/dist/template/presets/ky/module/#index.js.handlebars +14 -0
- package/dist/template/presets/ky/module/components.d.ts.handlebars +1 -0
- package/dist/template/presets/ky/module/helper.js.handlebars +27 -0
- package/dist/template/presets/ky/module/services/#index.js.handlebars +9 -0
- package/dist/template/presets/ky/module/services/{tag}.d.ts.handlebars +11 -0
- package/dist/template/presets/ky/module/services/{tag}.js.handlebars +19 -0
- package/dist/template/presets/ky/partials/api-jsdoc.handlebars +44 -0
- package/dist/template/presets/ky/partials/comment.handlebars +19 -0
- package/dist/template/presets/ky/partials/components-body.handlebars +4 -0
- package/dist/template/presets/ky/partials/dts-fn-declare.handlebars +1 -0
- package/dist/template/presets/ky/partials/dts-types.handlebars +9 -0
- package/dist/template/presets/ky/typescript/#index.ts.handlebars +14 -0
- package/dist/template/presets/ky/typescript/components.d.ts.handlebars +1 -0
- package/dist/template/presets/ky/typescript/helper.ts.handlebars +30 -0
- package/dist/template/presets/ky/typescript/services/#index.ts.handlebars +9 -0
- package/dist/template/presets/ky/typescript/services/{tag}.ts.handlebars +30 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/type/api.js +14 -0
- package/dist/type/ast.js +24 -0
- package/dist/type/base.js +17 -0
- package/dist/type/index.js +20 -0
- package/dist/type/lib.js +17 -0
- package/dist/type/openapi.js +2 -0
- package/dist/utils/base.js +212 -0
- package/dist/utils/format.js +64 -0
- package/dist/utils/index.js +21 -0
- package/dist/utils/openapi.js +417 -0
- package/dist/utils/readPackageJson.js +35 -0
- package/dist/utils/template.js +93 -0
- package/package.json +88 -0
- package/typings/index.d.ts +512 -0
- package/typings/plugins.d.ts +727 -0
|
@@ -0,0 +1,551 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InitRenderer = exports.INIT_TEMPLATE_CHOICES = exports.MultiProjectRenderer = exports.MultiGeneratorRenderer = void 0;
|
|
4
|
+
/* eslint-disable no-console */
|
|
5
|
+
const log_update_1 = require("log-update");
|
|
6
|
+
const theme_1 = require("./theme");
|
|
7
|
+
const BAR_WIDTH = 20;
|
|
8
|
+
function formatProgressBar(progress) {
|
|
9
|
+
const clamped = Math.max(0, Math.min(100, progress));
|
|
10
|
+
const filled = Math.round((clamped / 100) * BAR_WIDTH);
|
|
11
|
+
const empty = BAR_WIDTH - filled;
|
|
12
|
+
return theme_1.theme.header('█'.repeat(filled)) + theme_1.theme.dim('░'.repeat(empty));
|
|
13
|
+
}
|
|
14
|
+
function formatDuration(ms) {
|
|
15
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
16
|
+
}
|
|
17
|
+
function separatorWidth() {
|
|
18
|
+
const cols = process.stdout.columns || 80;
|
|
19
|
+
return Math.min(cols - 2, 60);
|
|
20
|
+
}
|
|
21
|
+
function sep() {
|
|
22
|
+
return theme_1.theme.dim('─'.repeat(separatorWidth()));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Terminal live-progress renderer for the `worma gen` command.
|
|
26
|
+
*
|
|
27
|
+
* Layout (three phases)
|
|
28
|
+
* ──────────────────────────────────────────
|
|
29
|
+
* Phase 1 — Pre-flight (static, printed once)
|
|
30
|
+
* Worma v2.0.0
|
|
31
|
+
*
|
|
32
|
+
* Config: ./worma.config.ts
|
|
33
|
+
* Generators: 3
|
|
34
|
+
* ─────
|
|
35
|
+
* ○ input1 → output1
|
|
36
|
+
* ○ input2 → output2
|
|
37
|
+
* ○ input3 → output3
|
|
38
|
+
* ─────
|
|
39
|
+
*
|
|
40
|
+
* Phase 2 — Generation (live-update via log-update)
|
|
41
|
+
* ✔ input1 → output1
|
|
42
|
+
*
|
|
43
|
+
* ◉ input2 → output2
|
|
44
|
+
* ██████████░░░░░░░░░░ 50% processing templates
|
|
45
|
+
*
|
|
46
|
+
* ○ input3 → output3
|
|
47
|
+
* ─────
|
|
48
|
+
* ⏱ 3.2s ✔ 1 ◉ 1 ○ 1 3 total
|
|
49
|
+
*
|
|
50
|
+
* Phase 3 — Summary (after done())
|
|
51
|
+
* ✔ Generated successfully!
|
|
52
|
+
* ──────────────────────────────────────────
|
|
53
|
+
*/
|
|
54
|
+
class MultiGeneratorRenderer {
|
|
55
|
+
constructor(generators, version, configPath) {
|
|
56
|
+
this.logUpdateInstance = null;
|
|
57
|
+
this.states = generators.map((g, i) => ({
|
|
58
|
+
index: i,
|
|
59
|
+
input: Array.isArray(g.input) ? (g.input[0] || '') : (g.input || ''),
|
|
60
|
+
output: g.output || '',
|
|
61
|
+
status: 'pending',
|
|
62
|
+
progress: 0,
|
|
63
|
+
stage: '',
|
|
64
|
+
}));
|
|
65
|
+
this.version = version;
|
|
66
|
+
this.startTime = Date.now();
|
|
67
|
+
// ── Phase 1: Pre-flight ──
|
|
68
|
+
this.printPreFlight(configPath);
|
|
69
|
+
// ── Phase 2: live-update area ──
|
|
70
|
+
this.logUpdateInstance = (0, log_update_1.createLogUpdate)(process.stdout, { showCursor: false });
|
|
71
|
+
this.render();
|
|
72
|
+
}
|
|
73
|
+
/** Print static pre-flight info (config path, generator count, input→output mapping). */
|
|
74
|
+
printPreFlight(configPath) {
|
|
75
|
+
const lines = [];
|
|
76
|
+
lines.push('');
|
|
77
|
+
lines.push(` ${theme_1.theme.header('Worma')} ${theme_1.theme.version(`v${this.version}`)}`);
|
|
78
|
+
lines.push('');
|
|
79
|
+
lines.push(` ${theme_1.theme.label('Config:')} ${theme_1.theme.path(configPath)}`);
|
|
80
|
+
lines.push(` ${theme_1.theme.label('Generators:')} ${this.states.length}`);
|
|
81
|
+
lines.push(` ${sep()}`);
|
|
82
|
+
lines.push('');
|
|
83
|
+
console.log(lines.join('\n'));
|
|
84
|
+
}
|
|
85
|
+
// ── State transitions ──────────────────────────────────────────
|
|
86
|
+
setActive(index) {
|
|
87
|
+
this.states[index].status = 'active';
|
|
88
|
+
this.states[index].startTime = Date.now();
|
|
89
|
+
this.states[index].progress = 0;
|
|
90
|
+
this.states[index].stage = 'starting';
|
|
91
|
+
this.render();
|
|
92
|
+
}
|
|
93
|
+
setProgress(index, progress, stage) {
|
|
94
|
+
const st = this.states[index];
|
|
95
|
+
// Guard: don't revert a terminal status back to active.
|
|
96
|
+
if (st.status === 'done' || st.status === 'failed' || st.status === 'skipped') {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
st.status = 'active';
|
|
100
|
+
st.progress = Math.max(0, Math.min(100, progress));
|
|
101
|
+
st.stage = stage;
|
|
102
|
+
this.render();
|
|
103
|
+
}
|
|
104
|
+
setDone(index, resolvedInput) {
|
|
105
|
+
const st = this.states[index];
|
|
106
|
+
st.status = 'done';
|
|
107
|
+
st.progress = 100;
|
|
108
|
+
st.stage = 'completed';
|
|
109
|
+
st.endTime = Date.now();
|
|
110
|
+
if (resolvedInput)
|
|
111
|
+
st.input = resolvedInput;
|
|
112
|
+
this.render();
|
|
113
|
+
}
|
|
114
|
+
setFailed(index, error) {
|
|
115
|
+
const st = this.states[index];
|
|
116
|
+
st.status = 'failed';
|
|
117
|
+
st.error = error;
|
|
118
|
+
st.endTime = Date.now();
|
|
119
|
+
this.render();
|
|
120
|
+
}
|
|
121
|
+
setSkipped(index, resolvedInput) {
|
|
122
|
+
const st = this.states[index];
|
|
123
|
+
st.status = 'skipped';
|
|
124
|
+
st.stage = 'skipped';
|
|
125
|
+
st.endTime = Date.now();
|
|
126
|
+
if (resolvedInput)
|
|
127
|
+
st.input = resolvedInput;
|
|
128
|
+
this.render();
|
|
129
|
+
}
|
|
130
|
+
// ── Phase 2: Live-update rendering ─────────────────────────────
|
|
131
|
+
render() {
|
|
132
|
+
if (!this.logUpdateInstance)
|
|
133
|
+
return;
|
|
134
|
+
const elapsed = ((Date.now() - this.startTime) / 1000).toFixed(1);
|
|
135
|
+
const doneCount = this.states.filter(s => s.status === 'done').length;
|
|
136
|
+
const failedCount = this.states.filter(s => s.status === 'failed').length;
|
|
137
|
+
const activeCount = this.states.filter(s => s.status === 'active').length;
|
|
138
|
+
const skippedCount = this.states.filter(s => s.status === 'skipped').length;
|
|
139
|
+
const lines = [];
|
|
140
|
+
// Generator rows
|
|
141
|
+
const maxInputLen = Math.max(...this.states.map(s => s.input.length), 8);
|
|
142
|
+
const maxOutputLen = Math.max(...this.states.map(s => s.output.length), 8);
|
|
143
|
+
for (const st of this.states) {
|
|
144
|
+
const icon = theme_1.icons[st.status];
|
|
145
|
+
const idx = `[${st.index + 1}/${this.states.length}]`;
|
|
146
|
+
const input = theme_1.theme.path(st.input.padEnd(maxInputLen));
|
|
147
|
+
const output = theme_1.theme.path(st.output.padEnd(maxOutputLen));
|
|
148
|
+
let row = ` ${icon} ${idx} ${input} ${theme_1.icons.arrow} ${output}`;
|
|
149
|
+
if (st.status === 'active') {
|
|
150
|
+
const bar = formatProgressBar(st.progress);
|
|
151
|
+
const pct = `${st.progress.toFixed(0).padStart(3)}%`;
|
|
152
|
+
const stage = st.stage ? ` ${theme_1.theme.stage(st.stage)}` : '';
|
|
153
|
+
row += `\n ${bar} ${pct}${stage}`;
|
|
154
|
+
}
|
|
155
|
+
else if (st.status === 'done') {
|
|
156
|
+
row += ` ${theme_1.theme.dim(formatDuration(st.endTime - st.startTime))}`;
|
|
157
|
+
}
|
|
158
|
+
else if (st.status === 'failed') {
|
|
159
|
+
row += `\n ${theme_1.theme.error(`✖ ${st.error || 'failed'}`)}`;
|
|
160
|
+
}
|
|
161
|
+
else if (st.status === 'skipped') {
|
|
162
|
+
row += ` ${theme_1.theme.dim('up-to-date')}`;
|
|
163
|
+
}
|
|
164
|
+
// Add blank line between rows for readability
|
|
165
|
+
lines.push(row);
|
|
166
|
+
lines.push('');
|
|
167
|
+
}
|
|
168
|
+
// Status bar
|
|
169
|
+
lines.push(` ${sep()}`);
|
|
170
|
+
const parts = [];
|
|
171
|
+
parts.push(`${theme_1.theme.label('⏱')} ${elapsed}s`);
|
|
172
|
+
if (doneCount > 0)
|
|
173
|
+
parts.push(`${theme_1.theme.success(`✔ ${doneCount}`)}`);
|
|
174
|
+
if (failedCount > 0)
|
|
175
|
+
parts.push(`${theme_1.theme.error(`✖ ${failedCount}`)}`);
|
|
176
|
+
if (activeCount > 0)
|
|
177
|
+
parts.push(`${theme_1.theme.header(`◉ ${activeCount}`)}`);
|
|
178
|
+
if (skippedCount > 0)
|
|
179
|
+
parts.push(`${theme_1.theme.warning(`⊗ ${skippedCount}`)}`);
|
|
180
|
+
parts.push(`${theme_1.theme.dim(`${this.states.length} total`)}`);
|
|
181
|
+
lines.push(` ${parts.join(' ')}`);
|
|
182
|
+
this.logUpdateInstance(lines.join('\n'));
|
|
183
|
+
}
|
|
184
|
+
// ── Phase 3: Summary ───────────────────────────────────────────
|
|
185
|
+
/**
|
|
186
|
+
* Finalize the display: stop live-update (keep last render visible),
|
|
187
|
+
* then show a concise ✔ / ✖ result.
|
|
188
|
+
*
|
|
189
|
+
* @param failedCount - Number of generators that ended in failure.
|
|
190
|
+
*/
|
|
191
|
+
finalize(failedCount) {
|
|
192
|
+
if (this.logUpdateInstance) {
|
|
193
|
+
this.render(); // ensure final state
|
|
194
|
+
this.logUpdateInstance.done();
|
|
195
|
+
this.logUpdateInstance = null;
|
|
196
|
+
}
|
|
197
|
+
if (failedCount === 0) {
|
|
198
|
+
console.log(theme_1.theme.success('\n✔ Generated successfully!\n'));
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
console.log(theme_1.theme.dim('\n Try `worma gen -f` to force regenerate.\n'));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
exports.MultiGeneratorRenderer = MultiGeneratorRenderer;
|
|
206
|
+
/**
|
|
207
|
+
* Terminal live-progress renderer for the `worma gen` command in monorepo
|
|
208
|
+
* (multi-project) mode.
|
|
209
|
+
*
|
|
210
|
+
* Displays every sub-package's generator progress simultaneously so the user
|
|
211
|
+
* can see all projects at a glance.
|
|
212
|
+
*
|
|
213
|
+
* Layout
|
|
214
|
+
* ──────────────────────────────────────────
|
|
215
|
+
* Worma v2.0.0
|
|
216
|
+
* Packages: 3
|
|
217
|
+
*
|
|
218
|
+
* ── Project 1/3 packages/a ──────────────────────
|
|
219
|
+
* Config: ./packages/a/worma.config.ts
|
|
220
|
+
* Generators: 2
|
|
221
|
+
* ─────
|
|
222
|
+
* ○ [1/2] inputA1 → outputA1
|
|
223
|
+
* ○ [2/2] inputA2 → outputA2
|
|
224
|
+
*
|
|
225
|
+
* ── Project 2/3 packages/b ──────────────────────
|
|
226
|
+
* Config: ./packages/b/worma.config.ts
|
|
227
|
+
* Generators: 2
|
|
228
|
+
* ─────
|
|
229
|
+
* ✔ [1/2] inputB1 → outputB1 2.1s
|
|
230
|
+
* ◉ [2/2] inputB2 → outputB2
|
|
231
|
+
* ██████░░░░░░░░░░░░ 30% parsing openapi
|
|
232
|
+
* ─────
|
|
233
|
+
* ⏱ 5.2s ✔ 1 ◉ 1 ○ 0 2 generators
|
|
234
|
+
*
|
|
235
|
+
* ── Project 3/3 packages/c ──────────────────────
|
|
236
|
+
* ...
|
|
237
|
+
* ─────
|
|
238
|
+
* ⏱ 5.2s ✔ 2 ◉ 1 ○ 2 5 generators
|
|
239
|
+
*
|
|
240
|
+
* ──────────────────────────────────────────
|
|
241
|
+
* ⏱ 8.3s ✔ 5 ◉ 1 ○ 3 9 total
|
|
242
|
+
* ──────────────────────────────────────────
|
|
243
|
+
*/
|
|
244
|
+
class MultiProjectRenderer {
|
|
245
|
+
constructor(projects, version) {
|
|
246
|
+
this.logUpdateInstance = null;
|
|
247
|
+
this.projects = projects.map(info => ({
|
|
248
|
+
info,
|
|
249
|
+
states: info.generators.map((g, i) => ({
|
|
250
|
+
index: i,
|
|
251
|
+
input: Array.isArray(g.input) ? (g.input[0] || '') : (g.input || ''),
|
|
252
|
+
output: g.output || '',
|
|
253
|
+
status: 'pending',
|
|
254
|
+
progress: 0,
|
|
255
|
+
stage: '',
|
|
256
|
+
})),
|
|
257
|
+
startTime: Date.now(),
|
|
258
|
+
}));
|
|
259
|
+
this.version = version;
|
|
260
|
+
// ── Phase 1: Pre-flight ──
|
|
261
|
+
this.printPreFlight();
|
|
262
|
+
// ── Phase 2: live-update area ──
|
|
263
|
+
this.logUpdateInstance = (0, log_update_1.createLogUpdate)(process.stdout, { showCursor: false });
|
|
264
|
+
this.render();
|
|
265
|
+
}
|
|
266
|
+
// ── State transitions ──────────────────────────────────────────
|
|
267
|
+
/** Route a per-generator progress event to its project. */
|
|
268
|
+
onProjectEvent(projectIndex, event) {
|
|
269
|
+
const proj = this.projects[projectIndex];
|
|
270
|
+
if (!proj)
|
|
271
|
+
return;
|
|
272
|
+
const st = proj.states[event.index];
|
|
273
|
+
if (!st)
|
|
274
|
+
return;
|
|
275
|
+
switch (event.phase) {
|
|
276
|
+
case 'active':
|
|
277
|
+
st.status = 'active';
|
|
278
|
+
st.startTime = Date.now();
|
|
279
|
+
st.progress = 0;
|
|
280
|
+
st.stage = 'starting';
|
|
281
|
+
break;
|
|
282
|
+
case 'progress':
|
|
283
|
+
// Guard: don't revert a terminal status back to active.
|
|
284
|
+
if (st.status === 'done' || st.status === 'failed' || st.status === 'skipped') {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
st.status = 'active';
|
|
288
|
+
st.progress = Math.max(0, Math.min(100, event.progress));
|
|
289
|
+
st.stage = event.message;
|
|
290
|
+
break;
|
|
291
|
+
case 'done':
|
|
292
|
+
st.status = 'done';
|
|
293
|
+
st.progress = 100;
|
|
294
|
+
st.stage = 'completed';
|
|
295
|
+
st.endTime = Date.now();
|
|
296
|
+
if (event.resolvedInput)
|
|
297
|
+
st.input = event.resolvedInput;
|
|
298
|
+
break;
|
|
299
|
+
case 'failed':
|
|
300
|
+
st.status = 'failed';
|
|
301
|
+
st.error = event.error;
|
|
302
|
+
st.endTime = Date.now();
|
|
303
|
+
break;
|
|
304
|
+
case 'skipped':
|
|
305
|
+
st.status = 'skipped';
|
|
306
|
+
st.stage = 'skipped';
|
|
307
|
+
st.endTime = Date.now();
|
|
308
|
+
if (event.resolvedInput)
|
|
309
|
+
st.input = event.resolvedInput;
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
this.render();
|
|
313
|
+
}
|
|
314
|
+
// ── Phase 1: Pre-flight ─────────────────────────────────────
|
|
315
|
+
/**
|
|
316
|
+
* Print a minimal static header. All project details (generator
|
|
317
|
+
* mappings, progress, status) live inside the `log-update` area
|
|
318
|
+
* so that every project remains visible regardless of terminal
|
|
319
|
+
* height and project count.
|
|
320
|
+
*/
|
|
321
|
+
printPreFlight() {
|
|
322
|
+
const lines = [];
|
|
323
|
+
lines.push('');
|
|
324
|
+
lines.push(` ${theme_1.theme.header('Worma')} ${theme_1.theme.version(`v${this.version}`)}`);
|
|
325
|
+
lines.push(` ${theme_1.theme.label('Packages:')} ${this.projects.length}`);
|
|
326
|
+
lines.push('');
|
|
327
|
+
console.log(lines.join('\n'));
|
|
328
|
+
}
|
|
329
|
+
// ── Phase 2: Live-update rendering ─────────────────────────────
|
|
330
|
+
render() {
|
|
331
|
+
if (!this.logUpdateInstance)
|
|
332
|
+
return;
|
|
333
|
+
const lines = [];
|
|
334
|
+
for (let pi = 0; pi < this.projects.length; pi++) {
|
|
335
|
+
const proj = this.projects[pi];
|
|
336
|
+
const doneCount = proj.states.filter(s => s.status === 'done').length;
|
|
337
|
+
const failedCount = proj.states.filter(s => s.status === 'failed').length;
|
|
338
|
+
const activeCount = proj.states.filter(s => s.status === 'active').length;
|
|
339
|
+
const skippedCount = proj.states.filter(s => s.status === 'skipped').length;
|
|
340
|
+
const pendingCount = proj.states.filter(s => s.status === 'pending').length;
|
|
341
|
+
const elapsed = ((Date.now() - proj.startTime) / 1000).toFixed(1);
|
|
342
|
+
const allTerminal = pendingCount === 0 && activeCount === 0;
|
|
343
|
+
if (allTerminal) {
|
|
344
|
+
// ── Collapsed: one-line summary for completed projects ──
|
|
345
|
+
const parts = [];
|
|
346
|
+
if (failedCount > 0) {
|
|
347
|
+
parts.push(theme_1.theme.error('✖'));
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
parts.push(theme_1.theme.success('✔'));
|
|
351
|
+
}
|
|
352
|
+
parts.push(theme_1.theme.header(`Project ${pi + 1}/${this.projects.length}`));
|
|
353
|
+
parts.push(theme_1.theme.path(proj.info.dir));
|
|
354
|
+
parts.push(`${theme_1.theme.label('⏱')} ${elapsed}s`);
|
|
355
|
+
if (doneCount > 0)
|
|
356
|
+
parts.push(theme_1.theme.success(`✔ ${doneCount}`));
|
|
357
|
+
if (failedCount > 0)
|
|
358
|
+
parts.push(theme_1.theme.error(`✖ ${failedCount}`));
|
|
359
|
+
if (skippedCount > 0)
|
|
360
|
+
parts.push(theme_1.theme.warning(`⊗ ${skippedCount}`));
|
|
361
|
+
lines.push(` ${parts.join(' ')}`);
|
|
362
|
+
// Show error details for failed generators in collapsed projects
|
|
363
|
+
if (failedCount > 0) {
|
|
364
|
+
for (const st of proj.states) {
|
|
365
|
+
if (st.status === 'failed' && st.error) {
|
|
366
|
+
lines.push(` ${theme_1.theme.error(`✖ ${st.error}`)}`);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
// ── Expanded: full project detail ──
|
|
373
|
+
lines.push(` ${theme_1.theme.header(`── Project ${pi + 1}/${this.projects.length}`)} ${theme_1.theme.path(proj.info.dir)} ${theme_1.theme.dim('─'.repeat(Math.max(0, 20)))}`);
|
|
374
|
+
lines.push(` ${theme_1.theme.label('Config:')} ${theme_1.theme.path(proj.info.configPath)}`);
|
|
375
|
+
lines.push(` ${theme_1.theme.label('Generators:')} ${proj.states.length}`);
|
|
376
|
+
lines.push(` ${theme_1.theme.dim('─'.repeat(5))}`);
|
|
377
|
+
// Generator rows
|
|
378
|
+
const maxInputLen = Math.max(...proj.states.map(s => s.input.length), 8);
|
|
379
|
+
const maxOutputLen = Math.max(...proj.states.map(s => s.output.length), 8);
|
|
380
|
+
for (const st of proj.states) {
|
|
381
|
+
const icon = theme_1.icons[st.status];
|
|
382
|
+
const idx = `[${st.index + 1}/${proj.states.length}]`;
|
|
383
|
+
const input = theme_1.theme.path(st.input.padEnd(maxInputLen));
|
|
384
|
+
const output = theme_1.theme.path(st.output.padEnd(maxOutputLen));
|
|
385
|
+
let row = ` ${icon} ${idx} ${input} ${theme_1.icons.arrow} ${output}`;
|
|
386
|
+
if (st.status === 'active') {
|
|
387
|
+
const bar = formatProgressBar(st.progress);
|
|
388
|
+
const pct = `${st.progress.toFixed(0).padStart(3)}%`;
|
|
389
|
+
const stage = st.stage ? ` ${theme_1.theme.stage(st.stage)}` : '';
|
|
390
|
+
row += `\n ${bar} ${pct}${stage}`;
|
|
391
|
+
}
|
|
392
|
+
else if (st.status === 'done') {
|
|
393
|
+
row += ` ${theme_1.theme.dim(formatDuration(st.endTime - st.startTime))}`;
|
|
394
|
+
}
|
|
395
|
+
else if (st.status === 'failed') {
|
|
396
|
+
row += `\n ${theme_1.theme.error(`✖ ${st.error || 'failed'}`)}`;
|
|
397
|
+
}
|
|
398
|
+
else if (st.status === 'skipped') {
|
|
399
|
+
row += ` ${theme_1.theme.dim('up-to-date')}`;
|
|
400
|
+
}
|
|
401
|
+
lines.push(row);
|
|
402
|
+
lines.push('');
|
|
403
|
+
}
|
|
404
|
+
lines.push(` ${theme_1.theme.dim('─'.repeat(5))}`);
|
|
405
|
+
// Per-project status bar
|
|
406
|
+
const parts = [];
|
|
407
|
+
parts.push(`${theme_1.theme.label('⏱')} ${elapsed}s`);
|
|
408
|
+
if (doneCount > 0)
|
|
409
|
+
parts.push(`${theme_1.theme.success(`✔ ${doneCount}`)}`);
|
|
410
|
+
if (failedCount > 0)
|
|
411
|
+
parts.push(`${theme_1.theme.error(`✖ ${failedCount}`)}`);
|
|
412
|
+
if (activeCount > 0)
|
|
413
|
+
parts.push(`${theme_1.theme.header(`◉ ${activeCount}`)}`);
|
|
414
|
+
if (skippedCount > 0)
|
|
415
|
+
parts.push(`${theme_1.theme.warning(`⊗ ${skippedCount}`)}`);
|
|
416
|
+
parts.push(`${theme_1.theme.dim(`${proj.states.length} generators`)}`);
|
|
417
|
+
lines.push(` ${parts.join(' ')}`);
|
|
418
|
+
}
|
|
419
|
+
if (pi < this.projects.length - 1) {
|
|
420
|
+
lines.push('');
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
// Global separator and aggregate stats
|
|
424
|
+
lines.push(` ${sep()}`);
|
|
425
|
+
let totalDone = 0;
|
|
426
|
+
let totalFailed = 0;
|
|
427
|
+
let totalActive = 0;
|
|
428
|
+
let totalSkipped = 0;
|
|
429
|
+
let totalGens = 0;
|
|
430
|
+
for (const proj of this.projects) {
|
|
431
|
+
totalDone += proj.states.filter(s => s.status === 'done').length;
|
|
432
|
+
totalFailed += proj.states.filter(s => s.status === 'failed').length;
|
|
433
|
+
totalActive += proj.states.filter(s => s.status === 'active').length;
|
|
434
|
+
totalSkipped += proj.states.filter(s => s.status === 'skipped').length;
|
|
435
|
+
totalGens += proj.states.length;
|
|
436
|
+
}
|
|
437
|
+
const totalElapsed = ((Date.now() - this.projects[0].startTime) / 1000).toFixed(1);
|
|
438
|
+
const totalParts = [];
|
|
439
|
+
totalParts.push(`${theme_1.theme.label('⏱')} ${totalElapsed}s`);
|
|
440
|
+
if (totalDone > 0)
|
|
441
|
+
totalParts.push(`${theme_1.theme.success(`✔ ${totalDone}`)}`);
|
|
442
|
+
if (totalFailed > 0)
|
|
443
|
+
totalParts.push(`${theme_1.theme.error(`✖ ${totalFailed}`)}`);
|
|
444
|
+
if (totalActive > 0)
|
|
445
|
+
totalParts.push(`${theme_1.theme.header(`◉ ${totalActive}`)}`);
|
|
446
|
+
if (totalSkipped > 0)
|
|
447
|
+
totalParts.push(`${theme_1.theme.warning(`⊗ ${totalSkipped}`)}`);
|
|
448
|
+
totalParts.push(`${theme_1.theme.dim(`${totalGens} total`)}`);
|
|
449
|
+
lines.push(` ${totalParts.join(' ')}`);
|
|
450
|
+
this.logUpdateInstance(lines.join('\n'));
|
|
451
|
+
}
|
|
452
|
+
// ── Phase 3: Summary ───────────────────────────────────────────
|
|
453
|
+
/**
|
|
454
|
+
* Finalize the display: stop live-update, then show a concise ✔ / ✖ summary.
|
|
455
|
+
*
|
|
456
|
+
* @param allResults - `boolean[][]` array of per-project per-generator results.
|
|
457
|
+
*/
|
|
458
|
+
finalize(allResults) {
|
|
459
|
+
if (this.logUpdateInstance) {
|
|
460
|
+
this.render(); // ensure final state
|
|
461
|
+
this.logUpdateInstance.done();
|
|
462
|
+
this.logUpdateInstance = null;
|
|
463
|
+
}
|
|
464
|
+
const totalFailed = allResults.flat().filter(r => !r).length;
|
|
465
|
+
if (totalFailed === 0) {
|
|
466
|
+
console.log(theme_1.theme.success('\n✔ Generated successfully!\n'));
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
console.log(theme_1.theme.dim('\n Try `worma gen -f` to force regenerate.\n'));
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
exports.MultiProjectRenderer = MultiProjectRenderer;
|
|
474
|
+
// ─────────────────────────────────────────────────────────────────
|
|
475
|
+
// InitRenderer — static display for `worma init`
|
|
476
|
+
// ─────────────────────────────────────────────────────────────────
|
|
477
|
+
/** Available template presets for interactive selection. */
|
|
478
|
+
exports.INIT_TEMPLATE_CHOICES = [
|
|
479
|
+
{ name: 'alova', value: 'alova' },
|
|
480
|
+
{ name: 'axios', value: 'axios' },
|
|
481
|
+
{ name: 'fetch', value: 'fetch' },
|
|
482
|
+
{ name: 'ky', value: 'ky' },
|
|
483
|
+
];
|
|
484
|
+
/**
|
|
485
|
+
* Static-display renderer for the `alova init` command.
|
|
486
|
+
*
|
|
487
|
+
* Unlike MultiGeneratorRenderer / MultiProjectRenderer, init does NOT use
|
|
488
|
+
* log-update — it's a linear, single-step operation with no live progress.
|
|
489
|
+
*
|
|
490
|
+
* Layout
|
|
491
|
+
* ──────────────────────────────────────────
|
|
492
|
+
* Worma v2.0.0
|
|
493
|
+
*
|
|
494
|
+
* Project: /Users/me/my-project
|
|
495
|
+
* Type: typescript (auto-detected)
|
|
496
|
+
* Template: alova
|
|
497
|
+
* Output: /Users/me/my-project/worma.config.ts
|
|
498
|
+
*
|
|
499
|
+
* ──────────────────────────────────────────
|
|
500
|
+
* ✔ Configuration initialized successfully!
|
|
501
|
+
*
|
|
502
|
+
* Next steps:
|
|
503
|
+
* worma gen
|
|
504
|
+
*/
|
|
505
|
+
class InitRenderer {
|
|
506
|
+
constructor(version) {
|
|
507
|
+
this.version = version;
|
|
508
|
+
}
|
|
509
|
+
/** Print the unified header (shared with gen command). */
|
|
510
|
+
printHeader() {
|
|
511
|
+
console.log('');
|
|
512
|
+
console.log(` ${theme_1.theme.header('Worma')} ${theme_1.theme.version(`v${this.version}`)}`);
|
|
513
|
+
console.log('');
|
|
514
|
+
}
|
|
515
|
+
/** Print project and type info (shown before template selection / overwrite check). */
|
|
516
|
+
printProjectInfo(projectPath, type, isAutoDetected) {
|
|
517
|
+
const typeDisplay = isAutoDetected
|
|
518
|
+
? `${type} ${theme_1.theme.dim('(auto-detected)')}`
|
|
519
|
+
: type;
|
|
520
|
+
console.log(` ${theme_1.theme.label('Project:')} ${theme_1.theme.path(projectPath)}`);
|
|
521
|
+
console.log(` ${theme_1.theme.label('Type:')} ${typeDisplay}`);
|
|
522
|
+
}
|
|
523
|
+
/** Print template preset and output path (shown after template is determined). */
|
|
524
|
+
printConfigInfo(template, outputPath) {
|
|
525
|
+
console.log(` ${theme_1.theme.label('Template:')} ${template}`);
|
|
526
|
+
console.log(` ${theme_1.theme.label('Output:')} ${theme_1.theme.path(outputPath)}`);
|
|
527
|
+
}
|
|
528
|
+
/** Print the separator line. */
|
|
529
|
+
printSeparator() {
|
|
530
|
+
console.log(` ${sep()}`);
|
|
531
|
+
}
|
|
532
|
+
/** Print success summary with next-steps hint. */
|
|
533
|
+
printSuccess() {
|
|
534
|
+
console.log(theme_1.theme.success('✔ Configuration initialized successfully!'));
|
|
535
|
+
console.log('');
|
|
536
|
+
console.log(` ${theme_1.theme.label('Next steps:')}`);
|
|
537
|
+
console.log(' worma gen');
|
|
538
|
+
console.log('');
|
|
539
|
+
}
|
|
540
|
+
/** Print skipped result (config file already exists). */
|
|
541
|
+
printSkipped(outputPath) {
|
|
542
|
+
console.log(theme_1.icons.skipped + theme_1.theme.dim(` Skipped: ${outputPath} already exists`));
|
|
543
|
+
console.log('');
|
|
544
|
+
}
|
|
545
|
+
/** Print failure result. */
|
|
546
|
+
printFailure(error) {
|
|
547
|
+
console.log(theme_1.theme.error(`✖ ${error}`));
|
|
548
|
+
console.log('');
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
exports.InitRenderer = InitRenderer;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.icons = exports.theme = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
exports.theme = {
|
|
9
|
+
header: chalk_1.default.bold,
|
|
10
|
+
version: chalk_1.default.dim,
|
|
11
|
+
success: chalk_1.default.green,
|
|
12
|
+
error: chalk_1.default.red,
|
|
13
|
+
warning: chalk_1.default.yellow,
|
|
14
|
+
label: chalk_1.default.bold,
|
|
15
|
+
path: chalk_1.default.reset,
|
|
16
|
+
stage: chalk_1.default.reset,
|
|
17
|
+
dim: chalk_1.default.dim,
|
|
18
|
+
};
|
|
19
|
+
exports.icons = {
|
|
20
|
+
pending: chalk_1.default.dim('○'),
|
|
21
|
+
active: chalk_1.default.bold('◉'),
|
|
22
|
+
done: chalk_1.default.green('✔'),
|
|
23
|
+
failed: chalk_1.default.red('✖'),
|
|
24
|
+
skipped: chalk_1.default.yellow('⊗'),
|
|
25
|
+
arrow: chalk_1.default.dim('→'),
|
|
26
|
+
};
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGlobalConfig = getGlobalConfig;
|
|
4
|
+
exports.setGlobalConfig = setGlobalConfig;
|
|
5
|
+
const DEFAULT_CONFIG = {
|
|
6
|
+
cacheDir: '.worma-cache',
|
|
7
|
+
/** Overrides cacheDir's parent directory for monorepo unified cache. */
|
|
8
|
+
cacheRoot: undefined,
|
|
9
|
+
Error,
|
|
10
|
+
templateData: new Map(),
|
|
11
|
+
};
|
|
12
|
+
globalThis.WORMA_CONFIG = DEFAULT_CONFIG;
|
|
13
|
+
function getGlobalConfig() {
|
|
14
|
+
return globalThis.WORMA_CONFIG;
|
|
15
|
+
}
|
|
16
|
+
function setGlobalConfig(config) {
|
|
17
|
+
Object.assign(globalThis.WORMA_CONFIG, config);
|
|
18
|
+
}
|
|
19
|
+
exports.default = { getGlobalConfig, setGlobalConfig };
|