notiz-dev / nestjs-prisma

Easy Prisma support for your NestJS application
https://nestjs-prisma.dev
MIT License
587 stars 50 forks source link

Options fail with latest nest cli #69

Open NoahMarconi opened 1 year ago

NoahMarconi commented 1 year ago
$ 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 commented 1 year ago

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

not sure what you're trying to do here :thinking:

NoahMarconi commented 1 year ago

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