create-prisma 0.4.2-pr.34.116.1 → 0.4.2-pr.34.118.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 +16 -0
- package/dist/cli.mjs +1 -1
- package/dist/{create-DRZe4NlG.mjs → create-BJ8wReFa.mjs} +36 -48
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ Scaffold a new app with Prisma already wired up.
|
|
|
13
13
|
- adds `db:generate`, `db:migrate`, and `db:seed` scripts
|
|
14
14
|
- creates or updates `.env` with `DATABASE_URL`
|
|
15
15
|
- can install dependencies and run `prisma generate` for you
|
|
16
|
+
- can deploy the finished app to Prisma Compute and return a live URL
|
|
16
17
|
|
|
17
18
|
## Quick Start
|
|
18
19
|
|
|
@@ -116,6 +117,7 @@ create-prisma --name my-app --template nest --provider postgresql --prisma-postg
|
|
|
116
117
|
- `--no-generate` skip `prisma generate`
|
|
117
118
|
- `--prisma-postgres` provision Prisma Postgres for PostgreSQL
|
|
118
119
|
- `--skills --mcp --extension` enable optional add-ons
|
|
120
|
+
- `--deploy` / `--no-deploy` deploy the finished app to Prisma Compute (or skip the prompt)
|
|
119
121
|
- `--force` allow scaffolding into a non-empty directory
|
|
120
122
|
- `--verbose` print full command output
|
|
121
123
|
|
|
@@ -129,6 +131,20 @@ create-prisma --name my-app --template nest --provider postgresql --prisma-postg
|
|
|
129
131
|
|
|
130
132
|
These can be selected interactively or enabled with flags.
|
|
131
133
|
|
|
134
|
+
## Deploy to Prisma Compute
|
|
135
|
+
|
|
136
|
+
After scaffolding, `create-prisma` can deploy your app to [Prisma Compute](https://www.prisma.io/docs/compute), the serverless hosting for TypeScript apps that runs next to your Prisma Postgres database. It is offered for the templates the Prisma CLI can deploy today: `hono`, `elysia`, `next`, and `tanstack-start`.
|
|
137
|
+
|
|
138
|
+
Accept the prompt ("Deploy to Prisma Compute now?") when it appears, or pass the flag:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
create-prisma --name my-api --template hono --provider postgresql --deploy
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The deploy step signs you in with `prisma-cli auth login` if you are not signed in yet, creates or links a Prisma project, then runs `prisma-cli app deploy` to build your app and print its URL. When you scaffold a PostgreSQL app and have not supplied your own `DATABASE_URL`, the deploy provisions a Prisma Postgres database and wires it to the app. A `compute:deploy` script is added so you can redeploy from the project later.
|
|
145
|
+
|
|
146
|
+
The browser sign-in needs a person at the keyboard, so the deploy step is skipped in non-interactive runs unless a session already exists.
|
|
147
|
+
|
|
132
148
|
## Local Development
|
|
133
149
|
|
|
134
150
|
```bash
|
package/dist/cli.mjs
CHANGED
|
@@ -819,7 +819,7 @@ function getCommandErrorMessage(error) {
|
|
|
819
819
|
}
|
|
820
820
|
return error instanceof Error ? error.message : String(error);
|
|
821
821
|
}
|
|
822
|
-
async function
|
|
822
|
+
async function collectPrismaSetupInitialContext(input, options = {}) {
|
|
823
823
|
const projectDir = path.resolve(options.projectDir ?? process.cwd());
|
|
824
824
|
const useDefaults = input.yes === true;
|
|
825
825
|
const verbose = input.verbose === true;
|
|
@@ -828,20 +828,11 @@ async function collectPrismaSetupContext(input, options = {}) {
|
|
|
828
828
|
if (!databaseProvider) return;
|
|
829
829
|
const schemaPreset = input.schemaPreset ?? options.defaultSchemaPreset ?? DEFAULT_SCHEMA_PRESET$1;
|
|
830
830
|
const databaseUrl = input.databaseUrl;
|
|
831
|
-
let shouldUsePrismaPostgres = false;
|
|
832
|
-
const shouldUseComputePostgres = databaseProvider === "postgresql" && !databaseUrl && options.skipPrismaPostgresProvisioning === true;
|
|
833
|
-
if (databaseProvider === "postgresql" && !databaseUrl && !shouldUseComputePostgres) {
|
|
834
|
-
const prismaPostgresChoice = input.prismaPostgres ?? (useDefaults ? DEFAULT_PRISMA_POSTGRES : await promptForPrismaPostgres());
|
|
835
|
-
if (prismaPostgresChoice === void 0) return;
|
|
836
|
-
shouldUsePrismaPostgres = prismaPostgresChoice;
|
|
837
|
-
}
|
|
838
831
|
const detectedPackageManager = await detectPackageManager(projectDir);
|
|
839
832
|
const packageManager = input.packageManager ?? (useDefaults ? detectedPackageManager : await promptForPackageManager(detectedPackageManager));
|
|
840
833
|
if (!packageManager) return;
|
|
841
834
|
const shouldInstall = input.install ?? (useDefaults ? DEFAULT_INSTALL : await promptForDependencyInstall(packageManager));
|
|
842
835
|
if (shouldInstall === void 0) return;
|
|
843
|
-
const shouldMigrateAndSeed = !(shouldInstall && shouldGenerate && !(shouldUseComputePostgres && options.skipMigrateAndSeedPrompt)) ? false : input.migrateAndSeed ?? (useDefaults ? DEFAULT_MIGRATE_AND_SEED : await promptForMigrateAndSeed());
|
|
844
|
-
if (shouldMigrateAndSeed === void 0) return;
|
|
845
836
|
return {
|
|
846
837
|
projectDir,
|
|
847
838
|
verbose,
|
|
@@ -849,9 +840,24 @@ async function collectPrismaSetupContext(input, options = {}) {
|
|
|
849
840
|
databaseProvider,
|
|
850
841
|
schemaPreset,
|
|
851
842
|
databaseUrl,
|
|
852
|
-
shouldUsePrismaPostgres,
|
|
853
843
|
packageManager,
|
|
854
|
-
shouldInstall
|
|
844
|
+
shouldInstall
|
|
845
|
+
};
|
|
846
|
+
}
|
|
847
|
+
async function completePrismaSetupContext(input, context, options = {}) {
|
|
848
|
+
const useDefaults = input.yes === true;
|
|
849
|
+
let shouldUsePrismaPostgres = false;
|
|
850
|
+
const shouldUseComputePostgres = context.databaseProvider === "postgresql" && !context.databaseUrl && options.useComputePostgres === true;
|
|
851
|
+
if (context.databaseProvider === "postgresql" && !context.databaseUrl && !shouldUseComputePostgres) {
|
|
852
|
+
const prismaPostgresChoice = input.prismaPostgres ?? (useDefaults ? DEFAULT_PRISMA_POSTGRES : await promptForPrismaPostgres());
|
|
853
|
+
if (prismaPostgresChoice === void 0) return;
|
|
854
|
+
shouldUsePrismaPostgres = prismaPostgresChoice;
|
|
855
|
+
}
|
|
856
|
+
const shouldMigrateAndSeed = !(context.shouldInstall && context.shouldGenerate && !(shouldUseComputePostgres && options.skipMigrateAndSeedPrompt)) ? false : input.migrateAndSeed ?? (useDefaults ? DEFAULT_MIGRATE_AND_SEED : await promptForMigrateAndSeed());
|
|
857
|
+
if (shouldMigrateAndSeed === void 0) return;
|
|
858
|
+
return {
|
|
859
|
+
...context,
|
|
860
|
+
shouldUsePrismaPostgres,
|
|
855
861
|
shouldMigrateAndSeed
|
|
856
862
|
};
|
|
857
863
|
}
|
|
@@ -1772,26 +1778,11 @@ async function ensurePrismaCliAvailable(packageManager) {
|
|
|
1772
1778
|
return false;
|
|
1773
1779
|
}
|
|
1774
1780
|
}
|
|
1775
|
-
async function collectComputeDeployIntent(input, options) {
|
|
1776
|
-
if (!isComputeDeployableTemplate(options.template)) return null;
|
|
1777
|
-
if (input.deploy === false) return null;
|
|
1778
|
-
if (input.deploy === true) return true;
|
|
1779
|
-
if (options.useDefaults) return null;
|
|
1780
|
-
const confirmed = await confirm({
|
|
1781
|
-
message: "Deploy to Prisma Compute now?",
|
|
1782
|
-
initialValue: true
|
|
1783
|
-
});
|
|
1784
|
-
if (isCancel(confirmed)) {
|
|
1785
|
-
cancel("Operation cancelled.");
|
|
1786
|
-
return;
|
|
1787
|
-
}
|
|
1788
|
-
return confirmed;
|
|
1789
|
-
}
|
|
1790
1781
|
async function collectComputeDeployContext(input, options) {
|
|
1791
1782
|
if (!isComputeDeployableTemplate(options.template)) return null;
|
|
1792
|
-
if (
|
|
1783
|
+
if (input.deploy === false) return null;
|
|
1793
1784
|
let wantsDeploy;
|
|
1794
|
-
if (
|
|
1785
|
+
if (input.deploy === true) wantsDeploy = true;
|
|
1795
1786
|
else if (options.useDefaults) return null;
|
|
1796
1787
|
else {
|
|
1797
1788
|
const confirmed = await confirm({
|
|
@@ -1973,7 +1964,7 @@ async function getAnonymousId() {
|
|
|
1973
1964
|
}
|
|
1974
1965
|
function getCommonProperties() {
|
|
1975
1966
|
return {
|
|
1976
|
-
"cli-version": "0.4.2-pr.34.
|
|
1967
|
+
"cli-version": "0.4.2-pr.34.118.1",
|
|
1977
1968
|
"node-version": process.version,
|
|
1978
1969
|
platform: process.platform,
|
|
1979
1970
|
arch: process.arch
|
|
@@ -2249,16 +2240,23 @@ async function collectCreateContext(input) {
|
|
|
2249
2240
|
cancel(`Target directory ${formatPathForDisplay(targetDirectory)} is not empty. Use --force to continue.`);
|
|
2250
2241
|
return;
|
|
2251
2242
|
}
|
|
2252
|
-
const
|
|
2243
|
+
const prismaSetupInitialContext = await collectPrismaSetupInitialContext(input, {
|
|
2244
|
+
projectDir: targetDirectory,
|
|
2245
|
+
defaultSchemaPreset: DEFAULT_SCHEMA_PRESET
|
|
2246
|
+
});
|
|
2247
|
+
if (!prismaSetupInitialContext) return;
|
|
2248
|
+
const projectPackageName = toPackageName(path.basename(targetDirectory));
|
|
2249
|
+
const computeDeployContext = await collectComputeDeployContext(input, {
|
|
2253
2250
|
template,
|
|
2254
|
-
|
|
2251
|
+
packageManager: prismaSetupInitialContext.packageManager,
|
|
2252
|
+
useDefaults,
|
|
2253
|
+
defaultServiceName: projectPackageName
|
|
2255
2254
|
});
|
|
2256
|
-
if (
|
|
2257
|
-
const
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
skipMigrateAndSeedPrompt: computeDeployIntent === true && input.prismaPostgres !== false
|
|
2255
|
+
if (computeDeployContext === void 0) return;
|
|
2256
|
+
const useComputeDatabase = Boolean(computeDeployContext && prismaSetupInitialContext.databaseProvider === "postgresql" && !prismaSetupInitialContext.databaseUrl && input.prismaPostgres !== false);
|
|
2257
|
+
const prismaSetupContext = await completePrismaSetupContext(input, prismaSetupInitialContext, {
|
|
2258
|
+
useComputePostgres: useComputeDatabase,
|
|
2259
|
+
skipMigrateAndSeedPrompt: useComputeDatabase
|
|
2262
2260
|
});
|
|
2263
2261
|
if (!prismaSetupContext) return;
|
|
2264
2262
|
const addonSetupContext = await collectCreateAddonSetupContext(input, {
|
|
@@ -2267,16 +2265,6 @@ async function collectCreateContext(input) {
|
|
|
2267
2265
|
shouldUsePrismaPostgres: prismaSetupContext.shouldUsePrismaPostgres
|
|
2268
2266
|
});
|
|
2269
2267
|
if (addonSetupContext === void 0) return;
|
|
2270
|
-
const projectPackageName = toPackageName(path.basename(targetDirectory));
|
|
2271
|
-
const computeDeployContext = await collectComputeDeployContext(input, {
|
|
2272
|
-
template,
|
|
2273
|
-
packageManager: prismaSetupContext.packageManager,
|
|
2274
|
-
useDefaults,
|
|
2275
|
-
defaultServiceName: projectPackageName,
|
|
2276
|
-
wantsDeploy: computeDeployIntent
|
|
2277
|
-
});
|
|
2278
|
-
if (computeDeployContext === void 0) return;
|
|
2279
|
-
const useComputeDatabase = Boolean(computeDeployContext && prismaSetupContext.databaseProvider === "postgresql" && !prismaSetupContext.databaseUrl && input.prismaPostgres !== false);
|
|
2280
2268
|
return {
|
|
2281
2269
|
targetDirectory,
|
|
2282
2270
|
targetPathState,
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as DatabaseUrlSchema, i as DatabaseProviderSchema, n as CreateCommandInputSchema, o as PackageManagerSchema, r as CreateTemplateSchema, s as SchemaPresetSchema, t as runCreateCommand } from "./create-
|
|
2
|
+
import { a as DatabaseUrlSchema, i as DatabaseProviderSchema, n as CreateCommandInputSchema, o as PackageManagerSchema, r as CreateTemplateSchema, s as SchemaPresetSchema, t as runCreateCommand } from "./create-BJ8wReFa.mjs";
|
|
3
3
|
import { os } from "@orpc/server";
|
|
4
4
|
import { createCli } from "trpc-cli";
|
|
5
5
|
|
|
6
6
|
//#region src/index.ts
|
|
7
|
-
const CLI_VERSION = "0.4.2-pr.34.
|
|
7
|
+
const CLI_VERSION = "0.4.2-pr.34.118.1";
|
|
8
8
|
const router = os.router({ create: os.meta({
|
|
9
9
|
description: "Create a new project with Prisma setup",
|
|
10
10
|
default: true,
|
package/package.json
CHANGED