@prisma/cli 3.0.0-dev.99.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.
Files changed (87) hide show
  1. package/README.md +3 -1
  2. package/dist/cli.js +15115 -16
  3. package/dist/deploy-framework-C7bQM00A.js +23 -0
  4. package/dist/payload-B88Qvzxk-CrtTXSOe.js +34 -0
  5. package/dist/sender.js +192 -0
  6. package/package.json +22 -18
  7. package/dist/adapters/git.js +0 -54
  8. package/dist/adapters/local-state.js +0 -144
  9. package/dist/adapters/mock-api.js +0 -136
  10. package/dist/adapters/token-storage.js +0 -418
  11. package/dist/cli2.js +0 -119
  12. package/dist/commands/app/index.js +0 -345
  13. package/dist/commands/auth/index.js +0 -96
  14. package/dist/commands/branch/index.js +0 -27
  15. package/dist/commands/database/index.js +0 -159
  16. package/dist/commands/env.js +0 -99
  17. package/dist/commands/git/index.js +0 -36
  18. package/dist/commands/project/index.js +0 -69
  19. package/dist/commands/version/index.js +0 -18
  20. package/dist/controllers/app-env-api.js +0 -54
  21. package/dist/controllers/app-env-file.js +0 -181
  22. package/dist/controllers/app-env.js +0 -502
  23. package/dist/controllers/app.js +0 -2443
  24. package/dist/controllers/auth.js +0 -316
  25. package/dist/controllers/branch.js +0 -103
  26. package/dist/controllers/database.js +0 -318
  27. package/dist/controllers/project.js +0 -731
  28. package/dist/controllers/select-prompt-port.js +0 -12
  29. package/dist/controllers/version.js +0 -12
  30. package/dist/lib/app/app-interaction.js +0 -5
  31. package/dist/lib/app/app-provider.js +0 -544
  32. package/dist/lib/app/branch-database-api.js +0 -102
  33. package/dist/lib/app/branch-database-deploy.js +0 -325
  34. package/dist/lib/app/branch-database.js +0 -215
  35. package/dist/lib/app/build-settings.js +0 -93
  36. package/dist/lib/app/build.js +0 -80
  37. package/dist/lib/app/bun-project.js +0 -45
  38. package/dist/lib/app/compute-config.js +0 -147
  39. package/dist/lib/app/deploy-output.js +0 -24
  40. package/dist/lib/app/deploy-plan.js +0 -58
  41. package/dist/lib/app/deploy-progress.js +0 -100
  42. package/dist/lib/app/domain-guidance.js +0 -14
  43. package/dist/lib/app/env-config.js +0 -67
  44. package/dist/lib/app/env-file.js +0 -82
  45. package/dist/lib/app/env-vars.js +0 -50
  46. package/dist/lib/app/local-dev.js +0 -109
  47. package/dist/lib/app/production-deploy-gate.js +0 -161
  48. package/dist/lib/app/read-branch.js +0 -30
  49. package/dist/lib/auth/auth-ops.js +0 -158
  50. package/dist/lib/auth/client.js +0 -22
  51. package/dist/lib/auth/guard.js +0 -38
  52. package/dist/lib/auth/login.js +0 -330
  53. package/dist/lib/database/provider.js +0 -167
  54. package/dist/lib/diagnostics.js +0 -15
  55. package/dist/lib/fs/home-path.js +0 -24
  56. package/dist/lib/git/local-branch.js +0 -53
  57. package/dist/lib/git/local-status.js +0 -57
  58. package/dist/lib/project/interactive-setup.js +0 -56
  59. package/dist/lib/project/local-pin.js +0 -200
  60. package/dist/lib/project/resolution.js +0 -386
  61. package/dist/lib/project/setup.js +0 -135
  62. package/dist/lib/version.js +0 -55
  63. package/dist/output/patterns.js +0 -90
  64. package/dist/presenters/app-env.js +0 -265
  65. package/dist/presenters/app.js +0 -646
  66. package/dist/presenters/auth.js +0 -183
  67. package/dist/presenters/branch.js +0 -46
  68. package/dist/presenters/database.js +0 -274
  69. package/dist/presenters/project.js +0 -174
  70. package/dist/presenters/verbose-context.js +0 -64
  71. package/dist/presenters/version.js +0 -29
  72. package/dist/shell/command-arguments.js +0 -6
  73. package/dist/shell/command-meta.js +0 -622
  74. package/dist/shell/command-runner.js +0 -112
  75. package/dist/shell/diagnostics-output.js +0 -57
  76. package/dist/shell/errors.js +0 -134
  77. package/dist/shell/global-flags.js +0 -37
  78. package/dist/shell/help.js +0 -89
  79. package/dist/shell/output.js +0 -82
  80. package/dist/shell/prompt.js +0 -41
  81. package/dist/shell/runtime.js +0 -55
  82. package/dist/shell/ui.js +0 -116
  83. package/dist/shell/update-check.js +0 -247
  84. package/dist/use-cases/auth.js +0 -145
  85. package/dist/use-cases/branch.js +0 -47
  86. package/dist/use-cases/create-cli-gateways.js +0 -68
  87. package/dist/use-cases/project.js +0 -30
