@kubb/cli 3.7.1 → 3.7.2
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/{chunk-PUR4OZA2.cjs → chunk-C3II7A6I.cjs} +65 -145
- package/dist/chunk-C3II7A6I.cjs.map +1 -0
- package/dist/{chunk-LA3QWVJI.js → chunk-SMSDJUVC.js} +28 -23
- package/dist/chunk-SMSDJUVC.js.map +1 -0
- package/dist/{generate-Q72KJ3UY.js → generate-F47H4EHK.js} +75 -18
- package/dist/generate-F47H4EHK.js.map +1 -0
- package/dist/{generate-YUAX4RQZ.cjs → generate-LDGBIA4T.cjs} +84 -25
- package/dist/generate-LDGBIA4T.cjs.map +1 -0
- package/dist/index.cjs +9 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/package.json +8 -6
- package/src/commands/generate.ts +84 -15
- package/src/generate.ts +20 -11
- package/src/index.ts +3 -0
- package/src/utils/Writables.ts +2 -2
- package/src/utils/executeHooks.ts +3 -3
- package/src/utils/getSummary.ts +8 -8
- package/src/utils/watcher.ts +3 -3
- package/dist/chunk-LA3QWVJI.js.map +0 -1
- package/dist/chunk-PUR4OZA2.cjs.map +0 -1
- package/dist/generate-Q72KJ3UY.js.map +0 -1
- package/dist/generate-YUAX4RQZ.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkC3II7A6I_cjs = require('./chunk-C3II7A6I.cjs');
|
|
4
4
|
var citty = require('citty');
|
|
5
5
|
var getLatestVersion = require('latest-version');
|
|
6
6
|
var semver = require('semver');
|
|
7
|
+
var gradientString = require('gradient-string');
|
|
7
8
|
var consola = require('consola');
|
|
8
9
|
|
|
9
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
11
|
|
|
11
12
|
var getLatestVersion__default = /*#__PURE__*/_interopDefault(getLatestVersion);
|
|
13
|
+
var gradientString__default = /*#__PURE__*/_interopDefault(gradientString);
|
|
12
14
|
var consola__default = /*#__PURE__*/_interopDefault(consola);
|
|
13
15
|
|
|
14
16
|
// src/index.ts
|
|
15
|
-
|
|
17
|
+
chunkC3II7A6I_cjs.init_cjs_shims();
|
|
16
18
|
|
|
17
19
|
// package.json
|
|
18
|
-
var version = "3.7.
|
|
20
|
+
var version = "3.7.2";
|
|
19
21
|
var name = "kubb";
|
|
20
22
|
var main = citty.defineCommand({
|
|
21
23
|
meta: {
|
|
@@ -25,6 +27,7 @@ var main = citty.defineCommand({
|
|
|
25
27
|
},
|
|
26
28
|
async setup({ rawArgs }) {
|
|
27
29
|
try {
|
|
30
|
+
consola__default.default.log(gradientString__default.default(["#F58517", "#F5A217", "#F55A17"])("Kubb CLI:"));
|
|
28
31
|
const latestVersion = await getLatestVersion__default.default("@kubb/cli");
|
|
29
32
|
if (semver.lt(version, latestVersion)) {
|
|
30
33
|
consola__default.default.box({
|
|
@@ -41,13 +44,13 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
41
44
|
} catch (_e) {
|
|
42
45
|
}
|
|
43
46
|
if (rawArgs[0] !== "generate") {
|
|
44
|
-
const generateCommand = await import('./generate-
|
|
47
|
+
const generateCommand = await import('./generate-LDGBIA4T.cjs').then((r) => r.default);
|
|
45
48
|
await citty.runCommand(generateCommand, { rawArgs });
|
|
46
49
|
process.exit(0);
|
|
47
50
|
}
|
|
48
51
|
},
|
|
49
52
|
subCommands: {
|
|
50
|
-
generate: () => import('./generate-
|
|
53
|
+
generate: () => import('./generate-LDGBIA4T.cjs').then((r) => r.default)
|
|
51
54
|
}
|
|
52
55
|
});
|
|
53
56
|
async function run(_argv) {
|
|
@@ -56,7 +59,7 @@ async function run(_argv) {
|
|
|
56
59
|
|
|
57
60
|
Object.defineProperty(exports, "generate", {
|
|
58
61
|
enumerable: true,
|
|
59
|
-
get: function () { return
|
|
62
|
+
get: function () { return chunkC3II7A6I_cjs.generate; }
|
|
60
63
|
});
|
|
61
64
|
exports.run = run;
|
|
62
65
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../package.json"],"names":["init_cjs_shims","defineCommand","
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../package.json"],"names":["init_cjs_shims","defineCommand","consola","gradientString","getLatestVersion","lt","runCommand","runMain"],"mappings":";;;;;;;;;;;;;;;;AAAAA,gCAAA,EAAA;;;ACEE,IAAW,OAAA,GAAA,OAAA;ADMb,IAAM,IAAO,GAAA,MAAA;AAEb,IAAM,OAAOC,mBAAc,CAAA;AAAA,EACzB,IAAM,EAAA;AAAA,IACJ,IAAA;AAAA,IACA,OAAA;AAAA,IACA,WAAa,EAAA;AAAA,GACf;AAAA,EACA,MAAM,KAAA,CAAM,EAAE,OAAA,EAAW,EAAA;AACvB,IAAI,IAAA;AACF,MAAQC,wBAAA,CAAA,GAAA,CAAIC,gCAAe,CAAC,SAAA,EAAW,WAAW,SAAS,CAAC,CAAE,CAAA,WAAW,CAAC,CAAA;AAE1E,MAAM,MAAA,aAAA,GAAgB,MAAMC,iCAAA,CAAiB,WAAW,CAAA;AAExD,MAAI,IAAAC,SAAA,CAAG,OAAS,EAAA,aAAa,CAAG,EAAA;AAC9B,QAAAH,wBAAA,CAAQ,GAAI,CAAA;AAAA,UACV,KAAO,EAAA,8BAAA;AAAA,UACP,OAAS,EAAA,CAAA,GAAA,EAAM,OAAO,CAAA,aAAA,EAAW,aAAa,CAAA;AAAA,0CAAA,CAAA;AAAA,UAE9C,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,CAAA;AAAA,YACT,WAAa,EAAA,QAAA;AAAA,YACb,WAAa,EAAA;AAAA;AACf,SACD,CAAA;AAAA;AACH,aACO,EAAI,EAAA;AAAA;AAEb,IAAI,IAAA,OAAA,CAAQ,CAAC,CAAA,KAAM,UAAY,EAAA;AAE7B,MAAM,MAAA,eAAA,GAAkB,MAAM,OAAO,yBAAwB,EAAE,IAAK,CAAA,CAAC,CAAM,KAAA,CAAA,CAAE,OAAO,CAAA;AAEpF,MAAA,MAAMI,gBAAW,CAAA,eAAA,EAAiB,EAAE,OAAA,EAAS,CAAA;AAE7C,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA;AAChB,GACF;AAAA,EACA,WAAa,EAAA;AAAA,IACX,QAAA,EAAU,MAAM,OAAO,yBAAwB,EAAE,IAAK,CAAA,CAAC,CAAM,KAAA,CAAA,CAAE,OAAO;AAAA;AAE1E,CAAC,CAAA;AAED,eAAsB,IAAI,KAAiC,EAAA;AACzD,EAAA,MAAMC,cAAQ,IAAI,CAAA;AACpB","file":"index.cjs","sourcesContent":["import { defineCommand, runCommand, runMain } from 'citty'\nimport getLatestVersion from 'latest-version'\nimport { lt } from 'semver'\nimport { default as gradientString } from 'gradient-string'\n\nimport { version } from '../package.json'\nimport consola from 'consola'\n\nconst name = 'kubb'\n\nconst main = defineCommand({\n meta: {\n name,\n version,\n description: 'Kubb generation',\n },\n async setup({ rawArgs }) {\n try {\n consola.log(gradientString(['#F58517', '#F5A217', '#F55A17'])('Kubb CLI:'))\n\n const latestVersion = await getLatestVersion('@kubb/cli')\n\n if (lt(version, latestVersion)) {\n consola.box({\n title: 'Update available for `Kubb` ',\n message: `\\`v${version}\\` → \\`v${latestVersion}\\`\nRun \\`npm install -g @kubb/cli\\` to update`,\n style: {\n padding: 2,\n borderColor: 'yellow',\n borderStyle: 'rounded',\n },\n })\n }\n } catch (_e) {}\n\n if (rawArgs[0] !== 'generate') {\n // generate is not being used\n const generateCommand = await import('./commands/generate.ts').then((r) => r.default)\n\n await runCommand(generateCommand, { rawArgs })\n\n process.exit(0)\n }\n },\n subCommands: {\n generate: () => import('./commands/generate.ts').then((r) => r.default),\n },\n})\n\nexport async function run(_argv?: string[]): Promise<void> {\n await runMain(main)\n}\n\nexport { generate } from './generate.ts'\n","{\n \"name\": \"@kubb/cli\",\n \"version\": \"3.7.2\",\n \"description\": \"Generator cli\",\n \"keywords\": [\n \"typescript\",\n \"plugins\",\n \"kubb\",\n \"codegen\",\n \"cli\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git://github.com/kubb-labs/kubb.git\",\n \"directory\": \"packages/cli\"\n },\n \"license\": \"MIT\",\n \"author\": \"Stijn Van Hulle <stijn@stijnvanhulle.be\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"bin\": {\n \"kubb\": \"bin/kubb.cjs\"\n },\n \"files\": [\n \"src\",\n \"dist\",\n \"bin\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"npx rimraf ./dist\",\n \"lint\": \"bun biome lint .\",\n \"lint:fix\": \"bun biome lint --apply-unsafe .\",\n \"release\": \"pnpm publish --no-git-check\",\n \"release:canary\": \"bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check\",\n \"start\": \"tsup --watch\",\n \"test\": \"vitest --passWithNoTests\",\n \"typecheck\": \"tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false\"\n },\n \"dependencies\": {\n \"@kubb/core\": \"workspace:*\",\n \"@kubb/ui\": \"workspace:*\",\n \"chokidar\": \"^4.0.3\",\n \"citty\": \"^0.1.6\",\n \"cli-progress\": \"^3.12.0\",\n \"consola\": \"^3.4.2\",\n \"open\": \"^10.1.0\",\n \"gradient-string\": \"^3.0.0\",\n \"cosmiconfig\": \"^9.0.0\",\n \"execa\": \"^9.5.2\",\n \"jiti\": \"^2.4.2\",\n \"latest-version\": \"^9.0.0\",\n \"p-queue\": \"^8.1.0\",\n \"semver\": \"^7.7.1\",\n \"string-argv\": \"^0.3.2\"\n },\n \"devDependencies\": {\n \"@kubb/config-ts\": \"workspace:*\",\n \"@kubb/config-tsup\": \"workspace:*\",\n \"@kubb/plugin-oas\": \"workspace:*\",\n \"@types/cli-progress\": \"^3.11.6\",\n \"@types/node\": \"^20.17.28\",\n \"@types/semver\": \"^7.7.0\",\n \"source-map-support\": \"^0.5.21\",\n \"tsup\": \"catalog:\",\n \"typescript\": \"catalog:\"\n },\n \"engines\": {\n \"node\": \">=20\"\n },\n \"preferGlobal\": true,\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org/\"\n }\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Config } from '@kubb/core';
|
|
2
|
+
import { SingleBar } from 'cli-progress';
|
|
2
3
|
import { ParsedArgs } from 'citty';
|
|
3
4
|
|
|
4
5
|
declare global {
|
|
@@ -29,6 +30,12 @@ declare const args: {
|
|
|
29
30
|
readonly alias: "d";
|
|
30
31
|
readonly default: false;
|
|
31
32
|
};
|
|
33
|
+
readonly ui: {
|
|
34
|
+
readonly type: "boolean";
|
|
35
|
+
readonly description: "Open ui";
|
|
36
|
+
readonly alias: "u";
|
|
37
|
+
readonly default: false;
|
|
38
|
+
};
|
|
32
39
|
readonly help: {
|
|
33
40
|
readonly type: "boolean";
|
|
34
41
|
readonly description: "Show help";
|
|
@@ -42,8 +49,9 @@ type GenerateProps = {
|
|
|
42
49
|
input?: string;
|
|
43
50
|
config: Config;
|
|
44
51
|
args: Args;
|
|
52
|
+
progressCache: Map<string, SingleBar>;
|
|
45
53
|
};
|
|
46
|
-
declare function generate({ input, config, args }: GenerateProps): Promise<void>;
|
|
54
|
+
declare function generate({ input, config, progressCache, args }: GenerateProps): Promise<void>;
|
|
47
55
|
|
|
48
56
|
declare function run(_argv?: string[]): Promise<void>;
|
|
49
57
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Config } from '@kubb/core';
|
|
2
|
+
import { SingleBar } from 'cli-progress';
|
|
2
3
|
import { ParsedArgs } from 'citty';
|
|
3
4
|
|
|
4
5
|
declare global {
|
|
@@ -29,6 +30,12 @@ declare const args: {
|
|
|
29
30
|
readonly alias: "d";
|
|
30
31
|
readonly default: false;
|
|
31
32
|
};
|
|
33
|
+
readonly ui: {
|
|
34
|
+
readonly type: "boolean";
|
|
35
|
+
readonly description: "Open ui";
|
|
36
|
+
readonly alias: "u";
|
|
37
|
+
readonly default: false;
|
|
38
|
+
};
|
|
32
39
|
readonly help: {
|
|
33
40
|
readonly type: "boolean";
|
|
34
41
|
readonly description: "Show help";
|
|
@@ -42,8 +49,9 @@ type GenerateProps = {
|
|
|
42
49
|
input?: string;
|
|
43
50
|
config: Config;
|
|
44
51
|
args: Args;
|
|
52
|
+
progressCache: Map<string, SingleBar>;
|
|
45
53
|
};
|
|
46
|
-
declare function generate({ input, config, args }: GenerateProps): Promise<void>;
|
|
54
|
+
declare function generate({ input, config, progressCache, args }: GenerateProps): Promise<void>;
|
|
47
55
|
|
|
48
56
|
declare function run(_argv?: string[]): Promise<void>;
|
|
49
57
|
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
export { generate } from './chunk-
|
|
1
|
+
export { generate } from './chunk-SMSDJUVC.js';
|
|
2
2
|
import { defineCommand, runCommand, runMain } from 'citty';
|
|
3
3
|
import getLatestVersion from 'latest-version';
|
|
4
4
|
import { lt } from 'semver';
|
|
5
|
+
import gradientString from 'gradient-string';
|
|
5
6
|
import consola from 'consola';
|
|
6
7
|
|
|
7
8
|
// package.json
|
|
8
|
-
var version = "3.7.
|
|
9
|
+
var version = "3.7.2";
|
|
9
10
|
var name = "kubb";
|
|
10
11
|
var main = defineCommand({
|
|
11
12
|
meta: {
|
|
@@ -15,6 +16,7 @@ var main = defineCommand({
|
|
|
15
16
|
},
|
|
16
17
|
async setup({ rawArgs }) {
|
|
17
18
|
try {
|
|
19
|
+
consola.log(gradientString(["#F58517", "#F5A217", "#F55A17"])("Kubb CLI:"));
|
|
18
20
|
const latestVersion = await getLatestVersion("@kubb/cli");
|
|
19
21
|
if (lt(version, latestVersion)) {
|
|
20
22
|
consola.box({
|
|
@@ -31,13 +33,13 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
31
33
|
} catch (_e) {
|
|
32
34
|
}
|
|
33
35
|
if (rawArgs[0] !== "generate") {
|
|
34
|
-
const generateCommand = await import('./generate-
|
|
36
|
+
const generateCommand = await import('./generate-F47H4EHK.js').then((r) => r.default);
|
|
35
37
|
await runCommand(generateCommand, { rawArgs });
|
|
36
38
|
process.exit(0);
|
|
37
39
|
}
|
|
38
40
|
},
|
|
39
41
|
subCommands: {
|
|
40
|
-
generate: () => import('./generate-
|
|
42
|
+
generate: () => import('./generate-F47H4EHK.js').then((r) => r.default)
|
|
41
43
|
}
|
|
42
44
|
});
|
|
43
45
|
async function run(_argv) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/index.ts"],"names":[],"mappings":";;;;;;;;AAEE,IAAW,OAAA,GAAA,OAAA;ACMb,IAAM,IAAO,GAAA,MAAA;AAEb,IAAM,OAAO,aAAc,CAAA;AAAA,EACzB,IAAM,EAAA;AAAA,IACJ,IAAA;AAAA,IACA,OAAA;AAAA,IACA,WAAa,EAAA;AAAA,GACf;AAAA,EACA,MAAM,KAAA,CAAM,EAAE,OAAA,EAAW,EAAA;AACvB,IAAI,IAAA;AACF,MAAQ,OAAA,CAAA,GAAA,CAAI,eAAe,CAAC,SAAA,EAAW,WAAW,SAAS,CAAC,CAAE,CAAA,WAAW,CAAC,CAAA;AAE1E,MAAM,MAAA,aAAA,GAAgB,MAAM,gBAAA,CAAiB,WAAW,CAAA;AAExD,MAAI,IAAA,EAAA,CAAG,OAAS,EAAA,aAAa,CAAG,EAAA;AAC9B,QAAA,OAAA,CAAQ,GAAI,CAAA;AAAA,UACV,KAAO,EAAA,8BAAA;AAAA,UACP,OAAS,EAAA,CAAA,GAAA,EAAM,OAAO,CAAA,aAAA,EAAW,aAAa,CAAA;AAAA,0CAAA,CAAA;AAAA,UAE9C,KAAO,EAAA;AAAA,YACL,OAAS,EAAA,CAAA;AAAA,YACT,WAAa,EAAA,QAAA;AAAA,YACb,WAAa,EAAA;AAAA;AACf,SACD,CAAA;AAAA;AACH,aACO,EAAI,EAAA;AAAA;AAEb,IAAI,IAAA,OAAA,CAAQ,CAAC,CAAA,KAAM,UAAY,EAAA;AAE7B,MAAM,MAAA,eAAA,GAAkB,MAAM,OAAO,wBAAwB,EAAE,IAAK,CAAA,CAAC,CAAM,KAAA,CAAA,CAAE,OAAO,CAAA;AAEpF,MAAA,MAAM,UAAW,CAAA,eAAA,EAAiB,EAAE,OAAA,EAAS,CAAA;AAE7C,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA;AAChB,GACF;AAAA,EACA,WAAa,EAAA;AAAA,IACX,QAAA,EAAU,MAAM,OAAO,wBAAwB,EAAE,IAAK,CAAA,CAAC,CAAM,KAAA,CAAA,CAAE,OAAO;AAAA;AAE1E,CAAC,CAAA;AAED,eAAsB,IAAI,KAAiC,EAAA;AACzD,EAAA,MAAM,QAAQ,IAAI,CAAA;AACpB","file":"index.js","sourcesContent":["{\n \"name\": \"@kubb/cli\",\n \"version\": \"3.7.2\",\n \"description\": \"Generator cli\",\n \"keywords\": [\n \"typescript\",\n \"plugins\",\n \"kubb\",\n \"codegen\",\n \"cli\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git://github.com/kubb-labs/kubb.git\",\n \"directory\": \"packages/cli\"\n },\n \"license\": \"MIT\",\n \"author\": \"Stijn Van Hulle <stijn@stijnvanhulle.be\",\n \"sideEffects\": false,\n \"type\": \"module\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"require\": \"./dist/index.cjs\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"main\": \"dist/index.cjs\",\n \"module\": \"dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"bin\": {\n \"kubb\": \"bin/kubb.cjs\"\n },\n \"files\": [\n \"src\",\n \"dist\",\n \"bin\",\n \"!/**/**.test.**\",\n \"!/**/__tests__/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup\",\n \"clean\": \"npx rimraf ./dist\",\n \"lint\": \"bun biome lint .\",\n \"lint:fix\": \"bun biome lint --apply-unsafe .\",\n \"release\": \"pnpm publish --no-git-check\",\n \"release:canary\": \"bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check\",\n \"start\": \"tsup --watch\",\n \"test\": \"vitest --passWithNoTests\",\n \"typecheck\": \"tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false\"\n },\n \"dependencies\": {\n \"@kubb/core\": \"workspace:*\",\n \"@kubb/ui\": \"workspace:*\",\n \"chokidar\": \"^4.0.3\",\n \"citty\": \"^0.1.6\",\n \"cli-progress\": \"^3.12.0\",\n \"consola\": \"^3.4.2\",\n \"open\": \"^10.1.0\",\n \"gradient-string\": \"^3.0.0\",\n \"cosmiconfig\": \"^9.0.0\",\n \"execa\": \"^9.5.2\",\n \"jiti\": \"^2.4.2\",\n \"latest-version\": \"^9.0.0\",\n \"p-queue\": \"^8.1.0\",\n \"semver\": \"^7.7.1\",\n \"string-argv\": \"^0.3.2\"\n },\n \"devDependencies\": {\n \"@kubb/config-ts\": \"workspace:*\",\n \"@kubb/config-tsup\": \"workspace:*\",\n \"@kubb/plugin-oas\": \"workspace:*\",\n \"@types/cli-progress\": \"^3.11.6\",\n \"@types/node\": \"^20.17.28\",\n \"@types/semver\": \"^7.7.0\",\n \"source-map-support\": \"^0.5.21\",\n \"tsup\": \"catalog:\",\n \"typescript\": \"catalog:\"\n },\n \"engines\": {\n \"node\": \">=20\"\n },\n \"preferGlobal\": true,\n \"publishConfig\": {\n \"access\": \"public\",\n \"registry\": \"https://registry.npmjs.org/\"\n }\n}\n","import { defineCommand, runCommand, runMain } from 'citty'\nimport getLatestVersion from 'latest-version'\nimport { lt } from 'semver'\nimport { default as gradientString } from 'gradient-string'\n\nimport { version } from '../package.json'\nimport consola from 'consola'\n\nconst name = 'kubb'\n\nconst main = defineCommand({\n meta: {\n name,\n version,\n description: 'Kubb generation',\n },\n async setup({ rawArgs }) {\n try {\n consola.log(gradientString(['#F58517', '#F5A217', '#F55A17'])('Kubb CLI:'))\n\n const latestVersion = await getLatestVersion('@kubb/cli')\n\n if (lt(version, latestVersion)) {\n consola.box({\n title: 'Update available for `Kubb` ',\n message: `\\`v${version}\\` → \\`v${latestVersion}\\`\nRun \\`npm install -g @kubb/cli\\` to update`,\n style: {\n padding: 2,\n borderColor: 'yellow',\n borderStyle: 'rounded',\n },\n })\n }\n } catch (_e) {}\n\n if (rawArgs[0] !== 'generate') {\n // generate is not being used\n const generateCommand = await import('./commands/generate.ts').then((r) => r.default)\n\n await runCommand(generateCommand, { rawArgs })\n\n process.exit(0)\n }\n },\n subCommands: {\n generate: () => import('./commands/generate.ts').then((r) => r.default),\n },\n})\n\nexport async function run(_argv?: string[]): Promise<void> {\n await runMain(main)\n}\n\nexport { generate } from './generate.ts'\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/cli",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.2",
|
|
4
4
|
"description": "Generator cli",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -43,6 +43,8 @@
|
|
|
43
43
|
"citty": "^0.1.6",
|
|
44
44
|
"cli-progress": "^3.12.0",
|
|
45
45
|
"consola": "^3.4.2",
|
|
46
|
+
"open": "^10.1.0",
|
|
47
|
+
"gradient-string": "^3.0.0",
|
|
46
48
|
"cosmiconfig": "^9.0.0",
|
|
47
49
|
"execa": "^9.5.2",
|
|
48
50
|
"jiti": "^2.4.2",
|
|
@@ -50,8 +52,8 @@
|
|
|
50
52
|
"p-queue": "^8.1.0",
|
|
51
53
|
"semver": "^7.7.1",
|
|
52
54
|
"string-argv": "^0.3.2",
|
|
53
|
-
"
|
|
54
|
-
"@kubb/
|
|
55
|
+
"@kubb/core": "3.7.2",
|
|
56
|
+
"@kubb/ui": "3.7.2"
|
|
55
57
|
},
|
|
56
58
|
"devDependencies": {
|
|
57
59
|
"@types/cli-progress": "^3.11.6",
|
|
@@ -60,9 +62,9 @@
|
|
|
60
62
|
"source-map-support": "^0.5.21",
|
|
61
63
|
"tsup": "^8.4.0",
|
|
62
64
|
"typescript": "^5.8.2",
|
|
63
|
-
"@kubb/config-ts": "3.7.
|
|
64
|
-
"@kubb/config-tsup": "3.7.
|
|
65
|
-
"@kubb/plugin-oas": "3.7.
|
|
65
|
+
"@kubb/config-ts": "3.7.2",
|
|
66
|
+
"@kubb/config-tsup": "3.7.2",
|
|
67
|
+
"@kubb/plugin-oas": "3.7.2"
|
|
66
68
|
},
|
|
67
69
|
"engines": {
|
|
68
70
|
"node": ">=20"
|
package/src/commands/generate.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineCommand, showUsage } from 'citty'
|
|
2
2
|
import type { ArgsDef, ParsedArgs } from 'citty'
|
|
3
|
-
import
|
|
3
|
+
import { colors } from 'consola/utils'
|
|
4
4
|
|
|
5
5
|
import { getConfig } from '../utils/getConfig.ts'
|
|
6
6
|
import { getCosmiConfig } from '../utils/getCosmiConfig.ts'
|
|
@@ -11,6 +11,9 @@ import * as process from 'node:process'
|
|
|
11
11
|
import { PromiseManager, isInputPath } from '@kubb/core'
|
|
12
12
|
import { LogMapper, createLogger } from '@kubb/core/logger'
|
|
13
13
|
import { generate } from '../generate.ts'
|
|
14
|
+
import { startServer } from '@kubb/ui'
|
|
15
|
+
import open from 'open'
|
|
16
|
+
import type { SingleBar } from 'cli-progress'
|
|
14
17
|
|
|
15
18
|
declare global {
|
|
16
19
|
var isDevtoolsEnabled: any
|
|
@@ -41,6 +44,12 @@ const args = {
|
|
|
41
44
|
alias: 'd',
|
|
42
45
|
default: false,
|
|
43
46
|
},
|
|
47
|
+
ui: {
|
|
48
|
+
type: 'boolean',
|
|
49
|
+
description: 'Open ui',
|
|
50
|
+
alias: 'u',
|
|
51
|
+
default: false,
|
|
52
|
+
},
|
|
44
53
|
help: {
|
|
45
54
|
type: 'boolean',
|
|
46
55
|
description: 'Show help',
|
|
@@ -58,7 +67,11 @@ const command = defineCommand({
|
|
|
58
67
|
},
|
|
59
68
|
args,
|
|
60
69
|
async run(commandContext) {
|
|
70
|
+
let name = ''
|
|
71
|
+
const progressCache = new Map<string, SingleBar>()
|
|
72
|
+
|
|
61
73
|
const { args } = commandContext
|
|
74
|
+
|
|
62
75
|
const input = args._[0]
|
|
63
76
|
|
|
64
77
|
if (args.help) {
|
|
@@ -78,10 +91,73 @@ const command = defineCommand({
|
|
|
78
91
|
logger.emit('start', 'Loading config')
|
|
79
92
|
|
|
80
93
|
const result = await getCosmiConfig('kubb', args.config)
|
|
81
|
-
logger.emit('success', `Config loaded(${
|
|
94
|
+
logger.emit('success', `Config loaded(${colors.dim(path.relative(process.cwd(), result.filepath))})`)
|
|
82
95
|
|
|
83
96
|
const config = await getConfig(result, args)
|
|
84
97
|
|
|
98
|
+
const start = async () => {
|
|
99
|
+
if (Array.isArray(config)) {
|
|
100
|
+
const promiseManager = new PromiseManager()
|
|
101
|
+
const promises = config.map((c) => () => {
|
|
102
|
+
name = c.name || ''
|
|
103
|
+
progressCache.clear()
|
|
104
|
+
|
|
105
|
+
return generate({
|
|
106
|
+
input,
|
|
107
|
+
config: c,
|
|
108
|
+
args,
|
|
109
|
+
progressCache,
|
|
110
|
+
})
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
await promiseManager.run('seq', promises)
|
|
114
|
+
return
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
progressCache.clear()
|
|
118
|
+
|
|
119
|
+
await generate({
|
|
120
|
+
input,
|
|
121
|
+
config,
|
|
122
|
+
progressCache,
|
|
123
|
+
args,
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
return
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (args.ui) {
|
|
130
|
+
await startServer(
|
|
131
|
+
{
|
|
132
|
+
stop: () => process.exit(1),
|
|
133
|
+
restart: () => start(),
|
|
134
|
+
getMeta: () => {
|
|
135
|
+
const entries = [...progressCache.entries()]
|
|
136
|
+
|
|
137
|
+
const percentages = entries.reduce(
|
|
138
|
+
(acc, [key, singleBar]) => {
|
|
139
|
+
acc[key] = singleBar.getProgress()
|
|
140
|
+
|
|
141
|
+
return acc
|
|
142
|
+
},
|
|
143
|
+
{} as Record<string, number>,
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
name,
|
|
148
|
+
percentages,
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
(info) => {
|
|
153
|
+
const url = `${info.address}:${info.port}`.replace('::', 'http://localhost')
|
|
154
|
+
logger.consola?.start(`Starting ui on ${url}`)
|
|
155
|
+
|
|
156
|
+
open(url)
|
|
157
|
+
},
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
|
|
85
161
|
if (args.watch) {
|
|
86
162
|
if (Array.isArray(config)) {
|
|
87
163
|
throw new Error('Cannot use watcher with multiple Configs(array)')
|
|
@@ -89,29 +165,22 @@ const command = defineCommand({
|
|
|
89
165
|
|
|
90
166
|
if (isInputPath(config)) {
|
|
91
167
|
return startWatcher([input || config.input.path], async (paths) => {
|
|
92
|
-
await
|
|
93
|
-
logger.emit('start',
|
|
168
|
+
await start()
|
|
169
|
+
logger.emit('start', colors.yellow(colors.bold(`Watching for changes in ${paths.join(' and ')}`)))
|
|
94
170
|
})
|
|
95
171
|
}
|
|
96
172
|
}
|
|
97
173
|
|
|
98
|
-
|
|
99
|
-
const promiseManager = new PromiseManager()
|
|
100
|
-
const promises = config.map((item) => () => generate({ input, config: item, args }))
|
|
101
|
-
|
|
102
|
-
return promiseManager.run('seq', promises)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
await generate({ input, config, args })
|
|
174
|
+
await start()
|
|
106
175
|
|
|
107
176
|
if (globalThis.isDevtoolsEnabled) {
|
|
108
|
-
const
|
|
177
|
+
const canRestart = await logger.consola?.prompt('Restart(could be used to validate the profiler)?', {
|
|
109
178
|
type: 'confirm',
|
|
110
179
|
initial: false,
|
|
111
180
|
})
|
|
112
181
|
|
|
113
|
-
if (
|
|
114
|
-
await
|
|
182
|
+
if (canRestart) {
|
|
183
|
+
await start()
|
|
115
184
|
} else {
|
|
116
185
|
process.exit(1)
|
|
117
186
|
}
|
package/src/generate.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { LogMapper } from '@kubb/core/logger'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { colors } from 'consola/utils'
|
|
4
4
|
|
|
5
|
-
import { type Config, safeBuild } from '@kubb/core'
|
|
5
|
+
import { type Config, safeBuild, setup } from '@kubb/core'
|
|
6
6
|
import { executeHooks } from './utils/executeHooks.ts'
|
|
7
7
|
import { getErrorCauses } from './utils/getErrorCauses.ts'
|
|
8
8
|
import { getSummary } from './utils/getSummary.ts'
|
|
@@ -10,25 +10,28 @@ import { getSummary } from './utils/getSummary.ts'
|
|
|
10
10
|
import { createLogger } from '@kubb/core/logger'
|
|
11
11
|
import { Presets, SingleBar } from 'cli-progress'
|
|
12
12
|
import type { Args } from './commands/generate.ts'
|
|
13
|
+
import process from 'node:process'
|
|
13
14
|
|
|
14
15
|
type GenerateProps = {
|
|
15
16
|
input?: string
|
|
16
17
|
config: Config
|
|
17
18
|
args: Args
|
|
19
|
+
progressCache: Map<string, SingleBar>
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
export async function generate({ input, config, args }: GenerateProps): Promise<void> {
|
|
22
|
+
export async function generate({ input, config, progressCache, args }: GenerateProps): Promise<void> {
|
|
23
|
+
const hrStart = process.hrtime()
|
|
21
24
|
const logLevel = LogMapper[args.logLevel as keyof typeof LogMapper] || 3
|
|
25
|
+
|
|
22
26
|
const logger = createLogger({
|
|
23
27
|
logLevel,
|
|
24
28
|
name: config.name,
|
|
25
29
|
})
|
|
30
|
+
|
|
26
31
|
const { root = process.cwd(), ...userConfig } = config
|
|
27
32
|
const inputPath = input ?? ('path' in userConfig.input ? userConfig.input.path : undefined)
|
|
28
33
|
|
|
29
34
|
if (logger.logLevel !== LogMapper.debug) {
|
|
30
|
-
const progressCache = new Map<string, SingleBar>()
|
|
31
|
-
|
|
32
35
|
logger.on('progress_start', ({ id, size, message = '' }) => {
|
|
33
36
|
logger.consola?.pauseLogs()
|
|
34
37
|
const payload = { id, message }
|
|
@@ -60,8 +63,6 @@ export async function generate({ input, config, args }: GenerateProps): Promise<
|
|
|
60
63
|
})
|
|
61
64
|
}
|
|
62
65
|
|
|
63
|
-
logger.emit('start', `Building ${logger.logLevel !== LogMapper.silent ? c.dim(inputPath) : ''}`)
|
|
64
|
-
|
|
65
66
|
const definedConfig: Config = {
|
|
66
67
|
root,
|
|
67
68
|
...userConfig,
|
|
@@ -80,12 +81,20 @@ export async function generate({ input, config, args }: GenerateProps): Promise<
|
|
|
80
81
|
...userConfig.output,
|
|
81
82
|
},
|
|
82
83
|
}
|
|
83
|
-
|
|
84
|
-
const
|
|
84
|
+
|
|
85
|
+
const pluginManager = await setup({
|
|
85
86
|
config: definedConfig,
|
|
86
87
|
logger,
|
|
87
88
|
})
|
|
88
89
|
|
|
90
|
+
logger.emit('start', `Building ${logger.logLevel !== LogMapper.silent ? colors.dim(inputPath!) : ''}`)
|
|
91
|
+
|
|
92
|
+
const { files, error } = await safeBuild({
|
|
93
|
+
config: definedConfig,
|
|
94
|
+
pluginManager,
|
|
95
|
+
logger,
|
|
96
|
+
})
|
|
97
|
+
|
|
89
98
|
if (logger.logLevel === LogMapper.debug) {
|
|
90
99
|
logger.consola?.start('Writing logs')
|
|
91
100
|
|
|
@@ -104,7 +113,7 @@ export async function generate({ input, config, args }: GenerateProps): Promise<
|
|
|
104
113
|
|
|
105
114
|
if (error && logger.consola) {
|
|
106
115
|
logger.consola?.resumeLogs()
|
|
107
|
-
logger.consola.error(`Build failed ${logger.logLevel !== LogMapper.silent ?
|
|
116
|
+
logger.consola.error(`Build failed ${logger.logLevel !== LogMapper.silent ? colors.dim(inputPath!) : ''}`)
|
|
108
117
|
|
|
109
118
|
logger.consola.box({
|
|
110
119
|
title: `${config.name || ''}`,
|
|
@@ -132,7 +141,7 @@ export async function generate({ input, config, args }: GenerateProps): Promise<
|
|
|
132
141
|
await executeHooks({ hooks: config.hooks, logger })
|
|
133
142
|
}
|
|
134
143
|
|
|
135
|
-
logger.consola?.log(`⚡Build completed ${logger.logLevel !== LogMapper.silent ?
|
|
144
|
+
logger.consola?.log(`⚡Build completed ${logger.logLevel !== LogMapper.silent ? colors.dim(inputPath!) : ''}`)
|
|
136
145
|
|
|
137
146
|
logger.consola?.box({
|
|
138
147
|
title: `${config.name || ''}`,
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineCommand, runCommand, runMain } from 'citty'
|
|
2
2
|
import getLatestVersion from 'latest-version'
|
|
3
3
|
import { lt } from 'semver'
|
|
4
|
+
import { default as gradientString } from 'gradient-string'
|
|
4
5
|
|
|
5
6
|
import { version } from '../package.json'
|
|
6
7
|
import consola from 'consola'
|
|
@@ -15,6 +16,8 @@ const main = defineCommand({
|
|
|
15
16
|
},
|
|
16
17
|
async setup({ rawArgs }) {
|
|
17
18
|
try {
|
|
19
|
+
consola.log(gradientString(['#F58517', '#F5A217', '#F55A17'])('Kubb CLI:'))
|
|
20
|
+
|
|
18
21
|
const latestVersion = await getLatestVersion('@kubb/cli')
|
|
19
22
|
|
|
20
23
|
if (lt(version, latestVersion)) {
|
package/src/utils/Writables.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Writable } from 'node:stream'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { colors } from 'consola/utils'
|
|
4
4
|
|
|
5
5
|
import * as process from 'node:process'
|
|
6
6
|
import type { WritableOptions } from 'node:stream'
|
|
@@ -16,7 +16,7 @@ export class ConsolaWritable extends Writable {
|
|
|
16
16
|
this.consola = consola
|
|
17
17
|
}
|
|
18
18
|
_write(chunk: any, _encoding: BufferEncoding, callback: (error?: Error | null) => void): void {
|
|
19
|
-
process.stdout.write(`${
|
|
19
|
+
process.stdout.write(`${colors.dim(chunk?.toString())}`)
|
|
20
20
|
|
|
21
21
|
callback()
|
|
22
22
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Logger } from '@kubb/core/logger'
|
|
2
2
|
import { execa } from 'execa'
|
|
3
3
|
import { parseArgsStringToArgv } from 'string-argv'
|
|
4
|
-
import
|
|
4
|
+
import { colors } from 'consola/utils'
|
|
5
5
|
|
|
6
6
|
import { ConsolaWritable } from './Writables.ts'
|
|
7
7
|
|
|
@@ -27,7 +27,7 @@ export async function executeHooks({ hooks, logger }: ExecutingHooksProps): Prom
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
await queue.add(async () => {
|
|
30
|
-
logger?.emit('start', `Executing hook ${logger.logLevel !== LogMapper.silent ?
|
|
30
|
+
logger?.emit('start', `Executing hook ${logger.logLevel !== LogMapper.silent ? colors.dim(command) : ''}`)
|
|
31
31
|
|
|
32
32
|
await execa(cmd, _args, {
|
|
33
33
|
detached: true,
|
|
@@ -35,7 +35,7 @@ export async function executeHooks({ hooks, logger }: ExecutingHooksProps): Prom
|
|
|
35
35
|
stripFinalNewline: true,
|
|
36
36
|
})
|
|
37
37
|
|
|
38
|
-
logger?.emit('success', `Executed hook ${logger.logLevel !== LogMapper.silent ?
|
|
38
|
+
logger?.emit('success', `Executed hook ${logger.logLevel !== LogMapper.silent ? colors.dim(command) : ''}`)
|
|
39
39
|
})
|
|
40
40
|
})
|
|
41
41
|
|
package/src/utils/getSummary.ts
CHANGED
|
@@ -2,7 +2,7 @@ import path from 'node:path'
|
|
|
2
2
|
|
|
3
3
|
import { randomCliColour } from '@kubb/core/logger'
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { colors } from 'consola/utils'
|
|
6
6
|
|
|
7
7
|
import { parseHrtimeToSeconds } from './parseHrtimeToSeconds.ts'
|
|
8
8
|
|
|
@@ -32,20 +32,20 @@ export function getSummary({ pluginManager, filesCreated, status, hrStart, confi
|
|
|
32
32
|
const meta = {
|
|
33
33
|
plugins:
|
|
34
34
|
status === 'success'
|
|
35
|
-
? `${
|
|
36
|
-
: `${
|
|
35
|
+
? `${colors.green(`${buildStartPlugins.length} successful`)}, ${pluginsCount} total`
|
|
36
|
+
: `${colors.red(`${failedPlugins?.length ?? 1} failed`)}, ${pluginsCount} total`,
|
|
37
37
|
pluginsFailed: status === 'failed' ? failedPlugins?.map((name) => randomCliColour(name))?.join(', ') : undefined,
|
|
38
38
|
filesCreated: filesCreated,
|
|
39
|
-
time: `${
|
|
39
|
+
time: `${colors.yellow(`${elapsedSeconds}s`)}`,
|
|
40
40
|
output: path.isAbsolute(config.root) ? path.resolve(config.root, config.output.path) : config.root,
|
|
41
41
|
} as const
|
|
42
42
|
|
|
43
43
|
logs.add(
|
|
44
44
|
[
|
|
45
|
-
[`${
|
|
46
|
-
[`${
|
|
47
|
-
[`${
|
|
48
|
-
[`${
|
|
45
|
+
[`${colors.bold('Plugins:')} ${meta.plugins}`, true],
|
|
46
|
+
[`${colors.dim('Failed:')} ${meta.pluginsFailed || 'none'}`, !!meta.pluginsFailed],
|
|
47
|
+
[`${colors.bold('Generated:')} ${meta.filesCreated} files in ${meta.time}`, true],
|
|
48
|
+
[`${colors.bold('Output:')} ${meta.output}`, true],
|
|
49
49
|
]
|
|
50
50
|
.map((item) => {
|
|
51
51
|
if (item.at(1)) {
|
package/src/utils/watcher.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLogger } from '@kubb/core/logger'
|
|
2
|
-
import
|
|
2
|
+
import { colors } from 'consola/utils'
|
|
3
3
|
|
|
4
4
|
export async function startWatcher(path: string[], cb: (path: string[]) => Promise<void>): Promise<void> {
|
|
5
5
|
const { watch } = await import('chokidar')
|
|
@@ -12,12 +12,12 @@ export async function startWatcher(path: string[], cb: (path: string[]) => Promi
|
|
|
12
12
|
ignored,
|
|
13
13
|
})
|
|
14
14
|
watcher.on('all', (type, file) => {
|
|
15
|
-
logger?.emit('info',
|
|
15
|
+
logger?.emit('info', colors.yellow(colors.bold(`Change detected: ${type} ${file}`)))
|
|
16
16
|
|
|
17
17
|
try {
|
|
18
18
|
cb(path)
|
|
19
19
|
} catch (e) {
|
|
20
|
-
logger?.emit('warning',
|
|
20
|
+
logger?.emit('warning', colors.red('Watcher failed'))
|
|
21
21
|
}
|
|
22
22
|
})
|
|
23
23
|
}
|