Skip to content

Options fail with latest nest cli #69

@NoahMarconi

Description

@NoahMarconi
$ npx @nestjs/cli@latest add nestjs-prisma --addPrismaService
✔ Package installation in progress... ☕
Starting library setup...
/home/__SNIP__/node_modules/.pnpm/@[email protected][email protected]/node_modules/@angular-devkit/schematics-cli/bin/schematics.js:397
            throw new Error(`Unknown argument ${key}. Did you mean ${(0, yargs_parser_1.decamelize)(key)}?`);
                  ^

Error: Unknown argument addPrismaService. Did you mean add-prisma-service?

The below command works as expected:

$ npx @nestjs/cli@latest add nestjs-prisma --add-prisma-service

Here's the code snippet from the line indicated above (where it throws on any capital letters):

function parseArgs(args) {
    const { _, ...options } = (0, yargs_parser_1.default)(args, {
        boolean: booleanArgs,
        default: {
            'interactive': true,
            'debug': null,
            'dry-run': null,
        },
        configuration: {
            'dot-notation': false,
            'boolean-negation': true,
            'strip-aliased': true,
            'camel-case-expansion': false,
        },
    });
    // Camelize options as yargs will return the object in kebab-case when camel casing is disabled.
    const schematicOptions = {};
    const cliOptions = {};
    const isCliOptions = (key) => booleanArgs.includes(key);
    for (const [key, value] of Object.entries(options)) {
        if (/[A-Z]/.test(key)) {
            throw new Error(`Unknown argument ${key}. Did you mean ${(0, yargs_parser_1.decamelize)(key)}?`);
        }
        if (isCliOptions(key)) {
            cliOptions[key] = value;
        }
        else {
            schematicOptions[(0, yargs_parser_1.camelCase)(key)] = value;
        }
    }
    return {
        _: _.map((v) => v.toString()),
        schematicOptions,
        cliOptions,
    };
}

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