Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Options fail with latest nest cli #69

Open
NoahMarconi opened this issue Jul 14, 2023 · 2 comments
Open

Options fail with latest nest cli #69

NoahMarconi opened this issue Jul 14, 2023 · 2 comments

Comments

@NoahMarconi
Copy link

$ npx @nestjs/cli@latest add nestjs-prisma --addPrismaService
✔ Package installation in progress... ☕
Starting library setup...
/home/__SNIP__/node_modules/.pnpm/@angular-devkit+schematics-cli@16.1.0_chokidar@3.5.3/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,
    };
}
@micalevisk
Copy link

micalevisk commented Aug 10, 2023

that --add-prisma-service/--addPrismaService isn't a valid flag for @nestjs/cli add command

not sure what you're trying to do here 🤔

@NoahMarconi
Copy link
Author

It's from your docs: https://nestjs-prisma.dev/docs/custom-prisma-service/

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants