@prisma-next/cli 0.10.0-dev.9 → 0.11.0-dev.1
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/README.md +1 -1
- package/dist/{cli-errors-CF60g2cG.mjs → cli-errors-Djtz98Vm.mjs} +3 -3
- package/dist/cli-errors-Djtz98Vm.mjs.map +1 -0
- package/dist/cli.mjs +296 -53
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-Brv4qlfB.mjs → client-oXO2WCPD.mjs} +6 -5
- package/dist/client-oXO2WCPD.mjs.map +1 -0
- package/dist/{command-helpers-Dvgul7UA.mjs → command-helpers-DtavI0wJ.mjs} +108 -11
- package/dist/command-helpers-DtavI0wJ.mjs.map +1 -0
- package/dist/commands/contract-emit.mjs +1 -1
- package/dist/commands/contract-infer.mjs +1 -1
- package/dist/commands/db-init.d.mts.map +1 -1
- package/dist/commands/db-init.mjs +19 -20
- package/dist/commands/db-init.mjs.map +1 -1
- package/dist/commands/db-schema.mjs +6 -10
- package/dist/commands/db-schema.mjs.map +1 -1
- package/dist/commands/db-sign.mjs +7 -11
- package/dist/commands/db-sign.mjs.map +1 -1
- package/dist/commands/db-update.d.mts.map +1 -1
- package/dist/commands/db-update.mjs +16 -17
- package/dist/commands/db-update.mjs.map +1 -1
- package/dist/commands/db-verify.mjs +1 -1
- package/dist/commands/migrate.d.mts +1 -1
- package/dist/commands/migrate.mjs +7 -11
- package/dist/commands/migrate.mjs.map +1 -1
- package/dist/commands/migration-check.mjs +4 -7
- package/dist/commands/migration-check.mjs.map +1 -1
- package/dist/commands/migration-graph.d.mts +1 -1
- package/dist/commands/migration-graph.mjs +6 -10
- package/dist/commands/migration-graph.mjs.map +1 -1
- package/dist/commands/migration-list.mjs +5 -9
- package/dist/commands/migration-list.mjs.map +1 -1
- package/dist/commands/migration-log.d.mts.map +1 -1
- package/dist/commands/migration-log.mjs +7 -10
- package/dist/commands/migration-log.mjs.map +1 -1
- package/dist/commands/migration-new.mjs +6 -10
- package/dist/commands/migration-new.mjs.map +1 -1
- package/dist/commands/migration-plan.d.mts +1 -1
- package/dist/commands/migration-plan.mjs +1 -1
- package/dist/commands/migration-show.d.mts +1 -1
- package/dist/commands/migration-show.mjs +8 -12
- package/dist/commands/migration-show.mjs.map +1 -1
- package/dist/commands/migration-status.d.mts +1 -1
- package/dist/commands/migration-status.d.mts.map +1 -1
- package/dist/commands/migration-status.mjs +36 -14
- package/dist/commands/migration-status.mjs.map +1 -1
- package/dist/commands/ref.d.mts +1 -1
- package/dist/commands/ref.mjs +9 -19
- package/dist/commands/ref.mjs.map +1 -1
- package/dist/{contract-emit-iynA3BCA.mjs → contract-emit-bcrpT-wD.mjs} +3 -3
- package/dist/{contract-emit-iynA3BCA.mjs.map → contract-emit-bcrpT-wD.mjs.map} +1 -1
- package/dist/{contract-emit-BDBzHlaC.mjs → contract-emit-uwT-Mj8-.mjs} +7 -12
- package/dist/contract-emit-uwT-Mj8-.mjs.map +1 -0
- package/dist/{contract-infer-Dm8pBZMR.mjs → contract-infer-pKkiCt7C.mjs} +9 -14
- package/dist/contract-infer-pKkiCt7C.mjs.map +1 -0
- package/dist/{contract-space-aggregate-loader-pAc8CDfY.mjs → contract-space-aggregate-loader-BmNQwlws.mjs} +2 -2
- package/dist/{contract-space-aggregate-loader-pAc8CDfY.mjs.map → contract-space-aggregate-loader-BmNQwlws.mjs.map} +1 -1
- package/dist/{db-verify-CW8DR5Ei.mjs → db-verify-AoIUriL4.mjs} +9 -13
- package/dist/db-verify-AoIUriL4.mjs.map +1 -0
- package/dist/exports/control-api.d.mts +1 -1
- package/dist/exports/control-api.mjs +2 -2
- package/dist/exports/index.mjs +1 -1
- package/dist/exports/init-output.mjs +1 -1
- package/dist/{framework-components-xFLFpZUO.mjs → framework-components-65gOHkHB.mjs} +2 -2
- package/dist/{framework-components-xFLFpZUO.mjs.map → framework-components-65gOHkHB.mjs.map} +1 -1
- package/dist/{global-flags-DGmw6Kqg.d.mts → global-flags-CdE7M0d9.d.mts} +4 -1
- package/dist/global-flags-CdE7M0d9.d.mts.map +1 -0
- package/dist/{graph-render-eJDcLWny.mjs → graph-render-DJVv0_uf.mjs} +1 -1
- package/dist/{graph-render-eJDcLWny.mjs.map → graph-render-DJVv0_uf.mjs.map} +1 -1
- package/dist/{init-CxS9eqbQ.mjs → init-YX6lCJpG.mjs} +140 -301
- package/dist/init-YX6lCJpG.mjs.map +1 -0
- package/dist/{inspect-live-schema-iETRZ_59.mjs → inspect-live-schema-LeWvkZVz.mjs} +4 -4
- package/dist/{inspect-live-schema-iETRZ_59.mjs.map → inspect-live-schema-LeWvkZVz.mjs.map} +1 -1
- package/dist/{migration-command-scaffold-BlgVj_Pn.mjs → migration-command-scaffold-BtkunvFQ.mjs} +4 -4
- package/dist/{migration-command-scaffold-BlgVj_Pn.mjs.map → migration-command-scaffold-BtkunvFQ.mjs.map} +1 -1
- package/dist/{migration-plan-BSzcWsvm.mjs → migration-plan-C2jeH1J5.mjs} +8 -12
- package/dist/migration-plan-C2jeH1J5.mjs.map +1 -0
- package/dist/{migration-types-D2FW63pr.d.mts → migration-types-BXWvz12q.d.mts} +1 -1
- package/dist/{migration-types-D2FW63pr.d.mts.map → migration-types-BXWvz12q.d.mts.map} +1 -1
- package/dist/{migrations-CgANWI0w.mjs → migrations-CwZMa1Ck.mjs} +2 -2
- package/dist/{migrations-CgANWI0w.mjs.map → migrations-CwZMa1Ck.mjs.map} +1 -1
- package/dist/{output-B60Gw5fu.mjs → output-BlsrGMEF.mjs} +1 -1
- package/dist/{output-B60Gw5fu.mjs.map → output-BlsrGMEF.mjs.map} +1 -1
- package/dist/readme-mongo.md +35 -0
- package/dist/readme-postgres.md +34 -0
- package/dist/{terminal-ui-XtOQsqe9.mjs → terminal-ui-BiB_8KNo.mjs} +131 -24
- package/dist/terminal-ui-BiB_8KNo.mjs.map +1 -0
- package/dist/{types-0aS865QN.d.mts → types--CqjMdk0.d.mts} +2 -2
- package/dist/{types-0aS865QN.d.mts.map → types--CqjMdk0.d.mts.map} +1 -1
- package/dist/{verify-nlzO0uIY.mjs → verify-Bom75OYI.mjs} +2 -2
- package/dist/{verify-nlzO0uIY.mjs.map → verify-Bom75OYI.mjs.map} +1 -1
- package/package.json +18 -18
- package/src/cli.ts +36 -9
- package/src/commands/contract-emit.ts +4 -4
- package/src/commands/contract-infer.ts +7 -7
- package/src/commands/db-init.ts +13 -5
- package/src/commands/db-schema.ts +4 -4
- package/src/commands/db-sign.ts +4 -4
- package/src/commands/db-update.ts +13 -5
- package/src/commands/db-verify.ts +5 -5
- package/src/commands/init/detect-package-manager.ts +15 -0
- package/src/commands/init/errors.ts +31 -0
- package/src/commands/init/hygiene-gitattributes.ts +2 -2
- package/src/commands/init/index.ts +4 -3
- package/src/commands/init/init.ts +33 -17
- package/src/commands/init/inputs.ts +6 -4
- package/src/commands/init/output.ts +1 -1
- package/src/commands/init/skill-install.ts +37 -26
- package/src/commands/init/templates/code-templates.ts +8 -14
- package/src/commands/init/templates/env.ts +8 -1
- package/src/commands/init/templates/readme-mongo.md +35 -0
- package/src/commands/init/templates/readme-postgres.md +34 -0
- package/src/commands/init/templates/readme.ts +62 -0
- package/src/commands/migrate.ts +4 -7
- package/src/commands/migration-check.ts +4 -4
- package/src/commands/migration-graph.ts +4 -4
- package/src/commands/migration-list.ts +4 -4
- package/src/commands/migration-log.ts +6 -5
- package/src/commands/migration-new.ts +4 -4
- package/src/commands/migration-plan.ts +4 -4
- package/src/commands/migration-show.ts +4 -4
- package/src/commands/migration-status.ts +49 -6
- package/src/commands/ref.ts +8 -8
- package/src/control-api/operations/apply-aggregate.ts +1 -0
- package/src/utils/cli-errors.ts +4 -0
- package/src/utils/command-helpers.ts +14 -6
- package/src/utils/global-flags.ts +102 -17
- package/src/utils/telemetry.ts +27 -52
- package/src/utils/terminal-ui.ts +44 -23
- package/dist/cli-errors-CF60g2cG.mjs.map +0 -1
- package/dist/client-Brv4qlfB.mjs.map +0 -1
- package/dist/command-helpers-Dvgul7UA.mjs.map +0 -1
- package/dist/contract-emit-BDBzHlaC.mjs.map +0 -1
- package/dist/contract-infer-Dm8pBZMR.mjs.map +0 -1
- package/dist/db-verify-CW8DR5Ei.mjs.map +0 -1
- package/dist/errors-BYAXmyRJ.mjs +0 -56
- package/dist/errors-BYAXmyRJ.mjs.map +0 -1
- package/dist/global-flags-DGmw6Kqg.d.mts.map +0 -1
- package/dist/init-CxS9eqbQ.mjs.map +0 -1
- package/dist/is-ci-YyvQBBke.mjs +0 -44
- package/dist/is-ci-YyvQBBke.mjs.map +0 -1
- package/dist/migration-plan-BSzcWsvm.mjs.map +0 -1
- package/dist/result-handler-CG3vVoKf.mjs +0 -25
- package/dist/result-handler-CG3vVoKf.mjs.map +0 -1
- package/dist/terminal-ui-XtOQsqe9.mjs.map +0 -1
- /package/dist/{cli-errors-DdcjVLJV.d.mts → cli-errors-Czmx92Zy.d.mts} +0 -0
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { t as CliStructuredError } from "./cli-errors-
|
|
2
|
-
import {
|
|
3
|
-
import { n as
|
|
4
|
-
import { t as
|
|
5
|
-
import { t as version } from "./cli.mjs";
|
|
6
|
-
import { i as renderInitOutro, n as buildNextSteps, r as formatInitJson, t as InitOutputSchema } from "./output-B60Gw5fu.mjs";
|
|
1
|
+
import { t as CliStructuredError } from "./cli-errors-Djtz98Vm.mjs";
|
|
2
|
+
import { a as isCI, i as formatErrorOutput, r as formatErrorJson, t as createTerminalUI } from "./terminal-ui-BiB_8KNo.mjs";
|
|
3
|
+
import { a as starterSchema, c as version, i as schemaSample, n as dbFile, o as targetLabel, r as defaultSchemaPath, s as targetPackageName, t as configFile } from "./cli.mjs";
|
|
4
|
+
import { i as renderInitOutro, n as buildNextSteps, r as formatInitJson, t as InitOutputSchema } from "./output-BlsrGMEF.mjs";
|
|
7
5
|
import { createRequire } from "node:module";
|
|
8
6
|
import { basename, dirname, extname, isAbsolute, join, normalize } from "pathe";
|
|
9
7
|
import * as clack from "@clack/prompts";
|
|
@@ -56,6 +54,15 @@ function formatRunCommand(pm, bin, args) {
|
|
|
56
54
|
if (pm === "deno") return `deno run npm:${bin} ${args}`;
|
|
57
55
|
return `${pm} ${bin} ${args}`;
|
|
58
56
|
}
|
|
57
|
+
function formatRunScriptCommand(pm, scriptName) {
|
|
58
|
+
switch (pm) {
|
|
59
|
+
case "deno": return `deno task ${scriptName}`;
|
|
60
|
+
case "bun": return `bun run ${scriptName}`;
|
|
61
|
+
case "pnpm": return `pnpm run ${scriptName}`;
|
|
62
|
+
case "yarn": return `yarn run ${scriptName}`;
|
|
63
|
+
default: return `npm run ${scriptName}`;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
59
66
|
function formatAddArgs(pm, packages) {
|
|
60
67
|
if (pm === "deno") return ["add", ...packages.map((p) => `npm:${p}`)];
|
|
61
68
|
return ["add", ...packages];
|
|
@@ -225,6 +232,26 @@ function errorInitInvalidFlagValue(options) {
|
|
|
225
232
|
});
|
|
226
233
|
}
|
|
227
234
|
/**
|
|
235
|
+
* `--authoring` and `--schema-path` disagree on file extension (e.g. PSL
|
|
236
|
+
* authoring with a `.ts` path). Surfaces before any scaffold files are
|
|
237
|
+
* written so the project tree stays untouched.
|
|
238
|
+
*/
|
|
239
|
+
function errorInitAuthoringSchemaPathMismatch(options) {
|
|
240
|
+
const expectedAuthoring = options.expectedExtension === ".ts" ? "typescript" : "psl";
|
|
241
|
+
return new CliStructuredError("5014", "Authoring and schema path do not match", {
|
|
242
|
+
domain: "CLI",
|
|
243
|
+
why: `\`--authoring ${options.authoring}\` requires a schema file ending in ${options.expectedExtension}, but \`--schema-path ${options.schemaPath}\` ends in ${options.actualExtension}.`,
|
|
244
|
+
fix: `Use a matching pair, for example \`--authoring ${expectedAuthoring} --schema-path <path>${options.expectedExtension}\`, or change \`--authoring\` to match the path you supplied. You can also omit \`--schema-path\` to use the default for the chosen authoring.`,
|
|
245
|
+
docsUrl: "https://prisma-next.dev/docs/cli/init",
|
|
246
|
+
meta: {
|
|
247
|
+
authoring: options.authoring,
|
|
248
|
+
schemaPath: options.schemaPath,
|
|
249
|
+
actualExtension: options.actualExtension,
|
|
250
|
+
expectedExtension: options.expectedExtension
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
228
255
|
* The user cancelled an interactive prompt (Ctrl-C, escape, declined a
|
|
229
256
|
* selection). Distinct from `errorInitReinitNeedsForce` because that path
|
|
230
257
|
* applies to non-interactive mode where the user was never given the
|
|
@@ -415,7 +442,7 @@ function errorInitSkillInstallFailed(options) {
|
|
|
415
442
|
* `db/contract.json linguist-generated` — not the workspace-glob form
|
|
416
443
|
* `<glob>/contract.json` (which would over-match any unrelated
|
|
417
444
|
* `contract.json` the user has elsewhere) and not the absolute
|
|
418
|
-
* `
|
|
445
|
+
* `DEFAULT_CONTRACT_SOURCE_DIR/contract.json` (which would silently break for a non-default
|
|
419
446
|
* schema path).
|
|
420
447
|
*/
|
|
421
448
|
const ARTEFACT_FILENAMES$1 = [
|
|
@@ -448,7 +475,7 @@ function requiredGitattributesLines(schemaDir, _target) {
|
|
|
448
475
|
*
|
|
449
476
|
* Equivalence is exact-line: a user-customised line like
|
|
450
477
|
* `prisma/*.json linguist-generated` is *not* recognised as covering
|
|
451
|
-
* `
|
|
478
|
+
* `DEFAULT_CONTRACT_SOURCE_DIR/contract.json linguist-generated`. We accept that
|
|
452
479
|
* over-specification — preserving the user's broad pattern *and*
|
|
453
480
|
* appending the narrow one — because the narrow lines are what the
|
|
454
481
|
* acceptance criteria pin (FR3.4 AC).
|
|
@@ -608,261 +635,6 @@ function ensureEsmModuleType(existing) {
|
|
|
608
635
|
};
|
|
609
636
|
}
|
|
610
637
|
//#endregion
|
|
611
|
-
//#region src/commands/init/templates/code-templates.ts
|
|
612
|
-
function targetPackageName(target) {
|
|
613
|
-
return target === "postgres" ? "@prisma-next/postgres" : "@prisma-next/mongo";
|
|
614
|
-
}
|
|
615
|
-
function targetLabel(target) {
|
|
616
|
-
return target === "postgres" ? "PostgreSQL" : "MongoDB";
|
|
617
|
-
}
|
|
618
|
-
function defaultSchemaPath(authoring) {
|
|
619
|
-
if (authoring === "typescript") return "prisma/contract.ts";
|
|
620
|
-
return "prisma/contract.prisma";
|
|
621
|
-
}
|
|
622
|
-
function starterSchema(target, authoring) {
|
|
623
|
-
if (authoring === "typescript") return target === "mongo" ? starterSchemaTsMongo() : starterSchemaTsPostgres();
|
|
624
|
-
return target === "mongo" ? starterSchemaPslMongo() : starterSchemaPslPostgres();
|
|
625
|
-
}
|
|
626
|
-
/**
|
|
627
|
-
* Renders a short authoring-appropriate schema sample (FR5.1) for embedding
|
|
628
|
-
* in `prisma-next.md`. Returns a complete fenced markdown code block.
|
|
629
|
-
*
|
|
630
|
-
* The sample intentionally shows just one model: it's illustrative, not
|
|
631
|
-
* a substitute for the full scaffolded contract file. The TS samples use
|
|
632
|
-
* the same outer shape as `starterSchemaTs*` (FR5.3) so a user reading
|
|
633
|
-
* the doc and the file side-by-side sees the same structure.
|
|
634
|
-
*/
|
|
635
|
-
function schemaSample(target, authoring) {
|
|
636
|
-
if (authoring === "typescript") return target === "mongo" ? schemaSampleTsMongo() : schemaSampleTsPostgres();
|
|
637
|
-
return target === "mongo" ? schemaSamplePslMongo() : schemaSamplePslPostgres();
|
|
638
|
-
}
|
|
639
|
-
function schemaSamplePslPostgres() {
|
|
640
|
-
return `\`\`\`prisma
|
|
641
|
-
model User {
|
|
642
|
-
id Int @id @default(autoincrement())
|
|
643
|
-
email String @unique
|
|
644
|
-
username String?
|
|
645
|
-
name String?
|
|
646
|
-
}
|
|
647
|
-
\`\`\``;
|
|
648
|
-
}
|
|
649
|
-
function schemaSamplePslMongo() {
|
|
650
|
-
return `\`\`\`prisma
|
|
651
|
-
model User {
|
|
652
|
-
id ObjectId @id @map("_id")
|
|
653
|
-
email String @unique
|
|
654
|
-
username String?
|
|
655
|
-
name String?
|
|
656
|
-
@@map("users")
|
|
657
|
-
}
|
|
658
|
-
\`\`\``;
|
|
659
|
-
}
|
|
660
|
-
function schemaSampleTsPostgres() {
|
|
661
|
-
return `\`\`\`typescript
|
|
662
|
-
import { defineContract } from '@prisma-next/postgres/contract-builder';
|
|
663
|
-
import sqlFamily from '@prisma-next/postgres/family';
|
|
664
|
-
import postgresTarget from '@prisma-next/postgres/target';
|
|
665
|
-
|
|
666
|
-
export const contract = defineContract(
|
|
667
|
-
{ family: sqlFamily, target: postgresTarget },
|
|
668
|
-
({ field, model }) => ({
|
|
669
|
-
models: {
|
|
670
|
-
User: model('User', {
|
|
671
|
-
fields: {
|
|
672
|
-
id: field.id.uuidv7(),
|
|
673
|
-
email: field.text().unique(),
|
|
674
|
-
username: field.text().optional(),
|
|
675
|
-
name: field.text().optional(),
|
|
676
|
-
},
|
|
677
|
-
}),
|
|
678
|
-
},
|
|
679
|
-
}),
|
|
680
|
-
);
|
|
681
|
-
\`\`\``;
|
|
682
|
-
}
|
|
683
|
-
function schemaSampleTsMongo() {
|
|
684
|
-
return `\`\`\`typescript
|
|
685
|
-
import { defineContract } from '@prisma-next/mongo/contract-builder';
|
|
686
|
-
import mongoFamily from '@prisma-next/mongo/family';
|
|
687
|
-
import mongoTarget from '@prisma-next/mongo/target';
|
|
688
|
-
|
|
689
|
-
export const contract = defineContract(
|
|
690
|
-
{ family: mongoFamily, target: mongoTarget },
|
|
691
|
-
({ field, model }) => ({
|
|
692
|
-
models: {
|
|
693
|
-
User: model('User', {
|
|
694
|
-
collection: 'users',
|
|
695
|
-
fields: {
|
|
696
|
-
_id: field.objectId(),
|
|
697
|
-
email: field.string(),
|
|
698
|
-
username: field.string().optional(),
|
|
699
|
-
name: field.string().optional(),
|
|
700
|
-
},
|
|
701
|
-
}),
|
|
702
|
-
},
|
|
703
|
-
}),
|
|
704
|
-
);
|
|
705
|
-
\`\`\``;
|
|
706
|
-
}
|
|
707
|
-
function starterSchemaPslPostgres() {
|
|
708
|
-
return `// use prisma-next
|
|
709
|
-
|
|
710
|
-
model User {
|
|
711
|
-
id Int @id @default(autoincrement())
|
|
712
|
-
email String @unique
|
|
713
|
-
username String?
|
|
714
|
-
name String?
|
|
715
|
-
posts Post[]
|
|
716
|
-
createdAt DateTime @default(now())
|
|
717
|
-
updatedAt temporal.updatedAt()
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
model Post {
|
|
721
|
-
id Int @id @default(autoincrement())
|
|
722
|
-
title String
|
|
723
|
-
content String?
|
|
724
|
-
author User @relation(fields: [authorId], references: [id])
|
|
725
|
-
authorId Int
|
|
726
|
-
createdAt DateTime @default(now())
|
|
727
|
-
updatedAt temporal.updatedAt()
|
|
728
|
-
}
|
|
729
|
-
`;
|
|
730
|
-
}
|
|
731
|
-
function starterSchemaPslMongo() {
|
|
732
|
-
return `// use prisma-next
|
|
733
|
-
|
|
734
|
-
model User {
|
|
735
|
-
id ObjectId @id @map("_id")
|
|
736
|
-
email String @unique
|
|
737
|
-
username String?
|
|
738
|
-
name String?
|
|
739
|
-
posts Post[]
|
|
740
|
-
@@map("users")
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
model Post {
|
|
744
|
-
id ObjectId @id @map("_id")
|
|
745
|
-
title String
|
|
746
|
-
content String?
|
|
747
|
-
author User @relation(fields: [authorId], references: [id])
|
|
748
|
-
authorId ObjectId
|
|
749
|
-
@@map("posts")
|
|
750
|
-
}
|
|
751
|
-
`;
|
|
752
|
-
}
|
|
753
|
-
function starterSchemaTsPostgres() {
|
|
754
|
-
return `import { defineContract } from '@prisma-next/postgres/contract-builder';
|
|
755
|
-
import sqlFamily from '@prisma-next/postgres/family';
|
|
756
|
-
import postgresTarget from '@prisma-next/postgres/target';
|
|
757
|
-
|
|
758
|
-
export const contract = defineContract(
|
|
759
|
-
{ family: sqlFamily, target: postgresTarget },
|
|
760
|
-
({ field, model, rel }) => ({
|
|
761
|
-
models: {
|
|
762
|
-
User: model('User', {
|
|
763
|
-
fields: {
|
|
764
|
-
id: field.id.uuidv7(),
|
|
765
|
-
email: field.text().unique(),
|
|
766
|
-
username: field.text().optional(),
|
|
767
|
-
name: field.text().optional(),
|
|
768
|
-
createdAt: field.temporal.createdAt(),
|
|
769
|
-
updatedAt: field.temporal.updatedAt(),
|
|
770
|
-
},
|
|
771
|
-
relations: {
|
|
772
|
-
posts: rel.hasMany('Post', { by: 'authorId' }),
|
|
773
|
-
},
|
|
774
|
-
}),
|
|
775
|
-
|
|
776
|
-
Post: model('Post', {
|
|
777
|
-
fields: {
|
|
778
|
-
id: field.id.uuidv7(),
|
|
779
|
-
title: field.text(),
|
|
780
|
-
content: field.text().optional(),
|
|
781
|
-
authorId: field.uuid(),
|
|
782
|
-
createdAt: field.temporal.createdAt(),
|
|
783
|
-
updatedAt: field.temporal.updatedAt(),
|
|
784
|
-
},
|
|
785
|
-
relations: {
|
|
786
|
-
author: rel.belongsTo('User', { from: 'authorId', to: 'id' }),
|
|
787
|
-
},
|
|
788
|
-
}),
|
|
789
|
-
},
|
|
790
|
-
}),
|
|
791
|
-
);
|
|
792
|
-
`;
|
|
793
|
-
}
|
|
794
|
-
function starterSchemaTsMongo() {
|
|
795
|
-
return `import { defineContract } from '@prisma-next/mongo/contract-builder';
|
|
796
|
-
import mongoFamily from '@prisma-next/mongo/family';
|
|
797
|
-
import mongoTarget from '@prisma-next/mongo/target';
|
|
798
|
-
|
|
799
|
-
export const contract = defineContract(
|
|
800
|
-
{ family: mongoFamily, target: mongoTarget },
|
|
801
|
-
({ field, model, rel }) => ({
|
|
802
|
-
models: {
|
|
803
|
-
User: model('User', {
|
|
804
|
-
collection: 'users',
|
|
805
|
-
fields: {
|
|
806
|
-
_id: field.objectId(),
|
|
807
|
-
email: field.string(),
|
|
808
|
-
username: field.string().optional(),
|
|
809
|
-
name: field.string().optional(),
|
|
810
|
-
},
|
|
811
|
-
relations: {
|
|
812
|
-
posts: rel.hasMany('Post', { from: '_id', to: 'authorId' }),
|
|
813
|
-
},
|
|
814
|
-
}),
|
|
815
|
-
|
|
816
|
-
Post: model('Post', {
|
|
817
|
-
collection: 'posts',
|
|
818
|
-
fields: {
|
|
819
|
-
_id: field.objectId(),
|
|
820
|
-
title: field.string(),
|
|
821
|
-
content: field.string().optional(),
|
|
822
|
-
authorId: field.objectId(),
|
|
823
|
-
},
|
|
824
|
-
relations: {
|
|
825
|
-
author: rel.belongsTo('User', { from: 'authorId', to: '_id' }),
|
|
826
|
-
},
|
|
827
|
-
}),
|
|
828
|
-
},
|
|
829
|
-
}),
|
|
830
|
-
);
|
|
831
|
-
`;
|
|
832
|
-
}
|
|
833
|
-
function configFile(target, contractPath) {
|
|
834
|
-
return `import 'dotenv/config';
|
|
835
|
-
import { defineConfig } from '${targetPackageName(target)}/config';
|
|
836
|
-
|
|
837
|
-
export default defineConfig({
|
|
838
|
-
contract: ${JSON.stringify(contractPath)},
|
|
839
|
-
db: {
|
|
840
|
-
connection: process.env['DATABASE_URL']!,
|
|
841
|
-
},
|
|
842
|
-
});
|
|
843
|
-
`;
|
|
844
|
-
}
|
|
845
|
-
function dbFile(target) {
|
|
846
|
-
if (target === "postgres") return `import postgres from '@prisma-next/postgres/runtime';
|
|
847
|
-
import type { Contract } from './contract.d';
|
|
848
|
-
import contractJson from './contract.json' with { type: 'json' };
|
|
849
|
-
|
|
850
|
-
export const db = postgres<Contract>({
|
|
851
|
-
contractJson,
|
|
852
|
-
url: process.env['DATABASE_URL']!,
|
|
853
|
-
});
|
|
854
|
-
`;
|
|
855
|
-
return `import mongo from '@prisma-next/mongo/runtime';
|
|
856
|
-
import type { Contract } from './contract.d';
|
|
857
|
-
import contractJson from './contract.json' with { type: 'json' };
|
|
858
|
-
|
|
859
|
-
export const db = mongo<Contract>({
|
|
860
|
-
contractJson,
|
|
861
|
-
url: process.env['DATABASE_URL']!,
|
|
862
|
-
});
|
|
863
|
-
`;
|
|
864
|
-
}
|
|
865
|
-
//#endregion
|
|
866
638
|
//#region src/commands/init/inputs.ts
|
|
867
639
|
const TARGET_ALIASES = new Map([
|
|
868
640
|
["postgres", "postgres"],
|
|
@@ -1096,10 +868,11 @@ function validateSchemaPath(value, authoring) {
|
|
|
1096
868
|
});
|
|
1097
869
|
const ext = extname(trimmed).toLowerCase();
|
|
1098
870
|
const expected = authoring === "typescript" ? ".ts" : ".prisma";
|
|
1099
|
-
if (ext !== expected) throw
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
871
|
+
if (ext !== expected) throw errorInitAuthoringSchemaPathMismatch({
|
|
872
|
+
authoring,
|
|
873
|
+
schemaPath: trimmed,
|
|
874
|
+
actualExtension: ext.length > 0 ? ext : "(none)",
|
|
875
|
+
expectedExtension: expected
|
|
1103
876
|
});
|
|
1104
877
|
return normalize(trimmed);
|
|
1105
878
|
}
|
|
@@ -1437,6 +1210,17 @@ function isLocalPath(base) {
|
|
|
1437
1210
|
return base.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(base);
|
|
1438
1211
|
}
|
|
1439
1212
|
/**
|
|
1213
|
+
* Agents passed to every project-level init install. Upstream `skills add`
|
|
1214
|
+
* is the source of truth for per-agent install behaviour; the CLI lists
|
|
1215
|
+
* every supported runtime on one invocation and delegates the rest.
|
|
1216
|
+
*/
|
|
1217
|
+
const DEFAULT_SKILL_AGENTS = [
|
|
1218
|
+
"cursor",
|
|
1219
|
+
"claude-code",
|
|
1220
|
+
"codex",
|
|
1221
|
+
"windsurf"
|
|
1222
|
+
];
|
|
1223
|
+
/**
|
|
1440
1224
|
* Build the `<base>/<subpath>[#ref]` URL the `skills` CLI will
|
|
1441
1225
|
* resolve. Exported for unit tests so the per-source format can be
|
|
1442
1226
|
* asserted without going through the full install loop.
|
|
@@ -1456,39 +1240,34 @@ function formatSkillSourceUrl(source) {
|
|
|
1456
1240
|
* rest of the install step so a single project consistently uses one
|
|
1457
1241
|
* runner.
|
|
1458
1242
|
*
|
|
1459
|
-
* `--
|
|
1460
|
-
*
|
|
1461
|
-
* shows by default. A non-interactive scaffold step cannot present
|
|
1462
|
-
* prompts.
|
|
1243
|
+
* `--agent` takes space-separated slugs on one flag; `--skill '*'` and `-y`
|
|
1244
|
+
* skip the multi-select prompts a non-interactive scaffold step cannot show.
|
|
1463
1245
|
*
|
|
1464
1246
|
* Exported for unit tests so the per-PM dispatch can be asserted
|
|
1465
1247
|
* without a live subprocess.
|
|
1466
1248
|
*/
|
|
1467
|
-
function formatSkillInstallCommand(
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
"add",
|
|
1471
|
-
formatSkillSourceUrl(source),
|
|
1472
|
-
"--all"
|
|
1473
|
-
]);
|
|
1474
|
-
}
|
|
1475
|
-
/**
|
|
1476
|
-
* `skills add --all` should cover Claude Code, but upstream currently skips
|
|
1477
|
-
* project-local Claude symlinks when `.claude/` does not already exist. Run
|
|
1478
|
-
* the explicit Claude Code install as well so fresh projects get
|
|
1479
|
-
* `.claude/skills` without asking users to create that folder first.
|
|
1480
|
-
*/
|
|
1481
|
-
function formatClaudeSkillInstallCommand(pm, source) {
|
|
1482
|
-
return formatPackageManagerCommand(pm, [
|
|
1249
|
+
function formatSkillInstallCommand(args) {
|
|
1250
|
+
const agents = args.agents ?? DEFAULT_SKILL_AGENTS;
|
|
1251
|
+
const cliArgs = [
|
|
1483
1252
|
"skills@latest",
|
|
1484
1253
|
"add",
|
|
1485
|
-
formatSkillSourceUrl(source),
|
|
1254
|
+
formatSkillSourceUrl(args.source),
|
|
1486
1255
|
"--agent",
|
|
1487
|
-
|
|
1256
|
+
...agents,
|
|
1488
1257
|
"--skill",
|
|
1489
1258
|
"'*'",
|
|
1490
1259
|
"-y"
|
|
1491
|
-
]
|
|
1260
|
+
];
|
|
1261
|
+
return formatPackageManagerCommand(args.pm, cliArgs);
|
|
1262
|
+
}
|
|
1263
|
+
/**
|
|
1264
|
+
* Ordered skill-install commands for one init run. Exported for unit tests.
|
|
1265
|
+
*/
|
|
1266
|
+
function resolveProjectSkillInstallCommands(pm) {
|
|
1267
|
+
return DEFAULT_SKILL_SOURCES.map((source) => formatSkillInstallCommand({
|
|
1268
|
+
pm,
|
|
1269
|
+
source
|
|
1270
|
+
}));
|
|
1492
1271
|
}
|
|
1493
1272
|
function formatPackageManagerCommand(pm, args) {
|
|
1494
1273
|
switch (pm) {
|
|
@@ -1526,7 +1305,7 @@ function commandToExec(command) {
|
|
|
1526
1305
|
*/
|
|
1527
1306
|
async function runProjectLevelSkillInstall(ctx) {
|
|
1528
1307
|
const commands = [];
|
|
1529
|
-
const installCommands =
|
|
1308
|
+
const installCommands = resolveProjectSkillInstallCommands(ctx.pm);
|
|
1530
1309
|
for (const command of installCommands) {
|
|
1531
1310
|
const { file, args } = commandToExec(command);
|
|
1532
1311
|
try {
|
|
@@ -1607,7 +1386,12 @@ function envPlaceholderBody(target) {
|
|
|
1607
1386
|
lines.push(`# Requires ${label} >= ${minVersion}.`);
|
|
1608
1387
|
lines.push("");
|
|
1609
1388
|
if (target === "postgres") lines.push("DATABASE_URL=\"postgresql://user:password@localhost:5432/mydb\"");
|
|
1610
|
-
else
|
|
1389
|
+
else {
|
|
1390
|
+
lines.push("# Standalone local mongod / `docker run mongo:7` — no replica set required for first-run queries.");
|
|
1391
|
+
lines.push("# Transactions and change streams need a replica set; add ?replicaSet=... only after initiating one.");
|
|
1392
|
+
lines.push("");
|
|
1393
|
+
lines.push("DATABASE_URL=\"mongodb://user:password@localhost:27017/mydb\"");
|
|
1394
|
+
}
|
|
1611
1395
|
lines.push("");
|
|
1612
1396
|
return lines.join("\n");
|
|
1613
1397
|
}
|
|
@@ -1693,6 +1477,54 @@ function requirementsBlock(target) {
|
|
|
1693
1477
|
].join("\n");
|
|
1694
1478
|
}
|
|
1695
1479
|
//#endregion
|
|
1480
|
+
//#region src/commands/init/templates/readme.ts
|
|
1481
|
+
const sharedVariables = [
|
|
1482
|
+
"projectName",
|
|
1483
|
+
"contractPath",
|
|
1484
|
+
"runDev",
|
|
1485
|
+
"runContractEmit"
|
|
1486
|
+
];
|
|
1487
|
+
const postgresVariables = [
|
|
1488
|
+
...sharedVariables,
|
|
1489
|
+
"runDbInit",
|
|
1490
|
+
"runDbUpdate",
|
|
1491
|
+
"runMigrationPlan",
|
|
1492
|
+
"runMigrate",
|
|
1493
|
+
"runDbSeed"
|
|
1494
|
+
];
|
|
1495
|
+
const mongoVariables = [
|
|
1496
|
+
...sharedVariables,
|
|
1497
|
+
"runDbUp",
|
|
1498
|
+
"runDbDown",
|
|
1499
|
+
"runDbReset",
|
|
1500
|
+
"runMigrationPlan",
|
|
1501
|
+
"runMigrate",
|
|
1502
|
+
"runDbSeed"
|
|
1503
|
+
];
|
|
1504
|
+
function minimalProjectReadmeMd(target, schemaPath, projectName, pm) {
|
|
1505
|
+
const run = (script) => formatRunScriptCommand(pm, script);
|
|
1506
|
+
const shared = {
|
|
1507
|
+
projectName,
|
|
1508
|
+
contractPath: schemaPath,
|
|
1509
|
+
runDev: run("dev"),
|
|
1510
|
+
runContractEmit: run("contract:emit"),
|
|
1511
|
+
runMigrationPlan: run("migration:plan"),
|
|
1512
|
+
runMigrate: run("migrate"),
|
|
1513
|
+
runDbSeed: run("db:seed")
|
|
1514
|
+
};
|
|
1515
|
+
if (target === "mongo") return renderTemplate("readme-mongo.md", mongoVariables, {
|
|
1516
|
+
...shared,
|
|
1517
|
+
runDbUp: run("db:up"),
|
|
1518
|
+
runDbDown: run("db:down"),
|
|
1519
|
+
runDbReset: run("db:reset")
|
|
1520
|
+
});
|
|
1521
|
+
return renderTemplate("readme-postgres.md", postgresVariables, {
|
|
1522
|
+
...shared,
|
|
1523
|
+
runDbInit: run("db:init"),
|
|
1524
|
+
runDbUpdate: run("db:update")
|
|
1525
|
+
});
|
|
1526
|
+
}
|
|
1527
|
+
//#endregion
|
|
1696
1528
|
//#region src/commands/init/templates/tsconfig.ts
|
|
1697
1529
|
/**
|
|
1698
1530
|
* Compiler options the scaffolded `prisma-next.config.ts` and `db.ts` need
|
|
@@ -1850,10 +1682,7 @@ function mergeTypesArray(existing) {
|
|
|
1850
1682
|
*/
|
|
1851
1683
|
async function runInit(baseDir, runOptions) {
|
|
1852
1684
|
const { options, flags, canPrompt, probeOverrides, afterFirstTelemetryConsent } = runOptions;
|
|
1853
|
-
const ui =
|
|
1854
|
-
color: flags.color,
|
|
1855
|
-
interactive: flags.interactive
|
|
1856
|
-
});
|
|
1685
|
+
const ui = createTerminalUI(flags);
|
|
1857
1686
|
const warnings = [];
|
|
1858
1687
|
const filesWritten = [];
|
|
1859
1688
|
const filesDeleted = [];
|
|
@@ -1982,6 +1811,13 @@ async function runInit(baseDir, runOptions) {
|
|
|
1982
1811
|
if (typeWarning !== null) warnings.push(typeWarning);
|
|
1983
1812
|
if (synthesisePackageJson) warnings.push("No package.json found in the target directory; created a minimal one. Edit `name` / `version` to taste.");
|
|
1984
1813
|
}
|
|
1814
|
+
if (existsSync(join(baseDir, "src/index.ts"))) if (!existsSync(join(baseDir, "README.md"))) {
|
|
1815
|
+
const rawName = parsedPackageJson !== null && typeof parsedPackageJson["name"] === "string" ? parsedPackageJson["name"] : basename(baseDir);
|
|
1816
|
+
filesToWrite.push({
|
|
1817
|
+
path: "README.md",
|
|
1818
|
+
content: minimalProjectReadmeMd(inputs.target, inputs.schemaPath, sanitisePackageName(rawName), pm)
|
|
1819
|
+
});
|
|
1820
|
+
} else warnings.push("README.md already exists; leaving it untouched.");
|
|
1985
1821
|
for (const file of filesToWrite) {
|
|
1986
1822
|
const fullPath = join(baseDir, file.path);
|
|
1987
1823
|
mkdirSync(dirname(fullPath), { recursive: true });
|
|
@@ -2045,10 +1881,12 @@ async function runInit(baseDir, runOptions) {
|
|
|
2045
1881
|
filesWritten
|
|
2046
1882
|
}));
|
|
2047
1883
|
}
|
|
2048
|
-
const manualProjectSkillSummary = DEFAULT_SKILL_SOURCES.
|
|
1884
|
+
const manualProjectSkillSummary = DEFAULT_SKILL_SOURCES.map((source) => formatSkillInstallCommand({
|
|
1885
|
+
pm: install.effectivePm,
|
|
1886
|
+
source
|
|
1887
|
+
})).map((c) => `\`${c}\``).join(" && ");
|
|
2049
1888
|
let skillRegistered = false;
|
|
2050
1889
|
if (!inputs.installProjectSkill) warnings.push(`Skipped Prisma Next skills install (--no-skill). To install the skills later, run: ${manualProjectSkillSummary}`);
|
|
2051
|
-
else if (install.skipped) warnings.push(`Skipped Prisma Next skills install because --no-install was passed. After you run install manually, install the skills with: ${manualProjectSkillSummary}`);
|
|
2052
1890
|
else {
|
|
2053
1891
|
const spinner = ui.spinner();
|
|
2054
1892
|
spinner.start("Registering Prisma Next skills with the agent runtime...");
|
|
@@ -2139,7 +1977,8 @@ function exitCodeForError(error) {
|
|
|
2139
1977
|
case "5005":
|
|
2140
1978
|
case "5010":
|
|
2141
1979
|
case "5011":
|
|
2142
|
-
case "5012":
|
|
1980
|
+
case "5012":
|
|
1981
|
+
case "5014": return 2;
|
|
2143
1982
|
case "5006": return 3;
|
|
2144
1983
|
case "5007": return 4;
|
|
2145
1984
|
case "5008": return 5;
|
|
@@ -2361,7 +2200,7 @@ async function runEmit(ctx) {
|
|
|
2361
2200
|
const spinner = ctx.ui.spinner();
|
|
2362
2201
|
spinner.start("Emitting contract...");
|
|
2363
2202
|
try {
|
|
2364
|
-
const { executeContractEmit } = await import("./contract-emit-
|
|
2203
|
+
const { executeContractEmit } = await import("./contract-emit-bcrpT-wD.mjs").then((n) => n.t);
|
|
2365
2204
|
await executeContractEmit({ configPath: join(ctx.baseDir, "prisma-next.config.ts") });
|
|
2366
2205
|
spinner.stop("Contract emitted");
|
|
2367
2206
|
} catch (err) {
|
|
@@ -2414,4 +2253,4 @@ function sanitisePackageName(raw) {
|
|
|
2414
2253
|
//#endregion
|
|
2415
2254
|
export { runInit };
|
|
2416
2255
|
|
|
2417
|
-
//# sourceMappingURL=init-
|
|
2256
|
+
//# sourceMappingURL=init-YX6lCJpG.mjs.map
|