-
Notifications
You must be signed in to change notification settings - Fork 181
Open
Description
It's not so easy to update this project dependencies, without rewriting everything and possibly breaking compabilities (even just node versions) with existing apps. There are issues like #195, #206, #222 discussing this
I'm wondering if it's worth archiving the project, similarly to momentjs project for example
There are alternatives:
- https://www.npmjs.com/package/inquirer
- https://www.npmjs.com/package/prompts
- https://www.npmjs.com/package/enquirer
- https://www.npmjs.com/package/promptly
- https://www.npmjs.com/package/prompt-sync (a very small prompt lib)
- https://www.npmjs.com/package/prompt-ajv (prompt-sync + ajv, so very close to prompt)
For example with prompt-sync, you can achieve the same behavior than prompt like this:
const promptSync = require('prompt-sync')();
const Ajv = require('ajv');
const ajv = new Ajv({ coerceTypes: true, useDefaults: true });
function prompt(schemaProps) {
const res = {};
const properties = Object.fromEntries(Object.entries(schemaProps).map(([k, {required, ...v}]) => [k, v]));
for (const [key, {description = key, default: _default, required}] of Object.entries(schemaProps)) {
const msg = `${description} ${_default !== undefined ? `(${_default}) ` : ''}`;
res[key] = promptSync(msg) || undefined;
while (!ajv.validate({type: 'object', properties, required: required?[key]:[]}, res)) {
console.error(ajv.errors.filter(o => o.instancePath === '' || o.instancePath === `/${key}`).map(({message, params}) => `> ${message} ${JSON.stringify(params)}`).join('\n'));
res[key] = promptSync(msg) || undefined;
}
}
return res;
}
const data = prompt({
name: {type: 'string', minLength: 2, required: true},
size: {type: 'string', enum: ['xs', 'sm', 'lg']},
age: {type: 'integer', description: 'How old ru?', minimum: 0, maximum: 150},
height: {type: 'number', description: 'Height in meters?', minimum: 0, maximum: 2.8, default: 1.8},
})What are your thoughts?
NabiKAZ
Metadata
Metadata
Assignees
Labels
No labels