@kubb/cli
Advanced tools
Comparing version 0.14.1 to 0.19.0
@@ -9,2 +9,4 @@ #!/usr/bin/env node | ||
var ora = require('ora'); | ||
var execa = require('execa'); | ||
var stringArgv = require('string-argv'); | ||
var core = require('@kubb/core'); | ||
@@ -20,3 +22,3 @@ | ||
if (isJSONPlugins(plugins)) { | ||
return plugins.map(async (plugin) => { | ||
const promises = plugins.map(async (plugin) => { | ||
const [name, options = {}] = plugin; | ||
@@ -26,22 +28,24 @@ const importedPlugin = await import(name); | ||
}); | ||
return Promise.all(promises); | ||
} | ||
return plugins; | ||
return Promise.resolve(plugins); | ||
}; | ||
// src/utils/createConfig.ts | ||
var createConfig = async (result) => { | ||
let config = result?.config; | ||
var createConfig = async (result, options) => { | ||
const config = result?.config; | ||
if (result?.filepath.endsWith(".json")) { | ||
config = { | ||
...config, | ||
plugins: getPlugins(config.plugins) | ||
let JSONConfig = config; | ||
JSONConfig = { | ||
...JSONConfig, | ||
plugins: JSONConfig.plugins ? await getPlugins(JSONConfig.plugins) : void 0 | ||
}; | ||
return config; | ||
return Promise.resolve(JSONConfig); | ||
} | ||
if (typeof config === "function") { | ||
const possiblePromise = config(); | ||
if (typeof possiblePromise?.then === "function") { | ||
const possiblePromise = config(options); | ||
if (core.isPromise(possiblePromise)) { | ||
return possiblePromise; | ||
} | ||
return possiblePromise; | ||
return Promise.resolve(possiblePromise); | ||
} | ||
@@ -64,6 +68,6 @@ return config; | ||
spinner2.start("Building"); | ||
const config = await createConfig(result); | ||
const config = await createConfig(result, options); | ||
await core.build({ | ||
config: { | ||
...core.defaultConfig, | ||
root: process.cwd(), | ||
...config | ||
@@ -75,2 +79,17 @@ }, | ||
spinner2.succeed(pc2.blue("Kubb generation done")); | ||
if (config.hooks?.done) { | ||
spinner2.start("Running hooks"); | ||
let commands = []; | ||
if (typeof config.hooks?.done === "string") { | ||
commands = [config.hooks.done]; | ||
} else { | ||
commands = config.hooks.done; | ||
} | ||
const promises = commands.map(async (command) => { | ||
const [cmd, ..._args] = [...stringArgv.parseArgsStringToArgv(command)]; | ||
return execa.execa(cmd, _args); | ||
}); | ||
await Promise.all(promises); | ||
spinner2.succeed("Running hooks completed"); | ||
} | ||
} catch (err) { | ||
@@ -84,3 +103,3 @@ spinner2.fail("Something went wrong\n"); | ||
// package.json | ||
var version = "0.14.1"; | ||
var version = "0.19.0"; | ||
@@ -111,3 +130,3 @@ // src/index.ts | ||
}); | ||
var program = new commander.Command(moduleName).description("Codegen plugins").action(async (options) => { | ||
var program = new commander.Command(moduleName).description("Kubb").action(async (options) => { | ||
spinner.succeed(pc2.blue("Kubb generation started")); | ||
@@ -114,0 +133,0 @@ spinner.start("Loading config"); |
{ | ||
"name": "@kubb/cli", | ||
"version": "0.14.1", | ||
"version": "0.19.0", | ||
"description": "Generator cli", | ||
@@ -23,13 +23,15 @@ "repository": { | ||
"dependencies": { | ||
"@kubb/core": "0.14.1", | ||
"@kubb/core": "0.19.0", | ||
"commander": "^9.4.1", | ||
"cosmiconfig": "^8.0.0", | ||
"cosmiconfig-typescript-loader": "^4.3.0", | ||
"execa": "^6.1.0", | ||
"ora": "^6.1.2", | ||
"picocolors": "^1.0.0" | ||
"picocolors": "^1.0.0", | ||
"string-argv": "^0.3.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18.11.18", | ||
"tsup": "^6.5.0", | ||
"typescript": "^4.9.4", | ||
"@types/node": "^18.11.18" | ||
"typescript": "^4.9.4" | ||
}, | ||
@@ -36,0 +38,0 @@ "publishConfig": { |
Sorry, the diff of this file is not supported yet
11107
258
8
+ Addedexeca@^6.1.0
+ Addedstring-argv@^0.3.1
+ Added@kubb/core@0.19.0(transitive)
+ Addedcross-spawn@7.0.6(transitive)
+ Addedexeca@6.1.0(transitive)
+ Addedget-stream@6.0.1(transitive)
+ Addedhuman-signals@3.0.1(transitive)
+ Addedis-stream@3.0.0(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedmerge-stream@2.0.0(transitive)
+ Addedmimic-fn@4.0.0(transitive)
+ Addednpm-run-path@5.3.0(transitive)
+ Addedonetime@6.0.0(transitive)
+ Addedpath-key@3.1.14.0.0(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedstring-argv@0.3.2(transitive)
+ Addedstrip-final-newline@3.0.0(transitive)
+ Addedwhich@2.0.2(transitive)
- Removed@kubb/core@0.14.1(transitive)
Updated@kubb/core@0.19.0