vela 0.20.0 → 0.22.0
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 +1002 -784
- package/dist/bin.js.map +4 -4
- package/package.json +4 -3
package/dist/bin.js
CHANGED
|
@@ -12,15 +12,15 @@ function normalizeArgv(argv) {
|
|
|
12
12
|
|
|
13
13
|
// src/program.ts
|
|
14
14
|
import process54 from "node:process";
|
|
15
|
-
import * as
|
|
16
|
-
import { Command as
|
|
15
|
+
import * as p75 from "@clack/prompts";
|
|
16
|
+
import { Command as Command122 } from "commander";
|
|
17
17
|
import nodePath from "node:path";
|
|
18
18
|
import dotenv2 from "dotenv";
|
|
19
19
|
|
|
20
20
|
// package.json
|
|
21
21
|
var package_default = {
|
|
22
22
|
name: "vela",
|
|
23
|
-
version: "0.
|
|
23
|
+
version: "0.22.0",
|
|
24
24
|
type: "module",
|
|
25
25
|
description: "A CLI for creating and updating SvelteKit projects",
|
|
26
26
|
license: "MIT",
|
|
@@ -57,7 +57,7 @@ var package_default = {
|
|
|
57
57
|
dependencies: {
|
|
58
58
|
"@clack/prompts": "^1.7.0",
|
|
59
59
|
"@faker-js/faker": "^10.6.0",
|
|
60
|
-
"@velastack/patterns": "^0.
|
|
60
|
+
"@velastack/patterns": "^0.10.1",
|
|
61
61
|
"@velastack/pocketbase-codegen": "^0.1.0",
|
|
62
62
|
"@velastack/schema": "^0.3.0",
|
|
63
63
|
"@velastack/schema-ui": "^0.3.1",
|
|
@@ -65,6 +65,7 @@ var package_default = {
|
|
|
65
65
|
commander: "^15.0.0",
|
|
66
66
|
"cross-spawn": "^7.0.6",
|
|
67
67
|
dedent: "^1.7.2",
|
|
68
|
+
devalue: "^5.9.4",
|
|
68
69
|
dotenv: "^18.0.1",
|
|
69
70
|
"fetch-cookie": "^3.2.0",
|
|
70
71
|
"json-schema-faker": "^0.6.3",
|
|
@@ -73,7 +74,7 @@ var package_default = {
|
|
|
73
74
|
picocolors: "^1.1.1",
|
|
74
75
|
pocketbase: "^0.28.0",
|
|
75
76
|
"pocketbase-server": "^0.40.6-beta.5",
|
|
76
|
-
stripe: "^
|
|
77
|
+
stripe: "^23.0.1",
|
|
77
78
|
sv: "~1.1.1",
|
|
78
79
|
svelte: "^5.56.10",
|
|
79
80
|
tar: "^7.5.22",
|
|
@@ -419,9 +420,9 @@ function minOfComparatorSet(set) {
|
|
|
419
420
|
if (upperOnly) return { major: 0, minor: 0, patch: 0, prerelease: [] };
|
|
420
421
|
return floor;
|
|
421
422
|
}
|
|
422
|
-
function parseVersionPart(
|
|
423
|
-
if (
|
|
424
|
-
const match =
|
|
423
|
+
function parseVersionPart(text20) {
|
|
424
|
+
if (text20 === "" || text20 === "*" || text20 === "x" || text20 === "X") return null;
|
|
425
|
+
const match = text20.match(VERSION_PART);
|
|
425
426
|
if (!match) return null;
|
|
426
427
|
const nums = [match[1], match[2], match[3]];
|
|
427
428
|
const firstWild = nums.findIndex((n) => n === void 0 || /^[xX*]$/.test(n));
|
|
@@ -609,6 +610,9 @@ function detectFeatures(root, { isAppMode }) {
|
|
|
609
610
|
whatsapp: has("src/routes/(public)/(auth)/whatsapp"),
|
|
610
611
|
// The cart store every provider's ecommerce files share a path for.
|
|
611
612
|
ecommerce: has("src/lib/cart.svelte.ts"),
|
|
613
|
+
notifications: has("src/lib/server/notifications.ts"),
|
|
614
|
+
subscriptions: has("src/lib/workflows/sync-stripe-subscriptions.ts"),
|
|
615
|
+
orders: has("src/routes/webhooks/stripe/handlers/checkout"),
|
|
612
616
|
ui: detectUi(root)
|
|
613
617
|
};
|
|
614
618
|
}
|
|
@@ -914,10 +918,10 @@ function writeCachedIndex(cached2) {
|
|
|
914
918
|
fs6.mkdirSync(cacheRoot(), { recursive: true });
|
|
915
919
|
fs6.writeFileSync(indexCachePath(), JSON.stringify(cached2, null, 2));
|
|
916
920
|
}
|
|
917
|
-
function parseTemplateIndex(
|
|
921
|
+
function parseTemplateIndex(text20, url) {
|
|
918
922
|
let parsed;
|
|
919
923
|
try {
|
|
920
|
-
parsed = JSON.parse(
|
|
924
|
+
parsed = JSON.parse(text20);
|
|
921
925
|
} catch (e) {
|
|
922
926
|
throw new Error(`Template index at ${url} is not valid JSON: ${e.message}`);
|
|
923
927
|
}
|
|
@@ -1867,8 +1871,8 @@ async function readSite(root) {
|
|
|
1867
1871
|
if (!property || !Node6.isPropertyAssignment(property)) continue;
|
|
1868
1872
|
const value = property.getInitializer();
|
|
1869
1873
|
if (Node6.isStringLiteral(value) || Node6.isNoSubstitutionTemplateLiteral(value)) {
|
|
1870
|
-
const
|
|
1871
|
-
if (
|
|
1874
|
+
const text20 = value.getLiteralValue().trim();
|
|
1875
|
+
if (text20) info[key] = text20;
|
|
1872
1876
|
}
|
|
1873
1877
|
}
|
|
1874
1878
|
return info;
|
|
@@ -2140,8 +2144,8 @@ function mergeOriginConfig(root, options = {}) {
|
|
|
2140
2144
|
const sources = findPrerenderOrigins(arg);
|
|
2141
2145
|
const pathsProp = arg.getProperty("paths");
|
|
2142
2146
|
const paths = pathsProp && Node.isPropertyAssignment(pathsProp) ? pathsProp.getInitializerIfKind(SyntaxKind2.ObjectLiteralExpression) : void 0;
|
|
2143
|
-
const hasPathsOrigin = paths !== void 0 && hasOrigin(paths) || arg.getProperties().some((
|
|
2144
|
-
const spread = conditionalSpreadOf(
|
|
2147
|
+
const hasPathsOrigin = paths !== void 0 && hasOrigin(paths) || arg.getProperties().some((p76) => {
|
|
2148
|
+
const spread = conditionalSpreadOf(p76, "paths");
|
|
2145
2149
|
return spread !== void 0 && hasOrigin(spread.object);
|
|
2146
2150
|
});
|
|
2147
2151
|
if (sources === "unsupported") {
|
|
@@ -2203,15 +2207,15 @@ function mergeOriginConfig(root, options = {}) {
|
|
|
2203
2207
|
}
|
|
2204
2208
|
}
|
|
2205
2209
|
if (staleComment && !hasPathsOrigin && !paths) {
|
|
2206
|
-
const target = arg.getProperties().find((
|
|
2210
|
+
const target = arg.getProperties().find((p76) => isOriginElement(p76));
|
|
2207
2211
|
if (target) setOriginComment(target);
|
|
2208
2212
|
}
|
|
2209
2213
|
if (orphaned.length > 0) {
|
|
2210
|
-
let
|
|
2214
|
+
let text20 = vite.sourceFile.getFullText();
|
|
2211
2215
|
for (const comment of orphaned) {
|
|
2212
|
-
|
|
2216
|
+
text20 = text20.replace(new RegExp(String.raw`\n[\t ]*${escapeRegExp2(comment)}[\t ]*(?=\n)`), "");
|
|
2213
2217
|
}
|
|
2214
|
-
vite.sourceFile.replaceWithText(
|
|
2218
|
+
vite.sourceFile.replaceWithText(text20);
|
|
2215
2219
|
}
|
|
2216
2220
|
vite.sourceFile.saveSync();
|
|
2217
2221
|
const moved = hasPathsOrigin ? "removed prerender.origin, which SvelteKit 3 no longer accepts; kept the existing paths.origin" : "moved prerender.origin to paths.origin";
|
|
@@ -2224,12 +2228,12 @@ function mergeOriginConfig(root, options = {}) {
|
|
|
2224
2228
|
function configSetsOrigin(arg) {
|
|
2225
2229
|
const prerender = findPrerenderOrigins(arg);
|
|
2226
2230
|
if (prerender === "unsupported" || prerender.length > 0) return true;
|
|
2227
|
-
return arg.getProperties().some((
|
|
2228
|
-
if (Node.isPropertyAssignment(
|
|
2229
|
-
const paths =
|
|
2231
|
+
return arg.getProperties().some((p76) => {
|
|
2232
|
+
if (Node.isPropertyAssignment(p76) && p76.getName() === "paths") {
|
|
2233
|
+
const paths = p76.getInitializerIfKind(SyntaxKind2.ObjectLiteralExpression);
|
|
2230
2234
|
return paths !== void 0 && hasOrigin(paths);
|
|
2231
2235
|
}
|
|
2232
|
-
const spread = conditionalSpreadOf(
|
|
2236
|
+
const spread = conditionalSpreadOf(p76, "paths");
|
|
2233
2237
|
return spread !== void 0 && hasOrigin(spread.object);
|
|
2234
2238
|
});
|
|
2235
2239
|
}
|
|
@@ -2243,8 +2247,8 @@ var ORIGIN_COMMENT = [
|
|
|
2243
2247
|
"baked in at build time. It is left unset for a deploy that serves more",
|
|
2244
2248
|
"than one host, where each request's own origin is used instead."
|
|
2245
2249
|
];
|
|
2246
|
-
function escapeRegExp2(
|
|
2247
|
-
return
|
|
2250
|
+
function escapeRegExp2(text20) {
|
|
2251
|
+
return text20.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2248
2252
|
}
|
|
2249
2253
|
function mentionsPrerender(node) {
|
|
2250
2254
|
return node.getLeadingCommentRanges().some((c) => /prerender/i.test(c.getText()));
|
|
@@ -2352,7 +2356,7 @@ function originValue(prop) {
|
|
|
2352
2356
|
}
|
|
2353
2357
|
function hasOrigin(object8) {
|
|
2354
2358
|
return object8.getProperties().some(
|
|
2355
|
-
(
|
|
2359
|
+
(p76) => p76.getKind() !== SyntaxKind2.SpreadAssignment ? p76.getName?.() === "origin" : conditionalSpreadOf(p76, "origin") !== void 0
|
|
2356
2360
|
);
|
|
2357
2361
|
}
|
|
2358
2362
|
function findPrerenderOrigins(arg) {
|
|
@@ -2541,7 +2545,7 @@ function detectJsonIndent(source) {
|
|
|
2541
2545
|
var PRINT_WIDTH = 100;
|
|
2542
2546
|
function stringifyJson(value, indent, level = 0, prefix = 0) {
|
|
2543
2547
|
const pad2 = (n) => indent.repeat(n);
|
|
2544
|
-
const width = (
|
|
2548
|
+
const width = (text20) => text20.replaceAll(" ", " ").length;
|
|
2545
2549
|
if (Array.isArray(value)) {
|
|
2546
2550
|
if (value.length === 0) return "[]";
|
|
2547
2551
|
const scalars = value.every((v14) => v14 === null || typeof v14 !== "object");
|
|
@@ -3135,7 +3139,7 @@ import path30 from "node:path";
|
|
|
3135
3139
|
import process16 from "node:process";
|
|
3136
3140
|
import * as v5 from "valibot";
|
|
3137
3141
|
import { Command as Command3 } from "commander";
|
|
3138
|
-
import * as
|
|
3142
|
+
import * as p12 from "@clack/prompts";
|
|
3139
3143
|
import { detect as detect5, resolveCommand as resolveCommand3 } from "package-manager-detector";
|
|
3140
3144
|
|
|
3141
3145
|
// src/lib/schema-create.ts
|
|
@@ -3853,46 +3857,195 @@ async function seedLinkedProject(apiKey, projectId, template) {
|
|
|
3853
3857
|
|
|
3854
3858
|
// src/commands/login.ts
|
|
3855
3859
|
import os4 from "node:os";
|
|
3856
|
-
import process14 from "node:process";
|
|
3857
3860
|
import { Command as Command2 } from "commander";
|
|
3858
|
-
import * as
|
|
3861
|
+
import * as p10 from "@clack/prompts";
|
|
3859
3862
|
import makeFetchCookie from "fetch-cookie";
|
|
3863
|
+
|
|
3864
|
+
// src/lib/account.ts
|
|
3865
|
+
import process14 from "node:process";
|
|
3866
|
+
import * as p9 from "@clack/prompts";
|
|
3867
|
+
import { parse } from "devalue";
|
|
3868
|
+
var NO_WHATSAPP = { enabled: false, allowSignup: false };
|
|
3869
|
+
async function fetchAuthMethods() {
|
|
3870
|
+
try {
|
|
3871
|
+
const res = await fetch(`${API_URL}/api/collections/users/auth-methods`);
|
|
3872
|
+
if (!res.ok) return { password: true, whatsapp: NO_WHATSAPP };
|
|
3873
|
+
const data = await res.json();
|
|
3874
|
+
return {
|
|
3875
|
+
password: data.password?.enabled !== false,
|
|
3876
|
+
whatsapp: {
|
|
3877
|
+
enabled: data.whatsapp?.enabled === true,
|
|
3878
|
+
allowSignup: data.whatsapp?.allowSignup === true
|
|
3879
|
+
}
|
|
3880
|
+
};
|
|
3881
|
+
} catch {
|
|
3882
|
+
return { password: true, whatsapp: NO_WHATSAPP };
|
|
3883
|
+
}
|
|
3884
|
+
}
|
|
3885
|
+
async function chooseAuthMethod(kind, methods) {
|
|
3886
|
+
const whatsapp3 = methods.whatsapp.enabled && (kind === "login" || methods.whatsapp.allowSignup);
|
|
3887
|
+
if (!whatsapp3) return "password";
|
|
3888
|
+
if (!methods.password) return "whatsapp";
|
|
3889
|
+
const choice = await p9.select({
|
|
3890
|
+
message: kind === "signup" ? "How do you want to sign up?" : "How do you want to log in?",
|
|
3891
|
+
options: [
|
|
3892
|
+
{ value: "password", label: "Email and password" },
|
|
3893
|
+
{ value: "whatsapp", label: "WhatsApp", hint: "a one-time code on your phone" }
|
|
3894
|
+
]
|
|
3895
|
+
});
|
|
3896
|
+
if (p9.isCancel(choice)) cancelled();
|
|
3897
|
+
return choice;
|
|
3898
|
+
}
|
|
3899
|
+
function cancelled() {
|
|
3900
|
+
p9.cancel("Operation cancelled.");
|
|
3901
|
+
process14.exit(0);
|
|
3902
|
+
}
|
|
3903
|
+
async function postForm(fetchCookie, path68, fields) {
|
|
3904
|
+
const res = await fetchCookie(`${API_URL}${path68}`, {
|
|
3905
|
+
method: "POST",
|
|
3906
|
+
headers: {
|
|
3907
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
3908
|
+
Accept: "application/json",
|
|
3909
|
+
"x-sveltekit-action": "true",
|
|
3910
|
+
Origin: API_URL
|
|
3911
|
+
},
|
|
3912
|
+
body: new URLSearchParams(fields).toString()
|
|
3913
|
+
});
|
|
3914
|
+
let result;
|
|
3915
|
+
try {
|
|
3916
|
+
result = await res.json();
|
|
3917
|
+
} catch {
|
|
3918
|
+
return { type: "error", message: `velastack.dev answered ${res.status}` };
|
|
3919
|
+
}
|
|
3920
|
+
switch (result.type) {
|
|
3921
|
+
case "redirect":
|
|
3922
|
+
return { type: "redirect", location: result.location ?? "/" };
|
|
3923
|
+
case "success":
|
|
3924
|
+
return { type: "success" };
|
|
3925
|
+
case "failure":
|
|
3926
|
+
return { type: "failure", status: result.status ?? 400, message: formMessage(result.data) };
|
|
3927
|
+
default:
|
|
3928
|
+
return { type: "error", message: result.error?.message ?? null };
|
|
3929
|
+
}
|
|
3930
|
+
}
|
|
3931
|
+
function formMessage(data) {
|
|
3932
|
+
if (!data) return null;
|
|
3933
|
+
let form3;
|
|
3934
|
+
try {
|
|
3935
|
+
({ form: form3 } = parse(data));
|
|
3936
|
+
} catch {
|
|
3937
|
+
return null;
|
|
3938
|
+
}
|
|
3939
|
+
if (typeof form3?.message === "string") return form3.message;
|
|
3940
|
+
if (form3?.message?.text) return form3.message.text;
|
|
3941
|
+
for (const errors of Object.values(form3?.errors ?? {})) {
|
|
3942
|
+
if (errors?.[0]) return errors[0];
|
|
3943
|
+
}
|
|
3944
|
+
return null;
|
|
3945
|
+
}
|
|
3946
|
+
function redirectedTo(result) {
|
|
3947
|
+
if (result.type !== "redirect") return null;
|
|
3948
|
+
return new URL(result.location, API_URL).pathname;
|
|
3949
|
+
}
|
|
3950
|
+
function validatePhone(value) {
|
|
3951
|
+
const raw = (value ?? "").trim().replace(/^00/, "+");
|
|
3952
|
+
if (!raw.startsWith("+")) return "Enter the number in international format, eg. +16165550123";
|
|
3953
|
+
const rest = raw.slice(1);
|
|
3954
|
+
if (/[^0-9 .()-]/.test(rest)) return "Enter the number in international format, eg. +16165550123";
|
|
3955
|
+
const digits = rest.replace(/[^0-9]/g, "");
|
|
3956
|
+
if (digits.length < 8 || digits.length > 15 || digits.startsWith("0")) {
|
|
3957
|
+
return "Enter the number in international format, eg. +16165550123";
|
|
3958
|
+
}
|
|
3959
|
+
return void 0;
|
|
3960
|
+
}
|
|
3961
|
+
var CODE_ATTEMPTS = 3;
|
|
3962
|
+
async function signInWithWhatsApp(fetchCookie, kind) {
|
|
3963
|
+
const phone = await p9.text({
|
|
3964
|
+
message: "WhatsApp number",
|
|
3965
|
+
placeholder: "+1 616 555 0123",
|
|
3966
|
+
validate: validatePhone
|
|
3967
|
+
});
|
|
3968
|
+
if (p9.isCancel(phone)) cancelled();
|
|
3969
|
+
const sent = await postForm(fetchCookie, `/${kind}`, { type: "whatsapp", phone: phone.trim() });
|
|
3970
|
+
const codePath = redirectedTo(sent);
|
|
3971
|
+
const otpId = codePath?.match(/^\/whatsapp\/([^/]+)$/)?.[1];
|
|
3972
|
+
if (!otpId) {
|
|
3973
|
+
throw new Error(failureText(sent, "Failed to send the WhatsApp code."));
|
|
3974
|
+
}
|
|
3975
|
+
p9.log.info("We sent a code to your WhatsApp.");
|
|
3976
|
+
for (let attempt = 1; ; attempt++) {
|
|
3977
|
+
const code2 = await p9.text({
|
|
3978
|
+
message: "Code",
|
|
3979
|
+
validate: (value) => /^\d{4,8}$/.test((value ?? "").trim()) ? void 0 : "Enter the code"
|
|
3980
|
+
});
|
|
3981
|
+
if (p9.isCancel(code2)) cancelled();
|
|
3982
|
+
const verified = await postForm(fetchCookie, codePath, { otp: code2.trim() });
|
|
3983
|
+
const next = redirectedTo(verified);
|
|
3984
|
+
if (next) {
|
|
3985
|
+
const isNew = next.startsWith("/welcome");
|
|
3986
|
+
if (isNew) await askForName(fetchCookie);
|
|
3987
|
+
return { isNew };
|
|
3988
|
+
}
|
|
3989
|
+
if (verified.type !== "failure") {
|
|
3990
|
+
throw new Error(failureText(verified, "Failed to verify the code."));
|
|
3991
|
+
}
|
|
3992
|
+
if (attempt >= CODE_ATTEMPTS) {
|
|
3993
|
+
throw new Error(
|
|
3994
|
+
`${verified.message ?? "The code is wrong or has expired."} Run \`vela ${kind}\` again.`
|
|
3995
|
+
);
|
|
3996
|
+
}
|
|
3997
|
+
p9.log.warn(`${verified.message ?? "That code is wrong or has expired."} Try again.`);
|
|
3998
|
+
}
|
|
3999
|
+
}
|
|
4000
|
+
function failureText(result, fallback) {
|
|
4001
|
+
const message = result.type === "failure" || result.type === "error" ? result.message : null;
|
|
4002
|
+
return message ?? `${fallback} Try again or contact support.`;
|
|
4003
|
+
}
|
|
4004
|
+
async function askForName(fetchCookie) {
|
|
4005
|
+
const name = await p9.text({
|
|
4006
|
+
message: "Your name",
|
|
4007
|
+
validate: (value) => (value ?? "").trim() ? void 0 : "Enter your name"
|
|
4008
|
+
});
|
|
4009
|
+
if (p9.isCancel(name)) cancelled();
|
|
4010
|
+
const res = await postForm(fetchCookie, "/welcome", { name: name.trim() });
|
|
4011
|
+
if (!redirectedTo(res)) {
|
|
4012
|
+
p9.log.warn("Could not save your name. You can set it at https://velastack.dev/settings");
|
|
4013
|
+
}
|
|
4014
|
+
}
|
|
4015
|
+
|
|
4016
|
+
// src/commands/login.ts
|
|
3860
4017
|
var login = new Command2("login").description("login to velastack.dev").configureHelp(helpConfig).action(
|
|
3861
4018
|
() => runCommand(async () => {
|
|
3862
4019
|
await loginInteractively();
|
|
3863
|
-
|
|
4020
|
+
p10.log.success("Logged in to velastack.dev");
|
|
3864
4021
|
}, "Failed to login.")
|
|
3865
4022
|
);
|
|
3866
4023
|
async function loginInteractively() {
|
|
3867
|
-
const
|
|
4024
|
+
const method = await chooseAuthMethod("login", await fetchAuthMethods());
|
|
4025
|
+
const fetchCookie = makeFetchCookie(fetch);
|
|
4026
|
+
if (method === "whatsapp") {
|
|
4027
|
+
await signInWithWhatsApp(fetchCookie, "login");
|
|
4028
|
+
} else {
|
|
4029
|
+
await loginWithPassword(fetchCookie);
|
|
4030
|
+
}
|
|
4031
|
+
const apiKey = await issueApiKey(fetchCookie);
|
|
4032
|
+
writeConfig({ apiKey });
|
|
4033
|
+
return apiKey;
|
|
4034
|
+
}
|
|
4035
|
+
async function loginWithPassword(fetchCookie) {
|
|
4036
|
+
const { email: email2, password: password8 } = await p10.group(
|
|
3868
4037
|
{
|
|
3869
|
-
email: () =>
|
|
3870
|
-
password: () =>
|
|
4038
|
+
email: () => p10.text({ message: "Email" }),
|
|
4039
|
+
password: () => p10.password({ message: "Password" })
|
|
3871
4040
|
},
|
|
3872
|
-
{
|
|
3873
|
-
onCancel: () => {
|
|
3874
|
-
p9.cancel("Operation cancelled.");
|
|
3875
|
-
process14.exit(0);
|
|
3876
|
-
}
|
|
3877
|
-
}
|
|
4041
|
+
{ onCancel: cancelled }
|
|
3878
4042
|
);
|
|
3879
|
-
const
|
|
3880
|
-
|
|
3881
|
-
method: "POST",
|
|
3882
|
-
headers: {
|
|
3883
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
3884
|
-
Origin: API_URL
|
|
3885
|
-
},
|
|
3886
|
-
body: new URLSearchParams({ type: "password", email: email2, password: password8 }).toString()
|
|
3887
|
-
});
|
|
3888
|
-
if (!loginRes.headers.get("Set-Cookie")) {
|
|
4043
|
+
const result = await postForm(fetchCookie, "/login", { type: "password", email: email2, password: password8 });
|
|
4044
|
+
if (result.type !== "redirect") {
|
|
3889
4045
|
throw new Error(
|
|
3890
|
-
"Run
|
|
4046
|
+
`${failureText(result, "Failed to authenticate.")} Run \`vela signup\` to create an account or reset at https://velastack.dev/reset`
|
|
3891
4047
|
);
|
|
3892
4048
|
}
|
|
3893
|
-
const apiKey = await issueApiKey(fetchCookie);
|
|
3894
|
-
writeConfig({ apiKey });
|
|
3895
|
-
return apiKey;
|
|
3896
4049
|
}
|
|
3897
4050
|
async function issueApiKey(fetchCookie) {
|
|
3898
4051
|
const label2 = `CLI - ${os4.hostname()}`;
|
|
@@ -3937,7 +4090,7 @@ import path28 from "node:path";
|
|
|
3937
4090
|
import process15 from "node:process";
|
|
3938
4091
|
import { execFileSync, spawn as spawn3 } from "node:child_process";
|
|
3939
4092
|
import { createRequire as createRequire3 } from "node:module";
|
|
3940
|
-
import * as
|
|
4093
|
+
import * as p11 from "@clack/prompts";
|
|
3941
4094
|
import { x as x2 } from "tinyexec";
|
|
3942
4095
|
import { detect as detect4 } from "package-manager-detector";
|
|
3943
4096
|
import {
|
|
@@ -4397,10 +4550,10 @@ var npmViewLookup = (name, range, cwd) => new Promise((resolve2, reject) => {
|
|
|
4397
4550
|
(error, stdout, stderr) => {
|
|
4398
4551
|
if (error && /\bE404\b/.test(`${stderr}${error.message}`)) return resolve2(null);
|
|
4399
4552
|
if (error) return reject(error);
|
|
4400
|
-
const
|
|
4401
|
-
if (!
|
|
4553
|
+
const text20 = stdout.trim();
|
|
4554
|
+
if (!text20) return resolve2(null);
|
|
4402
4555
|
try {
|
|
4403
|
-
resolve2(newest(JSON.parse(
|
|
4556
|
+
resolve2(newest(JSON.parse(text20)));
|
|
4404
4557
|
} catch (e) {
|
|
4405
4558
|
reject(e);
|
|
4406
4559
|
}
|
|
@@ -4489,7 +4642,7 @@ function keyName(node) {
|
|
|
4489
4642
|
return node.getNameNode().getText().replace(/^['"`]|['"`]$/g, "");
|
|
4490
4643
|
}
|
|
4491
4644
|
function localesProperty(alias) {
|
|
4492
|
-
return alias.getProperties().find((
|
|
4645
|
+
return alias.getProperties().find((p76) => keyName(p76) === "$locales");
|
|
4493
4646
|
}
|
|
4494
4647
|
function localesSpecifier(root, rest) {
|
|
4495
4648
|
if (/\.(?:js|mjs|cjs|json)$/.test(rest)) return `#locales/${rest}`;
|
|
@@ -4696,8 +4849,8 @@ var KEPT_EXTENSIONS = /\.(svelte|svg|svx|css|json)$/;
|
|
|
4696
4849
|
var MODULE_EXTENSIONS = [".ts", ".js", ".mts", ".mjs"];
|
|
4697
4850
|
function resolveLibPath(root, rel) {
|
|
4698
4851
|
const lib = path26.join(root, "src", "lib");
|
|
4699
|
-
const isFile = (
|
|
4700
|
-
const isDir = (
|
|
4852
|
+
const isFile = (p76) => fs27.existsSync(path26.join(lib, p76)) && fs27.statSync(path26.join(lib, p76)).isFile();
|
|
4853
|
+
const isDir = (p76) => fs27.existsSync(path26.join(lib, p76)) && fs27.statSync(path26.join(lib, p76)).isDirectory();
|
|
4701
4854
|
if (rel === "") return "";
|
|
4702
4855
|
if (KEPT_EXTENSIONS.test(rel)) {
|
|
4703
4856
|
if (isFile(rel)) return rel;
|
|
@@ -4857,14 +5010,14 @@ function skipString(source, start) {
|
|
|
4857
5010
|
}
|
|
4858
5011
|
return -1;
|
|
4859
5012
|
}
|
|
4860
|
-
function splitTopLevel(
|
|
5013
|
+
function splitTopLevel(text20) {
|
|
4861
5014
|
const parts = [];
|
|
4862
5015
|
let depth = 0;
|
|
4863
5016
|
let partStart = 0;
|
|
4864
|
-
for (let i = 0; i <
|
|
4865
|
-
const c =
|
|
5017
|
+
for (let i = 0; i < text20.length; i++) {
|
|
5018
|
+
const c = text20[i];
|
|
4866
5019
|
if (c === '"' || c === "'" || c === "`") {
|
|
4867
|
-
const end = skipString(
|
|
5020
|
+
const end = skipString(text20, i);
|
|
4868
5021
|
if (end === -1) break;
|
|
4869
5022
|
i = end;
|
|
4870
5023
|
continue;
|
|
@@ -4872,12 +5025,12 @@ function splitTopLevel(text19) {
|
|
|
4872
5025
|
if (c === "(" || c === "{" || c === "[") depth++;
|
|
4873
5026
|
else if (c === ")" || c === "}" || c === "]") depth--;
|
|
4874
5027
|
else if (c === "," && depth === 0) {
|
|
4875
|
-
parts.push({ start: partStart, end: i, text:
|
|
5028
|
+
parts.push({ start: partStart, end: i, text: text20.slice(partStart, i) });
|
|
4876
5029
|
partStart = i + 1;
|
|
4877
5030
|
}
|
|
4878
5031
|
}
|
|
4879
|
-
if (
|
|
4880
|
-
parts.push({ start: partStart, end:
|
|
5032
|
+
if (text20.slice(partStart).trim()) {
|
|
5033
|
+
parts.push({ start: partStart, end: text20.length, text: text20.slice(partStart) });
|
|
4881
5034
|
}
|
|
4882
5035
|
return parts;
|
|
4883
5036
|
}
|
|
@@ -4928,21 +5081,21 @@ function rewriteGotoCalls(source, gotoNames) {
|
|
|
4928
5081
|
function rewriteGotoOptions(inner) {
|
|
4929
5082
|
const tail = inner.match(/,?\s*$/)[0];
|
|
4930
5083
|
const core = inner.slice(0, inner.length - tail.length);
|
|
4931
|
-
const keyed = splitTopLevel(core).map((
|
|
4932
|
-
const m =
|
|
5084
|
+
const keyed = splitTopLevel(core).map((p76) => {
|
|
5085
|
+
const m = p76.text.match(/^\s*(['"]?)([A-Za-z_$][\w$]*)\1\s*(?::\s*([\s\S]*?))?\s*$/);
|
|
4933
5086
|
return {
|
|
4934
|
-
...
|
|
5087
|
+
...p76,
|
|
4935
5088
|
key: m?.[2],
|
|
4936
5089
|
value: m ? m[3] ?? m[2] : void 0,
|
|
4937
5090
|
shorthand: m ? m[3] === void 0 : false
|
|
4938
5091
|
};
|
|
4939
5092
|
});
|
|
4940
|
-
const flags = keyed.filter((
|
|
5093
|
+
const flags = keyed.filter((p76) => p76.key === "noScroll" || p76.key === "keepFocus");
|
|
4941
5094
|
const summary = [];
|
|
4942
5095
|
const replaced = /* @__PURE__ */ new Map();
|
|
4943
5096
|
if (flags.length > 0) {
|
|
4944
5097
|
const values = flags.map((f) => f.shorthand ? void 0 : f.value?.trim());
|
|
4945
|
-
if (keyed.some((
|
|
5098
|
+
if (keyed.some((p76) => p76.key === "reset")) {
|
|
4946
5099
|
return {
|
|
4947
5100
|
inner,
|
|
4948
5101
|
summary: "",
|
|
@@ -4973,29 +5126,29 @@ function rewriteGotoOptions(inner) {
|
|
|
4973
5126
|
`${flags.map((f) => `${f.key}: ${f.value.trim()}`).join(", ")} \u2192 reset: ${allTrue ? "false" : "true"}`
|
|
4974
5127
|
);
|
|
4975
5128
|
}
|
|
4976
|
-
const invalidate = keyed.findIndex((
|
|
5129
|
+
const invalidate = keyed.findIndex((p76) => p76.key === "invalidateAll");
|
|
4977
5130
|
if (invalidate !== -1) {
|
|
4978
|
-
const
|
|
5131
|
+
const p76 = keyed[invalidate];
|
|
4979
5132
|
if (keyed.some((q) => q.key === "refreshAll")) {
|
|
4980
5133
|
replaced.set(invalidate, null);
|
|
4981
5134
|
summary.push("dropped invalidateAll (refreshAll already set)");
|
|
4982
|
-
} else if (
|
|
4983
|
-
replaced.set(invalidate,
|
|
5135
|
+
} else if (p76.shorthand) {
|
|
5136
|
+
replaced.set(invalidate, p76.text.replace("invalidateAll", "refreshAll: invalidateAll"));
|
|
4984
5137
|
summary.push("invalidateAll \u2192 refreshAll");
|
|
4985
5138
|
} else {
|
|
4986
|
-
replaced.set(invalidate,
|
|
5139
|
+
replaced.set(invalidate, p76.text.replace("invalidateAll", "refreshAll"));
|
|
4987
5140
|
summary.push("invalidateAll \u2192 refreshAll");
|
|
4988
5141
|
}
|
|
4989
5142
|
}
|
|
4990
5143
|
if (replaced.size === 0) return { inner, summary: "" };
|
|
4991
|
-
const kept = keyed.map((
|
|
5144
|
+
const kept = keyed.map((p76, i) => replaced.has(i) ? replaced.get(i) : p76.text).filter((t) => t !== null);
|
|
4992
5145
|
let joined = kept.join(",");
|
|
4993
5146
|
const lead = core.match(/^\s*/)[0];
|
|
4994
5147
|
if (!joined.startsWith(lead)) joined = lead + joined.trimStart();
|
|
4995
5148
|
return { inner: joined + tail, summary: summary.join("; ") };
|
|
4996
5149
|
}
|
|
4997
|
-
function escapeRegExp3(
|
|
4998
|
-
return
|
|
5150
|
+
function escapeRegExp3(text20) {
|
|
5151
|
+
return text20.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4999
5152
|
}
|
|
5000
5153
|
function rewriteInvalidateAll(source) {
|
|
5001
5154
|
const outcome = { edits: [], changes: [], tasks: [] };
|
|
@@ -5080,9 +5233,9 @@ function addTaskComments(source, file, tasks) {
|
|
|
5080
5233
|
const lineStart2 = code2.lastIndexOf("\n", index - 1) + 1;
|
|
5081
5234
|
const lineEnd = code2.indexOf("\n", index);
|
|
5082
5235
|
const excerpt = code2.slice(lineStart2, lineEnd === -1 ? void 0 : lineEnd).trim().replace(/--/g, "- -").slice(0, 80);
|
|
5083
|
-
const
|
|
5084
|
-
if (code2.includes(
|
|
5085
|
-
code2 = `<!-- ${
|
|
5236
|
+
const text20 = `${MIGRATION_TASK_MARKER} \`${excerpt}\`: ${message}`;
|
|
5237
|
+
if (code2.includes(text20)) continue;
|
|
5238
|
+
code2 = `<!-- ${text20} -->
|
|
5086
5239
|
${code2}`;
|
|
5087
5240
|
added.push(`line ${line}: ${message}`);
|
|
5088
5241
|
continue;
|
|
@@ -5265,15 +5418,15 @@ var Kit3MigrationError = class extends Error {
|
|
|
5265
5418
|
name = "Kit3MigrationError";
|
|
5266
5419
|
};
|
|
5267
5420
|
var clackLog = {
|
|
5268
|
-
step: (m) =>
|
|
5269
|
-
info: (m) =>
|
|
5270
|
-
warn: (m) =>
|
|
5271
|
-
success: (m) =>
|
|
5421
|
+
step: (m) => p11.log.step(m),
|
|
5422
|
+
info: (m) => p11.log.info(m),
|
|
5423
|
+
warn: (m) => p11.log.warn(m),
|
|
5424
|
+
success: (m) => p11.log.success(m)
|
|
5272
5425
|
};
|
|
5273
5426
|
async function runKit3Migration(root, options = {}) {
|
|
5274
5427
|
const quiet = options.quiet ?? false;
|
|
5275
5428
|
const base2 = options.log ?? clackLog;
|
|
5276
|
-
const
|
|
5429
|
+
const log58 = quiet ? { ...base2, step: () => {
|
|
5277
5430
|
}, info: () => {
|
|
5278
5431
|
}, success: () => {
|
|
5279
5432
|
} } : base2;
|
|
@@ -5284,19 +5437,19 @@ async function runKit3Migration(root, options = {}) {
|
|
|
5284
5437
|
let paramTypes = /* @__PURE__ */ new Set();
|
|
5285
5438
|
if (mode === "repair") {
|
|
5286
5439
|
sv.skipped = "SvelteKit 3 already, with no svelte.config: running only the vela steps";
|
|
5287
|
-
|
|
5440
|
+
log58.info("Already on SvelteKit 3: skipping sv and re-checking the vela steps.");
|
|
5288
5441
|
} else if (options.skipSv) {
|
|
5289
5442
|
sv.skipped = "--skip-sv";
|
|
5290
|
-
|
|
5443
|
+
log58.info("Skipping sv (--skip-sv).");
|
|
5291
5444
|
} else {
|
|
5292
|
-
|
|
5293
|
-
sv.cleared = clearOutputDirs(root,
|
|
5445
|
+
log58.step("Running sv migrate sveltekit-3...");
|
|
5446
|
+
sv.cleared = clearOutputDirs(root, log58);
|
|
5294
5447
|
svelteConfig = captureSvelteConfig(root);
|
|
5295
5448
|
paramTypes = captureParamTypeImports(root);
|
|
5296
|
-
await runSv(root, options.runSv ?? defaultSvRunner, quiet, sv,
|
|
5449
|
+
await runSv(root, options.runSv ?? defaultSvRunner, quiet, sv, log58);
|
|
5297
5450
|
sv.ran = true;
|
|
5298
5451
|
}
|
|
5299
|
-
|
|
5452
|
+
log58.step("Applying the vela steps...");
|
|
5300
5453
|
const cliVersion = options.cliVersion ?? package_default.version;
|
|
5301
5454
|
const fixups = [
|
|
5302
5455
|
originFixup(root, svelteConfig, sv),
|
|
@@ -5312,8 +5465,8 @@ async function runKit3Migration(root, options = {}) {
|
|
|
5312
5465
|
lockfileFixup(root)
|
|
5313
5466
|
];
|
|
5314
5467
|
for (const fixup2 of fixups) {
|
|
5315
|
-
if (fixup2.changed)
|
|
5316
|
-
for (const warning of fixup2.warnings)
|
|
5468
|
+
if (fixup2.changed) log58.info(`${fixup2.name}: ${fixup2.details.join("; ")}`);
|
|
5469
|
+
for (const warning of fixup2.warnings) log58.warn(`${fixup2.name}: ${warning}`);
|
|
5317
5470
|
}
|
|
5318
5471
|
let installed2 = null;
|
|
5319
5472
|
let formatted = [];
|
|
@@ -5396,7 +5549,7 @@ function spawnSync(command, args, cwd) {
|
|
|
5396
5549
|
}
|
|
5397
5550
|
var require_ = createRequire3(import.meta.url);
|
|
5398
5551
|
var OUTPUT_DIRS = /* @__PURE__ */ new Set(["dist", "build", ".svelte-kit"]);
|
|
5399
|
-
function clearOutputDirs(root,
|
|
5552
|
+
function clearOutputDirs(root, log58) {
|
|
5400
5553
|
const cleared = [];
|
|
5401
5554
|
const inGit = spawnSync("git", ["rev-parse", "--is-inside-work-tree"], root) !== null;
|
|
5402
5555
|
const walk2 = (dir, depth) => {
|
|
@@ -5410,7 +5563,7 @@ function clearOutputDirs(root, log57) {
|
|
|
5410
5563
|
fs29.rmSync(full, { recursive: true, force: true });
|
|
5411
5564
|
cleared.push(rel);
|
|
5412
5565
|
} else if (entry.name !== ".svelte-kit") {
|
|
5413
|
-
|
|
5566
|
+
log58.warn(
|
|
5414
5567
|
`${rel} is not ignored by git, so it was left in place; sv may fail to parse what is in it.`
|
|
5415
5568
|
);
|
|
5416
5569
|
}
|
|
@@ -5421,7 +5574,7 @@ function clearOutputDirs(root, log57) {
|
|
|
5421
5574
|
}
|
|
5422
5575
|
};
|
|
5423
5576
|
walk2(root, 0);
|
|
5424
|
-
if (cleared.length > 0)
|
|
5577
|
+
if (cleared.length > 0) log58.info(`Removed build output before running sv: ${cleared.join(", ")}`);
|
|
5425
5578
|
return cleared;
|
|
5426
5579
|
}
|
|
5427
5580
|
function svBin() {
|
|
@@ -5476,8 +5629,8 @@ function svArgs(root, tasks, exclude) {
|
|
|
5476
5629
|
}
|
|
5477
5630
|
var ANSI = /\u001b\[[0-9;?]*[A-Za-z]/g;
|
|
5478
5631
|
function parseSvFailure(output) {
|
|
5479
|
-
const
|
|
5480
|
-
const match =
|
|
5632
|
+
const text20 = output.replace(ANSI, "");
|
|
5633
|
+
const match = text20.match(/Task '([^']+)' failed: ([^\n]*)/);
|
|
5481
5634
|
if (!match) return null;
|
|
5482
5635
|
const message = match[2].trim();
|
|
5483
5636
|
const file = message.match(/Unable to process '([^']+)'/)?.[1];
|
|
@@ -5507,7 +5660,7 @@ function excludeGlob(files) {
|
|
|
5507
5660
|
return `{${alternatives.join(",")}}`;
|
|
5508
5661
|
}
|
|
5509
5662
|
var MAX_RETRIES_PER_TASK = 10;
|
|
5510
|
-
async function runSv(root, runner, quiet, summary,
|
|
5663
|
+
async function runSv(root, runner, quiet, summary, log58) {
|
|
5511
5664
|
const first = await runner(svArgs(root, "all", []), { cwd: root, quiet });
|
|
5512
5665
|
if (first.code === 0) return;
|
|
5513
5666
|
const failure = parseSvFailure(first.output);
|
|
@@ -5525,7 +5678,7 @@ async function runSv(root, runner, quiet, summary, log57) {
|
|
|
5525
5678
|
const task = SV_TASKS[i];
|
|
5526
5679
|
if (i === index && !failure.file) continue;
|
|
5527
5680
|
for (let attempt = 0; attempt < MAX_RETRIES_PER_TASK; attempt++) {
|
|
5528
|
-
|
|
5681
|
+
log58.info(
|
|
5529
5682
|
`Re-running sv task ${task}${summary.excluded.length ? `, skipping ${summary.excluded.join(", ")}` : ""}...`
|
|
5530
5683
|
);
|
|
5531
5684
|
const result = await runner(svArgs(root, task, summary.excluded), { cwd: root, quiet });
|
|
@@ -5547,7 +5700,7 @@ async function runSv(root, runner, quiet, summary, log57) {
|
|
|
5547
5700
|
function record(f) {
|
|
5548
5701
|
summary.failures.push(f);
|
|
5549
5702
|
if (f.file && !summary.excluded.includes(f.file)) summary.excluded.push(f.file);
|
|
5550
|
-
|
|
5703
|
+
log58.warn(
|
|
5551
5704
|
f.file ? `sv's ${f.task} task could not process ${f.file}: ${f.message.replace(/^Unable to process '[^']+'\. Reason: /, "")}` : `sv's ${f.task} task failed: ${f.message}`
|
|
5552
5705
|
);
|
|
5553
5706
|
}
|
|
@@ -5567,9 +5720,9 @@ function originFixup(root, capture, sv) {
|
|
|
5567
5720
|
${outcome.snippet}`);
|
|
5568
5721
|
}
|
|
5569
5722
|
const lost = Boolean(carry && !outcome.applied && outcome.snippet);
|
|
5570
|
-
for (const
|
|
5571
|
-
if (carry && !lost && carry.text.endsWith(
|
|
5572
|
-
sv.dropped.push({ file: capture.file, text:
|
|
5723
|
+
for (const text20 of capture?.spreads ?? []) {
|
|
5724
|
+
if (carry && !lost && carry.text.endsWith(text20)) continue;
|
|
5725
|
+
sv.dropped.push({ file: capture.file, text: text20 });
|
|
5573
5726
|
}
|
|
5574
5727
|
return f;
|
|
5575
5728
|
}
|
|
@@ -5869,10 +6022,10 @@ function belowFloor(project, key, entry) {
|
|
|
5869
6022
|
return Boolean(floor && locked && compareVersions(locked, floor) < 0);
|
|
5870
6023
|
}
|
|
5871
6024
|
function readJson(file) {
|
|
5872
|
-
const
|
|
6025
|
+
const text20 = fs29.readFileSync(file, "utf8");
|
|
5873
6026
|
return {
|
|
5874
|
-
data: JSON.parse(
|
|
5875
|
-
indent:
|
|
6027
|
+
data: JSON.parse(text20),
|
|
6028
|
+
indent: text20.match(/^[{[]\s*\n([\t ]+)/)?.[1] ?? " "
|
|
5876
6029
|
};
|
|
5877
6030
|
}
|
|
5878
6031
|
function writeJson(file, data, indent) {
|
|
@@ -5979,13 +6132,13 @@ function previousFollowUps(root, pattern) {
|
|
|
5979
6132
|
const end = content.indexOf("\n## ", start + FOLLOW_UPS_HEADING.length);
|
|
5980
6133
|
return content.slice(start, end === -1 ? void 0 : end).split("\n").filter((line) => line.startsWith("- [") && pattern.test(line)).map((line) => line.replace(/^- \[[ x]\] /, ""));
|
|
5981
6134
|
}
|
|
5982
|
-
function code(
|
|
5983
|
-
const fence =
|
|
5984
|
-
const pad2 =
|
|
5985
|
-
return `${fence}${pad2}${
|
|
6135
|
+
function code(text20) {
|
|
6136
|
+
const fence = text20.includes("`") ? "``" : "`";
|
|
6137
|
+
const pad2 = text20.startsWith("`") || text20.endsWith("`") ? " " : "";
|
|
6138
|
+
return `${fence}${pad2}${text20}${pad2}${fence}`;
|
|
5986
6139
|
}
|
|
5987
|
-
function escape(
|
|
5988
|
-
return
|
|
6140
|
+
function escape(text20) {
|
|
6141
|
+
return text20.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
5989
6142
|
}
|
|
5990
6143
|
function writeFollowUps(root, items, generic) {
|
|
5991
6144
|
const file = path28.join(root, MIGRATION_TASKS_FILE);
|
|
@@ -6127,8 +6280,8 @@ function findRepeaterImport(dir) {
|
|
|
6127
6280
|
for (const entry of entries) {
|
|
6128
6281
|
if (!entry.isFile() || !SOURCE_FILE.test(entry.name)) continue;
|
|
6129
6282
|
const file = path29.join(entry.parentPath, entry.name);
|
|
6130
|
-
const
|
|
6131
|
-
if (
|
|
6283
|
+
const text20 = fs30.readFileSync(file, "utf8");
|
|
6284
|
+
if (text20.includes("CmsRepeater") && REPEATER_IMPORT.test(text20)) {
|
|
6132
6285
|
return path29.relative(dir, file);
|
|
6133
6286
|
}
|
|
6134
6287
|
}
|
|
@@ -6257,7 +6410,7 @@ async function createProject2(cwdArg, options, listing) {
|
|
|
6257
6410
|
const resolved = await resolveCreatableTemplate(template);
|
|
6258
6411
|
const onCancel2 = () => {
|
|
6259
6412
|
resolved.cleanup();
|
|
6260
|
-
|
|
6413
|
+
p12.cancel("Operation cancelled.");
|
|
6261
6414
|
process16.exit(0);
|
|
6262
6415
|
};
|
|
6263
6416
|
let scaffolded;
|
|
@@ -6275,7 +6428,7 @@ async function createProject2(cwdArg, options, listing) {
|
|
|
6275
6428
|
writeProjectConfig(projectPath, { projectId, teamId, projectName });
|
|
6276
6429
|
}
|
|
6277
6430
|
const migrated = await migrateKit2Template(projectPath, template.name);
|
|
6278
|
-
|
|
6431
|
+
p12.log.success("Project created");
|
|
6279
6432
|
let packageManager2;
|
|
6280
6433
|
let installed2 = false;
|
|
6281
6434
|
if (options.install !== false) {
|
|
@@ -6290,7 +6443,7 @@ async function createProject2(cwdArg, options, listing) {
|
|
|
6290
6443
|
}
|
|
6291
6444
|
if (credentials) {
|
|
6292
6445
|
const { email: email2, password: password8 } = credentials;
|
|
6293
|
-
|
|
6446
|
+
p12.log.step("Initializing PocketBase...");
|
|
6294
6447
|
await createSuperuser(projectPath, email2, password8);
|
|
6295
6448
|
writeEnvFile(
|
|
6296
6449
|
projectPath,
|
|
@@ -6300,16 +6453,16 @@ async function createProject2(cwdArg, options, listing) {
|
|
|
6300
6453
|
},
|
|
6301
6454
|
["PocketBase superuser credentials \u2014 used by `vela` commands"]
|
|
6302
6455
|
);
|
|
6303
|
-
|
|
6456
|
+
p12.log.success("PocketBase initialized");
|
|
6304
6457
|
if (gallerySchema) {
|
|
6305
6458
|
if (!installed2) {
|
|
6306
6459
|
throw new Error(
|
|
6307
6460
|
"--schema needs the dependencies installed so PocketBase can run; create without --no-install, or run `vela generate migration --ai` after installing."
|
|
6308
6461
|
);
|
|
6309
6462
|
}
|
|
6310
|
-
|
|
6463
|
+
p12.log.step(`Creating the ${gallerySchema.title} schema...`);
|
|
6311
6464
|
const applied = await applyGallerySchema(projectPath, gallerySchema, { email: email2, password: password8 });
|
|
6312
|
-
|
|
6465
|
+
p12.log.success(
|
|
6313
6466
|
`Created ${applied.collections} collections (${applied.written.length} migration files)`
|
|
6314
6467
|
);
|
|
6315
6468
|
}
|
|
@@ -6317,7 +6470,7 @@ async function createProject2(cwdArg, options, listing) {
|
|
|
6317
6470
|
return { directory: projectPath, packageManager: packageManager2, installed: installed2, migrated, name, template, link: link2 };
|
|
6318
6471
|
}
|
|
6319
6472
|
async function resolveCreatableTemplate(template) {
|
|
6320
|
-
if (template.source === "remote")
|
|
6473
|
+
if (template.source === "remote") p12.log.step(`Downloading template ${template.name}...`);
|
|
6321
6474
|
const resolved = await resolveTemplate(template);
|
|
6322
6475
|
const blocker = findKit3Blocker(resolved.dir);
|
|
6323
6476
|
if (blocker) {
|
|
@@ -6334,29 +6487,29 @@ async function scaffoldProject(cwdArg, options, template, resolved, onCancel2) {
|
|
|
6334
6487
|
} else if (!interactive) {
|
|
6335
6488
|
throw new Error("Pass the directory to create the project in, e.g. `vela create my-app`.");
|
|
6336
6489
|
} else {
|
|
6337
|
-
const answer = await
|
|
6490
|
+
const answer = await p12.text({
|
|
6338
6491
|
message: "Where would you like your project to be created?",
|
|
6339
6492
|
placeholder: " (hit Enter to use current directory)",
|
|
6340
6493
|
defaultValue: "./"
|
|
6341
6494
|
});
|
|
6342
|
-
if (
|
|
6495
|
+
if (p12.isCancel(answer)) onCancel2();
|
|
6343
6496
|
directory = path30.resolve(answer);
|
|
6344
6497
|
}
|
|
6345
6498
|
if (fs31.existsSync(directory) && fs31.readdirSync(directory).filter((f) => !f.startsWith(".git")).length > 0) {
|
|
6346
6499
|
if (!interactive) throw new Error(`${directory} is not empty.`);
|
|
6347
|
-
const force = await
|
|
6500
|
+
const force = await p12.confirm({
|
|
6348
6501
|
message: "Directory not empty. Continue?",
|
|
6349
6502
|
initialValue: false
|
|
6350
6503
|
});
|
|
6351
|
-
if (
|
|
6504
|
+
if (p12.isCancel(force) || !force) onCancel2();
|
|
6352
6505
|
}
|
|
6353
6506
|
const dirName = path30.basename(directory);
|
|
6354
|
-
const { name } = await
|
|
6507
|
+
const { name } = await p12.group(
|
|
6355
6508
|
{
|
|
6356
6509
|
name: () => {
|
|
6357
6510
|
if (options.name) return Promise.resolve(options.name);
|
|
6358
6511
|
if (!interactive) return Promise.resolve(dirName || "SvelteKit");
|
|
6359
|
-
return
|
|
6512
|
+
return p12.text({
|
|
6360
6513
|
message: "App name (written to src/lib/site.ts)",
|
|
6361
6514
|
initialValue: dirName || "SvelteKit",
|
|
6362
6515
|
validate: (value) => value?.trim() ? void 0 : "App name is required"
|
|
@@ -6380,7 +6533,7 @@ async function migrateKit2Template(projectPath, templateName2) {
|
|
|
6380
6533
|
if (!(status3.declaredMajor !== null && status3.declaredMajor < 3 || status3.svelteConfig)) {
|
|
6381
6534
|
return false;
|
|
6382
6535
|
}
|
|
6383
|
-
|
|
6536
|
+
p12.log.step(`Template ${templateName2} is written for SvelteKit 2; migrating it to SvelteKit 3...`);
|
|
6384
6537
|
let result;
|
|
6385
6538
|
try {
|
|
6386
6539
|
result = await runKit3Migration(projectPath, { gitCheck: false, install: false, quiet: true });
|
|
@@ -6401,11 +6554,11 @@ The project is in ${projectPath}. Finish the migration by hand with
|
|
|
6401
6554
|
fs31.rmSync(tasksFile);
|
|
6402
6555
|
}
|
|
6403
6556
|
const left = fs31.existsSync(tasksFile);
|
|
6404
|
-
|
|
6557
|
+
p12.log.success(
|
|
6405
6558
|
`Migrated to SvelteKit 3${left ? `; ${MIGRATION_TASKS_FILE} lists what to check by hand` : ""}.`
|
|
6406
6559
|
);
|
|
6407
6560
|
if (result.followUps.length > 0) {
|
|
6408
|
-
|
|
6561
|
+
p12.log.warn(result.followUps.map((item) => `- ${item}`).join("\n"));
|
|
6409
6562
|
}
|
|
6410
6563
|
return true;
|
|
6411
6564
|
}
|
|
@@ -6445,7 +6598,7 @@ async function linkOnCreate(name, template, options, onCancel2) {
|
|
|
6445
6598
|
}
|
|
6446
6599
|
let linked;
|
|
6447
6600
|
if (decision.kind === "create") {
|
|
6448
|
-
|
|
6601
|
+
p12.log.step(
|
|
6449
6602
|
options.link === "new" ? "Linking to a new velastack.dev project..." : "Linking to a new velastack.dev project (pass `--link none` to skip)..."
|
|
6450
6603
|
);
|
|
6451
6604
|
linked = await linkNewProject(apiKey ?? requireApiKey(), {
|
|
@@ -6455,18 +6608,18 @@ async function linkOnCreate(name, template, options, onCancel2) {
|
|
|
6455
6608
|
interactive
|
|
6456
6609
|
});
|
|
6457
6610
|
} else if (decision.kind === "existing") {
|
|
6458
|
-
|
|
6611
|
+
p12.log.step("Linking to velastack.dev...");
|
|
6459
6612
|
linked = await linkExistingProject(requireApiKey(), decision.projectId);
|
|
6460
6613
|
} else if (decision.kind === "none" && decision.warn) {
|
|
6461
|
-
|
|
6614
|
+
p12.log.warn(decision.warn);
|
|
6462
6615
|
}
|
|
6463
6616
|
if (linked) {
|
|
6464
6617
|
outcome.linked = linked;
|
|
6465
|
-
|
|
6618
|
+
p12.log.success(`Linked to ${linked.projectName} (${linked.dashboardUrl})`);
|
|
6466
6619
|
if (templateCms && !outcome.cmsEndpoint) {
|
|
6467
6620
|
outcome.cmsEndpoint = cmsEndpointFor(linked.projectId);
|
|
6468
6621
|
outcome.cmsSource = "linked";
|
|
6469
|
-
|
|
6622
|
+
p12.log.success(`CMS: ${outcome.cmsEndpoint}`);
|
|
6470
6623
|
outcome.seed = await seedCms(apiKey ?? requireApiKey(), linked, template);
|
|
6471
6624
|
}
|
|
6472
6625
|
}
|
|
@@ -6477,20 +6630,20 @@ async function seedCms(apiKey, linked, template) {
|
|
|
6477
6630
|
const version = template.entry.version;
|
|
6478
6631
|
const seed = await seedLinkedProject(apiKey, linked.projectId, { name: template.name, version });
|
|
6479
6632
|
if (seed.status === "seeded") {
|
|
6480
|
-
|
|
6633
|
+
p12.log.success(`CMS content loaded (${seed.locales.join(", ")})`);
|
|
6481
6634
|
} else if (seed.status === "already-seeded") {
|
|
6482
|
-
|
|
6635
|
+
p12.log.info("The CMS already has content; left as it is.");
|
|
6483
6636
|
} else if (seed.status === "failed") {
|
|
6484
|
-
|
|
6637
|
+
p12.log.warn(`Could not load the template's content into the CMS: ${seed.error}`);
|
|
6485
6638
|
}
|
|
6486
6639
|
const forms = formsCreatedMessage(seed);
|
|
6487
|
-
if (forms)
|
|
6640
|
+
if (forms) p12.log.success(forms);
|
|
6488
6641
|
return seed;
|
|
6489
6642
|
}
|
|
6490
6643
|
async function promptCms(onCancel2) {
|
|
6491
|
-
|
|
6644
|
+
p12.note(`This template reads its copy from a hosted CMS.
|
|
6492
6645
|
${FREE_CMS_HINT}.`, "CMS");
|
|
6493
|
-
const choice = await
|
|
6646
|
+
const choice = await p12.select({
|
|
6494
6647
|
message: "Where should the site read its content from?",
|
|
6495
6648
|
options: [
|
|
6496
6649
|
{ value: "login", label: "Log in to velastack.dev and create one", hint: "free" },
|
|
@@ -6498,14 +6651,14 @@ ${FREE_CMS_HINT}.`, "CMS");
|
|
|
6498
6651
|
{ value: "skip", label: "Skip for now", hint: "the site shows its fallback copy" }
|
|
6499
6652
|
]
|
|
6500
6653
|
});
|
|
6501
|
-
if (
|
|
6654
|
+
if (p12.isCancel(choice)) onCancel2();
|
|
6502
6655
|
if (choice !== "url") return { kind: choice };
|
|
6503
|
-
const url = await
|
|
6656
|
+
const url = await p12.text({
|
|
6504
6657
|
message: "CMS URL",
|
|
6505
6658
|
placeholder: "https://velastack.dev/v1/projects/<project>/cms",
|
|
6506
6659
|
validate: (value) => CMS_URL_RE.test(value?.trim() ?? "") ? void 0 : "Enter an absolute http(s) URL"
|
|
6507
6660
|
});
|
|
6508
|
-
if (
|
|
6661
|
+
if (p12.isCancel(url)) onCancel2();
|
|
6509
6662
|
return { kind: "url", url: normalizeCmsUrl(url) };
|
|
6510
6663
|
}
|
|
6511
6664
|
function hasScript(directory, name) {
|
|
@@ -6522,12 +6675,12 @@ import { Command as Command11 } from "commander";
|
|
|
6522
6675
|
|
|
6523
6676
|
// src/commands/generate/form.ts
|
|
6524
6677
|
import { Command as Command4 } from "commander";
|
|
6525
|
-
import * as
|
|
6678
|
+
import * as p18 from "@clack/prompts";
|
|
6526
6679
|
|
|
6527
6680
|
// src/lib/pattern-runner.ts
|
|
6528
6681
|
import fs32 from "node:fs";
|
|
6529
6682
|
import path31 from "node:path";
|
|
6530
|
-
import * as
|
|
6683
|
+
import * as p13 from "@clack/prompts";
|
|
6531
6684
|
import { bySlug as bySlug3 } from "@velastack/patterns";
|
|
6532
6685
|
|
|
6533
6686
|
// src/lib/require-ui.ts
|
|
@@ -6574,7 +6727,9 @@ var DISABLE_COMMAND = {
|
|
|
6574
6727
|
blog: "vela disable blog",
|
|
6575
6728
|
contentNegotiation: "vela disable content-negotiation",
|
|
6576
6729
|
cms: "vela disable cms",
|
|
6577
|
-
ecommerce: "vela disable ecommerce"
|
|
6730
|
+
ecommerce: "vela disable ecommerce",
|
|
6731
|
+
subscriptions: "vela disable subscriptions",
|
|
6732
|
+
orders: "vela disable orders"
|
|
6578
6733
|
};
|
|
6579
6734
|
var FEATURE_NAME = {
|
|
6580
6735
|
apiKeys: "API keys",
|
|
@@ -6698,7 +6853,7 @@ async function runPattern(slug2, argv, input, report5, after) {
|
|
|
6698
6853
|
provider: typeof input.provider === "string" ? input.provider : void 0
|
|
6699
6854
|
});
|
|
6700
6855
|
const migrationsBefore = listMigrations2(workspaceRootDir);
|
|
6701
|
-
const
|
|
6856
|
+
const log58 = p13.taskLog({ title: report5.task.title });
|
|
6702
6857
|
let result;
|
|
6703
6858
|
try {
|
|
6704
6859
|
result = await pattern.generate({
|
|
@@ -6720,11 +6875,11 @@ async function runPattern(slug2, argv, input, report5, after) {
|
|
|
6720
6875
|
});
|
|
6721
6876
|
return collections2;
|
|
6722
6877
|
},
|
|
6723
|
-
logger: { info: (message) =>
|
|
6878
|
+
logger: { info: (message) => log58.message(message) }
|
|
6724
6879
|
});
|
|
6725
|
-
|
|
6880
|
+
log58.success(report5.task.success);
|
|
6726
6881
|
} catch (e) {
|
|
6727
|
-
|
|
6882
|
+
log58.error(report5.task.error);
|
|
6728
6883
|
throw e;
|
|
6729
6884
|
}
|
|
6730
6885
|
let afterError;
|
|
@@ -6751,7 +6906,7 @@ async function runPattern(slug2, argv, input, report5, after) {
|
|
|
6751
6906
|
const deleted = result.deletes.filter(isSuccess);
|
|
6752
6907
|
const totalChanges = created.length + modified.length + deleted.length + result.components.length + result.packages.length + result.collections.length;
|
|
6753
6908
|
if (totalChanges === 0 && failures.length === 0) {
|
|
6754
|
-
|
|
6909
|
+
p13.log.info(`${pattern.title ?? slug2} produced no changes.`);
|
|
6755
6910
|
} else {
|
|
6756
6911
|
reportResult({
|
|
6757
6912
|
summary: report5.summary ?? `Applied ${pattern.title ?? slug2}.`,
|
|
@@ -6798,18 +6953,18 @@ function resolveFormInput(root, detectedUi, requested) {
|
|
|
6798
6953
|
// src/lib/ai-flow.ts
|
|
6799
6954
|
import fs33 from "node:fs";
|
|
6800
6955
|
import path33 from "node:path";
|
|
6801
|
-
import * as
|
|
6956
|
+
import * as p17 from "@clack/prompts";
|
|
6802
6957
|
import pc6 from "picocolors";
|
|
6803
6958
|
|
|
6804
6959
|
// src/lib/ai-loop.ts
|
|
6805
|
-
import * as
|
|
6960
|
+
import * as p14 from "@clack/prompts";
|
|
6806
6961
|
async function aiLoop(opts) {
|
|
6807
6962
|
let prompt = opts.initialPrompt;
|
|
6808
6963
|
let history = [];
|
|
6809
6964
|
let attempt = 0;
|
|
6810
6965
|
while (true) {
|
|
6811
6966
|
attempt++;
|
|
6812
|
-
const spinner9 =
|
|
6967
|
+
const spinner9 = p14.spinner();
|
|
6813
6968
|
spinner9.start(`${opts.stageLabel} (${attempt > 1 ? "iteration " + attempt : "first pass"})\u2026`);
|
|
6814
6969
|
let result;
|
|
6815
6970
|
let turn;
|
|
@@ -6823,12 +6978,12 @@ async function aiLoop(opts) {
|
|
|
6823
6978
|
throw e;
|
|
6824
6979
|
}
|
|
6825
6980
|
opts.renderPreview(result);
|
|
6826
|
-
const next = await
|
|
6981
|
+
const next = await p14.text({
|
|
6827
6982
|
message: "Refine the result, or press Enter to apply.",
|
|
6828
6983
|
placeholder: opts.refinePlaceholder,
|
|
6829
6984
|
defaultValue: ""
|
|
6830
6985
|
});
|
|
6831
|
-
if (
|
|
6986
|
+
if (p14.isCancel(next)) return null;
|
|
6832
6987
|
const trimmed = (typeof next === "string" ? next : "").trim();
|
|
6833
6988
|
if (trimmed === "") return result;
|
|
6834
6989
|
history = turn;
|
|
@@ -6837,7 +6992,7 @@ async function aiLoop(opts) {
|
|
|
6837
6992
|
}
|
|
6838
6993
|
|
|
6839
6994
|
// src/lib/ai-existing-models.ts
|
|
6840
|
-
import * as
|
|
6995
|
+
import * as p15 from "@clack/prompts";
|
|
6841
6996
|
async function loadExistingModels(workspaceRootDir) {
|
|
6842
6997
|
let result = [];
|
|
6843
6998
|
try {
|
|
@@ -6862,7 +7017,7 @@ async function loadExistingModels(workspaceRootDir) {
|
|
|
6862
7017
|
});
|
|
6863
7018
|
} catch (e) {
|
|
6864
7019
|
const msg = e instanceof Error ? e.message : String(e);
|
|
6865
|
-
|
|
7020
|
+
p15.log.warn(
|
|
6866
7021
|
`Could not load existing schema from PocketBase (${msg}). The AI agent will design without that context.`
|
|
6867
7022
|
);
|
|
6868
7023
|
return [];
|
|
@@ -6871,7 +7026,7 @@ async function loadExistingModels(workspaceRootDir) {
|
|
|
6871
7026
|
}
|
|
6872
7027
|
|
|
6873
7028
|
// src/lib/ai-to-argv.ts
|
|
6874
|
-
import * as
|
|
7029
|
+
import * as p16 from "@clack/prompts";
|
|
6875
7030
|
var PRIMITIVE_TYPES = /* @__PURE__ */ new Set(["text", "number", "bool", "email", "date", "url", "file"]);
|
|
6876
7031
|
function singularize(name) {
|
|
6877
7032
|
if (name.endsWith("ies") && name.length > 3) return `${name.slice(0, -3)}y`;
|
|
@@ -6894,7 +7049,7 @@ function collectionSpecToArgv(spec) {
|
|
|
6894
7049
|
for (const field of spec.fields) {
|
|
6895
7050
|
const type = typeArg(field);
|
|
6896
7051
|
if (type === null) {
|
|
6897
|
-
|
|
7052
|
+
p16.log.warn(
|
|
6898
7053
|
`Skipping field "${field.name}" (type "${field.type}" cannot be represented as a pattern argument)`
|
|
6899
7054
|
);
|
|
6900
7055
|
continue;
|
|
@@ -6997,10 +7152,10 @@ function renderModel(spec) {
|
|
|
6997
7152
|
const tail = extra.length > 0 ? " " + pc6.dim(extra.join(" ")) : "";
|
|
6998
7153
|
lines.push(` ${f.name.padEnd(nameWidth)} ${f.type.padEnd(typeWidth)} ${required}${tail}`);
|
|
6999
7154
|
}
|
|
7000
|
-
|
|
7155
|
+
p17.log.message(lines.join("\n"));
|
|
7001
7156
|
}
|
|
7002
7157
|
function renderLayout(layout) {
|
|
7003
|
-
|
|
7158
|
+
p17.log.message(renderGrid(layout));
|
|
7004
7159
|
}
|
|
7005
7160
|
async function runSchemaStage(opts) {
|
|
7006
7161
|
const { workspaceRootDir } = await getWorkspace();
|
|
@@ -7071,12 +7226,12 @@ var form = new Command4("form").description("generate a form from a model").argu
|
|
|
7071
7226
|
}
|
|
7072
7227
|
const stage2 = await runSchemaStage({ prompt: options.ai, useCase: "form" });
|
|
7073
7228
|
if (!stage2) {
|
|
7074
|
-
|
|
7229
|
+
p18.cancel("Aborted before any files were written.");
|
|
7075
7230
|
return;
|
|
7076
7231
|
}
|
|
7077
7232
|
const layout = await runLayoutStage(stage2.workspaceRootDir, stage2.model);
|
|
7078
7233
|
if (!layout) {
|
|
7079
|
-
|
|
7234
|
+
p18.cancel("Aborted before any files were written.");
|
|
7080
7235
|
return;
|
|
7081
7236
|
}
|
|
7082
7237
|
argv = specToArgv(stage2.model);
|
|
@@ -7092,7 +7247,7 @@ var form = new Command4("form").description("generate a form from a model").argu
|
|
|
7092
7247
|
const { workspaceRootDir, features } = await getWorkspace();
|
|
7093
7248
|
const formInput = resolveFormInput(workspaceRootDir, features.ui, options.ui);
|
|
7094
7249
|
if (features.ui === "plain" && !options.ui) {
|
|
7095
|
-
|
|
7250
|
+
p18.log.info("shadcn-svelte not detected: generating a plain HTML form.");
|
|
7096
7251
|
}
|
|
7097
7252
|
const slug2 = options.remote ? "generate-form-remote" : "generate-form";
|
|
7098
7253
|
const nextSteps = [
|
|
@@ -7123,7 +7278,7 @@ var form = new Command4("form").description("generate a form from a model").argu
|
|
|
7123
7278
|
|
|
7124
7279
|
// src/commands/generate/schema.ts
|
|
7125
7280
|
import { Command as Command5 } from "commander";
|
|
7126
|
-
import * as
|
|
7281
|
+
import * as p19 from "@clack/prompts";
|
|
7127
7282
|
var schema = new Command5("schema").description("generate a schema from a model").argument("[model]", "model name").argument("[fields...]", "field definitions").option("--ai <description>", "design the schema with AI from a natural-language description").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
7128
7283
|
(model, fields, options) => runCommand(async () => {
|
|
7129
7284
|
let argv;
|
|
@@ -7134,7 +7289,7 @@ var schema = new Command5("schema").description("generate a schema from a model"
|
|
|
7134
7289
|
}
|
|
7135
7290
|
const stage2 = await runSchemaStage({ prompt: options.ai, useCase: "schema" });
|
|
7136
7291
|
if (!stage2) {
|
|
7137
|
-
|
|
7292
|
+
p19.cancel("Aborted before any files were written.");
|
|
7138
7293
|
return;
|
|
7139
7294
|
}
|
|
7140
7295
|
argv = specToArgv(stage2.model);
|
|
@@ -7194,7 +7349,7 @@ var resource = new Command6("resource").description("generate a resource (model
|
|
|
7194
7349
|
|
|
7195
7350
|
// src/commands/generate/scaffold.ts
|
|
7196
7351
|
import { Command as Command7 } from "commander";
|
|
7197
|
-
import * as
|
|
7352
|
+
import * as p20 from "@clack/prompts";
|
|
7198
7353
|
var scaffold = new Command7("scaffold").description("generate a full CRUD scaffold (model, forms, list, detail)").argument("[model]", "model name").argument("[fields...]", "field definitions").option("--remote", "generate create/update forms with SvelteKit remote functions").option(
|
|
7199
7354
|
"--route <route>",
|
|
7200
7355
|
'place the scaffold at a custom route (e.g. "(app)/[team_id]/projects"). Defaults to the pluralized model name under the (app) or (public) group, or src/routes when it has neither.'
|
|
@@ -7221,12 +7376,12 @@ var scaffold = new Command7("scaffold").description("generate a full CRUD scaffo
|
|
|
7221
7376
|
}
|
|
7222
7377
|
const stage2 = await runSchemaStage({ prompt: options.ai, useCase: "scaffold" });
|
|
7223
7378
|
if (!stage2) {
|
|
7224
|
-
|
|
7379
|
+
p20.cancel("Aborted before any files were written.");
|
|
7225
7380
|
return;
|
|
7226
7381
|
}
|
|
7227
7382
|
const layout = await runLayoutStage(stage2.workspaceRootDir, stage2.model);
|
|
7228
7383
|
if (!layout) {
|
|
7229
|
-
|
|
7384
|
+
p20.cancel("Aborted before any files were written.");
|
|
7230
7385
|
return;
|
|
7231
7386
|
}
|
|
7232
7387
|
argv = specToArgv(stage2.model);
|
|
@@ -7242,7 +7397,7 @@ var scaffold = new Command7("scaffold").description("generate a full CRUD scaffo
|
|
|
7242
7397
|
const { workspaceRootDir, features } = await getWorkspace();
|
|
7243
7398
|
const formInput = resolveFormInput(workspaceRootDir, features.ui, options.ui);
|
|
7244
7399
|
if (features.ui === "plain" && !options.ui) {
|
|
7245
|
-
|
|
7400
|
+
p20.log.info("shadcn-svelte not detected: generating plain HTML pages.");
|
|
7246
7401
|
}
|
|
7247
7402
|
const slug2 = options.remote ? "generate-scaffold-remote" : "generate-scaffold";
|
|
7248
7403
|
const nextSteps = [
|
|
@@ -7375,7 +7530,7 @@ var NEXT_STEPS = {
|
|
|
7375
7530
|
var generate = new Command11("generate").description("generate scaffolding for database models and forms").configureHelp(helpConfig).addCommand(form).addCommand(schema).addCommand(resource).addCommand(scaffold).addCommand(shop).addCommand(migration).addCommand(workflow);
|
|
7376
7531
|
|
|
7377
7532
|
// src/commands/enable.ts
|
|
7378
|
-
import { Command as
|
|
7533
|
+
import { Command as Command30 } from "commander";
|
|
7379
7534
|
|
|
7380
7535
|
// src/commands/enable/ai.ts
|
|
7381
7536
|
import { Command as Command12 } from "commander";
|
|
@@ -7530,7 +7685,7 @@ var apiKeys = new Command16("api-keys").description("enable API key management")
|
|
|
7530
7685
|
import process18 from "node:process";
|
|
7531
7686
|
import * as v6 from "valibot";
|
|
7532
7687
|
import { Command as Command17 } from "commander";
|
|
7533
|
-
import * as
|
|
7688
|
+
import * as p21 from "@clack/prompts";
|
|
7534
7689
|
import pc7 from "picocolors";
|
|
7535
7690
|
var optionsSchema3 = v6.strictObject({
|
|
7536
7691
|
email: emailFlag,
|
|
@@ -7577,7 +7732,7 @@ function backendNextSteps(ui2) {
|
|
|
7577
7732
|
];
|
|
7578
7733
|
}
|
|
7579
7734
|
async function initPocketbase(root, { email: email2, password: password8 }) {
|
|
7580
|
-
|
|
7735
|
+
p21.log.step("Initializing PocketBase...");
|
|
7581
7736
|
await upsertSuperuser(root, email2, password8);
|
|
7582
7737
|
upsertEnvFile(
|
|
7583
7738
|
root,
|
|
@@ -7587,21 +7742,21 @@ async function initPocketbase(root, { email: email2, password: password8 }) {
|
|
|
7587
7742
|
},
|
|
7588
7743
|
["PocketBase superuser credentials \u2014 used by `vela` commands"]
|
|
7589
7744
|
);
|
|
7590
|
-
|
|
7745
|
+
p21.log.success(`PocketBase initialized, credentials written to ${pc7.bold(".env")}`);
|
|
7591
7746
|
}
|
|
7592
7747
|
async function resolveCredentials(options) {
|
|
7593
7748
|
const decision = decideSuperuser(options, superuserFromEnv(), isInteractive());
|
|
7594
7749
|
if (decision.kind === "error") throw new Error(decision.message);
|
|
7595
7750
|
if (decision.kind === "use") {
|
|
7596
7751
|
if (decision.reused) {
|
|
7597
|
-
|
|
7752
|
+
p21.log.info(
|
|
7598
7753
|
`Using the superuser credentials already in your environment (${pc7.cyan(decision.credentials.email)}).`
|
|
7599
7754
|
);
|
|
7600
7755
|
}
|
|
7601
7756
|
return decision.credentials;
|
|
7602
7757
|
}
|
|
7603
7758
|
return promptSuperuser(decision.known, () => {
|
|
7604
|
-
|
|
7759
|
+
p21.cancel("Operation cancelled.");
|
|
7605
7760
|
process18.exit(0);
|
|
7606
7761
|
});
|
|
7607
7762
|
}
|
|
@@ -7663,7 +7818,7 @@ import fs35 from "node:fs";
|
|
|
7663
7818
|
import path35 from "node:path";
|
|
7664
7819
|
import process19 from "node:process";
|
|
7665
7820
|
import { Command as Command20 } from "commander";
|
|
7666
|
-
import * as
|
|
7821
|
+
import * as p22 from "@clack/prompts";
|
|
7667
7822
|
|
|
7668
7823
|
// src/lib/order-form.ts
|
|
7669
7824
|
import fs34 from "node:fs";
|
|
@@ -7812,7 +7967,7 @@ async function askBusiness(flags, currencyRequired) {
|
|
|
7812
7967
|
const ask = isInteractive();
|
|
7813
7968
|
if (!business.currency && !declared.currency) {
|
|
7814
7969
|
if (!ask) return business;
|
|
7815
|
-
business.currency = await
|
|
7970
|
+
business.currency = await text8({
|
|
7816
7971
|
message: "The currency the business prices in (ISO 4217)",
|
|
7817
7972
|
placeholder: "MXN, EUR, USD...",
|
|
7818
7973
|
validate: (value) => value && isCurrency(value) ? void 0 : currencyRequired || value ? "An ISO 4217 code, such as MXN or EUR" : void 0
|
|
@@ -7820,14 +7975,14 @@ async function askBusiness(flags, currencyRequired) {
|
|
|
7820
7975
|
}
|
|
7821
7976
|
const home = (business.currency ?? declared.currency ?? "").toUpperCase();
|
|
7822
7977
|
if (!business.country && !declared.country && ask) {
|
|
7823
|
-
business.country = await
|
|
7978
|
+
business.country = await text8({
|
|
7824
7979
|
message: "The country the business is in (ISO 3166-1, two letters), so prices format for it",
|
|
7825
7980
|
placeholder: "MX, ES, US...",
|
|
7826
7981
|
validate: (value) => !value || isCountry(value) ? void 0 : "A two-letter country code, such as MX"
|
|
7827
7982
|
});
|
|
7828
7983
|
}
|
|
7829
7984
|
if (business.currencies === void 0 && declared.currencies === void 0 && ask && home) {
|
|
7830
|
-
business.currencies = await
|
|
7985
|
+
business.currencies = await text8({
|
|
7831
7986
|
message: `Other currencies to show prices in, as estimates (comma-separated, blank for ${home} only)`,
|
|
7832
7987
|
placeholder: "USD, EUR",
|
|
7833
7988
|
validate: (value) => value && value.split(/[,\s]+/).some((code2) => code2 && !isCurrency(code2)) ? "ISO 4217 codes, comma-separated" : void 0
|
|
@@ -7839,10 +7994,10 @@ async function askBusiness(flags, currencyRequired) {
|
|
|
7839
7994
|
currencies: business.currencies ?? void 0
|
|
7840
7995
|
};
|
|
7841
7996
|
}
|
|
7842
|
-
async function
|
|
7843
|
-
const value = await
|
|
7844
|
-
if (
|
|
7845
|
-
|
|
7997
|
+
async function text8(options) {
|
|
7998
|
+
const value = await p22.text(options);
|
|
7999
|
+
if (p22.isCancel(value)) {
|
|
8000
|
+
p22.cancel("Operation cancelled.");
|
|
7846
8001
|
process19.exit(0);
|
|
7847
8002
|
}
|
|
7848
8003
|
return (value ?? "").trim() || void 0;
|
|
@@ -7860,7 +8015,7 @@ async function prepareOrderForm() {
|
|
|
7860
8015
|
}
|
|
7861
8016
|
function noteWebhookSecret() {
|
|
7862
8017
|
if (process19.env.STRIPE_WEBHOOK_SECRET || !isInteractive()) return;
|
|
7863
|
-
|
|
8018
|
+
p22.note(
|
|
7864
8019
|
[
|
|
7865
8020
|
"Download the Stripe CLI (https://stripe.com/docs/stripe-cli), then run:",
|
|
7866
8021
|
" stripe listen --forward-to localhost:5173/webhooks/stripe",
|
|
@@ -7872,15 +8027,15 @@ function noteWebhookSecret() {
|
|
|
7872
8027
|
}
|
|
7873
8028
|
async function askDemoId(provider) {
|
|
7874
8029
|
if (!isInteractive()) return "";
|
|
7875
|
-
const value = provider.id === "stripe" ? await
|
|
8030
|
+
const value = provider.id === "stripe" ? await p22.text({
|
|
7876
8031
|
message: "Stripe price_id for the demo page (price_...)",
|
|
7877
8032
|
placeholder: "leave blank to create a demo product"
|
|
7878
|
-
}) : await
|
|
8033
|
+
}) : await p22.text({
|
|
7879
8034
|
message: "Shopify product variant for the demo page (gid://shopify/ProductVariant/...)",
|
|
7880
8035
|
placeholder: "leave blank to skip the demo page"
|
|
7881
8036
|
});
|
|
7882
|
-
if (
|
|
7883
|
-
|
|
8037
|
+
if (p22.isCancel(value)) {
|
|
8038
|
+
p22.cancel("Operation cancelled.");
|
|
7884
8039
|
process19.exit(0);
|
|
7885
8040
|
}
|
|
7886
8041
|
return (value ?? "").trim();
|
|
@@ -7957,9 +8112,35 @@ var subscriptions = new Command22("subscriptions").description("enable Stripe su
|
|
|
7957
8112
|
)
|
|
7958
8113
|
);
|
|
7959
8114
|
|
|
7960
|
-
// src/commands/enable/
|
|
8115
|
+
// src/commands/enable/orders.ts
|
|
7961
8116
|
import { Command as Command23 } from "commander";
|
|
7962
|
-
var
|
|
8117
|
+
var orders = new Command23("orders").description("record Stripe Checkout orders (requires Stripe payments and the cart)").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8118
|
+
(_opts, cmd) => runCommand(
|
|
8119
|
+
() => runPattern(
|
|
8120
|
+
"enable-orders",
|
|
8121
|
+
cmd.args,
|
|
8122
|
+
{},
|
|
8123
|
+
{
|
|
8124
|
+
summary: "Enabled orders.",
|
|
8125
|
+
nextSteps: [
|
|
8126
|
+
"Forward webhooks locally with `stripe listen --forward-to localhost:5173/webhooks/stripe`.",
|
|
8127
|
+
"Run `vela dev`, buy something from the shop, and see the order on /checkout/success.",
|
|
8128
|
+
"With auth on, signed-in buyers see their orders at /orders."
|
|
8129
|
+
],
|
|
8130
|
+
task: {
|
|
8131
|
+
title: "Enabling orders",
|
|
8132
|
+
success: "Enabled orders",
|
|
8133
|
+
error: "Failed to enable orders"
|
|
8134
|
+
}
|
|
8135
|
+
}
|
|
8136
|
+
),
|
|
8137
|
+
"Failed to enable orders."
|
|
8138
|
+
)
|
|
8139
|
+
);
|
|
8140
|
+
|
|
8141
|
+
// src/commands/enable/notifications.ts
|
|
8142
|
+
import { Command as Command24 } from "commander";
|
|
8143
|
+
var notifications = new Command24("notifications").description("enable in-app notifications with a bell dropdown (requires auth)").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
7963
8144
|
(_opts, cmd) => runCommand(
|
|
7964
8145
|
() => runPattern(
|
|
7965
8146
|
"enable-notifications",
|
|
@@ -7985,8 +8166,8 @@ var notifications = new Command23("notifications").description("enable in-app no
|
|
|
7985
8166
|
|
|
7986
8167
|
// src/commands/enable/cms.ts
|
|
7987
8168
|
import process20 from "node:process";
|
|
7988
|
-
import { Command as
|
|
7989
|
-
import * as
|
|
8169
|
+
import { Command as Command25 } from "commander";
|
|
8170
|
+
import * as p23 from "@clack/prompts";
|
|
7990
8171
|
import pc8 from "picocolors";
|
|
7991
8172
|
function resolveCmsBackend(facts) {
|
|
7992
8173
|
if (facts.endpoint) return { kind: "hosted", endpoint: facts.endpoint, from: "flag" };
|
|
@@ -8003,7 +8184,7 @@ function adapterOf(root) {
|
|
|
8003
8184
|
return "none";
|
|
8004
8185
|
}
|
|
8005
8186
|
}
|
|
8006
|
-
var cms = new
|
|
8187
|
+
var cms = new Command25("cms").description("enable an inline-editing CMS with an admin bar").option(
|
|
8007
8188
|
"--endpoint <url>",
|
|
8008
8189
|
"read from a hosted CMS at this URL instead of installing the backend in this app"
|
|
8009
8190
|
).allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
@@ -8017,7 +8198,7 @@ var cms = new Command24("cms").description("enable an inline-editing CMS with an
|
|
|
8017
8198
|
projectId: readProjectConfig(root)?.projectId
|
|
8018
8199
|
});
|
|
8019
8200
|
if (backend3.kind === "none") {
|
|
8020
|
-
|
|
8201
|
+
p23.log.error(
|
|
8021
8202
|
`${pc8.cyan("vela enable cms")} needs somewhere to run the CMS backend, and this project has no Node server.
|
|
8022
8203
|
|
|
8023
8204
|
Any one of these gives it one:
|
|
@@ -8025,14 +8206,14 @@ Any one of these gives it one:
|
|
|
8025
8206
|
- ${pc8.cyan("vela enable cms --endpoint <url>")} to point at a hosted CMS yourself.
|
|
8026
8207
|
- ${pc8.cyan("vela enable backend")}, or switching to @sveltejs/adapter-node, to host it in this app.`
|
|
8027
8208
|
);
|
|
8028
|
-
|
|
8029
|
-
|
|
8209
|
+
p23.log.message();
|
|
8210
|
+
p23.cancel("Operation failed.");
|
|
8030
8211
|
process20.exitCode = 1;
|
|
8031
8212
|
return;
|
|
8032
8213
|
}
|
|
8033
8214
|
const hosted = backend3.kind === "hosted";
|
|
8034
8215
|
if (hosted && backend3.from === "link") {
|
|
8035
|
-
|
|
8216
|
+
p23.log.info(`Using the hosted CMS of the linked project (${pc8.cyan(backend3.endpoint)}).`);
|
|
8036
8217
|
}
|
|
8037
8218
|
const input = hosted ? { endpoint: backend3.endpoint } : { server: true };
|
|
8038
8219
|
await runPattern("enable-cms", cmd.args, input, {
|
|
@@ -8052,8 +8233,8 @@ Any one of these gives it one:
|
|
|
8052
8233
|
);
|
|
8053
8234
|
|
|
8054
8235
|
// src/commands/enable/blog.ts
|
|
8055
|
-
import { Command as
|
|
8056
|
-
var blog = new
|
|
8236
|
+
import { Command as Command26 } from "commander";
|
|
8237
|
+
var blog = new Command26("blog").description("enable an mdsvex blog with posts, tags, and RSS").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8057
8238
|
(_opts, cmd) => runCommand(
|
|
8058
8239
|
() => runPattern(
|
|
8059
8240
|
"enable-blog",
|
|
@@ -8079,8 +8260,8 @@ var blog = new Command25("blog").description("enable an mdsvex blog with posts,
|
|
|
8079
8260
|
|
|
8080
8261
|
// src/commands/enable/content-negotiation.ts
|
|
8081
8262
|
import process21 from "node:process";
|
|
8082
|
-
import { Command as
|
|
8083
|
-
var contentNegotiation = new
|
|
8263
|
+
import { Command as Command27 } from "commander";
|
|
8264
|
+
var contentNegotiation = new Command27("content-negotiation").description("enable content negotiation (sveltekit-negotiate)").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8084
8265
|
(_opts, cmd) => runCommand(
|
|
8085
8266
|
() => runPattern(
|
|
8086
8267
|
"enable-content-negotiation",
|
|
@@ -8106,8 +8287,8 @@ var contentNegotiation = new Command26("content-negotiation").description("enabl
|
|
|
8106
8287
|
);
|
|
8107
8288
|
|
|
8108
8289
|
// src/commands/enable/workflows.ts
|
|
8109
|
-
import { Command as
|
|
8110
|
-
var workflows = new
|
|
8290
|
+
import { Command as Command28 } from "commander";
|
|
8291
|
+
var workflows = new Command28("workflows").description("add background workflows to a project created before they were built in").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8111
8292
|
(_opts, cmd) => runCommand(
|
|
8112
8293
|
() => runPattern(
|
|
8113
8294
|
"enable-workflows",
|
|
@@ -8132,8 +8313,8 @@ var workflows = new Command27("workflows").description("add background workflows
|
|
|
8132
8313
|
);
|
|
8133
8314
|
|
|
8134
8315
|
// src/commands/enable/whatsapp.ts
|
|
8135
|
-
import { Command as
|
|
8136
|
-
var whatsapp = new
|
|
8316
|
+
import { Command as Command29 } from "commander";
|
|
8317
|
+
var whatsapp = new Command29("whatsapp").description("enable WhatsApp sign-in on the login and signup pages (requires auth)").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8137
8318
|
(_opts, cmd) => runCommand(
|
|
8138
8319
|
() => runPattern(
|
|
8139
8320
|
"enable-whatsapp",
|
|
@@ -8158,25 +8339,25 @@ var whatsapp = new Command28("whatsapp").description("enable WhatsApp sign-in on
|
|
|
8158
8339
|
);
|
|
8159
8340
|
|
|
8160
8341
|
// src/commands/enable.ts
|
|
8161
|
-
var enable = new
|
|
8342
|
+
var enable = new Command30("enable").description("enable features").configureHelp(helpConfig).addCommand(ai).addCommand(analytics).addCommand(auth).addCommand(api).addCommand(apiKeys).addCommand(backend).addCommand(contentNegotiation).addCommand(i18n).addCommand(teams).addCommand(payments).addCommand(ecommerce).addCommand(subscriptions).addCommand(orders).addCommand(notifications).addCommand(cms).addCommand(blog).addCommand(workflows).addCommand(whatsapp);
|
|
8162
8343
|
|
|
8163
8344
|
// src/commands/disable.ts
|
|
8164
|
-
import { Command as
|
|
8345
|
+
import { Command as Command46 } from "commander";
|
|
8165
8346
|
|
|
8166
8347
|
// src/commands/disable/ai.ts
|
|
8167
|
-
import { Command as
|
|
8348
|
+
import { Command as Command31 } from "commander";
|
|
8168
8349
|
|
|
8169
8350
|
// src/commands/disable/_shared.ts
|
|
8170
8351
|
import process22 from "node:process";
|
|
8171
|
-
import * as
|
|
8352
|
+
import * as p24 from "@clack/prompts";
|
|
8172
8353
|
async function runDisable(opts, flags, cmdArgs) {
|
|
8173
8354
|
if (!flags.yes) {
|
|
8174
|
-
const ok = await
|
|
8355
|
+
const ok = await p24.confirm({
|
|
8175
8356
|
message: opts.confirmMessage,
|
|
8176
8357
|
initialValue: false
|
|
8177
8358
|
});
|
|
8178
|
-
if (
|
|
8179
|
-
|
|
8359
|
+
if (p24.isCancel(ok) || !ok) {
|
|
8360
|
+
p24.cancel("Operation cancelled.");
|
|
8180
8361
|
process22.exit(0);
|
|
8181
8362
|
}
|
|
8182
8363
|
}
|
|
@@ -8184,7 +8365,7 @@ async function runDisable(opts, flags, cmdArgs) {
|
|
|
8184
8365
|
}
|
|
8185
8366
|
|
|
8186
8367
|
// src/commands/disable/ai.ts
|
|
8187
|
-
var ai2 = new
|
|
8368
|
+
var ai2 = new Command31("ai").description("disable AI chat").option("-y, --yes", "skip confirmation prompt").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8188
8369
|
(opts, cmd) => runCommand(
|
|
8189
8370
|
() => runDisable(
|
|
8190
8371
|
{
|
|
@@ -8210,8 +8391,8 @@ var ai2 = new Command30("ai").description("disable AI chat").option("-y, --yes",
|
|
|
8210
8391
|
);
|
|
8211
8392
|
|
|
8212
8393
|
// src/commands/disable/analytics.ts
|
|
8213
|
-
import { Command as
|
|
8214
|
-
var analytics2 = new
|
|
8394
|
+
import { Command as Command32 } from "commander";
|
|
8395
|
+
var analytics2 = new Command32("analytics").description("disable web analytics").option("-y, --yes", "skip confirmation prompt").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8215
8396
|
(opts, cmd) => runCommand(
|
|
8216
8397
|
() => runDisable(
|
|
8217
8398
|
{
|
|
@@ -8237,8 +8418,8 @@ var analytics2 = new Command31("analytics").description("disable web analytics")
|
|
|
8237
8418
|
);
|
|
8238
8419
|
|
|
8239
8420
|
// src/commands/disable/auth.ts
|
|
8240
|
-
import { Command as
|
|
8241
|
-
var auth2 = new
|
|
8421
|
+
import { Command as Command33 } from "commander";
|
|
8422
|
+
var auth2 = new Command33("auth").description("disable authentication").option("-y, --yes", "skip confirmation prompt").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8242
8423
|
(opts, cmd) => runCommand(
|
|
8243
8424
|
() => runDisable(
|
|
8244
8425
|
{
|
|
@@ -8264,8 +8445,8 @@ var auth2 = new Command32("auth").description("disable authentication").option("
|
|
|
8264
8445
|
);
|
|
8265
8446
|
|
|
8266
8447
|
// src/commands/disable/api.ts
|
|
8267
|
-
import { Command as
|
|
8268
|
-
var api2 = new
|
|
8448
|
+
import { Command as Command34 } from "commander";
|
|
8449
|
+
var api2 = new Command34("api").description("disable the REST API").option("-y, --yes", "skip confirmation prompt").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8269
8450
|
(opts, cmd) => runCommand(
|
|
8270
8451
|
() => runDisable(
|
|
8271
8452
|
{
|
|
@@ -8288,8 +8469,8 @@ var api2 = new Command33("api").description("disable the REST API").option("-y,
|
|
|
8288
8469
|
);
|
|
8289
8470
|
|
|
8290
8471
|
// src/commands/disable/api-keys.ts
|
|
8291
|
-
import { Command as
|
|
8292
|
-
var apiKeys2 = new
|
|
8472
|
+
import { Command as Command35 } from "commander";
|
|
8473
|
+
var apiKeys2 = new Command35("api-keys").description("disable API key management").option("-y, --yes", "skip confirmation prompt").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8293
8474
|
(opts, cmd) => runCommand(
|
|
8294
8475
|
() => runDisable(
|
|
8295
8476
|
{
|
|
@@ -8312,8 +8493,8 @@ var apiKeys2 = new Command34("api-keys").description("disable API key management
|
|
|
8312
8493
|
);
|
|
8313
8494
|
|
|
8314
8495
|
// src/commands/disable/backend.ts
|
|
8315
|
-
import { Command as
|
|
8316
|
-
var backend2 = new
|
|
8496
|
+
import { Command as Command36 } from "commander";
|
|
8497
|
+
var backend2 = new Command36("backend").description("disable the PocketBase backend").option("-y, --yes", "skip confirmation prompt").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8317
8498
|
(opts, cmd) => runCommand(
|
|
8318
8499
|
() => runDisable(
|
|
8319
8500
|
{
|
|
@@ -8336,8 +8517,8 @@ var backend2 = new Command35("backend").description("disable the PocketBase back
|
|
|
8336
8517
|
);
|
|
8337
8518
|
|
|
8338
8519
|
// src/commands/disable/content-negotiation.ts
|
|
8339
|
-
import { Command as
|
|
8340
|
-
var contentNegotiation2 = new
|
|
8520
|
+
import { Command as Command37 } from "commander";
|
|
8521
|
+
var contentNegotiation2 = new Command37("content-negotiation").description("disable content negotiation").option("-y, --yes", "skip confirmation prompt").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8341
8522
|
(opts, cmd) => runCommand(
|
|
8342
8523
|
() => runDisable(
|
|
8343
8524
|
{
|
|
@@ -8360,8 +8541,8 @@ var contentNegotiation2 = new Command36("content-negotiation").description("disa
|
|
|
8360
8541
|
);
|
|
8361
8542
|
|
|
8362
8543
|
// src/commands/disable/i18n.ts
|
|
8363
|
-
import { Command as
|
|
8364
|
-
var i18n2 = new
|
|
8544
|
+
import { Command as Command38 } from "commander";
|
|
8545
|
+
var i18n2 = new Command38("i18n").description("disable internationalization").option("-y, --yes", "skip confirmation prompt").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8365
8546
|
(opts, cmd) => runCommand(
|
|
8366
8547
|
() => runDisable(
|
|
8367
8548
|
{
|
|
@@ -8385,8 +8566,8 @@ var i18n2 = new Command37("i18n").description("disable internationalization").op
|
|
|
8385
8566
|
);
|
|
8386
8567
|
|
|
8387
8568
|
// src/commands/disable/notifications.ts
|
|
8388
|
-
import { Command as
|
|
8389
|
-
var notifications2 = new
|
|
8569
|
+
import { Command as Command39 } from "commander";
|
|
8570
|
+
var notifications2 = new Command39("notifications").description("disable in-app notifications").option("-y, --yes", "skip confirmation prompt").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8390
8571
|
(opts, cmd) => runCommand(
|
|
8391
8572
|
() => runDisable(
|
|
8392
8573
|
{
|
|
@@ -8412,8 +8593,8 @@ var notifications2 = new Command38("notifications").description("disable in-app
|
|
|
8412
8593
|
);
|
|
8413
8594
|
|
|
8414
8595
|
// src/commands/disable/teams.ts
|
|
8415
|
-
import { Command as
|
|
8416
|
-
var teams2 = new
|
|
8596
|
+
import { Command as Command40 } from "commander";
|
|
8597
|
+
var teams2 = new Command40("teams").description("disable teams").option("-y, --yes", "skip confirmation prompt").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8417
8598
|
(opts, cmd) => runCommand(
|
|
8418
8599
|
() => runDisable(
|
|
8419
8600
|
{
|
|
@@ -8436,7 +8617,7 @@ var teams2 = new Command39("teams").description("disable teams").option("-y, --y
|
|
|
8436
8617
|
);
|
|
8437
8618
|
|
|
8438
8619
|
// src/commands/disable/payments.ts
|
|
8439
|
-
import { Command as
|
|
8620
|
+
import { Command as Command41 } from "commander";
|
|
8440
8621
|
var STRIPE = {
|
|
8441
8622
|
confirmMessage: "Disable payments? Drops Stripe collections, strips Stripe env credentials, reverts nav/signup edits, and removes generated payment files. Stripe dashboard products/prices and the stripe packages are untouched.",
|
|
8442
8623
|
nextSteps: [
|
|
@@ -8458,7 +8639,7 @@ var WHATSAPP = {
|
|
|
8458
8639
|
]
|
|
8459
8640
|
};
|
|
8460
8641
|
var COPY = { shopify: SHOPIFY, whatsapp: WHATSAPP };
|
|
8461
|
-
var payments2 = new
|
|
8642
|
+
var payments2 = new Command41("payments").description("disable payments").option("-y, --yes", "skip confirmation prompt").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8462
8643
|
(opts, cmd) => runCommand(async () => {
|
|
8463
8644
|
const { detected } = await detectWorkspace();
|
|
8464
8645
|
const provider = detected.providers.payments;
|
|
@@ -8487,8 +8668,8 @@ var payments2 = new Command40("payments").description("disable payments").option
|
|
|
8487
8668
|
);
|
|
8488
8669
|
|
|
8489
8670
|
// src/commands/disable/ecommerce.ts
|
|
8490
|
-
import { Command as
|
|
8491
|
-
var ecommerce2 = new
|
|
8671
|
+
import { Command as Command42 } from "commander";
|
|
8672
|
+
var ecommerce2 = new Command42("ecommerce").description("disable ecommerce").option("-y, --yes", "skip confirmation prompt").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8492
8673
|
(opts, cmd) => runCommand(
|
|
8493
8674
|
() => runDisable(
|
|
8494
8675
|
{
|
|
@@ -8515,8 +8696,8 @@ var ecommerce2 = new Command41("ecommerce").description("disable ecommerce").opt
|
|
|
8515
8696
|
);
|
|
8516
8697
|
|
|
8517
8698
|
// src/commands/disable/subscriptions.ts
|
|
8518
|
-
import { Command as
|
|
8519
|
-
var subscriptions2 = new
|
|
8699
|
+
import { Command as Command43 } from "commander";
|
|
8700
|
+
var subscriptions2 = new Command43("subscriptions").description("disable Stripe subscriptions").option("-y, --yes", "skip confirmation prompt").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8520
8701
|
(opts, cmd) => runCommand(
|
|
8521
8702
|
() => runDisable(
|
|
8522
8703
|
{
|
|
@@ -8542,9 +8723,37 @@ var subscriptions2 = new Command42("subscriptions").description("disable Stripe
|
|
|
8542
8723
|
)
|
|
8543
8724
|
);
|
|
8544
8725
|
|
|
8726
|
+
// src/commands/disable/orders.ts
|
|
8727
|
+
import { Command as Command44 } from "commander";
|
|
8728
|
+
var orders2 = new Command44("orders").description("disable Stripe Checkout orders").option("-y, --yes", "skip confirmation prompt").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8729
|
+
(opts, cmd) => runCommand(
|
|
8730
|
+
() => runDisable(
|
|
8731
|
+
{
|
|
8732
|
+
slug: "disable-orders",
|
|
8733
|
+
confirmMessage: "Disable orders? Drops the orders and order_lines collections, removes the Checkout Session webhook handlers and the orders pages, and puts the success page back to Stripe\u2019s summary. Payments and the cart stay enabled.",
|
|
8734
|
+
report: {
|
|
8735
|
+
summary: "Disabled orders.",
|
|
8736
|
+
nextSteps: [
|
|
8737
|
+
"Stripe keeps every Checkout Session; the dashboard still lists what was bought.",
|
|
8738
|
+
"The cart is untouched; run `vela disable ecommerce` to remove it."
|
|
8739
|
+
],
|
|
8740
|
+
task: {
|
|
8741
|
+
title: "Disabling orders",
|
|
8742
|
+
success: "Disabled orders",
|
|
8743
|
+
error: "Failed to disable orders"
|
|
8744
|
+
}
|
|
8745
|
+
}
|
|
8746
|
+
},
|
|
8747
|
+
opts,
|
|
8748
|
+
cmd.args
|
|
8749
|
+
),
|
|
8750
|
+
"Failed to disable orders."
|
|
8751
|
+
)
|
|
8752
|
+
);
|
|
8753
|
+
|
|
8545
8754
|
// src/commands/disable/whatsapp.ts
|
|
8546
|
-
import { Command as
|
|
8547
|
-
var whatsapp2 = new
|
|
8755
|
+
import { Command as Command45 } from "commander";
|
|
8756
|
+
var whatsapp2 = new Command45("whatsapp").description("disable WhatsApp sign-in").option("-y, --yes", "skip confirmation prompt").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8548
8757
|
(opts, cmd) => runCommand(
|
|
8549
8758
|
() => runDisable(
|
|
8550
8759
|
{
|
|
@@ -8572,22 +8781,22 @@ var whatsapp2 = new Command43("whatsapp").description("disable WhatsApp sign-in"
|
|
|
8572
8781
|
);
|
|
8573
8782
|
|
|
8574
8783
|
// src/commands/disable.ts
|
|
8575
|
-
var disable = new
|
|
8784
|
+
var disable = new Command46("disable").description("disable features").configureHelp(helpConfig).addCommand(ai2).addCommand(analytics2).addCommand(auth2).addCommand(api2).addCommand(apiKeys2).addCommand(backend2).addCommand(contentNegotiation2).addCommand(i18n2).addCommand(notifications2).addCommand(teams2).addCommand(payments2).addCommand(ecommerce2).addCommand(subscriptions2).addCommand(orders2).addCommand(whatsapp2);
|
|
8576
8785
|
|
|
8577
8786
|
// src/commands/destroy.ts
|
|
8578
|
-
import { Command as
|
|
8787
|
+
import { Command as Command53 } from "commander";
|
|
8579
8788
|
|
|
8580
8789
|
// src/commands/destroy/form.ts
|
|
8581
|
-
import { Command as
|
|
8790
|
+
import { Command as Command47 } from "commander";
|
|
8582
8791
|
|
|
8583
8792
|
// src/commands/destroy/_shared.ts
|
|
8584
8793
|
import process23 from "node:process";
|
|
8585
|
-
import * as
|
|
8794
|
+
import * as p25 from "@clack/prompts";
|
|
8586
8795
|
async function runDestroy(slug2, model, confirmMessage, report5, flags) {
|
|
8587
8796
|
if (!flags.yes) {
|
|
8588
|
-
const ok = await
|
|
8589
|
-
if (
|
|
8590
|
-
|
|
8797
|
+
const ok = await p25.confirm({ message: confirmMessage, initialValue: false });
|
|
8798
|
+
if (p25.isCancel(ok) || !ok) {
|
|
8799
|
+
p25.cancel("Operation cancelled.");
|
|
8591
8800
|
process23.exit(0);
|
|
8592
8801
|
}
|
|
8593
8802
|
}
|
|
@@ -8595,7 +8804,7 @@ async function runDestroy(slug2, model, confirmMessage, report5, flags) {
|
|
|
8595
8804
|
}
|
|
8596
8805
|
|
|
8597
8806
|
// src/commands/destroy/form.ts
|
|
8598
|
-
var form2 = new
|
|
8807
|
+
var form2 = new Command47("form").description("destroy a form generated by `vela generate form`").argument("<model>", "model name used when the form was generated (e.g., contact, login)").option("-y, --yes", "skip confirmation prompt").option(
|
|
8599
8808
|
"--route <route>",
|
|
8600
8809
|
"custom route the form was generated at (must match the --route used at generation)"
|
|
8601
8810
|
).allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
@@ -8619,8 +8828,8 @@ var form2 = new Command45("form").description("destroy a form generated by `vela
|
|
|
8619
8828
|
);
|
|
8620
8829
|
|
|
8621
8830
|
// src/commands/destroy/schema.ts
|
|
8622
|
-
import { Command as
|
|
8623
|
-
var schema2 = new
|
|
8831
|
+
import { Command as Command48 } from "commander";
|
|
8832
|
+
var schema2 = new Command48("schema").description("destroy a zod schema generated by `vela generate schema`").argument("<model>", "schema model name (e.g., contact, login)").option("-y, --yes", "skip confirmation prompt").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8624
8833
|
(model, opts) => runCommand(
|
|
8625
8834
|
() => runDestroy(
|
|
8626
8835
|
"destroy-schema",
|
|
@@ -8641,8 +8850,8 @@ var schema2 = new Command46("schema").description("destroy a zod schema generate
|
|
|
8641
8850
|
);
|
|
8642
8851
|
|
|
8643
8852
|
// src/commands/destroy/resource.ts
|
|
8644
|
-
import { Command as
|
|
8645
|
-
var resource2 = new
|
|
8853
|
+
import { Command as Command49 } from "commander";
|
|
8854
|
+
var resource2 = new Command49("resource").description("destroy a resource generated by `vela generate resource`").argument("<model>", "model path used when the resource was generated (e.g., contacts, articles)").option("-y, --yes", "skip confirmation prompt").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
8646
8855
|
(model, opts) => runCommand(
|
|
8647
8856
|
() => runDestroy(
|
|
8648
8857
|
"destroy-resource",
|
|
@@ -8663,8 +8872,8 @@ var resource2 = new Command47("resource").description("destroy a resource genera
|
|
|
8663
8872
|
);
|
|
8664
8873
|
|
|
8665
8874
|
// src/commands/destroy/scaffold.ts
|
|
8666
|
-
import { Command as
|
|
8667
|
-
var scaffold2 = new
|
|
8875
|
+
import { Command as Command50 } from "commander";
|
|
8876
|
+
var scaffold2 = new Command50("scaffold").description("destroy a scaffold generated by `vela generate scaffold`").argument("<model>", "model name used when the scaffold was generated (e.g., contact, todo)").option("-y, --yes", "skip confirmation prompt").option(
|
|
8668
8877
|
"--route <route>",
|
|
8669
8878
|
"custom route the scaffold was generated at (must match the --route used at generation)"
|
|
8670
8879
|
).allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
@@ -8692,14 +8901,14 @@ var scaffold2 = new Command48("scaffold").description("destroy a scaffold genera
|
|
|
8692
8901
|
|
|
8693
8902
|
// src/commands/destroy/deployment.ts
|
|
8694
8903
|
import process27 from "node:process";
|
|
8695
|
-
import { Command as
|
|
8696
|
-
import * as
|
|
8904
|
+
import { Command as Command51 } from "commander";
|
|
8905
|
+
import * as p29 from "@clack/prompts";
|
|
8697
8906
|
import pc12 from "picocolors";
|
|
8698
8907
|
|
|
8699
8908
|
// src/lib/server-command.ts
|
|
8700
8909
|
import process26 from "node:process";
|
|
8701
8910
|
import * as v8 from "valibot";
|
|
8702
|
-
import * as
|
|
8911
|
+
import * as p26 from "@clack/prompts";
|
|
8703
8912
|
import pc9 from "picocolors";
|
|
8704
8913
|
|
|
8705
8914
|
// src/lib/deploy-config.ts
|
|
@@ -9539,8 +9748,8 @@ function describeTarget(target) {
|
|
|
9539
9748
|
return target.name;
|
|
9540
9749
|
}
|
|
9541
9750
|
}
|
|
9542
|
-
function bold(
|
|
9543
|
-
return `\`${
|
|
9751
|
+
function bold(text20) {
|
|
9752
|
+
return `\`${text20}\``;
|
|
9544
9753
|
}
|
|
9545
9754
|
|
|
9546
9755
|
// src/lib/server-command.ts
|
|
@@ -9637,7 +9846,7 @@ async function ensureBinding(workspaceRootDir, target, request = {}) {
|
|
|
9637
9846
|
writeBinding(workspaceRootDir, key, binding);
|
|
9638
9847
|
}
|
|
9639
9848
|
if (moving) {
|
|
9640
|
-
|
|
9849
|
+
p26.log.warn(
|
|
9641
9850
|
`${pc9.cyan(bindingName(target))} now points at ${pc9.cyan(server)}.
|
|
9642
9851
|
|
|
9643
9852
|
Whatever is running on ${existing.server} is left there, and this project can no
|
|
@@ -9656,12 +9865,12 @@ Drop ${pc9.cyan("--server")} to use the recorded one, or move the binding on pur
|
|
|
9656
9865
|
this command once from a terminal (or editing .vela/project.json).`
|
|
9657
9866
|
);
|
|
9658
9867
|
}
|
|
9659
|
-
const ok = await
|
|
9868
|
+
const ok = await p26.confirm({
|
|
9660
9869
|
message: `${name} ${target.kind === "preview" ? "run" : "runs"} on ${from}. Point ${name} at ${to} instead?`,
|
|
9661
9870
|
initialValue: false
|
|
9662
9871
|
});
|
|
9663
|
-
if (
|
|
9664
|
-
|
|
9872
|
+
if (p26.isCancel(ok) || !ok) {
|
|
9873
|
+
p26.cancel("Operation cancelled.");
|
|
9665
9874
|
process26.exit(0);
|
|
9666
9875
|
}
|
|
9667
9876
|
}
|
|
@@ -9678,28 +9887,28 @@ Pass ${pc9.cyan("--server user@host")}, or run the command once from your own ma
|
|
|
9678
9887
|
and commit ${pc9.cyan(".vela/project.json")}.`
|
|
9679
9888
|
);
|
|
9680
9889
|
}
|
|
9681
|
-
|
|
9890
|
+
p26.log.info(
|
|
9682
9891
|
`${pc9.cyan(name)} ${target.kind === "preview" ? "are" : "is"} not bound to a server yet.`
|
|
9683
9892
|
);
|
|
9684
|
-
const value = await
|
|
9893
|
+
const value = await p26.text({
|
|
9685
9894
|
message: `Which server should ${name} run on?`,
|
|
9686
9895
|
placeholder: "root@203.0.113.10",
|
|
9687
9896
|
validate: (input) => input?.trim() ? void 0 : "An ssh_config alias, or user@host"
|
|
9688
9897
|
});
|
|
9689
|
-
if (
|
|
9690
|
-
|
|
9898
|
+
if (p26.isCancel(value)) {
|
|
9899
|
+
p26.cancel("Operation cancelled.");
|
|
9691
9900
|
process26.exit(0);
|
|
9692
9901
|
}
|
|
9693
9902
|
return value.trim();
|
|
9694
9903
|
}
|
|
9695
9904
|
async function promptDomain(target) {
|
|
9696
9905
|
if (!process26.stdout.isTTY || process26.env.CI) return void 0;
|
|
9697
|
-
const value = await
|
|
9906
|
+
const value = await p26.text({
|
|
9698
9907
|
message: `Which hostname should ${target.name} be served on?`,
|
|
9699
9908
|
placeholder: "example.com \u2014 leave blank to decide later"
|
|
9700
9909
|
});
|
|
9701
|
-
if (
|
|
9702
|
-
|
|
9910
|
+
if (p26.isCancel(value)) {
|
|
9911
|
+
p26.cancel("Operation cancelled.");
|
|
9703
9912
|
process26.exit(0);
|
|
9704
9913
|
}
|
|
9705
9914
|
return value.trim() || void 0;
|
|
@@ -9708,10 +9917,10 @@ async function applyRestart(ctx) {
|
|
|
9708
9917
|
const outcome = await restartInstance(ctx.session, ctx.instance);
|
|
9709
9918
|
if (!outcome.deployed) return;
|
|
9710
9919
|
if (outcome.restarted) {
|
|
9711
|
-
|
|
9920
|
+
p26.log.success("App restarted");
|
|
9712
9921
|
return;
|
|
9713
9922
|
}
|
|
9714
|
-
|
|
9923
|
+
p26.log.error(
|
|
9715
9924
|
`App restart failed.
|
|
9716
9925
|
|
|
9717
9926
|
The new value is stored and will be used the next time the app starts.
|
|
@@ -9720,7 +9929,7 @@ ${pc9.dim(outcome.error ?? "")}`
|
|
|
9720
9929
|
}
|
|
9721
9930
|
async function applyEnvRestart(ctx, changed) {
|
|
9722
9931
|
if (touchesSuperuser(changed)) {
|
|
9723
|
-
|
|
9932
|
+
p26.log.warn(
|
|
9724
9933
|
`PocketBase superuser credentials changed.
|
|
9725
9934
|
|
|
9726
9935
|
The database still holds the old ones, so the app has not been restarted.
|
|
@@ -9797,11 +10006,11 @@ function describe({ appName, envTag, purge }) {
|
|
|
9797
10006
|
}
|
|
9798
10007
|
|
|
9799
10008
|
// src/lib/deploy-report.ts
|
|
9800
|
-
import * as
|
|
10009
|
+
import * as p28 from "@clack/prompts";
|
|
9801
10010
|
import pc11 from "picocolors";
|
|
9802
10011
|
|
|
9803
10012
|
// src/lib/server-identity.ts
|
|
9804
|
-
import * as
|
|
10013
|
+
import * as p27 from "@clack/prompts";
|
|
9805
10014
|
import pc10 from "picocolors";
|
|
9806
10015
|
var IPV4 = /^\d{1,3}(?:\.\d{1,3}){3}$/;
|
|
9807
10016
|
async function ensureServerIdentity(session, apiKey) {
|
|
@@ -9815,7 +10024,7 @@ async function ensureServerIdentity(session, apiKey) {
|
|
|
9815
10024
|
if (!existing || existing.serverId !== registered.serverId || existing.originHost !== registered.originHost || existing.token !== registered.token) {
|
|
9816
10025
|
await writeServerIdentity(session, registered);
|
|
9817
10026
|
if (existing) {
|
|
9818
|
-
|
|
10027
|
+
p27.log.info(`${pc10.cyan(session.target)} was re-registered with velastack.dev.`);
|
|
9819
10028
|
}
|
|
9820
10029
|
}
|
|
9821
10030
|
await runServerScript(session, "origin.sh");
|
|
@@ -9855,7 +10064,7 @@ function createDeployReporter(workspaceRootDir) {
|
|
|
9855
10064
|
const link2 = readProjectConfig(workspaceRootDir);
|
|
9856
10065
|
const apiKey = link2 ? readApiKey() : null;
|
|
9857
10066
|
if (link2 && !apiKey) {
|
|
9858
|
-
|
|
10067
|
+
p28.log.warn(
|
|
9859
10068
|
`This project is linked to ${pc11.cyan(link2.projectName)} on velastack.dev, but there is no
|
|
9860
10069
|
API key here, so this deploy will not be recorded. Run ${pc11.cyan("vela login")}, or set
|
|
9861
10070
|
${pc11.cyan("VELA_API_KEY")}.`
|
|
@@ -9906,7 +10115,7 @@ async function reportEnvironmentDestroyed(workspaceRootDir, envTag, { missingOk
|
|
|
9906
10115
|
}
|
|
9907
10116
|
}
|
|
9908
10117
|
function warn(what, err) {
|
|
9909
|
-
|
|
10118
|
+
p28.log.warn(
|
|
9910
10119
|
`velastack.dev could not ${what}.
|
|
9911
10120
|
${pc11.dim(err instanceof Error ? err.message : String(err))}`
|
|
9912
10121
|
);
|
|
@@ -9915,7 +10124,7 @@ ${pc11.dim(err instanceof Error ? err.message : String(err))}`
|
|
|
9915
10124
|
// src/commands/destroy/deployment.ts
|
|
9916
10125
|
var deployment = addLockWaitOption(
|
|
9917
10126
|
addTargetOptions(
|
|
9918
|
-
new
|
|
10127
|
+
new Command51("deployment").description("remove a deployed environment from its server").configureHelp(helpConfig),
|
|
9919
10128
|
"production"
|
|
9920
10129
|
)
|
|
9921
10130
|
).option("--purge", "also delete the database and uploaded files").option("-y, --yes", "skip the confirmation prompt").option(
|
|
@@ -9954,13 +10163,13 @@ var deployment = addLockWaitOption(
|
|
|
9954
10163
|
missingOk: true
|
|
9955
10164
|
});
|
|
9956
10165
|
}
|
|
9957
|
-
|
|
10166
|
+
p29.log.info(
|
|
9958
10167
|
`Nothing named ${pc12.cyan(`${ctx.appName} (${ctx.targetName})`)} on ${ctx.server}; nothing to remove.`
|
|
9959
10168
|
);
|
|
9960
10169
|
return;
|
|
9961
10170
|
}
|
|
9962
10171
|
await reportEnvironmentDestroyed(ctx.workspaceRootDir, ctx.envTag);
|
|
9963
|
-
|
|
10172
|
+
p29.log.success(
|
|
9964
10173
|
`Removed ${pc12.cyan(`${ctx.appName} (${ctx.targetName})`)} from ${ctx.server}.` + (result?.purged ? result.trash ? `
|
|
9965
10174
|
|
|
9966
10175
|
A snapshot of its data is at ${pc12.cyan(result.trash)} on the server for two weeks.` : "" : `
|
|
@@ -9978,39 +10187,39 @@ The database and uploads are still in the instance's shared directory. Pass ${pc
|
|
|
9978
10187
|
);
|
|
9979
10188
|
async function confirm6(appName, targetName, byName) {
|
|
9980
10189
|
if (byName) {
|
|
9981
|
-
const answer = await
|
|
10190
|
+
const answer = await p29.text({
|
|
9982
10191
|
message: `This removes ${pc12.cyan(`${appName} (${targetName})`)}. Type the app name to confirm`,
|
|
9983
10192
|
validate: (value) => value === appName ? void 0 : `Type ${appName} to confirm`
|
|
9984
10193
|
});
|
|
9985
|
-
if (
|
|
9986
|
-
|
|
10194
|
+
if (p29.isCancel(answer)) {
|
|
10195
|
+
p29.cancel("Operation cancelled.");
|
|
9987
10196
|
process27.exit(0);
|
|
9988
10197
|
}
|
|
9989
10198
|
return;
|
|
9990
10199
|
}
|
|
9991
|
-
const ok = await
|
|
10200
|
+
const ok = await p29.confirm({
|
|
9992
10201
|
message: `Remove ${appName} (${targetName})?`,
|
|
9993
10202
|
initialValue: false
|
|
9994
10203
|
});
|
|
9995
|
-
if (
|
|
9996
|
-
|
|
10204
|
+
if (p29.isCancel(ok) || !ok) {
|
|
10205
|
+
p29.cancel("Operation cancelled.");
|
|
9997
10206
|
process27.exit(0);
|
|
9998
10207
|
}
|
|
9999
10208
|
}
|
|
10000
10209
|
|
|
10001
10210
|
// src/commands/destroy/shop.ts
|
|
10002
10211
|
import process28 from "node:process";
|
|
10003
|
-
import { Command as
|
|
10004
|
-
import * as
|
|
10005
|
-
var shop2 = new
|
|
10212
|
+
import { Command as Command52 } from "commander";
|
|
10213
|
+
import * as p30 from "@clack/prompts";
|
|
10214
|
+
var shop2 = new Command52("shop").description("destroy the shop pages generated by `vela generate shop`").option("-y, --yes", "skip confirmation prompt").allowExcessArguments(true).configureHelp(helpConfig).action(
|
|
10006
10215
|
(opts, cmd) => runCommand(async () => {
|
|
10007
10216
|
if (!opts.yes) {
|
|
10008
|
-
const ok = await
|
|
10217
|
+
const ok = await p30.confirm({
|
|
10009
10218
|
message: "Destroy the shop? Removes the listing and product pages (and src/lib/catalog.ts on WhatsApp). The cart and payments stay.",
|
|
10010
10219
|
initialValue: false
|
|
10011
10220
|
});
|
|
10012
|
-
if (
|
|
10013
|
-
|
|
10221
|
+
if (p30.isCancel(ok) || !ok) {
|
|
10222
|
+
p30.cancel("Operation cancelled.");
|
|
10014
10223
|
process28.exit(0);
|
|
10015
10224
|
}
|
|
10016
10225
|
}
|
|
@@ -10031,14 +10240,14 @@ var shop2 = new Command50("shop").description("destroy the shop pages generated
|
|
|
10031
10240
|
);
|
|
10032
10241
|
|
|
10033
10242
|
// src/commands/destroy.ts
|
|
10034
|
-
var destroy = new
|
|
10243
|
+
var destroy = new Command53("destroy").description("destroy scaffolding, or a deployment").configureHelp(helpConfig).addCommand(form2).addCommand(schema2).addCommand(resource2).addCommand(scaffold2).addCommand(shop2).addCommand(deployment);
|
|
10035
10244
|
|
|
10036
10245
|
// src/commands/ui.ts
|
|
10037
|
-
import { Command as
|
|
10246
|
+
import { Command as Command59 } from "commander";
|
|
10038
10247
|
|
|
10039
10248
|
// src/commands/ui/add.ts
|
|
10040
|
-
import { Command as
|
|
10041
|
-
import * as
|
|
10249
|
+
import { Command as Command54 } from "commander";
|
|
10250
|
+
import * as p31 from "@clack/prompts";
|
|
10042
10251
|
import { installComponents } from "@velastack/patterns";
|
|
10043
10252
|
|
|
10044
10253
|
// src/lib/ui-add.ts
|
|
@@ -10087,22 +10296,22 @@ function uiAddReport(requested, outcome) {
|
|
|
10087
10296
|
}
|
|
10088
10297
|
|
|
10089
10298
|
// src/commands/ui/add.ts
|
|
10090
|
-
var add = new
|
|
10299
|
+
var add = new Command54("add").description("add ui components (shadcn-svelte items and vela components such as data-table)").argument("<components...>", "the components to add").option("--overwrite", "replace components that already exist", false).configureHelp(helpConfig).action(
|
|
10091
10300
|
(components, options) => runCommand(async () => {
|
|
10092
10301
|
const { workspaceRootDir } = await getWorkspace();
|
|
10093
10302
|
assertShadcn("vela ui add", workspaceRootDir);
|
|
10094
|
-
const
|
|
10303
|
+
const log58 = p31.taskLog({ title: "Adding UI components..." });
|
|
10095
10304
|
let outcome;
|
|
10096
10305
|
try {
|
|
10097
10306
|
outcome = await installComponents({
|
|
10098
10307
|
root: workspaceRootDir,
|
|
10099
10308
|
components,
|
|
10100
10309
|
overwrite: options.overwrite,
|
|
10101
|
-
logger: { info: (message) =>
|
|
10310
|
+
logger: { info: (message) => log58.message(message) }
|
|
10102
10311
|
});
|
|
10103
|
-
|
|
10312
|
+
log58.success("UI components ready");
|
|
10104
10313
|
} catch (e) {
|
|
10105
|
-
|
|
10314
|
+
log58.error("Could not add UI components");
|
|
10106
10315
|
throw e;
|
|
10107
10316
|
}
|
|
10108
10317
|
reportResult(uiAddReport(components, outcome));
|
|
@@ -10110,20 +10319,20 @@ var add = new Command52("add").description("add ui components (shadcn-svelte ite
|
|
|
10110
10319
|
);
|
|
10111
10320
|
|
|
10112
10321
|
// src/commands/ui/base.ts
|
|
10113
|
-
import { Command as
|
|
10114
|
-
import * as
|
|
10322
|
+
import { Command as Command55 } from "commander";
|
|
10323
|
+
import * as p32 from "@clack/prompts";
|
|
10115
10324
|
import { applyBaseColor } from "@velastack/patterns";
|
|
10116
|
-
var base = new
|
|
10325
|
+
var base = new Command55("base").description("change the base (gray) palette").argument("<color>", `base color to use (${BASE_COLORS.join(", ")})`).configureHelp(helpConfig).action(
|
|
10117
10326
|
(color) => runCommand(async () => {
|
|
10118
10327
|
const { workspaceRootDir } = await getWorkspace();
|
|
10119
10328
|
assertShadcn("vela ui base", workspaceRootDir);
|
|
10120
|
-
const
|
|
10329
|
+
const log58 = p32.taskLog({ title: `Applying the ${color} palette...` });
|
|
10121
10330
|
let outcome;
|
|
10122
10331
|
try {
|
|
10123
10332
|
outcome = await applyBaseColor({ root: workspaceRootDir, color });
|
|
10124
|
-
|
|
10333
|
+
log58.success("Palette applied");
|
|
10125
10334
|
} catch (e) {
|
|
10126
|
-
|
|
10335
|
+
log58.error("Could not change the base color");
|
|
10127
10336
|
throw e;
|
|
10128
10337
|
}
|
|
10129
10338
|
reportResult({
|
|
@@ -10139,8 +10348,8 @@ var base = new Command53("base").description("change the base (gray) palette").a
|
|
|
10139
10348
|
);
|
|
10140
10349
|
|
|
10141
10350
|
// src/commands/ui/list.ts
|
|
10142
|
-
import { Command as
|
|
10143
|
-
import * as
|
|
10351
|
+
import { Command as Command56 } from "commander";
|
|
10352
|
+
import * as p33 from "@clack/prompts";
|
|
10144
10353
|
import { listComponents } from "@velastack/patterns";
|
|
10145
10354
|
|
|
10146
10355
|
// src/lib/ui-list.ts
|
|
@@ -10171,7 +10380,7 @@ function uiListReport(result) {
|
|
|
10171
10380
|
}
|
|
10172
10381
|
|
|
10173
10382
|
// src/commands/ui/list.ts
|
|
10174
|
-
var list = new
|
|
10383
|
+
var list = new Command56("list").description("list installed ui components, vela components and the style registry").option("--json", "print the result as JSON", false).configureHelp(helpConfig).action(
|
|
10175
10384
|
(options) => runCommand(async () => {
|
|
10176
10385
|
const { workspaceRootDir } = await getWorkspace();
|
|
10177
10386
|
assertShadcn("vela ui list", workspaceRootDir);
|
|
@@ -10180,7 +10389,7 @@ var list = new Command54("list").description("list installed ui components, vela
|
|
|
10180
10389
|
console.log(JSON.stringify(result2, null, 2));
|
|
10181
10390
|
return;
|
|
10182
10391
|
}
|
|
10183
|
-
const spinner9 =
|
|
10392
|
+
const spinner9 = p33.spinner();
|
|
10184
10393
|
spinner9.start("Reading the registry...");
|
|
10185
10394
|
let result;
|
|
10186
10395
|
try {
|
|
@@ -10192,15 +10401,15 @@ var list = new Command54("list").description("list installed ui components, vela
|
|
|
10192
10401
|
spinner9.stop(`Read the ${result.style} registry`);
|
|
10193
10402
|
reportResult(uiListReport(result));
|
|
10194
10403
|
if (result.registryUnavailable) {
|
|
10195
|
-
|
|
10404
|
+
p33.log.warn(`${result.registryUnavailable}
|
|
10196
10405
|
Registry components are not listed.`);
|
|
10197
10406
|
}
|
|
10198
10407
|
}, "Failed to list UI components.")
|
|
10199
10408
|
);
|
|
10200
10409
|
|
|
10201
10410
|
// src/commands/ui/style.ts
|
|
10202
|
-
import { Command as
|
|
10203
|
-
import * as
|
|
10411
|
+
import { Command as Command57 } from "commander";
|
|
10412
|
+
import * as p34 from "@clack/prompts";
|
|
10204
10413
|
import { switchStyle } from "@velastack/patterns";
|
|
10205
10414
|
|
|
10206
10415
|
// src/lib/ui-style.ts
|
|
@@ -10226,74 +10435,74 @@ function uiStyleReport(result) {
|
|
|
10226
10435
|
}
|
|
10227
10436
|
|
|
10228
10437
|
// src/commands/ui/style.ts
|
|
10229
|
-
var style = new
|
|
10438
|
+
var style = new Command57("style").description("switch the shadcn-svelte style, re-adding its components").argument("<style>", `style to switch to (${STYLES.join(", ")})`).option("-y, --yes", "skip the confirmation prompt").option("--no-font", "keep the current font instead of applying the style's").configureHelp(helpConfig).action(
|
|
10230
10439
|
(name, options) => runCommand(async () => {
|
|
10231
10440
|
const { workspaceRootDir } = await getWorkspace();
|
|
10232
10441
|
assertShadcn("vela ui style", workspaceRootDir);
|
|
10233
|
-
const spinner9 =
|
|
10442
|
+
const spinner9 = p34.spinner();
|
|
10234
10443
|
spinner9.start(`Reading the ${name} registry...`);
|
|
10235
|
-
let
|
|
10444
|
+
let log58;
|
|
10236
10445
|
let outcome;
|
|
10237
10446
|
try {
|
|
10238
10447
|
outcome = await switchStyle({
|
|
10239
10448
|
root: workspaceRootDir,
|
|
10240
10449
|
style: name,
|
|
10241
10450
|
font: options.font,
|
|
10242
|
-
logger: { info: (message) =>
|
|
10451
|
+
logger: { info: (message) => log58?.message(message) },
|
|
10243
10452
|
confirm: async (components) => {
|
|
10244
10453
|
spinner9.stop(`Read the ${name} registry`);
|
|
10245
10454
|
if (components.length > 0) {
|
|
10246
|
-
|
|
10455
|
+
p34.log.info(
|
|
10247
10456
|
`Re-adds ${components.length} component(s) from the ${name} registry; local edits to their files are lost:
|
|
10248
10457
|
${components.map((c) => `- ${c}`).join("\n")}`
|
|
10249
10458
|
);
|
|
10250
10459
|
} else {
|
|
10251
|
-
|
|
10460
|
+
p34.log.info(
|
|
10252
10461
|
`No installed component comes from the registry; only the config changes.`
|
|
10253
10462
|
);
|
|
10254
10463
|
}
|
|
10255
10464
|
if (!options.yes) {
|
|
10256
|
-
const ok = await
|
|
10257
|
-
if (
|
|
10465
|
+
const ok = await p34.confirm({ message: `Switch to ${name}?`, initialValue: false });
|
|
10466
|
+
if (p34.isCancel(ok) || !ok) return false;
|
|
10258
10467
|
}
|
|
10259
|
-
|
|
10468
|
+
log58 = p34.taskLog({ title: `Switching to the ${name} style...` });
|
|
10260
10469
|
return true;
|
|
10261
10470
|
}
|
|
10262
10471
|
});
|
|
10263
10472
|
} catch (e) {
|
|
10264
10473
|
spinner9.stop(`Could not switch to ${name}`);
|
|
10265
|
-
|
|
10474
|
+
log58?.error("Could not switch style");
|
|
10266
10475
|
throw e;
|
|
10267
10476
|
}
|
|
10268
10477
|
spinner9.stop(`Read the ${name} registry`);
|
|
10269
10478
|
if (outcome.status === "unchanged") {
|
|
10270
|
-
|
|
10479
|
+
p34.log.info(`Already using the ${name} style.`);
|
|
10271
10480
|
return;
|
|
10272
10481
|
}
|
|
10273
10482
|
if (outcome.status === "cancelled") {
|
|
10274
|
-
|
|
10483
|
+
p34.cancel("Operation cancelled.");
|
|
10275
10484
|
return;
|
|
10276
10485
|
}
|
|
10277
|
-
|
|
10486
|
+
log58?.success("Style switched");
|
|
10278
10487
|
reportResult(uiStyleReport(outcome));
|
|
10279
10488
|
}, "Failed to switch style.")
|
|
10280
10489
|
);
|
|
10281
10490
|
|
|
10282
10491
|
// src/commands/ui/theme.ts
|
|
10283
|
-
import { Command as
|
|
10284
|
-
import * as
|
|
10492
|
+
import { Command as Command58 } from "commander";
|
|
10493
|
+
import * as p35 from "@clack/prompts";
|
|
10285
10494
|
import { applyTheme } from "@velastack/patterns";
|
|
10286
|
-
var theme = new
|
|
10495
|
+
var theme = new Command58("theme").description("change the accent color, keeping the base palette").argument("<accent>", `accent to use (${THEMES.join(", ")})`).configureHelp(helpConfig).action(
|
|
10287
10496
|
(accent) => runCommand(async () => {
|
|
10288
10497
|
const { workspaceRootDir } = await getWorkspace();
|
|
10289
10498
|
assertShadcn("vela ui theme", workspaceRootDir);
|
|
10290
|
-
const
|
|
10499
|
+
const log58 = p35.taskLog({ title: `Applying the ${accent} accent...` });
|
|
10291
10500
|
let outcome;
|
|
10292
10501
|
try {
|
|
10293
10502
|
outcome = await applyTheme({ root: workspaceRootDir, theme: accent });
|
|
10294
|
-
|
|
10503
|
+
log58.success("Accent applied");
|
|
10295
10504
|
} catch (e) {
|
|
10296
|
-
|
|
10505
|
+
log58.error("Could not change the accent");
|
|
10297
10506
|
throw e;
|
|
10298
10507
|
}
|
|
10299
10508
|
reportResult({
|
|
@@ -10309,25 +10518,25 @@ var theme = new Command56("theme").description("change the accent color, keeping
|
|
|
10309
10518
|
);
|
|
10310
10519
|
|
|
10311
10520
|
// src/commands/ui.ts
|
|
10312
|
-
var ui = new
|
|
10521
|
+
var ui = new Command59("ui").description("generate ui components").configureHelp(helpConfig).addCommand(add).addCommand(list).addCommand(style).addCommand(base).addCommand(theme);
|
|
10313
10522
|
|
|
10314
10523
|
// src/commands/legal.ts
|
|
10315
|
-
import { Command as
|
|
10524
|
+
import { Command as Command62 } from "commander";
|
|
10316
10525
|
|
|
10317
10526
|
// src/commands/legal/terms.ts
|
|
10318
10527
|
import path41 from "node:path";
|
|
10319
|
-
import { Command as
|
|
10320
|
-
import * as
|
|
10528
|
+
import { Command as Command60 } from "commander";
|
|
10529
|
+
import * as p37 from "@clack/prompts";
|
|
10321
10530
|
|
|
10322
10531
|
// src/commands/legal/shared.ts
|
|
10323
10532
|
import process29 from "node:process";
|
|
10324
10533
|
import fs41 from "node:fs";
|
|
10325
10534
|
import path40 from "node:path";
|
|
10326
|
-
import * as
|
|
10535
|
+
import * as p36 from "@clack/prompts";
|
|
10327
10536
|
function siteFields(site) {
|
|
10328
10537
|
const url = site?.url && !isLocalUrl(site.url) ? site.url : void 0;
|
|
10329
10538
|
return {
|
|
10330
|
-
websiteUrl: () =>
|
|
10539
|
+
websiteUrl: () => p36.text({
|
|
10331
10540
|
message: "What is your website URL?",
|
|
10332
10541
|
placeholder: "http://www.mysite.com",
|
|
10333
10542
|
initialValue: url,
|
|
@@ -10337,7 +10546,7 @@ function siteFields(site) {
|
|
|
10337
10546
|
}
|
|
10338
10547
|
}
|
|
10339
10548
|
}),
|
|
10340
|
-
websiteName: () =>
|
|
10549
|
+
websiteName: () => p36.text({
|
|
10341
10550
|
message: "What is your website name?",
|
|
10342
10551
|
placeholder: "My Site",
|
|
10343
10552
|
initialValue: site?.name,
|
|
@@ -10350,7 +10559,7 @@ function siteFields(site) {
|
|
|
10350
10559
|
};
|
|
10351
10560
|
}
|
|
10352
10561
|
var sharedFields = {
|
|
10353
|
-
entityType: () =>
|
|
10562
|
+
entityType: () => p36.select({
|
|
10354
10563
|
message: "Entity type",
|
|
10355
10564
|
options: [
|
|
10356
10565
|
{
|
|
@@ -10361,7 +10570,7 @@ var sharedFields = {
|
|
|
10361
10570
|
{ value: "individual", label: "I'm an Individual" }
|
|
10362
10571
|
]
|
|
10363
10572
|
}),
|
|
10364
|
-
businessName: ({ results }) => results?.entityType === "business" ?
|
|
10573
|
+
businessName: ({ results }) => results?.entityType === "business" ? p36.text({
|
|
10365
10574
|
message: "What is the name of the business?",
|
|
10366
10575
|
placeholder: "My Company LLC",
|
|
10367
10576
|
validate: (value) => {
|
|
@@ -10370,7 +10579,7 @@ var sharedFields = {
|
|
|
10370
10579
|
}
|
|
10371
10580
|
}
|
|
10372
10581
|
}) : void 0,
|
|
10373
|
-
businessAddress: ({ results }) => results?.entityType === "business" ?
|
|
10582
|
+
businessAddress: ({ results }) => results?.entityType === "business" ? p36.text({
|
|
10374
10583
|
message: "What is the address of the business?",
|
|
10375
10584
|
placeholder: "1 Cupertino, CA 95014",
|
|
10376
10585
|
validate: (value) => {
|
|
@@ -10379,7 +10588,7 @@ var sharedFields = {
|
|
|
10379
10588
|
}
|
|
10380
10589
|
}
|
|
10381
10590
|
}) : void 0,
|
|
10382
|
-
country: () =>
|
|
10591
|
+
country: () => p36.text({
|
|
10383
10592
|
message: "Enter the country",
|
|
10384
10593
|
validate: (value) => {
|
|
10385
10594
|
if (!value) {
|
|
@@ -10387,7 +10596,7 @@ var sharedFields = {
|
|
|
10387
10596
|
}
|
|
10388
10597
|
}
|
|
10389
10598
|
}),
|
|
10390
|
-
state: () =>
|
|
10599
|
+
state: () => p36.text({
|
|
10391
10600
|
message: "Enter the state",
|
|
10392
10601
|
validate: (value) => {
|
|
10393
10602
|
if (!value) {
|
|
@@ -10397,11 +10606,11 @@ var sharedFields = {
|
|
|
10397
10606
|
})
|
|
10398
10607
|
};
|
|
10399
10608
|
var onCancel = () => {
|
|
10400
|
-
|
|
10609
|
+
p36.cancel("Operation cancelled.");
|
|
10401
10610
|
process29.exit(0);
|
|
10402
10611
|
};
|
|
10403
10612
|
async function contactMethods(type) {
|
|
10404
|
-
const selection = await
|
|
10613
|
+
const selection = await p36.multiselect({
|
|
10405
10614
|
message: `How can users contact you for any questions regarding your ${type === "privacy" ? "Privacy Policy" : "Terms & Conditions"}? Check all that apply`,
|
|
10406
10615
|
options: [
|
|
10407
10616
|
{ value: "email", label: "By email" },
|
|
@@ -10410,11 +10619,11 @@ async function contactMethods(type) {
|
|
|
10410
10619
|
{ value: "mail", label: "By sending post mail" }
|
|
10411
10620
|
]
|
|
10412
10621
|
});
|
|
10413
|
-
if (
|
|
10622
|
+
if (p36.isCancel(selection)) onCancel();
|
|
10414
10623
|
const contact = selection;
|
|
10415
10624
|
const details = {};
|
|
10416
10625
|
if (contact.includes("email")) {
|
|
10417
|
-
const email2 = await
|
|
10626
|
+
const email2 = await p36.text({
|
|
10418
10627
|
message: "What's the email?",
|
|
10419
10628
|
placeholder: "office@mycompany.com",
|
|
10420
10629
|
validate: (value) => {
|
|
@@ -10423,11 +10632,11 @@ async function contactMethods(type) {
|
|
|
10423
10632
|
}
|
|
10424
10633
|
}
|
|
10425
10634
|
});
|
|
10426
|
-
if (
|
|
10635
|
+
if (p36.isCancel(email2)) onCancel();
|
|
10427
10636
|
details.email = email2;
|
|
10428
10637
|
}
|
|
10429
10638
|
if (contact.includes("page")) {
|
|
10430
|
-
const page = await
|
|
10639
|
+
const page = await p36.text({
|
|
10431
10640
|
message: "What's the link?",
|
|
10432
10641
|
placeholder: "http://www.mycompany.com/contact",
|
|
10433
10642
|
validate: (value) => {
|
|
@@ -10436,11 +10645,11 @@ async function contactMethods(type) {
|
|
|
10436
10645
|
}
|
|
10437
10646
|
}
|
|
10438
10647
|
});
|
|
10439
|
-
if (
|
|
10648
|
+
if (p36.isCancel(page)) onCancel();
|
|
10440
10649
|
details.page = page;
|
|
10441
10650
|
}
|
|
10442
10651
|
if (contact.includes("phone")) {
|
|
10443
|
-
const phone = await
|
|
10652
|
+
const phone = await p36.text({
|
|
10444
10653
|
message: "What's the phone number?",
|
|
10445
10654
|
placeholder: "408.996.1010",
|
|
10446
10655
|
validate: (value) => {
|
|
@@ -10449,11 +10658,11 @@ async function contactMethods(type) {
|
|
|
10449
10658
|
}
|
|
10450
10659
|
}
|
|
10451
10660
|
});
|
|
10452
|
-
if (
|
|
10661
|
+
if (p36.isCancel(phone)) onCancel();
|
|
10453
10662
|
details.phone = phone;
|
|
10454
10663
|
}
|
|
10455
10664
|
if (contact.includes("mail")) {
|
|
10456
|
-
const address = await
|
|
10665
|
+
const address = await p36.text({
|
|
10457
10666
|
message: "What's the address?",
|
|
10458
10667
|
placeholder: "767 Fifth Avenue New York, NY 10153, United States",
|
|
10459
10668
|
validate: (value) => {
|
|
@@ -10462,7 +10671,7 @@ async function contactMethods(type) {
|
|
|
10462
10671
|
}
|
|
10463
10672
|
}
|
|
10464
10673
|
});
|
|
10465
|
-
if (
|
|
10674
|
+
if (p36.isCancel(address)) onCancel();
|
|
10466
10675
|
details.address = address;
|
|
10467
10676
|
}
|
|
10468
10677
|
return { methods: contact, details };
|
|
@@ -10883,7 +11092,7 @@ var generateTermsHtml = (answers) => {
|
|
|
10883
11092
|
async function termsAction() {
|
|
10884
11093
|
const { workspaceRootDir, publicRoutesDir } = await getWorkspace();
|
|
10885
11094
|
const site = siteFields(await readSite(workspaceRootDir));
|
|
10886
|
-
const core = await
|
|
11095
|
+
const core = await p37.group(
|
|
10887
11096
|
{
|
|
10888
11097
|
websiteUrl: site.websiteUrl,
|
|
10889
11098
|
websiteName: site.websiteName,
|
|
@@ -10895,25 +11104,25 @@ async function termsAction() {
|
|
|
10895
11104
|
},
|
|
10896
11105
|
{ onCancel }
|
|
10897
11106
|
);
|
|
10898
|
-
const accounts = await
|
|
11107
|
+
const accounts = await p37.select({
|
|
10899
11108
|
message: "Can users create accounts?",
|
|
10900
11109
|
options: [
|
|
10901
11110
|
{ value: "yes", label: "Yes, users can create accounts" },
|
|
10902
11111
|
{ value: "no", label: "No" }
|
|
10903
11112
|
]
|
|
10904
11113
|
});
|
|
10905
|
-
if (
|
|
10906
|
-
const userContent = await
|
|
11114
|
+
if (p37.isCancel(accounts)) onCancel();
|
|
11115
|
+
const userContent = await p37.select({
|
|
10907
11116
|
message: "Can users create and/or upload content (ie. text, images)?",
|
|
10908
11117
|
options: [
|
|
10909
11118
|
{ value: "yes", label: "Yes, users can create and/or upload content" },
|
|
10910
11119
|
{ value: "no", label: "No" }
|
|
10911
11120
|
]
|
|
10912
11121
|
});
|
|
10913
|
-
if (
|
|
11122
|
+
if (p37.isCancel(userContent)) onCancel();
|
|
10914
11123
|
let infringementEmail;
|
|
10915
11124
|
if (userContent === "yes") {
|
|
10916
|
-
const email2 = await
|
|
11125
|
+
const email2 = await p37.text({
|
|
10917
11126
|
message: "What's the email address where you will receive infringements notices?",
|
|
10918
11127
|
placeholder: "dmca@website.com",
|
|
10919
11128
|
validate: (value) => {
|
|
@@ -10922,10 +11131,10 @@ async function termsAction() {
|
|
|
10922
11131
|
}
|
|
10923
11132
|
}
|
|
10924
11133
|
});
|
|
10925
|
-
if (
|
|
11134
|
+
if (p37.isCancel(email2)) onCancel();
|
|
10926
11135
|
infringementEmail = email2;
|
|
10927
11136
|
}
|
|
10928
|
-
const canBuyGoods = await
|
|
11137
|
+
const canBuyGoods = await p37.select({
|
|
10929
11138
|
message: "Can users buy goods (products, items)?",
|
|
10930
11139
|
options: [
|
|
10931
11140
|
{
|
|
@@ -10935,28 +11144,28 @@ async function termsAction() {
|
|
|
10935
11144
|
{ value: "no", label: "No" }
|
|
10936
11145
|
]
|
|
10937
11146
|
});
|
|
10938
|
-
if (
|
|
10939
|
-
const subscriptions3 = await
|
|
11147
|
+
if (p37.isCancel(canBuyGoods)) onCancel();
|
|
11148
|
+
const subscriptions3 = await p37.select({
|
|
10940
11149
|
message: "Do you offer subscription plans?",
|
|
10941
11150
|
options: [
|
|
10942
11151
|
{ value: "yes", label: "Yes, we offer subscription plans" },
|
|
10943
11152
|
{ value: "no", label: "No" }
|
|
10944
11153
|
]
|
|
10945
11154
|
});
|
|
10946
|
-
if (
|
|
11155
|
+
if (p37.isCancel(subscriptions3)) onCancel();
|
|
10947
11156
|
let freeTrial;
|
|
10948
11157
|
if (subscriptions3 === "yes") {
|
|
10949
|
-
const ft = await
|
|
11158
|
+
const ft = await p37.select({
|
|
10950
11159
|
message: "Do you offer a free trial?",
|
|
10951
11160
|
options: [
|
|
10952
11161
|
{ value: "yes", label: "Yes" },
|
|
10953
11162
|
{ value: "no", label: "No" }
|
|
10954
11163
|
]
|
|
10955
11164
|
});
|
|
10956
|
-
if (
|
|
11165
|
+
if (p37.isCancel(ft)) onCancel();
|
|
10957
11166
|
freeTrial = ft;
|
|
10958
11167
|
}
|
|
10959
|
-
const exclusiveContent = await
|
|
11168
|
+
const exclusiveContent = await p37.select({
|
|
10960
11169
|
message: "Do you want to make it clear that your own content & trademarks are your exclusive property?",
|
|
10961
11170
|
options: [
|
|
10962
11171
|
{
|
|
@@ -10966,24 +11175,24 @@ async function termsAction() {
|
|
|
10966
11175
|
{ value: "no", label: "No" }
|
|
10967
11176
|
]
|
|
10968
11177
|
});
|
|
10969
|
-
if (
|
|
10970
|
-
const feedbackReuse = await
|
|
11178
|
+
if (p37.isCancel(exclusiveContent)) onCancel();
|
|
11179
|
+
const feedbackReuse = await p37.select({
|
|
10971
11180
|
message: "If users provide you feedback & suggestions, do you want to use this feedback without compensation or credits given?",
|
|
10972
11181
|
options: [
|
|
10973
11182
|
{ value: "yes", label: "Yes, we may implement any feedback or suggestions we receive" },
|
|
10974
11183
|
{ value: "no", label: "No" }
|
|
10975
11184
|
]
|
|
10976
11185
|
});
|
|
10977
|
-
if (
|
|
10978
|
-
const promotions = await
|
|
11186
|
+
if (p37.isCancel(feedbackReuse)) onCancel();
|
|
11187
|
+
const promotions = await p37.select({
|
|
10979
11188
|
message: "Do you plan to offer promotions, contests, sweepstakes?",
|
|
10980
11189
|
options: [
|
|
10981
11190
|
{ value: "yes", label: "Yes, we may offer promotions, contests, sweepstakes" },
|
|
10982
11191
|
{ value: "no", label: "No" }
|
|
10983
11192
|
]
|
|
10984
11193
|
});
|
|
10985
|
-
if (
|
|
10986
|
-
const mobileAppRaw = await
|
|
11194
|
+
if (p37.isCancel(promotions)) onCancel();
|
|
11195
|
+
const mobileAppRaw = await p37.multiselect({
|
|
10987
11196
|
message: "Is the Service distributed through any mobile app stores? Check all that apply",
|
|
10988
11197
|
options: [
|
|
10989
11198
|
{ value: "apple", label: "Apple App Store" },
|
|
@@ -10991,7 +11200,7 @@ async function termsAction() {
|
|
|
10991
11200
|
],
|
|
10992
11201
|
required: false
|
|
10993
11202
|
});
|
|
10994
|
-
if (
|
|
11203
|
+
if (p37.isCancel(mobileAppRaw)) onCancel();
|
|
10995
11204
|
const mobileApp = mobileAppRaw ?? [];
|
|
10996
11205
|
const contact = await contactMethods("terms");
|
|
10997
11206
|
const html = generateTermsHtml({
|
|
@@ -11027,12 +11236,12 @@ async function termsAction() {
|
|
|
11027
11236
|
]
|
|
11028
11237
|
});
|
|
11029
11238
|
}
|
|
11030
|
-
var terms = new
|
|
11239
|
+
var terms = new Command60("terms").description("generate placeholder terms and conditions").configureHelp(helpConfig).action(() => runCommand(termsAction, "Failed to generate terms and conditions."));
|
|
11031
11240
|
|
|
11032
11241
|
// src/commands/legal/privacy.ts
|
|
11033
11242
|
import path42 from "node:path";
|
|
11034
|
-
import { Command as
|
|
11035
|
-
import * as
|
|
11243
|
+
import { Command as Command61 } from "commander";
|
|
11244
|
+
import * as p38 from "@clack/prompts";
|
|
11036
11245
|
var mapLabels = {
|
|
11037
11246
|
personalInfo: {
|
|
11038
11247
|
email: "Email address",
|
|
@@ -11450,12 +11659,12 @@ var generatePrivacyHtml = (answers) => {
|
|
|
11450
11659
|
return `<section data-role="content">${sections.join("")}</section>`;
|
|
11451
11660
|
};
|
|
11452
11661
|
async function promptWithCustom(message, options, customMessage) {
|
|
11453
|
-
const selection = await
|
|
11454
|
-
if (
|
|
11662
|
+
const selection = await p38.multiselect({ message, options });
|
|
11663
|
+
if (p38.isCancel(selection)) onCancel();
|
|
11455
11664
|
const values = selection;
|
|
11456
11665
|
if (values.includes("custom")) {
|
|
11457
|
-
const custom = await
|
|
11458
|
-
if (
|
|
11666
|
+
const custom = await p38.text({ message: customMessage });
|
|
11667
|
+
if (p38.isCancel(custom)) onCancel();
|
|
11459
11668
|
const idx = values.indexOf("custom");
|
|
11460
11669
|
if (idx !== -1) values.splice(idx, 1);
|
|
11461
11670
|
if (custom) values.push(String(custom));
|
|
@@ -11465,7 +11674,7 @@ async function promptWithCustom(message, options, customMessage) {
|
|
|
11465
11674
|
async function privacyAction() {
|
|
11466
11675
|
const { workspaceRootDir, publicRoutesDir } = await getWorkspace();
|
|
11467
11676
|
const site = siteFields(await readSite(workspaceRootDir));
|
|
11468
|
-
const core = await
|
|
11677
|
+
const core = await p38.group(
|
|
11469
11678
|
{
|
|
11470
11679
|
websiteUrl: site.websiteUrl,
|
|
11471
11680
|
websiteName: site.websiteName,
|
|
@@ -11477,7 +11686,7 @@ async function privacyAction() {
|
|
|
11477
11686
|
},
|
|
11478
11687
|
{ onCancel }
|
|
11479
11688
|
);
|
|
11480
|
-
const personalInfo = await
|
|
11689
|
+
const personalInfo = await p38.multiselect({
|
|
11481
11690
|
message: "What kind of personal information do you collect from users? Check all that apply",
|
|
11482
11691
|
options: [
|
|
11483
11692
|
{ value: "email", label: "Email address" },
|
|
@@ -11492,16 +11701,16 @@ async function privacyAction() {
|
|
|
11492
11701
|
],
|
|
11493
11702
|
required: false
|
|
11494
11703
|
});
|
|
11495
|
-
if (
|
|
11704
|
+
if (p38.isCancel(personalInfo)) onCancel();
|
|
11496
11705
|
const contact = await contactMethods("privacy");
|
|
11497
|
-
const tracking = await
|
|
11706
|
+
const tracking = await p38.select({
|
|
11498
11707
|
message: "Do you use tracking and/or analytics tools, such as Google Analytics?",
|
|
11499
11708
|
options: [
|
|
11500
11709
|
{ value: "yes", label: "Yes, we use Google Analytics or other related tools" },
|
|
11501
11710
|
{ value: "no", label: "No" }
|
|
11502
11711
|
]
|
|
11503
11712
|
});
|
|
11504
|
-
if (
|
|
11713
|
+
if (p38.isCancel(tracking)) onCancel();
|
|
11505
11714
|
let trackingTools;
|
|
11506
11715
|
if (tracking === "yes") {
|
|
11507
11716
|
trackingTools = await promptWithCustom(
|
|
@@ -11520,7 +11729,7 @@ async function privacyAction() {
|
|
|
11520
11729
|
"Enter your custom tracking/analytics tool name"
|
|
11521
11730
|
);
|
|
11522
11731
|
}
|
|
11523
|
-
const sendEmails = await
|
|
11732
|
+
const sendEmails = await p38.select({
|
|
11524
11733
|
message: "Do you send emails to users?",
|
|
11525
11734
|
options: [
|
|
11526
11735
|
{
|
|
@@ -11530,7 +11739,7 @@ async function privacyAction() {
|
|
|
11530
11739
|
{ value: "no", label: "No" }
|
|
11531
11740
|
]
|
|
11532
11741
|
});
|
|
11533
|
-
if (
|
|
11742
|
+
if (p38.isCancel(sendEmails)) onCancel();
|
|
11534
11743
|
let emailPlatforms;
|
|
11535
11744
|
if (sendEmails === "yes") {
|
|
11536
11745
|
emailPlatforms = await promptWithCustom(
|
|
@@ -11545,14 +11754,14 @@ async function privacyAction() {
|
|
|
11545
11754
|
"Enter your custom email platform"
|
|
11546
11755
|
);
|
|
11547
11756
|
}
|
|
11548
|
-
const showAds = await
|
|
11757
|
+
const showAds = await p38.select({
|
|
11549
11758
|
message: "Do you show ads?",
|
|
11550
11759
|
options: [
|
|
11551
11760
|
{ value: "yes", label: "Yes, we show ads" },
|
|
11552
11761
|
{ value: "no", label: "No" }
|
|
11553
11762
|
]
|
|
11554
11763
|
});
|
|
11555
|
-
if (
|
|
11764
|
+
if (p38.isCancel(showAds)) onCancel();
|
|
11556
11765
|
let adsPlatforms;
|
|
11557
11766
|
if (showAds === "yes") {
|
|
11558
11767
|
adsPlatforms = await promptWithCustom(
|
|
@@ -11575,7 +11784,7 @@ async function privacyAction() {
|
|
|
11575
11784
|
"Enter your custom ads platform"
|
|
11576
11785
|
);
|
|
11577
11786
|
}
|
|
11578
|
-
const canPay = await
|
|
11787
|
+
const canPay = await p38.select({
|
|
11579
11788
|
message: "Can users pay for products or services?",
|
|
11580
11789
|
options: [
|
|
11581
11790
|
{ value: "yes", label: "Yes, users can pay for our products/services" },
|
|
@@ -11585,7 +11794,7 @@ async function privacyAction() {
|
|
|
11585
11794
|
}
|
|
11586
11795
|
]
|
|
11587
11796
|
});
|
|
11588
|
-
if (
|
|
11797
|
+
if (p38.isCancel(canPay)) onCancel();
|
|
11589
11798
|
let paymentProcessors;
|
|
11590
11799
|
if (canPay === "yes") {
|
|
11591
11800
|
paymentProcessors = await promptWithCustom(
|
|
@@ -11616,14 +11825,14 @@ async function privacyAction() {
|
|
|
11616
11825
|
"Enter your custom payment processor/method"
|
|
11617
11826
|
);
|
|
11618
11827
|
}
|
|
11619
|
-
const remarketing = await
|
|
11828
|
+
const remarketing = await p38.select({
|
|
11620
11829
|
message: "Do you use remarketing services for marketing & advertising purposes?",
|
|
11621
11830
|
options: [
|
|
11622
11831
|
{ value: "yes", label: "Yes, we use remarketing services to advertise our business" },
|
|
11623
11832
|
{ value: "no", label: "No" }
|
|
11624
11833
|
]
|
|
11625
11834
|
});
|
|
11626
|
-
if (
|
|
11835
|
+
if (p38.isCancel(remarketing)) onCancel();
|
|
11627
11836
|
let remarketingPlatforms;
|
|
11628
11837
|
if (remarketing === "yes") {
|
|
11629
11838
|
remarketingPlatforms = await promptWithCustom(
|
|
@@ -11642,7 +11851,7 @@ async function privacyAction() {
|
|
|
11642
11851
|
"Enter your custom remarketing platform"
|
|
11643
11852
|
);
|
|
11644
11853
|
}
|
|
11645
|
-
const providersRaw = await
|
|
11854
|
+
const providersRaw = await p38.multiselect({
|
|
11646
11855
|
message: "Select if you use any of the following providers",
|
|
11647
11856
|
options: [
|
|
11648
11857
|
{ value: "recaptcha", label: "Invisible reCAPTCHA" },
|
|
@@ -11653,16 +11862,16 @@ async function privacyAction() {
|
|
|
11653
11862
|
],
|
|
11654
11863
|
required: false
|
|
11655
11864
|
});
|
|
11656
|
-
if (
|
|
11865
|
+
if (p38.isCancel(providersRaw)) onCancel();
|
|
11657
11866
|
const providers = providersRaw;
|
|
11658
11867
|
if (providers.includes("custom")) {
|
|
11659
|
-
const custom = await
|
|
11660
|
-
if (
|
|
11868
|
+
const custom = await p38.text({ message: "Enter your custom provider" });
|
|
11869
|
+
if (p38.isCancel(custom)) onCancel();
|
|
11661
11870
|
const idx = providers.indexOf("custom");
|
|
11662
11871
|
if (idx !== -1) providers.splice(idx, 1);
|
|
11663
11872
|
if (custom) providers.push(String(custom));
|
|
11664
11873
|
}
|
|
11665
|
-
const usStates = await
|
|
11874
|
+
const usStates = await p38.select({
|
|
11666
11875
|
message: "Include U.S. state privacy rights (CCPA/CPRA, VCDPA, CPA, CTDPA, UCPA, TX, OR, etc.)?",
|
|
11667
11876
|
options: [
|
|
11668
11877
|
{
|
|
@@ -11673,55 +11882,55 @@ async function privacyAction() {
|
|
|
11673
11882
|
],
|
|
11674
11883
|
initialValue: "yes"
|
|
11675
11884
|
});
|
|
11676
|
-
if (
|
|
11677
|
-
const gdpr = await
|
|
11885
|
+
if (p38.isCancel(usStates)) onCancel();
|
|
11886
|
+
const gdpr = await p38.select({
|
|
11678
11887
|
message: "Do you want your Privacy Policy to include GDPR / UK GDPR wording?",
|
|
11679
11888
|
options: [
|
|
11680
11889
|
{ value: "yes", label: "Yes. Include GDPR rights for EEA, UK, and Swiss residents" },
|
|
11681
11890
|
{ value: "no", label: "No" }
|
|
11682
11891
|
]
|
|
11683
11892
|
});
|
|
11684
|
-
if (
|
|
11893
|
+
if (p38.isCancel(gdpr)) onCancel();
|
|
11685
11894
|
let facebookFanPage = "no";
|
|
11686
11895
|
const facebookDetails = { name: "", url: "" };
|
|
11687
11896
|
if (gdpr === "yes") {
|
|
11688
|
-
const fan = await
|
|
11897
|
+
const fan = await p38.select({
|
|
11689
11898
|
message: "Do you have a Facebook Fan Page?",
|
|
11690
11899
|
options: [
|
|
11691
11900
|
{ value: "yes", label: "Yes, we have a Facebook Fan Page" },
|
|
11692
11901
|
{ value: "no", label: "No" }
|
|
11693
11902
|
]
|
|
11694
11903
|
});
|
|
11695
|
-
if (
|
|
11904
|
+
if (p38.isCancel(fan)) onCancel();
|
|
11696
11905
|
facebookFanPage = fan;
|
|
11697
11906
|
if (facebookFanPage === "yes") {
|
|
11698
|
-
const name = await
|
|
11907
|
+
const name = await p38.text({
|
|
11699
11908
|
message: "What is the name of the Facebook Fan Page?",
|
|
11700
11909
|
placeholder: "My Facebook Page"
|
|
11701
11910
|
});
|
|
11702
|
-
if (
|
|
11911
|
+
if (p38.isCancel(name)) onCancel();
|
|
11703
11912
|
facebookDetails.name = name;
|
|
11704
|
-
const url = await
|
|
11913
|
+
const url = await p38.text({
|
|
11705
11914
|
message: "What is the URL of the Facebook Fan Page?",
|
|
11706
11915
|
placeholder: "https://facebook.com/my-facebook-page"
|
|
11707
11916
|
});
|
|
11708
|
-
if (
|
|
11917
|
+
if (p38.isCancel(url)) onCancel();
|
|
11709
11918
|
facebookDetails.url = url;
|
|
11710
11919
|
}
|
|
11711
11920
|
}
|
|
11712
|
-
const kids = await
|
|
11921
|
+
const kids = await p38.select({
|
|
11713
11922
|
message: "Do you collect information from kids under the age of 13?",
|
|
11714
11923
|
options: [
|
|
11715
11924
|
{ value: "yes", label: "Yes. We collect information from children under the age of 13" },
|
|
11716
11925
|
{ value: "no", label: "No" }
|
|
11717
11926
|
]
|
|
11718
11927
|
});
|
|
11719
|
-
if (
|
|
11720
|
-
const retention = await
|
|
11928
|
+
if (p38.isCancel(kids)) onCancel();
|
|
11929
|
+
const retention = await p38.text({
|
|
11721
11930
|
message: "How long do you retain personal information? (leave blank for default wording)",
|
|
11722
11931
|
placeholder: "e.g. 12 months after account closure"
|
|
11723
11932
|
});
|
|
11724
|
-
if (
|
|
11933
|
+
if (p38.isCancel(retention)) onCancel();
|
|
11725
11934
|
const html = generatePrivacyHtml({
|
|
11726
11935
|
core,
|
|
11727
11936
|
personalInfo: personalInfo ?? [],
|
|
@@ -11763,16 +11972,16 @@ async function privacyAction() {
|
|
|
11763
11972
|
]
|
|
11764
11973
|
});
|
|
11765
11974
|
}
|
|
11766
|
-
var privacy = new
|
|
11975
|
+
var privacy = new Command61("privacy").description("generate placeholder privacy policy").configureHelp(helpConfig).action(() => runCommand(privacyAction, "Failed to generate privacy policy."));
|
|
11767
11976
|
|
|
11768
11977
|
// src/commands/legal.ts
|
|
11769
|
-
var legal = new
|
|
11978
|
+
var legal = new Command62("legal").description("generate placeholder legal documents").configureHelp(helpConfig).addCommand(terms).addCommand(privacy);
|
|
11770
11979
|
|
|
11771
11980
|
// src/commands/fixtures.ts
|
|
11772
|
-
import { Command as
|
|
11981
|
+
import { Command as Command68 } from "commander";
|
|
11773
11982
|
|
|
11774
11983
|
// src/commands/fixtures/load.ts
|
|
11775
|
-
import { Command as
|
|
11984
|
+
import { Command as Command63 } from "commander";
|
|
11776
11985
|
|
|
11777
11986
|
// src/lib/data.ts
|
|
11778
11987
|
import fs42 from "node:fs";
|
|
@@ -11962,7 +12171,7 @@ async function hasLoadedFixtures(pb) {
|
|
|
11962
12171
|
}
|
|
11963
12172
|
|
|
11964
12173
|
// src/commands/fixtures/load.ts
|
|
11965
|
-
var load = new
|
|
12174
|
+
var load = new Command63("load").description("load fixtures into the database").configureHelp(helpConfig).action(
|
|
11966
12175
|
() => runCommand(async () => {
|
|
11967
12176
|
const { workspaceRootDir } = await getWorkspace();
|
|
11968
12177
|
let loaded = [];
|
|
@@ -11988,8 +12197,8 @@ var load = new Command61("load").description("load fixtures into the database").
|
|
|
11988
12197
|
);
|
|
11989
12198
|
|
|
11990
12199
|
// src/commands/fixtures/clear.ts
|
|
11991
|
-
import { Command as
|
|
11992
|
-
var clear = new
|
|
12200
|
+
import { Command as Command64 } from "commander";
|
|
12201
|
+
var clear = new Command64("clear").description("clear loaded fixtures").configureHelp(helpConfig).action(
|
|
11993
12202
|
() => runCommand(async () => {
|
|
11994
12203
|
const { workspaceRootDir } = await getWorkspace();
|
|
11995
12204
|
let cleared = [];
|
|
@@ -12018,8 +12227,8 @@ var clear = new Command62("clear").description("clear loaded fixtures").configur
|
|
|
12018
12227
|
);
|
|
12019
12228
|
|
|
12020
12229
|
// src/commands/fixtures/reset.ts
|
|
12021
|
-
import { Command as
|
|
12022
|
-
var reset = new
|
|
12230
|
+
import { Command as Command65 } from "commander";
|
|
12231
|
+
var reset = new Command65("reset").description("clear and reload fixtures").configureHelp(helpConfig).action(
|
|
12023
12232
|
() => runCommand(async () => {
|
|
12024
12233
|
const { workspaceRootDir } = await getWorkspace();
|
|
12025
12234
|
let cleared = [];
|
|
@@ -12051,8 +12260,8 @@ var reset = new Command63("reset").description("clear and reload fixtures").conf
|
|
|
12051
12260
|
// src/commands/fixtures/generate.ts
|
|
12052
12261
|
import fs43 from "node:fs";
|
|
12053
12262
|
import path44 from "node:path";
|
|
12054
|
-
import { Command as
|
|
12055
|
-
import * as
|
|
12263
|
+
import { Command as Command66, InvalidArgumentError } from "commander";
|
|
12264
|
+
import * as p39 from "@clack/prompts";
|
|
12056
12265
|
import { annotate } from "annotate-json-schema";
|
|
12057
12266
|
import { createGenerator } from "json-schema-faker";
|
|
12058
12267
|
import { faker } from "@faker-js/faker";
|
|
@@ -12162,7 +12371,7 @@ async function generateFixtureFiles(pb, workspaceRootDir, opts) {
|
|
|
12162
12371
|
}
|
|
12163
12372
|
return { writtenFiles, warnings };
|
|
12164
12373
|
}
|
|
12165
|
-
var generate2 = new
|
|
12374
|
+
var generate2 = new Command66("generate").description("generate fixture data").option("-c, --count <count>", "number of records per collection", parseCount, 10).option("-s, --seed <seed>", "seed for deterministic output", parseSeed).option("-f, --force", "overwrite existing fixture files and clear loaded fixtures").configureHelp(helpConfig).action(
|
|
12166
12375
|
(opts) => runCommand(async () => {
|
|
12167
12376
|
const { workspaceRootDir } = await getWorkspace();
|
|
12168
12377
|
const existing = getFixtureFiles(workspaceRootDir);
|
|
@@ -12191,7 +12400,7 @@ var generate2 = new Command64("generate").description("generate fixture data").o
|
|
|
12191
12400
|
seed: opts.seed
|
|
12192
12401
|
});
|
|
12193
12402
|
});
|
|
12194
|
-
for (const warning of result.warnings)
|
|
12403
|
+
for (const warning of result.warnings) p39.log.warn(warning);
|
|
12195
12404
|
if (result.writtenFiles.length === 0) {
|
|
12196
12405
|
reportResult({
|
|
12197
12406
|
summary: "No eligible collections found to generate fixtures for.",
|
|
@@ -12215,8 +12424,8 @@ var generate2 = new Command64("generate").description("generate fixture data").o
|
|
|
12215
12424
|
);
|
|
12216
12425
|
|
|
12217
12426
|
// src/commands/fixtures/regen.ts
|
|
12218
|
-
import { Command as
|
|
12219
|
-
import * as
|
|
12427
|
+
import { Command as Command67, InvalidArgumentError as InvalidArgumentError2 } from "commander";
|
|
12428
|
+
import * as p40 from "@clack/prompts";
|
|
12220
12429
|
function parseCount2(value) {
|
|
12221
12430
|
const n = parseInt(value, 10);
|
|
12222
12431
|
if (!Number.isFinite(n) || n <= 0 || n > 999) {
|
|
@@ -12231,7 +12440,7 @@ function parseSeed2(value) {
|
|
|
12231
12440
|
}
|
|
12232
12441
|
return n;
|
|
12233
12442
|
}
|
|
12234
|
-
var regen = new
|
|
12443
|
+
var regen = new Command67("regen").description("clear the database, regenerate fixture files, and reload them").option("-c, --count <count>", "number of records per collection", parseCount2, 10).option("-s, --seed <seed>", "seed for deterministic output", parseSeed2).configureHelp(helpConfig).action(
|
|
12235
12444
|
(opts) => runCommand(async () => {
|
|
12236
12445
|
const { workspaceRootDir } = await getWorkspace();
|
|
12237
12446
|
let cleared = [];
|
|
@@ -12245,7 +12454,7 @@ var regen = new Command65("regen").description("clear the database, regenerate f
|
|
|
12245
12454
|
});
|
|
12246
12455
|
loaded = await loadFixtures(pb, workspaceRootDir);
|
|
12247
12456
|
});
|
|
12248
|
-
for (const warning of result.warnings)
|
|
12457
|
+
for (const warning of result.warnings) p40.log.warn(warning);
|
|
12249
12458
|
reportResult({
|
|
12250
12459
|
summary: `Regenerated fixtures (${loaded.length} collection(s) reloaded).`,
|
|
12251
12460
|
filesCreated: result.writtenFiles,
|
|
@@ -12260,14 +12469,14 @@ var regen = new Command65("regen").description("clear the database, regenerate f
|
|
|
12260
12469
|
);
|
|
12261
12470
|
|
|
12262
12471
|
// src/commands/fixtures.ts
|
|
12263
|
-
var fixtures = new
|
|
12472
|
+
var fixtures = new Command68("fixtures").description("manage fixture data").configureHelp(helpConfig).addCommand(generate2).addCommand(load).addCommand(clear).addCommand(reset).addCommand(regen);
|
|
12264
12473
|
|
|
12265
12474
|
// src/commands/seeds.ts
|
|
12266
|
-
import { Command as
|
|
12475
|
+
import { Command as Command72 } from "commander";
|
|
12267
12476
|
|
|
12268
12477
|
// src/commands/seeds/load.ts
|
|
12269
|
-
import { Command as
|
|
12270
|
-
var load2 = new
|
|
12478
|
+
import { Command as Command69 } from "commander";
|
|
12479
|
+
var load2 = new Command69("load").description("load seeds into the database").option("-f, --force", "load even if target collections already have records").configureHelp(helpConfig).action(
|
|
12271
12480
|
(opts) => runCommand(async () => {
|
|
12272
12481
|
const { workspaceRootDir } = await getWorkspace();
|
|
12273
12482
|
const seedFiles = getSeedFiles(workspaceRootDir);
|
|
@@ -12306,7 +12515,7 @@ var load2 = new Command67("load").description("load seeds into the database").op
|
|
|
12306
12515
|
// src/commands/seeds/save.ts
|
|
12307
12516
|
import fs44 from "node:fs";
|
|
12308
12517
|
import path45 from "node:path";
|
|
12309
|
-
import { Command as
|
|
12518
|
+
import { Command as Command70 } from "commander";
|
|
12310
12519
|
var padZeros2 = (num, length) => num.toString().padStart(length, "0");
|
|
12311
12520
|
function filterSystemFields(record, systemFieldNames) {
|
|
12312
12521
|
const out = {};
|
|
@@ -12317,7 +12526,7 @@ function filterSystemFields(record, systemFieldNames) {
|
|
|
12317
12526
|
}
|
|
12318
12527
|
return out;
|
|
12319
12528
|
}
|
|
12320
|
-
var save = new
|
|
12529
|
+
var save = new Command70("save").description("save the current data as seeds").option("-f, --force", "overwrite existing seed files").configureHelp(helpConfig).action(
|
|
12321
12530
|
(opts) => runCommand(async () => {
|
|
12322
12531
|
const { workspaceRootDir } = await getWorkspace();
|
|
12323
12532
|
const seedsPath = dataDir(workspaceRootDir, "seeds");
|
|
@@ -12389,8 +12598,8 @@ var save = new Command68("save").description("save the current data as seeds").o
|
|
|
12389
12598
|
);
|
|
12390
12599
|
|
|
12391
12600
|
// src/commands/seeds/clear.ts
|
|
12392
|
-
import { Command as
|
|
12393
|
-
var clear2 = new
|
|
12601
|
+
import { Command as Command71 } from "commander";
|
|
12602
|
+
var clear2 = new Command71("clear").description("clear seeded records").configureHelp(helpConfig).action(
|
|
12394
12603
|
() => runCommand(async () => {
|
|
12395
12604
|
const { workspaceRootDir } = await getWorkspace();
|
|
12396
12605
|
const seedFiles = getSeedFiles(workspaceRootDir);
|
|
@@ -12421,84 +12630,93 @@ var clear2 = new Command69("clear").description("clear seeded records").configur
|
|
|
12421
12630
|
);
|
|
12422
12631
|
|
|
12423
12632
|
// src/commands/seeds.ts
|
|
12424
|
-
var seeds = new
|
|
12633
|
+
var seeds = new Command72("seeds").description("manage seed data").configureHelp(helpConfig).addCommand(load2).addCommand(save).addCommand(clear2);
|
|
12425
12634
|
|
|
12426
12635
|
// src/commands/signup.ts
|
|
12427
|
-
import { Command as
|
|
12428
|
-
import * as
|
|
12636
|
+
import { Command as Command73 } from "commander";
|
|
12637
|
+
import * as p41 from "@clack/prompts";
|
|
12429
12638
|
import makeFetchCookie2 from "fetch-cookie";
|
|
12430
|
-
var signup = new
|
|
12639
|
+
var signup = new Command73("signup").description("signup to velastack.dev").configureHelp(helpConfig).action(
|
|
12431
12640
|
() => runCommand(async () => {
|
|
12432
|
-
const
|
|
12433
|
-
email: () => p40.text({ message: "Email" }),
|
|
12434
|
-
password: () => p40.password({ message: "Password" }),
|
|
12435
|
-
passwordConfirm: () => p40.password({ message: "Confirm password" })
|
|
12436
|
-
});
|
|
12437
|
-
if (password8 !== passwordConfirm) {
|
|
12438
|
-
throw new Error("Passwords do not match.");
|
|
12439
|
-
}
|
|
12641
|
+
const method = await chooseAuthMethod("signup", await fetchAuthMethods());
|
|
12440
12642
|
const fetchCookie = makeFetchCookie2(fetch);
|
|
12441
|
-
|
|
12442
|
-
|
|
12443
|
-
|
|
12444
|
-
|
|
12445
|
-
|
|
12446
|
-
},
|
|
12447
|
-
body: new URLSearchParams({
|
|
12448
|
-
type: "password",
|
|
12449
|
-
email: email2,
|
|
12450
|
-
password: password8,
|
|
12451
|
-
passwordConfirm
|
|
12452
|
-
}).toString()
|
|
12453
|
-
});
|
|
12454
|
-
if (!res.headers.get("Set-Cookie")) {
|
|
12455
|
-
throw new Error("Failed to signup. Try again or contact support.");
|
|
12643
|
+
let isNew = true;
|
|
12644
|
+
if (method === "whatsapp") {
|
|
12645
|
+
({ isNew } = await signInWithWhatsApp(fetchCookie, "signup"));
|
|
12646
|
+
} else {
|
|
12647
|
+
await signupWithPassword(fetchCookie);
|
|
12456
12648
|
}
|
|
12457
12649
|
const apiKey = await issueApiKey(fetchCookie);
|
|
12458
12650
|
writeConfig({ apiKey });
|
|
12459
|
-
|
|
12460
|
-
|
|
12651
|
+
p41.log.success(isNew ? "Signed up to velastack.dev" : "Logged in to velastack.dev");
|
|
12652
|
+
if (method === "password") {
|
|
12653
|
+
p41.log.info("Check your email for a confirmation link.");
|
|
12654
|
+
}
|
|
12461
12655
|
}, "Failed to signup.")
|
|
12462
12656
|
);
|
|
12657
|
+
async function signupWithPassword(fetchCookie) {
|
|
12658
|
+
const { email: email2, password: password8, passwordConfirm } = await p41.group(
|
|
12659
|
+
{
|
|
12660
|
+
email: () => p41.text({ message: "Email" }),
|
|
12661
|
+
password: () => p41.password({ message: "Password" }),
|
|
12662
|
+
passwordConfirm: () => p41.password({ message: "Confirm password" })
|
|
12663
|
+
},
|
|
12664
|
+
{ onCancel: cancelled }
|
|
12665
|
+
);
|
|
12666
|
+
if (password8 !== passwordConfirm) {
|
|
12667
|
+
throw new Error("Passwords do not match.");
|
|
12668
|
+
}
|
|
12669
|
+
const result = await postForm(fetchCookie, "/signup", {
|
|
12670
|
+
type: "password",
|
|
12671
|
+
email: email2,
|
|
12672
|
+
password: password8,
|
|
12673
|
+
passwordConfirm
|
|
12674
|
+
});
|
|
12675
|
+
if (result.type !== "redirect") {
|
|
12676
|
+
throw new Error(failureText(result, "Could not create the account."));
|
|
12677
|
+
}
|
|
12678
|
+
}
|
|
12463
12679
|
|
|
12464
12680
|
// src/commands/logout.ts
|
|
12465
|
-
import { Command as
|
|
12466
|
-
import * as
|
|
12467
|
-
var logout = new
|
|
12681
|
+
import { Command as Command74 } from "commander";
|
|
12682
|
+
import * as p42 from "@clack/prompts";
|
|
12683
|
+
var logout = new Command74("logout").alias("signout").description("logout from velastack.dev").configureHelp(helpConfig).action(
|
|
12468
12684
|
() => runCommand(() => {
|
|
12469
12685
|
if (!readConfig()) {
|
|
12470
|
-
|
|
12686
|
+
p42.log.info("Not logged in");
|
|
12471
12687
|
return;
|
|
12472
12688
|
}
|
|
12473
12689
|
clearConfig();
|
|
12474
|
-
|
|
12690
|
+
p42.log.success("Logged out of velastack.dev");
|
|
12475
12691
|
})
|
|
12476
12692
|
);
|
|
12477
12693
|
|
|
12478
12694
|
// src/commands/whoami.ts
|
|
12479
|
-
import { Command as
|
|
12480
|
-
import * as
|
|
12481
|
-
var whoami = new
|
|
12695
|
+
import { Command as Command75 } from "commander";
|
|
12696
|
+
import * as p43 from "@clack/prompts";
|
|
12697
|
+
var whoami = new Command75("whoami").description("show the current user").configureHelp(helpConfig).action(
|
|
12482
12698
|
() => runCommand(async () => {
|
|
12483
12699
|
const apiKey = readConfig()?.apiKey;
|
|
12484
12700
|
if (!apiKey) {
|
|
12485
|
-
|
|
12701
|
+
p43.log.info("Not logged in. Run `vela login` to login.");
|
|
12486
12702
|
return;
|
|
12487
12703
|
}
|
|
12488
12704
|
const res = await fetch(`${API_URL}/api/collections/users/records`, {
|
|
12489
12705
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
12490
12706
|
});
|
|
12491
12707
|
const data = await res.json();
|
|
12492
|
-
|
|
12493
|
-
|
|
12708
|
+
const user = data.items[0];
|
|
12709
|
+
if (!user) throw new Error("No user found. Run `vela login` to login.");
|
|
12710
|
+
const who = user.email || user.phone || user.name || "an account without a name";
|
|
12711
|
+
p43.log.success(`Logged in as ${who}`);
|
|
12494
12712
|
})
|
|
12495
12713
|
);
|
|
12496
12714
|
|
|
12497
12715
|
// src/commands/migrate.ts
|
|
12498
|
-
import { Command as
|
|
12716
|
+
import { Command as Command82 } from "commander";
|
|
12499
12717
|
|
|
12500
12718
|
// src/commands/migrate/up.ts
|
|
12501
|
-
import { Command as
|
|
12719
|
+
import { Command as Command76 } from "commander";
|
|
12502
12720
|
|
|
12503
12721
|
// src/lib/migrate.ts
|
|
12504
12722
|
import path46 from "node:path";
|
|
@@ -12540,10 +12758,10 @@ async function runMigrateUp() {
|
|
|
12540
12758
|
]
|
|
12541
12759
|
});
|
|
12542
12760
|
}
|
|
12543
|
-
var up = new
|
|
12761
|
+
var up = new Command76("up").description("apply all pending migrations").configureHelp(helpConfig).action(() => runCommand(runMigrateUp, "Failed to run migrations."));
|
|
12544
12762
|
|
|
12545
12763
|
// src/commands/migrate/down.ts
|
|
12546
|
-
import { Command as
|
|
12764
|
+
import { Command as Command77, InvalidArgumentError as InvalidArgumentError3 } from "commander";
|
|
12547
12765
|
function parseSteps(value) {
|
|
12548
12766
|
const n = parseInt(value, 10);
|
|
12549
12767
|
if (!Number.isFinite(n) || n <= 0) {
|
|
@@ -12551,7 +12769,7 @@ function parseSteps(value) {
|
|
|
12551
12769
|
}
|
|
12552
12770
|
return n;
|
|
12553
12771
|
}
|
|
12554
|
-
var down = new
|
|
12772
|
+
var down = new Command77("down").alias("rollback").description("revert the last N applied migrations").argument("[number]", "how many migrations to revert", parseSteps, 1).configureHelp(helpConfig).action(
|
|
12555
12773
|
(n) => runCommand(async () => {
|
|
12556
12774
|
await runPocketbaseMigrate(["down", String(n)]);
|
|
12557
12775
|
reportResult({
|
|
@@ -12567,8 +12785,8 @@ var down = new Command75("down").alias("rollback").description("revert the last
|
|
|
12567
12785
|
// src/commands/migrate/create.ts
|
|
12568
12786
|
import fs45 from "node:fs";
|
|
12569
12787
|
import path47 from "node:path";
|
|
12570
|
-
import { Command as
|
|
12571
|
-
var create2 = new
|
|
12788
|
+
import { Command as Command78 } from "commander";
|
|
12789
|
+
var create2 = new Command78("create").alias("new").description("create a new blank migration").argument("<name>", "migration name (snake_case)").configureHelp(helpConfig).action(
|
|
12572
12790
|
(name) => runCommand(async () => {
|
|
12573
12791
|
const cwd = migrateRoot();
|
|
12574
12792
|
const before = listMigrationFiles(cwd);
|
|
@@ -12594,8 +12812,8 @@ function listMigrationFiles(cwd) {
|
|
|
12594
12812
|
// src/commands/migrate/collections.ts
|
|
12595
12813
|
import fs46 from "node:fs";
|
|
12596
12814
|
import path48 from "node:path";
|
|
12597
|
-
import { Command as
|
|
12598
|
-
var collections = new
|
|
12815
|
+
import { Command as Command79 } from "commander";
|
|
12816
|
+
var collections = new Command79("collections").alias("snapshot").description("snapshot local collections into a new migration").configureHelp(helpConfig).action(
|
|
12599
12817
|
() => runCommand(async () => {
|
|
12600
12818
|
const cwd = migrateRoot();
|
|
12601
12819
|
const before = listMigrationFiles2(cwd);
|
|
@@ -12626,8 +12844,8 @@ function listMigrationFiles2(cwd) {
|
|
|
12626
12844
|
}
|
|
12627
12845
|
|
|
12628
12846
|
// src/commands/migrate/history-sync.ts
|
|
12629
|
-
import { Command as
|
|
12630
|
-
var historySync = new
|
|
12847
|
+
import { Command as Command80 } from "commander";
|
|
12848
|
+
var historySync = new Command80("history-sync").description("drop _migrations rows whose files no longer exist").configureHelp(helpConfig).action(
|
|
12631
12849
|
() => runCommand(async () => {
|
|
12632
12850
|
await runPocketbaseMigrate(["history-sync"]);
|
|
12633
12851
|
reportResult({
|
|
@@ -12640,13 +12858,13 @@ var historySync = new Command78("history-sync").description("drop _migrations ro
|
|
|
12640
12858
|
// src/commands/migrate/sveltekit-3.ts
|
|
12641
12859
|
import path49 from "node:path";
|
|
12642
12860
|
import process31 from "node:process";
|
|
12643
|
-
import { Command as
|
|
12644
|
-
import * as
|
|
12861
|
+
import { Command as Command81 } from "commander";
|
|
12862
|
+
import * as p44 from "@clack/prompts";
|
|
12645
12863
|
import pc13 from "picocolors";
|
|
12646
|
-
var sveltekit3 = new
|
|
12864
|
+
var sveltekit3 = new Command81("sveltekit-3").description("upgrade a SvelteKit 2 project to SvelteKit 3 (sv migrate, then the vela steps)").option("--cwd <path>", "the project to migrate (default: the current project)").option("--no-install", "skip installing dependencies").option("--force", "run even when the git working tree has uncommitted changes").option("--skip-sv", "only run the vela steps (sv has already been run)").configureHelp(helpConfig).action(
|
|
12647
12865
|
(options) => runCommand(async () => {
|
|
12648
12866
|
const root = options.cwd ? path49.resolve(options.cwd) : findWorkspaceRoot() ?? process31.cwd();
|
|
12649
|
-
|
|
12867
|
+
p44.intro(pc13.bgCyan(pc13.black(" vela migrate sveltekit-3 ")));
|
|
12650
12868
|
const result = await runKit3Migration(root, {
|
|
12651
12869
|
install: options.install,
|
|
12652
12870
|
force: options.force,
|
|
@@ -12673,14 +12891,14 @@ function printReport(root, result) {
|
|
|
12673
12891
|
"",
|
|
12674
12892
|
`${tasks.filesToReview} file(s) to review, ${tasks.markerComments} \`@migration-task\` comment(s) in the code.`
|
|
12675
12893
|
);
|
|
12676
|
-
|
|
12894
|
+
p44.note(lines.join("\n"), `${MIGRATION_TASKS_FILE}`, { format: (line) => line });
|
|
12677
12895
|
}
|
|
12678
12896
|
if (result.followUps.length > 0) {
|
|
12679
|
-
|
|
12897
|
+
p44.note(result.followUps.map((item) => `- ${item}`).join("\n"), "VelaStack follow-ups", {
|
|
12680
12898
|
format: (line) => line
|
|
12681
12899
|
});
|
|
12682
12900
|
}
|
|
12683
|
-
|
|
12901
|
+
p44.note(
|
|
12684
12902
|
nextStepsFor(result).map((s) => `- ${s}`).join("\n"),
|
|
12685
12903
|
"Next steps",
|
|
12686
12904
|
{
|
|
@@ -12717,14 +12935,14 @@ function nextStepsFor(result) {
|
|
|
12717
12935
|
}
|
|
12718
12936
|
|
|
12719
12937
|
// src/commands/migrate.ts
|
|
12720
|
-
var migrate = new
|
|
12938
|
+
var migrate = new Command82("migrate").description("manage database migrations (and `migrate sveltekit-3` to upgrade SvelteKit)").configureHelp(helpConfig).action(() => runCommand(runMigrateUp, "Failed to run migrations.")).addCommand(up).addCommand(down).addCommand(create2).addCommand(collections).addCommand(historySync).addCommand(sveltekit3);
|
|
12721
12939
|
|
|
12722
12940
|
// src/commands/dev.ts
|
|
12723
12941
|
import fs47 from "node:fs";
|
|
12724
12942
|
import path51 from "node:path";
|
|
12725
12943
|
import process33 from "node:process";
|
|
12726
12944
|
import { performance } from "node:perf_hooks";
|
|
12727
|
-
import { Command as
|
|
12945
|
+
import { Command as Command83, InvalidArgumentError as InvalidArgumentError4 } from "commander";
|
|
12728
12946
|
import pc15 from "picocolors";
|
|
12729
12947
|
import PocketBase5 from "pocketbase";
|
|
12730
12948
|
|
|
@@ -12797,7 +13015,7 @@ function parsePort(value) {
|
|
|
12797
13015
|
}
|
|
12798
13016
|
return port;
|
|
12799
13017
|
}
|
|
12800
|
-
var dev = new
|
|
13018
|
+
var dev = new Command83("dev").description("start the development server").option("--open [path]", "open the app in a browser once the server is ready").option("--host [host]", "expose the server on the network").option("--port <port>", "port to listen on", parsePort).option("--strictPort", "exit if the port is already in use instead of taking the next one").option("--cors", "enable CORS").option("--force", "re-bundle dependencies, ignoring the optimizer cache").option("--all-sql", "also print the auth lookup PocketBase runs on every request").configureHelp(helpConfig).action(async (options) => {
|
|
12801
13019
|
const cwd = process33.cwd();
|
|
12802
13020
|
warnIfKit2(findWorkspaceRoot(cwd) ?? cwd, (m) => console.warn(pc15.yellow(`\u25B2 ${m}`)));
|
|
12803
13021
|
process33.env.VELA_DATA_DIR ??= localDataDir(cwd);
|
|
@@ -12922,8 +13140,8 @@ async function startWatchingTypes(cwd, pb) {
|
|
|
12922
13140
|
import fs48 from "node:fs";
|
|
12923
13141
|
import path52 from "node:path";
|
|
12924
13142
|
import process35 from "node:process";
|
|
12925
|
-
import { Command as
|
|
12926
|
-
import * as
|
|
13143
|
+
import { Command as Command84 } from "commander";
|
|
13144
|
+
import * as p45 from "@clack/prompts";
|
|
12927
13145
|
import pc16 from "picocolors";
|
|
12928
13146
|
import { x as x4 } from "tinyexec";
|
|
12929
13147
|
import { detect as detect7 } from "package-manager-detector";
|
|
@@ -12963,9 +13181,9 @@ function splitHosts(value) {
|
|
|
12963
13181
|
|
|
12964
13182
|
// src/commands/build.ts
|
|
12965
13183
|
var PRERENDERED_DIR = path52.join(".svelte-kit", "output", "prerendered");
|
|
12966
|
-
var build = new
|
|
13184
|
+
var build = new Command84("build").description("build the app").configureHelp(helpConfig).option("-t, --target <target>", "which copy of the app to build for", PRODUCTION_TARGET).action(async (options) => {
|
|
12967
13185
|
const cwd = process35.cwd();
|
|
12968
|
-
warnIfKit2(findWorkspaceRoot(cwd) ?? cwd, (m) =>
|
|
13186
|
+
warnIfKit2(findWorkspaceRoot(cwd) ?? cwd, (m) => p45.log.warn(m));
|
|
12969
13187
|
warnIfSsrExternalMissing(findWorkspaceRoot(cwd) ?? cwd);
|
|
12970
13188
|
applyBuildEnv(cwd);
|
|
12971
13189
|
const origin = await originForBuild(cwd, options.target);
|
|
@@ -13016,7 +13234,7 @@ function warnIfSsrExternalMissing(root) {
|
|
|
13016
13234
|
}
|
|
13017
13235
|
const check2 = ssrExternalNotInDependencies(root);
|
|
13018
13236
|
const problem = ssrExternalProblem(check2) ?? ssrExternalAllNotice(check2);
|
|
13019
|
-
if (problem)
|
|
13237
|
+
if (problem) p45.log.warn(problem);
|
|
13020
13238
|
}
|
|
13021
13239
|
async function originForBuild(cwd, target) {
|
|
13022
13240
|
const workspaceRootDir = findWorkspaceRoot(cwd);
|
|
@@ -13034,7 +13252,7 @@ function warnIfPrerendered(cwd) {
|
|
|
13034
13252
|
const dir = path52.join(cwd, PRERENDERED_DIR);
|
|
13035
13253
|
if (!fs48.existsSync(dir) || fs48.readdirSync(dir).length === 0) return;
|
|
13036
13254
|
if (process35.env.VELA_ORIGIN === "") {
|
|
13037
|
-
|
|
13255
|
+
p45.log.warn(
|
|
13038
13256
|
`Prerendered pages were built with no origin, on purpose: this app is served on
|
|
13039
13257
|
several hosts (or on none yet), and baking one in would make the others render
|
|
13040
13258
|
as it and refuse their form posts. Each host takes its origin from the request
|
|
@@ -13044,7 +13262,7 @@ from ${pc16.cyan("src/lib/site.ts")}, as the templates' canonical links are.`
|
|
|
13044
13262
|
);
|
|
13045
13263
|
return;
|
|
13046
13264
|
}
|
|
13047
|
-
|
|
13265
|
+
p45.log.warn(
|
|
13048
13266
|
`Prerendered pages were built with no domain configured, so anything they take
|
|
13049
13267
|
from the request's origin points at SvelteKit's placeholder host rather than at
|
|
13050
13268
|
this site. Links built from ${pc16.cyan("src/lib/site.ts")}, as the templates' canonical
|
|
@@ -13058,17 +13276,17 @@ Set one with ${pc16.cyan("vela deploy --domain example.com")}, or pass ${pc16.cy
|
|
|
13058
13276
|
import fs49 from "node:fs";
|
|
13059
13277
|
import path53 from "node:path";
|
|
13060
13278
|
import process36 from "node:process";
|
|
13061
|
-
import { Command as
|
|
13062
|
-
import * as
|
|
13279
|
+
import { Command as Command85 } from "commander";
|
|
13280
|
+
import * as p46 from "@clack/prompts";
|
|
13063
13281
|
import pc17 from "picocolors";
|
|
13064
13282
|
import { x as x5 } from "tinyexec";
|
|
13065
13283
|
import { detect as detect8 } from "package-manager-detector";
|
|
13066
13284
|
import { resolveCommand as resolveCommand6 } from "package-manager-detector/commands";
|
|
13067
13285
|
var ADAPTER_NODE_MODULE = path53.join("build", "adapter-node.js");
|
|
13068
|
-
var preview = new
|
|
13286
|
+
var preview = new Command85("preview").description("preview the built app").configureHelp(helpConfig).action(async () => {
|
|
13069
13287
|
const cwd = process36.cwd();
|
|
13070
13288
|
process36.env.VELA_DATA_DIR ??= localDataDir(cwd);
|
|
13071
|
-
warnIfKit2(findWorkspaceRoot(cwd) ?? cwd, (m) =>
|
|
13289
|
+
warnIfKit2(findWorkspaceRoot(cwd) ?? cwd, (m) => p46.log.warn(m));
|
|
13072
13290
|
warnIfOriginBaked(cwd);
|
|
13073
13291
|
let pbProc;
|
|
13074
13292
|
const needsStart = hasBackend(cwd) && !process36.env.POCKETBASE_URL;
|
|
@@ -13123,7 +13341,7 @@ function warnIfOriginBaked(cwd) {
|
|
|
13123
13341
|
}
|
|
13124
13342
|
const origin = bakedOrigin(source);
|
|
13125
13343
|
if (!origin || isLocalUrl(origin)) return;
|
|
13126
|
-
|
|
13344
|
+
p46.log.warn(
|
|
13127
13345
|
`This build was made for ${pc17.cyan(origin)}, and SvelteKit treats that as the origin of
|
|
13128
13346
|
every request. Form posts from localhost will be refused as cross-site (403).
|
|
13129
13347
|
|
|
@@ -13134,8 +13352,8 @@ set empty so no domain is baked in.`
|
|
|
13134
13352
|
|
|
13135
13353
|
// src/commands/sync.ts
|
|
13136
13354
|
import path54 from "node:path";
|
|
13137
|
-
import { Command as
|
|
13138
|
-
var sync = new
|
|
13355
|
+
import { Command as Command86 } from "commander";
|
|
13356
|
+
var sync = new Command86("sync").description("sync types from the database").configureHelp(helpConfig).action(
|
|
13139
13357
|
() => runCommand(async () => {
|
|
13140
13358
|
const { workspaceRootDir } = await getWorkspace();
|
|
13141
13359
|
const typesDir = path54.join(workspaceRootDir, ".svelte-kit", "types");
|
|
@@ -13148,8 +13366,8 @@ var sync = new Command84("sync").description("sync types from the database").con
|
|
|
13148
13366
|
);
|
|
13149
13367
|
|
|
13150
13368
|
// src/commands/provision.ts
|
|
13151
|
-
import { Command as
|
|
13152
|
-
import * as
|
|
13369
|
+
import { Command as Command87 } from "commander";
|
|
13370
|
+
import * as p47 from "@clack/prompts";
|
|
13153
13371
|
import pc18 from "picocolors";
|
|
13154
13372
|
import * as v9 from "valibot";
|
|
13155
13373
|
var NODE_MAJOR = "24";
|
|
@@ -13163,7 +13381,7 @@ var OptionsSchema2 = v9.object({
|
|
|
13163
13381
|
)
|
|
13164
13382
|
});
|
|
13165
13383
|
var provision = addSshOptions(
|
|
13166
|
-
new
|
|
13384
|
+
new Command87("provision").description("prepare a server to host vela apps").argument("<target>", "SSH target \u2014 an alias from ~/.ssh/config, or user@host").configureHelp(helpConfig)
|
|
13167
13385
|
).option("--pb-version <version>", "PocketBase version to install").option(
|
|
13168
13386
|
"--node-major <version>",
|
|
13169
13387
|
"Node.js major version to bring the server up to (match the one you build with)",
|
|
@@ -13172,19 +13390,19 @@ var provision = addSshOptions(
|
|
|
13172
13390
|
(target, raw) => runCommand(async () => {
|
|
13173
13391
|
const options = parseOptions(OptionsSchema2, raw);
|
|
13174
13392
|
const pbVersion = options.pbVersion ?? pocketbaseVersion();
|
|
13175
|
-
|
|
13176
|
-
|
|
13393
|
+
p47.intro(pc18.bgCyan(pc18.black(" vela provision ")));
|
|
13394
|
+
p47.log.info(`Target ${pc18.cyan(target)}`);
|
|
13177
13395
|
await withSsh(target, sshOptionsFrom(options), async (session) => {
|
|
13178
13396
|
await session.detectElevation();
|
|
13179
13397
|
const existing = await readServerInfo(session);
|
|
13180
13398
|
if (existing) {
|
|
13181
|
-
|
|
13399
|
+
p47.log.info(
|
|
13182
13400
|
`Already provisioned by vela ${existing.cliVersion} on ${existing.provisionedAt}. Bringing it up to date.`
|
|
13183
13401
|
);
|
|
13184
13402
|
}
|
|
13185
|
-
|
|
13403
|
+
p47.log.step("Uploading server scripts");
|
|
13186
13404
|
await syncServerScripts(session);
|
|
13187
|
-
|
|
13405
|
+
p47.log.step("Running provision");
|
|
13188
13406
|
const result = await runServerScript(session, "provision.sh", {
|
|
13189
13407
|
args: [
|
|
13190
13408
|
"--pb-version",
|
|
@@ -13196,7 +13414,7 @@ var provision = addSshOptions(
|
|
|
13196
13414
|
],
|
|
13197
13415
|
stream: true
|
|
13198
13416
|
});
|
|
13199
|
-
|
|
13417
|
+
p47.log.success(
|
|
13200
13418
|
`${target} is ready.
|
|
13201
13419
|
|
|
13202
13420
|
Node ${result?.node ?? "installed"}
|
|
@@ -13204,7 +13422,7 @@ var provision = addSshOptions(
|
|
|
13204
13422
|
PocketBase ${result?.pocketbase ?? pbVersion}`
|
|
13205
13423
|
);
|
|
13206
13424
|
});
|
|
13207
|
-
|
|
13425
|
+
p47.outro(`Deploy with ${pc18.cyan(`vela deploy --server ${target}`)}`);
|
|
13208
13426
|
}, "Failed to provision.")
|
|
13209
13427
|
);
|
|
13210
13428
|
|
|
@@ -13212,8 +13430,8 @@ var provision = addSshOptions(
|
|
|
13212
13430
|
import path58 from "node:path";
|
|
13213
13431
|
import fs53 from "node:fs";
|
|
13214
13432
|
import process38 from "node:process";
|
|
13215
|
-
import { Command as
|
|
13216
|
-
import * as
|
|
13433
|
+
import { Command as Command88, Option as Option2 } from "commander";
|
|
13434
|
+
import * as p49 from "@clack/prompts";
|
|
13217
13435
|
import pc20 from "picocolors";
|
|
13218
13436
|
import * as v10 from "valibot";
|
|
13219
13437
|
|
|
@@ -13485,7 +13703,7 @@ The build would bake in your development value. Set ${baked.length === 1 ? "it"
|
|
|
13485
13703
|
import fs52 from "node:fs";
|
|
13486
13704
|
import path57 from "node:path";
|
|
13487
13705
|
import process37 from "node:process";
|
|
13488
|
-
import * as
|
|
13706
|
+
import * as p48 from "@clack/prompts";
|
|
13489
13707
|
import pc19 from "picocolors";
|
|
13490
13708
|
var ENV_EXAMPLE = ".env.example";
|
|
13491
13709
|
var SUPPLIED = /^(NODE_ENV|HOST|PORT|ORIGIN|PROTOCOL_HEADER|HOST_HEADER|ADDRESS_HEADER|XFF_DEPTH|PB_PORT|POCKETBASE_URL|POCKETBASE_SUPERUSER_EMAIL|POCKETBASE_SUPERUSER_PASSWORD|APP_NAME|VELA_)/;
|
|
@@ -13500,7 +13718,7 @@ async function nudgeMissingEnv(root, target, present) {
|
|
|
13500
13718
|
if (missing.length === 0) return [];
|
|
13501
13719
|
const where = pc19.cyan(target.targetName);
|
|
13502
13720
|
if (!isInteractive()) {
|
|
13503
|
-
|
|
13721
|
+
p48.log.warn(
|
|
13504
13722
|
`${where} does not have ${missing.length} of the variables ${ENV_EXAMPLE} documents:
|
|
13505
13723
|
|
|
13506
13724
|
` + missing.map((key) => ` ${key}`).join("\n") + `
|
|
@@ -13509,13 +13727,13 @@ Set any it needs with ${pc19.cyan(`vela env set KEY -t ${target.targetName}`)}.`
|
|
|
13509
13727
|
);
|
|
13510
13728
|
return [];
|
|
13511
13729
|
}
|
|
13512
|
-
|
|
13730
|
+
p48.log.warn(
|
|
13513
13731
|
`${where} does not have ${missing.length} of the variables ${ENV_EXAMPLE} documents:
|
|
13514
13732
|
|
|
13515
13733
|
` + missing.map((key) => ` ${key}`).join("\n")
|
|
13516
13734
|
);
|
|
13517
|
-
const go = await
|
|
13518
|
-
if (
|
|
13735
|
+
const go = await p48.confirm({ message: "Set any of them now?", initialValue: true });
|
|
13736
|
+
if (p48.isCancel(go)) cancel22();
|
|
13519
13737
|
if (!go) return [];
|
|
13520
13738
|
const set = [];
|
|
13521
13739
|
for (const key of missing) {
|
|
@@ -13525,7 +13743,7 @@ Set any it needs with ${pc19.cyan(`vela env set KEY -t ${target.targetName}`)}.`
|
|
|
13525
13743
|
const value = await promptValue(key, asPublic);
|
|
13526
13744
|
const files = layer === "instance" ? layerFiles(target.appId, "instance", target.instance) : layerFiles(target.appId, layer);
|
|
13527
13745
|
await setInLayer(target.session, files, key, value, asPublic);
|
|
13528
|
-
|
|
13746
|
+
p48.log.success(
|
|
13529
13747
|
`${key} set${asPublic ? " (public)" : ""} ${pc19.dim(`(${layer === "instance" ? target.targetName : layer})`)}`
|
|
13530
13748
|
);
|
|
13531
13749
|
set.push(key);
|
|
@@ -13539,27 +13757,27 @@ async function pickLayer(key, target) {
|
|
|
13539
13757
|
];
|
|
13540
13758
|
if (target.preview) options.push({ value: "preview", label: "preview", hint: "every preview" });
|
|
13541
13759
|
options.push({ value: "skip", label: "skip", hint: "leave it unset" });
|
|
13542
|
-
const choice = await
|
|
13543
|
-
if (
|
|
13760
|
+
const choice = await p48.select({ message: `Where should ${pc19.cyan(key)} be set?`, options });
|
|
13761
|
+
if (p48.isCancel(choice)) cancel22();
|
|
13544
13762
|
return choice === "skip" ? null : choice;
|
|
13545
13763
|
}
|
|
13546
13764
|
async function askPublic(key) {
|
|
13547
|
-
const choice = await
|
|
13765
|
+
const choice = await p48.confirm({
|
|
13548
13766
|
message: `Is ${pc19.cyan(key)} public? (readable back with vela env list; no for a secret)`,
|
|
13549
13767
|
initialValue: false
|
|
13550
13768
|
});
|
|
13551
|
-
if (
|
|
13769
|
+
if (p48.isCancel(choice)) cancel22();
|
|
13552
13770
|
return choice;
|
|
13553
13771
|
}
|
|
13554
13772
|
async function promptValue(key, asPublic) {
|
|
13555
13773
|
const message = `Value for ${pc19.cyan(key)}${asPublic ? pc19.dim(" (public)") : ""}`;
|
|
13556
13774
|
const validate = (input) => !input?.length ? "Required" : void 0;
|
|
13557
|
-
const value = asPublic ? await
|
|
13558
|
-
if (
|
|
13775
|
+
const value = asPublic ? await p48.text({ message, validate }) : await p48.password({ message, validate });
|
|
13776
|
+
if (p48.isCancel(value)) cancel22();
|
|
13559
13777
|
return value;
|
|
13560
13778
|
}
|
|
13561
13779
|
function cancel22() {
|
|
13562
|
-
|
|
13780
|
+
p48.cancel("Operation cancelled.");
|
|
13563
13781
|
process37.exit(0);
|
|
13564
13782
|
}
|
|
13565
13783
|
|
|
@@ -13578,7 +13796,7 @@ var OptionsSchema3 = v10.object({
|
|
|
13578
13796
|
});
|
|
13579
13797
|
var deploy = addLockWaitOption(
|
|
13580
13798
|
addTargetOptions(
|
|
13581
|
-
new
|
|
13799
|
+
new Command88("deploy").description("deploy the app").configureHelp(helpConfig),
|
|
13582
13800
|
"production"
|
|
13583
13801
|
)
|
|
13584
13802
|
).option("--project <name>", "override the project name").option("--domain <hosts>", "hostname(s) to serve on, comma separated").option("--health-path <path>", "path the health check requests").option("--keep <count>", "how many old releases to keep on the server").option("--pb-version <version>", "PocketBase version to run").option("--no-build", "deploy the existing build output without rebuilding").addOption(
|
|
@@ -13594,13 +13812,13 @@ var deploy = addLockWaitOption(
|
|
|
13594
13812
|
(raw) => runCommand(async () => {
|
|
13595
13813
|
const options = parseOptions(OptionsSchema3, raw);
|
|
13596
13814
|
const backend3 = hasBackend();
|
|
13597
|
-
|
|
13815
|
+
p49.intro(pc20.bgCyan(pc20.black(" vela deploy ")));
|
|
13598
13816
|
if (options.build !== false) {
|
|
13599
13817
|
const { workspaceRootDir } = await getWorkspace();
|
|
13600
13818
|
await prepareAdapter(workspaceRootDir);
|
|
13601
13819
|
const foreign = foreignLockfile(workspaceRootDir);
|
|
13602
13820
|
if (foreign) {
|
|
13603
|
-
|
|
13821
|
+
p49.log.warn(
|
|
13604
13822
|
`Dependencies are pinned by ${pc20.cyan(foreign)}, but the server installs with npm, which cannot replay it.
|
|
13605
13823
|
Versions there are resolved from package.json ranges and may differ from yours. Commit a
|
|
13606
13824
|
${pc20.cyan("package-lock.json")} (${pc20.dim("npm install --package-lock-only")}) for a reproducible deploy.`
|
|
@@ -13613,13 +13831,13 @@ ${pc20.cyan("package-lock.json")} (${pc20.dim("npm install --package-lock-only")
|
|
|
13613
13831
|
{
|
|
13614
13832
|
remote: async (ctx) => {
|
|
13615
13833
|
const { session, instance, workspaceRootDir } = ctx;
|
|
13616
|
-
|
|
13834
|
+
p49.log.info(
|
|
13617
13835
|
`${pc20.cyan(ctx.appName)} ${pc20.dim("\u2192")} ${pc20.cyan(ctx.targetName)} ${pc20.dim(`(${ctx.server})`)}`
|
|
13618
13836
|
);
|
|
13619
13837
|
const serverNode = await requireServerNode(session, ctx.server);
|
|
13620
13838
|
const drift = nodeMajorDrift(serverNode, process38.version);
|
|
13621
13839
|
if (drift) {
|
|
13622
|
-
|
|
13840
|
+
p49.log.warn(
|
|
13623
13841
|
`${ctx.server} runs Node ${drift.server}, but this deploy runs Node ${drift.build}. The server's npm can reject a lockfile this one accepts.
|
|
13624
13842
|
Run ${pc20.cyan(`vela provision ${ctx.server}`)} to bring it up to ${drift.build}.`
|
|
13625
13843
|
);
|
|
@@ -13631,7 +13849,7 @@ Run ${pc20.cyan(`vela provision ${ctx.server}`)} to bring it up to ${drift.build
|
|
|
13631
13849
|
const askedForRemoteDb = options.remoteDb;
|
|
13632
13850
|
const remoteDb = askedForRemoteDb ?? instanceHasBackend(existing);
|
|
13633
13851
|
if (existing && instanceHasBackend(existing) !== backend3) {
|
|
13634
|
-
|
|
13852
|
+
p49.log.info(
|
|
13635
13853
|
backend3 ? `${pc20.cyan(ctx.targetName)} was deployed without a backend before. This deploy adds PocketBase.` : `${pc20.cyan(ctx.targetName)} was deployed with a backend before. This deploy removes PocketBase; its database stays on the server.`
|
|
13636
13854
|
);
|
|
13637
13855
|
}
|
|
@@ -13694,7 +13912,7 @@ with DNS of your own pointing at ${ctx.server}.`
|
|
|
13694
13912
|
tunnel = await openDatabaseTunnel(session, instance, existing);
|
|
13695
13913
|
} catch (err) {
|
|
13696
13914
|
if (askedForRemoteDb) throw err;
|
|
13697
|
-
|
|
13915
|
+
p49.log.warn(
|
|
13698
13916
|
`Could not build against the ${pc20.cyan(ctx.targetName)} database, using a local one instead.
|
|
13699
13917
|
${pc20.dim(String(err))}`
|
|
13700
13918
|
);
|
|
@@ -13702,7 +13920,7 @@ ${pc20.dim(String(err))}`
|
|
|
13702
13920
|
}
|
|
13703
13921
|
if (tunnel) {
|
|
13704
13922
|
derived = { ...derived, ...tunnel.env };
|
|
13705
|
-
|
|
13923
|
+
p49.log.info(
|
|
13706
13924
|
`Building against the ${pc20.cyan(ctx.targetName)} database on ${ctx.server} ${pc20.dim(`(port ${tunnel.pbPort})`)}`
|
|
13707
13925
|
);
|
|
13708
13926
|
} else if (backend3) {
|
|
@@ -13714,11 +13932,11 @@ ${pc20.dim(String(err))}`
|
|
|
13714
13932
|
tunnel: tunnel !== null
|
|
13715
13933
|
});
|
|
13716
13934
|
if (blanked.length > 0) {
|
|
13717
|
-
|
|
13935
|
+
p49.log.info(
|
|
13718
13936
|
`Building without ${blanked.join(", ")} \u2014 set in .env but not for ${pc20.cyan(ctx.targetName)}.`
|
|
13719
13937
|
);
|
|
13720
13938
|
}
|
|
13721
|
-
|
|
13939
|
+
p49.log.step("Building");
|
|
13722
13940
|
try {
|
|
13723
13941
|
await runBuild(workspaceRootDir, void 0, buildEnv);
|
|
13724
13942
|
} finally {
|
|
@@ -13726,9 +13944,9 @@ ${pc20.dim(String(err))}`
|
|
|
13726
13944
|
}
|
|
13727
13945
|
}
|
|
13728
13946
|
const entries = collectArtifact(workspaceRootDir);
|
|
13729
|
-
|
|
13947
|
+
p49.log.step(`Uploading release ${pc20.dim(release)}`);
|
|
13730
13948
|
await uploadRelease(session, instance, release, entries);
|
|
13731
|
-
|
|
13949
|
+
p49.log.step("Activating");
|
|
13732
13950
|
result = await runServerScript(session, "apply.sh", {
|
|
13733
13951
|
args: [
|
|
13734
13952
|
instance,
|
|
@@ -13793,7 +14011,7 @@ ${pc20.dim(String(err))}`
|
|
|
13793
14011
|
url: primaryHost ? url : void 0
|
|
13794
14012
|
});
|
|
13795
14013
|
const redirects = started?.environment.redirects ?? [];
|
|
13796
|
-
|
|
14014
|
+
p49.log.success(
|
|
13797
14015
|
`Deployed ${pc20.cyan(ctx.appName)} ${pc20.dim(release)}
|
|
13798
14016
|
|
|
13799
14017
|
URL ${url}
|
|
@@ -13801,10 +14019,10 @@ ${pc20.dim(String(err))}`
|
|
|
13801
14019
|
` : "") + ` Port ${result?.webPort ?? "?"}${backend3 ? ` (PocketBase ${result?.pbPort ?? "?"})` : ""}`
|
|
13802
14020
|
);
|
|
13803
14021
|
if (managed && managed !== existing?.managed) {
|
|
13804
|
-
|
|
14022
|
+
p49.log.info(`${pc20.cyan(managed)} goes live within a minute.`);
|
|
13805
14023
|
}
|
|
13806
14024
|
if (result?.superuserCreated) {
|
|
13807
|
-
|
|
14025
|
+
p49.log.info(
|
|
13808
14026
|
`Created the PocketBase superuser this app authenticates as.
|
|
13809
14027
|
|
|
13810
14028
|
Its credentials are stored in the environment on the server. To use
|
|
@@ -13813,7 +14031,7 @@ and deploy again.`
|
|
|
13813
14031
|
);
|
|
13814
14032
|
}
|
|
13815
14033
|
if (!primaryHost) {
|
|
13816
|
-
|
|
14034
|
+
p49.log.warn(
|
|
13817
14035
|
`No domain configured, so nothing is proxied to this app yet.
|
|
13818
14036
|
Redeploy with ${pc20.cyan("--domain example.com")} once DNS points at ${ctx.server}` + (reporter.enabled ? "" : `,
|
|
13819
14037
|
or ${pc20.cyan("vela link")} it to get a free velastack.app hostname.`) + `.`
|
|
@@ -13823,7 +14041,7 @@ or ${pc20.cyan("vela link")} it to get a free velastack.app hostname.`) + `.`
|
|
|
13823
14041
|
},
|
|
13824
14042
|
{ project: options.project, askDomain: true, label: "deploy" }
|
|
13825
14043
|
);
|
|
13826
|
-
|
|
14044
|
+
p49.outro(`${pc20.cyan("vela status")} to see what is running`);
|
|
13827
14045
|
}, "Failed to deploy.")
|
|
13828
14046
|
);
|
|
13829
14047
|
async function prepareAdapter(workspaceRootDir) {
|
|
@@ -13843,12 +14061,12 @@ ${pc20.cyan(err.snippet)}` : err.message);
|
|
|
13843
14061
|
const editable = current !== void 0 && !/^svelte\.config\./.test(path58.basename(current.file));
|
|
13844
14062
|
if (current && editable && (current.kind === "auto" || current.kind === "none") && isInteractive()) {
|
|
13845
14063
|
const has = current.kind === "auto" ? `is on ${ADAPTER_AUTO}` : "has no SvelteKit adapter configured";
|
|
13846
|
-
const confirmed = await
|
|
14064
|
+
const confirmed = await p49.confirm({
|
|
13847
14065
|
message: `This project ${has}, and vela deploy runs the app as a Node server.
|
|
13848
14066
|
Switch it to ${ADAPTER_NODE}? This edits ${path58.basename(current.file)} and package.json.`
|
|
13849
14067
|
});
|
|
13850
|
-
if (
|
|
13851
|
-
|
|
14068
|
+
if (p49.isCancel(confirmed) || !confirmed) {
|
|
14069
|
+
p49.cancel("Nothing was changed, and nothing was deployed.");
|
|
13852
14070
|
process38.exit(0);
|
|
13853
14071
|
}
|
|
13854
14072
|
}
|
|
@@ -13859,8 +14077,8 @@ Switch it to ${ADAPTER_NODE}? This edits ${path58.basename(current.file)} and pa
|
|
|
13859
14077
|
outcome.packageJsonChanged ? "package.json" : void 0
|
|
13860
14078
|
].filter((f) => Boolean(f));
|
|
13861
14079
|
const why = outcome.previous === "auto" ? `${ADAPTER_AUTO} builds nothing for a server of your own` : outcome.previous === "none" ? "No adapter was configured" : `${ADAPTER_NODE} was configured but not in package.json`;
|
|
13862
|
-
|
|
13863
|
-
|
|
14080
|
+
p49.log.step(`Switching the adapter to ${pc20.cyan(ADAPTER_NODE)}`);
|
|
14081
|
+
p49.log.info(
|
|
13864
14082
|
`${why}, and vela deploy runs the app as a Node server.
|
|
13865
14083
|
|
|
13866
14084
|
Changed ${changed.join(", ")}` + (outcome.removedDeps.length ? `
|
|
@@ -13873,7 +14091,7 @@ Switch it to ${ADAPTER_NODE}? This edits ${path58.basename(current.file)} and pa
|
|
|
13873
14091
|
rethrow(err);
|
|
13874
14092
|
}
|
|
13875
14093
|
}
|
|
13876
|
-
|
|
14094
|
+
p49.log.warn(`Commit ${changed.join(", ")} so every deploy builds the same way.`);
|
|
13877
14095
|
}
|
|
13878
14096
|
function ssrExternalPreflight(root) {
|
|
13879
14097
|
const major = kitMajor(root);
|
|
@@ -13889,7 +14107,7 @@ function ssrExternalPreflight(root) {
|
|
|
13889
14107
|
const problem = ssrExternalProblem(check2);
|
|
13890
14108
|
if (problem) throw new Error(problem);
|
|
13891
14109
|
const notice = ssrExternalAllNotice(check2);
|
|
13892
|
-
if (notice)
|
|
14110
|
+
if (notice) p49.log.warn(notice);
|
|
13893
14111
|
}
|
|
13894
14112
|
async function openDatabaseTunnel(session, instance, state) {
|
|
13895
14113
|
const pbPort = instanceHasBackend(state) ? state?.pbPort : void 0;
|
|
@@ -14004,7 +14222,7 @@ async function serverTimeOrLocal(session) {
|
|
|
14004
14222
|
try {
|
|
14005
14223
|
return await serverTime(session);
|
|
14006
14224
|
} catch {
|
|
14007
|
-
|
|
14225
|
+
p49.log.warn("Could not read the clock on the server; stamping this release from this machine.");
|
|
14008
14226
|
return /* @__PURE__ */ new Date();
|
|
14009
14227
|
}
|
|
14010
14228
|
}
|
|
@@ -14012,15 +14230,15 @@ async function serverTimeOrLocal(session) {
|
|
|
14012
14230
|
// src/commands/link.ts
|
|
14013
14231
|
import path59 from "node:path";
|
|
14014
14232
|
import process39 from "node:process";
|
|
14015
|
-
import { Command as
|
|
14016
|
-
import * as
|
|
14233
|
+
import { Command as Command89 } from "commander";
|
|
14234
|
+
import * as p50 from "@clack/prompts";
|
|
14017
14235
|
var CREATE_NEW = "__new__";
|
|
14018
|
-
var link = new
|
|
14236
|
+
var link = new Command89("link").description("link this project to a velastack.dev project").configureHelp(helpConfig).action(() => runCommand(linkProject, "Failed to link the project."));
|
|
14019
14237
|
async function linkProject() {
|
|
14020
14238
|
const { workspaceRootDir } = await getWorkspace();
|
|
14021
14239
|
const existing = readProjectConfig(workspaceRootDir);
|
|
14022
14240
|
if (existing) {
|
|
14023
|
-
|
|
14241
|
+
p50.log.success(`Linked to ${existing.projectName}.`);
|
|
14024
14242
|
return;
|
|
14025
14243
|
}
|
|
14026
14244
|
const apiKey = requireApiKey();
|
|
@@ -14037,10 +14255,10 @@ async function linkProject() {
|
|
|
14037
14255
|
}
|
|
14038
14256
|
const { projectId, teamId, projectName } = linked;
|
|
14039
14257
|
writeProjectConfig(workspaceRootDir, { projectId, teamId, projectName });
|
|
14040
|
-
|
|
14258
|
+
p50.log.success(`Linked to ${projectName} (${linked.dashboardUrl}).`);
|
|
14041
14259
|
}
|
|
14042
14260
|
async function pickExistingProject(projects) {
|
|
14043
|
-
const choice = await
|
|
14261
|
+
const choice = await p50.select({
|
|
14044
14262
|
message: "Select a project",
|
|
14045
14263
|
options: [
|
|
14046
14264
|
...projects.map((pr) => ({
|
|
@@ -14050,23 +14268,23 @@ async function pickExistingProject(projects) {
|
|
|
14050
14268
|
{ value: CREATE_NEW, label: "Create a new project" }
|
|
14051
14269
|
]
|
|
14052
14270
|
});
|
|
14053
|
-
if (
|
|
14054
|
-
|
|
14271
|
+
if (p50.isCancel(choice)) {
|
|
14272
|
+
p50.cancel("Operation cancelled.");
|
|
14055
14273
|
process39.exit(0);
|
|
14056
14274
|
}
|
|
14057
14275
|
return choice;
|
|
14058
14276
|
}
|
|
14059
14277
|
async function promptProjectName(workspaceRootDir) {
|
|
14060
14278
|
const defaultValue = defaultProjectName2(workspaceRootDir);
|
|
14061
|
-
const value = await
|
|
14279
|
+
const value = await p50.text({
|
|
14062
14280
|
message: "Project name",
|
|
14063
14281
|
defaultValue,
|
|
14064
14282
|
initialValue: defaultValue,
|
|
14065
14283
|
placeholder: defaultValue,
|
|
14066
14284
|
validate: (v14) => !v14?.trim() ? "Required" : void 0
|
|
14067
14285
|
});
|
|
14068
|
-
if (
|
|
14069
|
-
|
|
14286
|
+
if (p50.isCancel(value)) {
|
|
14287
|
+
p50.cancel("Operation cancelled.");
|
|
14070
14288
|
process39.exit(0);
|
|
14071
14289
|
}
|
|
14072
14290
|
return value.trim();
|
|
@@ -14082,17 +14300,17 @@ function defaultProjectName2(workspaceRootDir) {
|
|
|
14082
14300
|
}
|
|
14083
14301
|
|
|
14084
14302
|
// src/commands/env.ts
|
|
14085
|
-
import { Command as
|
|
14303
|
+
import { Command as Command95 } from "commander";
|
|
14086
14304
|
|
|
14087
14305
|
// src/commands/env/list.ts
|
|
14088
|
-
import { Command as
|
|
14306
|
+
import { Command as Command90 } from "commander";
|
|
14089
14307
|
import * as v12 from "valibot";
|
|
14090
|
-
import * as
|
|
14308
|
+
import * as p53 from "@clack/prompts";
|
|
14091
14309
|
import pc23 from "picocolors";
|
|
14092
14310
|
|
|
14093
14311
|
// src/lib/local-env.ts
|
|
14094
14312
|
import fs54 from "node:fs";
|
|
14095
|
-
import * as
|
|
14313
|
+
import * as p51 from "@clack/prompts";
|
|
14096
14314
|
import pc21 from "picocolors";
|
|
14097
14315
|
function readLocalEnv(envFile) {
|
|
14098
14316
|
if (!fs54.existsSync(envFile)) return {};
|
|
@@ -14118,23 +14336,23 @@ async function applyLocalEnvChange(ctx, changed) {
|
|
|
14118
14336
|
process.env.POCKETBASE_SUPERUSER_EMAIL = email2;
|
|
14119
14337
|
process.env.POCKETBASE_SUPERUSER_PASSWORD = password8;
|
|
14120
14338
|
await ensureSuperuser(ctx.workspaceRootDir);
|
|
14121
|
-
|
|
14339
|
+
p51.log.success("Local superuser updated to match");
|
|
14122
14340
|
} else {
|
|
14123
|
-
|
|
14341
|
+
p51.log.warn(
|
|
14124
14342
|
`The local database still has the old superuser.
|
|
14125
14343
|
Set both ${pc21.cyan("POCKETBASE_SUPERUSER_EMAIL")} and ${pc21.cyan("POCKETBASE_SUPERUSER_PASSWORD")} to reconcile it.`
|
|
14126
14344
|
);
|
|
14127
14345
|
}
|
|
14128
14346
|
}
|
|
14129
14347
|
if (getPocketbaseMetadata(ctx.workspaceRootDir)) {
|
|
14130
|
-
|
|
14348
|
+
p51.log.info(`Restart ${pc21.cyan("vela dev")} to pick this up.`);
|
|
14131
14349
|
}
|
|
14132
14350
|
}
|
|
14133
14351
|
|
|
14134
14352
|
// src/lib/env-command.ts
|
|
14135
14353
|
import process40 from "node:process";
|
|
14136
14354
|
import * as v11 from "valibot";
|
|
14137
|
-
import * as
|
|
14355
|
+
import * as p52 from "@clack/prompts";
|
|
14138
14356
|
import pc22 from "picocolors";
|
|
14139
14357
|
var ALL_SCOPE = "all";
|
|
14140
14358
|
var PREVIEW_SCOPE = "preview";
|
|
@@ -14259,12 +14477,12 @@ async function promptScope(workspaceRootDir, label2) {
|
|
|
14259
14477
|
[ALL_SCOPE]: "every deployed target, on every server",
|
|
14260
14478
|
[PREVIEW_SCOPE]: "every preview"
|
|
14261
14479
|
};
|
|
14262
|
-
const choice = await
|
|
14480
|
+
const choice = await p52.select({
|
|
14263
14481
|
message: "Which environment?",
|
|
14264
14482
|
options: scopes.map((scope) => ({ value: scope, label: scope, hint: hints[scope] }))
|
|
14265
14483
|
});
|
|
14266
|
-
if (
|
|
14267
|
-
|
|
14484
|
+
if (p52.isCancel(choice)) {
|
|
14485
|
+
p52.cancel("Operation cancelled.");
|
|
14268
14486
|
process40.exit(0);
|
|
14269
14487
|
}
|
|
14270
14488
|
return parseEnvScope(choice);
|
|
@@ -14275,7 +14493,7 @@ function readAtBuildTime(workspaceRootDir, keys) {
|
|
|
14275
14493
|
}
|
|
14276
14494
|
async function applyLayerRestart(ctx, changed) {
|
|
14277
14495
|
if (touchesSuperuser(changed)) {
|
|
14278
|
-
|
|
14496
|
+
p52.log.warn(
|
|
14279
14497
|
`PocketBase superuser credentials changed.
|
|
14280
14498
|
|
|
14281
14499
|
Each database still holds the old ones, so nothing was restarted.
|
|
@@ -14284,22 +14502,22 @@ Run ${pc22.cyan("vela deploy")} for every target to push them in.`
|
|
|
14284
14502
|
return;
|
|
14285
14503
|
}
|
|
14286
14504
|
if (ctx.reached.length === 0) {
|
|
14287
|
-
|
|
14505
|
+
p52.log.info(`Nothing of this app runs on ${ctx.server} yet; the value applies on first deploy.`);
|
|
14288
14506
|
return;
|
|
14289
14507
|
}
|
|
14290
14508
|
for (const state of ctx.reached) {
|
|
14291
14509
|
const shadowed = await shadowedKeys(ctx.session, ctx.appId, state, ctx.layer, changed);
|
|
14292
14510
|
const reach = changed.filter((key) => !(key in shadowed));
|
|
14293
|
-
if (Object.keys(shadowed).length > 0)
|
|
14511
|
+
if (Object.keys(shadowed).length > 0) p52.log.warn(shadowWarning(state, ctx.layer, shadowed));
|
|
14294
14512
|
if (reach.length === 0) {
|
|
14295
|
-
|
|
14513
|
+
p52.log.info(`${state.env} not restarted ${pc22.dim(`(${ctx.server})`)}`);
|
|
14296
14514
|
continue;
|
|
14297
14515
|
}
|
|
14298
14516
|
const outcome = await restartInstance(ctx.session, state.instance);
|
|
14299
14517
|
if (!outcome.deployed) continue;
|
|
14300
|
-
if (outcome.restarted)
|
|
14518
|
+
if (outcome.restarted) p52.log.success(`${state.env} restarted ${pc22.dim(`(${ctx.server})`)}`);
|
|
14301
14519
|
else {
|
|
14302
|
-
|
|
14520
|
+
p52.log.error(
|
|
14303
14521
|
`${state.env} restart failed.
|
|
14304
14522
|
|
|
14305
14523
|
The new value is stored and will be used the next time it starts.
|
|
@@ -14337,7 +14555,7 @@ function shadowWarning(state, layer, shadowed) {
|
|
|
14337
14555
|
async function applyChange(workspaceRootDir, ctx, changed) {
|
|
14338
14556
|
const { baked, how } = readAtBuildTime(workspaceRootDir, changed);
|
|
14339
14557
|
if (baked.length > 0) {
|
|
14340
|
-
|
|
14558
|
+
p52.log.info(
|
|
14341
14559
|
`${baked.join(", ")} ${baked.length === 1 ? "is" : "are"} read at build time (${pc22.cyan(how)}); redeploy to apply.`
|
|
14342
14560
|
);
|
|
14343
14561
|
const rest = changed.filter((key) => !baked.includes(key));
|
|
@@ -14357,7 +14575,7 @@ var OptionsSchema5 = v12.object({
|
|
|
14357
14575
|
var HIDDEN = "\u2022\u2022\u2022\u2022";
|
|
14358
14576
|
var MAX_VALUE = 32;
|
|
14359
14577
|
var envList = addEnvTargetOptions(
|
|
14360
|
-
new
|
|
14578
|
+
new Command90("list").description("list environment variables \u2014 every scope at once without -t").configureHelp(helpConfig)
|
|
14361
14579
|
).action(
|
|
14362
14580
|
(raw) => runCommand(async () => {
|
|
14363
14581
|
const options = parseOptions(OptionsSchema5, raw);
|
|
@@ -14373,10 +14591,10 @@ var envList = addEnvTargetOptions(
|
|
|
14373
14591
|
local: async (ctx) => {
|
|
14374
14592
|
const keys = Object.keys(readLocalEnv(ctx.envFile)).sort();
|
|
14375
14593
|
if (keys.length === 0) {
|
|
14376
|
-
|
|
14594
|
+
p53.log.info(`No environment variables configured ${pc23.dim("(local)")}.`);
|
|
14377
14595
|
return;
|
|
14378
14596
|
}
|
|
14379
|
-
|
|
14597
|
+
p53.log.info(
|
|
14380
14598
|
`Environment ${pc23.dim("(local, .env)")}
|
|
14381
14599
|
|
|
14382
14600
|
${keys.map((k) => ` ${k}`).join("\n")}`
|
|
@@ -14386,11 +14604,11 @@ ${keys.map((k) => ` ${k}`).join("\n")}`
|
|
|
14386
14604
|
const stack = await resolveStack(ctx.session, ctx.appId, ctx.instance, ctx.preview);
|
|
14387
14605
|
const keys = Object.keys(stack.entries).sort();
|
|
14388
14606
|
if (keys.length === 0) {
|
|
14389
|
-
|
|
14607
|
+
p53.log.info(`No environment variables configured ${pc23.dim(`(${ctx.targetName})`)}.`);
|
|
14390
14608
|
return;
|
|
14391
14609
|
}
|
|
14392
14610
|
const width = Math.max(...keys.map((k) => k.length));
|
|
14393
|
-
|
|
14611
|
+
p53.log.info(
|
|
14394
14612
|
`Environment ${pc23.dim(`(${ctx.targetName}, as the app sees it)`)}
|
|
14395
14613
|
|
|
14396
14614
|
` + keys.map((key) => {
|
|
@@ -14405,11 +14623,11 @@ ${keys.map((k) => ` ${k}`).join("\n")}`
|
|
|
14405
14623
|
const keys = [...Object.keys(contents.secret), ...Object.keys(contents.public)].sort();
|
|
14406
14624
|
const where = `${ctx.layer}, ${ctx.server}`;
|
|
14407
14625
|
if (keys.length === 0) {
|
|
14408
|
-
|
|
14626
|
+
p53.log.info(`No environment variables configured ${pc23.dim(`(${where})`)}.`);
|
|
14409
14627
|
return;
|
|
14410
14628
|
}
|
|
14411
14629
|
const width = Math.max(...keys.map((k) => k.length));
|
|
14412
|
-
|
|
14630
|
+
p53.log.info(
|
|
14413
14631
|
`Environment ${pc23.dim(`(${where})`)}
|
|
14414
14632
|
|
|
14415
14633
|
` + keys.map(
|
|
@@ -14433,14 +14651,14 @@ async function listMatrix(raw) {
|
|
|
14433
14651
|
const app = readAppIdentity(workspaceRootDir);
|
|
14434
14652
|
const bindings = readBindings(workspaceRootDir);
|
|
14435
14653
|
const local = Object.keys(readLocalEnv(`${workspaceRootDir}/.env`)).sort();
|
|
14436
|
-
|
|
14654
|
+
p53.log.info(
|
|
14437
14655
|
local.length ? `Local ${pc23.dim("(.env, names only)")}
|
|
14438
14656
|
|
|
14439
14657
|
${local.map((k) => ` ${k}`).join("\n")}` : `No local environment ${pc23.dim("(.env)")}.`
|
|
14440
14658
|
);
|
|
14441
14659
|
const servers = [...new Set(Object.values(bindings).map((b) => b.server))];
|
|
14442
14660
|
if (!app || servers.length === 0) {
|
|
14443
|
-
|
|
14661
|
+
p53.log.info(`No target is bound to a server yet; ${pc23.cyan("vela deploy")} binds one.`);
|
|
14444
14662
|
return;
|
|
14445
14663
|
}
|
|
14446
14664
|
for (const server of servers) {
|
|
@@ -14479,7 +14697,7 @@ ${local.map((k) => ` ${k}`).join("\n")}` : `No local environment ${pc23.dim("(.
|
|
|
14479
14697
|
)
|
|
14480
14698
|
].sort();
|
|
14481
14699
|
if (keys.length === 0) {
|
|
14482
|
-
|
|
14700
|
+
p53.log.info(`No environment variables configured ${pc23.dim(`(${server})`)}.`);
|
|
14483
14701
|
return;
|
|
14484
14702
|
}
|
|
14485
14703
|
const rows = keys.map((key) => [
|
|
@@ -14491,7 +14709,7 @@ ${local.map((k) => ` ${k}`).join("\n")}` : `No local environment ${pc23.dim("(.
|
|
|
14491
14709
|
(h, i) => Math.max(h.length, ...rows.map((r) => plain(r[i]).length))
|
|
14492
14710
|
);
|
|
14493
14711
|
const line = (cells) => cells.map((c, i) => c + " ".repeat(widths[i] - plain(c).length)).join(" ");
|
|
14494
|
-
|
|
14712
|
+
p53.log.info(
|
|
14495
14713
|
`Environment ${pc23.dim(`(${server})`)}
|
|
14496
14714
|
|
|
14497
14715
|
${pc23.dim(line(headings))}
|
|
@@ -14517,17 +14735,17 @@ function matrixCell(key, columns, index, states) {
|
|
|
14517
14735
|
return pc23.dim("\u2014");
|
|
14518
14736
|
}
|
|
14519
14737
|
var ANSI3 = /\u001b\[[0-9;]*m/g;
|
|
14520
|
-
function plain(
|
|
14521
|
-
return
|
|
14738
|
+
function plain(text20) {
|
|
14739
|
+
return text20.replace(ANSI3, "");
|
|
14522
14740
|
}
|
|
14523
14741
|
|
|
14524
14742
|
// src/commands/env/set.ts
|
|
14525
14743
|
import process41 from "node:process";
|
|
14526
|
-
import { Command as
|
|
14527
|
-
import * as
|
|
14744
|
+
import { Command as Command91 } from "commander";
|
|
14745
|
+
import * as p54 from "@clack/prompts";
|
|
14528
14746
|
import pc24 from "picocolors";
|
|
14529
14747
|
var envSet = addEnvTargetOptions(
|
|
14530
|
-
new
|
|
14748
|
+
new Command91("set").description("set an environment variable \u2014 the value is prompted for, never an argument").argument("<key>", "variable name").option(
|
|
14531
14749
|
"--public",
|
|
14532
14750
|
"readable back with `vela env list` and `vela env get`; PUBLIC_* keys are public regardless"
|
|
14533
14751
|
).configureHelp(helpConfig)
|
|
@@ -14541,7 +14759,7 @@ var envSet = addEnvTargetOptions(
|
|
|
14541
14759
|
local: async (ctx) => {
|
|
14542
14760
|
const value = await promptValue2(key, "public");
|
|
14543
14761
|
setLocalEnv(ctx.envFile, key, value);
|
|
14544
|
-
|
|
14762
|
+
p54.log.success(`${key} updated ${pc24.dim("(local)")}`);
|
|
14545
14763
|
await applyLocalEnvChange(ctx, [key]);
|
|
14546
14764
|
},
|
|
14547
14765
|
instance: async (ctx) => {
|
|
@@ -14563,9 +14781,9 @@ var envSet = addEnvTargetOptions(
|
|
|
14563
14781
|
);
|
|
14564
14782
|
function report(key, visibility, moved, where) {
|
|
14565
14783
|
const tag = visibility === "public" ? " (public)" : "";
|
|
14566
|
-
|
|
14784
|
+
p54.log.success(`${key} updated${tag} ${pc24.dim(`(${where})`)}`);
|
|
14567
14785
|
if (moved) {
|
|
14568
|
-
|
|
14786
|
+
p54.log.info(
|
|
14569
14787
|
visibility === "public" ? `${key} was secret before; it is readable from now on.` : `${key} was public before; it is write-only from now on.`
|
|
14570
14788
|
);
|
|
14571
14789
|
}
|
|
@@ -14573,9 +14791,9 @@ function report(key, visibility, moved, where) {
|
|
|
14573
14791
|
async function promptValue2(key, visibility) {
|
|
14574
14792
|
const message = `Value for ${pc24.cyan(key)}${visibility === "public" ? pc24.dim(" (public)") : ""}`;
|
|
14575
14793
|
const validate = (input) => !input?.length ? "Required" : void 0;
|
|
14576
|
-
const value = visibility === "public" ? await
|
|
14577
|
-
if (
|
|
14578
|
-
|
|
14794
|
+
const value = visibility === "public" ? await p54.text({ message, validate }) : await p54.password({ message, validate });
|
|
14795
|
+
if (p54.isCancel(value)) {
|
|
14796
|
+
p54.cancel("Operation cancelled.");
|
|
14579
14797
|
process41.exit(0);
|
|
14580
14798
|
}
|
|
14581
14799
|
if (visibility === "secret" && isPublicKey(key)) {
|
|
@@ -14585,11 +14803,11 @@ async function promptValue2(key, visibility) {
|
|
|
14585
14803
|
}
|
|
14586
14804
|
|
|
14587
14805
|
// src/commands/env/unset.ts
|
|
14588
|
-
import { Command as
|
|
14589
|
-
import * as
|
|
14806
|
+
import { Command as Command92 } from "commander";
|
|
14807
|
+
import * as p55 from "@clack/prompts";
|
|
14590
14808
|
import pc25 from "picocolors";
|
|
14591
14809
|
var envUnset = addEnvTargetOptions(
|
|
14592
|
-
new
|
|
14810
|
+
new Command92("unset").description("remove an environment variable").argument("<key>", "variable name").configureHelp(helpConfig)
|
|
14593
14811
|
).action(
|
|
14594
14812
|
(key, raw) => runCommand(
|
|
14595
14813
|
() => withEnvScope(
|
|
@@ -14597,29 +14815,29 @@ var envUnset = addEnvTargetOptions(
|
|
|
14597
14815
|
{
|
|
14598
14816
|
local: async (ctx) => {
|
|
14599
14817
|
if (!(key in readLocalEnv(ctx.envFile))) {
|
|
14600
|
-
|
|
14818
|
+
p55.log.info(`${key} is not set \u2014 nothing to remove.`);
|
|
14601
14819
|
return;
|
|
14602
14820
|
}
|
|
14603
14821
|
unsetLocalEnv(ctx.envFile, key);
|
|
14604
|
-
|
|
14822
|
+
p55.log.success(`${key} removed ${pc25.dim("(local)")}`);
|
|
14605
14823
|
await applyLocalEnvChange(ctx, [key]);
|
|
14606
14824
|
},
|
|
14607
14825
|
// Removed from whichever side it was on; nobody should have to
|
|
14608
14826
|
// remember whether a key was public to take it out.
|
|
14609
14827
|
instance: async (ctx) => {
|
|
14610
14828
|
if (!await unsetInLayer(ctx.session, ctx.files, key)) {
|
|
14611
|
-
|
|
14829
|
+
p55.log.info(`${key} is not set on ${ctx.targetName} \u2014 nothing to remove.`);
|
|
14612
14830
|
return;
|
|
14613
14831
|
}
|
|
14614
|
-
|
|
14832
|
+
p55.log.success(`${key} removed ${pc25.dim(`(${ctx.targetName})`)}`);
|
|
14615
14833
|
await applyChange(ctx.workspaceRootDir, ctx, [key]);
|
|
14616
14834
|
},
|
|
14617
14835
|
layer: async (ctx) => {
|
|
14618
14836
|
if (!await unsetInLayer(ctx.session, ctx.files, key)) {
|
|
14619
|
-
|
|
14837
|
+
p55.log.info(`${key} is not set (${ctx.layer}, ${ctx.server}) \u2014 nothing to remove.`);
|
|
14620
14838
|
return;
|
|
14621
14839
|
}
|
|
14622
|
-
|
|
14840
|
+
p55.log.success(`${key} removed ${pc25.dim(`(${ctx.layer}, ${ctx.server})`)}`);
|
|
14623
14841
|
await applyChange(ctx.workspaceRootDir, ctx, [key]);
|
|
14624
14842
|
}
|
|
14625
14843
|
},
|
|
@@ -14633,11 +14851,11 @@ var envUnset = addEnvTargetOptions(
|
|
|
14633
14851
|
import fs55 from "node:fs";
|
|
14634
14852
|
import path60 from "node:path";
|
|
14635
14853
|
import process42 from "node:process";
|
|
14636
|
-
import { Command as
|
|
14637
|
-
import * as
|
|
14854
|
+
import { Command as Command93 } from "commander";
|
|
14855
|
+
import * as p56 from "@clack/prompts";
|
|
14638
14856
|
import pc26 from "picocolors";
|
|
14639
14857
|
var envImport = addEnvTargetOptions(
|
|
14640
|
-
new
|
|
14858
|
+
new Command93("import").description("merge a dotenv file into the environment").argument("<file>", "dotenv file to read").option("--public", "import as readable values; PUBLIC_* keys are public regardless").configureHelp(helpConfig)
|
|
14641
14859
|
).action(
|
|
14642
14860
|
(file, raw) => runCommand(
|
|
14643
14861
|
() => withEnvScope(
|
|
@@ -14651,12 +14869,12 @@ var envImport = addEnvTargetOptions(
|
|
|
14651
14869
|
const incoming = read(source, file);
|
|
14652
14870
|
const keys = Object.keys(incoming);
|
|
14653
14871
|
if (keys.length === 0) return;
|
|
14654
|
-
|
|
14872
|
+
p56.log.step(`Importing ${keys.length} variable(s) from ${pc26.cyan(file)}`);
|
|
14655
14873
|
editLocalEnv(
|
|
14656
14874
|
ctx.envFile,
|
|
14657
14875
|
(content) => keys.reduce((acc, key) => upsertEnvVar(acc, key, incoming[key]), content)
|
|
14658
14876
|
);
|
|
14659
|
-
|
|
14877
|
+
p56.log.success(`${keys.length} variable(s) updated ${pc26.dim("(local)")}`);
|
|
14660
14878
|
await applyLocalEnvChange(ctx, keys);
|
|
14661
14879
|
},
|
|
14662
14880
|
// Merge: values in the layer that the file does not mention stay put.
|
|
@@ -14664,7 +14882,7 @@ var envImport = addEnvTargetOptions(
|
|
|
14664
14882
|
const incoming = read(resolve(file), file);
|
|
14665
14883
|
const keys = Object.keys(incoming);
|
|
14666
14884
|
if (keys.length === 0) return;
|
|
14667
|
-
|
|
14885
|
+
p56.log.step(`Importing ${keys.length} variable(s) from ${pc26.cyan(file)}`);
|
|
14668
14886
|
const outcome = await importIntoLayer(
|
|
14669
14887
|
ctx.session,
|
|
14670
14888
|
ctx.files,
|
|
@@ -14678,7 +14896,7 @@ var envImport = addEnvTargetOptions(
|
|
|
14678
14896
|
const incoming = read(resolve(file), file);
|
|
14679
14897
|
const keys = Object.keys(incoming);
|
|
14680
14898
|
if (keys.length === 0) return;
|
|
14681
|
-
|
|
14899
|
+
p56.log.step(`Importing ${keys.length} variable(s) from ${pc26.cyan(file)}`);
|
|
14682
14900
|
const outcome = await importIntoLayer(
|
|
14683
14901
|
ctx.session,
|
|
14684
14902
|
ctx.files,
|
|
@@ -14699,7 +14917,7 @@ function report2(outcome, where) {
|
|
|
14699
14917
|
outcome.secret.length ? `${outcome.secret.length} secret` : "",
|
|
14700
14918
|
outcome.public.length ? `${outcome.public.length} public` : ""
|
|
14701
14919
|
].filter(Boolean);
|
|
14702
|
-
|
|
14920
|
+
p56.log.success(`${parts.join(", ")} variable(s) updated ${pc26.dim(`(${where})`)}`);
|
|
14703
14921
|
}
|
|
14704
14922
|
function resolve(file) {
|
|
14705
14923
|
return path60.resolve(process42.cwd(), file);
|
|
@@ -14707,17 +14925,17 @@ function resolve(file) {
|
|
|
14707
14925
|
function read(resolved, shown) {
|
|
14708
14926
|
if (!fs55.existsSync(resolved)) throw new Error(`${shown} does not exist.`);
|
|
14709
14927
|
const incoming = readLocalEnvFile(resolved);
|
|
14710
|
-
if (Object.keys(incoming).length === 0)
|
|
14928
|
+
if (Object.keys(incoming).length === 0) p56.log.info(`${shown} has no variables to import.`);
|
|
14711
14929
|
return incoming;
|
|
14712
14930
|
}
|
|
14713
14931
|
|
|
14714
14932
|
// src/commands/env/get.ts
|
|
14715
14933
|
import process43 from "node:process";
|
|
14716
|
-
import { Command as
|
|
14717
|
-
import * as
|
|
14934
|
+
import { Command as Command94 } from "commander";
|
|
14935
|
+
import * as p57 from "@clack/prompts";
|
|
14718
14936
|
import pc27 from "picocolors";
|
|
14719
14937
|
var envGet = addEnvTargetOptions(
|
|
14720
|
-
new
|
|
14938
|
+
new Command94("get").description("print a public environment variable").argument("<key>", "variable name").configureHelp(helpConfig)
|
|
14721
14939
|
).action(
|
|
14722
14940
|
(key, raw) => runCommand(
|
|
14723
14941
|
() => withEnvScope(
|
|
@@ -14757,7 +14975,7 @@ var envGet = addEnvTargetOptions(
|
|
|
14757
14975
|
)
|
|
14758
14976
|
);
|
|
14759
14977
|
function secret(key, where, from) {
|
|
14760
|
-
|
|
14978
|
+
p57.log.info(
|
|
14761
14979
|
`${key} is secret ${pc27.dim(`(${where}${from ? `, from ${from}` : ""})`)}, so it is not read back.
|
|
14762
14980
|
Set it again to change it: ${pc27.cyan(`vela env set ${key}`)}`
|
|
14763
14981
|
);
|
|
@@ -14765,14 +14983,14 @@ Set it again to change it: ${pc27.cyan(`vela env set ${key}`)}`
|
|
|
14765
14983
|
}
|
|
14766
14984
|
|
|
14767
14985
|
// src/commands/env.ts
|
|
14768
|
-
var env = new
|
|
14986
|
+
var env = new Command95("env").description("manage environment variables, locally or on a target").configureHelp(helpConfig).addCommand(envList).addCommand(envGet).addCommand(envSet).addCommand(envUnset).addCommand(envImport);
|
|
14769
14987
|
|
|
14770
14988
|
// src/commands/status.ts
|
|
14771
|
-
import { Command as
|
|
14772
|
-
import * as
|
|
14989
|
+
import { Command as Command96 } from "commander";
|
|
14990
|
+
import * as p58 from "@clack/prompts";
|
|
14773
14991
|
import pc28 from "picocolors";
|
|
14774
14992
|
var status = addTargetOptions(
|
|
14775
|
-
new
|
|
14993
|
+
new Command96("status").description("show what is deployed").configureHelp(helpConfig),
|
|
14776
14994
|
"production"
|
|
14777
14995
|
).option("--all", "show every app on the server, not just this project").option("--json", "print raw JSON").action(
|
|
14778
14996
|
(raw) => runCommand(async () => {
|
|
@@ -14803,11 +15021,11 @@ function report3(states, json2) {
|
|
|
14803
15021
|
return;
|
|
14804
15022
|
}
|
|
14805
15023
|
if (states.length === 0) {
|
|
14806
|
-
|
|
15024
|
+
p58.log.info("Nothing is deployed here yet.");
|
|
14807
15025
|
return;
|
|
14808
15026
|
}
|
|
14809
15027
|
for (const state of states) {
|
|
14810
|
-
|
|
15028
|
+
p58.log.info(describe2(state));
|
|
14811
15029
|
}
|
|
14812
15030
|
}
|
|
14813
15031
|
function describe2(state) {
|
|
@@ -14831,12 +15049,12 @@ function describe2(state) {
|
|
|
14831
15049
|
}
|
|
14832
15050
|
|
|
14833
15051
|
// src/commands/rollback.ts
|
|
14834
|
-
import { Command as
|
|
14835
|
-
import * as
|
|
15052
|
+
import { Command as Command97 } from "commander";
|
|
15053
|
+
import * as p59 from "@clack/prompts";
|
|
14836
15054
|
import pc29 from "picocolors";
|
|
14837
15055
|
var rollback = addLockWaitOption(
|
|
14838
15056
|
addTargetOptions(
|
|
14839
|
-
new
|
|
15057
|
+
new Command97("rollback").description("put the previous release back").configureHelp(helpConfig),
|
|
14840
15058
|
"production"
|
|
14841
15059
|
)
|
|
14842
15060
|
).option("--to <release>", "roll back to a specific release instead of the previous one").action(
|
|
@@ -14846,7 +15064,7 @@ var rollback = addLockWaitOption(
|
|
|
14846
15064
|
raw,
|
|
14847
15065
|
{
|
|
14848
15066
|
remote: async (ctx) => {
|
|
14849
|
-
|
|
15067
|
+
p59.log.step(
|
|
14850
15068
|
`Rolling back ${pc29.cyan(ctx.appName)} ${pc29.dim(`(${ctx.targetName})`)} on ${ctx.server}`
|
|
14851
15069
|
);
|
|
14852
15070
|
const result = await runServerScript(
|
|
@@ -14861,7 +15079,7 @@ var rollback = addLockWaitOption(
|
|
|
14861
15079
|
stream: true
|
|
14862
15080
|
}
|
|
14863
15081
|
);
|
|
14864
|
-
|
|
15082
|
+
p59.log.success(
|
|
14865
15083
|
`Rolled back to ${pc29.cyan(result?.release ?? "the previous release")}` + (result?.from ? ` ${pc29.dim(`(was ${result.from})`)}` : "")
|
|
14866
15084
|
);
|
|
14867
15085
|
}
|
|
@@ -14875,7 +15093,7 @@ var rollback = addLockWaitOption(
|
|
|
14875
15093
|
);
|
|
14876
15094
|
|
|
14877
15095
|
// src/commands/logs.ts
|
|
14878
|
-
import { Command as
|
|
15096
|
+
import { Command as Command98 } from "commander";
|
|
14879
15097
|
|
|
14880
15098
|
// src/lib/remote-pocketbase.ts
|
|
14881
15099
|
import PocketBase6 from "pocketbase";
|
|
@@ -14926,7 +15144,7 @@ async function withRemotePocketbase(session, instance, fn) {
|
|
|
14926
15144
|
|
|
14927
15145
|
// src/commands/logs.ts
|
|
14928
15146
|
var logs = addTargetOptions(
|
|
14929
|
-
new
|
|
15147
|
+
new Command98("logs").description("tail the logs of a deployed app").configureHelp(helpConfig),
|
|
14930
15148
|
"production"
|
|
14931
15149
|
).option("-f, --follow", "keep streaming new output").option("-n, --lines <count>", "how many lines of history to show", "100").option("--pocketbase", "show the PocketBase service instead of the app").action(
|
|
14932
15150
|
(raw) => runCommand(async () => {
|
|
@@ -14961,16 +15179,16 @@ var logs = addTargetOptions(
|
|
|
14961
15179
|
);
|
|
14962
15180
|
|
|
14963
15181
|
// src/commands/admin.ts
|
|
14964
|
-
import { Command as
|
|
15182
|
+
import { Command as Command100 } from "commander";
|
|
14965
15183
|
|
|
14966
15184
|
// src/commands/admin/create.ts
|
|
14967
15185
|
import process44 from "node:process";
|
|
14968
|
-
import { Command as
|
|
14969
|
-
import * as
|
|
15186
|
+
import { Command as Command99 } from "commander";
|
|
15187
|
+
import * as p60 from "@clack/prompts";
|
|
14970
15188
|
import pc30 from "picocolors";
|
|
14971
15189
|
var MIN_PASSWORD = 10;
|
|
14972
15190
|
var adminCreate = addTargetOptions(
|
|
14973
|
-
new
|
|
15191
|
+
new Command99("create").description("create a login for the admin panel").argument("[email]", "email to sign in with \u2014 prompted for when omitted").configureHelp(helpConfig),
|
|
14974
15192
|
"local"
|
|
14975
15193
|
).action(
|
|
14976
15194
|
(email2, raw) => runCommand(
|
|
@@ -15005,7 +15223,7 @@ Run ${pc30.cyan("vela enable backend")} to add one.`
|
|
|
15005
15223
|
const metadata = getPocketbaseMetadata(ctx.workspaceRootDir);
|
|
15006
15224
|
if (metadata) signIn = `http://${metadata.viteHost}:${metadata.vitePort}`;
|
|
15007
15225
|
}
|
|
15008
|
-
|
|
15226
|
+
p60.log.info(
|
|
15009
15227
|
signIn ? `Sign in at ${pc30.cyan(`${signIn}/admin`)}` : `Sign in at ${pc30.cyan("/admin")} once ${pc30.cyan("vela dev")} is running.`
|
|
15010
15228
|
);
|
|
15011
15229
|
},
|
|
@@ -15020,7 +15238,7 @@ Run ${pc30.cyan("vela enable backend")} to add one.`
|
|
|
15020
15238
|
(pb) => upsertSuperuser2(pb, address, password8)
|
|
15021
15239
|
);
|
|
15022
15240
|
const base2 = state?.domain ? `https://${state.domain.split(",")[0].trim()}` : "";
|
|
15023
|
-
|
|
15241
|
+
p60.log.info(
|
|
15024
15242
|
base2 ? `Sign in at ${pc30.cyan(`${base2}/admin`)}` : `Sign in at ${pc30.cyan("/admin")} once a domain is configured for this target.`
|
|
15025
15243
|
);
|
|
15026
15244
|
}
|
|
@@ -15033,20 +15251,20 @@ Run ${pc30.cyan("vela enable backend")} to add one.`
|
|
|
15033
15251
|
async function upsertSuperuser2(pb, email2, password8) {
|
|
15034
15252
|
const existing = await findSuperuser(pb, email2);
|
|
15035
15253
|
if (existing) {
|
|
15036
|
-
const confirmed = await
|
|
15254
|
+
const confirmed = await p60.confirm({
|
|
15037
15255
|
message: `${email2} already has an account, update its password?`,
|
|
15038
15256
|
initialValue: false
|
|
15039
15257
|
});
|
|
15040
|
-
if (
|
|
15041
|
-
|
|
15258
|
+
if (p60.isCancel(confirmed) || !confirmed) {
|
|
15259
|
+
p60.cancel("Operation cancelled.");
|
|
15042
15260
|
process44.exit(0);
|
|
15043
15261
|
}
|
|
15044
15262
|
await pb.collection("_superusers").update(existing, { password: password8, passwordConfirm: password8 });
|
|
15045
|
-
|
|
15263
|
+
p60.log.success(`Password updated for ${pc30.cyan(email2)}, you can sign in now`);
|
|
15046
15264
|
return;
|
|
15047
15265
|
}
|
|
15048
15266
|
await pb.collection("_superusers").create({ email: email2, password: password8, passwordConfirm: password8 });
|
|
15049
|
-
|
|
15267
|
+
p60.log.success(`${pc30.cyan(email2)} can now sign in`);
|
|
15050
15268
|
}
|
|
15051
15269
|
async function findSuperuser(pb, email2) {
|
|
15052
15270
|
try {
|
|
@@ -15057,47 +15275,47 @@ async function findSuperuser(pb, email2) {
|
|
|
15057
15275
|
}
|
|
15058
15276
|
}
|
|
15059
15277
|
async function promptEmail() {
|
|
15060
|
-
const value = await
|
|
15278
|
+
const value = await p60.text({
|
|
15061
15279
|
message: "Email to sign in with",
|
|
15062
15280
|
validate: (input) => input?.includes("@") ? void 0 : "An email address is required"
|
|
15063
15281
|
});
|
|
15064
|
-
if (
|
|
15065
|
-
|
|
15282
|
+
if (p60.isCancel(value)) {
|
|
15283
|
+
p60.cancel("Operation cancelled.");
|
|
15066
15284
|
process44.exit(0);
|
|
15067
15285
|
}
|
|
15068
15286
|
return value.trim();
|
|
15069
15287
|
}
|
|
15070
15288
|
async function promptPassword() {
|
|
15071
|
-
const value = await
|
|
15289
|
+
const value = await p60.password({
|
|
15072
15290
|
message: "Password",
|
|
15073
15291
|
validate: (input) => (input?.length ?? 0) >= MIN_PASSWORD ? void 0 : `At least ${MIN_PASSWORD} characters is required`
|
|
15074
15292
|
});
|
|
15075
|
-
if (
|
|
15076
|
-
|
|
15293
|
+
if (p60.isCancel(value)) {
|
|
15294
|
+
p60.cancel("Operation cancelled.");
|
|
15077
15295
|
process44.exit(0);
|
|
15078
15296
|
}
|
|
15079
|
-
const again = await
|
|
15297
|
+
const again = await p60.password({
|
|
15080
15298
|
message: "Password again",
|
|
15081
15299
|
validate: (input) => input === value ? void 0 : "The two do not match"
|
|
15082
15300
|
});
|
|
15083
|
-
if (
|
|
15084
|
-
|
|
15301
|
+
if (p60.isCancel(again)) {
|
|
15302
|
+
p60.cancel("Operation cancelled.");
|
|
15085
15303
|
process44.exit(0);
|
|
15086
15304
|
}
|
|
15087
15305
|
return value;
|
|
15088
15306
|
}
|
|
15089
15307
|
|
|
15090
15308
|
// src/commands/admin.ts
|
|
15091
|
-
var admin = new
|
|
15309
|
+
var admin = new Command100("admin").description("manage admin panel logins").configureHelp(helpConfig).addCommand(adminCreate);
|
|
15092
15310
|
|
|
15093
15311
|
// src/commands/backup.ts
|
|
15094
|
-
import { Command as
|
|
15312
|
+
import { Command as Command106 } from "commander";
|
|
15095
15313
|
|
|
15096
15314
|
// src/commands/backup/create.ts
|
|
15097
15315
|
import fs56 from "node:fs";
|
|
15098
15316
|
import path61 from "node:path";
|
|
15099
|
-
import { Command as
|
|
15100
|
-
import * as
|
|
15317
|
+
import { Command as Command101 } from "commander";
|
|
15318
|
+
import * as p61 from "@clack/prompts";
|
|
15101
15319
|
import pc32 from "picocolors";
|
|
15102
15320
|
|
|
15103
15321
|
// src/lib/backup-target.ts
|
|
@@ -15245,7 +15463,7 @@ async function writeSchedule(pb, cron, maxKeep) {
|
|
|
15245
15463
|
// src/commands/backup/create.ts
|
|
15246
15464
|
var DEFAULT_BACKUP_DIR = "backups";
|
|
15247
15465
|
var backupCreate = addTargetOptions(
|
|
15248
|
-
new
|
|
15466
|
+
new Command101("create").description("take a backup of the database and uploads").argument("[name]", "name for the archive \u2014 generated when omitted").option("-o, --output <dir>", "where to save the archive", DEFAULT_BACKUP_DIR).option("--no-download", "leave the archive on the server").configureHelp(helpConfig),
|
|
15249
15467
|
"production"
|
|
15250
15468
|
).action(
|
|
15251
15469
|
(name, raw) => runCommand(() => {
|
|
@@ -15261,7 +15479,7 @@ Backup names are lowercase letters, digits, ${pc32.cyan("-")} and ${pc32.cyan("_
|
|
|
15261
15479
|
}
|
|
15262
15480
|
const storage = await readStorageSettings(ctx.pb);
|
|
15263
15481
|
if (storage.s3Enabled) {
|
|
15264
|
-
|
|
15482
|
+
p61.log.warn(
|
|
15265
15483
|
`Uploads are stored in S3, so this archive holds the database only.
|
|
15266
15484
|
|
|
15267
15485
|
PocketBase leaves ${pc32.cyan("storage/")} out of a backup whenever S3 is on.
|
|
@@ -15269,7 +15487,7 @@ Your bucket's own versioning is what protects the uploaded files.`
|
|
|
15269
15487
|
);
|
|
15270
15488
|
}
|
|
15271
15489
|
if (ctx.session) await checkpointAppDatabases(ctx.session, ctx.instance);
|
|
15272
|
-
const spinner9 =
|
|
15490
|
+
const spinner9 = p61.spinner();
|
|
15273
15491
|
spinner9.start(`Backing up ${ctx.targetName}`);
|
|
15274
15492
|
try {
|
|
15275
15493
|
await createBackup(ctx.pb, key);
|
|
@@ -15316,7 +15534,7 @@ async function download(ctx, key, outputDir) {
|
|
|
15316
15534
|
fs56.copyFileSync(path61.join(ctx.workspaceRootDir, "data", "backups", key), destination);
|
|
15317
15535
|
return path61.relative(ctx.workspaceRootDir, destination);
|
|
15318
15536
|
}
|
|
15319
|
-
const spinner9 =
|
|
15537
|
+
const spinner9 = p61.spinner();
|
|
15320
15538
|
spinner9.start(`Downloading ${key}`);
|
|
15321
15539
|
try {
|
|
15322
15540
|
await ctx.session.download(remotePaths.backup(ctx.instance, key), destination);
|
|
@@ -15329,18 +15547,18 @@ async function download(ctx, key, outputDir) {
|
|
|
15329
15547
|
}
|
|
15330
15548
|
|
|
15331
15549
|
// src/commands/backup/list.ts
|
|
15332
|
-
import { Command as
|
|
15333
|
-
import * as
|
|
15550
|
+
import { Command as Command102 } from "commander";
|
|
15551
|
+
import * as p62 from "@clack/prompts";
|
|
15334
15552
|
import pc33 from "picocolors";
|
|
15335
15553
|
var backupList = addTargetOptions(
|
|
15336
|
-
new
|
|
15554
|
+
new Command102("list").description("list the backups on a target").configureHelp(helpConfig),
|
|
15337
15555
|
"production"
|
|
15338
15556
|
).action(
|
|
15339
15557
|
(raw) => runCommand(
|
|
15340
15558
|
() => withBackupTarget(raw, "backup list", async (ctx) => {
|
|
15341
15559
|
const backups = await listBackups(ctx.pb);
|
|
15342
15560
|
if (backups.length === 0) {
|
|
15343
|
-
|
|
15561
|
+
p62.log.info(
|
|
15344
15562
|
`${pc33.cyan(ctx.targetName)} has no backups yet.
|
|
15345
15563
|
|
|
15346
15564
|
Take one with ${pc33.cyan("vela backup create")}.`
|
|
@@ -15348,7 +15566,7 @@ Take one with ${pc33.cyan("vela backup create")}.`
|
|
|
15348
15566
|
return;
|
|
15349
15567
|
}
|
|
15350
15568
|
const width = Math.max(...backups.map((b) => b.key.length));
|
|
15351
|
-
|
|
15569
|
+
p62.log.message(
|
|
15352
15570
|
backups.map(
|
|
15353
15571
|
(b) => `${b.key.padEnd(width)} ${pc33.dim(formatBytes(b.size).padStart(8))} ${pc33.dim(b.modified)}`
|
|
15354
15572
|
).join("\n")
|
|
@@ -15361,11 +15579,11 @@ Take one with ${pc33.cyan("vela backup create")}.`
|
|
|
15361
15579
|
// src/commands/backup/download.ts
|
|
15362
15580
|
import fs57 from "node:fs";
|
|
15363
15581
|
import path62 from "node:path";
|
|
15364
|
-
import { Command as
|
|
15365
|
-
import * as
|
|
15582
|
+
import { Command as Command103 } from "commander";
|
|
15583
|
+
import * as p63 from "@clack/prompts";
|
|
15366
15584
|
import pc34 from "picocolors";
|
|
15367
15585
|
var backupDownload = addTargetOptions(
|
|
15368
|
-
new
|
|
15586
|
+
new Command103("download").description("save a backup off the server").argument("<key>", "archive to download, as shown by `vela backup list`").option("-o, --output <dir>", "where to save the archive", DEFAULT_BACKUP_DIR).configureHelp(helpConfig),
|
|
15369
15587
|
"production"
|
|
15370
15588
|
).action(
|
|
15371
15589
|
(key, raw) => runCommand(() => {
|
|
@@ -15393,7 +15611,7 @@ Fetch it from the bucket directly \u2014 vela does not hold its credentials.`
|
|
|
15393
15611
|
if (!ctx.session) {
|
|
15394
15612
|
fs57.copyFileSync(path62.join(ctx.workspaceRootDir, "data", "backups", key), destination);
|
|
15395
15613
|
} else {
|
|
15396
|
-
const spinner9 =
|
|
15614
|
+
const spinner9 = p63.spinner();
|
|
15397
15615
|
spinner9.start(`Downloading ${key} (${formatBytes(found.size)})`);
|
|
15398
15616
|
try {
|
|
15399
15617
|
await ctx.session.download(remotePaths.backup(ctx.instance, key), destination);
|
|
@@ -15413,11 +15631,11 @@ Fetch it from the bucket directly \u2014 vela does not hold its credentials.`
|
|
|
15413
15631
|
|
|
15414
15632
|
// src/commands/backup/delete.ts
|
|
15415
15633
|
import process45 from "node:process";
|
|
15416
|
-
import { Command as
|
|
15417
|
-
import * as
|
|
15634
|
+
import { Command as Command104 } from "commander";
|
|
15635
|
+
import * as p64 from "@clack/prompts";
|
|
15418
15636
|
import pc35 from "picocolors";
|
|
15419
15637
|
var backupDelete = addTargetOptions(
|
|
15420
|
-
new
|
|
15638
|
+
new Command104("delete").description("remove a backup from a target").argument("<key>", "archive to delete, as shown by `vela backup list`").option("-y, --yes", "skip the confirmation").configureHelp(helpConfig),
|
|
15421
15639
|
"production"
|
|
15422
15640
|
).action(
|
|
15423
15641
|
(key, raw) => runCommand(() => {
|
|
@@ -15432,12 +15650,12 @@ Run ${pc35.cyan("vela backup list")} to see what it does have.`
|
|
|
15432
15650
|
);
|
|
15433
15651
|
}
|
|
15434
15652
|
if (!options.yes) {
|
|
15435
|
-
const confirmed = await
|
|
15653
|
+
const confirmed = await p64.confirm({
|
|
15436
15654
|
message: `Delete ${key} (${formatBytes(found.size)}) from ${ctx.targetName}?`,
|
|
15437
15655
|
initialValue: false
|
|
15438
15656
|
});
|
|
15439
|
-
if (
|
|
15440
|
-
|
|
15657
|
+
if (p64.isCancel(confirmed) || !confirmed) {
|
|
15658
|
+
p64.cancel("Operation cancelled.");
|
|
15441
15659
|
process45.exit(0);
|
|
15442
15660
|
}
|
|
15443
15661
|
}
|
|
@@ -15448,12 +15666,12 @@ Run ${pc35.cyan("vela backup list")} to see what it does have.`
|
|
|
15448
15666
|
);
|
|
15449
15667
|
|
|
15450
15668
|
// src/commands/backup/schedule.ts
|
|
15451
|
-
import { Command as
|
|
15452
|
-
import * as
|
|
15669
|
+
import { Command as Command105 } from "commander";
|
|
15670
|
+
import * as p65 from "@clack/prompts";
|
|
15453
15671
|
import pc36 from "picocolors";
|
|
15454
15672
|
var DEFAULT_KEEP = 7;
|
|
15455
15673
|
var backupSchedule = addTargetOptions(
|
|
15456
|
-
new
|
|
15674
|
+
new Command105("schedule").description("back up automatically on a schedule").argument("[cron]", "when to run, as a cron expression \u2014 shows the current one when omitted").option("--keep <n>", "how many scheduled archives to keep", String(DEFAULT_KEEP)).option("--off", "stop backing up automatically").configureHelp(helpConfig),
|
|
15457
15675
|
"production"
|
|
15458
15676
|
).action(
|
|
15459
15677
|
(cron, raw) => runCommand(() => {
|
|
@@ -15466,7 +15684,7 @@ var backupSchedule = addTargetOptions(
|
|
|
15466
15684
|
}
|
|
15467
15685
|
if (!cron) {
|
|
15468
15686
|
const current = await readSchedule(ctx.pb);
|
|
15469
|
-
|
|
15687
|
+
p65.log.info(
|
|
15470
15688
|
current.cron ? `${ctx.targetName} backs up on ${pc36.cyan(current.cron)}, keeping ${current.maxKeep}.` : `${ctx.targetName} has no backup schedule.
|
|
15471
15689
|
|
|
15472
15690
|
Set one with ${pc36.cyan('vela backup schedule "0 3 * * *"')}.`
|
|
@@ -15497,18 +15715,18 @@ Set one with ${pc36.cyan('vela backup schedule "0 3 * * *"')}.`
|
|
|
15497
15715
|
);
|
|
15498
15716
|
|
|
15499
15717
|
// src/commands/backup.ts
|
|
15500
|
-
var backup = new
|
|
15718
|
+
var backup = new Command106("backup").description("back up the database and uploads, locally or on a target").configureHelp(helpConfig).addCommand(backupCreate).addCommand(backupList).addCommand(backupDownload).addCommand(backupDelete).addCommand(backupSchedule);
|
|
15501
15719
|
|
|
15502
15720
|
// src/commands/restore.ts
|
|
15503
15721
|
import fs58 from "node:fs";
|
|
15504
15722
|
import path63 from "node:path";
|
|
15505
15723
|
import process46 from "node:process";
|
|
15506
|
-
import { Command as
|
|
15507
|
-
import * as
|
|
15724
|
+
import { Command as Command107 } from "commander";
|
|
15725
|
+
import * as p66 from "@clack/prompts";
|
|
15508
15726
|
import pc37 from "picocolors";
|
|
15509
15727
|
var restore = addLockWaitOption(
|
|
15510
15728
|
addTargetOptions(
|
|
15511
|
-
new
|
|
15729
|
+
new Command107("restore").description("replace a deployment\u2019s database and uploads from a backup").argument("[source]", "a backup key on the target, or a path to a local archive").configureHelp(helpConfig),
|
|
15512
15730
|
"production"
|
|
15513
15731
|
)
|
|
15514
15732
|
).option("-y, --yes", "skip the confirmation prompt").option("--no-migrate", "do not run migrations against the restored database").option("--keep-previous <n>", "how many replaced databases to keep", "1").action(
|
|
@@ -15552,18 +15770,18 @@ Run \`vela deploy\` first, then restore.`
|
|
|
15552
15770
|
],
|
|
15553
15771
|
stream: true
|
|
15554
15772
|
});
|
|
15555
|
-
|
|
15773
|
+
p66.log.success(
|
|
15556
15774
|
`Restored ${pc37.cyan(`${ctx.appName} (${ctx.targetName})`)} from ${pc37.cyan(
|
|
15557
15775
|
local ? path63.basename(local) : key
|
|
15558
15776
|
)}.`
|
|
15559
15777
|
);
|
|
15560
15778
|
if (result?.storageCarriedOver) {
|
|
15561
|
-
|
|
15779
|
+
p66.log.info(
|
|
15562
15780
|
"The archive held no uploads, so the files already on the server were kept."
|
|
15563
15781
|
);
|
|
15564
15782
|
}
|
|
15565
15783
|
if (result?.previousDataDir) {
|
|
15566
|
-
|
|
15784
|
+
p66.log.info(
|
|
15567
15785
|
`The database this replaced is at ${pc37.cyan(result.previousDataDir)}.
|
|
15568
15786
|
|
|
15569
15787
|
It is the only way back. Remove it once you are satisfied with the restore.`
|
|
@@ -15604,7 +15822,7 @@ Run ${pc37.cyan("vela backup list")} to see what it does have.`
|
|
|
15604
15822
|
Take one with ${pc37.cyan("vela backup create")}, or pass the path to an archive on this machine.`
|
|
15605
15823
|
);
|
|
15606
15824
|
}
|
|
15607
|
-
const chosen = await
|
|
15825
|
+
const chosen = await p66.select({
|
|
15608
15826
|
message: `Which backup should ${ctx.targetName} be restored from?`,
|
|
15609
15827
|
options: backups.map((b) => ({
|
|
15610
15828
|
value: b.key,
|
|
@@ -15612,8 +15830,8 @@ Take one with ${pc37.cyan("vela backup create")}, or pass the path to an archive
|
|
|
15612
15830
|
hint: `${formatBytes(b.size)}, ${b.modified}`
|
|
15613
15831
|
}))
|
|
15614
15832
|
});
|
|
15615
|
-
if (
|
|
15616
|
-
|
|
15833
|
+
if (p66.isCancel(chosen)) {
|
|
15834
|
+
p66.cancel("Operation cancelled.");
|
|
15617
15835
|
process46.exit(0);
|
|
15618
15836
|
}
|
|
15619
15837
|
return chosen;
|
|
@@ -15621,7 +15839,7 @@ Take one with ${pc37.cyan("vela backup create")}, or pass the path to an archive
|
|
|
15621
15839
|
async function stage(ctx, file) {
|
|
15622
15840
|
const dir = remotePaths.restoreStage(ctx.instance);
|
|
15623
15841
|
const remote = `${dir}/${path63.basename(file)}`;
|
|
15624
|
-
const spinner9 =
|
|
15842
|
+
const spinner9 = p66.spinner();
|
|
15625
15843
|
spinner9.start(`Uploading ${path63.basename(file)}`);
|
|
15626
15844
|
try {
|
|
15627
15845
|
await ctx.session.script(`mkdir -p "$1"`, { args: [dir] });
|
|
@@ -15636,29 +15854,29 @@ async function stage(ctx, file) {
|
|
|
15636
15854
|
async function confirm14(appName, targetName, envTag, from) {
|
|
15637
15855
|
const what = `${pc37.cyan(`${appName} (${targetName})`)} from ${pc37.cyan(path63.basename(from))}`;
|
|
15638
15856
|
if (isProd(envTag)) {
|
|
15639
|
-
const answer = await
|
|
15857
|
+
const answer = await p66.text({
|
|
15640
15858
|
message: `This replaces the database and uploads of ${what}. Type the app name to confirm`,
|
|
15641
15859
|
validate: (value) => value === appName ? void 0 : `Type ${appName} to confirm`
|
|
15642
15860
|
});
|
|
15643
|
-
if (
|
|
15644
|
-
|
|
15861
|
+
if (p66.isCancel(answer)) {
|
|
15862
|
+
p66.cancel("Operation cancelled.");
|
|
15645
15863
|
process46.exit(0);
|
|
15646
15864
|
}
|
|
15647
15865
|
return;
|
|
15648
15866
|
}
|
|
15649
|
-
const ok = await
|
|
15867
|
+
const ok = await p66.confirm({
|
|
15650
15868
|
message: `Replace the database and uploads of ${what}?`,
|
|
15651
15869
|
initialValue: false
|
|
15652
15870
|
});
|
|
15653
|
-
if (
|
|
15654
|
-
|
|
15871
|
+
if (p66.isCancel(ok) || !ok) {
|
|
15872
|
+
p66.cancel("Operation cancelled.");
|
|
15655
15873
|
process46.exit(0);
|
|
15656
15874
|
}
|
|
15657
15875
|
}
|
|
15658
15876
|
|
|
15659
15877
|
// src/commands/targets.ts
|
|
15660
|
-
import { Command as
|
|
15661
|
-
import * as
|
|
15878
|
+
import { Command as Command108 } from "commander";
|
|
15879
|
+
import * as p67 from "@clack/prompts";
|
|
15662
15880
|
import pc38 from "picocolors";
|
|
15663
15881
|
import * as v13 from "valibot";
|
|
15664
15882
|
var OptionsSchema6 = v13.object({
|
|
@@ -15667,7 +15885,7 @@ var OptionsSchema6 = v13.object({
|
|
|
15667
15885
|
offline: v13.optional(v13.boolean())
|
|
15668
15886
|
});
|
|
15669
15887
|
var targets = addSshOptions(
|
|
15670
|
-
new
|
|
15888
|
+
new Command108("targets").description("list the targets this project can deploy to").configureHelp(helpConfig)
|
|
15671
15889
|
).option("--json", "print raw JSON").option("--offline", "skip connecting to servers").action(
|
|
15672
15890
|
(raw) => runCommand(async () => {
|
|
15673
15891
|
const options = parseOptions(OptionsSchema6, raw);
|
|
@@ -15732,11 +15950,11 @@ function report4(rows, offline) {
|
|
|
15732
15950
|
const lines = rows.map(
|
|
15733
15951
|
(row) => `${row.kind === "local" ? pc38.dim(row.target.padEnd(target)) : pc38.cyan(row.target.padEnd(target))} ${row.server.padEnd(server)} ${row.domain.padEnd(domain)} ${row.release}`
|
|
15734
15952
|
);
|
|
15735
|
-
|
|
15953
|
+
p67.log.info(`${pc38.dim(header)}
|
|
15736
15954
|
${lines.join("\n")}`);
|
|
15737
15955
|
const unreachable = rows.filter((row) => row.kind === "remote" && !row.reachable);
|
|
15738
15956
|
if (!offline && unreachable.length > 0) {
|
|
15739
|
-
|
|
15957
|
+
p67.log.warn(
|
|
15740
15958
|
`Could not reach ${unreachable.map((row) => row.server).join(", ")}.
|
|
15741
15959
|
Release and domain are shown from what this project recorded.`
|
|
15742
15960
|
);
|
|
@@ -15746,14 +15964,14 @@ Release and domain are shown from what this project recorded.`
|
|
|
15746
15964
|
// src/commands/test.ts
|
|
15747
15965
|
import path64 from "node:path";
|
|
15748
15966
|
import process47 from "node:process";
|
|
15749
|
-
import { Command as
|
|
15967
|
+
import { Command as Command109 } from "commander";
|
|
15750
15968
|
import PocketBase7 from "pocketbase";
|
|
15751
15969
|
import pc39 from "picocolors";
|
|
15752
15970
|
import { x as x6 } from "tinyexec";
|
|
15753
15971
|
import { detect as detect9 } from "package-manager-detector";
|
|
15754
15972
|
import { resolveCommand as resolveCommand7 } from "package-manager-detector/commands";
|
|
15755
15973
|
import fs59 from "node:fs";
|
|
15756
|
-
var testServer = new
|
|
15974
|
+
var testServer = new Command109("test:server").description("run server tests").allowUnknownOption(true).allowExcessArguments(true).configureHelp(helpConfig).action(async (_opts, cmd) => {
|
|
15757
15975
|
const cwd = process47.cwd();
|
|
15758
15976
|
warnIfKit2(cwd, (m) => console.warn(pc39.yellow(`\u25B2 ${m}`)));
|
|
15759
15977
|
const email2 = `test-${Math.random().toString(36).slice(2)}@example.com`;
|
|
@@ -15897,7 +16115,7 @@ function stubPagesPlugin() {
|
|
|
15897
16115
|
// src/commands/routes.ts
|
|
15898
16116
|
import fs60 from "node:fs";
|
|
15899
16117
|
import path65 from "node:path";
|
|
15900
|
-
import { Command as
|
|
16118
|
+
import { Command as Command110 } from "commander";
|
|
15901
16119
|
var HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
15902
16120
|
"GET",
|
|
15903
16121
|
"POST",
|
|
@@ -15908,7 +16126,7 @@ var HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
|
15908
16126
|
"HEAD",
|
|
15909
16127
|
"fallback"
|
|
15910
16128
|
]);
|
|
15911
|
-
var routes = new
|
|
16129
|
+
var routes = new Command110("routes").description("list routes").configureHelp(helpConfig).action(async () => {
|
|
15912
16130
|
const { workspaceRootDir, routesDir } = await getWorkspace();
|
|
15913
16131
|
const routesRoot = path65.join(workspaceRootDir, routesDir);
|
|
15914
16132
|
const found = walk(routesRoot, routesRoot).filter((r) => r.methods.length > 0);
|
|
@@ -15986,7 +16204,7 @@ function printTable(routes2) {
|
|
|
15986
16204
|
import fs61 from "node:fs";
|
|
15987
16205
|
import path66 from "node:path";
|
|
15988
16206
|
import process48 from "node:process";
|
|
15989
|
-
import { Command as
|
|
16207
|
+
import { Command as Command111 } from "commander";
|
|
15990
16208
|
import { x as x7 } from "tinyexec";
|
|
15991
16209
|
import { detect as detect10 } from "package-manager-detector";
|
|
15992
16210
|
import { resolveCommand as resolveCommand8 } from "package-manager-detector/commands";
|
|
@@ -16005,24 +16223,24 @@ async function runWuchale(extraArgs) {
|
|
|
16005
16223
|
throwOnError: true
|
|
16006
16224
|
});
|
|
16007
16225
|
}
|
|
16008
|
-
var extract2 = new
|
|
16009
|
-
var watch = new
|
|
16010
|
-
var status2 = new
|
|
16011
|
-
var clean = new
|
|
16012
|
-
var i18n3 = new
|
|
16226
|
+
var extract2 = new Command111("extract").description("extract translatable strings").configureHelp(helpConfig).action(() => runCommand(() => runWuchale([])));
|
|
16227
|
+
var watch = new Command111("watch").description("watch and extract translatable strings").configureHelp(helpConfig).action(() => runCommand(() => runWuchale(["--watch"])));
|
|
16228
|
+
var status2 = new Command111("status").description("show i18n status").configureHelp(helpConfig).action(() => runCommand(() => runWuchale(["status"])));
|
|
16229
|
+
var clean = new Command111("clean").description("clean unused translatable strings").configureHelp(helpConfig).action(() => runCommand(() => runWuchale(["--clean"])));
|
|
16230
|
+
var i18n3 = new Command111("i18n").description("i18n utilities").configureHelp(helpConfig).addCommand(extract2, { isDefault: true }).addCommand(watch).addCommand(status2).addCommand(clean);
|
|
16013
16231
|
|
|
16014
16232
|
// src/commands/cms.ts
|
|
16015
|
-
import { Command as
|
|
16233
|
+
import { Command as Command117 } from "commander";
|
|
16016
16234
|
|
|
16017
16235
|
// src/commands/cms/deploy.ts
|
|
16018
16236
|
import process49 from "node:process";
|
|
16019
|
-
import { Command as
|
|
16020
|
-
import * as
|
|
16237
|
+
import { Command as Command112 } from "commander";
|
|
16238
|
+
import * as p68 from "@clack/prompts";
|
|
16021
16239
|
import pc40 from "picocolors";
|
|
16022
16240
|
var POLL_INTERVAL2 = 5e3;
|
|
16023
16241
|
var POLL_TIMEOUT = 30 * 6e4;
|
|
16024
16242
|
var inFlight = (run) => run?.status === "pending" || run?.status === "building";
|
|
16025
|
-
var deploy2 = new
|
|
16243
|
+
var deploy2 = new Command112("deploy").description("rebuild the hosted site with the latest published content").option(
|
|
16026
16244
|
"--project <id>",
|
|
16027
16245
|
"velastack.dev project whose site to rebuild, instead of the linked one"
|
|
16028
16246
|
).option("--no-wait", "return once the build has started instead of waiting for it").configureHelp(helpConfig).action(
|
|
@@ -16039,18 +16257,18 @@ A site deployed with ${pc40.cyan("vela deploy")} is updated by deploying again.`
|
|
|
16039
16257
|
}
|
|
16040
16258
|
const url = state.site?.url ?? "";
|
|
16041
16259
|
if (inFlight(state.latest)) {
|
|
16042
|
-
|
|
16260
|
+
p68.log.info(`A deploy of ${pc40.cyan(url)} is already in progress.`);
|
|
16043
16261
|
} else {
|
|
16044
16262
|
state = await startSiteDeploy(apiKey, projectId);
|
|
16045
16263
|
}
|
|
16046
16264
|
if (!options.wait) {
|
|
16047
|
-
|
|
16265
|
+
p68.log.success(
|
|
16048
16266
|
`Build started for ${pc40.cyan(url)} (deployment ${pc40.dim(state.latest?.id ?? "")}).
|
|
16049
16267
|
It goes live when the build finishes.`
|
|
16050
16268
|
);
|
|
16051
16269
|
return;
|
|
16052
16270
|
}
|
|
16053
|
-
const spinner9 =
|
|
16271
|
+
const spinner9 = p68.spinner();
|
|
16054
16272
|
spinner9.start(`Building ${url}`);
|
|
16055
16273
|
let latest;
|
|
16056
16274
|
try {
|
|
@@ -16061,7 +16279,7 @@ It goes live when the build finishes.`
|
|
|
16061
16279
|
}
|
|
16062
16280
|
if (!latest) {
|
|
16063
16281
|
spinner9.stop(`Still building ${url}.`);
|
|
16064
|
-
|
|
16282
|
+
p68.log.warn(
|
|
16065
16283
|
`The build has not finished after ${Math.round(POLL_TIMEOUT / 6e4)} minutes.
|
|
16066
16284
|
It goes live on its own if it does; the deployments page on velastack.dev shows how it ends.`
|
|
16067
16285
|
);
|
|
@@ -16111,12 +16329,12 @@ async function waitForRun(apiKey, projectId, runId) {
|
|
|
16111
16329
|
}
|
|
16112
16330
|
|
|
16113
16331
|
// src/commands/cms/editor.ts
|
|
16114
|
-
import { Command as
|
|
16332
|
+
import { Command as Command116 } from "commander";
|
|
16115
16333
|
|
|
16116
16334
|
// src/commands/cms/editor/add.ts
|
|
16117
16335
|
import { randomBytes } from "node:crypto";
|
|
16118
|
-
import { Command as
|
|
16119
|
-
import * as
|
|
16336
|
+
import { Command as Command113 } from "commander";
|
|
16337
|
+
import * as p69 from "@clack/prompts";
|
|
16120
16338
|
import pc42 from "picocolors";
|
|
16121
16339
|
|
|
16122
16340
|
// src/lib/cms-backend.ts
|
|
@@ -16158,7 +16376,7 @@ async function withCmsBackend(fn, cwd = process50.cwd()) {
|
|
|
16158
16376
|
}
|
|
16159
16377
|
|
|
16160
16378
|
// src/commands/cms/editor/add.ts
|
|
16161
|
-
var editorAdd = new
|
|
16379
|
+
var editorAdd = new Command113("add").description("create an editor who can sign in to the admin bar").argument("<email>", "email the editor signs in with").option("--password <password>", "password to set \u2014 generated and shown once when omitted").option("--project <id>", "project the editor may edit", DEFAULT_PROJECT).configureHelp(helpConfig).action(
|
|
16162
16380
|
(email2, options) => runCommand(async () => {
|
|
16163
16381
|
const generated = options.password === void 0;
|
|
16164
16382
|
const password8 = options.password ?? randomBytes(12).toString("base64url");
|
|
@@ -16169,31 +16387,31 @@ var editorAdd = new Command111("add").description("create an editor who can sign
|
|
|
16169
16387
|
if (generated) {
|
|
16170
16388
|
lines.push("", `Password: ${pc42.bold(password8)}`, "", "It is shown once; copy it now.");
|
|
16171
16389
|
}
|
|
16172
|
-
|
|
16173
|
-
|
|
16390
|
+
p69.log.success(lines.join("\n"));
|
|
16391
|
+
p69.log.info(
|
|
16174
16392
|
`Run ${pc42.cyan("vela dev")}, open any page with ${pc42.cyan("?edit")} on the URL (or press ${pc42.cyan("Ctrl+E")}), and sign in.`
|
|
16175
16393
|
);
|
|
16176
16394
|
}, "Failed to add the editor.")
|
|
16177
16395
|
);
|
|
16178
16396
|
|
|
16179
16397
|
// src/commands/cms/editor/password.ts
|
|
16180
|
-
import { Command as
|
|
16181
|
-
import * as
|
|
16398
|
+
import { Command as Command114 } from "commander";
|
|
16399
|
+
import * as p70 from "@clack/prompts";
|
|
16182
16400
|
import pc43 from "picocolors";
|
|
16183
|
-
var editorPassword = new
|
|
16401
|
+
var editorPassword = new Command114("password").description("set an editor's password").argument("<email>", "email of the editor").argument("<password>", "new password").configureHelp(helpConfig).action(
|
|
16184
16402
|
(email2, password8) => runCommand(async () => {
|
|
16185
16403
|
await withCmsBackend((cms3) => cms3.editors.setPassword(email2, password8));
|
|
16186
|
-
|
|
16404
|
+
p70.log.success(
|
|
16187
16405
|
`Updated the password for ${pc43.cyan(email2)}. Existing sessions were signed out.`
|
|
16188
16406
|
);
|
|
16189
16407
|
}, "Failed to set the password.")
|
|
16190
16408
|
);
|
|
16191
16409
|
|
|
16192
16410
|
// src/commands/cms/editor/list.ts
|
|
16193
|
-
import { Command as
|
|
16194
|
-
import * as
|
|
16411
|
+
import { Command as Command115 } from "commander";
|
|
16412
|
+
import * as p71 from "@clack/prompts";
|
|
16195
16413
|
import pc44 from "picocolors";
|
|
16196
|
-
var editorList = new
|
|
16414
|
+
var editorList = new Command115("list").description("list editors and the projects they may edit").configureHelp(helpConfig).action(
|
|
16197
16415
|
() => runCommand(async () => {
|
|
16198
16416
|
const rows = await withCmsBackend(
|
|
16199
16417
|
async (cms3) => cms3.editors.list().map((editor2) => ({
|
|
@@ -16202,11 +16420,11 @@ var editorList = new Command113("list").description("list editors and the projec
|
|
|
16202
16420
|
}))
|
|
16203
16421
|
);
|
|
16204
16422
|
if (rows.length === 0) {
|
|
16205
|
-
|
|
16423
|
+
p71.log.info(`No editors yet. Add one with ${pc44.cyan("vela cms editor add <email>")}.`);
|
|
16206
16424
|
return;
|
|
16207
16425
|
}
|
|
16208
16426
|
const width = Math.max(...rows.map((row) => row.email.length));
|
|
16209
|
-
|
|
16427
|
+
p71.log.info(
|
|
16210
16428
|
`Editors
|
|
16211
16429
|
|
|
16212
16430
|
` + rows.map(
|
|
@@ -16217,18 +16435,18 @@ var editorList = new Command113("list").description("list editors and the projec
|
|
|
16217
16435
|
);
|
|
16218
16436
|
|
|
16219
16437
|
// src/commands/cms/editor.ts
|
|
16220
|
-
var editor = new
|
|
16438
|
+
var editor = new Command116("editor").description("manage who can sign in to the admin bar").configureHelp(helpConfig).addCommand(editorAdd).addCommand(editorPassword).addCommand(editorList);
|
|
16221
16439
|
|
|
16222
16440
|
// src/commands/cms.ts
|
|
16223
|
-
var cms2 = new
|
|
16441
|
+
var cms2 = new Command117("cms").description("manage the CMS").configureHelp(helpConfig).addCommand(editor).addCommand(deploy2);
|
|
16224
16442
|
|
|
16225
16443
|
// src/commands/workflows.ts
|
|
16226
|
-
import { Command as
|
|
16444
|
+
import { Command as Command121 } from "commander";
|
|
16227
16445
|
|
|
16228
16446
|
// src/commands/workflows/list.ts
|
|
16229
16447
|
import process51 from "node:process";
|
|
16230
|
-
import { Command as
|
|
16231
|
-
import * as
|
|
16448
|
+
import { Command as Command118, InvalidArgumentError as InvalidArgumentError5 } from "commander";
|
|
16449
|
+
import * as p72 from "@clack/prompts";
|
|
16232
16450
|
import pc45 from "picocolors";
|
|
16233
16451
|
|
|
16234
16452
|
// src/lib/workflows-api.ts
|
|
@@ -16302,7 +16520,7 @@ function formatRun(run, nameWidth) {
|
|
|
16302
16520
|
const error = run.status === "failed" && run.error?.message ? pc45.red(` ${run.error.message}`) : "";
|
|
16303
16521
|
return `${run.id} ${run.workflowName.padEnd(nameWidth)} ${status3}${attempts} ${when}${error}`;
|
|
16304
16522
|
}
|
|
16305
|
-
var workflowsList = new
|
|
16523
|
+
var workflowsList = new Command118("list").description("list recent workflow runs").option("--status <status>", `only runs in this state (${STATUSES.join(", ")})`, parseStatus).option("--name <workflow>", "only runs of this workflow").option("--limit <n>", "how many to show", parseLimit, 50).configureHelp(helpConfig).action(
|
|
16306
16524
|
(options) => runCommand(async () => {
|
|
16307
16525
|
await withPocketbase(process51.cwd(), async (pb) => {
|
|
16308
16526
|
const runs = await listRuns(pb, {
|
|
@@ -16311,7 +16529,7 @@ var workflowsList = new Command116("list").description("list recent workflow run
|
|
|
16311
16529
|
limit: options.limit
|
|
16312
16530
|
});
|
|
16313
16531
|
if (runs.length === 0) {
|
|
16314
|
-
|
|
16532
|
+
p72.log.info(
|
|
16315
16533
|
`No workflow runs yet.
|
|
16316
16534
|
|
|
16317
16535
|
Start one from server code with ${pc45.cyan("<workflow>.run(input)")}, or with ${pc45.cyan("vela workflows run <name>")}.`
|
|
@@ -16319,15 +16537,15 @@ Start one from server code with ${pc45.cyan("<workflow>.run(input)")}, or with $
|
|
|
16319
16537
|
return;
|
|
16320
16538
|
}
|
|
16321
16539
|
const width = Math.max(...runs.map((r) => r.workflowName.length));
|
|
16322
|
-
|
|
16540
|
+
p72.log.message(runs.map((r) => formatRun(r, width)).join("\n"));
|
|
16323
16541
|
});
|
|
16324
16542
|
}, "Failed to list workflow runs.")
|
|
16325
16543
|
);
|
|
16326
16544
|
|
|
16327
16545
|
// src/commands/workflows/run.ts
|
|
16328
16546
|
import process52 from "node:process";
|
|
16329
|
-
import { Command as
|
|
16330
|
-
import * as
|
|
16547
|
+
import { Command as Command119, InvalidArgumentError as InvalidArgumentError6 } from "commander";
|
|
16548
|
+
import * as p73 from "@clack/prompts";
|
|
16331
16549
|
import pc46 from "picocolors";
|
|
16332
16550
|
function parseInput(value) {
|
|
16333
16551
|
try {
|
|
@@ -16336,11 +16554,11 @@ function parseInput(value) {
|
|
|
16336
16554
|
throw new InvalidArgumentError6(`must be JSON, e.g. '{"userId":"abc"}'.`);
|
|
16337
16555
|
}
|
|
16338
16556
|
}
|
|
16339
|
-
var workflowsRun = new
|
|
16557
|
+
var workflowsRun = new Command119("run").description("start a run of a workflow; the running app picks it up").argument("<name>", "the workflow name, as in its defineWorkflow spec").argument("[input]", "the run input as JSON", parseInput).configureHelp(helpConfig).action(
|
|
16340
16558
|
(name, input) => runCommand(async () => {
|
|
16341
16559
|
await withPocketbase(process52.cwd(), async (pb) => {
|
|
16342
16560
|
const run = await createRun(pb, name, input);
|
|
16343
|
-
|
|
16561
|
+
p73.log.success(
|
|
16344
16562
|
`Queued ${pc46.cyan(name)} as run ${pc46.bold(run.id)}.
|
|
16345
16563
|
|
|
16346
16564
|
It runs once the app is up (${pc46.cyan("vela dev")}); ${pc46.cyan("vela workflows list")} shows its state.`
|
|
@@ -16351,20 +16569,20 @@ It runs once the app is up (${pc46.cyan("vela dev")}); ${pc46.cyan("vela workflo
|
|
|
16351
16569
|
|
|
16352
16570
|
// src/commands/workflows/cancel.ts
|
|
16353
16571
|
import process53 from "node:process";
|
|
16354
|
-
import { Command as
|
|
16355
|
-
import * as
|
|
16572
|
+
import { Command as Command120 } from "commander";
|
|
16573
|
+
import * as p74 from "@clack/prompts";
|
|
16356
16574
|
import pc47 from "picocolors";
|
|
16357
|
-
var workflowsCancel = new
|
|
16575
|
+
var workflowsCancel = new Command120("cancel").description("cancel a pending or running workflow run").argument("<run-id>", "the run id from `vela workflows list`").configureHelp(helpConfig).action(
|
|
16358
16576
|
(id) => runCommand(async () => {
|
|
16359
16577
|
await withPocketbase(process53.cwd(), async (pb) => {
|
|
16360
16578
|
const run = await cancelRun(pb, id);
|
|
16361
|
-
|
|
16579
|
+
p74.log.success(`Canceled run ${pc47.bold(run.id)} of ${pc47.cyan(run.workflowName)}.`);
|
|
16362
16580
|
});
|
|
16363
16581
|
}, "Failed to cancel the workflow run.")
|
|
16364
16582
|
);
|
|
16365
16583
|
|
|
16366
16584
|
// src/commands/workflows.ts
|
|
16367
|
-
var workflows2 = new
|
|
16585
|
+
var workflows2 = new Command121("workflows").description("list, start and cancel background workflow runs").configureHelp(helpConfig).addCommand(workflowsList).addCommand(workflowsRun).addCommand(workflowsCancel);
|
|
16368
16586
|
|
|
16369
16587
|
// src/program.ts
|
|
16370
16588
|
var NO_BACKEND_COMMMANDS = /* @__PURE__ */ new Set([
|
|
@@ -16437,7 +16655,7 @@ var PROVIDER_GATED_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
16437
16655
|
]);
|
|
16438
16656
|
var BACKEND_OPTIONAL_COMMANDS = /* @__PURE__ */ new Set(["dev", "build", "preview", "deploy"]);
|
|
16439
16657
|
var SELF_CREDENTIALED_COMMANDS = /* @__PURE__ */ new Set(["test:server"]);
|
|
16440
|
-
var program = new
|
|
16658
|
+
var program = new Command122().name(package_default.name).description(package_default.description).version(package_default.version, "-v, --version").configureHelp(helpConfig);
|
|
16441
16659
|
program.hook("preAction", (_thisCommand, actionCommand) => {
|
|
16442
16660
|
const envRoot = findWorkspaceRoot() ?? process54.cwd();
|
|
16443
16661
|
dotenv2.config({ path: nodePath.join(envRoot, ".env"), quiet: true });
|
|
@@ -16448,17 +16666,17 @@ program.hook("preAction", (_thisCommand, actionCommand) => {
|
|
|
16448
16666
|
if (NO_BACKEND_COMMMANDS.has(top)) return;
|
|
16449
16667
|
if (!hasBackend()) {
|
|
16450
16668
|
if (BACKEND_OPTIONAL_COMMANDS.has(top)) return;
|
|
16451
|
-
|
|
16452
|
-
|
|
16453
|
-
|
|
16669
|
+
p75.log.error(missingBackendMessage(`vela ${path68}`));
|
|
16670
|
+
p75.log.message();
|
|
16671
|
+
p75.cancel("Operation failed.");
|
|
16454
16672
|
process54.exit(1);
|
|
16455
16673
|
}
|
|
16456
16674
|
if (SELF_CREDENTIALED_COMMANDS.has(path68)) return;
|
|
16457
16675
|
if (path68 === "generate migration" && actionCommand.opts().ai) return;
|
|
16458
16676
|
if (!hasSuperuserCredentials()) {
|
|
16459
|
-
|
|
16460
|
-
|
|
16461
|
-
|
|
16677
|
+
p75.log.error(missingCredentialsMessage());
|
|
16678
|
+
p75.log.message();
|
|
16679
|
+
p75.cancel("Operation failed.");
|
|
16462
16680
|
process54.exit(1);
|
|
16463
16681
|
}
|
|
16464
16682
|
});
|