@supersdk/supercli 0.3.2-staging.42 → 0.3.2-staging.44
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/build/artifactIntegrity.js +119 -0
- package/dist/build/artifactIntegrity.js.map +1 -0
- package/dist/cli.js +22 -11
- package/dist/cli.js.map +1 -1
- package/dist/commands/add.js +79 -31
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/analytics.js +15 -9
- package/dist/commands/analytics.js.map +1 -1
- package/dist/commands/build.js +231 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/config.js +170 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/db.js +24 -19
- package/dist/commands/db.js.map +1 -1
- package/dist/commands/deploy.js +434 -751
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/env.js +8 -8
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/image.js +31 -20
- package/dist/commands/image.js.map +1 -1
- package/dist/commands/init.js +68 -37
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/logs.js +16 -7
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/publishSite.js +28 -943
- package/dist/commands/publishSite.js.map +1 -1
- package/dist/commands/register.js +51 -30
- package/dist/commands/register.js.map +1 -1
- package/dist/commands/settings.js +10 -6
- package/dist/commands/settings.js.map +1 -1
- package/dist/config/appConfig.js +40 -36
- package/dist/config/appConfig.js.map +1 -1
- package/dist/config/superConfig.js +429 -0
- package/dist/config/superConfig.js.map +1 -0
- package/dist/deploy/adapterTypes.js +3 -0
- package/dist/deploy/adapterTypes.js.map +1 -0
- package/dist/deploy/manifest.js +381 -0
- package/dist/deploy/manifest.js.map +1 -0
- package/dist/deploy/preflight.js +202 -0
- package/dist/deploy/preflight.js.map +1 -0
- package/dist/deploy/resultWriter.js +178 -0
- package/dist/deploy/resultWriter.js.map +1 -0
- package/dist/deploy/runAdapter.js +299 -0
- package/dist/deploy/runAdapter.js.map +1 -0
- package/dist/deploy/siteAdapter.js +182 -0
- package/dist/deploy/siteAdapter.js.map +1 -0
- package/dist/docker/dockerCli.js +63 -1
- package/dist/docker/dockerCli.js.map +1 -1
- package/dist/output/envelope.js +5 -1
- package/dist/output/envelope.js.map +1 -1
- package/dist/output/resultPrinter.js +3 -0
- package/dist/output/resultPrinter.js.map +1 -1
- package/dist/publish/responseClassifier.js +4 -4
- package/dist/publish/responseClassifier.js.map +1 -1
- package/dist/publish/runClient.js +11 -11
- package/dist/publish/runClient.js.map +1 -1
- package/dist/publish/siteZip.js +4 -5
- package/dist/publish/siteZip.js.map +1 -1
- package/dist/template/README.md +64 -227
- package/dist/template/android/app/src/main/java/com/supersdk/simple/EnvironmentStore.java +1 -1
- package/dist/template/android/app/src/main/java/com/supersdk/simple/SimpleApplication.java +2 -2
- package/dist/template/android/gradle/supersdk-config-reader.gradle +6 -5
- package/dist/template/android/supersdk-default.config.json +4 -3
- package/dist/template/ios/Sources/App/AppDelegate.swift +1 -1
- package/dist/template/ios/Sources/App/SimpleSDKBootstrap.swift +1 -1
- package/dist/template/scripts/build_android.sh +26 -10
- package/dist/template/scripts/build_ios.sh +41 -9
- package/dist/template/scripts/build_service.sh +89 -0
- package/dist/template/scripts/build_site.sh +40 -26
- package/dist/template/scripts/lib/workspace.sh +4 -4
- package/dist/template/scripts/serve_web.py +2 -4
- package/dist/template/scripts/super_build_orchestrator.py +278 -355
- package/dist/template/scripts/supersdk_template.py +415 -182
- package/dist/template/scripts/web_package.py +9 -8
- package/dist/template/service/Dockerfile +2 -0
- package/dist/template/{supersdk.json → super.json} +21 -2
- package/dist/template/super_build.sh +39 -113
- package/dist/template/template_manifest.json +5 -4
- package/dist/workspace/config.js +81 -119
- package/dist/workspace/config.js.map +1 -1
- package/dist/workspace/identity.js +15 -14
- package/dist/workspace/identity.js.map +1 -1
- package/dist/workspace/inspect.js +1 -0
- package/dist/workspace/inspect.js.map +1 -1
- package/dist/workspace/projectContext.js +93 -0
- package/dist/workspace/projectContext.js.map +1 -0
- package/dist/workspace/projectIdentity.js +53 -96
- package/dist/workspace/projectIdentity.js.map +1 -1
- package/dist/workspace/template.js +5 -8
- package/dist/workspace/template.js.map +1 -1
- package/package.json +2 -2
- package/dist/publish/siteConfig.js +0 -649
- package/dist/publish/siteConfig.js.map +0 -1
package/dist/commands/deploy.js
CHANGED
|
@@ -33,45 +33,29 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
37
|
-
exports.
|
|
38
|
-
exports.
|
|
39
|
-
exports.isNonRootRejection = isNonRootRejection;
|
|
40
|
-
exports.extractLogLines = extractLogLines;
|
|
41
|
-
exports.runDeploy = runDeploy;
|
|
36
|
+
exports.defaultUnifiedDeployDeps = exports.parseEnvAssignment = void 0;
|
|
37
|
+
exports.runUnifiedDeploy = runUnifiedDeploy;
|
|
38
|
+
exports.emitUnifiedDeployResult = emitUnifiedDeployResult;
|
|
42
39
|
exports.registerDeployCommand = registerDeployCommand;
|
|
43
|
-
// `supercli deploy` — one command from a Dockerfile to a running, addressable
|
|
44
|
-
// container service (CA-F260810034335 · AC-2 / AC-5 / AC-9 / AC-16 / AC-17).
|
|
45
|
-
//
|
|
46
|
-
// The shape is a deliberate copy of publishSite.ts, because that command is this
|
|
47
|
-
// repo's settled answer to "what does an agent-callable CLI command look like":
|
|
48
|
-
//
|
|
49
|
-
// local validation → path existence → auth (env token wins) → org
|
|
50
|
-
// → dry-run returns here (validate only, no image pushed, nothing written)
|
|
51
|
-
// → build + push (skippable with a digest-pinned --image)
|
|
52
|
-
// → create the service with an idempotency key
|
|
53
|
-
// → poll/report readiness; on failure, pull the last N startup log lines
|
|
54
|
-
//
|
|
55
|
-
// Everything the user sees goes through ResultPrinter, so `--output json` emits
|
|
56
|
-
// exactly one envelope line on stdout while docker's build output — which is
|
|
57
|
-
// long, noisy, and produced by a program we do not control — is confined to
|
|
58
|
-
// stderr (see docker/dockerCli.ts).
|
|
59
|
-
const crypto = __importStar(require("node:crypto"));
|
|
60
|
-
const fs = __importStar(require("node:fs"));
|
|
61
40
|
const path = __importStar(require("node:path"));
|
|
62
41
|
const consoleClient_1 = require("../api/consoleClient");
|
|
63
42
|
const tokenAuth_1 = require("../auth/tokenAuth");
|
|
64
43
|
const environments_1 = require("../config/environments");
|
|
65
|
-
const
|
|
44
|
+
const superConfig_1 = require("../config/superConfig");
|
|
45
|
+
const preflight_1 = require("../deploy/preflight");
|
|
46
|
+
const resultWriter_1 = require("../deploy/resultWriter");
|
|
47
|
+
const runAdapter_1 = require("../deploy/runAdapter");
|
|
48
|
+
const siteAdapter_1 = require("../deploy/siteAdapter");
|
|
66
49
|
const registry_1 = require("../docker/registry");
|
|
67
50
|
const resultPrinter_1 = require("../output/resultPrinter");
|
|
68
|
-
const orgResolve_1 = require("../publish/orgResolve");
|
|
69
|
-
const runClient_1 = require("../publish/runClient");
|
|
70
51
|
const accountStore_1 = require("../store/accountStore");
|
|
71
52
|
const credentialStore_1 = require("../store/credentialStore");
|
|
72
53
|
const log_1 = require("../util/log");
|
|
73
54
|
const prompt_1 = require("../util/prompt");
|
|
74
|
-
|
|
55
|
+
// Security-oriented public parser retained for the registered name-only
|
|
56
|
+
// `--secret` flag. It is the same implementation used by deploy preflight.
|
|
57
|
+
var preflight_2 = require("../deploy/preflight");
|
|
58
|
+
Object.defineProperty(exports, "parseEnvAssignment", { enumerable: true, get: function () { return preflight_2.parseRuntimeAssignment; } });
|
|
75
59
|
function resolveBackend(account) {
|
|
76
60
|
return (0, credentialStore_1.backendForAccount)(account.backend, {
|
|
77
61
|
passphraseProvider: account.backend === 'encrypted-file'
|
|
@@ -79,193 +63,96 @@ function resolveBackend(account) {
|
|
|
79
63
|
: undefined,
|
|
80
64
|
});
|
|
81
65
|
}
|
|
82
|
-
exports.
|
|
66
|
+
exports.defaultUnifiedDeployDeps = {
|
|
67
|
+
resolveConfig: superConfig_1.resolveSuperConfig,
|
|
68
|
+
preflight: preflight_1.preflightDeploy,
|
|
69
|
+
createWriter: resultWriter_1.createDeployResultWriter,
|
|
70
|
+
deploySite: (input) => (0, siteAdapter_1.deploySite)(input),
|
|
71
|
+
deployRun: (input) => (0, runAdapter_1.deployRun)(input),
|
|
83
72
|
getCurrentAccount: accountStore_1.getCurrentAccount,
|
|
84
73
|
getStoredToken: (account) => resolveBackend(account).get(account.accountKey)?.token ?? null,
|
|
85
74
|
markNeedsLogin: accountStore_1.markAccountNeedsLogin,
|
|
86
75
|
fetchWhoami: (apiOrigin, token) => new consoleClient_1.ConsoleClient(apiOrigin).whoami(token),
|
|
87
|
-
createRunClient: (apiOrigin) => new runClient_1.RunClient(apiOrigin),
|
|
88
|
-
docker: dockerCli_1.defaultDockerFacade,
|
|
89
|
-
statPath: (target) => {
|
|
90
|
-
try {
|
|
91
|
-
const stat = fs.statSync(target);
|
|
92
|
-
if (stat.isDirectory())
|
|
93
|
-
return 'dir';
|
|
94
|
-
if (stat.isFile())
|
|
95
|
-
return 'file';
|
|
96
|
-
return 'other';
|
|
97
|
-
}
|
|
98
|
-
catch {
|
|
99
|
-
return 'missing';
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
sleep: (ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
|
103
|
-
pollAttempts: 40,
|
|
104
|
-
pollIntervalMs: 3_000,
|
|
105
76
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
/** Mirrors `validate_run_slug` (CA): the container and static-site name pools are the same one. */
|
|
110
|
-
const SLUG_PATTERN = /^[a-z0-9]{1,32}$/;
|
|
111
|
-
const RESERVED_SLUGS = new Set(['stg', 'site']);
|
|
112
|
-
const SPID_PATTERN = /^[a-z0-9]{8}$/;
|
|
113
|
-
const ENV_PATTERN = /^[a-z0-9]{1,10}$/;
|
|
114
|
-
/** Mirrors `validate_env_key` (CA). */
|
|
115
|
-
const ENV_KEY_PATTERN = /^[A-Z_][A-Z0-9_]{0,127}$/;
|
|
116
|
-
const SPEC_LIMITS = {
|
|
117
|
-
port: { min: 1, max: 65_535, def: 8080 },
|
|
118
|
-
cpu: { min: 1, max: 4_000, def: undefined },
|
|
119
|
-
memory: { min: 1, max: 8_192, def: undefined },
|
|
120
|
-
maxScale: { min: 1, max: 10, def: undefined },
|
|
121
|
-
};
|
|
122
|
-
/** Digest of the not-yet-built image, used ONLY to let a dry-run reach the server's validator. */
|
|
123
|
-
const PLACEHOLDER_DIGEST = `sha256:${'0'.repeat(64)}`;
|
|
124
|
-
function trimFlag(value) {
|
|
125
|
-
const trimmed = value?.trim();
|
|
126
|
-
return trimmed ? trimmed : undefined;
|
|
77
|
+
function trim(value) {
|
|
78
|
+
const normalized = value?.trim();
|
|
79
|
+
return normalized ? normalized : undefined;
|
|
127
80
|
}
|
|
128
|
-
function
|
|
129
|
-
|
|
130
|
-
if (trimmed === undefined)
|
|
131
|
-
return { ok: true, value: undefined };
|
|
132
|
-
if (!/^[0-9]+$/.test(trimmed))
|
|
133
|
-
return { ok: false, message: `invalid ${flag}: must be a whole number` };
|
|
134
|
-
const value = Number(trimmed);
|
|
135
|
-
if (value < limits.min || value > limits.max) {
|
|
136
|
-
return { ok: false, message: `invalid ${flag}: must be in ${limits.min}..${limits.max}` };
|
|
137
|
-
}
|
|
138
|
-
return { ok: true, value };
|
|
81
|
+
function record(value) {
|
|
82
|
+
return value !== null && typeof value === 'object' ? value : undefined;
|
|
139
83
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
* `test/unit/util/log.test.ts` (TC-27) enforces across the whole command
|
|
148
|
-
* surface. So a secret rides in the environment and the command line carries
|
|
149
|
-
* only its NAME. Nothing about the non-interactive story is lost: a CI runner
|
|
150
|
-
* already holds its secrets as environment variables.
|
|
151
|
-
*/
|
|
152
|
-
function parseEnvAssignment(entry, flag, opts = { allowInlineValue: true }) {
|
|
153
|
-
const separator = entry.indexOf('=');
|
|
154
|
-
const key = (separator === -1 ? entry : entry.slice(0, separator)).trim();
|
|
155
|
-
if (!ENV_KEY_PATTERN.test(key)) {
|
|
156
|
-
// 🔴 Only the key is ever echoed — never the value (CR-4 discipline, CLI half).
|
|
157
|
-
return { ok: false, message: `invalid ${flag} name "${key}": must match ^[A-Z_][A-Z0-9_]{0,127}$` };
|
|
158
|
-
}
|
|
159
|
-
if (separator !== -1 && !opts.allowInlineValue) {
|
|
160
|
-
return {
|
|
161
|
-
ok: false,
|
|
162
|
-
message: `${flag} takes a NAME, not a value: write \`${flag} ${key}\` and export ${key} in the environment first. ` +
|
|
163
|
-
'a value written on the command line is visible to every process on this machine and is recorded in shell ' +
|
|
164
|
-
'history and CI logs (use --env-var for values that are not secret)',
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
if (separator === -1) {
|
|
168
|
-
const fromEnv = process.env[key];
|
|
169
|
-
if (fromEnv === undefined) {
|
|
170
|
-
const inlineHint = opts.allowInlineValue ? `pass ${flag} ${key}=<value>, or ` : '';
|
|
171
|
-
return { ok: false, message: `${flag} ${key} has no value: ${inlineHint}export ${key} in the environment first` };
|
|
172
|
-
}
|
|
173
|
-
return { ok: true, key, value: fromEnv };
|
|
84
|
+
function failureKind(kind) {
|
|
85
|
+
switch (kind) {
|
|
86
|
+
case 'forbidden': return 'forbidden';
|
|
87
|
+
case 'rate_limited': return 'rate_limited';
|
|
88
|
+
case 'infra_error': return 'infra_error';
|
|
89
|
+
case 'auth_invalid': return 'auth_invalid';
|
|
90
|
+
default: return 'business_error';
|
|
174
91
|
}
|
|
175
|
-
return { ok: true, key, value: entry.slice(separator + 1) };
|
|
176
92
|
}
|
|
177
|
-
function
|
|
178
|
-
const
|
|
179
|
-
const
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
{ entries: opts.secret ?? [], flag: '--secret', secret: true },
|
|
183
|
-
];
|
|
184
|
-
for (const group of groups) {
|
|
185
|
-
for (const entry of group.entries) {
|
|
186
|
-
const parsed = parseEnvAssignment(entry, group.flag, { allowInlineValue: !group.secret });
|
|
187
|
-
if (!parsed.ok)
|
|
188
|
-
return parsed;
|
|
189
|
-
if (seen.has(parsed.key)) {
|
|
190
|
-
return { ok: false, message: `duplicate environment variable ${parsed.key}: declare each key once` };
|
|
191
|
-
}
|
|
192
|
-
seen.add(parsed.key);
|
|
193
|
-
vars.push({ key: parsed.key, value: parsed.value, is_secret: group.secret });
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return { ok: true, vars };
|
|
93
|
+
function projectVersion(config, project) {
|
|
94
|
+
const fromProject = record(project.version)?.name;
|
|
95
|
+
const fromWorkspace = record(config.document.version)?.name;
|
|
96
|
+
const selected = typeof fromProject === 'string' ? fromProject : typeof fromWorkspace === 'string' ? fromWorkspace : undefined;
|
|
97
|
+
return selected && /^\d+\.\d+\.\d+$/.test(selected) ? selected : undefined;
|
|
197
98
|
}
|
|
198
|
-
function
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
99
|
+
function resultInputIdentity(config, envTarget, projectId) {
|
|
100
|
+
return {
|
|
101
|
+
configPath: path.resolve(config.path),
|
|
102
|
+
configSha256: config.digest,
|
|
103
|
+
spid: config.spid,
|
|
104
|
+
...(projectId ? { projectId } : {}),
|
|
105
|
+
envTarget,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function publicDeployResult(writer, deploy) {
|
|
109
|
+
return {
|
|
110
|
+
resultPath: writer.resultPath,
|
|
111
|
+
deploy,
|
|
112
|
+
configPath: deploy.configPath,
|
|
113
|
+
spid: deploy.spid,
|
|
114
|
+
envTarget: deploy.envTarget,
|
|
115
|
+
...(deploy.projectId ? { projectId: deploy.projectId } : {}),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function parseLogTail(raw) {
|
|
119
|
+
const normalized = typeof raw === 'string' ? raw.trim() : undefined;
|
|
120
|
+
if (normalized !== undefined && !/^[0-9]+$/.test(normalized)) {
|
|
121
|
+
return { ok: false, message: '--log-tail must be a whole number from 1 through 2000' };
|
|
207
122
|
}
|
|
208
|
-
const value =
|
|
209
|
-
if (!value) {
|
|
210
|
-
return { ok: false, message: '--
|
|
123
|
+
const value = raw === undefined ? 50 : typeof raw === 'number' ? raw : Number(normalized);
|
|
124
|
+
if (!Number.isSafeInteger(value) || value < 1 || value > 2_000) {
|
|
125
|
+
return { ok: false, message: '--log-tail must be a whole number from 1 through 2000' };
|
|
211
126
|
}
|
|
212
127
|
return { ok: true, value };
|
|
213
128
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
function terminalResult() {
|
|
224
|
-
return { ok: false, kind: 'needs_login', message: 'credentials are no longer valid — run `supercli login` again' };
|
|
225
|
-
}
|
|
226
|
-
function failureKind(kind) {
|
|
227
|
-
switch (kind) {
|
|
228
|
-
case 'forbidden':
|
|
229
|
-
return 'forbidden';
|
|
230
|
-
case 'rate_limited':
|
|
231
|
-
return 'rate_limited';
|
|
232
|
-
case 'infra_error':
|
|
233
|
-
return 'infra_error';
|
|
234
|
-
case 'auth_invalid':
|
|
235
|
-
return 'auth_invalid';
|
|
236
|
-
default:
|
|
237
|
-
return 'business_error';
|
|
129
|
+
function preflightFailureResult(writer, config, envTarget, preflight, projectId) {
|
|
130
|
+
let deploy;
|
|
131
|
+
try {
|
|
132
|
+
deploy = writer.finalize({
|
|
133
|
+
...resultInputIdentity(config, envTarget, projectId),
|
|
134
|
+
buildManifestSha256: preflight.buildManifestSha256,
|
|
135
|
+
overallStatus: 'failed',
|
|
136
|
+
projects: preflight.projects,
|
|
137
|
+
});
|
|
238
138
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
return `${outcome.message} — too many requests; retry later`;
|
|
248
|
-
case 'infra_error':
|
|
249
|
-
return `${context} failed: ${outcome.message}`;
|
|
250
|
-
default:
|
|
251
|
-
return `${context} failed`;
|
|
139
|
+
catch (error) {
|
|
140
|
+
return {
|
|
141
|
+
ok: false,
|
|
142
|
+
kind: 'infra_error',
|
|
143
|
+
publicCode: 'DEPLOY_RESULT_WRITE_FAILED',
|
|
144
|
+
message: `deploy result could not be written: ${error.message}; invocation ${writer.invocationId}`,
|
|
145
|
+
invocationId: writer.invocationId,
|
|
146
|
+
};
|
|
252
147
|
}
|
|
148
|
+
return {
|
|
149
|
+
ok: false,
|
|
150
|
+
kind: 'business_error',
|
|
151
|
+
publicCode: preflight.publicCode ?? 'ARTIFACT_INTEGRITY_FAILED',
|
|
152
|
+
message: `${preflight.message ?? 'deploy preflight failed'}; deploy result: ${writer.resultPath}`,
|
|
153
|
+
result: publicDeployResult(writer, deploy),
|
|
154
|
+
};
|
|
253
155
|
}
|
|
254
|
-
function valueFromOutcome(outcome) {
|
|
255
|
-
if (outcome.kind === 'success')
|
|
256
|
-
return outcome.data;
|
|
257
|
-
if (outcome.kind === 'soft_success')
|
|
258
|
-
return outcome.resource;
|
|
259
|
-
return undefined;
|
|
260
|
-
}
|
|
261
|
-
function asRecord(value) {
|
|
262
|
-
return value !== null && typeof value === 'object' ? value : undefined;
|
|
263
|
-
}
|
|
264
|
-
function stringField(value, key) {
|
|
265
|
-
const field = asRecord(value)?.[key];
|
|
266
|
-
return typeof field === 'string' && field.length > 0 ? field : undefined;
|
|
267
|
-
}
|
|
268
|
-
/** Resolves the effective token + apiOrigin (env token wins — a clean CI machine needs no keyring). */
|
|
269
156
|
function resolveAuth(deps) {
|
|
270
157
|
const envToken = (0, tokenAuth_1.resolveEnvToken)();
|
|
271
158
|
if (envToken)
|
|
@@ -273,611 +160,407 @@ function resolveAuth(deps) {
|
|
|
273
160
|
const account = deps.getCurrentAccount();
|
|
274
161
|
if (!account)
|
|
275
162
|
return { ok: false, kind: 'needs_login', message: 'no account is logged in — run `supercli login` first' };
|
|
276
|
-
const
|
|
277
|
-
if (!
|
|
163
|
+
const token = deps.getStoredToken(account);
|
|
164
|
+
if (!token) {
|
|
278
165
|
deps.markNeedsLogin(account.accountKey);
|
|
279
166
|
return { ok: false, kind: 'needs_login', message: 'no valid credential found locally — run `supercli login` again' };
|
|
280
167
|
}
|
|
281
|
-
return { token
|
|
282
|
-
}
|
|
283
|
-
// ---------------------------------------------------------------------------
|
|
284
|
-
// AC-16: docker is missing → say what to do instead, never just die
|
|
285
|
-
// ---------------------------------------------------------------------------
|
|
286
|
-
/**
|
|
287
|
-
* The downgrade path, spelled out. `deploy` cannot build without a daemon, but
|
|
288
|
-
* "cannot build" is NOT "cannot deploy": an image that is already in the registry
|
|
289
|
-
* can be deployed by digest with zero local docker involvement (AC-2), and that
|
|
290
|
-
* is the option a CI runner or an AI agent on a docker-less box actually needs to
|
|
291
|
-
* be told about.
|
|
292
|
-
*/
|
|
293
|
-
function dockerUnavailableMessage(probe, opts) {
|
|
294
|
-
const headline = probe.reason === 'not-installed'
|
|
295
|
-
? `no docker CLI available (${probe.detail}) — nothing was built and nothing was deployed.`
|
|
296
|
-
: `the docker daemon did not answer (${probe.detail}) — nothing was built and nothing was deployed.`;
|
|
297
|
-
const rerun = reissueCommand(opts);
|
|
298
|
-
const lines = [
|
|
299
|
-
headline,
|
|
300
|
-
'two ways forward:',
|
|
301
|
-
probe.reason === 'not-installed'
|
|
302
|
-
? '1) install Docker (https://docs.docker.com/get-docker/), then re-run: ' + rerun
|
|
303
|
-
: '1) start Docker (Docker Desktop, `colima start`, or `sudo systemctl start docker`), then re-run: ' + rerun,
|
|
304
|
-
'2) skip the local build entirely — deploy an image that is already pushed, by digest:',
|
|
305
|
-
` ${rerun} --image ${(0, shell_1.shellQuote)('<registry>/<spid>/<slug>@sha256:<64-hex>')}`,
|
|
306
|
-
' (any machine or CI job that can push the image can produce that digest: `docker push` prints it, ' +
|
|
307
|
-
"and `docker image inspect --format '{{index .RepoDigests 0}}' <tag>` re-reads it)",
|
|
308
|
-
];
|
|
309
|
-
return lines.join('\n');
|
|
310
|
-
}
|
|
311
|
-
/** The command the user just ran, minus the flags that would change its meaning. */
|
|
312
|
-
function reissueCommand(opts) {
|
|
313
|
-
const parts = ['supercli deploy'];
|
|
314
|
-
if (opts.spid)
|
|
315
|
-
parts.push(`--spid ${(0, shell_1.shellQuote)(opts.spid)}`);
|
|
316
|
-
if (opts.slug)
|
|
317
|
-
parts.push(`--slug ${(0, shell_1.shellQuote)(opts.slug)}`);
|
|
318
|
-
if (opts.env)
|
|
319
|
-
parts.push(`--env ${(0, shell_1.shellQuote)(opts.env)}`);
|
|
320
|
-
if (opts.dir)
|
|
321
|
-
parts.push(`--dir ${(0, shell_1.shellQuote)(opts.dir)}`);
|
|
322
|
-
if (opts.port)
|
|
323
|
-
parts.push(`--port ${(0, shell_1.shellQuote)(opts.port)}`);
|
|
324
|
-
return parts.join(' ');
|
|
168
|
+
return { token, apiOrigin: account.apiOrigin, accountKey: account.accountKey };
|
|
325
169
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
'run as root',
|
|
332
|
-
'must run as non-root',
|
|
333
|
-
'violates podsecurity',
|
|
334
|
-
'podsecurity "restricted"',
|
|
335
|
-
'allowprivilegeescalation',
|
|
336
|
-
'container has runasnonroot',
|
|
337
|
-
];
|
|
338
|
-
function isNonRootRejection(text) {
|
|
339
|
-
if (!text)
|
|
340
|
-
return false;
|
|
341
|
-
const haystack = text.toLowerCase();
|
|
342
|
-
return NON_ROOT_SIGNALS.some((signal) => haystack.includes(signal));
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* The remediation is a Dockerfile fragment, not prose: the fix is two lines, and
|
|
346
|
-
* a user staring at `container has runAsNonRoot and image will run as root` has
|
|
347
|
-
* no way to guess that the cluster's Pod Security admission is what rejected it.
|
|
348
|
-
*
|
|
349
|
-
* 🔴 A NUMERIC uid is what the cluster can actually verify. `USER app` alone
|
|
350
|
-
* leaves the uid to be resolved from the image's /etc/passwd at runtime, which
|
|
351
|
-
* `runAsNonRoot` admission cannot do — the pod is rejected again, and the user
|
|
352
|
-
* concludes the hint was wrong.
|
|
353
|
-
*/
|
|
354
|
-
exports.NON_ROOT_REMEDIATION = [
|
|
355
|
-
'the cluster refuses images that run as root. add a non-root user to your Dockerfile and redeploy:',
|
|
356
|
-
'',
|
|
357
|
-
' # debian/ubuntu base',
|
|
358
|
-
' RUN useradd --uid 10001 --create-home app',
|
|
359
|
-
' USER 10001',
|
|
360
|
-
'',
|
|
361
|
-
' # alpine base',
|
|
362
|
-
' RUN adduser -D -u 10001 app',
|
|
363
|
-
' USER 10001',
|
|
364
|
-
'',
|
|
365
|
-
' 🔴 use the NUMERIC uid in `USER` (`USER 10001`, not `USER app`): the admission check runs before',
|
|
366
|
-
' the image filesystem is consulted, so a name-only USER still reads as "may run as root".',
|
|
367
|
-
' also make sure anything the process writes to (cache dirs, /tmp files) is writable by that uid.',
|
|
368
|
-
].join('\n');
|
|
369
|
-
function withNonRootHint(message) {
|
|
370
|
-
return isNonRootRejection(message) ? `${message}\n\n${exports.NON_ROOT_REMEDIATION}` : message;
|
|
371
|
-
}
|
|
372
|
-
// ---------------------------------------------------------------------------
|
|
373
|
-
// AC-5 (CLI half): the last N startup lines, attached to the failure
|
|
374
|
-
// ---------------------------------------------------------------------------
|
|
375
|
-
function extractLogLines(payload) {
|
|
376
|
-
const record = asRecord(payload);
|
|
377
|
-
const lines = record?.lines;
|
|
378
|
-
if (Array.isArray(lines)) {
|
|
379
|
-
return lines.filter((line) => typeof line === 'string' && line.length > 0);
|
|
170
|
+
async function resolveOrg(auth, config, explicitOrg, deps) {
|
|
171
|
+
const started = Date.now();
|
|
172
|
+
let who;
|
|
173
|
+
try {
|
|
174
|
+
who = await deps.fetchWhoami(auth.apiOrigin, auth.token);
|
|
380
175
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
return
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
176
|
+
catch (error) {
|
|
177
|
+
const message = `identity request failed: ${error.message}`;
|
|
178
|
+
log_1.log.error(message, {
|
|
179
|
+
target: auth.apiOrigin,
|
|
180
|
+
request_summary: `/api/open/whoami for ${config.spid}`,
|
|
181
|
+
response_summary: 'transport threw',
|
|
182
|
+
duration_ms: Date.now() - started,
|
|
183
|
+
retry: true,
|
|
184
|
+
});
|
|
185
|
+
return { ok: false, kind: 'infra_error', code: 'AUTH_RESOLUTION_FAILED', message };
|
|
186
|
+
}
|
|
187
|
+
if (who.kind === 'auth_invalid') {
|
|
188
|
+
log_1.log.error('identity request rejected the current credential', {
|
|
189
|
+
target: auth.apiOrigin,
|
|
190
|
+
request_summary: `/api/open/whoami for ${config.spid}`,
|
|
191
|
+
response_summary: 'AUTH_INVALID',
|
|
192
|
+
duration_ms: Date.now() - started,
|
|
193
|
+
retry: false,
|
|
194
|
+
});
|
|
195
|
+
if (auth.accountKey)
|
|
196
|
+
deps.markNeedsLogin(auth.accountKey);
|
|
197
|
+
return { ok: false, kind: 'needs_login', code: 'AUTH_INVALID', message: 'credentials are no longer valid — run `supercli login` again' };
|
|
399
198
|
}
|
|
400
|
-
if (
|
|
401
|
-
|
|
199
|
+
if (who.kind !== 'success') {
|
|
200
|
+
const code = who.kind === 'forbidden' ? 'FORBIDDEN' : who.kind === 'rate_limited' ? 'RATE_LIMITED' : 'AUTH_RESOLUTION_FAILED';
|
|
201
|
+
log_1.log.error(`identity request failed: ${who.message}`, {
|
|
202
|
+
target: auth.apiOrigin,
|
|
203
|
+
request_summary: `/api/open/whoami for ${config.spid}`,
|
|
204
|
+
response_summary: code,
|
|
205
|
+
duration_ms: Date.now() - started,
|
|
206
|
+
retry: who.kind === 'rate_limited' || who.kind === 'infra_error',
|
|
207
|
+
});
|
|
208
|
+
return {
|
|
209
|
+
ok: false,
|
|
210
|
+
kind: failureKind(who.kind),
|
|
211
|
+
code,
|
|
212
|
+
message: `cannot resolve the org bound to the current token: ${'message' in who ? who.message : 'identity request failed'}`,
|
|
213
|
+
};
|
|
402
214
|
}
|
|
403
|
-
const
|
|
404
|
-
const
|
|
405
|
-
|
|
215
|
+
const tokenOrg = String(who.data.org_id ?? '');
|
|
216
|
+
const requested = trim(explicitOrg) ?? config.orgId ?? tokenOrg;
|
|
217
|
+
if (!/^[1-9][0-9]*$/.test(requested)) {
|
|
218
|
+
return { ok: false, kind: 'business_error', code: 'ORG_REQUIRED', message: 'the selected config/token has no valid org binding' };
|
|
219
|
+
}
|
|
220
|
+
if (tokenOrg !== requested || (config.orgId !== undefined && config.orgId !== requested)) {
|
|
221
|
+
return { ok: false, kind: 'forbidden', code: 'ORG_MISMATCH', message: 'the token org, --org and configured orgId must identify the same organization' };
|
|
222
|
+
}
|
|
223
|
+
return { ok: true, orgId: requested };
|
|
406
224
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
225
|
+
function replaceProjectResult(results, projectId, replacement) {
|
|
226
|
+
const index = results.findIndex((entry) => entry.projectId === projectId);
|
|
227
|
+
if (index >= 0)
|
|
228
|
+
results[index] = replacement;
|
|
229
|
+
}
|
|
230
|
+
/** Unified deploy path: config + portable manifest are the only sources of project identity. */
|
|
231
|
+
async function runUnifiedDeploy(mode, options, deps = exports.defaultUnifiedDeployDeps) {
|
|
232
|
+
const projectId = trim(options.project);
|
|
233
|
+
const envTarget = trim(options.envTarget);
|
|
234
|
+
const buildDirOption = trim(options.buildDir);
|
|
235
|
+
if (!envTarget || !buildDirOption || (mode === 'single' && !projectId)) {
|
|
236
|
+
return {
|
|
237
|
+
ok: false,
|
|
238
|
+
kind: 'usage_error',
|
|
239
|
+
publicCode: 'USAGE_ERROR',
|
|
240
|
+
message: mode === 'single' ? '--project, --env-target and --build-dir are required' : '--env-target and --build-dir are required',
|
|
241
|
+
};
|
|
414
242
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
return { ok: false, message: 'invalid --slug: must be 1-32 lowercase letters or digits, and must not be `stg` or `site`' };
|
|
243
|
+
const logTail = parseLogTail(options.logTail);
|
|
244
|
+
if (!logTail.ok) {
|
|
245
|
+
return { ok: false, kind: 'usage_error', publicCode: 'USAGE_ERROR', message: logTail.message };
|
|
419
246
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
return { ok: false, message: maxScale.message };
|
|
437
|
-
const logTail = parseIntFlag(opts.logTail, '--log-tail', { min: 1, max: 2_000 });
|
|
438
|
-
if (!logTail.ok)
|
|
439
|
-
return { ok: false, message: logTail.message };
|
|
440
|
-
const envVars = collectEnvVars(opts);
|
|
441
|
-
if (!envVars.ok)
|
|
442
|
-
return { ok: false, message: envVars.message };
|
|
443
|
-
const databaseConnection = databaseConnectionChoice(opts);
|
|
444
|
-
if (!databaseConnection.ok)
|
|
445
|
-
return { ok: false, message: databaseConnection.message };
|
|
446
|
-
// ---- 2. image plan + path existence (still local, still free) ----
|
|
447
|
-
const explicitImage = trimFlag(opts.image);
|
|
448
|
-
const plan = { mode: explicitImage ? 'prebuilt' : 'build' };
|
|
449
|
-
if (explicitImage) {
|
|
450
|
-
const split = (0, registry_1.splitDigestRef)(explicitImage);
|
|
451
|
-
if (!split) {
|
|
247
|
+
const resolved = deps.resolveConfig(process.cwd(), trim(options.config));
|
|
248
|
+
if (resolved.kind !== 'valid') {
|
|
249
|
+
return {
|
|
250
|
+
ok: false,
|
|
251
|
+
kind: 'business_error',
|
|
252
|
+
publicCode: resolved.kind === 'ambiguous' ? 'CONFIG_AMBIGUOUS' : 'CONFIG_INVALID',
|
|
253
|
+
message: (0, superConfig_1.configProblem)(resolved) ?? 'configuration is invalid',
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
const config = resolved.config;
|
|
257
|
+
if (mode === 'single' && options.requiredProjectType) {
|
|
258
|
+
const selected = config.projects.find((project) => project.projectId === projectId);
|
|
259
|
+
if (!selected) {
|
|
260
|
+
return { ok: false, kind: 'business_error', publicCode: 'PROJECT_NOT_FOUND', message: `project ${projectId ?? ''} is not declared in ${config.path}` };
|
|
261
|
+
}
|
|
262
|
+
if (selected.type !== options.requiredProjectType) {
|
|
452
263
|
return {
|
|
453
264
|
ok: false,
|
|
454
|
-
|
|
455
|
-
|
|
265
|
+
kind: 'business_error',
|
|
266
|
+
publicCode: 'UNSUPPORTED_PROJECT_TYPE',
|
|
267
|
+
message: `this command only accepts a ${options.requiredProjectType} project; ${selected.projectId} is ${selected.type}`,
|
|
456
268
|
};
|
|
457
269
|
}
|
|
458
|
-
plan.imageRef = explicitImage;
|
|
459
|
-
plan.digest = split.digest;
|
|
460
|
-
plan.repository = split.repository;
|
|
461
270
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
271
|
+
const writer = deps.createWriter(config.root);
|
|
272
|
+
const preflight = deps.preflight({
|
|
273
|
+
config,
|
|
274
|
+
buildDir: path.resolve(buildDirOption),
|
|
275
|
+
envTarget,
|
|
276
|
+
...(mode === 'single' ? { projectId } : {}),
|
|
277
|
+
...(mode === 'single' ? { supplement: { envVars: options.envVar, secrets: options.secret } } : {}),
|
|
278
|
+
});
|
|
279
|
+
if (!preflight.ok)
|
|
280
|
+
return preflightFailureResult(writer, config, envTarget, preflight, mode === 'single' ? projectId : undefined);
|
|
281
|
+
for (const plan of preflight.plans) {
|
|
282
|
+
if (plan.project.type === 'site' && !projectVersion(config, plan.project)) {
|
|
283
|
+
const message = `site project ${plan.project.projectId} has no valid version.name for publishing`;
|
|
284
|
+
replaceProjectResult(preflight.projects, plan.project.projectId, {
|
|
285
|
+
projectId: plan.project.projectId,
|
|
286
|
+
type: plan.project.type,
|
|
287
|
+
status: 'not-configured',
|
|
288
|
+
target: { envTarget: plan.target.envTarget, slug: plan.target.slug, env: plan.target.env },
|
|
289
|
+
error: { code: 'TARGET_NOT_CONFIGURED', message, retryable: false },
|
|
290
|
+
});
|
|
291
|
+
return preflightFailureResult(writer, config, envTarget, { ...preflight, ok: false, publicCode: 'TARGET_NOT_CONFIGURED', message }, mode === 'single' ? projectId : undefined);
|
|
477
292
|
}
|
|
478
|
-
if (fileState !== 'file')
|
|
479
|
-
return { ok: false, message: `--dockerfile is not a regular file: ${dockerfile}` };
|
|
480
|
-
plan.contextDir = contextDir;
|
|
481
|
-
plan.dockerfile = dockerfile;
|
|
482
293
|
}
|
|
483
|
-
//
|
|
294
|
+
// This is intentionally after every local project has passed config, target,
|
|
295
|
+
// environment-reference and artifact integrity validation.
|
|
484
296
|
const auth = resolveAuth(deps);
|
|
485
|
-
if ('ok' in auth)
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
297
|
+
if ('ok' in auth) {
|
|
298
|
+
const projects = preflight.projects.map((project) => project.status === 'not-run'
|
|
299
|
+
? { ...project, error: { code: 'AUTH_INVALID', message: auth.message, retryable: false } }
|
|
300
|
+
: project);
|
|
301
|
+
let deploy;
|
|
302
|
+
try {
|
|
303
|
+
deploy = writer.finalize({
|
|
304
|
+
...resultInputIdentity(config, envTarget, mode === 'single' ? projectId : undefined),
|
|
305
|
+
buildManifestSha256: preflight.buildManifestSha256,
|
|
306
|
+
overallStatus: 'failed',
|
|
307
|
+
projects,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
return { ok: false, kind: 'infra_error', publicCode: 'DEPLOY_RESULT_WRITE_FAILED', message: `deploy result could not be written: ${error.message}; invocation ${writer.invocationId}`, invocationId: writer.invocationId };
|
|
312
|
+
}
|
|
313
|
+
return { ...auth, message: `${auth.message}; deploy result: ${writer.resultPath}`, result: publicDeployResult(writer, deploy) };
|
|
495
314
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
315
|
+
const org = await resolveOrg(auth, config, options.org, deps);
|
|
316
|
+
if (!org.ok) {
|
|
317
|
+
const projects = preflight.projects.map((project) => project.status === 'not-run'
|
|
318
|
+
? { ...project, error: { code: org.code, message: org.message, retryable: org.kind === 'rate_limited' || org.kind === 'infra_error' } }
|
|
319
|
+
: project);
|
|
320
|
+
let deploy;
|
|
321
|
+
try {
|
|
322
|
+
deploy = writer.finalize({
|
|
323
|
+
...resultInputIdentity(config, envTarget, mode === 'single' ? projectId : undefined),
|
|
324
|
+
buildManifestSha256: preflight.buildManifestSha256,
|
|
325
|
+
overallStatus: 'failed',
|
|
326
|
+
projects,
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
catch (error) {
|
|
330
|
+
return { ok: false, kind: 'infra_error', publicCode: 'DEPLOY_RESULT_WRITE_FAILED', message: `deploy result could not be written: ${error.message}; invocation ${writer.invocationId}`, invocationId: writer.invocationId };
|
|
506
331
|
}
|
|
507
|
-
|
|
508
|
-
if (!orgId || orgId === '0')
|
|
509
|
-
return { ok: false, message: 'the current token is not bound to any org — nothing to deploy to' };
|
|
332
|
+
return { ok: false, kind: org.kind, publicCode: org.code, message: `${org.message}; deploy result: ${writer.resultPath}`, result: publicDeployResult(writer, deploy) };
|
|
510
333
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
334
|
+
const results = preflight.projects.map((project) => ({ ...project }));
|
|
335
|
+
let successes = 0;
|
|
336
|
+
let running = 0;
|
|
337
|
+
let firstFailure;
|
|
338
|
+
let anySoft = false;
|
|
339
|
+
const identity = resultInputIdentity(config, envTarget, mode === 'single' ? projectId : undefined);
|
|
340
|
+
const checkpoint = () => writer.checkpoint({
|
|
341
|
+
...identity,
|
|
342
|
+
buildManifestSha256: preflight.buildManifestSha256,
|
|
343
|
+
overallStatus: 'incomplete',
|
|
344
|
+
projects: results,
|
|
516
345
|
});
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
346
|
+
let deploy;
|
|
347
|
+
try {
|
|
348
|
+
// Durable invocation evidence exists before the first adapter can mutate a
|
|
349
|
+
// remote service. Subsequent checkpoints replace this file atomically.
|
|
350
|
+
deploy = checkpoint();
|
|
520
351
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
...(description ? { description } : {}),
|
|
540
|
-
});
|
|
541
|
-
/**
|
|
542
|
-
* The REDEPLOY body (IND-1) — narrower than create's on purpose: the service, its
|
|
543
|
-
* slug and its display name already exist, so a redeploy only carries the image and
|
|
544
|
-
* the runtime spec. `--name` is therefore inert on this path (documented on the flag),
|
|
545
|
-
* and `--env-var` / `--secret` are refused rather than silently dropped.
|
|
546
|
-
*/
|
|
547
|
-
const deployBody = () => ({
|
|
548
|
-
image_ref: plan.imageRef ?? `${plan.repository ?? slug}@${PLACEHOLDER_DIGEST}`,
|
|
549
|
-
image_digest: plan.digest ?? PLACEHOLDER_DIGEST,
|
|
550
|
-
port: port.value ?? SPEC_LIMITS.port.def,
|
|
551
|
-
...(cpu.value !== undefined ? { cpu_milli: cpu.value } : {}),
|
|
552
|
-
...(memory.value !== undefined ? { mem_mib: memory.value } : {}),
|
|
553
|
-
...(maxScale.value !== undefined ? { max_scale: maxScale.value } : {}),
|
|
554
|
-
...(databaseConnection.value !== undefined ? { database_connection: databaseConnection.value } : {}),
|
|
555
|
-
});
|
|
556
|
-
// ---- 6. dry-run (AC-16): validate only. No image is built, none pushed, nothing created. ----
|
|
557
|
-
if (opts.dryRun) {
|
|
558
|
-
const notes = [];
|
|
559
|
-
if (plan.mode === 'build') {
|
|
560
|
-
if (!registry)
|
|
561
|
-
notes.push(registryIssueMessage(registryResolution, auth.apiOrigin));
|
|
562
|
-
// 🔴 A dry-run never builds, so there is no digest yet. Probing docker is
|
|
563
|
-
// read-only and worth reporting, but it must NOT fail the plan: the whole
|
|
564
|
-
// point of a dry-run is to answer "would this be accepted?", and the answer
|
|
565
|
-
// does not depend on this machine having a daemon right now.
|
|
566
|
-
const probe = deps.docker.probe();
|
|
567
|
-
if (!probe.available) {
|
|
568
|
-
notes.push(`docker is not usable on this machine right now (${probe.detail}); the real deploy would need it, ` +
|
|
569
|
-
'or an already-pushed --image <ref@sha256:…>');
|
|
570
|
-
}
|
|
571
|
-
notes.push('the image digest is decided at build time — this plan validated everything except the digest itself');
|
|
352
|
+
catch (error) {
|
|
353
|
+
return {
|
|
354
|
+
ok: false,
|
|
355
|
+
kind: 'infra_error',
|
|
356
|
+
publicCode: 'DEPLOY_RESULT_WRITE_FAILED',
|
|
357
|
+
message: `deploy result could not be initialized; no remote deploy was started: ${error.message}; invocation ${writer.invocationId}`,
|
|
358
|
+
invocationId: writer.invocationId,
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
for (const plan of preflight.plans) {
|
|
362
|
+
replaceProjectResult(results, plan.project.projectId, {
|
|
363
|
+
projectId: plan.project.projectId,
|
|
364
|
+
type: plan.project.type,
|
|
365
|
+
status: 'running',
|
|
366
|
+
target: { envTarget: plan.target.envTarget, slug: plan.target.slug, env: plan.target.env },
|
|
367
|
+
});
|
|
368
|
+
try {
|
|
369
|
+
deploy = checkpoint();
|
|
572
370
|
}
|
|
573
|
-
|
|
574
|
-
if (validated.kind !== 'outcome')
|
|
575
|
-
return terminalResult();
|
|
576
|
-
if (validated.outcome.kind !== 'success' && validated.outcome.kind !== 'soft_success') {
|
|
371
|
+
catch (error) {
|
|
577
372
|
return {
|
|
578
373
|
ok: false,
|
|
579
|
-
kind:
|
|
580
|
-
|
|
374
|
+
kind: 'infra_error',
|
|
375
|
+
publicCode: 'DEPLOY_RESULT_WRITE_FAILED',
|
|
376
|
+
message: `deploy result could not record the next running project; no further remote deploy was started: ${error.message}; invocation ${writer.invocationId}`,
|
|
377
|
+
result: publicDeployResult(writer, deploy),
|
|
581
378
|
};
|
|
582
379
|
}
|
|
583
|
-
const
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
...(description ? { description } : {}),
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
380
|
+
const adapter = plan.project.type === 'site'
|
|
381
|
+
? await deps.deploySite({
|
|
382
|
+
apiOrigin: auth.apiOrigin,
|
|
383
|
+
token: auth.token,
|
|
384
|
+
orgId: org.orgId,
|
|
385
|
+
spid: config.spid,
|
|
386
|
+
projectId: plan.project.projectId,
|
|
387
|
+
target: plan.target,
|
|
388
|
+
directory: plan.build.artifacts.find((artifact) => artifact.id === 'site-dist' && artifact.kind === 'directory').absolutePath,
|
|
389
|
+
version: projectVersion(config, plan.project),
|
|
390
|
+
...(trim(options.description) ? { description: trim(options.description) } : {}),
|
|
391
|
+
...(options.dryRun ? { dryRun: true } : {}),
|
|
392
|
+
...(trim(options.idempotencyKey) ? { idempotencyKey: `${trim(options.idempotencyKey)}:${plan.project.projectId}` } : {}),
|
|
393
|
+
})
|
|
394
|
+
: await deps.deployRun({
|
|
395
|
+
apiOrigin: auth.apiOrigin,
|
|
396
|
+
token: auth.token,
|
|
397
|
+
orgId: org.orgId,
|
|
398
|
+
spid: config.spid,
|
|
399
|
+
project: plan.project,
|
|
400
|
+
target: plan.target,
|
|
401
|
+
build: plan.build,
|
|
402
|
+
runtimeValues: plan.runtimeValues,
|
|
403
|
+
logTail: logTail.value,
|
|
404
|
+
...(options.dryRun ? { dryRun: true } : {}),
|
|
405
|
+
...(trim(options.description) ? { description: trim(options.description) } : {}),
|
|
406
|
+
...(trim(options.idempotencyKey) ? { idempotencyKey: `${trim(options.idempotencyKey)}:${plan.project.projectId}` } : {}),
|
|
407
|
+
...(mode === 'single' && options.allowForeignRegistry ? { allowForeignRegistry: true } : {}),
|
|
408
|
+
});
|
|
409
|
+
if (!adapter.ok) {
|
|
410
|
+
firstFailure = adapter;
|
|
411
|
+
replaceProjectResult(results, plan.project.projectId, {
|
|
412
|
+
projectId: plan.project.projectId,
|
|
413
|
+
type: plan.project.type,
|
|
414
|
+
status: 'failed',
|
|
415
|
+
target: { envTarget: plan.target.envTarget, slug: plan.target.slug, env: plan.target.env },
|
|
416
|
+
error: { code: adapter.code, message: adapter.message, retryable: adapter.retryable },
|
|
417
|
+
});
|
|
418
|
+
try {
|
|
419
|
+
deploy = checkpoint();
|
|
420
|
+
}
|
|
421
|
+
catch (error) {
|
|
422
|
+
return {
|
|
423
|
+
ok: false,
|
|
424
|
+
kind: 'infra_error',
|
|
425
|
+
publicCode: 'DEPLOY_RESULT_WRITE_FAILED',
|
|
426
|
+
message: `remote state may have changed, but its failed transition could not be recorded: ${error.message}; invocation ${writer.invocationId}`,
|
|
427
|
+
result: publicDeployResult(writer, deploy),
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
break;
|
|
624
431
|
}
|
|
625
|
-
|
|
626
|
-
const
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
credential,
|
|
638
|
-
dockerfile: plan.dockerfile,
|
|
639
|
-
context: plan.contextDir,
|
|
640
|
-
tag,
|
|
641
|
-
...(trimFlag(opts.platform) ? { platform: trimFlag(opts.platform) } : {}),
|
|
642
|
-
...(opts.buildArg && opts.buildArg.length > 0 ? { buildArgs: opts.buildArg } : {}),
|
|
432
|
+
anySoft ||= adapter.soft === true;
|
|
433
|
+
const stillRunning = adapter.resource.status === 'provisioning';
|
|
434
|
+
if (stillRunning)
|
|
435
|
+
running += 1;
|
|
436
|
+
else
|
|
437
|
+
successes += 1;
|
|
438
|
+
replaceProjectResult(results, plan.project.projectId, {
|
|
439
|
+
projectId: plan.project.projectId,
|
|
440
|
+
type: plan.project.type,
|
|
441
|
+
status: stillRunning ? 'running' : 'success',
|
|
442
|
+
target: { envTarget: plan.target.envTarget, slug: plan.target.slug, env: plan.target.env },
|
|
443
|
+
resource: adapter.resource,
|
|
643
444
|
});
|
|
644
|
-
|
|
445
|
+
try {
|
|
446
|
+
// Keep the remote-complete -> durable-result window as small as the
|
|
447
|
+
// adapter boundary permits, before starting the next project.
|
|
448
|
+
deploy = checkpoint();
|
|
449
|
+
}
|
|
450
|
+
catch (error) {
|
|
645
451
|
return {
|
|
646
452
|
ok: false,
|
|
647
|
-
|
|
453
|
+
kind: 'infra_error',
|
|
454
|
+
publicCode: 'DEPLOY_RESULT_WRITE_FAILED',
|
|
455
|
+
message: `remote state changed, but its project transition could not be recorded: ${error.message}; invocation ${writer.invocationId}`,
|
|
456
|
+
result: publicDeployResult(writer, deploy),
|
|
648
457
|
};
|
|
649
458
|
}
|
|
650
|
-
plan.digest = built.digest;
|
|
651
|
-
plan.imageRef = (0, registry_1.digestRef)(repository, built.digest);
|
|
652
|
-
log_1.log.info(`pushed ${plan.imageRef}`);
|
|
653
459
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
if (attempt.kind !== 'outcome')
|
|
673
|
-
return terminalResult();
|
|
674
|
-
let outcome = attempt.outcome;
|
|
675
|
-
let mode = 'create';
|
|
676
|
-
if (outcome.kind === 'business_error' && outcome.code === 'SITE_SLUG_DUPLICATE') {
|
|
677
|
-
const probe = await withAuth(auth, deps, (token) => client.getService({ ...context, accessToken: token }, spid, slug, env));
|
|
678
|
-
if (probe.kind !== 'outcome')
|
|
679
|
-
return terminalResult();
|
|
680
|
-
// Not readable as an existing service in THIS env (NOT_FOUND, or a read we cannot
|
|
681
|
-
// trust) ⇒ leave the create failure standing; describeRunError explains the real
|
|
682
|
-
// collision. Never redeploy something we did not confirm.
|
|
683
|
-
if (probe.outcome.kind === 'success' || probe.outcome.kind === 'soft_success') {
|
|
684
|
-
// 🔴 The redeploy contract carries no env vars. Accepting them here would mean
|
|
685
|
-
// `--secret DATABASE_URL` quietly doing nothing on every run after the first.
|
|
686
|
-
if (envVars.vars.length > 0) {
|
|
687
|
-
return { ok: false, kind: 'business_error', message: redeployEnvVarsMessage(spid, slug, env) };
|
|
688
|
-
}
|
|
689
|
-
const redeployed = await withAuth(auth, deps, (token) => client.deployService({ ...context, accessToken: token }, spid, slug, env, deployBody(), idempotencyKey));
|
|
690
|
-
if (redeployed.kind !== 'outcome')
|
|
691
|
-
return terminalResult();
|
|
692
|
-
mode = 'redeploy';
|
|
693
|
-
outcome = redeployed.outcome;
|
|
460
|
+
if (firstFailure && !firstFailure.ok) {
|
|
461
|
+
const overallStatus = successes + running > 0 ? 'partial' : 'failed';
|
|
462
|
+
try {
|
|
463
|
+
deploy = writer.finalize({
|
|
464
|
+
...identity,
|
|
465
|
+
buildManifestSha256: preflight.buildManifestSha256,
|
|
466
|
+
overallStatus,
|
|
467
|
+
projects: results,
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
catch (error) {
|
|
471
|
+
return {
|
|
472
|
+
ok: false,
|
|
473
|
+
kind: 'infra_error',
|
|
474
|
+
publicCode: 'DEPLOY_RESULT_WRITE_FAILED',
|
|
475
|
+
message: `deploy stopped, but its final result could not be recorded: ${error.message}; invocation ${writer.invocationId}`,
|
|
476
|
+
result: publicDeployResult(writer, deploy),
|
|
477
|
+
};
|
|
694
478
|
}
|
|
695
|
-
}
|
|
696
|
-
if (outcome.kind !== 'success' && outcome.kind !== 'soft_success') {
|
|
697
479
|
return {
|
|
698
480
|
ok: false,
|
|
699
|
-
kind:
|
|
700
|
-
|
|
481
|
+
kind: firstFailure.kind,
|
|
482
|
+
publicCode: firstFailure.code,
|
|
483
|
+
message: `${firstFailure.message}; deploy result: ${writer.resultPath}`,
|
|
484
|
+
result: publicDeployResult(writer, deploy),
|
|
701
485
|
};
|
|
702
486
|
}
|
|
703
|
-
|
|
704
|
-
const idempotentReplay = asRecord(view)?.idempotent_replay === true;
|
|
705
|
-
if (idempotentReplay) {
|
|
706
|
-
// The server replayed the first request with this key and answered with just
|
|
707
|
-
// the service id — re-read the service so the caller still gets a full view.
|
|
708
|
-
const reread = await withAuth(auth, deps, (token) => client.getService({ ...context, accessToken: token }, spid, slug, env));
|
|
709
|
-
if (reread.kind !== 'outcome')
|
|
710
|
-
return terminalResult();
|
|
711
|
-
if (reread.outcome.kind === 'success' || reread.outcome.kind === 'soft_success') {
|
|
712
|
-
view = valueFromOutcome(reread.outcome);
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
// ---- 9. readiness ----
|
|
716
|
-
let status = stringField(view, 'status') ?? 'provisioning';
|
|
717
|
-
let attempts = 0;
|
|
718
|
-
while (status === 'provisioning' && attempts < deps.pollAttempts) {
|
|
719
|
-
attempts += 1;
|
|
720
|
-
await deps.sleep(deps.pollIntervalMs);
|
|
721
|
-
const polled = await withAuth(auth, deps, (token) => client.getService({ ...context, accessToken: token }, spid, slug, env));
|
|
722
|
-
if (polled.kind !== 'outcome')
|
|
723
|
-
return terminalResult();
|
|
724
|
-
if (polled.outcome.kind !== 'success' && polled.outcome.kind !== 'soft_success') {
|
|
725
|
-
// A transient read failure must not be reported as a deploy failure: the
|
|
726
|
-
// service was created, we simply cannot see its state right now.
|
|
727
|
-
break;
|
|
728
|
-
}
|
|
729
|
-
view = valueFromOutcome(polled.outcome);
|
|
730
|
-
status = stringField(view, 'status') ?? status;
|
|
731
|
-
}
|
|
732
|
-
const domain = stringField(view, 'domain');
|
|
733
|
-
const label = stringField(view, 'label');
|
|
734
|
-
const statusReason = stringField(view, 'status_reason');
|
|
735
|
-
const baseResult = {
|
|
736
|
-
dryRun: false,
|
|
737
|
-
spid,
|
|
738
|
-
slug,
|
|
739
|
-
env,
|
|
740
|
-
name,
|
|
741
|
-
/** `create` on the first deploy of this (slug, env), `redeploy` on every one after (IND-1). */
|
|
742
|
-
mode,
|
|
743
|
-
image: { mode: plan.mode, ref: plan.imageRef, digest: plan.digest, ...(plan.repository ? { repository: plan.repository } : {}) },
|
|
744
|
-
port: port.value ?? SPEC_LIMITS.port.def,
|
|
745
|
-
database_connection: databaseConnection.value === undefined ? null : databaseConnection.value,
|
|
746
|
-
env_var_keys: envVarKeys,
|
|
747
|
-
secret_keys: secretKeys,
|
|
748
|
-
// 🔴 IND-9: echoed, not stored — the Console API has no field for it (see the flag's help).
|
|
749
|
-
...(description ? { description } : {}),
|
|
750
|
-
idempotency_key: idempotencyKey,
|
|
751
|
-
idempotent_replay: idempotentReplay,
|
|
752
|
-
status,
|
|
753
|
-
...(domain ? { domain } : {}),
|
|
754
|
-
...(label ? { label } : {}),
|
|
755
|
-
service: view,
|
|
756
|
-
};
|
|
757
|
-
if (status === 'failed' || status === 'timeout') {
|
|
758
|
-
const tail = logTail.value ?? 50;
|
|
759
|
-
const logs = await tailStartupLogs(auth, deps, client, context, spid, slug, env, tail);
|
|
760
|
-
const reason = statusReason ?? (status === 'timeout' ? 'the container did not become ready in time' : 'the container failed to start');
|
|
761
|
-
const parts = [`deploy ${status}: ${reason}`];
|
|
762
|
-
if (logs.lines.length > 0) {
|
|
763
|
-
parts.push(`last ${logs.lines.length} startup log line(s):\n${logs.lines.map((line) => ` | ${line}`).join('\n')}`);
|
|
764
|
-
}
|
|
765
|
-
else if (logs.note) {
|
|
766
|
-
parts.push(logs.note);
|
|
767
|
-
}
|
|
768
|
-
parts.push(`for more context re-run with a larger --log-tail (e.g. --log-tail ${Math.min(tail * 4, 2_000)}), or open the service page in the Console`);
|
|
769
|
-
return { ok: false, kind: 'business_error', message: withNonRootHint(parts.join('\n')) };
|
|
770
|
-
}
|
|
771
|
-
if (status === 'provisioning') {
|
|
772
|
-
// 🔴 The "how do I poll this?" answer differs by path: an idempotency key replays a
|
|
773
|
-
// CREATE, but a redeploy is guarded by the server's state machine instead (a redeploy
|
|
774
|
-
// is refused while the previous one is still `provisioning`), so retrying the same
|
|
775
|
-
// command cannot stack revisions either way. Saying the wrong one is worse than
|
|
776
|
-
// saying nothing.
|
|
777
|
-
const pollHint = mode === 'redeploy'
|
|
778
|
-
? 're-run the same command to check on it — while it is still `provisioning` the server refuses another ' +
|
|
779
|
-
'redeploy, so a retry cannot stack a second revision'
|
|
780
|
-
: `re-run the same command with --idempotency-key ${(0, shell_1.shellQuote)(idempotencyKey)} to poll it without creating a second service`;
|
|
487
|
+
if (running > 0) {
|
|
781
488
|
return {
|
|
782
489
|
ok: true,
|
|
783
490
|
soft: true,
|
|
784
|
-
message: `accepted
|
|
785
|
-
|
|
786
|
-
|
|
491
|
+
message: `accepted ${successes + running} project${successes + running === 1 ? '' : 's'} for envTarget ${envTarget}; ${running} still provisioning`,
|
|
492
|
+
result: publicDeployResult(writer, deploy),
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
try {
|
|
496
|
+
deploy = writer.finalize({
|
|
497
|
+
...identity,
|
|
498
|
+
buildManifestSha256: preflight.buildManifestSha256,
|
|
499
|
+
overallStatus: 'success',
|
|
500
|
+
projects: results,
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
catch (error) {
|
|
504
|
+
return {
|
|
505
|
+
ok: false,
|
|
506
|
+
kind: 'infra_error',
|
|
507
|
+
publicCode: 'DEPLOY_RESULT_WRITE_FAILED',
|
|
508
|
+
message: `remote state changed, but the completed result could not be recorded: ${error.message}; invocation ${writer.invocationId}`,
|
|
509
|
+
result: publicDeployResult(writer, deploy),
|
|
787
510
|
};
|
|
788
511
|
}
|
|
789
|
-
const reachable = domain ? `reachable at https://${domain}` : 'find the public domain on the service page in the Console';
|
|
790
512
|
return {
|
|
791
513
|
ok: true,
|
|
792
|
-
|
|
793
|
-
|
|
514
|
+
soft: anySoft,
|
|
515
|
+
message: `deployed ${successes} project${successes === 1 ? '' : 's'} for envTarget ${envTarget}`,
|
|
516
|
+
result: publicDeployResult(writer, deploy),
|
|
794
517
|
};
|
|
795
518
|
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
'(the registry host is derived from the Console origin, e.g. console.supersdk.com → repo.supersdk.com)');
|
|
519
|
+
function emitUnifiedDeployResult(result, mode) {
|
|
520
|
+
const invocationId = result.result?.deploy.invocationId ?? result.invocationId;
|
|
521
|
+
const printer = new resultPrinter_1.ResultPrinter(mode, invocationId);
|
|
522
|
+
const identitySummary = result.result
|
|
523
|
+
? `configPath=${result.result.configPath}; spid=${result.result.spid}; ${result.result.projectId ? `projectId=${result.result.projectId}; ` : ''}envTarget=${result.result.envTarget}`
|
|
524
|
+
: undefined;
|
|
525
|
+
const humanMessage = identitySummary ? `${result.message}; ${identitySummary}` : result.message;
|
|
526
|
+
if (result.ok)
|
|
527
|
+
printer.success(result.result ?? {}, { soft: result.soft, humanMessage });
|
|
528
|
+
else {
|
|
529
|
+
const deploy = result.result?.deploy;
|
|
530
|
+
const statusSummary = deploy
|
|
531
|
+
? `; overall=${deploy.overallStatus}; projects=${deploy.projects.map((project) => `${project.projectId}:${project.status}`).join(',')}`
|
|
532
|
+
: '';
|
|
533
|
+
printer.failure(result.kind ?? 'business_error', `${humanMessage}${statusSummary}`, {
|
|
534
|
+
publicCode: result.publicCode,
|
|
535
|
+
...(result.result !== undefined ? { result: result.result } : {}),
|
|
536
|
+
});
|
|
537
|
+
}
|
|
816
538
|
}
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
* The registry login sends the caller's full-power console token as the Basic
|
|
820
|
-
* password (see `resolveRegistryHost`'s docstring), so refusing by default —
|
|
821
|
-
* and requiring an explicit, auditable `--allow-foreign-registry` to proceed —
|
|
822
|
-
* keeps that token from being handed to an unrelated host by a stray/typo'd
|
|
823
|
-
* env var.
|
|
824
|
-
*/
|
|
825
|
-
function registryForeignBlockedNote(host, zone) {
|
|
826
|
-
return (`refusing to push to ${registry_1.SUPERCLI_REGISTRY_ENV}=${host}: it is outside the ${zone} zone this account uses, and the ` +
|
|
827
|
-
'registry login sends your full-power console token as the password — sending that to an unrelated host is a real ' +
|
|
828
|
-
'credential-leak risk. Pass --allow-foreign-registry to push there anyway, unset ' +
|
|
829
|
-
`${registry_1.SUPERCLI_REGISTRY_ENV} to use the platform registry (repo.${zone}), or deploy an already-pushed image with ` +
|
|
830
|
-
'--image <ref@sha256:…>');
|
|
539
|
+
function modeFor(command) {
|
|
540
|
+
return command.optsWithGlobals?.()?.output === 'json' ? 'json' : 'human';
|
|
831
541
|
}
|
|
832
|
-
function
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
542
|
+
function addOptions(command, includeProject) {
|
|
543
|
+
const collect = (value, previous = []) => previous.concat([value]);
|
|
544
|
+
if (includeProject) {
|
|
545
|
+
command.requiredOption('--project <projectId>', 'stable projectId from super.json')
|
|
546
|
+
.option('--env-var <KEY=VALUE|KEY>', 'create-only plaintext runtime variable; single-project service deploy only', collect)
|
|
547
|
+
.option('--secret <KEY>', 'create-only secret name; value comes from the same environment variable', collect)
|
|
548
|
+
.option('--allow-foreign-registry', `allow ${registry_1.SUPERCLI_REGISTRY_ENV} outside the account zone (single-project service deploy only)`);
|
|
549
|
+
}
|
|
550
|
+
return command
|
|
551
|
+
.requiredOption('--env-target <name>', 'named deploy target from the selected project(s)')
|
|
552
|
+
.requiredOption('--build-dir <dir>', 'portable build directory containing super-build-manifest.json')
|
|
553
|
+
.option('--config <path>', 'explicit super.json-compatible config path')
|
|
554
|
+
.option('--org <id>', 'organization id; must match config and the current token')
|
|
555
|
+
.option('--log-tail <count>', 'startup log lines retained when a service fails readiness (1..2000)', '50')
|
|
556
|
+
.option('--dry-run', 'validate through the platform without uploading, pushing or changing resources')
|
|
557
|
+
.option('--idempotency-key <key>', 'base idempotency key; projectId is appended per adapter call')
|
|
558
|
+
.option('--description <description>', 'free-text note; NOT stored by the platform');
|
|
836
559
|
}
|
|
837
560
|
function registerDeployCommand(program) {
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
.
|
|
842
|
-
.requiredOption('--spid <spid>', 'project spid (8 lowercase letters or digits)')
|
|
843
|
-
.requiredOption('--slug <slug>', 'service slug; shares the project name pool with static sites')
|
|
844
|
-
.requiredOption('--env <env>', 'project environment (prod, staging, …)')
|
|
845
|
-
.option('--name <name>', 'display name for a NEW service; defaults to the slug. Ignored when the service already exists — a redeploy does not rename it')
|
|
846
|
-
.option('--org <id>', 'organization id; defaults to the org bound to the current token')
|
|
847
|
-
.option('--dir <dir>', 'docker build context; defaults to the current directory')
|
|
848
|
-
.option('--dockerfile <path>', 'Dockerfile to build; defaults to <dir>/Dockerfile')
|
|
849
|
-
.option('--image <ref>', 'deploy an already-pushed, digest-pinned image (repo@sha256:…) and skip the local build')
|
|
850
|
-
.option('--platform <platform>', 'docker build platform; defaults to linux/amd64 (the cluster architecture)', 'linux/amd64')
|
|
851
|
-
.option('--build-arg <KEY=VALUE>', 'docker --build-arg, repeatable', collect)
|
|
852
|
-
.option('--port <port>', 'container port the service listens on', String(SPEC_LIMITS.port.def))
|
|
853
|
-
.option('--cpu <millicores>', 'CPU limit in millicores (1-4000)')
|
|
854
|
-
.option('--memory <MiB>', 'memory limit in MiB (1-8192)')
|
|
855
|
-
.option('--max-scale <n>', 'maximum number of replicas (1-10)')
|
|
856
|
-
// 🔴 IND-1: both env-var flags apply to a NEW service only. On a redeploy the command
|
|
857
|
-
// refuses them out loud rather than rolling out an image while dropping them.
|
|
858
|
-
.option('--env-var <KEY=VALUE>', 'plaintext environment variable for a NEW service, repeatable (KEY alone reads the value from the environment); not accepted on a redeploy', collect)
|
|
859
|
-
// 🔴 <KEY>, never <KEY=VALUE>: the value is read from the environment so it never lands on argv (TC-27).
|
|
860
|
-
.option('--secret <KEY>', 'secret environment variable NAME for a NEW service, repeatable; its value is read from the environment of the same name. Not accepted on a redeploy', collect)
|
|
861
|
-
.option('--database-connection <name>', 'bind this service to a named database connection on first deploy, or switch it on a redeploy')
|
|
862
|
-
.option('--remove-database-connection', 'explicitly remove the database connection binding on a redeploy (omitting --database-connection preserves the current binding)')
|
|
863
|
-
// 🔴 IND-9: the Console API has no field for this today, so promising it is "recorded"
|
|
864
|
-
// would be a straight lie. It is echoed back in the result and nothing more.
|
|
865
|
-
.option('--description <description>', 'free-text note; NOT stored by the platform (the Console API has no such field) — echoed back in the result so a caller can correlate runs')
|
|
866
|
-
.option('--dry-run', 'validate locally + server-side without building, pushing or creating anything')
|
|
867
|
-
.option('--idempotency-key <key>', 'client idempotency key; replaying the same key returns the first deploy')
|
|
868
|
-
.option('--log-tail <n>', 'startup log lines to print when the deploy fails', '50')
|
|
869
|
-
.option('--allow-foreign-registry', `let ${registry_1.SUPERCLI_REGISTRY_ENV} point outside this account's own zone; the registry login sends your ` +
|
|
870
|
-
'console token there as the password, so this is an explicit opt-in, never a default')
|
|
871
|
-
.action(async (options, cmd) => {
|
|
872
|
-
const mode = cmd.optsWithGlobals?.()?.output === 'json' ? 'json' : 'human';
|
|
873
|
-
const printer = new resultPrinter_1.ResultPrinter(mode);
|
|
874
|
-
const result = await runDeploy(options);
|
|
875
|
-
if (result.ok) {
|
|
876
|
-
printer.success(result.result ?? {}, { soft: result.soft, humanMessage: result.message });
|
|
877
|
-
}
|
|
878
|
-
else {
|
|
879
|
-
printer.failure(result.kind ?? 'business_error', result.message ?? 'deploy failed');
|
|
880
|
-
}
|
|
881
|
-
});
|
|
561
|
+
addOptions(program.command('deploy').description('Deploy one configured project artifact.'), true)
|
|
562
|
+
.action(async (options, command) => emitUnifiedDeployResult(await runUnifiedDeploy('single', options), modeFor(command)));
|
|
563
|
+
addOptions(program.command('deploy-all').description('Preflight then deploy all configured projects for one envTarget.'), false)
|
|
564
|
+
.action(async (options, command) => emitUnifiedDeployResult(await runUnifiedDeploy('all', options), modeFor(command)));
|
|
882
565
|
}
|
|
883
566
|
//# sourceMappingURL=deploy.js.map
|