@prisma-next/cli 0.5.0-dev.4 → 0.5.0-dev.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-skill-mongo.md +63 -31
- package/dist/agent-skill-postgres.md +1 -1
- package/dist/cli.mjs +119 -13
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-TG7rbCWT.mjs → client-CrsnY58k.mjs} +4 -4
- package/dist/{client-TG7rbCWT.mjs.map → client-CrsnY58k.mjs.map} +1 -1
- package/dist/commands/contract-emit.mjs +2 -2
- package/dist/commands/contract-infer.mjs +2 -2
- package/dist/commands/db-init.mjs +7 -7
- package/dist/commands/db-schema.mjs +5 -5
- package/dist/commands/db-sign.mjs +7 -7
- package/dist/commands/db-update.mjs +7 -7
- package/dist/commands/db-verify.mjs +7 -7
- package/dist/commands/migration-apply.mjs +6 -6
- package/dist/commands/migration-new.mjs +5 -5
- package/dist/commands/migration-plan.mjs +6 -6
- package/dist/commands/migration-ref.d.mts +1 -1
- package/dist/commands/migration-ref.mjs +4 -4
- package/dist/commands/migration-show.d.mts +1 -1
- package/dist/commands/migration-show.mjs +6 -6
- package/dist/commands/migration-status.mjs +2 -2
- package/dist/{config-loader-_W4T21X1.mjs → config-loader-C25b63rJ.mjs} +1 -1
- package/dist/{config-loader-_W4T21X1.mjs.map → config-loader-C25b63rJ.mjs.map} +1 -1
- package/dist/config-loader.mjs +1 -1
- package/dist/contract-emit--feXyNd7.mjs +4 -0
- package/dist/{contract-emit-DpPjuFy-.mjs → contract-emit-NJ01hiiv.mjs} +8 -8
- package/dist/{contract-emit-DpPjuFy-.mjs.map → contract-emit-NJ01hiiv.mjs.map} +1 -1
- package/dist/{contract-emit-CQfj7xJn.mjs → contract-emit-V5SSitUT.mjs} +6 -6
- package/dist/{contract-emit-CQfj7xJn.mjs.map → contract-emit-V5SSitUT.mjs.map} +1 -1
- package/dist/{contract-enrichment-CGW6mm-E.mjs → contract-enrichment-CAOELa-H.mjs} +1 -1
- package/dist/{contract-enrichment-CGW6mm-E.mjs.map → contract-enrichment-CAOELa-H.mjs.map} +1 -1
- package/dist/{contract-infer-BS4kIX9c.mjs → contract-infer-D9cC3rJm.mjs} +4 -4
- package/dist/{contract-infer-BS4kIX9c.mjs.map → contract-infer-D9cC3rJm.mjs.map} +1 -1
- package/dist/exports/control-api.mjs +4 -4
- package/dist/exports/index.mjs +2 -2
- package/dist/exports/init-output.d.mts +39 -0
- package/dist/exports/init-output.d.mts.map +1 -0
- package/dist/exports/init-output.mjs +3 -0
- package/dist/{extract-operation-statements-DZUJNmL3.mjs → extract-operation-statements-DsFfxXVZ.mjs} +2 -2
- package/dist/{extract-operation-statements-DZUJNmL3.mjs.map → extract-operation-statements-DsFfxXVZ.mjs.map} +1 -1
- package/dist/{extract-sql-ddl-DDMX-9mz.mjs → extract-sql-ddl-D9UbZDyz.mjs} +1 -1
- package/dist/{extract-sql-ddl-DDMX-9mz.mjs.map → extract-sql-ddl-D9UbZDyz.mjs.map} +1 -1
- package/dist/{framework-components-DfZKQBQ2.mjs → framework-components-Cr--XBKy.mjs} +2 -2
- package/dist/{framework-components-DfZKQBQ2.mjs.map → framework-components-Cr--XBKy.mjs.map} +1 -1
- package/dist/init-C5220SY9.mjs +2062 -0
- package/dist/init-C5220SY9.mjs.map +1 -0
- package/dist/{inspect-live-schema-BsoFVoS1.mjs → inspect-live-schema-yrHAvG71.mjs} +6 -6
- package/dist/{inspect-live-schema-BsoFVoS1.mjs.map → inspect-live-schema-yrHAvG71.mjs.map} +1 -1
- package/dist/migration-cli.mjs +1 -1
- package/dist/{migration-command-scaffold-DOXnheFa.mjs → migration-command-scaffold-B3B09et6.mjs} +6 -6
- package/dist/{migration-command-scaffold-DOXnheFa.mjs.map → migration-command-scaffold-B3B09et6.mjs.map} +1 -1
- package/dist/{migration-status-Ry3TnEya.mjs → migration-status-DUMiH8_G.mjs} +6 -6
- package/dist/{migration-status-Ry3TnEya.mjs.map → migration-status-DUMiH8_G.mjs.map} +1 -1
- package/dist/{migrations-fU0xoKjS.mjs → migrations-Bo5WtTla.mjs} +2 -2
- package/dist/{migrations-fU0xoKjS.mjs.map → migrations-Bo5WtTla.mjs.map} +1 -1
- package/dist/output-BpcQrnnq.mjs +103 -0
- package/dist/output-BpcQrnnq.mjs.map +1 -0
- package/dist/{progress-adapter-B-YvmcDu.mjs → progress-adapter-DvQWB1nK.mjs} +1 -1
- package/dist/{progress-adapter-B-YvmcDu.mjs.map → progress-adapter-DvQWB1nK.mjs.map} +1 -1
- package/dist/quick-reference-mongo.md +34 -13
- package/dist/quick-reference-postgres.md +11 -9
- package/dist/{result-handler-BJwA7ufw.mjs → result-handler-Ba3zWQsI.mjs} +4 -77
- package/dist/result-handler-Ba3zWQsI.mjs.map +1 -0
- package/dist/{terminal-ui-C5k88MmW.mjs → terminal-ui-C3ZLwQxK.mjs} +76 -2
- package/dist/terminal-ui-C3ZLwQxK.mjs.map +1 -0
- package/dist/{validate-contract-deps-esa-VQ0h.mjs → validate-contract-deps-B_Cs29TL.mjs} +1 -1
- package/dist/{validate-contract-deps-esa-VQ0h.mjs.map → validate-contract-deps-B_Cs29TL.mjs.map} +1 -1
- package/dist/{verify-bl__PkXk.mjs → verify-Bkycc-Tf.mjs} +2 -2
- package/dist/{verify-bl__PkXk.mjs.map → verify-Bkycc-Tf.mjs.map} +1 -1
- package/package.json +21 -16
- package/src/commands/init/detect-pnpm-catalog.ts +141 -0
- package/src/commands/init/errors.ts +254 -0
- package/src/commands/init/exit-codes.ts +62 -0
- package/src/commands/init/hygiene-gitattributes.ts +97 -0
- package/src/commands/init/hygiene-gitignore.ts +48 -0
- package/src/commands/init/hygiene-package-scripts.ts +91 -0
- package/src/commands/init/index.ts +112 -7
- package/src/commands/init/init.ts +766 -144
- package/src/commands/init/inputs.ts +421 -0
- package/src/commands/init/output.ts +147 -0
- package/src/commands/init/probe-db.ts +308 -0
- package/src/commands/init/reinit-cleanup.ts +83 -0
- package/src/commands/init/templates/agent-skill-mongo.md +63 -31
- package/src/commands/init/templates/agent-skill-postgres.md +1 -1
- package/src/commands/init/templates/agent-skill.ts +25 -3
- package/src/commands/init/templates/code-templates.ts +125 -32
- package/src/commands/init/templates/env.ts +80 -0
- package/src/commands/init/templates/quick-reference-mongo.md +34 -13
- package/src/commands/init/templates/quick-reference-postgres.md +11 -9
- package/src/commands/init/templates/quick-reference.ts +42 -3
- package/src/commands/init/templates/tsconfig.ts +167 -5
- package/src/exports/init-output.ts +10 -0
- package/dist/contract-emit-fhNwwhkQ.mjs +0 -4
- package/dist/init-CQfo_4Ro.mjs +0 -430
- package/dist/init-CQfo_4Ro.mjs.map +0 -1
- package/dist/result-handler-BJwA7ufw.mjs.map +0 -1
- package/dist/terminal-ui-C5k88MmW.mjs.map +0 -1
- /package/dist/{cli-errors-C0JhVj0c.d.mts → cli-errors-BFYgBH3L.d.mts} +0 -0
- /package/dist/{cli-errors-DHq6GQGu.mjs → cli-errors-Cd79vmTH.mjs} +0 -0
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
addGlobalOptions,
|
|
4
|
+
setCommandDescriptions,
|
|
5
|
+
setCommandExamples,
|
|
6
|
+
} from '../../utils/command-helpers';
|
|
7
|
+
import { type CommonCommandOptions, parseGlobalFlags } from '../../utils/global-flags';
|
|
8
|
+
import {
|
|
9
|
+
INIT_EXIT_EMIT_FAILED,
|
|
10
|
+
INIT_EXIT_INSTALL_FAILED,
|
|
11
|
+
INIT_EXIT_INTERNAL_ERROR,
|
|
12
|
+
INIT_EXIT_OK,
|
|
13
|
+
INIT_EXIT_PRECONDITION,
|
|
14
|
+
INIT_EXIT_USER_ABORTED,
|
|
15
|
+
} from './exit-codes';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Commander.js parsed options for `init`. The init-specific options live
|
|
19
|
+
* alongside the inherited `CommonCommandOptions` global flags.
|
|
20
|
+
*
|
|
21
|
+
* `target` and `authoring` are typed as plain `string` here because
|
|
22
|
+
* Commander.js does not enforce enums at parse time — the validation /
|
|
23
|
+
* normalisation happens in `inputs.ts::resolveInitInputs`, which can
|
|
24
|
+
* raise a structured `errorInitInvalidFlagValue` with the full set of
|
|
25
|
+
* allowed values.
|
|
26
|
+
*/
|
|
27
|
+
interface InitCommandOptions extends CommonCommandOptions {
|
|
28
|
+
readonly target?: string;
|
|
29
|
+
readonly authoring?: string;
|
|
30
|
+
readonly schemaPath?: string;
|
|
31
|
+
readonly force?: boolean;
|
|
32
|
+
readonly writeEnv?: boolean;
|
|
33
|
+
readonly probeDb?: boolean;
|
|
34
|
+
readonly strictProbe?: boolean;
|
|
35
|
+
readonly install?: boolean;
|
|
36
|
+
}
|
|
3
37
|
|
|
4
38
|
export function createInitCommand(): Command {
|
|
5
39
|
const command = new Command('init');
|
|
@@ -7,15 +41,86 @@ export function createInitCommand(): Command {
|
|
|
7
41
|
command,
|
|
8
42
|
'Initialize a new Prisma Next project',
|
|
9
43
|
'Scaffolds config, schema, and runtime files, installs dependencies,\n' +
|
|
10
|
-
'and emits the contract. Gets you from zero to typed queries in one step
|
|
44
|
+
'and emits the contract. Gets you from zero to typed queries in one step.\n' +
|
|
45
|
+
'\n' +
|
|
46
|
+
'Run interactively for a guided experience, or supply --target / --authoring\n' +
|
|
47
|
+
'and --yes for a fully scriptable run (CI, AI coding agents, automation).\n' +
|
|
48
|
+
'\n' +
|
|
49
|
+
'Exit codes (see CLI Style Guide § Exit Codes):\n' +
|
|
50
|
+
` ${INIT_EXIT_OK} OK Init succeeded.\n` +
|
|
51
|
+
` ${INIT_EXIT_INTERNAL_ERROR} INTERNAL_ERROR Unexpected bug in prisma-next (please report).\n` +
|
|
52
|
+
` ${INIT_EXIT_PRECONDITION} PRECONDITION Bad flags / missing prerequisite (e.g. no package.json).\n` +
|
|
53
|
+
` ${INIT_EXIT_USER_ABORTED} USER_ABORTED User cancelled an interactive prompt.\n` +
|
|
54
|
+
` ${INIT_EXIT_INSTALL_FAILED} INSTALL_FAILED Dependency installation failed (init-specific).\n` +
|
|
55
|
+
` ${INIT_EXIT_EMIT_FAILED} EMIT_FAILED \`contract emit\` failed after install (init-specific).`,
|
|
11
56
|
);
|
|
12
|
-
setCommandExamples(command, [
|
|
13
|
-
|
|
57
|
+
setCommandExamples(command, [
|
|
58
|
+
'prisma-next init',
|
|
59
|
+
'prisma-next init --yes --target postgres --authoring psl',
|
|
60
|
+
'prisma-next init --yes --target mongodb --authoring typescript --json',
|
|
61
|
+
'prisma-next init --yes --force --target postgres --authoring psl # overwrite an existing scaffold',
|
|
62
|
+
'prisma-next init --no-install # skip pnpm/npm install + emit',
|
|
63
|
+
]);
|
|
64
|
+
|
|
65
|
+
return addGlobalOptions(command)
|
|
66
|
+
.option('--target <db>', 'Database target: postgres or mongodb')
|
|
67
|
+
.option('--authoring <style>', 'Schema authoring style: psl or typescript')
|
|
68
|
+
.option(
|
|
69
|
+
'--schema-path <path>',
|
|
70
|
+
'Where to write the starter schema (default: prisma/contract.prisma)',
|
|
71
|
+
)
|
|
72
|
+
.option('--force', 'Overwrite an existing scaffold without prompting')
|
|
73
|
+
.option(
|
|
74
|
+
'--write-env',
|
|
75
|
+
'Write a .env file from .env.example (gitignored; default: only .env.example)',
|
|
76
|
+
)
|
|
77
|
+
.option(
|
|
78
|
+
'--probe-db',
|
|
79
|
+
'Connect to DATABASE_URL once and check the server version against the target minimum (opt-in; off by default)',
|
|
80
|
+
)
|
|
81
|
+
.option(
|
|
82
|
+
'--strict-probe',
|
|
83
|
+
'Treat a failed --probe-db as fatal (no-op without --probe-db; init is offline-by-default)',
|
|
84
|
+
)
|
|
14
85
|
.option('--no-install', 'Skip dependency installation and contract emission')
|
|
15
|
-
.action(async (options:
|
|
86
|
+
.action(async (options: InitCommandOptions) => {
|
|
16
87
|
const { runInit } = await import('./init');
|
|
17
|
-
|
|
88
|
+
const flags = parseGlobalFlags(options);
|
|
89
|
+
const canPrompt = deriveCanPrompt({
|
|
90
|
+
flagsInteractive: flags.interactive,
|
|
91
|
+
optionInteractive: options.interactive,
|
|
92
|
+
stdinIsTTY: Boolean(process.stdin.isTTY),
|
|
93
|
+
});
|
|
94
|
+
const exitCode = await runInit(process.cwd(), { options, flags, canPrompt });
|
|
95
|
+
process.exit(exitCode);
|
|
18
96
|
});
|
|
97
|
+
}
|
|
19
98
|
|
|
20
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Bridges the action handler's two TTY checks (stdout via `flags`, stdin
|
|
101
|
+
* via `process.stdin.isTTY`) into the `canPrompt` boolean `runInit`
|
|
102
|
+
* consumes.
|
|
103
|
+
*
|
|
104
|
+
* Per the [Style Guide § Interactivity](../../../../../../../docs/CLI%20Style%20Guide.md#interactivity):
|
|
105
|
+
*
|
|
106
|
+
* - `flags.interactive` governs *decoration* (TerminalUI, intro/outro,
|
|
107
|
+
* spinners) and is derived from stdout-TTY by `parseGlobalFlags`,
|
|
108
|
+
* honouring `--interactive` / `--no-interactive`.
|
|
109
|
+
* - Prompting additionally requires a stdin TTY — closing stdin is a
|
|
110
|
+
* common signal in CI / agent environments even when stdout stays
|
|
111
|
+
* attached.
|
|
112
|
+
* - `--interactive` is the explicit override: when the user passes it,
|
|
113
|
+
* we honour it (e.g. testing flows where stdin is stubbed).
|
|
114
|
+
*
|
|
115
|
+
* Exported so callers and tests can derive the same value without
|
|
116
|
+
* touching `process` globals — F14 of the M1/M2 review.
|
|
117
|
+
*/
|
|
118
|
+
export function deriveCanPrompt(opts: {
|
|
119
|
+
readonly flagsInteractive: boolean | undefined;
|
|
120
|
+
readonly optionInteractive: boolean | undefined;
|
|
121
|
+
readonly stdinIsTTY: boolean;
|
|
122
|
+
}): boolean {
|
|
123
|
+
if (opts.optionInteractive === true) return true;
|
|
124
|
+
if (opts.flagsInteractive === false) return false;
|
|
125
|
+
return opts.stdinIsTTY;
|
|
21
126
|
}
|