@kubb/cli 0.11.2 → 0.14.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.js +34 -44
- package/dist/index.mjs +35 -45
- package/package.json +4 -6
package/dist/index.js
CHANGED
|
@@ -51,45 +51,48 @@ var createConfig = async (result) => {
|
|
|
51
51
|
let config = result?.config;
|
|
52
52
|
if (result?.filepath.endsWith(".json")) {
|
|
53
53
|
config = {
|
|
54
|
-
...
|
|
55
|
-
plugins: getPlugins(
|
|
54
|
+
...config,
|
|
55
|
+
plugins: getPlugins(config.plugins)
|
|
56
56
|
};
|
|
57
|
+
return config;
|
|
57
58
|
}
|
|
58
|
-
if (typeof
|
|
59
|
-
const possiblePromise =
|
|
59
|
+
if (typeof config === "function") {
|
|
60
|
+
const possiblePromise = config();
|
|
60
61
|
if (typeof possiblePromise?.then === "function") {
|
|
61
|
-
|
|
62
|
-
} else {
|
|
63
|
-
config = possiblePromise;
|
|
62
|
+
return possiblePromise;
|
|
64
63
|
}
|
|
64
|
+
return possiblePromise;
|
|
65
65
|
}
|
|
66
66
|
return config;
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
// src/run.ts
|
|
70
|
-
|
|
71
|
-
async function run(result) {
|
|
70
|
+
async function run(result, options) {
|
|
72
71
|
const spinner = (0, import_ora.default)({
|
|
73
72
|
color: "blue",
|
|
74
|
-
text: import_picocolors.default.blue("
|
|
75
|
-
spinner:
|
|
76
|
-
stream: process.stdout
|
|
73
|
+
text: import_picocolors.default.blue("Kubb generation started"),
|
|
74
|
+
spinner: "timeTravel"
|
|
77
75
|
}).start();
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
spinner
|
|
87
|
-
}
|
|
76
|
+
const logger = {
|
|
77
|
+
log(message, logLevel) {
|
|
78
|
+
if (logLevel === "error") {
|
|
79
|
+
spinner.fail(message);
|
|
80
|
+
}
|
|
81
|
+
spinner[logLevel](message);
|
|
82
|
+
},
|
|
83
|
+
spinner
|
|
88
84
|
};
|
|
89
85
|
try {
|
|
90
86
|
const config = await createConfig(result);
|
|
91
|
-
await import_core.build
|
|
92
|
-
|
|
87
|
+
await (0, import_core.build)({
|
|
88
|
+
config: {
|
|
89
|
+
...import_core.defaultConfig,
|
|
90
|
+
...config
|
|
91
|
+
},
|
|
92
|
+
mode: options.mode || "development",
|
|
93
|
+
logger
|
|
94
|
+
});
|
|
95
|
+
spinner.succeed(import_picocolors.default.blue("Kubb generation done"));
|
|
93
96
|
} catch (err) {
|
|
94
97
|
spinner.fail("Something went wrong\n");
|
|
95
98
|
console.error(err);
|
|
@@ -97,6 +100,9 @@ async function run(result) {
|
|
|
97
100
|
return true;
|
|
98
101
|
}
|
|
99
102
|
|
|
103
|
+
// package.json
|
|
104
|
+
var version = "0.14.0";
|
|
105
|
+
|
|
100
106
|
// src/index.ts
|
|
101
107
|
var moduleName = "kubb";
|
|
102
108
|
var explorer = (0, import_cosmiconfig.cosmiconfig)(moduleName, {
|
|
@@ -116,28 +122,12 @@ var explorer = (0, import_cosmiconfig.cosmiconfig)(moduleName, {
|
|
|
116
122
|
noExt: import_cosmiconfig.defaultLoaders[".js"]
|
|
117
123
|
}
|
|
118
124
|
});
|
|
119
|
-
var program = new import_commander.Command(
|
|
125
|
+
var program = new import_commander.Command(moduleName).description("Codegen plugins").action(async (options) => {
|
|
120
126
|
const result = options.config ? await explorer.load(options.config) : await explorer.search();
|
|
121
127
|
if (result?.isEmpty || !result || !result.config) {
|
|
122
128
|
console.log(import_picocolors2.default.red("Config not defined, create a kubb.config.js or pass through your config with the option --config"));
|
|
123
129
|
return;
|
|
124
130
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
console.log(`Config data
|
|
129
|
-
${result?.config}`);
|
|
130
|
-
} else {
|
|
131
|
-
console.log(`Config data
|
|
132
|
-
${JSON.stringify(result?.config, void 0, 2)}`);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (options.debug) {
|
|
136
|
-
console.log("\n");
|
|
137
|
-
console.log(import_picocolors2.default.blue("Build started with:\n"));
|
|
138
|
-
console.log(import_picocolors2.default.white(JSON.stringify(result.config, void 0, 2)));
|
|
139
|
-
console.log("\n");
|
|
140
|
-
}
|
|
141
|
-
await run(result);
|
|
142
|
-
}).addOption(new import_commander.Option("-c, --config <path>", "Path to @kubb config")).addOption(new import_commander.Option("-d, --debug", "Debug mode").default(false));
|
|
143
|
-
program.name(moduleName).description("Generate").version("0.0.1").parse();
|
|
131
|
+
await run(result, options);
|
|
132
|
+
}).addOption(new import_commander.Option("-m, --mode <mode>", "Mode of Kubb, development or production").default("development")).addOption(new import_commander.Option("-c, --config <path>", "Path to @kubb config")).addOption(new import_commander.Option("-d, --debug", "Debug mode").default(false));
|
|
133
|
+
program.name(moduleName).description("Generate").version(version, "-v").parse();
|
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import pc2 from "picocolors";
|
|
|
9
9
|
// src/run.ts
|
|
10
10
|
import pc from "picocolors";
|
|
11
11
|
import ora from "ora";
|
|
12
|
-
import { build } from "@kubb/core";
|
|
12
|
+
import { build, defaultConfig } from "@kubb/core";
|
|
13
13
|
|
|
14
14
|
// src/utils/getPlugins.ts
|
|
15
15
|
var isJSONPlugins = (plugins) => {
|
|
@@ -33,45 +33,48 @@ var createConfig = async (result) => {
|
|
|
33
33
|
let config = result?.config;
|
|
34
34
|
if (result?.filepath.endsWith(".json")) {
|
|
35
35
|
config = {
|
|
36
|
-
...
|
|
37
|
-
plugins: getPlugins(
|
|
36
|
+
...config,
|
|
37
|
+
plugins: getPlugins(config.plugins)
|
|
38
38
|
};
|
|
39
|
+
return config;
|
|
39
40
|
}
|
|
40
|
-
if (typeof
|
|
41
|
-
const possiblePromise =
|
|
41
|
+
if (typeof config === "function") {
|
|
42
|
+
const possiblePromise = config();
|
|
42
43
|
if (typeof possiblePromise?.then === "function") {
|
|
43
|
-
|
|
44
|
-
} else {
|
|
45
|
-
config = possiblePromise;
|
|
44
|
+
return possiblePromise;
|
|
46
45
|
}
|
|
46
|
+
return possiblePromise;
|
|
47
47
|
}
|
|
48
48
|
return config;
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
// src/run.ts
|
|
52
|
-
|
|
53
|
-
async function run(result) {
|
|
52
|
+
async function run(result, options) {
|
|
54
53
|
const spinner = ora({
|
|
55
54
|
color: "blue",
|
|
56
|
-
text: pc.blue("
|
|
57
|
-
spinner:
|
|
58
|
-
stream: process.stdout
|
|
55
|
+
text: pc.blue("Kubb generation started"),
|
|
56
|
+
spinner: "timeTravel"
|
|
59
57
|
}).start();
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
spinner
|
|
69
|
-
}
|
|
58
|
+
const logger = {
|
|
59
|
+
log(message, logLevel) {
|
|
60
|
+
if (logLevel === "error") {
|
|
61
|
+
spinner.fail(message);
|
|
62
|
+
}
|
|
63
|
+
spinner[logLevel](message);
|
|
64
|
+
},
|
|
65
|
+
spinner
|
|
70
66
|
};
|
|
71
67
|
try {
|
|
72
68
|
const config = await createConfig(result);
|
|
73
|
-
await build
|
|
74
|
-
|
|
69
|
+
await build({
|
|
70
|
+
config: {
|
|
71
|
+
...defaultConfig,
|
|
72
|
+
...config
|
|
73
|
+
},
|
|
74
|
+
mode: options.mode || "development",
|
|
75
|
+
logger
|
|
76
|
+
});
|
|
77
|
+
spinner.succeed(pc.blue("Kubb generation done"));
|
|
75
78
|
} catch (err) {
|
|
76
79
|
spinner.fail("Something went wrong\n");
|
|
77
80
|
console.error(err);
|
|
@@ -79,6 +82,9 @@ async function run(result) {
|
|
|
79
82
|
return true;
|
|
80
83
|
}
|
|
81
84
|
|
|
85
|
+
// package.json
|
|
86
|
+
var version = "0.14.0";
|
|
87
|
+
|
|
82
88
|
// src/index.ts
|
|
83
89
|
var moduleName = "kubb";
|
|
84
90
|
var explorer = cosmiconfig(moduleName, {
|
|
@@ -98,28 +104,12 @@ var explorer = cosmiconfig(moduleName, {
|
|
|
98
104
|
noExt: defaultLoaders[".js"]
|
|
99
105
|
}
|
|
100
106
|
});
|
|
101
|
-
var program = new Command(
|
|
107
|
+
var program = new Command(moduleName).description("Codegen plugins").action(async (options) => {
|
|
102
108
|
const result = options.config ? await explorer.load(options.config) : await explorer.search();
|
|
103
109
|
if (result?.isEmpty || !result || !result.config) {
|
|
104
110
|
console.log(pc2.red("Config not defined, create a kubb.config.js or pass through your config with the option --config"));
|
|
105
111
|
return;
|
|
106
112
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
console.log(`Config data
|
|
111
|
-
${result?.config}`);
|
|
112
|
-
} else {
|
|
113
|
-
console.log(`Config data
|
|
114
|
-
${JSON.stringify(result?.config, void 0, 2)}`);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (options.debug) {
|
|
118
|
-
console.log("\n");
|
|
119
|
-
console.log(pc2.blue("Build started with:\n"));
|
|
120
|
-
console.log(pc2.white(JSON.stringify(result.config, void 0, 2)));
|
|
121
|
-
console.log("\n");
|
|
122
|
-
}
|
|
123
|
-
await run(result);
|
|
124
|
-
}).addOption(new Option("-c, --config <path>", "Path to @kubb config")).addOption(new Option("-d, --debug", "Debug mode").default(false));
|
|
125
|
-
program.name(moduleName).description("Generate").version("0.0.1").parse();
|
|
113
|
+
await run(result, options);
|
|
114
|
+
}).addOption(new Option("-m, --mode <mode>", "Mode of Kubb, development or production").default("development")).addOption(new Option("-c, --config <path>", "Path to @kubb config")).addOption(new Option("-d, --debug", "Debug mode").default(false));
|
|
115
|
+
program.name(moduleName).description("Generate").version(version, "-v").parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Generator cli",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,19 +20,17 @@
|
|
|
20
20
|
"!/**/__tests__/**"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@kubb/core": "0.
|
|
23
|
+
"@kubb/core": "0.14.0",
|
|
24
24
|
"commander": "^9.4.1",
|
|
25
25
|
"cosmiconfig": "^8.0.0",
|
|
26
26
|
"cosmiconfig-typescript-loader": "^4.3.0",
|
|
27
|
-
"ora": "^
|
|
27
|
+
"ora": "^6.1.2",
|
|
28
28
|
"picocolors": "^1.0.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@kubb/swagger": "0.11.2",
|
|
32
|
-
"@kubb/swagger-typescript": "0.11.2",
|
|
33
31
|
"tsup": "^6.5.0",
|
|
34
32
|
"typescript": "^4.9.4",
|
|
35
|
-
"@types/node": "^18.11.
|
|
33
|
+
"@types/node": "^18.11.18"
|
|
36
34
|
},
|
|
37
35
|
"publishConfig": {
|
|
38
36
|
"access": "public",
|