New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@kubb/cli

Package Overview
Dependencies
Maintainers
1
Versions
685
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kubb/cli - npm Package Compare versions

Comparing version 0.34.0 to 0.35.0

199

dist/index.js

@@ -5,5 +5,3 @@ #!/usr/bin/env node

var commander = require('commander');
var cosmiconfig = require('cosmiconfig');
var cosmiconfigTypescriptLoader = require('cosmiconfig-typescript-loader');
var pc2 = require('picocolors');
var pc3 = require('picocolors');
var ora = require('ora');

@@ -13,3 +11,70 @@ var execa = require('execa');

var core = require('@kubb/core');
var cosmiconfig = require('cosmiconfig');
var cosmiconfigTypescriptLoader = require('cosmiconfig-typescript-loader');
async function run({ config, options, spinner: spinner2 }) {
const logger = {
log(message, logLevel) {
if (logLevel === "error") {
spinner2.fail(message);
}
spinner2[logLevel](message);
},
spinner: spinner2
};
const onDone = async (config2) => {
if (!config2.hooks?.done) {
return;
}
spinner2.start("Running hooks");
let commands = [];
if (typeof config2.hooks?.done === "string") {
commands = [config2.hooks.done];
} else {
commands = config2.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");
};
try {
spinner2.start("Building");
await core.build({
config: {
root: process.cwd(),
...config
},
mode: options.mode || "development",
logger
});
spinner2.succeed(pc3.blue("Kubb generation done"));
await onDone(config);
} catch (err) {
spinner2.fail("Something went wrong\n");
console.error(err);
}
return true;
}
var startWatcher = async (cb, options) => {
const { spinner: spinner2, path } = options;
const { watch } = await import('chokidar');
const ignored = ["**/{.git,node_modules}/**"];
const watcher = watch(path, {
ignorePermissionErrors: true,
ignored
});
watcher.on("all", async (type, file) => {
spinner2.succeed(pc3.yellow(pc3.bold(`Change detected: ${type} ${file}`)));
spinner2.spinner = "clock";
try {
await cb(options.path);
} catch (e) {
spinner2.warn(pc3.red(e));
}
});
};
// src/utils/getPlugins.ts

@@ -53,54 +118,33 @@ var isJSONPlugins = (plugins) => {

};
// src/run.ts
async function run({ result, options, spinner: spinner2 }) {
const logger = {
log(message, logLevel) {
if (logLevel === "error") {
spinner2.fail(message);
}
spinner2[logLevel](message);
},
spinner: spinner2
};
const onDone = async (config) => {
if (!config.hooks?.done) {
return;
var getCosmiConfig = async (moduleName2, config) => {
const explorer = cosmiconfig.cosmiconfig(moduleName2, {
cache: false,
searchPlaces: [
"package.json",
`.${moduleName2}rc`,
`.${moduleName2}rc.json`,
`.${moduleName2}rc.js`,
`.${moduleName2}rc.cjs`,
`${moduleName2}.config.js`,
`${moduleName2}.config.cjs`,
`.${moduleName2}rc.ts`,
`${moduleName2}.config.ts`
],
loaders: {
".ts": cosmiconfigTypescriptLoader.TypeScriptLoader({
swc: true,
typeCheck: false
}),
noExt: cosmiconfig.defaultLoaders[".js"]
}
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");
};
try {
spinner2.start("Building");
const config = await getConfig(result, options);
await core.build({
config: {
root: process.cwd(),
...config
},
mode: options.mode || "development",
logger
});
spinner2.succeed(pc2.blue("Kubb generation done"));
await onDone(config);
} catch (err) {
spinner2.fail("Something went wrong\n");
console.error(err);
});
const result = config ? await explorer.load(config) : await explorer.search();
if (result?.isEmpty || !result || !result.config) {
throw new Error("Config not defined, create a kubb.config.js or pass through your config with the option --config");
}
return true;
}
return result;
};
// package.json
var version = "0.34.0";
var version = "0.35.0";

@@ -111,33 +155,32 @@ // src/index.ts

color: "blue",
text: pc2.blue("Kubb generation started"),
text: pc3.blue("Kubb generation started"),
spinner: "clock"
}).start();
var explorer = cosmiconfig.cosmiconfig(moduleName, {
searchPlaces: [
"package.json",
`.${moduleName}rc`,
`.${moduleName}rc.json`,
`.${moduleName}rc.js`,
`.${moduleName}rc.cjs`,
`${moduleName}.config.js`,
`${moduleName}.config.cjs`,
`.${moduleName}rc.ts`,
`${moduleName}.config.ts`
],
loaders: {
".ts": cosmiconfigTypescriptLoader.TypeScriptLoader(),
noExt: cosmiconfig.defaultLoaders[".js"]
}
});
var program = new commander.Command(moduleName).description("Kubb").action(async (options) => {
spinner.succeed(pc2.blue("Kubb generation started"));
spinner.start("Loading config");
const result = options.config ? await explorer.load(options.config) : await explorer.search();
if (result?.isEmpty || !result || !result.config) {
spinner.fail(pc2.red("Config not defined, create a kubb.config.js or pass through your config with the option --config"));
return;
try {
spinner.succeed(pc3.blue("Kubb generation started"));
spinner.start("Loading config");
const result = await getCosmiConfig(moduleName, options.config);
spinner.succeed("Config loaded");
if (options.watch) {
const config = await getConfig(result, options);
startWatcher(
async (paths) => {
await run({ config, spinner, options });
spinner.spinner = "simpleDotsScrolling";
spinner.start(pc3.yellow(pc3.bold(`Watching for changes in ${paths.join(" and ")}`)));
},
{
spinner,
path: [config.input.path]
}
);
} else {
const config = await getConfig(result, options);
await run({ config, spinner, options });
}
} catch (e) {
spinner.fail(pc3.red(e.message));
}
spinner.succeed("Config loaded");
await run({ result, spinner, options });
}).addOption(new commander.Option("-m, --mode <mode>", "Mode of Kubb, development or production").default("development")).addOption(new commander.Option("-c, --config <path>", "Path to @kubb config")).addOption(new commander.Option("-d, --debug", "Debug mode").default(false));
}).addOption(new commander.Option("-m, --mode <mode>", "Mode of Kubb, development or production").default("development")).addOption(new commander.Option("-c, --config <path>", "Path to @kubb config")).addOption(new commander.Option("-d, --debug", "Debug mode").default(false)).addOption(new commander.Option("-w, --watch", "Watch mode based on the input file"));
program.name(moduleName).description("Generate").version(version, "-v").parse();
{
"name": "@kubb/cli",
"version": "0.34.0",
"version": "0.35.0",
"description": "Generator cli",

@@ -23,3 +23,4 @@ "repository": {

"dependencies": {
"@kubb/core": "0.34.0",
"@kubb/core": "0.35.0",
"chokidar": "^3.5.3",
"commander": "^9.4.1",

@@ -34,4 +35,4 @@ "cosmiconfig": "^8.0.0",

"devDependencies": {
"@types/node": "^18.11.18",
"ts-node": "^10.9.1",
"@types/node": "^18.11.18",
"tsup": "^6.5.0",

@@ -38,0 +39,0 @@ "typescript": "^4.9.4"

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc