Should we archive this project?
caub opened this issue · comments
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?
you are still losing all case scenarios of array items, and object , this is valid only for primtives
@ilyashusterman how do you pass arrays from the REPL?
@ilyashusterman oh right, I didn't even know prompt package supported arrays, I'm fine not supporting them to be honest
I created a simple prompt-ajv package that does it: https://replit.com/@caub/prompt#index.js