@@ -1,135 +0,0 @@
1
- import { CliError, usageError } from "../../shell/errors.js";
2
- import { shortenHomePath } from "../fs/home-path.js";
3
- import { LOCAL_RESOLUTION_PIN_RELATIVE_PATH, ensureLocalResolutionPinGitignore, writeLocalResolutionPin } from "./local-pin.js";
4
- import "../../shell/command-arguments.js";
5
- import { projectAmbiguousError, projectNotFoundError } from "./resolution.js";
6
- import path from "node:path";
7
- import { Result, matchError } from "better-result";
8
- //#region src/lib/project/setup.ts
9
- function isValidProjectSetupName(projectName) {
10
- return projectName.trim().length > 0;
11
- }
12
- function validateProjectSetupNameText(value, fallback) {
13
- if ((value?.trim() || fallback).trim().length > 0) return;
14
- return "Enter a Project name.";
15
- }
16
- function resolveProjectForSetup(projectRef, projects, workspace) {
17
- const matches = projects.filter((project) => project.id === projectRef || project.name === projectRef);
18
- if (matches.length === 1) return matches[0];
19
- if (matches.length > 1) throw projectAmbiguousError(projectRef, matches);
20
- throw projectNotFoundError(projectRef, workspace);
21
- }
22
- async function bindProjectToDirectory(context, workspace, project, action, directory = context.runtime.cwd) {
23
- return Result.gen(async function* () {
24
- yield* Result.await(writeLocalResolutionPin(directory, {
25
- workspaceId: workspace.id,
26
- projectId: project.id
27
- }, context.runtime.signal));
28
- yield* Result.await(ensureLocalResolutionPinGitignore(directory, context.runtime.signal));
29
- return Result.ok({
30
- workspace,
31
- project,
32
- directory: formatSetupDirectory(directory, context),
33
- localPin: {
34
- path: LOCAL_RESOLUTION_PIN_RELATIVE_PATH,
35
- written: true
36
- },
37
- action
38
- });
39
- });
40
- }
41
- function projectDirectoryBindingErrorToCliError(error) {
42
- return matchError(error, {
43
- LocalResolutionPinSerializationError: (error) => {
44
- throw error;
45
- },
46
- LocalResolutionPinWriteAbortedError: (error) => {
47
- throw error;
48
- },
49
- LocalResolutionPinWriteFailedError: (error) => localStateWriteFailedError(error, {
50
- why: `The CLI could not write ${LOCAL_RESOLUTION_PIN_RELATIVE_PATH}.`,
51
- meta: {
52
- pinPath: error.pinPath,
53
- operation: error.operation
54
- }
55
- }),
56
- LocalResolutionPinGitignoreUpdateAbortedError: (error) => {
57
- throw error;
58
- },
59
- LocalResolutionPinGitignoreUpdateFailedError: (error) => localStateWriteFailedError(error, {
60
- why: "The CLI could not update .gitignore to keep local Project binding state out of git.",
61
- meta: {
62
- gitignorePath: error.gitignorePath,
63
- operation: error.operation
64
- }
65
- })
66
- });
67
- }
68
- function localStateWriteFailedError(error, options) {
69
- return new CliError({
70
- code: "LOCAL_STATE_WRITE_FAILED",
71
- domain: "project",
72
- summary: "Could not save local Project binding",
73
- why: options.why,
74
- fix: "Check that this directory is writable and that .prisma/local.json and .gitignore are not blocked by directories or permissions, then retry.",
75
- debug: formatDebugDetails(error.cause),
76
- meta: options.meta,
77
- exitCode: 1,
78
- nextSteps: ["prisma-cli project link <id-or-name>", "prisma-cli app deploy --project <id-or-name>"]
79
- });
80
- }
81
- function toProjectSummary(project) {
82
- return {
83
- id: project.id,
84
- name: project.name,
85
- ...project.url ? { url: project.url } : {}
86
- };
87
- }
88
- function projectSetupNameRequiredError(command) {
89
- return usageError("Project create requires a name", "The project name must be a non-empty value.", "Pass a Project name explicitly.", [`prisma-cli ${command} my-app`], "project");
90
- }
91
- function projectCreateFailedError(error, projectName, workspace, options) {
92
- const status = extractHttpStatus(error);
93
- if (status === 401 || status === 403) return new CliError({
94
- code: "PROJECT_CREATE_FAILED",
95
- domain: "project",
96
- summary: `Could not create Project "${projectName}"`,
97
- why: `The platform rejected the Project create in workspace "${workspace.name}" (HTTP ${status}).`,
98
- fix: options.permissionFix,
99
- debug: formatDebugDetails(error),
100
- exitCode: 1,
101
- nextSteps: options.nextSteps
102
- });
103
- return new CliError({
104
- code: "PROJECT_CREATE_FAILED",
105
- domain: "project",
106
- summary: `Could not create Project "${projectName}"`,
107
- why: error instanceof Error ? error.message : String(error),
108
- fix: options.fallbackFix,
109
- debug: formatDebugDetails(error),
110
- exitCode: 1,
111
- nextSteps: options.nextSteps
112
- });
113
- }
114
- function formatSetupDirectory(directory, context) {
115
- if (path.resolve(directory) !== path.resolve(context.runtime.cwd)) return shortenHomePath(directory, context.runtime.env);
116
- const basename = directory.split(/[\\/]/).filter(Boolean).pop();
117
- return basename ? `./${basename}` : ".";
118
- }
119
- function extractHttpStatus(error) {
120
- if (!error || typeof error !== "object") return null;
121
- const candidate = error;
122
- if (typeof candidate.statusCode === "number") return candidate.statusCode;
123
- if (typeof candidate.status === "number") return candidate.status;
124
- if (typeof candidate.message === "string") {
125
- const match = /\(HTTP (\d{3})\)/.exec(candidate.message);
126
- if (match) return Number.parseInt(match[1], 10);
127
- }
128
- return null;
129
- }
130
- function formatDebugDetails(error) {
131
- if (error instanceof Error) return error.stack ?? error.message;
132
- return typeof error === "string" ? error : null;
133
- }
134
- //#endregion
135
- export { bindProjectToDirectory, isValidProjectSetupName, projectCreateFailedError, projectDirectoryBindingErrorToCliError, projectSetupNameRequiredError, resolveProjectForSetup, toProjectSummary, validateProjectSetupNameText };
@@ -1,55 +0,0 @@
1
- import { CliError } from "../shell/errors.js";
2
- import { createRequire } from "node:module";
3
- import process from "node:process";
4
- //#region src/lib/version.ts
5
- const requireFromHere = createRequire(import.meta.url);
6
- function readPackageMetadata() {
7
- try {
8
- return requireFromHere("../../package.json");
9
- } catch {
10
- return {};
11
- }
12
- }
13
- function getCliVersion() {
14
- const pkg = readPackageMetadata();
15
- if (!pkg.version) throw new CliError({
16
- code: "VERSION_UNAVAILABLE",
17
- domain: "cli",
18
- summary: "CLI version metadata is missing from the installed package",
19
- why: "The bundled package.json could not be read or did not contain a version field.",
20
- fix: "Reinstall the CLI from the npm registry, or check your install path is intact.",
21
- exitCode: 1
22
- });
23
- return pkg.version;
24
- }
25
- function getCliName() {
26
- return "prisma-cli";
27
- }
28
- function detectInvocation(env, argv) {
29
- if (env.npm_config_user_agent?.startsWith("bun")) return "bunx";
30
- const normalizedExecPath = env.npm_execpath?.replace(/\\/g, "/").toLowerCase();
31
- const normalizedUserAgent = env.npm_config_user_agent?.toLowerCase();
32
- if (env.npm_lifecycle_event === "npx" || normalizedExecPath?.includes("/_npx/") || normalizedUserAgent?.includes("npx")) return "npx";
33
- const entry = (argv[1] ?? "").replace(/\\/g, "/").toLowerCase();
34
- if (entry.endsWith(".ts") || entry.includes("/tsx/")) return "dev";
35
- if (entry.includes("/_npx/")) return "npx";
36
- if (entry.includes("/.bun/")) return "bunx";
37
- if (entry.includes("/node_modules/.bin/") || /\/prisma-cli(\.cmd|\.exe)?$/.test(entry)) return "global";
38
- return "unknown";
39
- }
40
- function buildVersionResult(env, argv) {
41
- return {
42
- cli: {
43
- name: getCliName(),
44
- version: getCliVersion()
45
- },
46
- node: { version: process.version },
47
- os: {
48
- platform: process.platform,
49
- arch: process.arch
50
- },
51
- invocation: detectInvocation(env, argv)
52
- };
53
- }
54
- //#endregion
55
- export { buildVersionResult, getCliName, getCliVersion };
@@ -1,90 +0,0 @@
1
- import { formatDescriptorLabel } from "../shell/command-meta.js";
2
- import { maskValue, padDisplay, renderSummaryLine } from "../shell/ui.js";
3
- import stringWidth from "string-width";
4
- //#region src/output/patterns.ts
5
- function renderList(input, ui) {
6
- const keyWidth = Math.max(stringWidth(`${input.parentContext.key}:`), ...input.items.map((item) => stringWidth(`⚬ ${item.noun}:`)), ...readMoreWidth(input.descriptor));
7
- const lines = renderCardTitle(input.descriptor, input.title, ui);
8
- lines.push(renderCardRow(ui, keyWidth, input.parentContext.key, input.parentContext.value));
9
- if (input.items.length === 0) lines.push(renderPlainCardLine(ui, ui.dim(input.emptyMessage)));
10
- else for (const item of input.items) lines.push(renderCardRow(ui, keyWidth, `⚬ ${item.noun}`, formatListItemValue(ui, item)));
11
- pushReadMore(lines, ui, keyWidth, input.descriptor);
12
- return lines;
13
- }
14
- function serializeList(input) {
15
- return {
16
- context: input.context,
17
- items: input.items.map((item) => ({
18
- name: item.label,
19
- id: item.id,
20
- status: item.status
21
- })),
22
- count: input.items.length
23
- };
24
- }
25
- function renderShow(input, ui) {
26
- const keyWidth = Math.max(0, ...input.fields.map((field) => stringWidth(`${field.key}:`)), ...readMoreWidth(input.descriptor));
27
- const lines = renderCardTitle(input.descriptor, input.title, ui);
28
- for (const field of input.fields) lines.push(renderCardRow(ui, keyWidth, field.key, formatValue(ui, field.value, field.tone, field.sensitive)));
29
- pushReadMore(lines, ui, keyWidth, input.descriptor);
30
- return lines;
31
- }
32
- function renderMutate(input, ui) {
33
- const rows = input.context;
34
- const keyWidth = Math.max(0, ...rows.map((row) => stringWidth(`${row.key}:`)), ...readMoreWidth(input.descriptor));
35
- const lines = renderCardTitle(input.descriptor, input.title, ui);
36
- for (const row of rows) lines.push(renderCardRow(ui, keyWidth, row.key, formatValue(ui, row.value, row.tone, row.sensitive)));
37
- pushReadMore(lines, ui, keyWidth, input.descriptor);
38
- lines.push("");
39
- lines.push(`${ui.warning("◇")} ${input.operationDescription}...`);
40
- lines.push(renderSummaryLine(ui, "success", `Applied ${input.operationCount} operation(s)`));
41
- for (const detail of input.details) lines.push(` ${detail}`);
42
- for (const alert of input.alerts ?? []) {
43
- lines.push("");
44
- lines.push(renderSummaryLine(ui, alert.tone, alert.text));
45
- }
46
- return lines;
47
- }
48
- function renderCardTitle(descriptor, title, ui) {
49
- return [`${ui.strong(formatDescriptorLabel(descriptor))} ${ui.dim("→")} ${ui.dim(title)}`, ""];
50
- }
51
- function renderCardRow(ui, keyWidth, key, value) {
52
- return `${renderCardRail(ui)} ${ui.accent(padDisplay(`${key}:`, keyWidth))} ${value}`;
53
- }
54
- function renderPlainCardLine(ui, text) {
55
- return `${renderCardRail(ui)} ${text}`;
56
- }
57
- function renderCardDivider(ui) {
58
- return renderCardRail(ui);
59
- }
60
- function readMoreWidth(descriptor) {
61
- return descriptor.docsPath ? [stringWidth("Read more")] : [];
62
- }
63
- function pushReadMore(lines, ui, keyWidth, descriptor) {
64
- if (!descriptor.docsPath) return;
65
- lines.push(renderCardDivider(ui));
66
- lines.push(`${renderCardRail(ui)} ${ui.accent(padDisplay("Read more", keyWidth))} ${ui.link(descriptor.docsPath)}`);
67
- }
68
- function renderCardRail(ui) {
69
- return ui.dim("│");
70
- }
71
- function formatListItemValue(ui, item) {
72
- const annotation = renderAnnotation(ui, item.status);
73
- return annotation ? `${item.label} ${annotation}` : item.label;
74
- }
75
- function renderAnnotation(ui, status) {
76
- if (status === "active") return ui.success("(active)");
77
- if (status === "default") return ui.dim("(default)");
78
- return "";
79
- }
80
- function formatValue(ui, value, tone = "default", sensitive = false) {
81
- const resolvedValue = sensitive ? maskValue(value) : value;
82
- if (tone === "success") return ui.success(resolvedValue);
83
- if (tone === "warning") return ui.warning(resolvedValue);
84
- if (tone === "error") return ui.error(resolvedValue);
85
- if (tone === "link") return ui.link(resolvedValue);
86
- if (tone === "dim") return ui.dim(resolvedValue);
87
- return resolvedValue;
88
- }
89
- //#endregion
90
- export { renderList, renderMutate, renderShow, serializeList };
@@ -1,265 +0,0 @@
1
- import { renderVerboseBlock } from "../shell/ui.js";
2
- import { renderList, renderShow, serializeList } from "../output/patterns.js";
3
- import { renderResolvedProjectContextBlock, stripVerboseContext } from "./verbose-context.js";
4
- //#region src/presenters/app-env.ts
5
- function scopeLabel(scope) {
6
- if (scope.kind === "role") return scope.role ?? "unknown";
7
- if (scope.kind === "overview") return "overview";
8
- return `branch:${scope.branchName ?? scope.branchId ?? "unknown"}`;
9
- }
10
- function listTargetLabel(result) {
11
- const target = result.target;
12
- if (target.source === "overview") return "overview";
13
- if (target.branchName) {
14
- const suffix = target.branchExists === false ? " (not created yet)" : "";
15
- return `branch:${target.branchName} -> ${target.envMap}${suffix}`;
16
- }
17
- return scopeLabel(result.scope);
18
- }
19
- function renderEnvVerboseBlocks(context, result) {
20
- return [...renderEnvResolvedContextBlock(context, result.verboseContext), ...renderEnvTargetBlock(context, result)];
21
- }
22
- function renderEnvResolvedContextBlock(context, verboseContext) {
23
- return renderResolvedProjectContextBlock(context.ui, verboseContext);
24
- }
25
- function renderEnvTargetBlock(context, result) {
26
- return renderVerboseBlock(context.ui, envTargetRows(result), { title: "Env target" });
27
- }
28
- function envTargetRows(result) {
29
- return [
30
- {
31
- key: "project id",
32
- value: result.projectId,
33
- tone: "dim"
34
- },
35
- {
36
- key: "scope",
37
- value: scopeLabel(result.scope)
38
- },
39
- ...envListTargetRows(result),
40
- ...envFileRows(result),
41
- {
42
- key: "keys",
43
- value: formatKeyNames(envResultKeys(result)),
44
- tone: envResultKeys(result).length > 0 ? "default" : "dim"
45
- }
46
- ];
47
- }
48
- function envListTargetRows(result) {
49
- if (!("target" in result)) return [];
50
- return [
51
- {
52
- key: "target source",
53
- value: result.target.source
54
- },
55
- {
56
- key: "env map",
57
- value: result.target.envMap
58
- },
59
- ...result.target.branchName ? [{
60
- key: "branch",
61
- value: result.target.branchName
62
- }] : [],
63
- ...result.target.branchId ? [{
64
- key: "branch id",
65
- value: result.target.branchId,
66
- tone: "dim"
67
- }] : [],
68
- ...result.target.branchExists === false ? [{
69
- key: "branch state",
70
- value: "not created yet",
71
- tone: "warning"
72
- }] : []
73
- ];
74
- }
75
- function envFileRows(result) {
76
- if (!("file" in result) || !result.file) return [];
77
- return [{
78
- key: "file",
79
- value: result.file.path
80
- }, {
81
- key: "file count",
82
- value: String(result.file.count)
83
- }];
84
- }
85
- function envResultKeys(result) {
86
- if ("variables" in result && result.variables) return result.variables.map((variable) => variable.key).sort((left, right) => left.localeCompare(right));
87
- if ("variable" in result && result.variable) return [result.variable.key];
88
- if ("key" in result) return [result.key];
89
- return [];
90
- }
91
- function formatKeyNames(keys) {
92
- return keys.length > 0 ? keys.join(", ") : "none";
93
- }
94
- function renderEnvAdd(context, descriptor, result) {
95
- if (result.variables !== void 0) {
96
- const lines = renderList({
97
- title: "Setting new environment variables from file.",
98
- descriptor,
99
- parentContext: {
100
- key: "target",
101
- value: `${scopeLabel(result.scope)} from ${result.file.path}`
102
- },
103
- items: result.variables.map((variable) => ({
104
- noun: "variable",
105
- label: `${variable.key} (${variable.source})`,
106
- id: variable.id,
107
- status: variable.isManagedBySystem ? "default" : null
108
- })),
109
- emptyMessage: "No environment variables imported."
110
- }, context.ui);
111
- lines.push(...renderEnvVerboseBlocks(context, result));
112
- return lines;
113
- }
114
- const lines = renderShow({
115
- title: "Setting a new environment variable.",
116
- descriptor,
117
- fields: [
118
- {
119
- key: "project",
120
- value: result.projectId
121
- },
122
- {
123
- key: "scope",
124
- value: scopeLabel(result.scope)
125
- },
126
- {
127
- key: "key",
128
- value: result.variable.key
129
- },
130
- {
131
- key: "id",
132
- value: result.variable.id,
133
- tone: "dim"
134
- },
135
- {
136
- key: "last updated",
137
- value: result.variable.updatedAt,
138
- tone: "dim"
139
- }
140
- ]
141
- }, context.ui);
142
- lines.push(...renderEnvVerboseBlocks(context, result));
143
- return lines;
144
- }
145
- function serializeEnvAdd(result) {
146
- return stripVerboseContext(result);
147
- }
148
- function renderEnvUpdate(context, descriptor, result) {
149
- if (result.variables !== void 0) {
150
- const lines = renderList({
151
- title: "Replacing environment variable values from file.",
152
- descriptor,
153
- parentContext: {
154
- key: "target",
155
- value: `${scopeLabel(result.scope)} from ${result.file.path}`
156
- },
157
- items: result.variables.map((variable) => ({
158
- noun: "variable",
159
- label: `${variable.key} (${variable.source})`,
160
- id: variable.id,
161
- status: variable.isManagedBySystem ? "default" : null
162
- })),
163
- emptyMessage: "No environment variables updated."
164
- }, context.ui);
165
- lines.push(...renderEnvVerboseBlocks(context, result));
166
- return lines;
167
- }
168
- const lines = renderShow({
169
- title: "Replacing the environment variable's value.",
170
- descriptor,
171
- fields: [
172
- {
173
- key: "project",
174
- value: result.projectId
175
- },
176
- {
177
- key: "scope",
178
- value: scopeLabel(result.scope)
179
- },
180
- {
181
- key: "key",
182
- value: result.variable.key
183
- },
184
- {
185
- key: "id",
186
- value: result.variable.id,
187
- tone: "dim"
188
- },
189
- {
190
- key: "last updated",
191
- value: result.variable.updatedAt,
192
- tone: "dim"
193
- }
194
- ]
195
- }, context.ui);
196
- lines.push(...renderEnvVerboseBlocks(context, result));
197
- return lines;
198
- }
199
- function serializeEnvUpdate(result) {
200
- return stripVerboseContext(result);
201
- }
202
- function renderEnvList(context, descriptor, result) {
203
- const lines = renderList({
204
- title: "Listing environment variables for the selected scope.",
205
- descriptor,
206
- parentContext: {
207
- key: "target",
208
- value: listTargetLabel(result)
209
- },
210
- items: result.variables.map((variable) => ({
211
- noun: "variable",
212
- label: `${variable.key} (${variable.source})`,
213
- id: variable.id,
214
- status: variable.isManagedBySystem ? "default" : null
215
- })),
216
- emptyMessage: "No environment variables defined in this scope."
217
- }, context.ui);
218
- lines.push(...renderEnvVerboseBlocks(context, result));
219
- return lines;
220
- }
221
- function serializeEnvList(result) {
222
- const serializable = stripVerboseContext(result);
223
- return {
224
- projectId: serializable.projectId,
225
- scope: serializable.scope,
226
- target: serializable.target,
227
- ...serializeList({
228
- context: { target: listTargetLabel(serializable) },
229
- items: serializable.variables.map((variable) => ({
230
- noun: "variable",
231
- label: `${variable.key} (${variable.source})`,
232
- id: variable.id,
233
- status: variable.isManagedBySystem ? "default" : null
234
- }))
235
- }),
236
- variables: serializable.variables
237
- };
238
- }
239
- function renderEnvRm(context, descriptor, result) {
240
- const lines = renderShow({
241
- title: "Removing the environment variable from the scope.",
242
- descriptor,
243
- fields: [
244
- {
245
- key: "project",
246
- value: result.projectId
247
- },
248
- {
249
- key: "scope",
250
- value: scopeLabel(result.scope)
251
- },
252
- {
253
- key: "key",
254
- value: result.key
255
- }
256
- ]
257
- }, context.ui);
258
- lines.push(...renderEnvVerboseBlocks(context, result));
259
- return lines;
260
- }
261
- function serializeEnvRm(result) {
262
- return stripVerboseContext(result);
263
- }
264
- //#endregion
265
- export { renderEnvAdd, renderEnvList, renderEnvRm, renderEnvUpdate, serializeEnvAdd, serializeEnvList, serializeEnvRm, serializeEnvUpdate };