vela 0.22.0 → 0.23.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 +469 -360
- package/dist/bin.js.map +4 -4
- package/dist/testing.d.ts +21 -0
- package/dist/testing.js +43 -0
- package/dist/testing.js.map +7 -0
- package/package.json +10 -3
- package/templates/minimal/_gitignore +3 -0
- package/templates/minimal/package.template.json +2 -0
- package/templates/minimal/test/setup.ts +15 -9
- package/templates/minimal/vitest.config.ts +42 -5
package/dist/bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/bin.ts
|
|
4
|
-
import
|
|
4
|
+
import process56 from "node:process";
|
|
5
5
|
|
|
6
6
|
// src/lib/argv.ts
|
|
7
7
|
function normalizeArgv(argv) {
|
|
@@ -11,7 +11,7 @@ function normalizeArgv(argv) {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
// src/program.ts
|
|
14
|
-
import
|
|
14
|
+
import process55 from "node:process";
|
|
15
15
|
import * as p75 from "@clack/prompts";
|
|
16
16
|
import { Command as Command122 } from "commander";
|
|
17
17
|
import nodePath from "node:path";
|
|
@@ -20,7 +20,7 @@ import dotenv2 from "dotenv";
|
|
|
20
20
|
// package.json
|
|
21
21
|
var package_default = {
|
|
22
22
|
name: "vela",
|
|
23
|
-
version: "0.
|
|
23
|
+
version: "0.23.0",
|
|
24
24
|
type: "module",
|
|
25
25
|
description: "A CLI for creating and updating SvelteKit projects",
|
|
26
26
|
license: "MIT",
|
|
@@ -36,12 +36,19 @@ var package_default = {
|
|
|
36
36
|
vela: "./dist/bin.js",
|
|
37
37
|
velastack: "./dist/bin.js"
|
|
38
38
|
},
|
|
39
|
+
exports: {
|
|
40
|
+
"./testing": {
|
|
41
|
+
types: "./dist/testing.d.ts",
|
|
42
|
+
default: "./dist/testing.js"
|
|
43
|
+
},
|
|
44
|
+
"./package.json": "./package.json"
|
|
45
|
+
},
|
|
39
46
|
files: [
|
|
40
47
|
"dist",
|
|
41
48
|
"templates"
|
|
42
49
|
],
|
|
43
50
|
scripts: {
|
|
44
|
-
build: "node --experimental-strip-types scripts/build.ts",
|
|
51
|
+
build: "node --experimental-strip-types scripts/build.ts && tsc -p tsconfig.testing.json",
|
|
45
52
|
dev: "node --experimental-strip-types scripts/build.ts --watch",
|
|
46
53
|
clean: "rm -rf dist",
|
|
47
54
|
lint: "npm run lint:ts && npm run lint:format && npm run lint:sh",
|
|
@@ -57,7 +64,7 @@ var package_default = {
|
|
|
57
64
|
dependencies: {
|
|
58
65
|
"@clack/prompts": "^1.7.0",
|
|
59
66
|
"@faker-js/faker": "^10.6.0",
|
|
60
|
-
"@velastack/patterns": "^0.
|
|
67
|
+
"@velastack/patterns": "^0.11.0",
|
|
61
68
|
"@velastack/pocketbase-codegen": "^0.1.0",
|
|
62
69
|
"@velastack/schema": "^0.3.0",
|
|
63
70
|
"@velastack/schema-ui": "^0.3.1",
|
|
@@ -301,8 +308,8 @@ function dropTemplateAdapters(user, template) {
|
|
|
301
308
|
}
|
|
302
309
|
return copy;
|
|
303
310
|
}
|
|
304
|
-
function readPackageJson(
|
|
305
|
-
return JSON.parse(fs2.readFileSync(
|
|
311
|
+
function readPackageJson(path69) {
|
|
312
|
+
return JSON.parse(fs2.readFileSync(path69, "utf8"));
|
|
306
313
|
}
|
|
307
314
|
var PACKAGE_NAME_PLACEHOLDER = /~TODO~/g;
|
|
308
315
|
var APP_NAME_PLACEHOLDER = /~APP_NAME~/g;
|
|
@@ -331,12 +338,12 @@ function jsString(value) {
|
|
|
331
338
|
const quote2 = count("'") > count('"') ? '"' : "'";
|
|
332
339
|
return `${quote2}${escapeFor(quote2, value)}${quote2}`;
|
|
333
340
|
}
|
|
334
|
-
function readTemplatePackageJson(
|
|
335
|
-
const raw = fillTemplatePlaceholders(fs2.readFileSync(
|
|
341
|
+
function readTemplatePackageJson(path69, values) {
|
|
342
|
+
const raw = fillTemplatePlaceholders(fs2.readFileSync(path69, "utf8"), values);
|
|
336
343
|
return JSON.parse(raw);
|
|
337
344
|
}
|
|
338
|
-
function writePackageJson(
|
|
339
|
-
fs2.writeFileSync(
|
|
345
|
+
function writePackageJson(path69, pkg) {
|
|
346
|
+
fs2.writeFileSync(path69, JSON.stringify(pkg, null, " ") + "\n");
|
|
340
347
|
}
|
|
341
348
|
function toValidPackageName(name) {
|
|
342
349
|
return name.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z0-9~.-]+/g, "-");
|
|
@@ -505,16 +512,16 @@ function compareVersions(a, b) {
|
|
|
505
512
|
return b.prerelease.length - a.prerelease.length;
|
|
506
513
|
}
|
|
507
514
|
for (let i = 0; i < Math.max(a.prerelease.length, b.prerelease.length); i++) {
|
|
508
|
-
const
|
|
515
|
+
const x9 = a.prerelease[i];
|
|
509
516
|
const y = b.prerelease[i];
|
|
510
|
-
if (
|
|
517
|
+
if (x9 === void 0) return -1;
|
|
511
518
|
if (y === void 0) return 1;
|
|
512
|
-
if (
|
|
513
|
-
const xn = /^\d+$/.test(
|
|
519
|
+
if (x9 === y) continue;
|
|
520
|
+
const xn = /^\d+$/.test(x9);
|
|
514
521
|
const yn = /^\d+$/.test(y);
|
|
515
|
-
if (xn && yn) return Number(
|
|
522
|
+
if (xn && yn) return Number(x9) - Number(y);
|
|
516
523
|
if (xn !== yn) return xn ? -1 : 1;
|
|
517
|
-
return
|
|
524
|
+
return x9 < y ? -1 : 1;
|
|
518
525
|
}
|
|
519
526
|
return 0;
|
|
520
527
|
}
|
|
@@ -2799,7 +2806,7 @@ var VELA_ONLY_FILES = [
|
|
|
2799
2806
|
{ path: ".ignore", adds: "search ignores for generated files" },
|
|
2800
2807
|
{
|
|
2801
2808
|
path: "vitest.config.ts",
|
|
2802
|
-
adds: "the server test project `vela
|
|
2809
|
+
adds: "the server test project, with the `vela/testing` global setup that starts its servers \u2014 without it test/setup.ts never loads"
|
|
2803
2810
|
}
|
|
2804
2811
|
];
|
|
2805
2812
|
var VELA_ONLY_DIRS = ["src/lib/components", "src/lib/workflows", "data", "test", "static"];
|
|
@@ -3900,8 +3907,8 @@ function cancelled() {
|
|
|
3900
3907
|
p9.cancel("Operation cancelled.");
|
|
3901
3908
|
process14.exit(0);
|
|
3902
3909
|
}
|
|
3903
|
-
async function postForm(fetchCookie,
|
|
3904
|
-
const res = await fetchCookie(`${API_URL}${
|
|
3910
|
+
async function postForm(fetchCookie, path69, fields) {
|
|
3911
|
+
const res = await fetchCookie(`${API_URL}${path69}`, {
|
|
3905
3912
|
method: "POST",
|
|
3906
3913
|
headers: {
|
|
3907
3914
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
@@ -7682,8 +7689,13 @@ var apiKeys = new Command16("api-keys").description("enable API key management")
|
|
|
7682
7689
|
);
|
|
7683
7690
|
|
|
7684
7691
|
// src/commands/enable/backend.ts
|
|
7692
|
+
import fs34 from "node:fs";
|
|
7693
|
+
import path34 from "node:path";
|
|
7685
7694
|
import process18 from "node:process";
|
|
7686
7695
|
import * as v6 from "valibot";
|
|
7696
|
+
import { x as x3 } from "tinyexec";
|
|
7697
|
+
import { detect as detect6 } from "package-manager-detector";
|
|
7698
|
+
import { resolveCommand as resolveCommand4 } from "package-manager-detector/commands";
|
|
7687
7699
|
import { Command as Command17 } from "commander";
|
|
7688
7700
|
import * as p21 from "@clack/prompts";
|
|
7689
7701
|
import pc7 from "picocolors";
|
|
@@ -7711,7 +7723,10 @@ var backend = new Command17("backend").description("enable the PocketBase backen
|
|
|
7711
7723
|
},
|
|
7712
7724
|
// The pattern installs `pocketbase-server` before this runs, and
|
|
7713
7725
|
// scaffolds the `data/` directory the database lives in.
|
|
7714
|
-
() =>
|
|
7726
|
+
async () => {
|
|
7727
|
+
await ensureVelaDependency(workspaceRootDir);
|
|
7728
|
+
await initPocketbase(workspaceRootDir, credentials);
|
|
7729
|
+
}
|
|
7715
7730
|
);
|
|
7716
7731
|
}, "Failed to enable backend.")
|
|
7717
7732
|
);
|
|
@@ -7731,6 +7746,22 @@ function backendNextSteps(ui2) {
|
|
|
7731
7746
|
"`vela enable auth` needs shadcn-svelte: `npx sv add tailwindcss`, then `npx shadcn-svelte@latest init`."
|
|
7732
7747
|
];
|
|
7733
7748
|
}
|
|
7749
|
+
async function ensureVelaDependency(root) {
|
|
7750
|
+
const file = path34.join(root, "package.json");
|
|
7751
|
+
if (!fs34.existsSync(file)) return;
|
|
7752
|
+
const manifest = JSON.parse(fs34.readFileSync(file, "utf8"));
|
|
7753
|
+
if (manifest.dependencies?.vela || manifest.devDependencies?.vela) return;
|
|
7754
|
+
p21.log.step("Adding vela to devDependencies...");
|
|
7755
|
+
const pm = (await detect6({ cwd: root }))?.name ?? "npm";
|
|
7756
|
+
const resolved = resolveCommand4(pm, "add", [`vela@^${package_default.version}`, "-D"]);
|
|
7757
|
+
const result = await x3(resolved.command, resolved.args, {
|
|
7758
|
+
nodeOptions: { cwd: root, stdio: "pipe" }
|
|
7759
|
+
});
|
|
7760
|
+
if (result.exitCode !== 0) {
|
|
7761
|
+
throw new Error(`Failed to add vela to devDependencies:
|
|
7762
|
+
${result.stderr || result.stdout}`);
|
|
7763
|
+
}
|
|
7764
|
+
}
|
|
7734
7765
|
async function initPocketbase(root, { email: email2, password: password8 }) {
|
|
7735
7766
|
p21.log.step("Initializing PocketBase...");
|
|
7736
7767
|
await upsertSuperuser(root, email2, password8);
|
|
@@ -7814,22 +7845,22 @@ var teams = new Command19("teams").description("enable team / multi-tenant suppo
|
|
|
7814
7845
|
);
|
|
7815
7846
|
|
|
7816
7847
|
// src/commands/enable/payments.ts
|
|
7817
|
-
import
|
|
7818
|
-
import
|
|
7848
|
+
import fs36 from "node:fs";
|
|
7849
|
+
import path36 from "node:path";
|
|
7819
7850
|
import process19 from "node:process";
|
|
7820
7851
|
import { Command as Command20 } from "commander";
|
|
7821
7852
|
import * as p22 from "@clack/prompts";
|
|
7822
7853
|
|
|
7823
7854
|
// src/lib/order-form.ts
|
|
7824
|
-
import
|
|
7825
|
-
import
|
|
7855
|
+
import fs35 from "node:fs";
|
|
7856
|
+
import path35 from "node:path";
|
|
7826
7857
|
var ORDER_FORM_KEY = "order";
|
|
7827
7858
|
var ORDER_FORM_NAME = "Orders";
|
|
7828
7859
|
var HOSTED_CMS = /^(https?:\/\/[^/]+)\/v1\/projects\/([^/?#]+)\/cms\/?$/;
|
|
7829
7860
|
function hostedCmsProject(root) {
|
|
7830
7861
|
let source;
|
|
7831
7862
|
try {
|
|
7832
|
-
source =
|
|
7863
|
+
source = fs35.readFileSync(path35.join(root, "src", "lib", "cms.ts"), "utf8");
|
|
7833
7864
|
} catch {
|
|
7834
7865
|
return null;
|
|
7835
7866
|
}
|
|
@@ -7948,9 +7979,9 @@ function isCountry(code2) {
|
|
|
7948
7979
|
}
|
|
7949
7980
|
function declaredBusiness() {
|
|
7950
7981
|
const root = findWorkspaceRoot();
|
|
7951
|
-
const site = root ?
|
|
7952
|
-
if (!site || !
|
|
7953
|
-
const source =
|
|
7982
|
+
const site = root ? path36.join(root, "src", "lib", "site.ts") : null;
|
|
7983
|
+
if (!site || !fs36.existsSync(site)) return {};
|
|
7984
|
+
const source = fs36.readFileSync(site, "utf8");
|
|
7954
7985
|
return {
|
|
7955
7986
|
currency: /^\s*currency\s*:\s*['"]([A-Za-z]{3})['"]/m.exec(source)?.[1],
|
|
7956
7987
|
country: /^\s*country\s*:\s*['"]([A-Za-z]{2})['"]/m.exec(source)?.[1],
|
|
@@ -8912,25 +8943,25 @@ import * as p26 from "@clack/prompts";
|
|
|
8912
8943
|
import pc9 from "picocolors";
|
|
8913
8944
|
|
|
8914
8945
|
// src/lib/deploy-config.ts
|
|
8915
|
-
import
|
|
8916
|
-
import
|
|
8946
|
+
import fs37 from "node:fs";
|
|
8947
|
+
import path37 from "node:path";
|
|
8917
8948
|
import crypto2 from "node:crypto";
|
|
8918
8949
|
function projectFilePath(workspaceRootDir) {
|
|
8919
|
-
return
|
|
8950
|
+
return path37.join(workspaceRootDir, ".vela", "project.json");
|
|
8920
8951
|
}
|
|
8921
8952
|
function readProjectFile(workspaceRootDir) {
|
|
8922
8953
|
const file = projectFilePath(workspaceRootDir);
|
|
8923
|
-
if (!
|
|
8954
|
+
if (!fs37.existsSync(file)) return {};
|
|
8924
8955
|
try {
|
|
8925
|
-
return JSON.parse(
|
|
8956
|
+
return JSON.parse(fs37.readFileSync(file, "utf8"));
|
|
8926
8957
|
} catch {
|
|
8927
8958
|
return {};
|
|
8928
8959
|
}
|
|
8929
8960
|
}
|
|
8930
8961
|
function writeProjectFile(workspaceRootDir, data) {
|
|
8931
8962
|
const file = projectFilePath(workspaceRootDir);
|
|
8932
|
-
|
|
8933
|
-
|
|
8963
|
+
fs37.mkdirSync(path37.dirname(file), { recursive: true });
|
|
8964
|
+
fs37.writeFileSync(file, JSON.stringify(data, null, 2) + "\n");
|
|
8934
8965
|
}
|
|
8935
8966
|
function resolveAppIdentity(workspaceRootDir, projectName) {
|
|
8936
8967
|
const project = readProjectFile(workspaceRootDir);
|
|
@@ -8955,11 +8986,11 @@ function readAppIdentity(workspaceRootDir, projectName) {
|
|
|
8955
8986
|
}
|
|
8956
8987
|
function defaultProjectName(workspaceRootDir) {
|
|
8957
8988
|
try {
|
|
8958
|
-
const pkg = readPackageJson(
|
|
8989
|
+
const pkg = readPackageJson(path37.join(workspaceRootDir, "package.json"));
|
|
8959
8990
|
if (typeof pkg.name === "string" && pkg.name.trim()) return pkg.name.trim();
|
|
8960
8991
|
} catch {
|
|
8961
8992
|
}
|
|
8962
|
-
return
|
|
8993
|
+
return path37.basename(workspaceRootDir);
|
|
8963
8994
|
}
|
|
8964
8995
|
function slug(value) {
|
|
8965
8996
|
return value.toLowerCase().replace(/^@/, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 32) || "app";
|
|
@@ -9030,15 +9061,15 @@ function randomSuffix() {
|
|
|
9030
9061
|
}
|
|
9031
9062
|
|
|
9032
9063
|
// src/lib/artifact.ts
|
|
9033
|
-
import
|
|
9034
|
-
import
|
|
9035
|
-
import { detect as
|
|
9036
|
-
import { resolveCommand as
|
|
9064
|
+
import fs39 from "node:fs";
|
|
9065
|
+
import path39 from "node:path";
|
|
9066
|
+
import { detect as detect7 } from "package-manager-detector";
|
|
9067
|
+
import { resolveCommand as resolveCommand5 } from "package-manager-detector/commands";
|
|
9037
9068
|
|
|
9038
9069
|
// src/lib/ssh.ts
|
|
9039
|
-
import
|
|
9070
|
+
import fs38 from "node:fs";
|
|
9040
9071
|
import os5 from "node:os";
|
|
9041
|
-
import
|
|
9072
|
+
import path38 from "node:path";
|
|
9042
9073
|
import crypto4 from "node:crypto";
|
|
9043
9074
|
import process24 from "node:process";
|
|
9044
9075
|
import { spawn as spawn4 } from "node:child_process";
|
|
@@ -9081,9 +9112,9 @@ var SshSession = class {
|
|
|
9081
9112
|
}
|
|
9082
9113
|
async open() {
|
|
9083
9114
|
if (this.controlPath) return;
|
|
9084
|
-
const dir =
|
|
9085
|
-
|
|
9086
|
-
const socket =
|
|
9115
|
+
const dir = path38.join(os5.tmpdir(), "vela-ssh");
|
|
9116
|
+
fs38.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
9117
|
+
const socket = path38.join(dir, `${crypto4.randomBytes(6).toString("hex")}.sock`);
|
|
9087
9118
|
this.controlPath = socket;
|
|
9088
9119
|
const args = [
|
|
9089
9120
|
...this.sshArgs(),
|
|
@@ -9354,8 +9385,8 @@ async function runBuild(cwd, buildCommand, env2) {
|
|
|
9354
9385
|
throw new BuildError(`\`${buildCommand}\` exited ${result2.exitCode}.`);
|
|
9355
9386
|
return;
|
|
9356
9387
|
}
|
|
9357
|
-
const pm = (await
|
|
9358
|
-
const resolved =
|
|
9388
|
+
const pm = (await detect7({ cwd }))?.name ?? "npm";
|
|
9389
|
+
const resolved = resolveCommand5(pm, "run", ["build"]);
|
|
9359
9390
|
if (!resolved) throw new BuildError(`Could not work out how to run a build with ${pm}.`);
|
|
9360
9391
|
const result = await spawnCapture(resolved.command, resolved.args, {
|
|
9361
9392
|
cwd,
|
|
@@ -9373,11 +9404,11 @@ function collectArtifact(cwd) {
|
|
|
9373
9404
|
const outputDir = DEFAULT_OUTPUT_DIR;
|
|
9374
9405
|
const entries = [];
|
|
9375
9406
|
const add2 = (rel, remoteDir = "") => {
|
|
9376
|
-
const localPath =
|
|
9377
|
-
if (
|
|
9407
|
+
const localPath = path39.join(cwd, rel);
|
|
9408
|
+
if (fs39.existsSync(localPath)) entries.push({ localPath, remoteDir });
|
|
9378
9409
|
};
|
|
9379
|
-
const buildPath =
|
|
9380
|
-
if (!
|
|
9410
|
+
const buildPath = path39.join(cwd, outputDir);
|
|
9411
|
+
if (!fs39.existsSync(path39.join(buildPath, "index.js"))) {
|
|
9381
9412
|
throw new BuildError(
|
|
9382
9413
|
`No ${outputDir}/index.js to deploy.
|
|
9383
9414
|
|
|
@@ -9390,18 +9421,18 @@ build ran with it as the adapter, then deploy again.`
|
|
|
9390
9421
|
for (const lockfile of [NPM_LOCKFILE, ...FOREIGN_LOCKFILES]) add2(lockfile);
|
|
9391
9422
|
add2(".npmrc");
|
|
9392
9423
|
add2(MIGRATIONS_DIR);
|
|
9393
|
-
const hooks =
|
|
9394
|
-
if (
|
|
9424
|
+
const hooks = path39.join(cwd, DATA_DIR, "hooks");
|
|
9425
|
+
if (fs39.existsSync(hooks)) entries.push({ localPath: hooks, remoteDir: "hooks" });
|
|
9395
9426
|
return entries;
|
|
9396
9427
|
}
|
|
9397
9428
|
var NPM_LOCKFILE = "package-lock.json";
|
|
9398
9429
|
var FOREIGN_LOCKFILES = ["pnpm-lock.yaml", "yarn.lock", "bun.lock", "bun.lockb"];
|
|
9399
9430
|
function hasLockfile(cwd) {
|
|
9400
|
-
return
|
|
9431
|
+
return fs39.existsSync(path39.join(cwd, NPM_LOCKFILE));
|
|
9401
9432
|
}
|
|
9402
9433
|
function foreignLockfile(cwd) {
|
|
9403
9434
|
if (hasLockfile(cwd)) return void 0;
|
|
9404
|
-
return FOREIGN_LOCKFILES.find((name) =>
|
|
9435
|
+
return FOREIGN_LOCKFILES.find((name) => fs39.existsSync(path39.join(cwd, name)));
|
|
9405
9436
|
}
|
|
9406
9437
|
async function gitSha(cwd) {
|
|
9407
9438
|
const result = await spawnCapture("git", ["rev-parse", "HEAD"], { cwd });
|
|
@@ -9440,8 +9471,8 @@ function sshOptionsFrom(options) {
|
|
|
9440
9471
|
|
|
9441
9472
|
// src/lib/remote.ts
|
|
9442
9473
|
import crypto5 from "node:crypto";
|
|
9443
|
-
import
|
|
9444
|
-
import
|
|
9474
|
+
import fs40 from "node:fs";
|
|
9475
|
+
import path40 from "node:path";
|
|
9445
9476
|
import process25 from "node:process";
|
|
9446
9477
|
var VELA_ROOT = "/var/lib/vela";
|
|
9447
9478
|
var VELA_ETC = "/etc/vela";
|
|
@@ -9454,19 +9485,19 @@ function instanceHasBackend(state) {
|
|
|
9454
9485
|
return state.backend ?? Boolean(state.pbPort);
|
|
9455
9486
|
}
|
|
9456
9487
|
function serverTemplatesDir() {
|
|
9457
|
-
return
|
|
9488
|
+
return path40.join(templatesDir(), "server");
|
|
9458
9489
|
}
|
|
9459
9490
|
var DIGEST_LENGTH = 12;
|
|
9460
9491
|
function serverScriptsDigest(dir = serverTemplatesDir()) {
|
|
9461
9492
|
const hash = crypto5.createHash("sha256");
|
|
9462
9493
|
for (const file of listFiles(dir).sort()) {
|
|
9463
|
-
hash.update(file).update("\0").update(
|
|
9494
|
+
hash.update(file).update("\0").update(fs40.readFileSync(path40.join(dir, file))).update("\0");
|
|
9464
9495
|
}
|
|
9465
9496
|
return hash.digest("hex").slice(0, DIGEST_LENGTH);
|
|
9466
9497
|
}
|
|
9467
9498
|
function listFiles(root, prefix = "") {
|
|
9468
9499
|
const files = [];
|
|
9469
|
-
for (const entry of
|
|
9500
|
+
for (const entry of fs40.readdirSync(path40.join(root, prefix), { withFileTypes: true })) {
|
|
9470
9501
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
9471
9502
|
if (entry.isDirectory()) files.push(...listFiles(root, rel));
|
|
9472
9503
|
else if (entry.isFile()) files.push(rel);
|
|
@@ -9593,7 +9624,7 @@ var remotePaths = {
|
|
|
9593
9624
|
};
|
|
9594
9625
|
|
|
9595
9626
|
// src/lib/remote-env.ts
|
|
9596
|
-
import
|
|
9627
|
+
import fs41 from "node:fs";
|
|
9597
9628
|
import dotenv from "dotenv";
|
|
9598
9629
|
var KEY_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
9599
9630
|
function isValidKey(key) {
|
|
@@ -9641,7 +9672,7 @@ function quote(value) {
|
|
|
9641
9672
|
return `"${escaped}"`;
|
|
9642
9673
|
}
|
|
9643
9674
|
function readLocalEnvFile(file) {
|
|
9644
|
-
const parsed = dotenv.parse(
|
|
9675
|
+
const parsed = dotenv.parse(fs41.readFileSync(file));
|
|
9645
9676
|
const result = {};
|
|
9646
9677
|
for (const [key, value] of Object.entries(parsed)) {
|
|
9647
9678
|
if (isValidKey(key)) result[key] = value;
|
|
@@ -10524,14 +10555,14 @@ var ui = new Command59("ui").description("generate ui components").configureHelp
|
|
|
10524
10555
|
import { Command as Command62 } from "commander";
|
|
10525
10556
|
|
|
10526
10557
|
// src/commands/legal/terms.ts
|
|
10527
|
-
import
|
|
10558
|
+
import path42 from "node:path";
|
|
10528
10559
|
import { Command as Command60 } from "commander";
|
|
10529
10560
|
import * as p37 from "@clack/prompts";
|
|
10530
10561
|
|
|
10531
10562
|
// src/commands/legal/shared.ts
|
|
10532
10563
|
import process29 from "node:process";
|
|
10533
|
-
import
|
|
10534
|
-
import
|
|
10564
|
+
import fs42 from "node:fs";
|
|
10565
|
+
import path41 from "node:path";
|
|
10535
10566
|
import * as p36 from "@clack/prompts";
|
|
10536
10567
|
function siteFields(site) {
|
|
10537
10568
|
const url = site?.url && !isLocalUrl(site.url) ? site.url : void 0;
|
|
@@ -10813,16 +10844,16 @@ function writeLegalPage(root, dir, page) {
|
|
|
10813
10844
|
|
|
10814
10845
|
${html}`;
|
|
10815
10846
|
}
|
|
10816
|
-
const pagePath =
|
|
10817
|
-
|
|
10818
|
-
|
|
10847
|
+
const pagePath = path41.join(root, dir, "+page.svelte");
|
|
10848
|
+
fs42.mkdirSync(path41.dirname(pagePath), { recursive: true });
|
|
10849
|
+
fs42.writeFileSync(pagePath, html);
|
|
10819
10850
|
const written = [pagePath];
|
|
10820
10851
|
if (metaTags) {
|
|
10821
|
-
const loaderPath =
|
|
10822
|
-
|
|
10852
|
+
const loaderPath = path41.join(root, dir, "+page.ts");
|
|
10853
|
+
fs42.writeFileSync(loaderPath, pageMetaTagsLoader(page.title, page.description));
|
|
10823
10854
|
written.push(loaderPath);
|
|
10824
10855
|
}
|
|
10825
|
-
return written.map((file) =>
|
|
10856
|
+
return written.map((file) => path41.relative(root, file));
|
|
10826
10857
|
}
|
|
10827
10858
|
|
|
10828
10859
|
// src/commands/legal/terms.ts
|
|
@@ -11219,7 +11250,7 @@ async function termsAction() {
|
|
|
11219
11250
|
});
|
|
11220
11251
|
const [relativeTermsPage, ...rest] = writeLegalPage(
|
|
11221
11252
|
workspaceRootDir,
|
|
11222
|
-
|
|
11253
|
+
path42.join(publicRoutesDir, LEGAL_DIR, "terms"),
|
|
11223
11254
|
{
|
|
11224
11255
|
html,
|
|
11225
11256
|
title: "Terms of Service",
|
|
@@ -11239,7 +11270,7 @@ async function termsAction() {
|
|
|
11239
11270
|
var terms = new Command60("terms").description("generate placeholder terms and conditions").configureHelp(helpConfig).action(() => runCommand(termsAction, "Failed to generate terms and conditions."));
|
|
11240
11271
|
|
|
11241
11272
|
// src/commands/legal/privacy.ts
|
|
11242
|
-
import
|
|
11273
|
+
import path43 from "node:path";
|
|
11243
11274
|
import { Command as Command61 } from "commander";
|
|
11244
11275
|
import * as p38 from "@clack/prompts";
|
|
11245
11276
|
var mapLabels = {
|
|
@@ -11955,7 +11986,7 @@ async function privacyAction() {
|
|
|
11955
11986
|
});
|
|
11956
11987
|
const [relativePrivacyPage, ...rest] = writeLegalPage(
|
|
11957
11988
|
workspaceRootDir,
|
|
11958
|
-
|
|
11989
|
+
path43.join(publicRoutesDir, LEGAL_DIR, "privacy"),
|
|
11959
11990
|
{
|
|
11960
11991
|
html,
|
|
11961
11992
|
title: "Privacy Policy",
|
|
@@ -11984,8 +12015,8 @@ import { Command as Command68 } from "commander";
|
|
|
11984
12015
|
import { Command as Command63 } from "commander";
|
|
11985
12016
|
|
|
11986
12017
|
// src/lib/data.ts
|
|
11987
|
-
import
|
|
11988
|
-
import
|
|
12018
|
+
import fs43 from "node:fs";
|
|
12019
|
+
import path44 from "node:path";
|
|
11989
12020
|
import { ClientResponseError } from "pocketbase";
|
|
11990
12021
|
|
|
11991
12022
|
// src/lib/collections.ts
|
|
@@ -12022,14 +12053,14 @@ function dependencyOrder(collections2, startingCollectionId) {
|
|
|
12022
12053
|
|
|
12023
12054
|
// src/lib/data.ts
|
|
12024
12055
|
function dataDir(cwd, kind) {
|
|
12025
|
-
return
|
|
12056
|
+
return path44.join(cwd, DATA_DIR, kind);
|
|
12026
12057
|
}
|
|
12027
12058
|
function getDataFiles(cwd, kind) {
|
|
12028
12059
|
const dir = dataDir(cwd, kind);
|
|
12029
|
-
if (!
|
|
12030
|
-
return
|
|
12060
|
+
if (!fs43.existsSync(dir)) return [];
|
|
12061
|
+
return fs43.readdirSync(dir).filter((file) => file.endsWith(".json")).sort((a, b) => a.localeCompare(b)).map((file) => ({
|
|
12031
12062
|
collectionName: file.replace(/\.json$/i, "").replace(/^\d+[-_]?/, ""),
|
|
12032
|
-
filePath:
|
|
12063
|
+
filePath: path44.join(dir, file)
|
|
12033
12064
|
}));
|
|
12034
12065
|
}
|
|
12035
12066
|
function getSeedFiles(cwd) {
|
|
@@ -12039,7 +12070,7 @@ function getFixtureFiles(cwd) {
|
|
|
12039
12070
|
return getDataFiles(cwd, "fixtures");
|
|
12040
12071
|
}
|
|
12041
12072
|
function readRecords(filePath) {
|
|
12042
|
-
return JSON.parse(
|
|
12073
|
+
return JSON.parse(fs43.readFileSync(filePath, "utf8"));
|
|
12043
12074
|
}
|
|
12044
12075
|
function readSeedIds(cwd) {
|
|
12045
12076
|
const ids = /* @__PURE__ */ new Map();
|
|
@@ -12076,7 +12107,7 @@ function describeError(e) {
|
|
|
12076
12107
|
return e instanceof Error ? e.message : String(e);
|
|
12077
12108
|
}
|
|
12078
12109
|
function label(cwd, filePath, count) {
|
|
12079
|
-
return `${
|
|
12110
|
+
return `${path44.relative(cwd, filePath)} (${count} records)`;
|
|
12080
12111
|
}
|
|
12081
12112
|
async function createRecords(pb, kind, cwd, { collectionName, filePath }) {
|
|
12082
12113
|
const records = readRecords(filePath);
|
|
@@ -12084,7 +12115,7 @@ async function createRecords(pb, kind, cwd, { collectionName, filePath }) {
|
|
|
12084
12115
|
try {
|
|
12085
12116
|
await pb.collection(collectionName).create(record);
|
|
12086
12117
|
} catch (e) {
|
|
12087
|
-
throw new DataLoadError(kind,
|
|
12118
|
+
throw new DataLoadError(kind, path44.relative(cwd, filePath), index, e);
|
|
12088
12119
|
}
|
|
12089
12120
|
}
|
|
12090
12121
|
return records.length;
|
|
@@ -12258,8 +12289,8 @@ var reset = new Command65("reset").description("clear and reload fixtures").conf
|
|
|
12258
12289
|
);
|
|
12259
12290
|
|
|
12260
12291
|
// src/commands/fixtures/generate.ts
|
|
12261
|
-
import
|
|
12262
|
-
import
|
|
12292
|
+
import fs44 from "node:fs";
|
|
12293
|
+
import path45 from "node:path";
|
|
12263
12294
|
import { Command as Command66, InvalidArgumentError } from "commander";
|
|
12264
12295
|
import * as p39 from "@clack/prompts";
|
|
12265
12296
|
import { annotate } from "annotate-json-schema";
|
|
@@ -12296,9 +12327,9 @@ async function loadCollections(pb) {
|
|
|
12296
12327
|
}
|
|
12297
12328
|
async function generateFixtureFiles(pb, workspaceRootDir, opts) {
|
|
12298
12329
|
const fixturesDir = dataDir(workspaceRootDir, "fixtures");
|
|
12299
|
-
|
|
12300
|
-
for (const file of
|
|
12301
|
-
if (file.endsWith(".json"))
|
|
12330
|
+
fs44.mkdirSync(fixturesDir, { recursive: true });
|
|
12331
|
+
for (const file of fs44.readdirSync(fixturesDir)) {
|
|
12332
|
+
if (file.endsWith(".json")) fs44.unlinkSync(path45.join(fixturesDir, file));
|
|
12302
12333
|
}
|
|
12303
12334
|
if (opts.seed !== void 0) faker.seed(opts.seed);
|
|
12304
12335
|
const generator = createGenerator({
|
|
@@ -12365,8 +12396,8 @@ async function generateFixtureFiles(pb, workspaceRootDir, opts) {
|
|
|
12365
12396
|
items.push(record);
|
|
12366
12397
|
}
|
|
12367
12398
|
const filename = `${padZeros(fileIndex, 2)}-${collection.name}.json`;
|
|
12368
|
-
|
|
12369
|
-
writtenFiles.push(`${
|
|
12399
|
+
fs44.writeFileSync(path45.join(fixturesDir, filename), JSON.stringify(items, null, 2));
|
|
12400
|
+
writtenFiles.push(`${path45.join(DATA_DIR, "fixtures", filename)} (${items.length} records)`);
|
|
12370
12401
|
fileIndex++;
|
|
12371
12402
|
}
|
|
12372
12403
|
return { writtenFiles, warnings };
|
|
@@ -12513,8 +12544,8 @@ var load2 = new Command69("load").description("load seeds into the database").op
|
|
|
12513
12544
|
);
|
|
12514
12545
|
|
|
12515
12546
|
// src/commands/seeds/save.ts
|
|
12516
|
-
import
|
|
12517
|
-
import
|
|
12547
|
+
import fs45 from "node:fs";
|
|
12548
|
+
import path46 from "node:path";
|
|
12518
12549
|
import { Command as Command70 } from "commander";
|
|
12519
12550
|
var padZeros2 = (num, length) => num.toString().padStart(length, "0");
|
|
12520
12551
|
function filterSystemFields(record, systemFieldNames) {
|
|
@@ -12534,10 +12565,10 @@ var save = new Command70("save").description("save the current data as seeds").o
|
|
|
12534
12565
|
if (existing.length > 0 && !opts.force) {
|
|
12535
12566
|
throw new Error("Existing seed files found in data/seeds. Pass --force to overwrite.");
|
|
12536
12567
|
}
|
|
12537
|
-
|
|
12568
|
+
fs45.mkdirSync(seedsPath, { recursive: true });
|
|
12538
12569
|
if (opts.force) {
|
|
12539
|
-
for (const file of
|
|
12540
|
-
if (file.endsWith(".json"))
|
|
12570
|
+
for (const file of fs45.readdirSync(seedsPath)) {
|
|
12571
|
+
if (file.endsWith(".json")) fs45.unlinkSync(path46.join(seedsPath, file));
|
|
12541
12572
|
}
|
|
12542
12573
|
}
|
|
12543
12574
|
const saved = [];
|
|
@@ -12566,13 +12597,13 @@ var save = new Command70("save").description("save the current data as seeds").o
|
|
|
12566
12597
|
const filtered = records.map(
|
|
12567
12598
|
(r) => filterSystemFields(r, systemFieldNames)
|
|
12568
12599
|
);
|
|
12569
|
-
const relativeSeedPath =
|
|
12600
|
+
const relativeSeedPath = path46.join(
|
|
12570
12601
|
DATA_DIR,
|
|
12571
12602
|
"seeds",
|
|
12572
12603
|
`${padZeros2(count, 2)}-${collectionName}.json`
|
|
12573
12604
|
);
|
|
12574
|
-
const seedPath =
|
|
12575
|
-
|
|
12605
|
+
const seedPath = path46.join(workspaceRootDir, relativeSeedPath);
|
|
12606
|
+
fs45.writeFileSync(seedPath, JSON.stringify(filtered, null, 2));
|
|
12576
12607
|
saved.push(`${relativeSeedPath} (${filtered.length} records)`);
|
|
12577
12608
|
count++;
|
|
12578
12609
|
}
|
|
@@ -12719,9 +12750,9 @@ import { Command as Command82 } from "commander";
|
|
|
12719
12750
|
import { Command as Command76 } from "commander";
|
|
12720
12751
|
|
|
12721
12752
|
// src/lib/migrate.ts
|
|
12722
|
-
import
|
|
12753
|
+
import path47 from "node:path";
|
|
12723
12754
|
import process30 from "node:process";
|
|
12724
|
-
import { x as
|
|
12755
|
+
import { x as x4 } from "tinyexec";
|
|
12725
12756
|
function migrateRoot() {
|
|
12726
12757
|
return findWorkspaceRoot() ?? process30.cwd();
|
|
12727
12758
|
}
|
|
@@ -12729,13 +12760,13 @@ async function runPocketbaseMigrate(args) {
|
|
|
12729
12760
|
const cwd = migrateRoot();
|
|
12730
12761
|
const { getBinaryPath } = await import("pocketbase-server");
|
|
12731
12762
|
const binaryPath = getBinaryPath();
|
|
12732
|
-
await
|
|
12763
|
+
await x4(
|
|
12733
12764
|
binaryPath,
|
|
12734
12765
|
[
|
|
12735
12766
|
"--dir",
|
|
12736
|
-
|
|
12767
|
+
path47.join(cwd, DATA_DIR),
|
|
12737
12768
|
"--migrationsDir",
|
|
12738
|
-
|
|
12769
|
+
path47.join(cwd, MIGRATIONS_DIR),
|
|
12739
12770
|
"migrate",
|
|
12740
12771
|
...args
|
|
12741
12772
|
],
|
|
@@ -12783,8 +12814,8 @@ var down = new Command77("down").alias("rollback").description("revert the last
|
|
|
12783
12814
|
);
|
|
12784
12815
|
|
|
12785
12816
|
// src/commands/migrate/create.ts
|
|
12786
|
-
import
|
|
12787
|
-
import
|
|
12817
|
+
import fs46 from "node:fs";
|
|
12818
|
+
import path48 from "node:path";
|
|
12788
12819
|
import { Command as Command78 } from "commander";
|
|
12789
12820
|
var create2 = new Command78("create").alias("new").description("create a new blank migration").argument("<name>", "migration name (snake_case)").configureHelp(helpConfig).action(
|
|
12790
12821
|
(name) => runCommand(async () => {
|
|
@@ -12795,7 +12826,7 @@ var create2 = new Command78("create").alias("new").description("create a new bla
|
|
|
12795
12826
|
const added = [...after].filter((f) => !before.has(f));
|
|
12796
12827
|
reportResult({
|
|
12797
12828
|
summary: `Created blank migration ${name}.`,
|
|
12798
|
-
filesCreated: added.map((f) =>
|
|
12829
|
+
filesCreated: added.map((f) => path48.join(MIGRATIONS_DIR, f)),
|
|
12799
12830
|
nextSteps: [
|
|
12800
12831
|
`Open the new file in ${MIGRATIONS_DIR}/ and fill in the up/down handlers.`,
|
|
12801
12832
|
"Run `vela migrate up` to apply the migration once the handlers are written."
|
|
@@ -12804,14 +12835,14 @@ var create2 = new Command78("create").alias("new").description("create a new bla
|
|
|
12804
12835
|
}, "Failed to create migration.")
|
|
12805
12836
|
);
|
|
12806
12837
|
function listMigrationFiles(cwd) {
|
|
12807
|
-
const dir =
|
|
12808
|
-
if (!
|
|
12809
|
-
return new Set(
|
|
12838
|
+
const dir = path48.join(cwd, MIGRATIONS_DIR);
|
|
12839
|
+
if (!fs46.existsSync(dir)) return /* @__PURE__ */ new Set();
|
|
12840
|
+
return new Set(fs46.readdirSync(dir).filter((f) => /\.[jt]s$/.test(f)));
|
|
12810
12841
|
}
|
|
12811
12842
|
|
|
12812
12843
|
// src/commands/migrate/collections.ts
|
|
12813
|
-
import
|
|
12814
|
-
import
|
|
12844
|
+
import fs47 from "node:fs";
|
|
12845
|
+
import path49 from "node:path";
|
|
12815
12846
|
import { Command as Command79 } from "commander";
|
|
12816
12847
|
var collections = new Command79("collections").alias("snapshot").description("snapshot local collections into a new migration").configureHelp(helpConfig).action(
|
|
12817
12848
|
() => runCommand(async () => {
|
|
@@ -12828,7 +12859,7 @@ var collections = new Command79("collections").alias("snapshot").description("sn
|
|
|
12828
12859
|
}
|
|
12829
12860
|
reportResult({
|
|
12830
12861
|
summary: "Snapshotted local collections into a new migration.",
|
|
12831
|
-
filesCreated: added.map((f) =>
|
|
12862
|
+
filesCreated: added.map((f) => path49.join(MIGRATIONS_DIR, f)),
|
|
12832
12863
|
nextSteps: [
|
|
12833
12864
|
`Review the generated snapshot in ${MIGRATIONS_DIR}/.`,
|
|
12834
12865
|
"Commit the snapshot so teammates pick up the new schema.",
|
|
@@ -12838,9 +12869,9 @@ var collections = new Command79("collections").alias("snapshot").description("sn
|
|
|
12838
12869
|
}, "Failed to snapshot collections.")
|
|
12839
12870
|
);
|
|
12840
12871
|
function listMigrationFiles2(cwd) {
|
|
12841
|
-
const dir =
|
|
12842
|
-
if (!
|
|
12843
|
-
return new Set(
|
|
12872
|
+
const dir = path49.join(cwd, MIGRATIONS_DIR);
|
|
12873
|
+
if (!fs47.existsSync(dir)) return /* @__PURE__ */ new Set();
|
|
12874
|
+
return new Set(fs47.readdirSync(dir).filter((f) => /\.[jt]s$/.test(f)));
|
|
12844
12875
|
}
|
|
12845
12876
|
|
|
12846
12877
|
// src/commands/migrate/history-sync.ts
|
|
@@ -12856,14 +12887,14 @@ var historySync = new Command80("history-sync").description("drop _migrations ro
|
|
|
12856
12887
|
);
|
|
12857
12888
|
|
|
12858
12889
|
// src/commands/migrate/sveltekit-3.ts
|
|
12859
|
-
import
|
|
12890
|
+
import path50 from "node:path";
|
|
12860
12891
|
import process31 from "node:process";
|
|
12861
12892
|
import { Command as Command81 } from "commander";
|
|
12862
12893
|
import * as p44 from "@clack/prompts";
|
|
12863
12894
|
import pc13 from "picocolors";
|
|
12864
12895
|
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(
|
|
12865
12896
|
(options) => runCommand(async () => {
|
|
12866
|
-
const root = options.cwd ?
|
|
12897
|
+
const root = options.cwd ? path50.resolve(options.cwd) : findWorkspaceRoot() ?? process31.cwd();
|
|
12867
12898
|
p44.intro(pc13.bgCyan(pc13.black(" vela migrate sveltekit-3 ")));
|
|
12868
12899
|
const result = await runKit3Migration(root, {
|
|
12869
12900
|
install: options.install,
|
|
@@ -12880,7 +12911,7 @@ function printReport(root, result) {
|
|
|
12880
12911
|
sections.push({ label: "Build output removed first", items: result.sv.cleared });
|
|
12881
12912
|
}
|
|
12882
12913
|
for (const fixup2 of changed) sections.push({ label: fixup2.name, items: fixup2.details });
|
|
12883
|
-
const summary = result.mode === "repair" ? changed.length > 0 ? "Already on SvelteKit 3; brought the vela setup up to date." : "Already on SvelteKit 3; nothing left to change." : `Migrated ${
|
|
12914
|
+
const summary = result.mode === "repair" ? changed.length > 0 ? "Already on SvelteKit 3; brought the vela setup up to date." : "Already on SvelteKit 3; nothing left to change." : `Migrated ${path50.basename(root)} to SvelteKit 3.`;
|
|
12884
12915
|
reportResult({ summary, sections });
|
|
12885
12916
|
const tasks = result.tasks;
|
|
12886
12917
|
if (tasks && (tasks.sections.length > 0 || tasks.markerComments > 0)) {
|
|
@@ -12938,8 +12969,8 @@ function nextStepsFor(result) {
|
|
|
12938
12969
|
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);
|
|
12939
12970
|
|
|
12940
12971
|
// src/commands/dev.ts
|
|
12941
|
-
import
|
|
12942
|
-
import
|
|
12972
|
+
import fs48 from "node:fs";
|
|
12973
|
+
import path52 from "node:path";
|
|
12943
12974
|
import process33 from "node:process";
|
|
12944
12975
|
import { performance } from "node:perf_hooks";
|
|
12945
12976
|
import { Command as Command83, InvalidArgumentError as InvalidArgumentError4 } from "commander";
|
|
@@ -12971,7 +13002,7 @@ function createPocketbaseLogFilter() {
|
|
|
12971
13002
|
}
|
|
12972
13003
|
|
|
12973
13004
|
// src/lib/vite.ts
|
|
12974
|
-
import
|
|
13005
|
+
import path51 from "node:path";
|
|
12975
13006
|
import process32 from "node:process";
|
|
12976
13007
|
import { createRequire as createRequire4 } from "node:module";
|
|
12977
13008
|
import { pathToFileURL } from "node:url";
|
|
@@ -12991,7 +13022,7 @@ function viteVersionError(version) {
|
|
|
12991
13022
|
}
|
|
12992
13023
|
function resolveProjectVite(cwd) {
|
|
12993
13024
|
try {
|
|
12994
|
-
return createRequire4(
|
|
13025
|
+
return createRequire4(path51.join(cwd, "package.json")).resolve("vite");
|
|
12995
13026
|
} catch {
|
|
12996
13027
|
return null;
|
|
12997
13028
|
}
|
|
@@ -13021,8 +13052,8 @@ var dev = new Command83("dev").description("start the development server").optio
|
|
|
13021
13052
|
process33.env.VELA_DATA_DIR ??= localDataDir(cwd);
|
|
13022
13053
|
const startTime = performance.now();
|
|
13023
13054
|
const { createServer, resolveConfig, version } = await loadVite(cwd);
|
|
13024
|
-
const viteMetadataDir =
|
|
13025
|
-
const viteMetadataFile =
|
|
13055
|
+
const viteMetadataDir = path52.join(cwd, "node_modules", ".vite");
|
|
13056
|
+
const viteMetadataFile = path52.join(viteMetadataDir, "_pocketbase_metadata.json");
|
|
13026
13057
|
const serverOptions = {};
|
|
13027
13058
|
if (options.open !== void 0) serverOptions.open = options.open;
|
|
13028
13059
|
if (options.host !== void 0) serverOptions.host = options.host;
|
|
@@ -13038,7 +13069,7 @@ var dev = new Command83("dev").description("start the development server").optio
|
|
|
13038
13069
|
const needsStart = backend3 && !process33.env.POCKETBASE_URL;
|
|
13039
13070
|
const cleanup = () => {
|
|
13040
13071
|
if (pbProc?.pid) pbProc.kill();
|
|
13041
|
-
if (
|
|
13072
|
+
if (fs48.existsSync(viteMetadataFile)) fs48.rmSync(viteMetadataFile);
|
|
13042
13073
|
};
|
|
13043
13074
|
if (needsStart) {
|
|
13044
13075
|
const resolved = await resolveConfig(inlineConfig, "serve");
|
|
@@ -13056,11 +13087,11 @@ var dev = new Command83("dev").description("start the development server").optio
|
|
|
13056
13087
|
)
|
|
13057
13088
|
);
|
|
13058
13089
|
}
|
|
13059
|
-
const dataDir2 =
|
|
13090
|
+
const dataDir2 = path52.join(cwd, DATA_DIR);
|
|
13060
13091
|
const started = await startPocketbaseServe({
|
|
13061
13092
|
dataDir: dataDir2,
|
|
13062
13093
|
migrationsDir: MIGRATIONS_DIR,
|
|
13063
|
-
hooksDir:
|
|
13094
|
+
hooksDir: path52.join(dataDir2, "hooks"),
|
|
13064
13095
|
dev: true,
|
|
13065
13096
|
stdio: "pipe",
|
|
13066
13097
|
env: {
|
|
@@ -13082,8 +13113,8 @@ var dev = new Command83("dev").description("start the development server").optio
|
|
|
13082
13113
|
if (!backend3) return;
|
|
13083
13114
|
const { address, port: vitePort } = server.httpServer.address();
|
|
13084
13115
|
const viteHost = address === "::1" ? "localhost" : address;
|
|
13085
|
-
await
|
|
13086
|
-
await
|
|
13116
|
+
await fs48.promises.mkdir(viteMetadataDir, { recursive: true });
|
|
13117
|
+
await fs48.promises.writeFile(
|
|
13087
13118
|
viteMetadataFile,
|
|
13088
13119
|
JSON.stringify({
|
|
13089
13120
|
pocketbaseUrl: process33.env.POCKETBASE_URL,
|
|
@@ -13114,18 +13145,18 @@ var dev = new Command83("dev").description("start the development server").optio
|
|
|
13114
13145
|
});
|
|
13115
13146
|
async function startWatchingTypes(cwd, pb) {
|
|
13116
13147
|
const { processTypes } = await import("@velastack/pocketbase-codegen");
|
|
13117
|
-
const typesDir =
|
|
13118
|
-
const pocketbaseDir =
|
|
13119
|
-
const pocketbaseTypes =
|
|
13148
|
+
const typesDir = path52.resolve(cwd, ".svelte-kit", "types");
|
|
13149
|
+
const pocketbaseDir = path52.join(typesDir, "pocketbase");
|
|
13150
|
+
const pocketbaseTypes = path52.join(pocketbaseDir, "$types.d.ts");
|
|
13120
13151
|
const regenerate = () => processTypes(pb, typesDir).catch(() => {
|
|
13121
13152
|
});
|
|
13122
13153
|
await regenerate();
|
|
13123
13154
|
void (async () => {
|
|
13124
13155
|
for (; ; ) {
|
|
13125
13156
|
try {
|
|
13126
|
-
await
|
|
13127
|
-
for await (const event of
|
|
13128
|
-
if (event.eventType === "rename" && event.filename === "$types.d.ts" && !
|
|
13157
|
+
await fs48.promises.mkdir(pocketbaseDir, { recursive: true });
|
|
13158
|
+
for await (const event of fs48.promises.watch(pocketbaseDir)) {
|
|
13159
|
+
if (event.eventType === "rename" && event.filename === "$types.d.ts" && !fs48.existsSync(pocketbaseTypes)) {
|
|
13129
13160
|
setTimeout(regenerate, 100);
|
|
13130
13161
|
}
|
|
13131
13162
|
}
|
|
@@ -13137,15 +13168,15 @@ async function startWatchingTypes(cwd, pb) {
|
|
|
13137
13168
|
}
|
|
13138
13169
|
|
|
13139
13170
|
// src/commands/build.ts
|
|
13140
|
-
import
|
|
13141
|
-
import
|
|
13171
|
+
import fs49 from "node:fs";
|
|
13172
|
+
import path53 from "node:path";
|
|
13142
13173
|
import process35 from "node:process";
|
|
13143
13174
|
import { Command as Command84 } from "commander";
|
|
13144
13175
|
import * as p45 from "@clack/prompts";
|
|
13145
13176
|
import pc16 from "picocolors";
|
|
13146
|
-
import { x as
|
|
13147
|
-
import { detect as
|
|
13148
|
-
import { resolveCommand as
|
|
13177
|
+
import { x as x5 } from "tinyexec";
|
|
13178
|
+
import { detect as detect8 } from "package-manager-detector";
|
|
13179
|
+
import { resolveCommand as resolveCommand6 } from "package-manager-detector/commands";
|
|
13149
13180
|
|
|
13150
13181
|
// src/lib/build-env.ts
|
|
13151
13182
|
function applyBuildEnv(cwd, env2 = process.env) {
|
|
@@ -13180,7 +13211,7 @@ function splitHosts(value) {
|
|
|
13180
13211
|
}
|
|
13181
13212
|
|
|
13182
13213
|
// src/commands/build.ts
|
|
13183
|
-
var PRERENDERED_DIR =
|
|
13214
|
+
var PRERENDERED_DIR = path53.join(".svelte-kit", "output", "prerendered");
|
|
13184
13215
|
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) => {
|
|
13185
13216
|
const cwd = process35.cwd();
|
|
13186
13217
|
warnIfKit2(findWorkspaceRoot(cwd) ?? cwd, (m) => p45.log.warn(m));
|
|
@@ -13198,22 +13229,22 @@ var build = new Command84("build").description("build the app").configureHelp(he
|
|
|
13198
13229
|
onTerminate(cleanup);
|
|
13199
13230
|
if (needsStart) {
|
|
13200
13231
|
await ensureSuperuser(cwd);
|
|
13201
|
-
const dataDir2 =
|
|
13232
|
+
const dataDir2 = path53.join(cwd, DATA_DIR);
|
|
13202
13233
|
const started = await startPocketbaseServe({
|
|
13203
13234
|
dataDir: dataDir2,
|
|
13204
13235
|
migrationsDir: MIGRATIONS_DIR,
|
|
13205
|
-
hooksDir:
|
|
13236
|
+
hooksDir: path53.join(dataDir2, "hooks"),
|
|
13206
13237
|
dev: true
|
|
13207
13238
|
});
|
|
13208
13239
|
pbProc = started.proc;
|
|
13209
13240
|
process35.env.POCKETBASE_URL = started.url;
|
|
13210
13241
|
}
|
|
13211
13242
|
try {
|
|
13212
|
-
const pm = (await
|
|
13213
|
-
const resolved =
|
|
13243
|
+
const pm = (await detect8({ cwd }))?.name ?? "npm";
|
|
13244
|
+
const resolved = resolveCommand6(pm, "execute", ["vite", "build"]);
|
|
13214
13245
|
const args = resolved.args.slice();
|
|
13215
13246
|
if (pm === "npm") args.unshift("--yes");
|
|
13216
|
-
const vite =
|
|
13247
|
+
const vite = x5(resolved.command, args, {
|
|
13217
13248
|
nodeOptions: { cwd, stdio: "inherit" },
|
|
13218
13249
|
throwOnError: true
|
|
13219
13250
|
});
|
|
@@ -13249,8 +13280,8 @@ async function originForBuild(cwd, target) {
|
|
|
13249
13280
|
}
|
|
13250
13281
|
}
|
|
13251
13282
|
function warnIfPrerendered(cwd) {
|
|
13252
|
-
const dir =
|
|
13253
|
-
if (!
|
|
13283
|
+
const dir = path53.join(cwd, PRERENDERED_DIR);
|
|
13284
|
+
if (!fs49.existsSync(dir) || fs49.readdirSync(dir).length === 0) return;
|
|
13254
13285
|
if (process35.env.VELA_ORIGIN === "") {
|
|
13255
13286
|
p45.log.warn(
|
|
13256
13287
|
`Prerendered pages were built with no origin, on purpose: this app is served on
|
|
@@ -13273,16 +13304,16 @@ Set one with ${pc16.cyan("vela deploy --domain example.com")}, or pass ${pc16.cy
|
|
|
13273
13304
|
}
|
|
13274
13305
|
|
|
13275
13306
|
// src/commands/preview.ts
|
|
13276
|
-
import
|
|
13277
|
-
import
|
|
13307
|
+
import fs50 from "node:fs";
|
|
13308
|
+
import path54 from "node:path";
|
|
13278
13309
|
import process36 from "node:process";
|
|
13279
13310
|
import { Command as Command85 } from "commander";
|
|
13280
13311
|
import * as p46 from "@clack/prompts";
|
|
13281
13312
|
import pc17 from "picocolors";
|
|
13282
|
-
import { x as
|
|
13283
|
-
import { detect as
|
|
13284
|
-
import { resolveCommand as
|
|
13285
|
-
var ADAPTER_NODE_MODULE =
|
|
13313
|
+
import { x as x6 } from "tinyexec";
|
|
13314
|
+
import { detect as detect9 } from "package-manager-detector";
|
|
13315
|
+
import { resolveCommand as resolveCommand7 } from "package-manager-detector/commands";
|
|
13316
|
+
var ADAPTER_NODE_MODULE = path54.join("build", "adapter-node.js");
|
|
13286
13317
|
var preview = new Command85("preview").description("preview the built app").configureHelp(helpConfig).action(async () => {
|
|
13287
13318
|
const cwd = process36.cwd();
|
|
13288
13319
|
process36.env.VELA_DATA_DIR ??= localDataDir(cwd);
|
|
@@ -13297,22 +13328,22 @@ var preview = new Command85("preview").description("preview the built app").conf
|
|
|
13297
13328
|
};
|
|
13298
13329
|
onTerminate(cleanup);
|
|
13299
13330
|
if (needsStart) {
|
|
13300
|
-
const dataDir2 =
|
|
13331
|
+
const dataDir2 = path54.join(cwd, DATA_DIR);
|
|
13301
13332
|
const started = await startPocketbaseServe({
|
|
13302
13333
|
dataDir: dataDir2,
|
|
13303
13334
|
migrationsDir: MIGRATIONS_DIR,
|
|
13304
|
-
hooksDir:
|
|
13335
|
+
hooksDir: path54.join(dataDir2, "hooks"),
|
|
13305
13336
|
dev: true
|
|
13306
13337
|
});
|
|
13307
13338
|
pbProc = started.proc;
|
|
13308
13339
|
process36.env.POCKETBASE_URL = started.url;
|
|
13309
13340
|
}
|
|
13310
13341
|
try {
|
|
13311
|
-
const pm = (await
|
|
13312
|
-
const resolved =
|
|
13342
|
+
const pm = (await detect9({ cwd }))?.name ?? "npm";
|
|
13343
|
+
const resolved = resolveCommand7(pm, "execute", ["vite", "preview"]);
|
|
13313
13344
|
const args = resolved.args.slice();
|
|
13314
13345
|
if (pm === "npm") args.unshift("--yes");
|
|
13315
|
-
const vite =
|
|
13346
|
+
const vite = x6(resolved.command, args, {
|
|
13316
13347
|
nodeOptions: { cwd, stdio: "inherit" },
|
|
13317
13348
|
throwOnError: true
|
|
13318
13349
|
});
|
|
@@ -13335,7 +13366,7 @@ function bakedOrigin(source) {
|
|
|
13335
13366
|
function warnIfOriginBaked(cwd) {
|
|
13336
13367
|
let source;
|
|
13337
13368
|
try {
|
|
13338
|
-
source =
|
|
13369
|
+
source = fs50.readFileSync(path54.join(cwd, ADAPTER_NODE_MODULE), "utf8");
|
|
13339
13370
|
} catch {
|
|
13340
13371
|
return;
|
|
13341
13372
|
}
|
|
@@ -13351,12 +13382,12 @@ set empty so no domain is baked in.`
|
|
|
13351
13382
|
}
|
|
13352
13383
|
|
|
13353
13384
|
// src/commands/sync.ts
|
|
13354
|
-
import
|
|
13385
|
+
import path55 from "node:path";
|
|
13355
13386
|
import { Command as Command86 } from "commander";
|
|
13356
13387
|
var sync = new Command86("sync").description("sync types from the database").configureHelp(helpConfig).action(
|
|
13357
13388
|
() => runCommand(async () => {
|
|
13358
13389
|
const { workspaceRootDir } = await getWorkspace();
|
|
13359
|
-
const typesDir =
|
|
13390
|
+
const typesDir = path55.join(workspaceRootDir, ".svelte-kit", "types");
|
|
13360
13391
|
const { processTypes } = await import("@velastack/pocketbase-codegen");
|
|
13361
13392
|
await withPocketbase(workspaceRootDir, async (pb) => {
|
|
13362
13393
|
await processTypes(pb, typesDir);
|
|
@@ -13427,8 +13458,8 @@ var provision = addSshOptions(
|
|
|
13427
13458
|
);
|
|
13428
13459
|
|
|
13429
13460
|
// src/commands/deploy.ts
|
|
13430
|
-
import
|
|
13431
|
-
import
|
|
13461
|
+
import path59 from "node:path";
|
|
13462
|
+
import fs54 from "node:fs";
|
|
13432
13463
|
import process38 from "node:process";
|
|
13433
13464
|
import { Command as Command88, Option as Option2 } from "commander";
|
|
13434
13465
|
import * as p49 from "@clack/prompts";
|
|
@@ -13546,12 +13577,12 @@ function reachedInstances(states, appId, layer) {
|
|
|
13546
13577
|
}
|
|
13547
13578
|
|
|
13548
13579
|
// src/lib/build-stack.ts
|
|
13549
|
-
import
|
|
13550
|
-
import
|
|
13580
|
+
import fs52 from "node:fs";
|
|
13581
|
+
import path57 from "node:path";
|
|
13551
13582
|
|
|
13552
13583
|
// src/lib/static-env.ts
|
|
13553
|
-
import
|
|
13554
|
-
import
|
|
13584
|
+
import fs51 from "node:fs";
|
|
13585
|
+
import path56 from "node:path";
|
|
13555
13586
|
import { ENV_DECL_CANDIDATES } from "@velastack/patterns";
|
|
13556
13587
|
import { Node as Node5, Project as Project5, QuoteKind as QuoteKind3 } from "ts-morph";
|
|
13557
13588
|
function staticEnv(root) {
|
|
@@ -13565,7 +13596,7 @@ function staticEnv(root) {
|
|
|
13565
13596
|
};
|
|
13566
13597
|
}
|
|
13567
13598
|
const file = findEnvDecl(root);
|
|
13568
|
-
const rel = file ?
|
|
13599
|
+
const rel = file ? path56.relative(root, file).split(path56.sep).join("/") : ENV_DECL_CANDIDATES[0];
|
|
13569
13600
|
return {
|
|
13570
13601
|
names: file ? staticEnvDeclarations(file) : /* @__PURE__ */ new Set(),
|
|
13571
13602
|
rule: "declarations",
|
|
@@ -13575,8 +13606,8 @@ function staticEnv(root) {
|
|
|
13575
13606
|
}
|
|
13576
13607
|
function findEnvDecl(root) {
|
|
13577
13608
|
for (const rel of ENV_DECL_CANDIDATES) {
|
|
13578
|
-
const abs =
|
|
13579
|
-
if (
|
|
13609
|
+
const abs = path56.join(root, rel);
|
|
13610
|
+
if (fs51.existsSync(abs)) return abs;
|
|
13580
13611
|
}
|
|
13581
13612
|
return null;
|
|
13582
13613
|
}
|
|
@@ -13648,10 +13679,10 @@ var SOURCE_EXTENSIONS2 = /* @__PURE__ */ new Set([".ts", ".js", ".mts", ".mjs",
|
|
|
13648
13679
|
var STATIC_IMPORT = /import\s*(?:type\s*)?\{([^}]*)\}\s*from\s*['"]\$env\/static\/(?:private|public)['"]/g;
|
|
13649
13680
|
function staticEnvImports(root) {
|
|
13650
13681
|
const names = /* @__PURE__ */ new Set();
|
|
13651
|
-
const src =
|
|
13652
|
-
if (!
|
|
13682
|
+
const src = path56.join(root, "src");
|
|
13683
|
+
if (!fs51.existsSync(src)) return names;
|
|
13653
13684
|
for (const file of sourceFiles2(src)) {
|
|
13654
|
-
const content =
|
|
13685
|
+
const content = fs51.readFileSync(file, "utf8");
|
|
13655
13686
|
if (!content.includes("$env/static/")) continue;
|
|
13656
13687
|
for (const match of content.matchAll(STATIC_IMPORT)) {
|
|
13657
13688
|
for (const spec of match[1].split(",")) {
|
|
@@ -13663,11 +13694,11 @@ function staticEnvImports(root) {
|
|
|
13663
13694
|
return names;
|
|
13664
13695
|
}
|
|
13665
13696
|
function* sourceFiles2(dir) {
|
|
13666
|
-
for (const entry of
|
|
13697
|
+
for (const entry of fs51.readdirSync(dir, { withFileTypes: true })) {
|
|
13667
13698
|
if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
|
|
13668
|
-
const full =
|
|
13699
|
+
const full = path56.join(dir, entry.name);
|
|
13669
13700
|
if (entry.isDirectory()) yield* sourceFiles2(full);
|
|
13670
|
-
else if (SOURCE_EXTENSIONS2.has(
|
|
13701
|
+
else if (SOURCE_EXTENSIONS2.has(path56.extname(entry.name))) yield full;
|
|
13671
13702
|
}
|
|
13672
13703
|
}
|
|
13673
13704
|
|
|
@@ -13678,8 +13709,8 @@ var DevOnlyEnvError = class extends Error {
|
|
|
13678
13709
|
function buildStack(root, input) {
|
|
13679
13710
|
const env2 = { ...input.stack, ...input.derived };
|
|
13680
13711
|
const blanked = [];
|
|
13681
|
-
const file =
|
|
13682
|
-
const local =
|
|
13712
|
+
const file = path57.join(root, ".env");
|
|
13713
|
+
const local = fs52.existsSync(file) ? readLocalEnvFile(file) : {};
|
|
13683
13714
|
for (const key of Object.keys(local)) {
|
|
13684
13715
|
if (key in env2) continue;
|
|
13685
13716
|
if (!input.tunnel && LOCAL_BUILD_KEYS.test(key)) continue;
|
|
@@ -13700,16 +13731,16 @@ The build would bake in your development value. Set ${baked.length === 1 ? "it"
|
|
|
13700
13731
|
}
|
|
13701
13732
|
|
|
13702
13733
|
// src/lib/env-nudge.ts
|
|
13703
|
-
import
|
|
13704
|
-
import
|
|
13734
|
+
import fs53 from "node:fs";
|
|
13735
|
+
import path58 from "node:path";
|
|
13705
13736
|
import process37 from "node:process";
|
|
13706
13737
|
import * as p48 from "@clack/prompts";
|
|
13707
13738
|
import pc19 from "picocolors";
|
|
13708
13739
|
var ENV_EXAMPLE = ".env.example";
|
|
13709
13740
|
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_)/;
|
|
13710
13741
|
function missingFromExample(root, present) {
|
|
13711
|
-
const file =
|
|
13712
|
-
if (!
|
|
13742
|
+
const file = path58.join(root, ENV_EXAMPLE);
|
|
13743
|
+
if (!fs53.existsSync(file)) return [];
|
|
13713
13744
|
const have = new Set(present);
|
|
13714
13745
|
return Object.keys(readLocalEnvFile(file)).filter((key) => !have.has(key) && !SUPPLIED.test(key)).sort();
|
|
13715
13746
|
}
|
|
@@ -14058,12 +14089,12 @@ ${pc20.cyan(err.snippet)}` : err.message);
|
|
|
14058
14089
|
current = detectAdapter(workspaceRootDir);
|
|
14059
14090
|
} catch {
|
|
14060
14091
|
}
|
|
14061
|
-
const editable = current !== void 0 && !/^svelte\.config\./.test(
|
|
14092
|
+
const editable = current !== void 0 && !/^svelte\.config\./.test(path59.basename(current.file));
|
|
14062
14093
|
if (current && editable && (current.kind === "auto" || current.kind === "none") && isInteractive()) {
|
|
14063
14094
|
const has = current.kind === "auto" ? `is on ${ADAPTER_AUTO}` : "has no SvelteKit adapter configured";
|
|
14064
14095
|
const confirmed = await p49.confirm({
|
|
14065
14096
|
message: `This project ${has}, and vela deploy runs the app as a Node server.
|
|
14066
|
-
Switch it to ${ADAPTER_NODE}? This edits ${
|
|
14097
|
+
Switch it to ${ADAPTER_NODE}? This edits ${path59.basename(current.file)} and package.json.`
|
|
14067
14098
|
});
|
|
14068
14099
|
if (p49.isCancel(confirmed) || !confirmed) {
|
|
14069
14100
|
p49.cancel("Nothing was changed, and nothing was deployed.");
|
|
@@ -14187,7 +14218,7 @@ async function uploadRelease(session, instance, release, entries) {
|
|
|
14187
14218
|
}
|
|
14188
14219
|
function isDirectory(target) {
|
|
14189
14220
|
try {
|
|
14190
|
-
return
|
|
14221
|
+
return fs54.statSync(target).isDirectory();
|
|
14191
14222
|
} catch {
|
|
14192
14223
|
return false;
|
|
14193
14224
|
}
|
|
@@ -14228,7 +14259,7 @@ async function serverTimeOrLocal(session) {
|
|
|
14228
14259
|
}
|
|
14229
14260
|
|
|
14230
14261
|
// src/commands/link.ts
|
|
14231
|
-
import
|
|
14262
|
+
import path60 from "node:path";
|
|
14232
14263
|
import process39 from "node:process";
|
|
14233
14264
|
import { Command as Command89 } from "commander";
|
|
14234
14265
|
import * as p50 from "@clack/prompts";
|
|
@@ -14291,12 +14322,12 @@ async function promptProjectName(workspaceRootDir) {
|
|
|
14291
14322
|
}
|
|
14292
14323
|
function defaultProjectName2(workspaceRootDir) {
|
|
14293
14324
|
try {
|
|
14294
|
-
const pkg = readPackageJson(
|
|
14325
|
+
const pkg = readPackageJson(path60.join(workspaceRootDir, "package.json"));
|
|
14295
14326
|
const name = pkg.name;
|
|
14296
14327
|
if (typeof name === "string" && name.trim()) return name.trim();
|
|
14297
14328
|
} catch {
|
|
14298
14329
|
}
|
|
14299
|
-
return
|
|
14330
|
+
return path60.basename(workspaceRootDir);
|
|
14300
14331
|
}
|
|
14301
14332
|
|
|
14302
14333
|
// src/commands/env.ts
|
|
@@ -14309,17 +14340,17 @@ import * as p53 from "@clack/prompts";
|
|
|
14309
14340
|
import pc23 from "picocolors";
|
|
14310
14341
|
|
|
14311
14342
|
// src/lib/local-env.ts
|
|
14312
|
-
import
|
|
14343
|
+
import fs55 from "node:fs";
|
|
14313
14344
|
import * as p51 from "@clack/prompts";
|
|
14314
14345
|
import pc21 from "picocolors";
|
|
14315
14346
|
function readLocalEnv(envFile) {
|
|
14316
|
-
if (!
|
|
14347
|
+
if (!fs55.existsSync(envFile)) return {};
|
|
14317
14348
|
return readLocalEnvFile(envFile);
|
|
14318
14349
|
}
|
|
14319
14350
|
function editLocalEnv(envFile, edit) {
|
|
14320
|
-
const before =
|
|
14351
|
+
const before = fs55.existsSync(envFile) ? fs55.readFileSync(envFile, "utf8") : "";
|
|
14321
14352
|
const after = edit(before);
|
|
14322
|
-
if (after !== before)
|
|
14353
|
+
if (after !== before) fs55.writeFileSync(envFile, after);
|
|
14323
14354
|
}
|
|
14324
14355
|
function setLocalEnv(envFile, key, value) {
|
|
14325
14356
|
editLocalEnv(envFile, (content) => upsertEnvVar(content, key, value));
|
|
@@ -14848,8 +14879,8 @@ var envUnset = addEnvTargetOptions(
|
|
|
14848
14879
|
);
|
|
14849
14880
|
|
|
14850
14881
|
// src/commands/env/import.ts
|
|
14851
|
-
import
|
|
14852
|
-
import
|
|
14882
|
+
import fs56 from "node:fs";
|
|
14883
|
+
import path61 from "node:path";
|
|
14853
14884
|
import process42 from "node:process";
|
|
14854
14885
|
import { Command as Command93 } from "commander";
|
|
14855
14886
|
import * as p56 from "@clack/prompts";
|
|
@@ -14920,10 +14951,10 @@ function report2(outcome, where) {
|
|
|
14920
14951
|
p56.log.success(`${parts.join(", ")} variable(s) updated ${pc26.dim(`(${where})`)}`);
|
|
14921
14952
|
}
|
|
14922
14953
|
function resolve(file) {
|
|
14923
|
-
return
|
|
14954
|
+
return path61.resolve(process42.cwd(), file);
|
|
14924
14955
|
}
|
|
14925
14956
|
function read(resolved, shown) {
|
|
14926
|
-
if (!
|
|
14957
|
+
if (!fs56.existsSync(resolved)) throw new Error(`${shown} does not exist.`);
|
|
14927
14958
|
const incoming = readLocalEnvFile(resolved);
|
|
14928
14959
|
if (Object.keys(incoming).length === 0) p56.log.info(`${shown} has no variables to import.`);
|
|
14929
14960
|
return incoming;
|
|
@@ -15312,8 +15343,8 @@ var admin = new Command100("admin").description("manage admin panel logins").con
|
|
|
15312
15343
|
import { Command as Command106 } from "commander";
|
|
15313
15344
|
|
|
15314
15345
|
// src/commands/backup/create.ts
|
|
15315
|
-
import
|
|
15316
|
-
import
|
|
15346
|
+
import fs57 from "node:fs";
|
|
15347
|
+
import path62 from "node:path";
|
|
15317
15348
|
import { Command as Command101 } from "commander";
|
|
15318
15349
|
import * as p61 from "@clack/prompts";
|
|
15319
15350
|
import pc32 from "picocolors";
|
|
@@ -15527,12 +15558,12 @@ Your bucket's own versioning is what protects the uploaded files.`
|
|
|
15527
15558
|
}, "Failed to create the backup.")
|
|
15528
15559
|
);
|
|
15529
15560
|
async function download(ctx, key, outputDir) {
|
|
15530
|
-
const dir =
|
|
15531
|
-
|
|
15532
|
-
const destination =
|
|
15561
|
+
const dir = path62.resolve(ctx.workspaceRootDir, outputDir);
|
|
15562
|
+
fs57.mkdirSync(dir, { recursive: true });
|
|
15563
|
+
const destination = path62.join(dir, key);
|
|
15533
15564
|
if (!ctx.session) {
|
|
15534
|
-
|
|
15535
|
-
return
|
|
15565
|
+
fs57.copyFileSync(path62.join(ctx.workspaceRootDir, "data", "backups", key), destination);
|
|
15566
|
+
return path62.relative(ctx.workspaceRootDir, destination);
|
|
15536
15567
|
}
|
|
15537
15568
|
const spinner9 = p61.spinner();
|
|
15538
15569
|
spinner9.start(`Downloading ${key}`);
|
|
@@ -15543,7 +15574,7 @@ async function download(ctx, key, outputDir) {
|
|
|
15543
15574
|
throw error;
|
|
15544
15575
|
}
|
|
15545
15576
|
spinner9.stop(`Downloaded ${key}`);
|
|
15546
|
-
return
|
|
15577
|
+
return path62.relative(ctx.workspaceRootDir, destination);
|
|
15547
15578
|
}
|
|
15548
15579
|
|
|
15549
15580
|
// src/commands/backup/list.ts
|
|
@@ -15577,8 +15608,8 @@ Take one with ${pc33.cyan("vela backup create")}.`
|
|
|
15577
15608
|
);
|
|
15578
15609
|
|
|
15579
15610
|
// src/commands/backup/download.ts
|
|
15580
|
-
import
|
|
15581
|
-
import
|
|
15611
|
+
import fs58 from "node:fs";
|
|
15612
|
+
import path63 from "node:path";
|
|
15582
15613
|
import { Command as Command103 } from "commander";
|
|
15583
15614
|
import * as p63 from "@clack/prompts";
|
|
15584
15615
|
import pc34 from "picocolors";
|
|
@@ -15605,11 +15636,11 @@ Run ${pc34.cyan("vela backup list")} to see what it does have.`
|
|
|
15605
15636
|
Fetch it from the bucket directly \u2014 vela does not hold its credentials.`
|
|
15606
15637
|
);
|
|
15607
15638
|
}
|
|
15608
|
-
const dir =
|
|
15609
|
-
|
|
15610
|
-
const destination =
|
|
15639
|
+
const dir = path63.resolve(ctx.workspaceRootDir, options.output);
|
|
15640
|
+
fs58.mkdirSync(dir, { recursive: true });
|
|
15641
|
+
const destination = path63.join(dir, key);
|
|
15611
15642
|
if (!ctx.session) {
|
|
15612
|
-
|
|
15643
|
+
fs58.copyFileSync(path63.join(ctx.workspaceRootDir, "data", "backups", key), destination);
|
|
15613
15644
|
} else {
|
|
15614
15645
|
const spinner9 = p63.spinner();
|
|
15615
15646
|
spinner9.start(`Downloading ${key} (${formatBytes(found.size)})`);
|
|
@@ -15623,7 +15654,7 @@ Fetch it from the bucket directly \u2014 vela does not hold its credentials.`
|
|
|
15623
15654
|
}
|
|
15624
15655
|
reportResult({
|
|
15625
15656
|
summary: `Saved ${key} from ${ctx.targetName}.`,
|
|
15626
|
-
filesCreated: [
|
|
15657
|
+
filesCreated: [path63.relative(ctx.workspaceRootDir, destination)]
|
|
15627
15658
|
});
|
|
15628
15659
|
});
|
|
15629
15660
|
}, "Failed to download the backup.")
|
|
@@ -15718,8 +15749,8 @@ Set one with ${pc36.cyan('vela backup schedule "0 3 * * *"')}.`
|
|
|
15718
15749
|
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);
|
|
15719
15750
|
|
|
15720
15751
|
// src/commands/restore.ts
|
|
15721
|
-
import
|
|
15722
|
-
import
|
|
15752
|
+
import fs59 from "node:fs";
|
|
15753
|
+
import path64 from "node:path";
|
|
15723
15754
|
import process46 from "node:process";
|
|
15724
15755
|
import { Command as Command107 } from "commander";
|
|
15725
15756
|
import * as p66 from "@clack/prompts";
|
|
@@ -15749,7 +15780,7 @@ Run \`vela deploy\` first, then restore.`
|
|
|
15749
15780
|
`${ctx.targetName} was deployed without a database, so there is nothing to restore.`
|
|
15750
15781
|
);
|
|
15751
15782
|
}
|
|
15752
|
-
const local = source &&
|
|
15783
|
+
const local = source && fs59.existsSync(source) ? source : void 0;
|
|
15753
15784
|
const key = local ? void 0 : await resolveKey(ctx, source);
|
|
15754
15785
|
if (!options.yes) {
|
|
15755
15786
|
await confirm14(ctx.appName, ctx.targetName, ctx.envTag, local ?? key);
|
|
@@ -15772,7 +15803,7 @@ Run \`vela deploy\` first, then restore.`
|
|
|
15772
15803
|
});
|
|
15773
15804
|
p66.log.success(
|
|
15774
15805
|
`Restored ${pc37.cyan(`${ctx.appName} (${ctx.targetName})`)} from ${pc37.cyan(
|
|
15775
|
-
local ?
|
|
15806
|
+
local ? path64.basename(local) : key
|
|
15776
15807
|
)}.`
|
|
15777
15808
|
);
|
|
15778
15809
|
if (result?.storageCarriedOver) {
|
|
@@ -15838,21 +15869,21 @@ Take one with ${pc37.cyan("vela backup create")}, or pass the path to an archive
|
|
|
15838
15869
|
}
|
|
15839
15870
|
async function stage(ctx, file) {
|
|
15840
15871
|
const dir = remotePaths.restoreStage(ctx.instance);
|
|
15841
|
-
const remote = `${dir}/${
|
|
15872
|
+
const remote = `${dir}/${path64.basename(file)}`;
|
|
15842
15873
|
const spinner9 = p66.spinner();
|
|
15843
|
-
spinner9.start(`Uploading ${
|
|
15874
|
+
spinner9.start(`Uploading ${path64.basename(file)}`);
|
|
15844
15875
|
try {
|
|
15845
15876
|
await ctx.session.script(`mkdir -p "$1"`, { args: [dir] });
|
|
15846
15877
|
await ctx.session.upload([file], dir);
|
|
15847
15878
|
} catch (error) {
|
|
15848
|
-
spinner9.stop(`Could not upload ${
|
|
15879
|
+
spinner9.stop(`Could not upload ${path64.basename(file)}.`);
|
|
15849
15880
|
throw error;
|
|
15850
15881
|
}
|
|
15851
|
-
spinner9.stop(`Uploaded ${
|
|
15882
|
+
spinner9.stop(`Uploaded ${path64.basename(file)}`);
|
|
15852
15883
|
return remote;
|
|
15853
15884
|
}
|
|
15854
15885
|
async function confirm14(appName, targetName, envTag, from) {
|
|
15855
|
-
const what = `${pc37.cyan(`${appName} (${targetName})`)} from ${pc37.cyan(
|
|
15886
|
+
const what = `${pc37.cyan(`${appName} (${targetName})`)} from ${pc37.cyan(path64.basename(from))}`;
|
|
15856
15887
|
if (isProd(envTag)) {
|
|
15857
15888
|
const answer = await p66.text({
|
|
15858
15889
|
message: `This replaces the database and uploads of ${what}. Type the app name to confirm`,
|
|
@@ -15962,70 +15993,72 @@ Release and domain are shown from what this project recorded.`
|
|
|
15962
15993
|
}
|
|
15963
15994
|
|
|
15964
15995
|
// src/commands/test.ts
|
|
15965
|
-
import
|
|
15966
|
-
import process47 from "node:process";
|
|
15996
|
+
import process48 from "node:process";
|
|
15967
15997
|
import { Command as Command109 } from "commander";
|
|
15968
|
-
import PocketBase7 from "pocketbase";
|
|
15969
15998
|
import pc39 from "picocolors";
|
|
15970
|
-
import { x as
|
|
15971
|
-
import { detect as
|
|
15972
|
-
import { resolveCommand as
|
|
15973
|
-
|
|
15974
|
-
|
|
15975
|
-
|
|
15976
|
-
|
|
15999
|
+
import { x as x7 } from "tinyexec";
|
|
16000
|
+
import { detect as detect10 } from "package-manager-detector";
|
|
16001
|
+
import { resolveCommand as resolveCommand8 } from "package-manager-detector/commands";
|
|
16002
|
+
|
|
16003
|
+
// src/lib/test-harness.ts
|
|
16004
|
+
import fs60 from "node:fs";
|
|
16005
|
+
import path65 from "node:path";
|
|
16006
|
+
import process47 from "node:process";
|
|
16007
|
+
import PocketBase7 from "pocketbase";
|
|
16008
|
+
var TEST_DATA_DIR = "test-data";
|
|
16009
|
+
var HarnessError = class extends Error {
|
|
16010
|
+
};
|
|
16011
|
+
async function startTestHarness(cwd, { log: log58 = () => {
|
|
16012
|
+
} } = {}) {
|
|
15977
16013
|
const email2 = `test-${Math.random().toString(36).slice(2)}@example.com`;
|
|
15978
16014
|
const password8 = "password";
|
|
15979
|
-
const
|
|
15980
|
-
|
|
15981
|
-
const
|
|
15982
|
-
|
|
15983
|
-
|
|
16015
|
+
const root = path65.join(cwd, TEST_DATA_DIR);
|
|
16016
|
+
pruneStaleRuns(root);
|
|
16017
|
+
const dataDir2 = path65.join(root, String(process47.pid));
|
|
16018
|
+
fs60.rmSync(dataDir2, { recursive: true, force: true });
|
|
16019
|
+
const { stop: stopPocketbase, url: pocketbaseUrl } = await launchPocketbase(cwd, {
|
|
16020
|
+
dir: dataDir2,
|
|
16021
|
+
migrationsDir: path65.join(cwd, MIGRATIONS_DIR),
|
|
15984
16022
|
// The app's PocketBase hooks (slug generation, personal teams, …) are part
|
|
15985
16023
|
// of its behaviour; the suite runs against the same server dev and build
|
|
15986
16024
|
// start, so it loads them from the same place.
|
|
15987
|
-
hooksDir:
|
|
16025
|
+
hooksDir: path65.join(cwd, DATA_DIR, "hooks"),
|
|
15988
16026
|
email: email2,
|
|
15989
16027
|
password: password8
|
|
15990
16028
|
});
|
|
15991
|
-
process47.env.POCKETBASE_URL = url;
|
|
15992
|
-
process47.env.POCKETBASE_SUPERUSER_EMAIL = email2;
|
|
15993
|
-
process47.env.POCKETBASE_SUPERUSER_PASSWORD = password8;
|
|
15994
|
-
process47.env.VELA_DATA_DIR = testDataDir;
|
|
15995
|
-
process47.env.TEST = "true";
|
|
15996
|
-
console.log(`${pc39.greenBright("\u2713")} Created test database`);
|
|
15997
16029
|
let vite;
|
|
15998
|
-
let
|
|
15999
|
-
const
|
|
16000
|
-
if (
|
|
16001
|
-
|
|
16002
|
-
|
|
16003
|
-
|
|
16030
|
+
let stopped = false;
|
|
16031
|
+
const stopSync = () => {
|
|
16032
|
+
if (stopped) return;
|
|
16033
|
+
stopped = true;
|
|
16034
|
+
stopPocketbase();
|
|
16035
|
+
fs60.rmSync(dataDir2, { recursive: true, force: true });
|
|
16004
16036
|
};
|
|
16005
|
-
const
|
|
16006
|
-
if (
|
|
16037
|
+
const stop = async () => {
|
|
16038
|
+
if (stopped) return;
|
|
16007
16039
|
process47.emit("sveltekit:shutdown", 0);
|
|
16008
16040
|
await vite?.close().catch(() => {
|
|
16009
16041
|
});
|
|
16010
|
-
|
|
16042
|
+
stopSync();
|
|
16011
16043
|
};
|
|
16012
16044
|
const fail = async (message) => {
|
|
16013
|
-
|
|
16014
|
-
|
|
16015
|
-
process47.exit(1);
|
|
16045
|
+
await stop();
|
|
16046
|
+
throw new HarnessError(message);
|
|
16016
16047
|
};
|
|
16017
|
-
|
|
16018
|
-
|
|
16019
|
-
|
|
16020
|
-
|
|
16021
|
-
|
|
16022
|
-
|
|
16023
|
-
|
|
16024
|
-
|
|
16025
|
-
|
|
16026
|
-
|
|
16027
|
-
}
|
|
16028
|
-
|
|
16048
|
+
const env2 = {
|
|
16049
|
+
POCKETBASE_URL: pocketbaseUrl,
|
|
16050
|
+
POCKETBASE_SUPERUSER_EMAIL: email2,
|
|
16051
|
+
POCKETBASE_SUPERUSER_PASSWORD: password8,
|
|
16052
|
+
// The app's data directory is PocketBase's, here as everywhere else. It
|
|
16053
|
+
// points at the throwaway one so that a database or an uploaded file the
|
|
16054
|
+
// suite creates is removed with it, rather than accumulating in the
|
|
16055
|
+
// directory the developer actually works against.
|
|
16056
|
+
VELA_DATA_DIR: dataDir2,
|
|
16057
|
+
TEST: "true"
|
|
16058
|
+
};
|
|
16059
|
+
Object.assign(process47.env, env2);
|
|
16060
|
+
log58("Created test database");
|
|
16061
|
+
const pb = new PocketBase7(pocketbaseUrl);
|
|
16029
16062
|
try {
|
|
16030
16063
|
await authWithRetries(pb, email2, password8);
|
|
16031
16064
|
} catch (e) {
|
|
@@ -16033,60 +16066,61 @@ var testServer = new Command109("test:server").description("run server tests").a
|
|
|
16033
16066
|
}
|
|
16034
16067
|
try {
|
|
16035
16068
|
const seeds2 = await loadSeeds(pb, cwd);
|
|
16036
|
-
if (seeds2.length > 0) {
|
|
16037
|
-
console.log(`${pc39.greenBright("\u2713")} Loaded ${seeds2.length} seed file(s)`);
|
|
16038
|
-
}
|
|
16069
|
+
if (seeds2.length > 0) log58(`Loaded ${seeds2.length} seed file(s)`);
|
|
16039
16070
|
const fixtures2 = await loadFixtures(pb, cwd);
|
|
16040
|
-
if (fixtures2.length > 0) {
|
|
16041
|
-
console.log(`${pc39.greenBright("\u2713")} Loaded ${fixtures2.length} fixture file(s)`);
|
|
16042
|
-
}
|
|
16071
|
+
if (fixtures2.length > 0) log58(`Loaded ${fixtures2.length} fixture file(s)`);
|
|
16043
16072
|
} catch (e) {
|
|
16044
16073
|
await fail(describeLoadFailure(e));
|
|
16045
16074
|
}
|
|
16046
|
-
const { createServer } = await loadVite(cwd);
|
|
16047
|
-
vite = await createServer({
|
|
16048
|
-
mode: "test",
|
|
16049
|
-
plugins: [stubPagesPlugin()],
|
|
16050
|
-
optimizeDeps: { noDiscovery: true },
|
|
16051
|
-
// This config differs from `vela dev`'s, so sharing node_modules/.vite
|
|
16052
|
-
// would make Vite re-optimize dependencies under a running dev server,
|
|
16053
|
-
// which then loads two copies of Svelte and fails reading `page`.
|
|
16054
|
-
cacheDir: "node_modules/.vite-test"
|
|
16055
|
-
});
|
|
16056
|
-
const vitePort = await findFreePort();
|
|
16057
|
-
await vite.listen(vitePort);
|
|
16058
|
-
process47.env.VITE_TEST_URL = `http://localhost:${vitePort}`;
|
|
16059
|
-
console.log(`${pc39.greenBright("\u2713")} Started Vite: http://localhost:${vitePort}`);
|
|
16060
|
-
console.log(`${pc39.greenBright("\u2713")} Started PocketBase: ${url}`);
|
|
16061
|
-
const extraArgs = (cmd.parent?.args ?? []).slice(1);
|
|
16062
|
-
let filter = extraArgs.find((arg) => !arg.startsWith("-"));
|
|
16063
|
-
const passthrough = filter ? extraArgs.filter((a) => a !== filter) : extraArgs;
|
|
16064
|
-
const defaulted = !filter;
|
|
16065
|
-
if (!filter) filter = "server";
|
|
16066
16075
|
try {
|
|
16067
|
-
const
|
|
16068
|
-
|
|
16069
|
-
"
|
|
16070
|
-
|
|
16071
|
-
|
|
16072
|
-
|
|
16073
|
-
|
|
16074
|
-
|
|
16075
|
-
|
|
16076
|
-
const resolvedArgs = resolved.args.slice();
|
|
16077
|
-
if (pm === "npm") resolvedArgs.unshift("--yes");
|
|
16078
|
-
const result = await x6(resolved.command, resolvedArgs, {
|
|
16079
|
-
nodeOptions: { cwd, stdio: "inherit", env: { ...process47.env, CI: "1" } }
|
|
16076
|
+
const { createServer } = await loadVite(cwd);
|
|
16077
|
+
vite = await createServer({
|
|
16078
|
+
mode: "test",
|
|
16079
|
+
plugins: [stubPagesPlugin()],
|
|
16080
|
+
optimizeDeps: { noDiscovery: true },
|
|
16081
|
+
// This config differs from `vela dev`'s, so sharing node_modules/.vite
|
|
16082
|
+
// would make Vite re-optimize dependencies under a running dev server,
|
|
16083
|
+
// which then loads two copies of Svelte and fails reading `page`.
|
|
16084
|
+
cacheDir: "node_modules/.vite-test"
|
|
16080
16085
|
});
|
|
16081
|
-
|
|
16086
|
+
const port = await findFreePort();
|
|
16087
|
+
await vite.listen(port);
|
|
16082
16088
|
} catch (e) {
|
|
16083
|
-
|
|
16084
|
-
process47.exitCode = 1;
|
|
16085
|
-
} finally {
|
|
16086
|
-
await cleanup();
|
|
16087
|
-
process47.exit(process47.exitCode ?? 0);
|
|
16089
|
+
await fail(`Failed to start Vite: ${e.message}`);
|
|
16088
16090
|
}
|
|
16089
|
-
}
|
|
16091
|
+
const appUrl = `http://localhost:${vite.config.server.port}`;
|
|
16092
|
+
env2.VITE_TEST_URL = appUrl;
|
|
16093
|
+
process47.env.VITE_TEST_URL = appUrl;
|
|
16094
|
+
log58(`Started Vite: ${appUrl}`);
|
|
16095
|
+
log58(`Started PocketBase: ${pocketbaseUrl}`);
|
|
16096
|
+
return {
|
|
16097
|
+
pocketbaseUrl,
|
|
16098
|
+
appUrl,
|
|
16099
|
+
superuser: { email: email2, password: password8 },
|
|
16100
|
+
dataDir: dataDir2,
|
|
16101
|
+
env: env2,
|
|
16102
|
+
stop,
|
|
16103
|
+
stopSync
|
|
16104
|
+
};
|
|
16105
|
+
}
|
|
16106
|
+
function pruneStaleRuns(root) {
|
|
16107
|
+
if (!fs60.existsSync(root)) return;
|
|
16108
|
+
for (const entry of fs60.readdirSync(root, { withFileTypes: true })) {
|
|
16109
|
+
if (!entry.isDirectory()) continue;
|
|
16110
|
+
const pid = Number(entry.name);
|
|
16111
|
+
if (!Number.isInteger(pid) || pid === process47.pid) continue;
|
|
16112
|
+
if (isAlive(pid)) continue;
|
|
16113
|
+
fs60.rmSync(path65.join(root, entry.name), { recursive: true, force: true });
|
|
16114
|
+
}
|
|
16115
|
+
}
|
|
16116
|
+
function isAlive(pid) {
|
|
16117
|
+
try {
|
|
16118
|
+
process47.kill(pid, 0);
|
|
16119
|
+
return true;
|
|
16120
|
+
} catch (e) {
|
|
16121
|
+
return e.code === "EPERM";
|
|
16122
|
+
}
|
|
16123
|
+
}
|
|
16090
16124
|
function describeLoadFailure(e) {
|
|
16091
16125
|
if (e instanceof DataLoadError) {
|
|
16092
16126
|
const hint = e.kind === "fixtures" ? "Run `vela fixtures regen` to regenerate fixtures from the current schema." : `Check ${e.file} against the current schema.`;
|
|
@@ -16112,9 +16146,83 @@ function stubPagesPlugin() {
|
|
|
16112
16146
|
};
|
|
16113
16147
|
}
|
|
16114
16148
|
|
|
16149
|
+
// src/commands/test.ts
|
|
16150
|
+
var testServer = new Command109("test:server").description("run server tests").allowUnknownOption(true).allowExcessArguments(true).configureHelp(helpConfig).action(async (_opts, cmd) => {
|
|
16151
|
+
const cwd = process48.cwd();
|
|
16152
|
+
warnIfKit2(cwd, (m) => console.warn(pc39.yellow(`\u25B2 ${m}`)));
|
|
16153
|
+
const extraArgs = (cmd.parent?.args ?? []).slice(1);
|
|
16154
|
+
const filtered = extraArgs.some((arg) => !arg.startsWith("-"));
|
|
16155
|
+
try {
|
|
16156
|
+
const pm = (await detect10({ cwd }))?.name ?? "npm";
|
|
16157
|
+
const resolved = resolveCommand8(pm, "execute", [
|
|
16158
|
+
"vitest",
|
|
16159
|
+
"run",
|
|
16160
|
+
"--project",
|
|
16161
|
+
"server",
|
|
16162
|
+
"--reporter=dot",
|
|
16163
|
+
...filtered ? [] : ["--passWithNoTests"],
|
|
16164
|
+
...extraArgs
|
|
16165
|
+
]);
|
|
16166
|
+
const resolvedArgs = resolved.args.slice();
|
|
16167
|
+
if (pm === "npm") resolvedArgs.unshift("--yes");
|
|
16168
|
+
const result = await x7(resolved.command, resolvedArgs, {
|
|
16169
|
+
nodeOptions: { cwd, stdio: "inherit", env: { ...process48.env, CI: "1" } }
|
|
16170
|
+
});
|
|
16171
|
+
process48.exitCode = result.exitCode ?? 1;
|
|
16172
|
+
} catch (e) {
|
|
16173
|
+
console.error(`${pc39.redBright("\u2717")} ${e.message}`);
|
|
16174
|
+
process48.exitCode = 1;
|
|
16175
|
+
}
|
|
16176
|
+
});
|
|
16177
|
+
var testHarness = new Command109("test:harness").description("start the servers for server tests and wait (used by vela/testing)").configureHelp(helpConfig).action(async () => {
|
|
16178
|
+
const cwd = process48.cwd();
|
|
16179
|
+
if (!process48.send) {
|
|
16180
|
+
console.error(
|
|
16181
|
+
`${pc39.redBright("\u2717")} vela test:harness is started by vitest through \`vela/testing\`. Run \`vela test:server\` instead.`
|
|
16182
|
+
);
|
|
16183
|
+
process48.exit(1);
|
|
16184
|
+
}
|
|
16185
|
+
let harness;
|
|
16186
|
+
let exiting = false;
|
|
16187
|
+
const exit = async (code2) => {
|
|
16188
|
+
if (exiting) return;
|
|
16189
|
+
exiting = true;
|
|
16190
|
+
await harness?.stop();
|
|
16191
|
+
process48.exit(code2);
|
|
16192
|
+
};
|
|
16193
|
+
process48.on("exit", () => harness?.stopSync());
|
|
16194
|
+
for (const [signal, code2] of [
|
|
16195
|
+
["SIGINT", 130],
|
|
16196
|
+
["SIGTERM", 143],
|
|
16197
|
+
["SIGHUP", 129]
|
|
16198
|
+
]) {
|
|
16199
|
+
process48.on(signal, () => void exit(code2));
|
|
16200
|
+
}
|
|
16201
|
+
process48.on("disconnect", () => void exit(0));
|
|
16202
|
+
process48.on("message", (message) => {
|
|
16203
|
+
if (message === "stop") void exit(0);
|
|
16204
|
+
});
|
|
16205
|
+
try {
|
|
16206
|
+
harness = await startTestHarness(cwd, {
|
|
16207
|
+
log: (message) => console.log(`${pc39.greenBright("\u2713")} ${message}`)
|
|
16208
|
+
});
|
|
16209
|
+
} catch (e) {
|
|
16210
|
+
const message = e instanceof HarnessError ? e.message : `Failed to start the test servers: ${e.message}`;
|
|
16211
|
+
console.error(`${pc39.redBright("\u2717")} ${message}`);
|
|
16212
|
+
process48.send({ type: "error", message });
|
|
16213
|
+
process48.exit(1);
|
|
16214
|
+
}
|
|
16215
|
+
const { pocketbaseUrl, appUrl, superuser, dataDir: dataDir2, env: env2 } = harness;
|
|
16216
|
+
process48.send({
|
|
16217
|
+
type: "ready",
|
|
16218
|
+
servers: { pocketbaseUrl, appUrl, superuser, dataDir: dataDir2 },
|
|
16219
|
+
env: env2
|
|
16220
|
+
});
|
|
16221
|
+
});
|
|
16222
|
+
|
|
16115
16223
|
// src/commands/routes.ts
|
|
16116
|
-
import
|
|
16117
|
-
import
|
|
16224
|
+
import fs61 from "node:fs";
|
|
16225
|
+
import path66 from "node:path";
|
|
16118
16226
|
import { Command as Command110 } from "commander";
|
|
16119
16227
|
var HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
16120
16228
|
"GET",
|
|
@@ -16128,30 +16236,30 @@ var HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
|
16128
16236
|
]);
|
|
16129
16237
|
var routes = new Command110("routes").description("list routes").configureHelp(helpConfig).action(async () => {
|
|
16130
16238
|
const { workspaceRootDir, routesDir } = await getWorkspace();
|
|
16131
|
-
const routesRoot =
|
|
16239
|
+
const routesRoot = path66.join(workspaceRootDir, routesDir);
|
|
16132
16240
|
const found = walk(routesRoot, routesRoot).filter((r) => r.methods.length > 0);
|
|
16133
16241
|
found.sort((a, b) => a.urlPattern.localeCompare(b.urlPattern));
|
|
16134
16242
|
printTable(found);
|
|
16135
16243
|
});
|
|
16136
16244
|
function walk(root, dir) {
|
|
16137
|
-
const entries =
|
|
16245
|
+
const entries = fs61.readdirSync(dir, { withFileTypes: true });
|
|
16138
16246
|
const routes2 = [];
|
|
16139
16247
|
const hasLeaf = entries.some((e) => e.isFile() && isRouteFile(e.name));
|
|
16140
16248
|
if (hasLeaf) {
|
|
16141
|
-
const id = "/" +
|
|
16249
|
+
const id = "/" + path66.relative(root, dir).split(path66.sep).filter(Boolean).join("/");
|
|
16142
16250
|
const urlPattern = id.replace(/\([^)]+\)\/?/g, "").replace(/\/$/, "") || "/";
|
|
16143
16251
|
const methods = /* @__PURE__ */ new Set();
|
|
16144
16252
|
for (const entry of entries) {
|
|
16145
16253
|
if (!entry.isFile()) continue;
|
|
16146
16254
|
if (entry.name.endsWith("+page.svelte")) methods.add("GET");
|
|
16147
16255
|
if (entry.name.endsWith("+server.ts") || entry.name.endsWith("+server.js") || entry.name.endsWith("+page.server.ts") || entry.name.endsWith("+page.server.js")) {
|
|
16148
|
-
extractMethods(
|
|
16256
|
+
extractMethods(path66.join(dir, entry.name)).forEach((m) => methods.add(m));
|
|
16149
16257
|
}
|
|
16150
16258
|
}
|
|
16151
16259
|
routes2.push({ id: id || "/", urlPattern, methods: [...methods] });
|
|
16152
16260
|
}
|
|
16153
16261
|
for (const entry of entries) {
|
|
16154
|
-
if (entry.isDirectory()) routes2.push(...walk(root,
|
|
16262
|
+
if (entry.isDirectory()) routes2.push(...walk(root, path66.join(dir, entry.name)));
|
|
16155
16263
|
}
|
|
16156
16264
|
return routes2;
|
|
16157
16265
|
}
|
|
@@ -16160,7 +16268,7 @@ function isRouteFile(name) {
|
|
|
16160
16268
|
}
|
|
16161
16269
|
function extractMethods(file) {
|
|
16162
16270
|
try {
|
|
16163
|
-
const content =
|
|
16271
|
+
const content = fs61.readFileSync(file, "utf8");
|
|
16164
16272
|
const methods = [];
|
|
16165
16273
|
const exportRegex = /export\s+(?:const|async\s+function|function)\s+(\w+)/g;
|
|
16166
16274
|
let match;
|
|
@@ -16201,24 +16309,24 @@ function printTable(routes2) {
|
|
|
16201
16309
|
}
|
|
16202
16310
|
|
|
16203
16311
|
// src/commands/i18n.ts
|
|
16204
|
-
import
|
|
16205
|
-
import
|
|
16206
|
-
import
|
|
16312
|
+
import fs62 from "node:fs";
|
|
16313
|
+
import path67 from "node:path";
|
|
16314
|
+
import process49 from "node:process";
|
|
16207
16315
|
import { Command as Command111 } from "commander";
|
|
16208
|
-
import { x as
|
|
16209
|
-
import { detect as
|
|
16210
|
-
import { resolveCommand as
|
|
16316
|
+
import { x as x8 } from "tinyexec";
|
|
16317
|
+
import { detect as detect11 } from "package-manager-detector";
|
|
16318
|
+
import { resolveCommand as resolveCommand9 } from "package-manager-detector/commands";
|
|
16211
16319
|
var WUCHALE_CONFIG_NAMES = ["js", "mjs", "ts", "mts"].map((ext) => `wuchale.config.${ext}`);
|
|
16212
16320
|
async function runWuchale(extraArgs) {
|
|
16213
|
-
const cwd = findWorkspaceRoot() ??
|
|
16214
|
-
if (!WUCHALE_CONFIG_NAMES.some((name) =>
|
|
16321
|
+
const cwd = findWorkspaceRoot() ?? process49.cwd();
|
|
16322
|
+
if (!WUCHALE_CONFIG_NAMES.some((name) => fs62.existsSync(path67.join(cwd, name)))) {
|
|
16215
16323
|
throw new Error("No wuchale config found. Run `vela enable i18n` to set up i18n.");
|
|
16216
16324
|
}
|
|
16217
|
-
const pm = (await
|
|
16218
|
-
const resolved =
|
|
16325
|
+
const pm = (await detect11({ cwd }))?.name ?? "npm";
|
|
16326
|
+
const resolved = resolveCommand9(pm, "execute", ["wuchale", ...extraArgs]);
|
|
16219
16327
|
const args = resolved.args.slice();
|
|
16220
16328
|
if (pm === "npm") args.unshift("--yes");
|
|
16221
|
-
await
|
|
16329
|
+
await x8(resolved.command, args, {
|
|
16222
16330
|
nodeOptions: { cwd, stdio: "inherit" },
|
|
16223
16331
|
throwOnError: true
|
|
16224
16332
|
});
|
|
@@ -16233,7 +16341,7 @@ var i18n3 = new Command111("i18n").description("i18n utilities").configureHelp(h
|
|
|
16233
16341
|
import { Command as Command117 } from "commander";
|
|
16234
16342
|
|
|
16235
16343
|
// src/commands/cms/deploy.ts
|
|
16236
|
-
import
|
|
16344
|
+
import process50 from "node:process";
|
|
16237
16345
|
import { Command as Command112 } from "commander";
|
|
16238
16346
|
import * as p68 from "@clack/prompts";
|
|
16239
16347
|
import pc40 from "picocolors";
|
|
@@ -16299,7 +16407,7 @@ function resolveProjectId(explicit) {
|
|
|
16299
16407
|
}
|
|
16300
16408
|
return explicit;
|
|
16301
16409
|
}
|
|
16302
|
-
const root = findWorkspaceRoot(
|
|
16410
|
+
const root = findWorkspaceRoot(process50.cwd());
|
|
16303
16411
|
const link2 = root ? readProjectConfig(root) : null;
|
|
16304
16412
|
if (!link2) {
|
|
16305
16413
|
throw new Error(
|
|
@@ -16339,15 +16447,15 @@ import pc42 from "picocolors";
|
|
|
16339
16447
|
|
|
16340
16448
|
// src/lib/cms-backend.ts
|
|
16341
16449
|
import { createRequire as createRequire5 } from "node:module";
|
|
16342
|
-
import
|
|
16343
|
-
import
|
|
16450
|
+
import path68 from "node:path";
|
|
16451
|
+
import process51 from "node:process";
|
|
16344
16452
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
16345
16453
|
import pc41 from "picocolors";
|
|
16346
16454
|
var DEFAULT_PROJECT = "default";
|
|
16347
16455
|
async function loadBackendModule(root) {
|
|
16348
16456
|
let entry;
|
|
16349
16457
|
try {
|
|
16350
|
-
entry = createRequire5(
|
|
16458
|
+
entry = createRequire5(path68.join(root, "package.json")).resolve("@velastack/cms/backend");
|
|
16351
16459
|
} catch {
|
|
16352
16460
|
throw new Error(
|
|
16353
16461
|
`@velastack/cms is not installed in this project.
|
|
@@ -16357,7 +16465,7 @@ Run ${pc41.cyan("vela enable cms")} first.`
|
|
|
16357
16465
|
}
|
|
16358
16466
|
return await import(pathToFileURL2(entry).href);
|
|
16359
16467
|
}
|
|
16360
|
-
async function withCmsBackend(fn, cwd =
|
|
16468
|
+
async function withCmsBackend(fn, cwd = process51.cwd()) {
|
|
16361
16469
|
const root = findWorkspaceRoot(cwd);
|
|
16362
16470
|
if (!root) {
|
|
16363
16471
|
throw new Error("Could not find workspace root (no package.json found)");
|
|
@@ -16365,8 +16473,8 @@ async function withCmsBackend(fn, cwd = process50.cwd()) {
|
|
|
16365
16473
|
const { createCmsBackend } = await loadBackendModule(root);
|
|
16366
16474
|
const dataDir2 = localDataDir(root);
|
|
16367
16475
|
const backend3 = createCmsBackend({
|
|
16368
|
-
dbPath:
|
|
16369
|
-
uploadDir:
|
|
16476
|
+
dbPath: path68.join(dataDir2, "cms.sqlite"),
|
|
16477
|
+
uploadDir: path68.join(dataDir2, "uploads")
|
|
16370
16478
|
});
|
|
16371
16479
|
try {
|
|
16372
16480
|
return await fn(backend3);
|
|
@@ -16444,7 +16552,7 @@ var cms2 = new Command117("cms").description("manage the CMS").configureHelp(hel
|
|
|
16444
16552
|
import { Command as Command121 } from "commander";
|
|
16445
16553
|
|
|
16446
16554
|
// src/commands/workflows/list.ts
|
|
16447
|
-
import
|
|
16555
|
+
import process52 from "node:process";
|
|
16448
16556
|
import { Command as Command118, InvalidArgumentError as InvalidArgumentError5 } from "commander";
|
|
16449
16557
|
import * as p72 from "@clack/prompts";
|
|
16450
16558
|
import pc45 from "picocolors";
|
|
@@ -16522,7 +16630,7 @@ function formatRun(run, nameWidth) {
|
|
|
16522
16630
|
}
|
|
16523
16631
|
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(
|
|
16524
16632
|
(options) => runCommand(async () => {
|
|
16525
|
-
await withPocketbase(
|
|
16633
|
+
await withPocketbase(process52.cwd(), async (pb) => {
|
|
16526
16634
|
const runs = await listRuns(pb, {
|
|
16527
16635
|
status: options.status,
|
|
16528
16636
|
workflowName: options.name,
|
|
@@ -16543,7 +16651,7 @@ Start one from server code with ${pc45.cyan("<workflow>.run(input)")}, or with $
|
|
|
16543
16651
|
);
|
|
16544
16652
|
|
|
16545
16653
|
// src/commands/workflows/run.ts
|
|
16546
|
-
import
|
|
16654
|
+
import process53 from "node:process";
|
|
16547
16655
|
import { Command as Command119, InvalidArgumentError as InvalidArgumentError6 } from "commander";
|
|
16548
16656
|
import * as p73 from "@clack/prompts";
|
|
16549
16657
|
import pc46 from "picocolors";
|
|
@@ -16556,7 +16664,7 @@ function parseInput(value) {
|
|
|
16556
16664
|
}
|
|
16557
16665
|
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(
|
|
16558
16666
|
(name, input) => runCommand(async () => {
|
|
16559
|
-
await withPocketbase(
|
|
16667
|
+
await withPocketbase(process53.cwd(), async (pb) => {
|
|
16560
16668
|
const run = await createRun(pb, name, input);
|
|
16561
16669
|
p73.log.success(
|
|
16562
16670
|
`Queued ${pc46.cyan(name)} as run ${pc46.bold(run.id)}.
|
|
@@ -16568,13 +16676,13 @@ It runs once the app is up (${pc46.cyan("vela dev")}); ${pc46.cyan("vela workflo
|
|
|
16568
16676
|
);
|
|
16569
16677
|
|
|
16570
16678
|
// src/commands/workflows/cancel.ts
|
|
16571
|
-
import
|
|
16679
|
+
import process54 from "node:process";
|
|
16572
16680
|
import { Command as Command120 } from "commander";
|
|
16573
16681
|
import * as p74 from "@clack/prompts";
|
|
16574
16682
|
import pc47 from "picocolors";
|
|
16575
16683
|
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(
|
|
16576
16684
|
(id) => runCommand(async () => {
|
|
16577
|
-
await withPocketbase(
|
|
16685
|
+
await withPocketbase(process54.cwd(), async (pb) => {
|
|
16578
16686
|
const run = await cancelRun(pb, id);
|
|
16579
16687
|
p74.log.success(`Canceled run ${pc47.bold(run.id)} of ${pc47.cyan(run.workflowName)}.`);
|
|
16580
16688
|
});
|
|
@@ -16654,30 +16762,30 @@ var PROVIDER_GATED_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
16654
16762
|
"destroy shop"
|
|
16655
16763
|
]);
|
|
16656
16764
|
var BACKEND_OPTIONAL_COMMANDS = /* @__PURE__ */ new Set(["dev", "build", "preview", "deploy"]);
|
|
16657
|
-
var SELF_CREDENTIALED_COMMANDS = /* @__PURE__ */ new Set(["test:server"]);
|
|
16765
|
+
var SELF_CREDENTIALED_COMMANDS = /* @__PURE__ */ new Set(["test:server", "test:harness"]);
|
|
16658
16766
|
var program = new Command122().name(package_default.name).description(package_default.description).version(package_default.version, "-v, --version").configureHelp(helpConfig);
|
|
16659
16767
|
program.hook("preAction", (_thisCommand, actionCommand) => {
|
|
16660
|
-
const envRoot = findWorkspaceRoot() ??
|
|
16768
|
+
const envRoot = findWorkspaceRoot() ?? process55.cwd();
|
|
16661
16769
|
dotenv2.config({ path: nodePath.join(envRoot, ".env"), quiet: true });
|
|
16662
|
-
const
|
|
16663
|
-
if (NO_BACKEND_COMMMANDS.has(
|
|
16664
|
-
if (PROVIDER_GATED_COMMANDS.has(
|
|
16665
|
-
const top =
|
|
16770
|
+
const path69 = getCommandPath(actionCommand);
|
|
16771
|
+
if (NO_BACKEND_COMMMANDS.has(path69)) return;
|
|
16772
|
+
if (PROVIDER_GATED_COMMANDS.has(path69)) return;
|
|
16773
|
+
const top = path69.split(" ", 1)[0];
|
|
16666
16774
|
if (NO_BACKEND_COMMMANDS.has(top)) return;
|
|
16667
16775
|
if (!hasBackend()) {
|
|
16668
16776
|
if (BACKEND_OPTIONAL_COMMANDS.has(top)) return;
|
|
16669
|
-
p75.log.error(missingBackendMessage(`vela ${
|
|
16777
|
+
p75.log.error(missingBackendMessage(`vela ${path69}`));
|
|
16670
16778
|
p75.log.message();
|
|
16671
16779
|
p75.cancel("Operation failed.");
|
|
16672
|
-
|
|
16780
|
+
process55.exit(1);
|
|
16673
16781
|
}
|
|
16674
|
-
if (SELF_CREDENTIALED_COMMANDS.has(
|
|
16675
|
-
if (
|
|
16782
|
+
if (SELF_CREDENTIALED_COMMANDS.has(path69)) return;
|
|
16783
|
+
if (path69 === "generate migration" && actionCommand.opts().ai) return;
|
|
16676
16784
|
if (!hasSuperuserCredentials()) {
|
|
16677
16785
|
p75.log.error(missingCredentialsMessage());
|
|
16678
16786
|
p75.log.message();
|
|
16679
16787
|
p75.cancel("Operation failed.");
|
|
16680
|
-
|
|
16788
|
+
process55.exit(1);
|
|
16681
16789
|
}
|
|
16682
16790
|
});
|
|
16683
16791
|
function getCommandPath(cmd) {
|
|
@@ -16728,7 +16836,8 @@ for (const command of [
|
|
|
16728
16836
|
]) {
|
|
16729
16837
|
program.addCommand(command);
|
|
16730
16838
|
}
|
|
16839
|
+
program.addCommand(testHarness, { hidden: true });
|
|
16731
16840
|
|
|
16732
16841
|
// src/bin.ts
|
|
16733
|
-
program.parse(normalizeArgv(
|
|
16842
|
+
program.parse(normalizeArgv(process56.argv.slice(2)), { from: "user" });
|
|
16734
16843
|
//# sourceMappingURL=bin.js.map
|