Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

autoprompt

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autoprompt - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

4

dist/autoprompt/autoprompt.d.ts

@@ -17,5 +17,5 @@ import type { Command, Option, OptionValues } from "commander";

};
export declare function autoprompt<T>(program: Command, autoPromptOpts?: AutoPromptOptions): Promise<T>;
export declare function promptForMissingOptions<T>(prompter: typeof prompt, options: ValidOption[], parsedOptions: OptionValues): Promise<T>;
export declare function autoprompt(program: Command, autoPromptOpts?: AutoPromptOptions): Promise<Command>;
export declare function promptForMissingOptions(prompter: typeof prompt, options: ValidOption[], parsedOptions: OptionValues): Promise<Partial<OptionValues>>;
export {};
//# sourceMappingURL=autoprompt.d.ts.map
import chalk from "chalk";
import enquirer from "enquirer";
import { convertStringToOptions } from "../util.js";
import { camelize, convertStringToOptions } from "../util.js";
const { prompt } = enquirer;

@@ -41,6 +41,13 @@ export const validateOption = (option) => {

const options = program.options.map(validateOption);
program.parse();
program.parseOptions(process.argv);
const parsedOptions = program.opts();
const promptedOptions = await promptForMissingOptions(autoPromptOpts?.prompter ?? prompt, options, parsedOptions);
return { ...parsedOptions, ...promptedOptions };
const args = process.argv;
args.push(...Object.entries(promptedOptions)
.filter(([_key, value]) => value != null)
.map(([key, value]) => {
return `--${key}=${value}`;
}));
program.parse(args);
return program;
}

@@ -51,5 +58,5 @@ export async function promptForMissingOptions(prompter, options, parsedOptions) {

// only prompt for options that were not passed in
const missingValue = !parsedOptions[opt.long.replace("--", "")];
const missingValue = !parsedOptions[camelize(opt.long.replace("--", ""))];
if (!missingValue) {
console.log(`${chalk.green("✔")} ${opt.description} · ${parsedOptions[opt.long.replace("--", "")]}`);
console.log(`${chalk.green("✔")} ${opt.description} · ${parsedOptions[camelize(opt.long.replace("--", ""))]}`);
}

@@ -56,0 +63,0 @@ return missingValue;

export declare function convertStringToOptions(input: string): string[];
export declare const kebabize: (str: string) => string;
export declare const camelize: (s: string) => string;
//# sourceMappingURL=util.d.ts.map

@@ -9,3 +9,3 @@ export function convertStringToOptions(input) {

if (match?.[1]) {
return match[1].split('|');
return match[1].split("|");
}

@@ -15,2 +15,4 @@ // Return an empty array if no options are found

}
export const kebabize = (str) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? "-" : "") + $.toLowerCase());
export const camelize = (s) => s.replace(/-./g, (x) => x[1].toUpperCase());
//# sourceMappingURL=util.js.map
{
"name": "autoprompt",
"version": "1.0.1",
"version": "2.0.0",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "type": "module",

@@ -43,11 +43,11 @@ # autoprompt

"Toppings",
);
).action((opts: Pizza) => {
console.log(opts);
});
program.parse(process.argv);
// prompt the user for optionss not provided on the command line
const options = await autoprompt<Pizza>(program);
// prompt the user for options not provided on the command line
await autoprompt(program);
console.log(options);
/**

@@ -54,0 +54,0 @@ * {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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