Skip to content

Should we archive this project? #223

@caub

Description

@caub

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:

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions