@prisma/cli 8.0.0-rc.1 → 8.0.0-rc.2
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/cli.js +15115 -16
- package/dist/deploy-framework-C7bQM00A.js +23 -0
- package/dist/{v8/sender.js → sender.js} +2 -2
- package/package.json +11 -15
- package/dist/adapters/git.js +0 -54
- package/dist/adapters/local-state.js +0 -155
- package/dist/auth/client.js +0 -30
- package/dist/auth/errors.js +0 -50
- package/dist/auth/guard.js +0 -39
- package/dist/auth/login.js +0 -471
- package/dist/auth/operations.js +0 -208
- package/dist/auth/recipient.js +0 -42
- package/dist/auth/token-storage.js +0 -439
- package/dist/auth/workspaces.js +0 -171
- package/dist/cli-command.js +0 -14
- package/dist/cli-name.js +0 -12
- package/dist/cli2.js +0 -136
- package/dist/command-arguments.js +0 -12
- package/dist/commands/agent/index.js +0 -60
- package/dist/commands/app/index.js +0 -350
- package/dist/commands/auth/index.js +0 -95
- package/dist/commands/branch/index.js +0 -27
- package/dist/commands/bucket/index.js +0 -123
- package/dist/commands/build/index.js +0 -29
- package/dist/commands/database/index.js +0 -249
- package/dist/commands/env.js +0 -99
- package/dist/commands/feedback/index.js +0 -20
- package/dist/commands/git/index.js +0 -36
- package/dist/commands/init/index.js +0 -33
- package/dist/commands/project/index.js +0 -118
- package/dist/commands/version/index.js +0 -18
- package/dist/controllers/agent-setup.js +0 -52
- package/dist/controllers/agent.js +0 -228
- package/dist/controllers/app-env-api.js +0 -55
- package/dist/controllers/app-env-file.js +0 -181
- package/dist/controllers/app-env.js +0 -502
- package/dist/controllers/app.js +0 -2508
- package/dist/controllers/auth.js +0 -124
- package/dist/controllers/branch.js +0 -92
- package/dist/controllers/bucket.js +0 -184
- package/dist/controllers/build.js +0 -88
- package/dist/controllers/database.js +0 -463
- package/dist/controllers/feedback.js +0 -90
- package/dist/controllers/init.js +0 -814
- package/dist/controllers/project.js +0 -892
- package/dist/controllers/select-prompt-port.js +0 -13
- package/dist/controllers/version.js +0 -12
- package/dist/errors.js +0 -102
- package/dist/lib/agent/cli-command.js +0 -20
- package/dist/lib/agent/constants.js +0 -12
- package/dist/lib/agent/package-manager.js +0 -99
- package/dist/lib/agent/setup-status.js +0 -83
- package/dist/lib/app/app-provider.js +0 -617
- package/dist/lib/app/branch-database-api.js +0 -102
- package/dist/lib/app/branch-database-deploy.js +0 -353
- package/dist/lib/app/branch-database.js +0 -234
- package/dist/lib/app/build-settings.js +0 -98
- package/dist/lib/app/build.js +0 -82
- package/dist/lib/app/bun-project.js +0 -45
- package/dist/lib/app/compute-config.js +0 -145
- package/dist/lib/app/deploy-output.js +0 -24
- package/dist/lib/app/deploy-plan.js +0 -59
- package/dist/lib/app/deploy-progress.js +0 -100
- package/dist/lib/app/domain-guidance.js +0 -14
- package/dist/lib/app/env-config.js +0 -67
- package/dist/lib/app/env-file.js +0 -82
- package/dist/lib/app/env-vars.js +0 -50
- package/dist/lib/app/local-dev.js +0 -109
- package/dist/lib/app/production-deploy-gate.js +0 -162
- package/dist/lib/app/read-branch.js +0 -30
- package/dist/lib/bucket/provider.js +0 -139
- package/dist/lib/database/provider.js +0 -385
- package/dist/lib/diagnostics.js +0 -16
- package/dist/lib/feedback.js +0 -15
- package/dist/lib/fs/home-path.js +0 -24
- package/dist/lib/git/local-branch.js +0 -53
- package/dist/lib/git/local-status.js +0 -57
- package/dist/lib/project/interactive-setup.js +0 -57
- package/dist/lib/project/local-pin.js +0 -200
- package/dist/lib/project/provider.js +0 -93
- package/dist/lib/project/resolution.js +0 -389
- package/dist/lib/project/setup.js +0 -138
- package/dist/lib/version.js +0 -56
- package/dist/lib/workspace-id.js +0 -18
- package/dist/output/patterns.js +0 -90
- package/dist/presenters/agent.js +0 -74
- package/dist/presenters/app-env.js +0 -265
- package/dist/presenters/app.js +0 -672
- package/dist/presenters/auth.js +0 -184
- package/dist/presenters/branch.js +0 -46
- package/dist/presenters/bucket.js +0 -174
- package/dist/presenters/database.js +0 -462
- package/dist/presenters/feedback.js +0 -26
- package/dist/presenters/init.js +0 -30
- package/dist/presenters/project.js +0 -268
- package/dist/presenters/verbose-context.js +0 -64
- package/dist/presenters/version.js +0 -29
- package/dist/shell/cli-command.js +0 -2
- package/dist/shell/command-meta.js +0 -923
- package/dist/shell/command-runner.js +0 -119
- package/dist/shell/diagnostics-output.js +0 -57
- package/dist/shell/global-flags.js +0 -37
- package/dist/shell/help.js +0 -90
- package/dist/shell/output.js +0 -144
- package/dist/shell/prompt.js +0 -48
- package/dist/shell/runtime.js +0 -38
- package/dist/shell/ui.js +0 -116
- package/dist/state-dir.js +0 -12
- package/dist/update-check.js +0 -248
- package/dist/v8/cli.js +0 -14699
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
3
|
-
import { resolveBuildSettings, resolveConfiguredBuildSettings } from "@prisma/compute-sdk";
|
|
4
|
-
//#region src/lib/app/build-settings.ts
|
|
5
|
-
/** Legacy build-settings file: no longer read or written, only detected for migration. */
|
|
6
|
-
const PRISMA_APP_CONFIG_FILENAME = "prisma.app.json";
|
|
7
|
-
/**
|
|
8
|
-
* Detects a leftover `prisma.app.json`. The file is no longer used: one that
|
|
9
|
-
* matches the effective settings is reported for deletion, one with custom
|
|
10
|
-
* values must be migrated to the compute config so builds never silently
|
|
11
|
-
* change.
|
|
12
|
-
*/
|
|
13
|
-
async function detectLegacyBuildSettings(options) {
|
|
14
|
-
const configPath = path.join(options.appPath, PRISMA_APP_CONFIG_FILENAME);
|
|
15
|
-
let content;
|
|
16
|
-
try {
|
|
17
|
-
options.signal?.throwIfAborted();
|
|
18
|
-
content = await readFile(configPath, {
|
|
19
|
-
encoding: "utf8",
|
|
20
|
-
signal: options.signal
|
|
21
|
-
});
|
|
22
|
-
} catch (error) {
|
|
23
|
-
if (options.signal?.aborted) throw error;
|
|
24
|
-
return { kind: "absent" };
|
|
25
|
-
}
|
|
26
|
-
let legacy;
|
|
27
|
-
try {
|
|
28
|
-
const parsed = JSON.parse(content);
|
|
29
|
-
const buildCommand = normalizeLegacyBuildCommand(parsed.buildCommand);
|
|
30
|
-
const outputDirectory = typeof parsed.outputDirectory === "string" ? normalizeRelativePath(parsed.outputDirectory) : void 0;
|
|
31
|
-
if (buildCommand === void 0 || !outputDirectory) return {
|
|
32
|
-
kind: "invalid",
|
|
33
|
-
configPath
|
|
34
|
-
};
|
|
35
|
-
legacy = {
|
|
36
|
-
buildCommand,
|
|
37
|
-
outputDirectory
|
|
38
|
-
};
|
|
39
|
-
} catch {
|
|
40
|
-
return {
|
|
41
|
-
kind: "invalid",
|
|
42
|
-
configPath
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
return legacy.buildCommand === options.effective.buildCommand && legacy.outputDirectory === options.effective.outputDirectory ? {
|
|
46
|
-
kind: "matching",
|
|
47
|
-
configPath
|
|
48
|
-
} : {
|
|
49
|
-
kind: "custom",
|
|
50
|
-
configPath,
|
|
51
|
-
...legacy
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
/** Resolves build settings purely from framework inference; nothing is read or written. */
|
|
55
|
-
async function resolveInferredAppBuildSettings(options) {
|
|
56
|
-
return {
|
|
57
|
-
status: "inferred",
|
|
58
|
-
configPath: null,
|
|
59
|
-
relativeConfigPath: null,
|
|
60
|
-
settings: await resolveBuildSettings(options)
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Resolves build settings when the compute config owns them: configured
|
|
65
|
-
* fields win, omitted fields fall back to framework defaults.
|
|
66
|
-
*/
|
|
67
|
-
async function resolveConfiguredAppBuildSettings(options) {
|
|
68
|
-
const configFilename = path.basename(options.configPath);
|
|
69
|
-
const settings = await resolveConfiguredBuildSettings({
|
|
70
|
-
appPath: options.appPath,
|
|
71
|
-
buildType: options.buildType,
|
|
72
|
-
configured: options.configured,
|
|
73
|
-
source: `set by ${configFilename}`,
|
|
74
|
-
signal: options.signal
|
|
75
|
-
});
|
|
76
|
-
return {
|
|
77
|
-
status: "config",
|
|
78
|
-
configPath: options.configPath,
|
|
79
|
-
relativeConfigPath: configFilename,
|
|
80
|
-
settings
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
const WINDOWS_DRIVE_PREFIX = /^[A-Za-z]:/;
|
|
84
|
-
function normalizeLegacyBuildCommand(value) {
|
|
85
|
-
if (typeof value === "string") return value.trim() || null;
|
|
86
|
-
if (value === null) return null;
|
|
87
|
-
}
|
|
88
|
-
function normalizeRelativePath(value) {
|
|
89
|
-
const raw = value.trim().replace(/\\/g, "/");
|
|
90
|
-
if (raw.length === 0 || raw.split("/").includes("..")) return;
|
|
91
|
-
if (WINDOWS_DRIVE_PREFIX.test(raw)) return;
|
|
92
|
-
const normalized = path.posix.normalize(raw);
|
|
93
|
-
const segments = normalized.split("/");
|
|
94
|
-
if (path.win32.isAbsolute(value) || path.posix.isAbsolute(normalized) || segments.includes("..")) return;
|
|
95
|
-
return normalized === "." ? "." : normalized;
|
|
96
|
-
}
|
|
97
|
-
//#endregion
|
|
98
|
-
export { PRISMA_APP_CONFIG_FILENAME, detectLegacyBuildSettings, resolveConfiguredAppBuildSettings, resolveInferredAppBuildSettings };
|
package/dist/lib/app/build.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import "node:path";
|
|
2
|
-
import "node:fs/promises";
|
|
3
|
-
import { FRAMEWORKS } from "@prisma/compute-sdk/config";
|
|
4
|
-
import { normalizeArtifactSymlinks, resolveBuildStrategy } from "@prisma/compute-sdk";
|
|
5
|
-
//#region src/lib/app/build.ts
|
|
6
|
-
const RESOLVED_APP_BUILD_TYPES = [...frameworkBuildTypesByLastOccurrence()];
|
|
7
|
-
const APP_BUILD_TYPES = ["auto", ...RESOLVED_APP_BUILD_TYPES];
|
|
8
|
-
const APP_BUILD_TYPE_LABELS = APP_BUILD_TYPES.join(", ");
|
|
9
|
-
function frameworkBuildTypesByLastOccurrence() {
|
|
10
|
-
const buildTypes = /* @__PURE__ */ new Set();
|
|
11
|
-
for (const framework of FRAMEWORKS) {
|
|
12
|
-
if (buildTypes.has(framework.buildType)) buildTypes.delete(framework.buildType);
|
|
13
|
-
buildTypes.add(framework.buildType);
|
|
14
|
-
}
|
|
15
|
-
return buildTypes;
|
|
16
|
-
}
|
|
17
|
-
var AppBuildStrategy = class {
|
|
18
|
-
#appPath;
|
|
19
|
-
#entrypoint;
|
|
20
|
-
#buildType;
|
|
21
|
-
#signal;
|
|
22
|
-
#buildSettings;
|
|
23
|
-
constructor(options) {
|
|
24
|
-
this.#appPath = options.appPath;
|
|
25
|
-
this.#entrypoint = options.entrypoint;
|
|
26
|
-
this.#buildType = options.buildType ?? "auto";
|
|
27
|
-
this.#signal = options.signal;
|
|
28
|
-
this.#buildSettings = options.buildSettings;
|
|
29
|
-
}
|
|
30
|
-
async canBuild(signal = this.#signal) {
|
|
31
|
-
const { strategy } = await resolveAppBuildStrategy({
|
|
32
|
-
appPath: this.#appPath,
|
|
33
|
-
entrypoint: this.#entrypoint,
|
|
34
|
-
buildType: this.#buildType,
|
|
35
|
-
signal,
|
|
36
|
-
buildSettings: this.#buildSettings
|
|
37
|
-
});
|
|
38
|
-
return strategy.canBuild(signal);
|
|
39
|
-
}
|
|
40
|
-
async execute(signal = this.#signal) {
|
|
41
|
-
const { artifact } = await executeAppBuild({
|
|
42
|
-
appPath: this.#appPath,
|
|
43
|
-
entrypoint: this.#entrypoint,
|
|
44
|
-
buildType: this.#buildType,
|
|
45
|
-
signal,
|
|
46
|
-
buildSettings: this.#buildSettings
|
|
47
|
-
});
|
|
48
|
-
return artifact;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
async function executeAppBuild(options) {
|
|
52
|
-
const { strategy, buildType } = await resolveAppBuildStrategy({
|
|
53
|
-
appPath: options.appPath,
|
|
54
|
-
entrypoint: options.entrypoint,
|
|
55
|
-
buildType: options.buildType ?? "auto",
|
|
56
|
-
signal: options.signal,
|
|
57
|
-
buildSettings: options.buildSettings
|
|
58
|
-
});
|
|
59
|
-
const artifact = await strategy.execute(options.signal);
|
|
60
|
-
try {
|
|
61
|
-
await normalizeArtifactSymlinks(artifact.directory, options.appPath, options.signal);
|
|
62
|
-
return {
|
|
63
|
-
artifact,
|
|
64
|
-
buildType
|
|
65
|
-
};
|
|
66
|
-
} catch (error) {
|
|
67
|
-
await artifact.cleanup?.().catch(() => void 0);
|
|
68
|
-
throw error;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
async function resolveAppBuildStrategy(options) {
|
|
72
|
-
const buildType = options.buildType === "auto" && options.entrypoint ? "bun" : options.buildType;
|
|
73
|
-
return resolveBuildStrategy({
|
|
74
|
-
appPath: options.appPath,
|
|
75
|
-
buildType,
|
|
76
|
-
entrypoint: options.entrypoint,
|
|
77
|
-
buildSettings: options.buildSettings,
|
|
78
|
-
signal: options.signal
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
//#endregion
|
|
82
|
-
export { APP_BUILD_TYPES, APP_BUILD_TYPE_LABELS, AppBuildStrategy, RESOLVED_APP_BUILD_TYPES, executeAppBuild };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { access, readFile } from "node:fs/promises";
|
|
3
|
-
//#region src/lib/app/bun-project.ts
|
|
4
|
-
async function readBunPackageJson(appPath, signal) {
|
|
5
|
-
const packageJsonPath = path.join(appPath, "package.json");
|
|
6
|
-
let content;
|
|
7
|
-
signal?.throwIfAborted();
|
|
8
|
-
try {
|
|
9
|
-
content = await readFile(packageJsonPath, {
|
|
10
|
-
encoding: "utf8",
|
|
11
|
-
signal
|
|
12
|
-
});
|
|
13
|
-
} catch (error) {
|
|
14
|
-
if (error.code === "ENOENT") return null;
|
|
15
|
-
throw new Error(`Failed to read ${packageJsonPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
16
|
-
}
|
|
17
|
-
try {
|
|
18
|
-
return JSON.parse(content);
|
|
19
|
-
} catch (error) {
|
|
20
|
-
throw new Error(`Failed to parse ${packageJsonPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function readBunPackageEntrypoint(packageJson) {
|
|
24
|
-
return typeof packageJson?.main === "string" ? packageJson.main : void 0;
|
|
25
|
-
}
|
|
26
|
-
async function resolveBunEntrypoint(appPath, explicitEntrypoint, signal) {
|
|
27
|
-
const packageJson = await readBunPackageJson(appPath, signal);
|
|
28
|
-
const candidate = explicitEntrypoint ?? readBunPackageEntrypoint(packageJson);
|
|
29
|
-
if (!candidate) throw new Error("Entrypoint is required. Pass --entry or define package.json main.");
|
|
30
|
-
if (path.isAbsolute(candidate)) throw new Error("Entrypoint must be a relative path.");
|
|
31
|
-
const normalized = path.normalize(candidate);
|
|
32
|
-
if (normalized.startsWith("..") || path.isAbsolute(normalized) || normalized.includes(`${path.sep}..${path.sep}`)) throw new Error("Entrypoint must not escape the app directory.");
|
|
33
|
-
const entrypointPath = path.join(appPath, normalized);
|
|
34
|
-
signal?.throwIfAborted();
|
|
35
|
-
try {
|
|
36
|
-
await access(entrypointPath);
|
|
37
|
-
signal?.throwIfAborted();
|
|
38
|
-
} catch (error) {
|
|
39
|
-
if (signal?.aborted) throw error;
|
|
40
|
-
throw new Error(`Entrypoint file does not exist: ${entrypointPath}`);
|
|
41
|
-
}
|
|
42
|
-
return normalized.split(path.sep).join("/");
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
|
-
export { readBunPackageEntrypoint, readBunPackageJson, resolveBunEntrypoint };
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { CliError } from "../../errors.js";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { COMPUTE_CONFIG_FILENAME, frameworkByKey, loadComputeConfig } from "@prisma/compute-sdk/config";
|
|
4
|
-
import { matchError } from "better-result";
|
|
5
|
-
//#region src/lib/app/compute-config.ts
|
|
6
|
-
/**
|
|
7
|
-
* Loads the nearest compute config, searching from `cwd` up to the source
|
|
8
|
-
* root (repository or workspace boundary). Thin adapter over the SDK loader
|
|
9
|
-
* keeping the CLI's positional-signal call shape.
|
|
10
|
-
*/
|
|
11
|
-
async function loadComputeConfig$1(cwd, signal) {
|
|
12
|
-
return loadComputeConfig(cwd, { signal });
|
|
13
|
-
}
|
|
14
|
-
/** Local build/run strategy implied by a configured framework. */
|
|
15
|
-
function computeFrameworkToBuildType(framework) {
|
|
16
|
-
return frameworkByKey(framework).buildType;
|
|
17
|
-
}
|
|
18
|
-
function mergeComputeDeployInputs(options) {
|
|
19
|
-
const { cli, target, configFilename } = options;
|
|
20
|
-
const configAnnotation = `set by ${configFilename}`;
|
|
21
|
-
const framework = mergeStringInput(cli.framework, "set by --framework", target?.framework ?? void 0, configAnnotation);
|
|
22
|
-
const entrypoint = mergeStringInput(cli.entrypoint, "set by --entry", target?.entry ?? void 0, configAnnotation);
|
|
23
|
-
const httpPort = mergeStringInput(cli.httpPort, "set by --http-port", target?.httpPort ? String(target.httpPort) : void 0, configAnnotation);
|
|
24
|
-
const region = mergeStringInput(cli.region, "set by --region", target?.region ?? void 0, configAnnotation);
|
|
25
|
-
const cliEnvInputs = cli.envInputs && cli.envInputs.length > 0 ? cli.envInputs : void 0;
|
|
26
|
-
const configEnvInputs = target && target.envInputs.length > 0 ? target.envInputs : void 0;
|
|
27
|
-
const envInputs = cliEnvInputs ?? configEnvInputs;
|
|
28
|
-
const configAppName = readConfigAppName(target, configAnnotation);
|
|
29
|
-
return {
|
|
30
|
-
framework,
|
|
31
|
-
entrypoint,
|
|
32
|
-
httpPort,
|
|
33
|
-
region,
|
|
34
|
-
envInputs,
|
|
35
|
-
envInputsFromConfig: !cliEnvInputs && configEnvInputs !== void 0,
|
|
36
|
-
configAppName,
|
|
37
|
-
appRoot: target?.root ?? void 0
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
function mergeStringInput(cliValue, cliAnnotation, configValue, configAnnotation) {
|
|
41
|
-
if (cliValue !== void 0) return {
|
|
42
|
-
value: cliValue,
|
|
43
|
-
annotation: cliAnnotation
|
|
44
|
-
};
|
|
45
|
-
if (configValue) return {
|
|
46
|
-
value: configValue,
|
|
47
|
-
annotation: configAnnotation
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function readConfigAppName(target, configAnnotation) {
|
|
51
|
-
if (target?.name) return {
|
|
52
|
-
value: target.name,
|
|
53
|
-
annotation: configAnnotation
|
|
54
|
-
};
|
|
55
|
-
if (target?.key) return {
|
|
56
|
-
value: target.key,
|
|
57
|
-
annotation: configAnnotation
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Merges CLI inputs for the local `app build` and `app run` commands with a
|
|
62
|
-
* selected config target. Explicit flags win; `--build-type auto` is the
|
|
63
|
-
* flag default and defers to the configured framework.
|
|
64
|
-
*/
|
|
65
|
-
function mergeComputeLocalInputs(options) {
|
|
66
|
-
const { cli, target } = options;
|
|
67
|
-
const cliBuildType = cli.buildType && cli.buildType !== "auto" ? cli.buildType : void 0;
|
|
68
|
-
const configBuildType = target?.framework ? computeFrameworkToBuildType(target.framework) : void 0;
|
|
69
|
-
return {
|
|
70
|
-
entrypoint: cli.entrypoint ?? target?.entry ?? void 0,
|
|
71
|
-
buildType: cliBuildType ?? configBuildType,
|
|
72
|
-
buildTypeFromConfig: !cliBuildType && configBuildType !== void 0,
|
|
73
|
-
port: cli.port ?? (target?.httpPort ? String(target.httpPort) : void 0),
|
|
74
|
-
appRoot: target?.root ?? void 0
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
function computeConfigErrorToCliError(error, commandName = "deploy") {
|
|
78
|
-
const command = `prisma-cli app ${commandName}`;
|
|
79
|
-
return matchError(error, {
|
|
80
|
-
ComputeConfigAmbiguousError: (ambiguous) => new CliError({
|
|
81
|
-
code: "COMPUTE_CONFIG_INVALID",
|
|
82
|
-
domain: "app",
|
|
83
|
-
summary: "Multiple compute config files found",
|
|
84
|
-
why: ambiguous.message,
|
|
85
|
-
fix: `Keep exactly one compute config file, preferably ${COMPUTE_CONFIG_FILENAME}.`,
|
|
86
|
-
meta: { configPaths: ambiguous.configPaths },
|
|
87
|
-
exitCode: 2,
|
|
88
|
-
nextSteps: [command]
|
|
89
|
-
}),
|
|
90
|
-
ComputeConfigLoadError: (load) => new CliError({
|
|
91
|
-
code: "COMPUTE_CONFIG_INVALID",
|
|
92
|
-
domain: "app",
|
|
93
|
-
summary: `Could not load ${path.basename(load.configPath)}`,
|
|
94
|
-
why: load.message,
|
|
95
|
-
fix: `Fix the error in ${path.basename(load.configPath)} and rerun the command.`,
|
|
96
|
-
where: load.configPath,
|
|
97
|
-
meta: { configPath: load.configPath },
|
|
98
|
-
exitCode: 2,
|
|
99
|
-
nextSteps: [command]
|
|
100
|
-
}),
|
|
101
|
-
ComputeConfigInvalidError: (invalid) => new CliError({
|
|
102
|
-
code: "COMPUTE_CONFIG_INVALID",
|
|
103
|
-
domain: "app",
|
|
104
|
-
summary: `Invalid ${path.basename(invalid.configPath)}`,
|
|
105
|
-
why: invalid.issues.join(" "),
|
|
106
|
-
fix: `Edit ${path.basename(invalid.configPath)} so it default-exports defineComputeConfig({ app }) or defineComputeConfig({ apps }).`,
|
|
107
|
-
where: invalid.configPath,
|
|
108
|
-
meta: {
|
|
109
|
-
configPath: invalid.configPath,
|
|
110
|
-
issues: invalid.issues
|
|
111
|
-
},
|
|
112
|
-
exitCode: 2,
|
|
113
|
-
nextSteps: [command]
|
|
114
|
-
}),
|
|
115
|
-
ComputeConfigTargetRequiredError: (required) => new CliError({
|
|
116
|
-
code: "COMPUTE_CONFIG_TARGET_REQUIRED",
|
|
117
|
-
domain: "app",
|
|
118
|
-
summary: "App target required",
|
|
119
|
-
why: required.message,
|
|
120
|
-
fix: `Pass the app target, for example ${command} <target>.`,
|
|
121
|
-
meta: {
|
|
122
|
-
configPath: required.configPath,
|
|
123
|
-
availableTargets: required.availableTargets
|
|
124
|
-
},
|
|
125
|
-
exitCode: 2,
|
|
126
|
-
nextSteps: required.availableTargets.map((target) => `${command} ${target}`)
|
|
127
|
-
}),
|
|
128
|
-
ComputeConfigTargetUnknownError: (unknown) => new CliError({
|
|
129
|
-
code: "COMPUTE_CONFIG_TARGET_UNKNOWN",
|
|
130
|
-
domain: "app",
|
|
131
|
-
summary: `Unknown app target "${unknown.requestedTarget}"`,
|
|
132
|
-
why: unknown.message,
|
|
133
|
-
fix: unknown.availableTargets.length > 0 ? `Pass one of the configured targets: ${unknown.availableTargets.join(", ")}.` : "Remove the target argument; this config defines a single app.",
|
|
134
|
-
meta: {
|
|
135
|
-
configPath: unknown.configPath,
|
|
136
|
-
requestedTarget: unknown.requestedTarget,
|
|
137
|
-
availableTargets: unknown.availableTargets
|
|
138
|
-
},
|
|
139
|
-
exitCode: 2,
|
|
140
|
-
nextSteps: unknown.availableTargets.length > 0 ? unknown.availableTargets.map((target) => `${command} ${target}`) : [command]
|
|
141
|
-
})
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
//#endregion
|
|
145
|
-
export { computeConfigErrorToCliError, computeFrameworkToBuildType, loadComputeConfig$1 as loadComputeConfig, mergeComputeDeployInputs, mergeComputeLocalInputs };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { padDisplay } from "../../shell/ui.js";
|
|
2
|
-
//#region src/lib/app/deploy-output.ts
|
|
3
|
-
const DEPLOY_OUTPUT_MIN_LABEL_WIDTH = 9;
|
|
4
|
-
const DEPLOY_OUTPUT_MIN_VALUE_WIDTH = 9;
|
|
5
|
-
const DEPLOY_SETTINGS_MIN_KEY_WIDTH = 10;
|
|
6
|
-
function renderDeployOutputRows(ui, rows) {
|
|
7
|
-
if (rows.length === 0) return [];
|
|
8
|
-
const labelWidth = Math.max(DEPLOY_OUTPUT_MIN_LABEL_WIDTH, ...rows.map((row) => row.label.length));
|
|
9
|
-
const valueWidth = Math.max(DEPLOY_OUTPUT_MIN_VALUE_WIDTH, ...rows.map((row) => row.value?.length ?? 0));
|
|
10
|
-
return rows.map((row) => {
|
|
11
|
-
if (!row.value) return ` ${row.label}`;
|
|
12
|
-
return ` ${padDisplay(row.label, labelWidth)} ${padDisplay(ui.strong(row.value), valueWidth)}${row.origin ? ` ${ui.dim(`· ${row.origin}`)}` : ""}`.trimEnd();
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
function renderDeploySettingsPreview(ui, rows) {
|
|
16
|
-
if (rows.length === 0) return [];
|
|
17
|
-
const keyWidth = Math.max(DEPLOY_SETTINGS_MIN_KEY_WIDTH, ...rows.map((row) => `${row.key}:`.length));
|
|
18
|
-
const rail = ui.dim("│");
|
|
19
|
-
return rows.map((row) => {
|
|
20
|
-
return `${rail} ${ui.accent(padDisplay(`${row.key}:`, keyWidth))} ${ui.strong(row.value)}`;
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
|
-
export { renderDeployOutputRows, renderDeploySettingsPreview };
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
//#region src/lib/app/deploy-plan.ts
|
|
2
|
-
/**
|
|
3
|
-
* Decides whether a deploy covers one app or the whole system. A multi-app
|
|
4
|
-
* config with no target named or inferred deploys every target in declaration
|
|
5
|
-
* order; everything else (single-app config, an explicit/inferred target, or
|
|
6
|
-
* no config at all) is a single deploy.
|
|
7
|
-
*/
|
|
8
|
-
function planAppDeploy(options) {
|
|
9
|
-
const { config, requestedTarget, hasCreateProject } = options;
|
|
10
|
-
if (!(config !== null && config.kind === "multi" && !requestedTarget && config.targets.length > 1)) return { mode: "single" };
|
|
11
|
-
const total = config.targets.length;
|
|
12
|
-
return {
|
|
13
|
-
mode: "all",
|
|
14
|
-
targets: config.targets.map((target, index) => ({
|
|
15
|
-
targetKey: target.key,
|
|
16
|
-
index,
|
|
17
|
-
total,
|
|
18
|
-
bindsCreateProject: index === 0 && hasCreateProject
|
|
19
|
-
}))
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Names the per-app inputs present in a deploy-all invocation, in the order
|
|
24
|
-
* they should be reported. An empty list means the run is unambiguous; the
|
|
25
|
-
* caller renders the usage error when it is not.
|
|
26
|
-
*/
|
|
27
|
-
function perAppInputsForDeployAll(inputs) {
|
|
28
|
-
return [
|
|
29
|
-
["--app", inputs.appName],
|
|
30
|
-
["--framework", inputs.framework],
|
|
31
|
-
["--entry", inputs.entrypoint],
|
|
32
|
-
["--http-port", inputs.httpPort],
|
|
33
|
-
["--region", inputs.region],
|
|
34
|
-
["--env", inputs.envAssignments?.length ? inputs.envAssignments : void 0],
|
|
35
|
-
[inputs.appIdEnvVar.name, inputs.appIdEnvVar.value]
|
|
36
|
-
].filter(([, value]) => value !== void 0).map(([flag]) => flag);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Describes a deploy-all run that stopped at the first failing target: which
|
|
40
|
-
* targets already went live and which were never attempted, so the caller can
|
|
41
|
-
* surface a converge path. Pure; the caller folds this into the CliError.
|
|
42
|
-
*/
|
|
43
|
-
function describeDeployAllFailure(options) {
|
|
44
|
-
const { targetKeys, failedIndex, completed } = options;
|
|
45
|
-
const failedTarget = targetKeys[failedIndex];
|
|
46
|
-
const notAttempted = targetKeys.slice(failedIndex + 1);
|
|
47
|
-
return {
|
|
48
|
-
failedTarget,
|
|
49
|
-
completed,
|
|
50
|
-
notAttempted,
|
|
51
|
-
contextLines: [
|
|
52
|
-
`Deploying all apps stopped at "${failedTarget}" (${failedIndex + 1}/${targetKeys.length}).`,
|
|
53
|
-
...completed.length > 0 ? [`Already live: ${completed.map((entry) => entry.target).join(", ")}.`] : [],
|
|
54
|
-
...notAttempted.length > 0 ? [`Not attempted: ${notAttempted.join(", ")}.`] : []
|
|
55
|
-
]
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
export { describeDeployAllFailure, perAppInputsForDeployAll, planAppDeploy };
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { renderDeployOutputRows } from "./deploy-output.js";
|
|
2
|
-
//#region src/lib/app/deploy-progress.ts
|
|
3
|
-
function createDeployProgressState() {
|
|
4
|
-
return {
|
|
5
|
-
buildStarted: false,
|
|
6
|
-
buildCompleted: false,
|
|
7
|
-
archiveReady: false,
|
|
8
|
-
uploadCompleted: false,
|
|
9
|
-
deploymentId: null,
|
|
10
|
-
startRequested: false,
|
|
11
|
-
containerLive: false,
|
|
12
|
-
deploymentUrl: null,
|
|
13
|
-
promotedUrl: null
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
function createDeployProgress(output, ui, enabled, state = createDeployProgressState()) {
|
|
17
|
-
const write = (line) => {
|
|
18
|
-
if (!enabled) return;
|
|
19
|
-
output.write(`${line}\n`);
|
|
20
|
-
};
|
|
21
|
-
const writeRows = (rows) => {
|
|
22
|
-
for (const line of renderDeployOutputRows(ui, rows)) write(line);
|
|
23
|
-
};
|
|
24
|
-
return {
|
|
25
|
-
onBuildStart() {
|
|
26
|
-
state.buildStarted = true;
|
|
27
|
-
write("Building locally...");
|
|
28
|
-
},
|
|
29
|
-
onBuildComplete() {
|
|
30
|
-
state.buildCompleted = true;
|
|
31
|
-
},
|
|
32
|
-
onArchiveReady(byteLength) {
|
|
33
|
-
state.archiveReady = true;
|
|
34
|
-
writeRows([{
|
|
35
|
-
label: "Built",
|
|
36
|
-
value: formatArtifactSize(byteLength)
|
|
37
|
-
}]);
|
|
38
|
-
},
|
|
39
|
-
onUploadStart() {
|
|
40
|
-
write("Uploading...");
|
|
41
|
-
},
|
|
42
|
-
onDeploymentCreated(deploymentId) {
|
|
43
|
-
state.deploymentId = deploymentId;
|
|
44
|
-
},
|
|
45
|
-
onUploadComplete() {
|
|
46
|
-
state.uploadCompleted = true;
|
|
47
|
-
writeRows([{ label: "Uploaded" }]);
|
|
48
|
-
},
|
|
49
|
-
onStartRequested() {
|
|
50
|
-
state.startRequested = true;
|
|
51
|
-
write("Deploying...");
|
|
52
|
-
},
|
|
53
|
-
onRunning(url) {
|
|
54
|
-
state.containerLive = true;
|
|
55
|
-
state.deploymentUrl = url;
|
|
56
|
-
writeRows([{ label: "Deployed" }]);
|
|
57
|
-
},
|
|
58
|
-
onPromoted(url) {
|
|
59
|
-
state.promotedUrl = url;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
function formatArtifactSize(byteLength) {
|
|
64
|
-
return `${(byteLength / 1024 / 1024).toFixed(1)} MB`;
|
|
65
|
-
}
|
|
66
|
-
function createPromoteProgress(output, enabled) {
|
|
67
|
-
if (!enabled) return;
|
|
68
|
-
const write = (line) => {
|
|
69
|
-
output.write(`${line}\n`);
|
|
70
|
-
};
|
|
71
|
-
return {
|
|
72
|
-
onDeploymentStarting(deploymentId) {
|
|
73
|
-
write(`Starting deployment ${deploymentId}...`);
|
|
74
|
-
},
|
|
75
|
-
onDeploymentStartRequested() {
|
|
76
|
-
write("Requesting deployment start...");
|
|
77
|
-
},
|
|
78
|
-
onStatusChange(status) {
|
|
79
|
-
write(`Status: ${status}`);
|
|
80
|
-
},
|
|
81
|
-
onDeploymentRunning() {
|
|
82
|
-
write("Deployment is running.");
|
|
83
|
-
},
|
|
84
|
-
onPromoteStart() {
|
|
85
|
-
write("Promoting deployment...");
|
|
86
|
-
},
|
|
87
|
-
onPromoted(url) {
|
|
88
|
-
if (url) {
|
|
89
|
-
write(`Promoted to ${url}.`);
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
write("Promotion complete.");
|
|
93
|
-
},
|
|
94
|
-
onPromoteFailed(error) {
|
|
95
|
-
write(`Promotion failed${error?.message ? `: ${error.message}` : "."}`);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
//#endregion
|
|
100
|
-
export { createDeployProgress, createDeployProgressState, createPromoteProgress };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//#region src/lib/app/domain-guidance.ts
|
|
2
|
-
function formatDomainFailureFix(domain) {
|
|
3
|
-
if (domain.status !== "failed") return null;
|
|
4
|
-
const dnsRecord = domain.dnsRecords[0];
|
|
5
|
-
if (domain.failureCategory === "dns") {
|
|
6
|
-
if (dnsRecord) return `Add ${dnsRecord.type} ${dnsRecord.name} -> ${dnsRecord.value}, then run prisma-cli app domain retry ${domain.hostname}.`;
|
|
7
|
-
return `DNS verification failed, but the platform did not return a DNS record. Run prisma-cli app domain show ${domain.hostname} later, then retry when the DNS target is available.`;
|
|
8
|
-
}
|
|
9
|
-
if (domain.failureCategory === "acme") return `Retry TLS issuance with prisma-cli app domain retry ${domain.hostname}. Contact support if it fails again.`;
|
|
10
|
-
if (domain.failureCategory === "storage") return `Retry provisioning with prisma-cli app domain retry ${domain.hostname}. Contact support if it fails again.`;
|
|
11
|
-
return `Run prisma-cli app domain retry ${domain.hostname}. Contact support if it fails again.`;
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
export { formatDomainFailureFix };
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { usageError } from "../../errors.js";
|
|
2
|
-
//#region src/lib/app/env-config.ts
|
|
3
|
-
const VALID_ROLES = new Set(["production", "preview"]);
|
|
4
|
-
function positionalHint(command) {
|
|
5
|
-
if (command === "add" || command === "update") return "KEY=value ";
|
|
6
|
-
if (command === "remove") return "KEY ";
|
|
7
|
-
return "";
|
|
8
|
-
}
|
|
9
|
-
function resolveEnvScope(flags, options) {
|
|
10
|
-
if (flags.roleName && flags.branchName) throw usageError(`prisma-cli project env ${options.command} accepts either --role or --branch`, "--role targets a project-level config map; --branch targets a preview branch override.", "Pass exactly one scope flag.", [`prisma-cli project env ${options.command} ${positionalHint(options.command)}--role preview`, `prisma-cli project env ${options.command} ${positionalHint(options.command)}--branch feature/foo`], "app");
|
|
11
|
-
if (flags.roleName) {
|
|
12
|
-
if (!VALID_ROLES.has(flags.roleName)) throw usageError(`Unknown role "${flags.roleName}"`, "--role accepts production or preview.", "Pass --role production or --role preview.", [`prisma-cli project env ${options.command} --role production`, `prisma-cli project env ${options.command} --role preview`], "app");
|
|
13
|
-
return {
|
|
14
|
-
kind: "role",
|
|
15
|
-
role: flags.roleName
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
if (flags.branchName) return {
|
|
19
|
-
kind: "branch",
|
|
20
|
-
branchName: flags.branchName
|
|
21
|
-
};
|
|
22
|
-
if (options.requireExplicit) {
|
|
23
|
-
const positional = positionalHint(options.command);
|
|
24
|
-
throw usageError(`prisma-cli project env ${options.command} requires --role or --branch`, "Writing without an explicit scope is rejected so the command never silently targets production.", "Pass --role production, --role preview, or --branch <git-name>.", [
|
|
25
|
-
`prisma-cli project env ${options.command} ${positional}--role production`,
|
|
26
|
-
`prisma-cli project env ${options.command} ${positional}--role preview`,
|
|
27
|
-
`prisma-cli project env ${options.command} ${positional}--branch feature/foo`
|
|
28
|
-
], "app");
|
|
29
|
-
}
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
function parseKeyValuePositional(raw, command, env = process.env) {
|
|
33
|
-
if (!raw) throw usageError(`prisma-cli project env ${command} requires KEY=VALUE`, "No KEY=VALUE positional argument was supplied.", "Pass the variable as KEY=VALUE, e.g. STRIPE_KEY=sk_test_xxx.", [`prisma-cli project env ${command} STRIPE_KEY=sk_test_xxx --role production`], "app");
|
|
34
|
-
const separatorIndex = raw.indexOf("=");
|
|
35
|
-
if (separatorIndex === -1) {
|
|
36
|
-
if (KEY_SHAPE.test(raw)) {
|
|
37
|
-
validateKey(raw, command);
|
|
38
|
-
const value = env[raw];
|
|
39
|
-
if (typeof value === "string" && value.length > 0) return {
|
|
40
|
-
key: raw,
|
|
41
|
-
value
|
|
42
|
-
};
|
|
43
|
-
throw usageError(`Value for "${raw}" was not provided`, `No KEY=VALUE assignment was supplied, and ${raw} is not set in the current environment.`, "Pass KEY=VALUE or export the variable before running the command.", [`prisma-cli project env ${command} ${raw}=value --role production`, `${raw}=value prisma-cli project env ${command} ${raw} --role production`], "app");
|
|
44
|
-
}
|
|
45
|
-
throw usageError(`KEY=VALUE argument is missing the = separator`, `"${raw}" does not contain an = character.`, "Pass the variable as KEY=VALUE, e.g. STRIPE_KEY=sk_test_xxx.", [`prisma-cli project env ${command} STRIPE_KEY=sk_test_xxx --role production`], "app");
|
|
46
|
-
}
|
|
47
|
-
const key = raw.slice(0, separatorIndex);
|
|
48
|
-
const value = raw.slice(separatorIndex + 1);
|
|
49
|
-
validateKey(key, command);
|
|
50
|
-
if (value.length === 0) throw usageError(`KEY=VALUE argument has an empty value`, `"${raw}" has an empty value after the = separator.`, `Pass a non-empty value, or use prisma-cli project env remove to remove a variable.`, [`prisma-cli project env ${command} ${key}=value --role production`], "app");
|
|
51
|
-
return {
|
|
52
|
-
key,
|
|
53
|
-
value
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
const KEY_SHAPE = /^[A-Z_][A-Z0-9_]*$/;
|
|
57
|
-
function validateKey(key, command) {
|
|
58
|
-
if (key.length === 0) throw usageError(`Variable key cannot be empty`, "An empty key was passed.", "Pass an env-var key, e.g. STRIPE_KEY.", [`prisma-cli project env ${command} STRIPE_KEY${command === "remove" ? "" : "=value"} --role production`], "app");
|
|
59
|
-
if (key.length > 256) throw usageError(`Variable key "${key}" exceeds the 256-character limit`, "Env-var keys are capped at 256 characters by the platform.", "Use a shorter key.", [], "app");
|
|
60
|
-
if (!KEY_SHAPE.test(key)) throw usageError(`Variable key "${key}" must match the POSIX env-var shape`, "Keys must start with an uppercase letter or underscore and contain only uppercase letters, digits, and underscores.", "Rename the key to match [A-Z_][A-Z0-9_]*.", [`prisma-cli project env ${command} STRIPE_KEY${command === "remove" ? "" : "=value"} --role production`], "app");
|
|
61
|
-
}
|
|
62
|
-
function formatScopeLabel(scope) {
|
|
63
|
-
if (scope.kind === "role") return scope.role;
|
|
64
|
-
return `branch:${scope.branchName}`;
|
|
65
|
-
}
|
|
66
|
-
//#endregion
|
|
67
|
-
export { formatScopeLabel, parseKeyValuePositional, resolveEnvScope, validateKey };
|