@prisma/cli 3.0.0-dev.127.1 → 3.0.0-dev.129.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/dist/commands/project/index.js +3 -2
- package/dist/controllers/app.js +11 -8
- package/dist/controllers/project.js +5 -2
- package/dist/lib/app/app-provider.js +3 -1
- package/dist/lib/project/resolution.js +2 -1
- package/dist/lib/project/setup.js +2 -1
- package/dist/presenters/app.js +5 -0
- package/dist/presenters/project.js +7 -2
- package/dist/use-cases/project.js +2 -1
- package/package.json +1 -1
- package/dist/lib/app/app-interaction.js +0 -5
|
@@ -67,10 +67,11 @@ function createProjectTransferCommand(runtime) {
|
|
|
67
67
|
}
|
|
68
68
|
function createProjectCreateCommand(runtime) {
|
|
69
69
|
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("create"), runtime), "project.create");
|
|
70
|
-
command.argument("<name>", "Project name");
|
|
70
|
+
command.argument("<name>", "Project name").addOption(new Option("--region <region>", "Prisma Compute region id"));
|
|
71
71
|
addGlobalFlags(command);
|
|
72
72
|
command.action(async (name, options) => {
|
|
73
|
-
|
|
73
|
+
const region = options.region;
|
|
74
|
+
await runCommand(runtime, "project.create", options, (context) => runProjectCreate(context, String(name), { region }), {
|
|
74
75
|
renderHuman: (context, descriptor, result) => renderProjectSetup(context, descriptor, result),
|
|
75
76
|
renderJson: (result) => serializeProjectSetup(result)
|
|
76
77
|
});
|
package/dist/controllers/app.js
CHANGED
|
@@ -5,12 +5,11 @@ import { canPrompt } from "../shell/runtime.js";
|
|
|
5
5
|
import { writeJsonEvent } from "../shell/output.js";
|
|
6
6
|
import { SERVICE_TOKEN_ENV_VAR, getApiBaseUrl } from "../lib/auth/client.js";
|
|
7
7
|
import { FileTokenStorage } from "../adapters/token-storage.js";
|
|
8
|
-
import { confirmPrompt, selectPrompt, textPrompt } from "../shell/prompt.js";
|
|
9
|
-
import "../lib/app/app-interaction.js";
|
|
10
8
|
import { PRISMA_APP_CONFIG_FILENAME, detectLegacyBuildSettings, resolveConfiguredAppBuildSettings, resolveInferredAppBuildSettings } from "../lib/app/build-settings.js";
|
|
11
9
|
import { APP_BUILD_TYPES, APP_BUILD_TYPE_LABELS, RESOLVED_APP_BUILD_TYPES, executeAppBuild } from "../lib/app/build.js";
|
|
12
10
|
import { envVarNames, parseEnvInputs } from "../lib/app/env-vars.js";
|
|
13
11
|
import { DomainApiError, createAppProvider } from "../lib/app/app-provider.js";
|
|
12
|
+
import { confirmPrompt, selectPrompt, textPrompt } from "../shell/prompt.js";
|
|
14
13
|
import { LOCAL_RESOLUTION_PIN_RELATIVE_PATH, readLocalResolutionPin } from "../lib/project/local-pin.js";
|
|
15
14
|
import { buildProjectSetupNextActions, inferTargetName, localProjectWorkspaceMismatchError, projectNotFoundError, projectResolutionErrorToCliError, resolveDurablePlatformMapping, resolveProjectTarget, sortProjects } from "../lib/project/resolution.js";
|
|
16
15
|
import { bindProjectToDirectory, projectCreateFailedError, projectDirectoryBindingErrorToCliError, projectSetupNameRequiredError, resolveProjectForSetup, toProjectSummary } from "../lib/project/setup.js";
|
|
@@ -281,6 +280,7 @@ async function runSingleAppDeploy(context, appName, options, preloadedConfig) {
|
|
|
281
280
|
const { provider, target, projectId } = await requireProviderAndDeployProjectContext(context, options?.projectRef, {
|
|
282
281
|
branch,
|
|
283
282
|
createProjectName: options?.createProjectName,
|
|
283
|
+
createProjectRegion: deployRegion?.value,
|
|
284
284
|
envProjectId,
|
|
285
285
|
localPin
|
|
286
286
|
});
|
|
@@ -416,6 +416,7 @@ async function runSingleAppDeploy(context, appName, options, preloadedConfig) {
|
|
|
416
416
|
entrypoint: entrypoint ?? buildSettingsResolution.settings.entrypoint ?? null,
|
|
417
417
|
httpPort: runtime.port,
|
|
418
418
|
region: deployResult.app.region ?? selectedApp.region ?? null,
|
|
419
|
+
regionSource: deployRegion?.annotation ?? null,
|
|
419
420
|
envVars: envVarNames(envVars)
|
|
420
421
|
},
|
|
421
422
|
durationMs: deployDurationMs,
|
|
@@ -1424,7 +1425,7 @@ async function resolveAmbiguousDeployApp(context, matches, targetName, requested
|
|
|
1424
1425
|
});
|
|
1425
1426
|
}
|
|
1426
1427
|
function deployNewAppRegion(configRegion) {
|
|
1427
|
-
return configRegion?.value
|
|
1428
|
+
return configRegion?.value;
|
|
1428
1429
|
}
|
|
1429
1430
|
async function resolveExistingAppSelection(context, projectId, apps, explicitAppName) {
|
|
1430
1431
|
if (explicitAppName) {
|
|
@@ -1654,7 +1655,7 @@ async function resolveDeployProjectContext(context, client, provider, explicitPr
|
|
|
1654
1655
|
if (!projectName) throw projectSetupNameRequiredError("app deploy --create-project");
|
|
1655
1656
|
return withRemoteDeployBranch(provider, {
|
|
1656
1657
|
workspace,
|
|
1657
|
-
project: toProjectSummary(await createProjectForDeploySetup(provider, projectName, workspace, context.runtime.signal)),
|
|
1658
|
+
project: toProjectSummary(await createProjectForDeploySetup(provider, projectName, workspace, context.runtime.signal, options.createProjectRegion)),
|
|
1658
1659
|
resolution: {
|
|
1659
1660
|
projectSource: "created",
|
|
1660
1661
|
targetName: projectName,
|
|
@@ -1705,14 +1706,14 @@ async function resolveDeployProjectContext(context, client, provider, explicitPr
|
|
|
1705
1706
|
targetNameSource: "platform-mapping"
|
|
1706
1707
|
}
|
|
1707
1708
|
}, branch, context.runtime.signal);
|
|
1708
|
-
if (canPrompt(context) && !context.flags.yes) return withRemoteDeployBranch(provider, await resolveInteractiveDeployProjectSetup(context, provider, workspace, projects), branch, context.runtime.signal);
|
|
1709
|
+
if (canPrompt(context) && !context.flags.yes) return withRemoteDeployBranch(provider, await resolveInteractiveDeployProjectSetup(context, provider, workspace, projects, options.createProjectRegion), branch, context.runtime.signal);
|
|
1709
1710
|
throw projectSetupRequiredError(projects, await inferTargetName(context.runtime.cwd, context.runtime.signal));
|
|
1710
1711
|
}
|
|
1711
|
-
async function resolveInteractiveDeployProjectSetup(context, provider, workspace, projects) {
|
|
1712
|
+
async function resolveInteractiveDeployProjectSetup(context, provider, workspace, projects, createProjectRegion) {
|
|
1712
1713
|
const setup = await promptForProjectSetupChoice({
|
|
1713
1714
|
context,
|
|
1714
1715
|
projects,
|
|
1715
|
-
createProject: (projectName) => createProjectForDeploySetup(provider, projectName, workspace, context.runtime.signal),
|
|
1716
|
+
createProject: (projectName) => createProjectForDeploySetup(provider, projectName, workspace, context.runtime.signal, createProjectRegion),
|
|
1716
1717
|
cancel: {
|
|
1717
1718
|
why: "Deploy needs a Project before it can continue.",
|
|
1718
1719
|
fix: "Choose an existing Project or create a new one, then rerun deploy.",
|
|
@@ -1730,9 +1731,10 @@ async function resolveInteractiveDeployProjectSetup(context, provider, workspace
|
|
|
1730
1731
|
localPinAction: setup.action
|
|
1731
1732
|
};
|
|
1732
1733
|
}
|
|
1733
|
-
async function createProjectForDeploySetup(provider, projectName, workspace, signal) {
|
|
1734
|
+
async function createProjectForDeploySetup(provider, projectName, workspace, signal, region) {
|
|
1734
1735
|
const created = await provider.createProject({
|
|
1735
1736
|
name: projectName,
|
|
1737
|
+
region,
|
|
1736
1738
|
signal
|
|
1737
1739
|
}).catch((error) => {
|
|
1738
1740
|
throw projectCreateFailedError(error, projectName, workspace, {
|
|
@@ -1748,6 +1750,7 @@ async function createProjectForDeploySetup(provider, projectName, workspace, sig
|
|
|
1748
1750
|
return {
|
|
1749
1751
|
id: created.id,
|
|
1750
1752
|
name: created.name,
|
|
1753
|
+
...created.defaultRegion != null ? { defaultRegion: created.defaultRegion } : {},
|
|
1751
1754
|
workspace
|
|
1752
1755
|
};
|
|
1753
1756
|
}
|
|
@@ -104,7 +104,7 @@ async function runProjectShow(context, explicitProject) {
|
|
|
104
104
|
}) : []
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
|
-
async function runProjectCreate(context, projectName) {
|
|
107
|
+
async function runProjectCreate(context, projectName, options) {
|
|
108
108
|
const workspace = (await requireAuthenticatedAuthState(context)).workspace;
|
|
109
109
|
if (!workspace) throw workspaceRequiredError();
|
|
110
110
|
if (!isValidProjectSetupName(projectName)) throw projectSetupNameRequiredError("project create");
|
|
@@ -115,6 +115,7 @@ async function runProjectCreate(context, projectName) {
|
|
|
115
115
|
const name = projectName.trim();
|
|
116
116
|
const created = await provider.createProject({
|
|
117
117
|
name,
|
|
118
|
+
region: options?.region,
|
|
118
119
|
signal: context.runtime.signal
|
|
119
120
|
}).catch((error) => {
|
|
120
121
|
throw projectCreateFailedError(error, name, workspace, {
|
|
@@ -125,7 +126,8 @@ async function runProjectCreate(context, projectName) {
|
|
|
125
126
|
});
|
|
126
127
|
const bindResult = await bindProjectToDirectory(context, workspace, {
|
|
127
128
|
id: created.id,
|
|
128
|
-
name: created.name
|
|
129
|
+
name: created.name,
|
|
130
|
+
...created.defaultRegion != null ? { defaultRegion: created.defaultRegion } : {}
|
|
129
131
|
}, "created");
|
|
130
132
|
if (bindResult.isErr()) throw projectDirectoryBindingErrorToCliError(bindResult.error);
|
|
131
133
|
return {
|
|
@@ -704,6 +706,7 @@ async function listRealWorkspaceProjects(client, workspace, signal) {
|
|
|
704
706
|
id: project.id,
|
|
705
707
|
name: project.name,
|
|
706
708
|
..."url" in project && typeof project.url === "string" ? { url: project.url } : {},
|
|
709
|
+
..."defaultRegion" in project ? { defaultRegion: project.defaultRegion } : {},
|
|
707
710
|
slug: "slug" in project && typeof project.slug === "string" ? project.slug : null,
|
|
708
711
|
workspace: {
|
|
709
712
|
id: project.workspace.id,
|
|
@@ -22,12 +22,14 @@ function createAppProvider(client, options) {
|
|
|
22
22
|
async createProject(options) {
|
|
23
23
|
const projectResult = await sdk.createProject({
|
|
24
24
|
name: options.name,
|
|
25
|
+
region: options.region,
|
|
25
26
|
signal: options.signal
|
|
26
27
|
});
|
|
27
28
|
if (projectResult.isErr()) throw new Error(projectResult.error.message);
|
|
28
29
|
return {
|
|
29
30
|
id: projectResult.value.id,
|
|
30
|
-
name: projectResult.value.name
|
|
31
|
+
name: projectResult.value.name,
|
|
32
|
+
defaultRegion: projectResult.value.defaultRegion
|
|
31
33
|
};
|
|
32
34
|
},
|
|
33
35
|
async listApps(projectId, options) {
|
|
@@ -379,7 +379,8 @@ function toProjectSummary(project) {
|
|
|
379
379
|
return {
|
|
380
380
|
id: project.id,
|
|
381
381
|
name: project.name,
|
|
382
|
-
...project.url ? { url: project.url } : {}
|
|
382
|
+
...project.url ? { url: project.url } : {},
|
|
383
|
+
...project.defaultRegion != null ? { defaultRegion: project.defaultRegion } : {}
|
|
383
384
|
};
|
|
384
385
|
}
|
|
385
386
|
//#endregion
|
|
@@ -82,7 +82,8 @@ function toProjectSummary(project) {
|
|
|
82
82
|
return {
|
|
83
83
|
id: project.id,
|
|
84
84
|
name: project.name,
|
|
85
|
-
...project.url ? { url: project.url } : {}
|
|
85
|
+
...project.url ? { url: project.url } : {},
|
|
86
|
+
...project.defaultRegion != null ? { defaultRegion: project.defaultRegion } : {}
|
|
86
87
|
};
|
|
87
88
|
}
|
|
88
89
|
function projectSetupNameRequiredError(command) {
|
package/dist/presenters/app.js
CHANGED
|
@@ -48,6 +48,11 @@ function renderAppDeploy(context, descriptor, result, options) {
|
|
|
48
48
|
label: "Logs",
|
|
49
49
|
value: logsCommand
|
|
50
50
|
},
|
|
51
|
+
...result.deploySettings.region && result.deploySettings.regionSource === null ? [{
|
|
52
|
+
label: "Region",
|
|
53
|
+
value: result.deploySettings.region,
|
|
54
|
+
origin: result.project.defaultRegion != null ? "project default" : "platform default — pass --region to choose"
|
|
55
|
+
}] : [],
|
|
51
56
|
...deployUsedComputeConfig(result) ? [] : [{
|
|
52
57
|
label: "Config",
|
|
53
58
|
value: resolvePrismaCliPackageCommandSync(context.runtime.cwd, ["init"])
|
|
@@ -17,9 +17,13 @@ function renderProjectList(context, descriptor, result) {
|
|
|
17
17
|
return lines;
|
|
18
18
|
}
|
|
19
19
|
const nameWidth = Math.max(4, ...result.projects.map((project) => stringWidth(project.name)));
|
|
20
|
+
const idWidth = Math.max(2, ...result.projects.map((project) => project.id.length));
|
|
20
21
|
lines.push(rail);
|
|
21
|
-
lines.push(`${rail} ${ui.accent(padDisplay("name", nameWidth))} ${ui.accent("id")}`);
|
|
22
|
-
for (const project of result.projects)
|
|
22
|
+
lines.push(`${rail} ${ui.accent(padDisplay("name", nameWidth))} ${ui.accent(padDisplay("id", idWidth))} ${ui.accent("region")}`);
|
|
23
|
+
for (const project of result.projects) {
|
|
24
|
+
const region = project.defaultRegion ? project.defaultRegion : ui.dim("none");
|
|
25
|
+
lines.push(`${rail} ${padDisplay(project.name, nameWidth)} ${padDisplay(project.id, idWidth)} ${region}`);
|
|
26
|
+
}
|
|
23
27
|
if (result.localBinding?.status === "not-linked" || result.localBinding?.status === "invalid") lines.push(...renderNextSteps(["Link an existing Project you choose: prisma-cli project link <id-or-name>", "Create a new Project: prisma-cli project create <name>"]));
|
|
24
28
|
return lines;
|
|
25
29
|
}
|
|
@@ -241,6 +245,7 @@ function renderBoundProjectShow(context, descriptor, result) {
|
|
|
241
245
|
lines.push(rail);
|
|
242
246
|
lines.push(`${rail} ${ui.dim("→")} ${ui.link(result.project.url)}`);
|
|
243
247
|
}
|
|
248
|
+
if (result.project.defaultRegion) lines.push(`${rail} ${ui.accent(padDisplay("region", keyWidth))} ${ui.dim(result.project.defaultRegion)}`);
|
|
244
249
|
lines.push(...renderResolvedProjectContextBlock(context.ui, {
|
|
245
250
|
workspace: result.workspace,
|
|
246
251
|
project: result.project,
|
|
@@ -23,7 +23,8 @@ function toProjectSummary(project) {
|
|
|
23
23
|
return {
|
|
24
24
|
id: project.id,
|
|
25
25
|
name: project.name,
|
|
26
|
-
...project.url ? { url: project.url } : {}
|
|
26
|
+
...project.url ? { url: project.url } : {},
|
|
27
|
+
...project.defaultRegion != null ? { defaultRegion: project.defaultRegion } : {}
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
30
|
//#endregion
|
package/package.json
CHANGED