vela 0.15.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +46 -5
- package/dist/bin.js.map +3 -3
- package/package.json +4 -3
- package/templates/server/apply.sh +16 -0
- package/templates/server/destroy.sh +4 -0
- package/templates/server/lib.sh +52 -0
package/dist/bin.js
CHANGED
|
@@ -21,7 +21,7 @@ import pc45 from "picocolors";
|
|
|
21
21
|
// package.json
|
|
22
22
|
var package_default = {
|
|
23
23
|
name: "vela",
|
|
24
|
-
version: "0.15.
|
|
24
|
+
version: "0.15.1",
|
|
25
25
|
type: "module",
|
|
26
26
|
description: "A CLI for creating and updating SvelteKit projects",
|
|
27
27
|
license: "MIT",
|
|
@@ -51,6 +51,7 @@ var package_default = {
|
|
|
51
51
|
format: "prettier --write .",
|
|
52
52
|
test: "vitest run",
|
|
53
53
|
prepare: "npm run build",
|
|
54
|
+
version: "npm run build",
|
|
54
55
|
"lint:sh": "shellcheck -x -P SCRIPTDIR -S warning templates/server/*.sh",
|
|
55
56
|
"test:scripts": "bash scripts/test-server-scripts.sh"
|
|
56
57
|
},
|
|
@@ -60,10 +61,10 @@ var package_default = {
|
|
|
60
61
|
"@velastack/patterns": "^0.4.0",
|
|
61
62
|
"@velastack/pocketbase-codegen": "^0.1.0",
|
|
62
63
|
"annotate-json-schema": "^0.1.1",
|
|
63
|
-
commander: "^
|
|
64
|
+
commander: "^15.0.0",
|
|
64
65
|
"cross-spawn": "^7.0.6",
|
|
65
66
|
dedent: "^1.7.2",
|
|
66
|
-
dotenv: "^
|
|
67
|
+
dotenv: "^18.0.1",
|
|
67
68
|
"fetch-cookie": "^3.2.0",
|
|
68
69
|
"json-schema-faker": "^0.6.3",
|
|
69
70
|
"magic-string": "^1.2.3",
|
|
@@ -620,12 +621,23 @@ var UnsupportedError = class extends Error {
|
|
|
620
621
|
this.reasons = reasons;
|
|
621
622
|
}
|
|
622
623
|
};
|
|
624
|
+
var TARGET_REMOVED_EXIT = 3;
|
|
625
|
+
var TargetRemovedError = class extends Error {
|
|
626
|
+
name = "TargetRemovedError";
|
|
627
|
+
exitCode = TARGET_REMOVED_EXIT;
|
|
628
|
+
};
|
|
623
629
|
|
|
624
630
|
// src/lib/run.ts
|
|
625
631
|
async function runCommand(action, failureMessage) {
|
|
626
632
|
try {
|
|
627
633
|
await action();
|
|
628
634
|
} catch (e) {
|
|
635
|
+
if (e instanceof TargetRemovedError) {
|
|
636
|
+
p.log.warn(e.message);
|
|
637
|
+
p.cancel("Nothing was deployed.");
|
|
638
|
+
process.exitCode = e.exitCode;
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
629
641
|
if (e instanceof UnsupportedError) {
|
|
630
642
|
const padding = Math.max(...e.reasons.map((r) => r.id.length), 0);
|
|
631
643
|
const message = e.reasons.map((r) => ` ${r.id.padEnd(padding)} ${pc2.redBright(r.reason)}`).join("\n");
|
|
@@ -3045,6 +3057,14 @@ import process10 from "node:process";
|
|
|
3045
3057
|
import * as p7 from "@clack/prompts";
|
|
3046
3058
|
|
|
3047
3059
|
// src/lib/velastack-api.ts
|
|
3060
|
+
var ApiError = class extends Error {
|
|
3061
|
+
constructor(status3, message) {
|
|
3062
|
+
super(message);
|
|
3063
|
+
this.status = status3;
|
|
3064
|
+
}
|
|
3065
|
+
status;
|
|
3066
|
+
name = "ApiError";
|
|
3067
|
+
};
|
|
3048
3068
|
async function apiFetch(apiKey, pathAndQuery, init) {
|
|
3049
3069
|
const headers = new Headers(init?.headers);
|
|
3050
3070
|
headers.set("Authorization", `Bearer ${apiKey}`);
|
|
@@ -3061,7 +3081,10 @@ async function apiFetch(apiKey, pathAndQuery, init) {
|
|
|
3061
3081
|
}
|
|
3062
3082
|
if (!res.ok) {
|
|
3063
3083
|
const body = await res.text().catch(() => "");
|
|
3064
|
-
throw new
|
|
3084
|
+
throw new ApiError(
|
|
3085
|
+
res.status,
|
|
3086
|
+
`Velastack API error (${res.status}): ${body || res.statusText}`
|
|
3087
|
+
);
|
|
3065
3088
|
}
|
|
3066
3089
|
return await res.json();
|
|
3067
3090
|
}
|
|
@@ -9198,13 +9221,14 @@ ${pc13.cyan("VELA_API_KEY")}.`
|
|
|
9198
9221
|
}
|
|
9199
9222
|
};
|
|
9200
9223
|
}
|
|
9201
|
-
async function reportEnvironmentDestroyed(workspaceRootDir, envTag) {
|
|
9224
|
+
async function reportEnvironmentDestroyed(workspaceRootDir, envTag, { missingOk = false } = {}) {
|
|
9202
9225
|
const link2 = readProjectConfig(workspaceRootDir);
|
|
9203
9226
|
const apiKey = link2 ? readApiKey() : null;
|
|
9204
9227
|
if (!link2 || !apiKey) return;
|
|
9205
9228
|
try {
|
|
9206
9229
|
await destroyEnvironment(apiKey, link2.projectId, envTag);
|
|
9207
9230
|
} catch (err) {
|
|
9231
|
+
if (missingOk && err instanceof ApiError && err.status === 404) return;
|
|
9208
9232
|
warn("retire the environment", err);
|
|
9209
9233
|
}
|
|
9210
9234
|
}
|
|
@@ -9252,6 +9276,11 @@ var deployment = addLockWaitOption(
|
|
|
9252
9276
|
stream: true
|
|
9253
9277
|
});
|
|
9254
9278
|
if (result?.existed === false) {
|
|
9279
|
+
if (ctx.target.kind === "preview") {
|
|
9280
|
+
await reportEnvironmentDestroyed(ctx.workspaceRootDir, ctx.envTag, {
|
|
9281
|
+
missingOk: true
|
|
9282
|
+
});
|
|
9283
|
+
}
|
|
9255
9284
|
p31.log.info(
|
|
9256
9285
|
`Nothing named ${pc14.cyan(`${ctx.appName} (${ctx.targetName})`)} on ${ctx.server}; nothing to remove.`
|
|
9257
9286
|
);
|
|
@@ -12711,6 +12740,18 @@ ${pc21.dim(String(err))}`
|
|
|
12711
12740
|
stream: true
|
|
12712
12741
|
});
|
|
12713
12742
|
} catch (err) {
|
|
12743
|
+
if (err instanceof RemoteCommandError && err.exitCode === TARGET_REMOVED_EXIT) {
|
|
12744
|
+
await reporter.finish({
|
|
12745
|
+
status: "failed",
|
|
12746
|
+
error: "The target was removed while this deploy was under way."
|
|
12747
|
+
});
|
|
12748
|
+
await reportEnvironmentDestroyed(workspaceRootDir, ctx.envTag, {
|
|
12749
|
+
missingOk: true
|
|
12750
|
+
});
|
|
12751
|
+
throw new TargetRemovedError(
|
|
12752
|
+
`${ctx.appName} (${ctx.targetName}) was removed from ${ctx.server} after this deploy began, so it was not put back.`
|
|
12753
|
+
);
|
|
12754
|
+
}
|
|
12714
12755
|
await reporter.finish({
|
|
12715
12756
|
status: "failed",
|
|
12716
12757
|
error: err instanceof Error ? err.message : String(err)
|