vela 0.10.3 → 0.10.5
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 +418 -285
- package/dist/bin.js.map +4 -4
- package/package.json +2 -2
- package/templates/minimal/.prettierignore +3 -0
- package/templates/minimal/package.template.json +7 -10
- package/templates/minimal/vite.config.ts +8 -1
- package/templates/static/.prettierignore +3 -0
- package/templates/static/package.template.json +6 -9
- package/templates/static/vite.config.ts +5 -0
package/dist/bin.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/bin.ts
|
|
4
|
-
import
|
|
4
|
+
import process33 from "node:process";
|
|
5
5
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
6
6
|
|
|
7
7
|
// package.json
|
|
8
8
|
var package_default = {
|
|
9
9
|
name: "vela",
|
|
10
|
-
version: "0.10.
|
|
10
|
+
version: "0.10.5",
|
|
11
11
|
type: "module",
|
|
12
12
|
description: "A CLI for creating and updating SvelteKit projects",
|
|
13
13
|
license: "MIT",
|
|
@@ -41,7 +41,7 @@ var package_default = {
|
|
|
41
41
|
dependencies: {
|
|
42
42
|
"@clack/prompts": "^1.7.0",
|
|
43
43
|
"@faker-js/faker": "^10.6.0",
|
|
44
|
-
"@velastack/patterns": "^0.1.
|
|
44
|
+
"@velastack/patterns": "^0.1.2",
|
|
45
45
|
"@velastack/pocketbase-codegen": "^0.1.0",
|
|
46
46
|
"annotate-json-schema": "^0.1.0",
|
|
47
47
|
commander: "^13.1.0",
|
|
@@ -168,12 +168,12 @@ function delegateToLocalCli(opts) {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
// src/program.ts
|
|
171
|
-
import
|
|
172
|
-
import * as
|
|
171
|
+
import process32 from "node:process";
|
|
172
|
+
import * as p43 from "@clack/prompts";
|
|
173
173
|
import { Command as Command87 } from "commander";
|
|
174
174
|
import nodePath from "node:path";
|
|
175
175
|
import dotenv2 from "dotenv";
|
|
176
|
-
import
|
|
176
|
+
import pc22 from "picocolors";
|
|
177
177
|
|
|
178
178
|
// src/lib/help.ts
|
|
179
179
|
import pc from "picocolors";
|
|
@@ -350,8 +350,8 @@ function mergePackageJson(user, template) {
|
|
|
350
350
|
}
|
|
351
351
|
return { merged, added, conflicts, replaced };
|
|
352
352
|
}
|
|
353
|
-
function readPackageJson(
|
|
354
|
-
return JSON.parse(fs2.readFileSync(
|
|
353
|
+
function readPackageJson(path44) {
|
|
354
|
+
return JSON.parse(fs2.readFileSync(path44, "utf8"));
|
|
355
355
|
}
|
|
356
356
|
var PACKAGE_NAME_PLACEHOLDER = /~TODO~/g;
|
|
357
357
|
var APP_NAME_PLACEHOLDER = /~APP_NAME~/g;
|
|
@@ -364,12 +364,12 @@ function fillTemplatePlaceholders(raw, values) {
|
|
|
364
364
|
function escapeSingleQuoted(value) {
|
|
365
365
|
return value.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
366
366
|
}
|
|
367
|
-
function readTemplatePackageJson(
|
|
368
|
-
const raw = fillTemplatePlaceholders(fs2.readFileSync(
|
|
367
|
+
function readTemplatePackageJson(path44, values) {
|
|
368
|
+
const raw = fillTemplatePlaceholders(fs2.readFileSync(path44, "utf8"), values);
|
|
369
369
|
return JSON.parse(raw);
|
|
370
370
|
}
|
|
371
|
-
function writePackageJson(
|
|
372
|
-
fs2.writeFileSync(
|
|
371
|
+
function writePackageJson(path44, pkg) {
|
|
372
|
+
fs2.writeFileSync(path44, JSON.stringify(pkg, null, " ") + "\n");
|
|
373
373
|
}
|
|
374
374
|
function toValidPackageName(name) {
|
|
375
375
|
return name.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z0-9~.-]+/g, "-");
|
|
@@ -1752,7 +1752,7 @@ async function runPattern(slug2, argv2, input, report4) {
|
|
|
1752
1752
|
throw new Error(`Unknown pattern: ${slug2}`);
|
|
1753
1753
|
}
|
|
1754
1754
|
const { workspaceRootDir, features } = await getWorkspace();
|
|
1755
|
-
const
|
|
1755
|
+
const log32 = p6.taskLog({ title: report4.task.title });
|
|
1756
1756
|
let result;
|
|
1757
1757
|
try {
|
|
1758
1758
|
result = await pattern.generate({
|
|
@@ -1772,11 +1772,11 @@ async function runPattern(slug2, argv2, input, report4) {
|
|
|
1772
1772
|
});
|
|
1773
1773
|
return collections2;
|
|
1774
1774
|
},
|
|
1775
|
-
logger: { info: (message) =>
|
|
1775
|
+
logger: { info: (message) => log32.message(message) }
|
|
1776
1776
|
});
|
|
1777
|
-
|
|
1777
|
+
log32.success(report4.task.success);
|
|
1778
1778
|
} catch (e) {
|
|
1779
|
-
|
|
1779
|
+
log32.error(report4.task.error);
|
|
1780
1780
|
throw e;
|
|
1781
1781
|
}
|
|
1782
1782
|
const rel = (f) => toRelative(workspaceRootDir, f);
|
|
@@ -6591,12 +6591,51 @@ var migrate = new Command65("migrate").description("manage database migrations")
|
|
|
6591
6591
|
|
|
6592
6592
|
// src/commands/dev.ts
|
|
6593
6593
|
import fs30 from "node:fs";
|
|
6594
|
-
import
|
|
6595
|
-
import
|
|
6594
|
+
import path33 from "node:path";
|
|
6595
|
+
import process21 from "node:process";
|
|
6596
6596
|
import { performance } from "node:perf_hooks";
|
|
6597
6597
|
import { Command as Command66, InvalidArgumentError as InvalidArgumentError5 } from "commander";
|
|
6598
|
-
import
|
|
6598
|
+
import pc8 from "picocolors";
|
|
6599
6599
|
import PocketBase2 from "pocketbase";
|
|
6600
|
+
|
|
6601
|
+
// src/lib/vite.ts
|
|
6602
|
+
import path32 from "node:path";
|
|
6603
|
+
import process20 from "node:process";
|
|
6604
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
6605
|
+
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
6606
|
+
import pc7 from "picocolors";
|
|
6607
|
+
var REQUIRED_VITE_MAJOR = 8;
|
|
6608
|
+
function viteVersionError(version) {
|
|
6609
|
+
const major = Number.parseInt(version, 10);
|
|
6610
|
+
if (!Number.isFinite(major) || major >= REQUIRED_VITE_MAJOR) return null;
|
|
6611
|
+
return [
|
|
6612
|
+
`This project has vite ${version}, but vela needs vite ${REQUIRED_VITE_MAJOR} or newer.`,
|
|
6613
|
+
"",
|
|
6614
|
+
" npm install -D vite@^8 @sveltejs/vite-plugin-svelte@^7",
|
|
6615
|
+
"",
|
|
6616
|
+
"Both move together: @sveltejs/vite-plugin-svelte 7 requires vite 8, and",
|
|
6617
|
+
"version 6 is the last that supports vite 7."
|
|
6618
|
+
].join("\n");
|
|
6619
|
+
}
|
|
6620
|
+
function resolveProjectVite(cwd) {
|
|
6621
|
+
try {
|
|
6622
|
+
return createRequire2(path32.join(cwd, "package.json")).resolve("vite");
|
|
6623
|
+
} catch {
|
|
6624
|
+
return null;
|
|
6625
|
+
}
|
|
6626
|
+
}
|
|
6627
|
+
async function loadVite(cwd = process20.cwd()) {
|
|
6628
|
+
const entry = resolveProjectVite(cwd);
|
|
6629
|
+
const vite = entry ? await import(pathToFileURL2(entry).href) : await import("vite");
|
|
6630
|
+
const error = viteVersionError(vite.version);
|
|
6631
|
+
if (error) {
|
|
6632
|
+
console.error(`${pc7.redBright("\u2717")} ${error}`);
|
|
6633
|
+
process20.exit(1);
|
|
6634
|
+
}
|
|
6635
|
+
return vite;
|
|
6636
|
+
}
|
|
6637
|
+
|
|
6638
|
+
// src/commands/dev.ts
|
|
6600
6639
|
function parsePort(value) {
|
|
6601
6640
|
const port = Number(value);
|
|
6602
6641
|
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
@@ -6605,37 +6644,37 @@ function parsePort(value) {
|
|
|
6605
6644
|
return port;
|
|
6606
6645
|
}
|
|
6607
6646
|
var dev = new Command66("dev").description("start the development server").option("--open [path]", "open the app in a browser once the server is ready").option("--host [host]", "expose the server on the network").option("--port <port>", "port to listen on", parsePort).option("--strictPort", "exit if the port is already in use instead of taking the next one").option("--cors", "enable CORS").option("--force", "re-bundle dependencies, ignoring the optimizer cache").configureHelp(helpConfig).action(async (options) => {
|
|
6608
|
-
const cwd =
|
|
6647
|
+
const cwd = process21.cwd();
|
|
6609
6648
|
const startTime = performance.now();
|
|
6610
|
-
const { createServer, version } = await
|
|
6611
|
-
const viteMetadataDir =
|
|
6612
|
-
const viteMetadataFile =
|
|
6649
|
+
const { createServer, version } = await loadVite(cwd);
|
|
6650
|
+
const viteMetadataDir = path33.join(cwd, "node_modules", ".vite");
|
|
6651
|
+
const viteMetadataFile = path33.join(viteMetadataDir, "_pocketbase_metadata.json");
|
|
6613
6652
|
let pbProc;
|
|
6614
6653
|
const backend3 = hasBackend(cwd);
|
|
6615
|
-
const needsStart = backend3 && !
|
|
6654
|
+
const needsStart = backend3 && !process21.env.POCKETBASE_URL;
|
|
6616
6655
|
const cleanup = () => {
|
|
6617
6656
|
if (pbProc?.pid) pbProc.kill();
|
|
6618
6657
|
if (fs30.existsSync(viteMetadataFile)) fs30.rmSync(viteMetadataFile);
|
|
6619
6658
|
};
|
|
6620
6659
|
if (needsStart) {
|
|
6621
|
-
const dataDir =
|
|
6660
|
+
const dataDir = path33.join(cwd, DATA_DIR);
|
|
6622
6661
|
const started = await startPocketbaseServe({
|
|
6623
6662
|
dataDir,
|
|
6624
6663
|
migrationsDir: MIGRATIONS_DIR,
|
|
6625
|
-
hooksDir:
|
|
6664
|
+
hooksDir: path33.join(dataDir, "hooks"),
|
|
6626
6665
|
dev: true,
|
|
6627
6666
|
stdio: "pipe"
|
|
6628
6667
|
});
|
|
6629
6668
|
pbProc = started.proc;
|
|
6630
|
-
|
|
6631
|
-
pbProc.stdout?.pipe(
|
|
6632
|
-
pbProc.stderr?.pipe(
|
|
6669
|
+
process21.env.POCKETBASE_URL = started.url;
|
|
6670
|
+
pbProc.stdout?.pipe(process21.stdout);
|
|
6671
|
+
pbProc.stderr?.pipe(process21.stderr);
|
|
6633
6672
|
pbProc.on("error", (err) => console.error("PocketBase error:", err));
|
|
6634
6673
|
pbProc.on("exit", (code) => console.log(`PocketBase exited with code ${code}`));
|
|
6635
|
-
|
|
6636
|
-
|
|
6674
|
+
process21.on("exit", cleanup);
|
|
6675
|
+
process21.on("SIGINT", () => {
|
|
6637
6676
|
cleanup();
|
|
6638
|
-
|
|
6677
|
+
process21.exit(0);
|
|
6639
6678
|
});
|
|
6640
6679
|
}
|
|
6641
6680
|
const serverOptions = {};
|
|
@@ -6657,27 +6696,27 @@ var dev = new Command66("dev").description("start the development server").optio
|
|
|
6657
6696
|
await fs30.promises.writeFile(
|
|
6658
6697
|
viteMetadataFile,
|
|
6659
6698
|
JSON.stringify({
|
|
6660
|
-
pocketbaseUrl:
|
|
6699
|
+
pocketbaseUrl: process21.env.POCKETBASE_URL,
|
|
6661
6700
|
vitePort,
|
|
6662
6701
|
viteHost
|
|
6663
6702
|
})
|
|
6664
6703
|
);
|
|
6665
|
-
const pb = new PocketBase2(
|
|
6704
|
+
const pb = new PocketBase2(process21.env.POCKETBASE_URL);
|
|
6666
6705
|
await pb.collection("_superusers").authWithPassword(
|
|
6667
|
-
|
|
6668
|
-
|
|
6706
|
+
process21.env.POCKETBASE_SUPERUSER_EMAIL,
|
|
6707
|
+
process21.env.POCKETBASE_SUPERUSER_PASSWORD
|
|
6669
6708
|
);
|
|
6670
6709
|
await pb.settings.update({ meta: { appURL: `http://${viteHost}:${vitePort}` } });
|
|
6671
6710
|
await startWatchingTypes(cwd, pb);
|
|
6672
6711
|
});
|
|
6673
6712
|
await server.listen();
|
|
6674
|
-
const hasExistingLogs =
|
|
6675
|
-
const startupDurationString =
|
|
6676
|
-
`ready in ${
|
|
6713
|
+
const hasExistingLogs = process21.stdout.bytesWritten > 0 || process21.stderr.bytesWritten > 0;
|
|
6714
|
+
const startupDurationString = pc8.dim(
|
|
6715
|
+
`ready in ${pc8.reset(pc8.bold(Math.ceil(performance.now() - startTime)))} ms`
|
|
6677
6716
|
);
|
|
6678
6717
|
server.config.logger.info(
|
|
6679
6718
|
`
|
|
6680
|
-
${
|
|
6719
|
+
${pc8.green(`${pc8.bold("VITE")} v${version}`)} ${startupDurationString}
|
|
6681
6720
|
`,
|
|
6682
6721
|
{ clear: !hasExistingLogs }
|
|
6683
6722
|
);
|
|
@@ -6686,9 +6725,9 @@ var dev = new Command66("dev").description("start the development server").optio
|
|
|
6686
6725
|
});
|
|
6687
6726
|
async function startWatchingTypes(cwd, pb) {
|
|
6688
6727
|
const { processTypes } = await import("@velastack/pocketbase-codegen");
|
|
6689
|
-
const typesDir =
|
|
6690
|
-
const pocketbaseDir =
|
|
6691
|
-
const pocketbaseTypes =
|
|
6728
|
+
const typesDir = path33.resolve(cwd, ".svelte-kit", "types");
|
|
6729
|
+
const pocketbaseDir = path33.join(typesDir, "pocketbase");
|
|
6730
|
+
const pocketbaseTypes = path33.join(pocketbaseDir, "$types.d.ts");
|
|
6692
6731
|
const regenerate = () => processTypes(pb, typesDir).catch(() => {
|
|
6693
6732
|
});
|
|
6694
6733
|
await regenerate();
|
|
@@ -6709,35 +6748,61 @@ async function startWatchingTypes(cwd, pb) {
|
|
|
6709
6748
|
}
|
|
6710
6749
|
|
|
6711
6750
|
// src/commands/build.ts
|
|
6712
|
-
import
|
|
6713
|
-
import
|
|
6751
|
+
import fs31 from "node:fs";
|
|
6752
|
+
import path34 from "node:path";
|
|
6753
|
+
import process23 from "node:process";
|
|
6714
6754
|
import { Command as Command67 } from "commander";
|
|
6755
|
+
import * as p30 from "@clack/prompts";
|
|
6756
|
+
import pc9 from "picocolors";
|
|
6715
6757
|
import { x as x3 } from "tinyexec";
|
|
6716
6758
|
import { detect as detect5 } from "package-manager-detector";
|
|
6717
6759
|
import { resolveCommand as resolveCommand5 } from "package-manager-detector/commands";
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6760
|
+
|
|
6761
|
+
// src/lib/origin.ts
|
|
6762
|
+
import process22 from "node:process";
|
|
6763
|
+
function resolveOrigin(workspaceRootDir, envTag, config = {}) {
|
|
6764
|
+
return normalizeOrigin(
|
|
6765
|
+
process22.env.VELA_ORIGIN ?? readBinding(workspaceRootDir, envTag)?.domain ?? config.deploy?.domain
|
|
6766
|
+
);
|
|
6767
|
+
}
|
|
6768
|
+
function normalizeOrigin(value) {
|
|
6769
|
+
const first = value?.split(",")[0]?.trim();
|
|
6770
|
+
if (!first) return null;
|
|
6771
|
+
const withScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(first) ? first : `https://${first}`;
|
|
6772
|
+
try {
|
|
6773
|
+
const url = new URL(withScheme);
|
|
6774
|
+
return url.origin;
|
|
6775
|
+
} catch {
|
|
6776
|
+
return null;
|
|
6777
|
+
}
|
|
6778
|
+
}
|
|
6779
|
+
|
|
6780
|
+
// src/commands/build.ts
|
|
6781
|
+
var PRERENDERED_DIR = path34.join(".svelte-kit", "output", "prerendered");
|
|
6782
|
+
var build = new Command67("build").description("build the app").configureHelp(helpConfig).option("-t, --target <target>", "which copy of the app to build for", PRODUCTION_TARGET).action(async (options) => {
|
|
6783
|
+
const cwd = process23.cwd();
|
|
6784
|
+
const origin = await originForBuild(cwd, options.target);
|
|
6785
|
+
if (origin) process23.env.VELA_ORIGIN = origin;
|
|
6721
6786
|
let pbProc;
|
|
6722
|
-
const needsStart = hasBackend(cwd) && !
|
|
6787
|
+
const needsStart = hasBackend(cwd) && !process23.env.POCKETBASE_URL;
|
|
6723
6788
|
const cleanup = () => {
|
|
6724
6789
|
if (pbProc?.pid) pbProc.kill();
|
|
6725
6790
|
};
|
|
6726
6791
|
if (needsStart) {
|
|
6727
6792
|
await ensureSuperuser(cwd);
|
|
6728
|
-
const dataDir =
|
|
6793
|
+
const dataDir = path34.join(cwd, DATA_DIR);
|
|
6729
6794
|
const started = await startPocketbaseServe({
|
|
6730
6795
|
dataDir,
|
|
6731
6796
|
migrationsDir: MIGRATIONS_DIR,
|
|
6732
|
-
hooksDir:
|
|
6797
|
+
hooksDir: path34.join(dataDir, "hooks"),
|
|
6733
6798
|
dev: true
|
|
6734
6799
|
});
|
|
6735
6800
|
pbProc = started.proc;
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6801
|
+
process23.env.POCKETBASE_URL = started.url;
|
|
6802
|
+
process23.on("exit", cleanup);
|
|
6803
|
+
process23.on("SIGINT", () => {
|
|
6739
6804
|
cleanup();
|
|
6740
|
-
|
|
6805
|
+
process23.exit(0);
|
|
6741
6806
|
});
|
|
6742
6807
|
}
|
|
6743
6808
|
try {
|
|
@@ -6752,36 +6817,59 @@ var build = new Command67("build").description("build the app").configureHelp(he
|
|
|
6752
6817
|
} finally {
|
|
6753
6818
|
cleanup();
|
|
6754
6819
|
}
|
|
6820
|
+
if (!origin) warnIfPrerendered(cwd);
|
|
6755
6821
|
});
|
|
6822
|
+
async function originForBuild(cwd, target) {
|
|
6823
|
+
const workspaceRootDir = findWorkspaceRoot(cwd);
|
|
6824
|
+
if (!workspaceRootDir) return null;
|
|
6825
|
+
try {
|
|
6826
|
+
const parsed = parseTarget(target, PRODUCTION_TARGET);
|
|
6827
|
+
if (parsed.kind !== "remote") return null;
|
|
6828
|
+
const config = await loadDeployConfig(workspaceRootDir);
|
|
6829
|
+
return resolveOrigin(workspaceRootDir, parsed.envTag, config);
|
|
6830
|
+
} catch {
|
|
6831
|
+
return null;
|
|
6832
|
+
}
|
|
6833
|
+
}
|
|
6834
|
+
function warnIfPrerendered(cwd) {
|
|
6835
|
+
const dir = path34.join(cwd, PRERENDERED_DIR);
|
|
6836
|
+
if (!fs31.existsSync(dir) || fs31.readdirSync(dir).length === 0) return;
|
|
6837
|
+
p30.log.warn(
|
|
6838
|
+
`Prerendered pages were built with no domain configured, so their canonical
|
|
6839
|
+
links point at SvelteKit's placeholder host rather than at this site.
|
|
6840
|
+
|
|
6841
|
+
Set one with ${pc9.cyan("vela deploy --domain example.com")}, or pass ${pc9.cyan("VELA_ORIGIN")}.`
|
|
6842
|
+
);
|
|
6843
|
+
}
|
|
6756
6844
|
|
|
6757
6845
|
// src/commands/preview.ts
|
|
6758
|
-
import
|
|
6759
|
-
import
|
|
6846
|
+
import path35 from "node:path";
|
|
6847
|
+
import process24 from "node:process";
|
|
6760
6848
|
import { Command as Command68 } from "commander";
|
|
6761
6849
|
import { x as x4 } from "tinyexec";
|
|
6762
6850
|
import { detect as detect6 } from "package-manager-detector";
|
|
6763
6851
|
import { resolveCommand as resolveCommand6 } from "package-manager-detector/commands";
|
|
6764
6852
|
var preview = new Command68("preview").description("preview the built app").configureHelp(helpConfig).action(async () => {
|
|
6765
|
-
const cwd =
|
|
6853
|
+
const cwd = process24.cwd();
|
|
6766
6854
|
let pbProc;
|
|
6767
|
-
const needsStart = hasBackend(cwd) && !
|
|
6855
|
+
const needsStart = hasBackend(cwd) && !process24.env.POCKETBASE_URL;
|
|
6768
6856
|
const cleanup = () => {
|
|
6769
6857
|
if (pbProc?.pid) pbProc.kill();
|
|
6770
6858
|
};
|
|
6771
6859
|
if (needsStart) {
|
|
6772
|
-
const dataDir =
|
|
6860
|
+
const dataDir = path35.join(cwd, DATA_DIR);
|
|
6773
6861
|
const started = await startPocketbaseServe({
|
|
6774
6862
|
dataDir,
|
|
6775
6863
|
migrationsDir: MIGRATIONS_DIR,
|
|
6776
|
-
hooksDir:
|
|
6864
|
+
hooksDir: path35.join(dataDir, "hooks"),
|
|
6777
6865
|
dev: true
|
|
6778
6866
|
});
|
|
6779
6867
|
pbProc = started.proc;
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6868
|
+
process24.env.POCKETBASE_URL = started.url;
|
|
6869
|
+
process24.on("exit", cleanup);
|
|
6870
|
+
process24.on("SIGINT", () => {
|
|
6783
6871
|
cleanup();
|
|
6784
|
-
|
|
6872
|
+
process24.exit(0);
|
|
6785
6873
|
});
|
|
6786
6874
|
}
|
|
6787
6875
|
try {
|
|
@@ -6799,12 +6887,12 @@ var preview = new Command68("preview").description("preview the built app").conf
|
|
|
6799
6887
|
});
|
|
6800
6888
|
|
|
6801
6889
|
// src/commands/sync.ts
|
|
6802
|
-
import
|
|
6890
|
+
import path36 from "node:path";
|
|
6803
6891
|
import { Command as Command69 } from "commander";
|
|
6804
6892
|
var sync = new Command69("sync").description("sync types from the database").configureHelp(helpConfig).action(
|
|
6805
6893
|
() => runCommand(async () => {
|
|
6806
6894
|
const { workspaceRootDir } = await getWorkspace();
|
|
6807
|
-
const typesDir =
|
|
6895
|
+
const typesDir = path36.join(workspaceRootDir, ".svelte-kit", "types");
|
|
6808
6896
|
const { processTypes } = await import("@velastack/pocketbase-codegen");
|
|
6809
6897
|
await withPocketbase(workspaceRootDir, async (pb) => {
|
|
6810
6898
|
await processTypes(pb, typesDir);
|
|
@@ -6815,8 +6903,8 @@ var sync = new Command69("sync").description("sync types from the database").con
|
|
|
6815
6903
|
|
|
6816
6904
|
// src/commands/provision.ts
|
|
6817
6905
|
import { Command as Command70 } from "commander";
|
|
6818
|
-
import * as
|
|
6819
|
-
import
|
|
6906
|
+
import * as p31 from "@clack/prompts";
|
|
6907
|
+
import pc10 from "picocolors";
|
|
6820
6908
|
import * as v6 from "valibot";
|
|
6821
6909
|
var OptionsSchema2 = v6.object({
|
|
6822
6910
|
...SSH_OPTION_SCHEMA,
|
|
@@ -6829,19 +6917,19 @@ var provision = addSshOptions(
|
|
|
6829
6917
|
(target, raw) => runCommand(async () => {
|
|
6830
6918
|
const options = parseOptions(OptionsSchema2, raw);
|
|
6831
6919
|
const pbVersion = options.pbVersion ?? pocketbaseVersion();
|
|
6832
|
-
|
|
6833
|
-
|
|
6920
|
+
p31.intro(pc10.bgCyan(pc10.black(" vela provision ")));
|
|
6921
|
+
p31.log.info(`Target ${pc10.cyan(target)}`);
|
|
6834
6922
|
await withSsh(target, sshOptionsFrom(options), async (session) => {
|
|
6835
6923
|
await session.detectElevation();
|
|
6836
6924
|
const existing = await readServerInfo(session);
|
|
6837
6925
|
if (existing) {
|
|
6838
|
-
|
|
6926
|
+
p31.log.info(
|
|
6839
6927
|
`Already provisioned by vela ${existing.cliVersion} on ${existing.provisionedAt}. Bringing it up to date.`
|
|
6840
6928
|
);
|
|
6841
6929
|
}
|
|
6842
|
-
|
|
6930
|
+
p31.log.step("Uploading server scripts");
|
|
6843
6931
|
await syncServerScripts(session);
|
|
6844
|
-
|
|
6932
|
+
p31.log.step("Running provision");
|
|
6845
6933
|
const result = await runServerScript(session, "provision.sh", {
|
|
6846
6934
|
args: [
|
|
6847
6935
|
"--pb-version",
|
|
@@ -6853,7 +6941,7 @@ var provision = addSshOptions(
|
|
|
6853
6941
|
],
|
|
6854
6942
|
stream: true
|
|
6855
6943
|
});
|
|
6856
|
-
|
|
6944
|
+
p31.log.success(
|
|
6857
6945
|
`${target} is ready.
|
|
6858
6946
|
|
|
6859
6947
|
Node ${result?.node ?? "installed"}
|
|
@@ -6861,22 +6949,22 @@ var provision = addSshOptions(
|
|
|
6861
6949
|
PocketBase ${result?.pocketbase ?? pbVersion}`
|
|
6862
6950
|
);
|
|
6863
6951
|
});
|
|
6864
|
-
|
|
6952
|
+
p31.outro(`Deploy with ${pc10.cyan(`vela deploy --server ${target}`)}`);
|
|
6865
6953
|
}, "Failed to provision.")
|
|
6866
6954
|
);
|
|
6867
6955
|
|
|
6868
6956
|
// src/commands/deploy.ts
|
|
6869
|
-
import
|
|
6870
|
-
import
|
|
6871
|
-
import { Command as Command71 } from "commander";
|
|
6872
|
-
import * as
|
|
6873
|
-
import
|
|
6957
|
+
import path39 from "node:path";
|
|
6958
|
+
import fs34 from "node:fs";
|
|
6959
|
+
import { Command as Command71, Option as Option2 } from "commander";
|
|
6960
|
+
import * as p32 from "@clack/prompts";
|
|
6961
|
+
import pc11 from "picocolors";
|
|
6874
6962
|
import * as v7 from "valibot";
|
|
6875
6963
|
|
|
6876
6964
|
// src/lib/pocketbase-settings.ts
|
|
6877
|
-
import
|
|
6878
|
-
import
|
|
6879
|
-
import
|
|
6965
|
+
import fs32 from "node:fs";
|
|
6966
|
+
import path37 from "node:path";
|
|
6967
|
+
import process25 from "node:process";
|
|
6880
6968
|
import PocketBase4 from "pocketbase";
|
|
6881
6969
|
|
|
6882
6970
|
// src/lib/remote-pocketbase.ts
|
|
@@ -6924,17 +7012,17 @@ async function withRemotePocketbase(session, instance, fn) {
|
|
|
6924
7012
|
// src/lib/pocketbase-settings.ts
|
|
6925
7013
|
var COPIED_KEYS = ["appName", "senderName", "senderAddress"];
|
|
6926
7014
|
async function readLocalMeta(cwd) {
|
|
6927
|
-
const dataDir =
|
|
6928
|
-
if (!
|
|
6929
|
-
const email3 =
|
|
6930
|
-
const password10 =
|
|
7015
|
+
const dataDir = path37.join(cwd, DATA_DIR);
|
|
7016
|
+
if (!fs32.existsSync(dataDir)) return null;
|
|
7017
|
+
const email3 = process25.env.POCKETBASE_SUPERUSER_EMAIL;
|
|
7018
|
+
const password10 = process25.env.POCKETBASE_SUPERUSER_PASSWORD;
|
|
6931
7019
|
if (!email3 || !password10) return null;
|
|
6932
7020
|
let proc;
|
|
6933
7021
|
try {
|
|
6934
7022
|
const started = await startPocketbaseServe({
|
|
6935
7023
|
dataDir,
|
|
6936
7024
|
migrationsDir: MIGRATIONS_DIR,
|
|
6937
|
-
hooksDir:
|
|
7025
|
+
hooksDir: path37.join(dataDir, "hooks")
|
|
6938
7026
|
});
|
|
6939
7027
|
proc = started.proc;
|
|
6940
7028
|
const pb = new PocketBase4(started.url);
|
|
@@ -6947,6 +7035,19 @@ async function readLocalMeta(cwd) {
|
|
|
6947
7035
|
proc?.kill();
|
|
6948
7036
|
}
|
|
6949
7037
|
}
|
|
7038
|
+
async function readRemoteAppURL(session, instance) {
|
|
7039
|
+
try {
|
|
7040
|
+
let appURL = null;
|
|
7041
|
+
await withRemotePocketbase(session, instance, async (pb) => {
|
|
7042
|
+
const settings = await pb.settings.getAll();
|
|
7043
|
+
const value = settings.meta?.appURL;
|
|
7044
|
+
appURL = typeof value === "string" && value.trim() ? value : null;
|
|
7045
|
+
});
|
|
7046
|
+
return appURL;
|
|
7047
|
+
} catch {
|
|
7048
|
+
return null;
|
|
7049
|
+
}
|
|
7050
|
+
}
|
|
6950
7051
|
async function seedRemoteMeta(session, instance, local, appURL) {
|
|
6951
7052
|
const patch = {};
|
|
6952
7053
|
for (const key of COPIED_KEYS) {
|
|
@@ -6963,8 +7064,8 @@ async function seedRemoteMeta(session, instance, local, appURL) {
|
|
|
6963
7064
|
}
|
|
6964
7065
|
|
|
6965
7066
|
// src/lib/artifact.ts
|
|
6966
|
-
import
|
|
6967
|
-
import
|
|
7067
|
+
import fs33 from "node:fs";
|
|
7068
|
+
import path38 from "node:path";
|
|
6968
7069
|
import { detect as detect7 } from "package-manager-detector";
|
|
6969
7070
|
import { resolveCommand as resolveCommand7 } from "package-manager-detector/commands";
|
|
6970
7071
|
var DEFAULT_OUTPUT_DIR = "build";
|
|
@@ -7001,11 +7102,11 @@ function collectArtifact(cwd, config = {}) {
|
|
|
7001
7102
|
const outputDir = config.outputDir ?? DEFAULT_OUTPUT_DIR;
|
|
7002
7103
|
const entries = [];
|
|
7003
7104
|
const add2 = (rel, remoteDir = "") => {
|
|
7004
|
-
const localPath =
|
|
7005
|
-
if (
|
|
7105
|
+
const localPath = path38.join(cwd, rel);
|
|
7106
|
+
if (fs33.existsSync(localPath)) entries.push({ localPath, remoteDir });
|
|
7006
7107
|
};
|
|
7007
|
-
const buildPath =
|
|
7008
|
-
if (!
|
|
7108
|
+
const buildPath = path38.join(cwd, outputDir);
|
|
7109
|
+
if (!fs33.existsSync(path38.join(buildPath, "index.js"))) {
|
|
7009
7110
|
throw new BuildError(
|
|
7010
7111
|
`No ${outputDir}/index.js after the build.
|
|
7011
7112
|
|
|
@@ -7018,8 +7119,8 @@ the adapter in your Vite or Svelte config, then build again.`
|
|
|
7018
7119
|
add2("package-lock.json");
|
|
7019
7120
|
add2(".npmrc");
|
|
7020
7121
|
add2(MIGRATIONS_DIR);
|
|
7021
|
-
const hooks =
|
|
7022
|
-
if (
|
|
7122
|
+
const hooks = path38.join(cwd, DATA_DIR, "hooks");
|
|
7123
|
+
if (fs33.existsSync(hooks)) entries.push({ localPath: hooks, remoteDir: "hooks" });
|
|
7023
7124
|
for (const extra of config.include ?? []) add2(extra);
|
|
7024
7125
|
return entries;
|
|
7025
7126
|
}
|
|
@@ -7043,39 +7144,57 @@ var OptionsSchema3 = v7.object({
|
|
|
7043
7144
|
var deploy = addTargetOptions(
|
|
7044
7145
|
new Command71("deploy").description("deploy the app").configureHelp(helpConfig),
|
|
7045
7146
|
"production"
|
|
7046
|
-
).option("--project <name>", "override the project name").option("--domain <hosts>", "hostname(s) to serve on, comma separated").option("--health-path <path>", "path the health check requests").option("--keep <count>", "how many old releases to keep on the server").option("--pb-version <version>", "PocketBase version to run").option("--no-build", "deploy the existing build output without rebuilding").
|
|
7047
|
-
|
|
7048
|
-
|
|
7147
|
+
).option("--project <name>", "override the project name").option("--domain <hosts>", "hostname(s) to serve on, comma separated").option("--health-path <path>", "path the health check requests").option("--keep <count>", "how many old releases to keep on the server").option("--pb-version <version>", "PocketBase version to run").option("--no-build", "deploy the existing build output without rebuilding").addOption(
|
|
7148
|
+
new Option2(
|
|
7149
|
+
"--remote-db",
|
|
7150
|
+
"render the build against the database on the server, over an SSH tunnel \u2014 on by default once the target has been deployed to"
|
|
7151
|
+
).default(void 0)
|
|
7152
|
+
).addOption(
|
|
7153
|
+
new Option2("--no-remote-db", "render the build against a throwaway local database").default(
|
|
7154
|
+
void 0
|
|
7155
|
+
)
|
|
7049
7156
|
).action(
|
|
7050
7157
|
(raw) => runCommand(async () => {
|
|
7051
7158
|
const options = parseOptions(OptionsSchema3, raw);
|
|
7052
7159
|
const backend3 = hasBackend();
|
|
7053
7160
|
const release = releaseId();
|
|
7054
|
-
|
|
7161
|
+
p32.intro(pc11.bgCyan(pc11.black(" vela deploy ")));
|
|
7055
7162
|
await withTarget(
|
|
7056
7163
|
raw,
|
|
7057
7164
|
{
|
|
7058
7165
|
remote: async (ctx) => {
|
|
7059
7166
|
const { session, instance, workspaceRootDir, config } = ctx;
|
|
7060
|
-
|
|
7061
|
-
`${
|
|
7167
|
+
p32.log.info(
|
|
7168
|
+
`${pc11.cyan(ctx.appName)} ${pc11.dim("\u2192")} ${pc11.cyan(ctx.targetName)} ${pc11.dim(`(${ctx.server})`)}`
|
|
7062
7169
|
);
|
|
7063
7170
|
const [existing] = await readInstanceStates(session, instance);
|
|
7064
7171
|
const domain = options.domain ?? ctx.binding.domain ?? config.deploy?.domain ?? existing?.domain ?? "";
|
|
7065
|
-
const
|
|
7172
|
+
const askedForRemoteDb = options.remoteDb ?? config.deploy?.buildAgainstRemote;
|
|
7173
|
+
const remoteDb = askedForRemoteDb ?? Boolean(existing?.pbPort);
|
|
7066
7174
|
if (options.build !== false) {
|
|
7067
|
-
|
|
7175
|
+
const origin = normalizeOrigin(process.env.VELA_ORIGIN ?? domain);
|
|
7176
|
+
let buildEnv = origin ? { VELA_ORIGIN: origin } : {};
|
|
7068
7177
|
let tunnel = null;
|
|
7069
7178
|
if (backend3 && remoteDb) {
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7179
|
+
try {
|
|
7180
|
+
tunnel = await openDatabaseTunnel(session, instance, existing);
|
|
7181
|
+
} catch (err) {
|
|
7182
|
+
if (askedForRemoteDb) throw err;
|
|
7183
|
+
p32.log.warn(
|
|
7184
|
+
`Could not build against the ${pc11.cyan(ctx.targetName)} database, using a local one instead.
|
|
7185
|
+
${pc11.dim(String(err))}`
|
|
7186
|
+
);
|
|
7187
|
+
}
|
|
7188
|
+
}
|
|
7189
|
+
if (tunnel) {
|
|
7190
|
+
buildEnv = { ...buildEnv, ...tunnel.env };
|
|
7191
|
+
p32.log.info(
|
|
7192
|
+
`Building against the ${pc11.cyan(ctx.targetName)} database on ${ctx.server} ${pc11.dim(`(port ${tunnel.pbPort})`)}`
|
|
7074
7193
|
);
|
|
7075
7194
|
} else if (backend3) {
|
|
7076
7195
|
await ensureSuperuser(workspaceRootDir);
|
|
7077
7196
|
}
|
|
7078
|
-
|
|
7197
|
+
p32.log.step("Building");
|
|
7079
7198
|
try {
|
|
7080
7199
|
await runBuild(workspaceRootDir, config.deploy?.buildCommand, buildEnv);
|
|
7081
7200
|
} finally {
|
|
@@ -7084,9 +7203,9 @@ var deploy = addTargetOptions(
|
|
|
7084
7203
|
}
|
|
7085
7204
|
const entries = collectArtifact(workspaceRootDir, config.deploy ?? {});
|
|
7086
7205
|
const sha = await gitSha(workspaceRootDir);
|
|
7087
|
-
|
|
7206
|
+
p32.log.step(`Uploading release ${pc11.dim(release)}`);
|
|
7088
7207
|
await uploadRelease(session, instance, release, entries);
|
|
7089
|
-
|
|
7208
|
+
p32.log.step("Activating");
|
|
7090
7209
|
const result = await runServerScript(session, "apply.sh", {
|
|
7091
7210
|
args: [
|
|
7092
7211
|
instance,
|
|
@@ -7118,8 +7237,8 @@ var deploy = addTargetOptions(
|
|
|
7118
7237
|
});
|
|
7119
7238
|
if (!existing) await reportEmptyEnvironment(session, instance, workspaceRootDir);
|
|
7120
7239
|
const url = result?.url ?? "";
|
|
7121
|
-
|
|
7122
|
-
`Deployed ${
|
|
7240
|
+
p32.log.success(
|
|
7241
|
+
`Deployed ${pc11.cyan(ctx.appName)} ${pc11.dim(release)}
|
|
7123
7242
|
|
|
7124
7243
|
URL ${url}
|
|
7125
7244
|
Port ${result?.webPort ?? "?"}${backend3 ? ` (PocketBase ${result?.pbPort ?? "?"})` : ""}`
|
|
@@ -7131,27 +7250,41 @@ var deploy = addTargetOptions(
|
|
|
7131
7250
|
workspaceRootDir,
|
|
7132
7251
|
domain ? result?.url ?? "" : ""
|
|
7133
7252
|
);
|
|
7134
|
-
|
|
7253
|
+
p32.log.info(
|
|
7135
7254
|
`Created the PocketBase superuser this app authenticates as.
|
|
7136
7255
|
|
|
7137
7256
|
Its credentials are stored in the environment on the server. To use
|
|
7138
|
-
your own instead, ${
|
|
7257
|
+
your own instead, ${pc11.cyan("vela env set POCKETBASE_SUPERUSER_PASSWORD")}
|
|
7139
7258
|
and deploy again.`
|
|
7140
7259
|
);
|
|
7260
|
+
} else if (backend3 && domain) {
|
|
7261
|
+
await reportAppURLDrift(session, instance, domain);
|
|
7141
7262
|
}
|
|
7142
7263
|
if (!domain) {
|
|
7143
|
-
|
|
7264
|
+
p32.log.warn(
|
|
7144
7265
|
`No domain configured, so nothing is proxied to this app yet.
|
|
7145
|
-
Redeploy with ${
|
|
7266
|
+
Redeploy with ${pc11.cyan("--domain example.com")} once DNS points at ${ctx.server}.`
|
|
7146
7267
|
);
|
|
7147
7268
|
}
|
|
7148
7269
|
}
|
|
7149
7270
|
},
|
|
7150
7271
|
{ project: options.project, askDomain: true, label: "deploy" }
|
|
7151
7272
|
);
|
|
7152
|
-
|
|
7273
|
+
p32.outro(`${pc11.cyan("vela status")} to see what is running`);
|
|
7153
7274
|
}, "Failed to deploy.")
|
|
7154
7275
|
);
|
|
7276
|
+
async function reportAppURLDrift(session, instance, domain) {
|
|
7277
|
+
const expected = normalizeOrigin(domain);
|
|
7278
|
+
if (!expected) return;
|
|
7279
|
+
const current = await readRemoteAppURL(session, instance);
|
|
7280
|
+
if (!current || normalizeOrigin(current) === expected) return;
|
|
7281
|
+
p32.log.warn(
|
|
7282
|
+
`This app's PocketBase ${pc11.cyan("appURL")} is ${pc11.dim(current)}, but it is served on ${pc11.dim(expected)}.
|
|
7283
|
+
|
|
7284
|
+
Emails and anything else PocketBase links to will use the former. Update it in
|
|
7285
|
+
the admin panel if that is not deliberate.`
|
|
7286
|
+
);
|
|
7287
|
+
}
|
|
7155
7288
|
async function copyLocalBranding(session, instance, workspaceRootDir, appURL) {
|
|
7156
7289
|
const local = await readLocalMeta(workspaceRootDir);
|
|
7157
7290
|
if (!local) return;
|
|
@@ -7160,17 +7293,17 @@ async function copyLocalBranding(session, instance, workspaceRootDir, appURL) {
|
|
|
7160
7293
|
if (copied.length === 0) return;
|
|
7161
7294
|
const outcome = await restartInstance(session, instance);
|
|
7162
7295
|
if (outcome.deployed && !outcome.restarted) {
|
|
7163
|
-
|
|
7296
|
+
p32.log.warn(
|
|
7164
7297
|
`Copied ${copied.join(", ")}, but the app did not restart to pick them up.
|
|
7165
|
-
${
|
|
7298
|
+
${pc11.dim(outcome.error ?? "")}`
|
|
7166
7299
|
);
|
|
7167
7300
|
return;
|
|
7168
7301
|
}
|
|
7169
|
-
|
|
7302
|
+
p32.log.success(`Copied ${copied.join(", ")} from this project's database`);
|
|
7170
7303
|
} catch (err) {
|
|
7171
|
-
|
|
7304
|
+
p32.log.warn(
|
|
7172
7305
|
`Could not copy this project's PocketBase settings across.
|
|
7173
|
-
Set them in the admin panel instead. ${
|
|
7306
|
+
Set them in the admin panel instead. ${pc11.dim(String(err))}`
|
|
7174
7307
|
);
|
|
7175
7308
|
}
|
|
7176
7309
|
}
|
|
@@ -7221,7 +7354,7 @@ async function uploadRelease(session, instance, release, entries) {
|
|
|
7221
7354
|
}
|
|
7222
7355
|
function isDirectory(target) {
|
|
7223
7356
|
try {
|
|
7224
|
-
return
|
|
7357
|
+
return fs34.statSync(target).isDirectory();
|
|
7225
7358
|
} catch {
|
|
7226
7359
|
return false;
|
|
7227
7360
|
}
|
|
@@ -7229,20 +7362,20 @@ function isDirectory(target) {
|
|
|
7229
7362
|
async function reportEmptyEnvironment(session, instance, workspaceRootDir) {
|
|
7230
7363
|
const remote = await readRemoteEnv(session, instance);
|
|
7231
7364
|
if (Object.keys(remote).length > 0) return;
|
|
7232
|
-
if (!
|
|
7233
|
-
|
|
7365
|
+
if (!fs34.existsSync(path39.join(workspaceRootDir, ".env"))) return;
|
|
7366
|
+
p32.log.warn(
|
|
7234
7367
|
`This app has no production environment variables yet.
|
|
7235
7368
|
|
|
7236
|
-
Local ${
|
|
7237
|
-
${
|
|
7369
|
+
Local ${pc11.cyan(".env")} values are not uploaded by a deploy. Set them with
|
|
7370
|
+
${pc11.cyan("vela env set KEY")}, or copy a file across with ${pc11.cyan("vela env import .env.production")}.`
|
|
7238
7371
|
);
|
|
7239
7372
|
}
|
|
7240
7373
|
|
|
7241
7374
|
// src/commands/link.ts
|
|
7242
|
-
import
|
|
7243
|
-
import
|
|
7375
|
+
import path40 from "node:path";
|
|
7376
|
+
import process26 from "node:process";
|
|
7244
7377
|
import { Command as Command72 } from "commander";
|
|
7245
|
-
import * as
|
|
7378
|
+
import * as p33 from "@clack/prompts";
|
|
7246
7379
|
|
|
7247
7380
|
// src/lib/velastack-api.ts
|
|
7248
7381
|
async function apiFetch(apiKey, pathAndQuery, init) {
|
|
@@ -7298,7 +7431,7 @@ async function linkProject() {
|
|
|
7298
7431
|
const { workspaceRootDir } = await getWorkspace();
|
|
7299
7432
|
const existing = readProjectConfig(workspaceRootDir);
|
|
7300
7433
|
if (existing) {
|
|
7301
|
-
|
|
7434
|
+
p33.log.success(`Linked to ${existing.projectName}.`);
|
|
7302
7435
|
return;
|
|
7303
7436
|
}
|
|
7304
7437
|
const apiKey = requireApiKey();
|
|
@@ -7325,10 +7458,10 @@ async function linkProject() {
|
|
|
7325
7458
|
projectName = created.name;
|
|
7326
7459
|
}
|
|
7327
7460
|
writeProjectConfig(workspaceRootDir, { projectId, teamId, projectName });
|
|
7328
|
-
|
|
7461
|
+
p33.log.success(`Linked to ${projectName}.`);
|
|
7329
7462
|
}
|
|
7330
7463
|
async function pickExistingProject(projects) {
|
|
7331
|
-
const choice = await
|
|
7464
|
+
const choice = await p33.select({
|
|
7332
7465
|
message: "Select a project",
|
|
7333
7466
|
options: [
|
|
7334
7467
|
...projects.map((pr) => ({
|
|
@@ -7338,50 +7471,50 @@ async function pickExistingProject(projects) {
|
|
|
7338
7471
|
{ value: CREATE_NEW, label: "Create a new project" }
|
|
7339
7472
|
]
|
|
7340
7473
|
});
|
|
7341
|
-
if (
|
|
7342
|
-
|
|
7343
|
-
|
|
7474
|
+
if (p33.isCancel(choice)) {
|
|
7475
|
+
p33.cancel("Operation cancelled.");
|
|
7476
|
+
process26.exit(0);
|
|
7344
7477
|
}
|
|
7345
7478
|
return choice;
|
|
7346
7479
|
}
|
|
7347
7480
|
async function pickTeam(teams3) {
|
|
7348
7481
|
if (teams3.length === 1) return teams3[0];
|
|
7349
|
-
const choice = await
|
|
7482
|
+
const choice = await p33.select({
|
|
7350
7483
|
message: "Select a team",
|
|
7351
7484
|
options: teams3.map((team) => ({
|
|
7352
7485
|
value: team.id,
|
|
7353
7486
|
label: team.is_personal ? `${team.name} (personal)` : team.name
|
|
7354
7487
|
}))
|
|
7355
7488
|
});
|
|
7356
|
-
if (
|
|
7357
|
-
|
|
7358
|
-
|
|
7489
|
+
if (p33.isCancel(choice)) {
|
|
7490
|
+
p33.cancel("Operation cancelled.");
|
|
7491
|
+
process26.exit(0);
|
|
7359
7492
|
}
|
|
7360
7493
|
return teams3.find((team) => team.id === choice);
|
|
7361
7494
|
}
|
|
7362
7495
|
async function promptProjectName(workspaceRootDir) {
|
|
7363
7496
|
const defaultValue = defaultProjectName2(workspaceRootDir);
|
|
7364
|
-
const value = await
|
|
7497
|
+
const value = await p33.text({
|
|
7365
7498
|
message: "Project name",
|
|
7366
7499
|
defaultValue,
|
|
7367
7500
|
initialValue: defaultValue,
|
|
7368
7501
|
placeholder: defaultValue,
|
|
7369
7502
|
validate: (v9) => !v9?.trim() ? "Required" : void 0
|
|
7370
7503
|
});
|
|
7371
|
-
if (
|
|
7372
|
-
|
|
7373
|
-
|
|
7504
|
+
if (p33.isCancel(value)) {
|
|
7505
|
+
p33.cancel("Operation cancelled.");
|
|
7506
|
+
process26.exit(0);
|
|
7374
7507
|
}
|
|
7375
7508
|
return value.trim();
|
|
7376
7509
|
}
|
|
7377
7510
|
function defaultProjectName2(workspaceRootDir) {
|
|
7378
7511
|
try {
|
|
7379
|
-
const pkg = readPackageJson(
|
|
7512
|
+
const pkg = readPackageJson(path40.join(workspaceRootDir, "package.json"));
|
|
7380
7513
|
const name = pkg.name;
|
|
7381
7514
|
if (typeof name === "string" && name.trim()) return name.trim();
|
|
7382
7515
|
} catch {
|
|
7383
7516
|
}
|
|
7384
|
-
return
|
|
7517
|
+
return path40.basename(workspaceRootDir);
|
|
7385
7518
|
}
|
|
7386
7519
|
|
|
7387
7520
|
// src/commands/env.ts
|
|
@@ -7389,21 +7522,21 @@ import { Command as Command77 } from "commander";
|
|
|
7389
7522
|
|
|
7390
7523
|
// src/commands/env/list.ts
|
|
7391
7524
|
import { Command as Command73 } from "commander";
|
|
7392
|
-
import * as
|
|
7393
|
-
import
|
|
7525
|
+
import * as p35 from "@clack/prompts";
|
|
7526
|
+
import pc13 from "picocolors";
|
|
7394
7527
|
|
|
7395
7528
|
// src/lib/local-env.ts
|
|
7396
|
-
import
|
|
7397
|
-
import * as
|
|
7398
|
-
import
|
|
7529
|
+
import fs35 from "node:fs";
|
|
7530
|
+
import * as p34 from "@clack/prompts";
|
|
7531
|
+
import pc12 from "picocolors";
|
|
7399
7532
|
function readLocalEnv(envFile) {
|
|
7400
|
-
if (!
|
|
7533
|
+
if (!fs35.existsSync(envFile)) return {};
|
|
7401
7534
|
return readLocalEnvFile(envFile);
|
|
7402
7535
|
}
|
|
7403
7536
|
function editLocalEnv(envFile, edit) {
|
|
7404
|
-
const before =
|
|
7537
|
+
const before = fs35.existsSync(envFile) ? fs35.readFileSync(envFile, "utf8") : "";
|
|
7405
7538
|
const after = edit(before);
|
|
7406
|
-
if (after !== before)
|
|
7539
|
+
if (after !== before) fs35.writeFileSync(envFile, after);
|
|
7407
7540
|
}
|
|
7408
7541
|
function setLocalEnv(envFile, key, value) {
|
|
7409
7542
|
editLocalEnv(envFile, (content) => upsertEnvVar(content, key, value));
|
|
@@ -7420,16 +7553,16 @@ async function applyLocalEnvChange(ctx, changed) {
|
|
|
7420
7553
|
process.env.POCKETBASE_SUPERUSER_EMAIL = email3;
|
|
7421
7554
|
process.env.POCKETBASE_SUPERUSER_PASSWORD = password10;
|
|
7422
7555
|
await ensureSuperuser(ctx.workspaceRootDir);
|
|
7423
|
-
|
|
7556
|
+
p34.log.success("Local superuser updated to match");
|
|
7424
7557
|
} else {
|
|
7425
|
-
|
|
7558
|
+
p34.log.warn(
|
|
7426
7559
|
`The local database still has the old superuser.
|
|
7427
|
-
Set both ${
|
|
7560
|
+
Set both ${pc12.cyan("POCKETBASE_SUPERUSER_EMAIL")} and ${pc12.cyan("POCKETBASE_SUPERUSER_PASSWORD")} to reconcile it.`
|
|
7428
7561
|
);
|
|
7429
7562
|
}
|
|
7430
7563
|
}
|
|
7431
7564
|
if (getPocketbaseMetadata(ctx.workspaceRootDir)) {
|
|
7432
|
-
|
|
7565
|
+
p34.log.info(`Restart ${pc12.cyan("vela dev")} to pick this up.`);
|
|
7433
7566
|
}
|
|
7434
7567
|
}
|
|
7435
7568
|
|
|
@@ -7457,21 +7590,21 @@ var envList = addTargetOptions(
|
|
|
7457
7590
|
);
|
|
7458
7591
|
function report(keys, where) {
|
|
7459
7592
|
if (keys.length === 0) {
|
|
7460
|
-
|
|
7593
|
+
p35.log.info(`No environment variables configured ${pc13.dim(`(${where})`)}.`);
|
|
7461
7594
|
return;
|
|
7462
7595
|
}
|
|
7463
|
-
|
|
7464
|
-
`Environment ${
|
|
7596
|
+
p35.log.info(
|
|
7597
|
+
`Environment ${pc13.dim(`(${where})`)}
|
|
7465
7598
|
|
|
7466
7599
|
` + keys.sort().map((key) => ` ${key}`).join("\n")
|
|
7467
7600
|
);
|
|
7468
7601
|
}
|
|
7469
7602
|
|
|
7470
7603
|
// src/commands/env/set.ts
|
|
7471
|
-
import
|
|
7604
|
+
import process27 from "node:process";
|
|
7472
7605
|
import { Command as Command74 } from "commander";
|
|
7473
|
-
import * as
|
|
7474
|
-
import
|
|
7606
|
+
import * as p36 from "@clack/prompts";
|
|
7607
|
+
import pc14 from "picocolors";
|
|
7475
7608
|
var envSet = addTargetOptions(
|
|
7476
7609
|
new Command74("set").description("set an environment variable").argument("<key>", "variable name").argument("[value]", "value \u2014 prompted for, without echo, when omitted").configureHelp(helpConfig),
|
|
7477
7610
|
"local"
|
|
@@ -7483,14 +7616,14 @@ var envSet = addTargetOptions(
|
|
|
7483
7616
|
local: async (ctx) => {
|
|
7484
7617
|
const resolved = await resolveValue(key, value);
|
|
7485
7618
|
setLocalEnv(ctx.envFile, key, resolved);
|
|
7486
|
-
|
|
7619
|
+
p36.log.success(`${key} updated ${pc14.dim("(local)")}`);
|
|
7487
7620
|
await applyLocalEnvChange(ctx, [key]);
|
|
7488
7621
|
},
|
|
7489
7622
|
remote: async (ctx) => {
|
|
7490
7623
|
const resolved = await resolveValue(key, value);
|
|
7491
7624
|
const env2 = await readRemoteEnv(ctx.session, ctx.instance);
|
|
7492
7625
|
await writeRemoteEnv(ctx.session, ctx.instance, { ...env2, [key]: resolved });
|
|
7493
|
-
|
|
7626
|
+
p36.log.success(`${key} updated ${pc14.dim(`(${ctx.targetName})`)}`);
|
|
7494
7627
|
await applyEnvRestart(ctx, [key]);
|
|
7495
7628
|
}
|
|
7496
7629
|
},
|
|
@@ -7504,21 +7637,21 @@ async function resolveValue(key, value) {
|
|
|
7504
7637
|
return value ?? await promptValue(key);
|
|
7505
7638
|
}
|
|
7506
7639
|
async function promptValue(key) {
|
|
7507
|
-
const value = await
|
|
7508
|
-
message: `Value for ${
|
|
7640
|
+
const value = await p36.password({
|
|
7641
|
+
message: `Value for ${pc14.cyan(key)}`,
|
|
7509
7642
|
validate: (input) => !input?.length ? "Required" : void 0
|
|
7510
7643
|
});
|
|
7511
|
-
if (
|
|
7512
|
-
|
|
7513
|
-
|
|
7644
|
+
if (p36.isCancel(value)) {
|
|
7645
|
+
p36.cancel("Operation cancelled.");
|
|
7646
|
+
process27.exit(0);
|
|
7514
7647
|
}
|
|
7515
7648
|
return value;
|
|
7516
7649
|
}
|
|
7517
7650
|
|
|
7518
7651
|
// src/commands/env/unset.ts
|
|
7519
7652
|
import { Command as Command75 } from "commander";
|
|
7520
|
-
import * as
|
|
7521
|
-
import
|
|
7653
|
+
import * as p37 from "@clack/prompts";
|
|
7654
|
+
import pc15 from "picocolors";
|
|
7522
7655
|
var envUnset = addTargetOptions(
|
|
7523
7656
|
new Command75("unset").description("remove an environment variable").argument("<key>", "variable name").configureHelp(helpConfig),
|
|
7524
7657
|
"local"
|
|
@@ -7529,22 +7662,22 @@ var envUnset = addTargetOptions(
|
|
|
7529
7662
|
{
|
|
7530
7663
|
local: async (ctx) => {
|
|
7531
7664
|
if (!(key in readLocalEnv(ctx.envFile))) {
|
|
7532
|
-
|
|
7665
|
+
p37.log.info(`${key} is not set \u2014 nothing to remove.`);
|
|
7533
7666
|
return;
|
|
7534
7667
|
}
|
|
7535
7668
|
unsetLocalEnv(ctx.envFile, key);
|
|
7536
|
-
|
|
7669
|
+
p37.log.success(`${key} removed ${pc15.dim("(local)")}`);
|
|
7537
7670
|
await applyLocalEnvChange(ctx, [key]);
|
|
7538
7671
|
},
|
|
7539
7672
|
remote: async (ctx) => {
|
|
7540
7673
|
const env2 = await readRemoteEnv(ctx.session, ctx.instance);
|
|
7541
7674
|
if (!(key in env2)) {
|
|
7542
|
-
|
|
7675
|
+
p37.log.info(`${key} is not set \u2014 nothing to remove.`);
|
|
7543
7676
|
return;
|
|
7544
7677
|
}
|
|
7545
7678
|
delete env2[key];
|
|
7546
7679
|
await writeRemoteEnv(ctx.session, ctx.instance, env2);
|
|
7547
|
-
|
|
7680
|
+
p37.log.success(`${key} removed ${pc15.dim(`(${ctx.targetName})`)}`);
|
|
7548
7681
|
await applyEnvRestart(ctx, [key]);
|
|
7549
7682
|
}
|
|
7550
7683
|
},
|
|
@@ -7555,12 +7688,12 @@ var envUnset = addTargetOptions(
|
|
|
7555
7688
|
);
|
|
7556
7689
|
|
|
7557
7690
|
// src/commands/env/import.ts
|
|
7558
|
-
import
|
|
7559
|
-
import
|
|
7560
|
-
import
|
|
7691
|
+
import fs36 from "node:fs";
|
|
7692
|
+
import path41 from "node:path";
|
|
7693
|
+
import process28 from "node:process";
|
|
7561
7694
|
import { Command as Command76 } from "commander";
|
|
7562
|
-
import * as
|
|
7563
|
-
import
|
|
7695
|
+
import * as p38 from "@clack/prompts";
|
|
7696
|
+
import pc16 from "picocolors";
|
|
7564
7697
|
var envImport = addTargetOptions(
|
|
7565
7698
|
new Command76("import").description("merge a dotenv file into the environment").argument("<file>", "dotenv file to read").configureHelp(helpConfig),
|
|
7566
7699
|
"local"
|
|
@@ -7577,22 +7710,22 @@ var envImport = addTargetOptions(
|
|
|
7577
7710
|
const incoming = read(source, file);
|
|
7578
7711
|
const keys = Object.keys(incoming);
|
|
7579
7712
|
if (keys.length === 0) return;
|
|
7580
|
-
|
|
7713
|
+
p38.log.step(`Importing ${keys.length} variable(s) from ${pc16.cyan(file)}`);
|
|
7581
7714
|
editLocalEnv(
|
|
7582
7715
|
ctx.envFile,
|
|
7583
7716
|
(content) => keys.reduce((acc, key) => upsertEnvVar(acc, key, incoming[key]), content)
|
|
7584
7717
|
);
|
|
7585
|
-
|
|
7718
|
+
p38.log.success(`${keys.length} variable(s) updated ${pc16.dim("(local)")}`);
|
|
7586
7719
|
await applyLocalEnvChange(ctx, keys);
|
|
7587
7720
|
},
|
|
7588
7721
|
remote: async (ctx) => {
|
|
7589
7722
|
const incoming = read(resolve(file), file);
|
|
7590
7723
|
const keys = Object.keys(incoming);
|
|
7591
7724
|
if (keys.length === 0) return;
|
|
7592
|
-
|
|
7725
|
+
p38.log.step(`Importing ${keys.length} variable(s) from ${pc16.cyan(file)}`);
|
|
7593
7726
|
const existing = await readRemoteEnv(ctx.session, ctx.instance);
|
|
7594
7727
|
await writeRemoteEnv(ctx.session, ctx.instance, { ...existing, ...incoming });
|
|
7595
|
-
|
|
7728
|
+
p38.log.success(`${keys.length} variable(s) updated ${pc16.dim(`(${ctx.targetName})`)}`);
|
|
7596
7729
|
await applyEnvRestart(ctx, keys);
|
|
7597
7730
|
}
|
|
7598
7731
|
},
|
|
@@ -7602,12 +7735,12 @@ var envImport = addTargetOptions(
|
|
|
7602
7735
|
)
|
|
7603
7736
|
);
|
|
7604
7737
|
function resolve(file) {
|
|
7605
|
-
return
|
|
7738
|
+
return path41.resolve(process28.cwd(), file);
|
|
7606
7739
|
}
|
|
7607
7740
|
function read(resolved, shown) {
|
|
7608
|
-
if (!
|
|
7741
|
+
if (!fs36.existsSync(resolved)) throw new Error(`${shown} does not exist.`);
|
|
7609
7742
|
const incoming = readLocalEnvFile(resolved);
|
|
7610
|
-
if (Object.keys(incoming).length === 0)
|
|
7743
|
+
if (Object.keys(incoming).length === 0) p38.log.info(`${shown} has no variables to import.`);
|
|
7611
7744
|
return incoming;
|
|
7612
7745
|
}
|
|
7613
7746
|
|
|
@@ -7616,8 +7749,8 @@ var env = new Command77("env").description("manage environment variables, locall
|
|
|
7616
7749
|
|
|
7617
7750
|
// src/commands/status.ts
|
|
7618
7751
|
import { Command as Command78 } from "commander";
|
|
7619
|
-
import * as
|
|
7620
|
-
import
|
|
7752
|
+
import * as p39 from "@clack/prompts";
|
|
7753
|
+
import pc17 from "picocolors";
|
|
7621
7754
|
var status = addTargetOptions(
|
|
7622
7755
|
new Command78("status").description("show what is deployed").configureHelp(helpConfig),
|
|
7623
7756
|
"production"
|
|
@@ -7650,15 +7783,15 @@ function report2(states, json) {
|
|
|
7650
7783
|
return;
|
|
7651
7784
|
}
|
|
7652
7785
|
if (states.length === 0) {
|
|
7653
|
-
|
|
7786
|
+
p39.log.info("Nothing is deployed here yet.");
|
|
7654
7787
|
return;
|
|
7655
7788
|
}
|
|
7656
7789
|
for (const state of states) {
|
|
7657
|
-
|
|
7790
|
+
p39.log.info(describe(state));
|
|
7658
7791
|
}
|
|
7659
7792
|
}
|
|
7660
7793
|
function describe(state) {
|
|
7661
|
-
const health = (value) => value === "active" ?
|
|
7794
|
+
const health = (value) => value === "active" ? pc17.green(value) : pc17.red(value || "inactive");
|
|
7662
7795
|
const rows = [
|
|
7663
7796
|
["Instance", state.instance],
|
|
7664
7797
|
["Environment", state.env],
|
|
@@ -7673,13 +7806,13 @@ function describe(state) {
|
|
|
7673
7806
|
...state.gitSha ? [["Commit", state.gitSha.slice(0, 12)]] : []
|
|
7674
7807
|
];
|
|
7675
7808
|
const width = Math.max(...rows.map(([label]) => label.length));
|
|
7676
|
-
return
|
|
7809
|
+
return pc17.cyan(state.name) + "\n\n" + rows.map(([label, value]) => ` ${label.padEnd(width)} ${value}`).join("\n");
|
|
7677
7810
|
}
|
|
7678
7811
|
|
|
7679
7812
|
// src/commands/rollback.ts
|
|
7680
7813
|
import { Command as Command79 } from "commander";
|
|
7681
|
-
import * as
|
|
7682
|
-
import
|
|
7814
|
+
import * as p40 from "@clack/prompts";
|
|
7815
|
+
import pc18 from "picocolors";
|
|
7683
7816
|
var rollback = addTargetOptions(
|
|
7684
7817
|
new Command79("rollback").description("put the previous release back").configureHelp(helpConfig),
|
|
7685
7818
|
"production"
|
|
@@ -7690,8 +7823,8 @@ var rollback = addTargetOptions(
|
|
|
7690
7823
|
raw,
|
|
7691
7824
|
{
|
|
7692
7825
|
remote: async (ctx) => {
|
|
7693
|
-
|
|
7694
|
-
`Rolling back ${
|
|
7826
|
+
p40.log.step(
|
|
7827
|
+
`Rolling back ${pc18.cyan(ctx.appName)} ${pc18.dim(`(${ctx.targetName})`)} on ${ctx.server}`
|
|
7695
7828
|
);
|
|
7696
7829
|
const result = await runServerScript(
|
|
7697
7830
|
ctx.session,
|
|
@@ -7701,8 +7834,8 @@ var rollback = addTargetOptions(
|
|
|
7701
7834
|
stream: true
|
|
7702
7835
|
}
|
|
7703
7836
|
);
|
|
7704
|
-
|
|
7705
|
-
`Rolled back to ${
|
|
7837
|
+
p40.log.success(
|
|
7838
|
+
`Rolled back to ${pc18.cyan(result?.release ?? "the previous release")}` + (result?.from ? ` ${pc18.dim(`(was ${result.from})`)}` : "")
|
|
7706
7839
|
);
|
|
7707
7840
|
}
|
|
7708
7841
|
},
|
|
@@ -7754,10 +7887,10 @@ var logs = addTargetOptions(
|
|
|
7754
7887
|
import { Command as Command82 } from "commander";
|
|
7755
7888
|
|
|
7756
7889
|
// src/commands/admin/create.ts
|
|
7757
|
-
import
|
|
7890
|
+
import process29 from "node:process";
|
|
7758
7891
|
import { Command as Command81 } from "commander";
|
|
7759
|
-
import * as
|
|
7760
|
-
import
|
|
7892
|
+
import * as p41 from "@clack/prompts";
|
|
7893
|
+
import pc19 from "picocolors";
|
|
7761
7894
|
var MIN_PASSWORD = 10;
|
|
7762
7895
|
var adminCreate = addTargetOptions(
|
|
7763
7896
|
new Command81("create").description("create a login for the admin panel").argument("[email]", "email to sign in with \u2014 prompted for when omitted").configureHelp(helpConfig),
|
|
@@ -7788,8 +7921,8 @@ var adminCreate = addTargetOptions(
|
|
|
7788
7921
|
const metadata = getPocketbaseMetadata(ctx.workspaceRootDir);
|
|
7789
7922
|
if (metadata) signIn = `http://${metadata.viteHost}:${metadata.vitePort}`;
|
|
7790
7923
|
}
|
|
7791
|
-
|
|
7792
|
-
signIn ? `Sign in at ${
|
|
7924
|
+
p41.log.info(
|
|
7925
|
+
signIn ? `Sign in at ${pc19.cyan(`${signIn}/admin`)}` : `Sign in at ${pc19.cyan("/admin")} once ${pc19.cyan("vela dev")} is running.`
|
|
7793
7926
|
);
|
|
7794
7927
|
},
|
|
7795
7928
|
remote: async (ctx) => {
|
|
@@ -7802,8 +7935,8 @@ var adminCreate = addTargetOptions(
|
|
|
7802
7935
|
(pb) => upsertSuperuser(pb, address, password10)
|
|
7803
7936
|
);
|
|
7804
7937
|
const base2 = state?.domain ? `https://${state.domain.split(",")[0].trim()}` : "";
|
|
7805
|
-
|
|
7806
|
-
base2 ? `Sign in at ${
|
|
7938
|
+
p41.log.info(
|
|
7939
|
+
base2 ? `Sign in at ${pc19.cyan(`${base2}/admin`)}` : `Sign in at ${pc19.cyan("/admin")} once a domain is configured for this target.`
|
|
7807
7940
|
);
|
|
7808
7941
|
}
|
|
7809
7942
|
},
|
|
@@ -7815,20 +7948,20 @@ var adminCreate = addTargetOptions(
|
|
|
7815
7948
|
async function upsertSuperuser(pb, email3, password10) {
|
|
7816
7949
|
const existing = await findSuperuser(pb, email3);
|
|
7817
7950
|
if (existing) {
|
|
7818
|
-
const confirmed = await
|
|
7819
|
-
message: `${email3}
|
|
7951
|
+
const confirmed = await p41.confirm({
|
|
7952
|
+
message: `${email3} already has an account, update its password?`,
|
|
7820
7953
|
initialValue: false
|
|
7821
7954
|
});
|
|
7822
|
-
if (
|
|
7823
|
-
|
|
7824
|
-
|
|
7955
|
+
if (p41.isCancel(confirmed) || !confirmed) {
|
|
7956
|
+
p41.cancel("Operation cancelled.");
|
|
7957
|
+
process29.exit(0);
|
|
7825
7958
|
}
|
|
7826
7959
|
await pb.collection("_superusers").update(existing, { password: password10, passwordConfirm: password10 });
|
|
7827
|
-
|
|
7960
|
+
p41.log.success(`Password updated for ${pc19.cyan(email3)}, you can sign in now`);
|
|
7828
7961
|
return;
|
|
7829
7962
|
}
|
|
7830
7963
|
await pb.collection("_superusers").create({ email: email3, password: password10, passwordConfirm: password10 });
|
|
7831
|
-
|
|
7964
|
+
p41.log.success(`${pc19.cyan(email3)} can now sign in`);
|
|
7832
7965
|
}
|
|
7833
7966
|
async function findSuperuser(pb, email3) {
|
|
7834
7967
|
try {
|
|
@@ -7839,32 +7972,32 @@ async function findSuperuser(pb, email3) {
|
|
|
7839
7972
|
}
|
|
7840
7973
|
}
|
|
7841
7974
|
async function promptEmail() {
|
|
7842
|
-
const value = await
|
|
7975
|
+
const value = await p41.text({
|
|
7843
7976
|
message: "Email to sign in with",
|
|
7844
7977
|
validate: (input) => input?.includes("@") ? void 0 : "An email address is required"
|
|
7845
7978
|
});
|
|
7846
|
-
if (
|
|
7847
|
-
|
|
7848
|
-
|
|
7979
|
+
if (p41.isCancel(value)) {
|
|
7980
|
+
p41.cancel("Operation cancelled.");
|
|
7981
|
+
process29.exit(0);
|
|
7849
7982
|
}
|
|
7850
7983
|
return value.trim();
|
|
7851
7984
|
}
|
|
7852
7985
|
async function promptPassword2() {
|
|
7853
|
-
const value = await
|
|
7986
|
+
const value = await p41.password({
|
|
7854
7987
|
message: "Password",
|
|
7855
7988
|
validate: (input) => (input?.length ?? 0) >= MIN_PASSWORD ? void 0 : `At least ${MIN_PASSWORD} characters is required`
|
|
7856
7989
|
});
|
|
7857
|
-
if (
|
|
7858
|
-
|
|
7859
|
-
|
|
7990
|
+
if (p41.isCancel(value)) {
|
|
7991
|
+
p41.cancel("Operation cancelled.");
|
|
7992
|
+
process29.exit(0);
|
|
7860
7993
|
}
|
|
7861
|
-
const again = await
|
|
7994
|
+
const again = await p41.password({
|
|
7862
7995
|
message: "Password again",
|
|
7863
7996
|
validate: (input) => input === value ? void 0 : "The two do not match"
|
|
7864
7997
|
});
|
|
7865
|
-
if (
|
|
7866
|
-
|
|
7867
|
-
|
|
7998
|
+
if (p41.isCancel(again)) {
|
|
7999
|
+
p41.cancel("Operation cancelled.");
|
|
8000
|
+
process29.exit(0);
|
|
7868
8001
|
}
|
|
7869
8002
|
return value;
|
|
7870
8003
|
}
|
|
@@ -7874,8 +8007,8 @@ var admin = new Command82("admin").description("manage admin panel logins").conf
|
|
|
7874
8007
|
|
|
7875
8008
|
// src/commands/targets.ts
|
|
7876
8009
|
import { Command as Command83 } from "commander";
|
|
7877
|
-
import * as
|
|
7878
|
-
import
|
|
8010
|
+
import * as p42 from "@clack/prompts";
|
|
8011
|
+
import pc20 from "picocolors";
|
|
7879
8012
|
import * as v8 from "valibot";
|
|
7880
8013
|
var OptionsSchema4 = v8.object({
|
|
7881
8014
|
...SSH_OPTION_SCHEMA,
|
|
@@ -7947,13 +8080,13 @@ function report3(rows, offline) {
|
|
|
7947
8080
|
const domain = width("DOMAIN", (row) => row.domain);
|
|
7948
8081
|
const header = `${"TARGET".padEnd(target)} ${"SERVER".padEnd(server)} ${"DOMAIN".padEnd(domain)} RELEASE`;
|
|
7949
8082
|
const lines = rows.map(
|
|
7950
|
-
(row) => `${row.kind === "local" ?
|
|
8083
|
+
(row) => `${row.kind === "local" ? pc20.dim(row.target.padEnd(target)) : pc20.cyan(row.target.padEnd(target))} ${row.server.padEnd(server)} ${row.domain.padEnd(domain)} ${row.release}`
|
|
7951
8084
|
);
|
|
7952
|
-
|
|
8085
|
+
p42.log.info(`${pc20.dim(header)}
|
|
7953
8086
|
${lines.join("\n")}`);
|
|
7954
8087
|
const unreachable = rows.filter((row) => row.kind === "remote" && !row.reachable);
|
|
7955
8088
|
if (!offline && unreachable.length > 0) {
|
|
7956
|
-
|
|
8089
|
+
p42.log.warn(
|
|
7957
8090
|
`Could not reach ${unreachable.map((row) => row.server).join(", ")}.
|
|
7958
8091
|
Release and domain are shown from what this project recorded.`
|
|
7959
8092
|
);
|
|
@@ -7961,33 +8094,33 @@ Release and domain are shown from what this project recorded.`
|
|
|
7961
8094
|
}
|
|
7962
8095
|
|
|
7963
8096
|
// src/commands/test.ts
|
|
7964
|
-
import
|
|
7965
|
-
import
|
|
8097
|
+
import path42 from "node:path";
|
|
8098
|
+
import process30 from "node:process";
|
|
7966
8099
|
import { Command as Command84 } from "commander";
|
|
7967
8100
|
import PocketBase5 from "pocketbase";
|
|
7968
|
-
import
|
|
8101
|
+
import pc21 from "picocolors";
|
|
7969
8102
|
import { x as x5 } from "tinyexec";
|
|
7970
8103
|
import { detect as detect8 } from "package-manager-detector";
|
|
7971
8104
|
import { resolveCommand as resolveCommand8 } from "package-manager-detector/commands";
|
|
7972
|
-
import
|
|
8105
|
+
import fs37 from "node:fs";
|
|
7973
8106
|
var testServer = new Command84("test:server").description("run server tests").allowUnknownOption(true).allowExcessArguments(true).configureHelp(helpConfig).action(async (_opts, cmd) => {
|
|
7974
|
-
const cwd =
|
|
8107
|
+
const cwd = process30.cwd();
|
|
7975
8108
|
const email3 = `test-${Math.random().toString(36).slice(2)}@example.com`;
|
|
7976
8109
|
const password10 = "password";
|
|
7977
|
-
const testDataDir =
|
|
7978
|
-
|
|
8110
|
+
const testDataDir = path42.join(cwd, "test-data");
|
|
8111
|
+
fs37.rmSync(testDataDir, { recursive: true, force: true });
|
|
7979
8112
|
const { stop, url } = await launchPocketbase(cwd, {
|
|
7980
8113
|
dir: testDataDir,
|
|
7981
|
-
migrationsDir:
|
|
8114
|
+
migrationsDir: path42.join(cwd, "migrations"),
|
|
7982
8115
|
email: email3,
|
|
7983
8116
|
password: password10
|
|
7984
8117
|
});
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
console.log(`${
|
|
7990
|
-
const { createServer } = await
|
|
8118
|
+
process30.env.POCKETBASE_URL = url;
|
|
8119
|
+
process30.env.POCKETBASE_SUPERUSER_EMAIL = email3;
|
|
8120
|
+
process30.env.POCKETBASE_SUPERUSER_PASSWORD = password10;
|
|
8121
|
+
process30.env.TEST = "true";
|
|
8122
|
+
console.log(`${pc21.greenBright("\u2713")} Created test database`);
|
|
8123
|
+
const { createServer } = await loadVite(cwd);
|
|
7991
8124
|
const vite = await createServer({
|
|
7992
8125
|
mode: "test",
|
|
7993
8126
|
plugins: [stubPagesPlugin()],
|
|
@@ -7995,21 +8128,21 @@ var testServer = new Command84("test:server").description("run server tests").al
|
|
|
7995
8128
|
});
|
|
7996
8129
|
const vitePort = await findFreePort();
|
|
7997
8130
|
await vite.listen(vitePort);
|
|
7998
|
-
|
|
7999
|
-
console.log(`${
|
|
8000
|
-
console.log(`${
|
|
8131
|
+
process30.env.VITE_TEST_URL = `http://localhost:${vitePort}`;
|
|
8132
|
+
console.log(`${pc21.greenBright("\u2713")} Started Vite: http://localhost:${vitePort}`);
|
|
8133
|
+
console.log(`${pc21.greenBright("\u2713")} Started PocketBase: ${url}`);
|
|
8001
8134
|
const cleanup = async () => {
|
|
8002
8135
|
stop();
|
|
8003
8136
|
await vite.close();
|
|
8004
|
-
|
|
8137
|
+
fs37.rmSync(testDataDir, { recursive: true, force: true });
|
|
8005
8138
|
};
|
|
8006
8139
|
const pb = new PocketBase5(url);
|
|
8007
8140
|
try {
|
|
8008
8141
|
await authWithRetries(pb, email3, password10);
|
|
8009
8142
|
} catch (e) {
|
|
8010
8143
|
await cleanup();
|
|
8011
|
-
console.error(`${
|
|
8012
|
-
|
|
8144
|
+
console.error(`${pc21.redBright("\u2717")} Auth failed: ${e.message}`);
|
|
8145
|
+
process30.exit(1);
|
|
8013
8146
|
}
|
|
8014
8147
|
const extraArgs = (cmd.parent?.args ?? []).slice(1);
|
|
8015
8148
|
let filter = extraArgs.find((arg) => !arg.startsWith("-"));
|
|
@@ -8027,7 +8160,7 @@ var testServer = new Command84("test:server").description("run server tests").al
|
|
|
8027
8160
|
const resolvedArgs = resolved.args.slice();
|
|
8028
8161
|
if (pm === "npm") resolvedArgs.unshift("--yes");
|
|
8029
8162
|
await x5(resolved.command, resolvedArgs, {
|
|
8030
|
-
nodeOptions: { cwd, stdio: "inherit", env: { ...
|
|
8163
|
+
nodeOptions: { cwd, stdio: "inherit", env: { ...process30.env, CI: "1" } },
|
|
8031
8164
|
throwOnError: true
|
|
8032
8165
|
});
|
|
8033
8166
|
} catch {
|
|
@@ -8053,8 +8186,8 @@ function stubPagesPlugin() {
|
|
|
8053
8186
|
}
|
|
8054
8187
|
|
|
8055
8188
|
// src/commands/routes.ts
|
|
8056
|
-
import
|
|
8057
|
-
import
|
|
8189
|
+
import fs38 from "node:fs";
|
|
8190
|
+
import path43 from "node:path";
|
|
8058
8191
|
import { Command as Command85 } from "commander";
|
|
8059
8192
|
var HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
8060
8193
|
"GET",
|
|
@@ -8068,30 +8201,30 @@ var HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
|
8068
8201
|
]);
|
|
8069
8202
|
var routes = new Command85("routes").description("list routes").configureHelp(helpConfig).action(async () => {
|
|
8070
8203
|
const { workspaceRootDir, routesDir } = await getWorkspace();
|
|
8071
|
-
const routesRoot =
|
|
8204
|
+
const routesRoot = path43.join(workspaceRootDir, routesDir);
|
|
8072
8205
|
const found = walk(routesRoot, routesRoot).filter((r) => r.methods.length > 0);
|
|
8073
8206
|
found.sort((a, b) => a.urlPattern.localeCompare(b.urlPattern));
|
|
8074
8207
|
printTable(found);
|
|
8075
8208
|
});
|
|
8076
8209
|
function walk(root, dir) {
|
|
8077
|
-
const entries =
|
|
8210
|
+
const entries = fs38.readdirSync(dir, { withFileTypes: true });
|
|
8078
8211
|
const routes2 = [];
|
|
8079
8212
|
const hasLeaf = entries.some((e) => e.isFile() && isRouteFile(e.name));
|
|
8080
8213
|
if (hasLeaf) {
|
|
8081
|
-
const id = "/" +
|
|
8214
|
+
const id = "/" + path43.relative(root, dir).split(path43.sep).filter(Boolean).join("/");
|
|
8082
8215
|
const urlPattern = id.replace(/\([^)]+\)\/?/g, "").replace(/\/$/, "") || "/";
|
|
8083
8216
|
const methods = /* @__PURE__ */ new Set();
|
|
8084
8217
|
for (const entry of entries) {
|
|
8085
8218
|
if (!entry.isFile()) continue;
|
|
8086
8219
|
if (entry.name.endsWith("+page.svelte")) methods.add("GET");
|
|
8087
8220
|
if (entry.name.endsWith("+server.ts") || entry.name.endsWith("+server.js") || entry.name.endsWith("+page.server.ts") || entry.name.endsWith("+page.server.js")) {
|
|
8088
|
-
extractMethods(
|
|
8221
|
+
extractMethods(path43.join(dir, entry.name)).forEach((m) => methods.add(m));
|
|
8089
8222
|
}
|
|
8090
8223
|
}
|
|
8091
8224
|
routes2.push({ id: id || "/", urlPattern, methods: [...methods] });
|
|
8092
8225
|
}
|
|
8093
8226
|
for (const entry of entries) {
|
|
8094
|
-
if (entry.isDirectory()) routes2.push(...walk(root,
|
|
8227
|
+
if (entry.isDirectory()) routes2.push(...walk(root, path43.join(dir, entry.name)));
|
|
8095
8228
|
}
|
|
8096
8229
|
return routes2;
|
|
8097
8230
|
}
|
|
@@ -8100,7 +8233,7 @@ function isRouteFile(name) {
|
|
|
8100
8233
|
}
|
|
8101
8234
|
function extractMethods(file) {
|
|
8102
8235
|
try {
|
|
8103
|
-
const content =
|
|
8236
|
+
const content = fs38.readFileSync(file, "utf8");
|
|
8104
8237
|
const methods = [];
|
|
8105
8238
|
const exportRegex = /export\s+(?:const|async\s+function|function)\s+(\w+)/g;
|
|
8106
8239
|
let match;
|
|
@@ -8141,13 +8274,13 @@ function printTable(routes2) {
|
|
|
8141
8274
|
}
|
|
8142
8275
|
|
|
8143
8276
|
// src/commands/i18n.ts
|
|
8144
|
-
import
|
|
8277
|
+
import process31 from "node:process";
|
|
8145
8278
|
import { Command as Command86 } from "commander";
|
|
8146
8279
|
import { x as x6 } from "tinyexec";
|
|
8147
8280
|
import { detect as detect9 } from "package-manager-detector";
|
|
8148
8281
|
import { resolveCommand as resolveCommand9 } from "package-manager-detector/commands";
|
|
8149
8282
|
async function runWuchale(extraArgs) {
|
|
8150
|
-
const cwd =
|
|
8283
|
+
const cwd = process31.cwd();
|
|
8151
8284
|
const pm = (await detect9({ cwd }))?.name ?? "npm";
|
|
8152
8285
|
const resolved = resolveCommand9(pm, "execute", ["wuchale", ...extraArgs]);
|
|
8153
8286
|
const args = resolved.args.slice();
|
|
@@ -8197,37 +8330,37 @@ var BACKEND_OPTIONAL_COMMANDS = /* @__PURE__ */ new Set(["dev", "build", "previe
|
|
|
8197
8330
|
var program = new Command87().name(package_default.name).description(package_default.description).version(package_default.version, "-v, --version").configureHelp(helpConfig);
|
|
8198
8331
|
program.hook("preAction", (_thisCommand, actionCommand) => {
|
|
8199
8332
|
if (isStub(actionCommand)) return;
|
|
8200
|
-
const envRoot = findWorkspaceRoot() ??
|
|
8333
|
+
const envRoot = findWorkspaceRoot() ?? process32.cwd();
|
|
8201
8334
|
dotenv2.config({ path: nodePath.join(envRoot, ".env"), quiet: true });
|
|
8202
|
-
const
|
|
8203
|
-
if (NO_BACKEND_COMMMANDS.has(
|
|
8204
|
-
const top =
|
|
8335
|
+
const path44 = getCommandPath(actionCommand);
|
|
8336
|
+
if (NO_BACKEND_COMMMANDS.has(path44)) return;
|
|
8337
|
+
const top = path44.split(" ", 1)[0];
|
|
8205
8338
|
if (NO_BACKEND_COMMMANDS.has(top)) return;
|
|
8206
8339
|
if (!hasBackend()) {
|
|
8207
8340
|
if (BACKEND_OPTIONAL_COMMANDS.has(top)) return;
|
|
8208
|
-
|
|
8209
|
-
`${
|
|
8341
|
+
p43.log.error(
|
|
8342
|
+
`${pc22.cyan(`vela ${path44}`)} needs a backend, and this project does not have one.
|
|
8210
8343
|
|
|
8211
8344
|
Static projects have no database to talk to.
|
|
8212
8345
|
|
|
8213
|
-
To add a backend to this project, run ${
|
|
8346
|
+
To add a backend to this project, run ${pc22.cyan("vela bless")}.`
|
|
8214
8347
|
);
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8348
|
+
p43.log.message();
|
|
8349
|
+
p43.cancel("Operation failed.");
|
|
8350
|
+
process32.exit(1);
|
|
8218
8351
|
}
|
|
8219
|
-
if (!
|
|
8220
|
-
|
|
8352
|
+
if (!process32.env.POCKETBASE_SUPERUSER_EMAIL || !process32.env.POCKETBASE_SUPERUSER_PASSWORD) {
|
|
8353
|
+
p43.log.error(
|
|
8221
8354
|
`PocketBase superuser credentials are required.
|
|
8222
8355
|
|
|
8223
|
-
Set ${
|
|
8356
|
+
Set ${pc22.cyan("POCKETBASE_SUPERUSER_EMAIL")} and ${pc22.cyan("POCKETBASE_SUPERUSER_PASSWORD")} in your .env file.
|
|
8224
8357
|
|
|
8225
|
-
To set up a new project, run ${
|
|
8226
|
-
To set up an existing project, run ${
|
|
8358
|
+
To set up a new project, run ${pc22.cyan("vela create")}.
|
|
8359
|
+
To set up an existing project, run ${pc22.cyan("vela bless")}.`
|
|
8227
8360
|
);
|
|
8228
|
-
|
|
8229
|
-
|
|
8230
|
-
|
|
8361
|
+
p43.log.message();
|
|
8362
|
+
p43.cancel("Operation failed.");
|
|
8363
|
+
process32.exit(1);
|
|
8231
8364
|
}
|
|
8232
8365
|
});
|
|
8233
8366
|
function getCommandPath(cmd) {
|
|
@@ -8278,14 +8411,14 @@ for (const command of [
|
|
|
8278
8411
|
}
|
|
8279
8412
|
|
|
8280
8413
|
// src/bin.ts
|
|
8281
|
-
var argv = normalizeArgv(
|
|
8414
|
+
var argv = normalizeArgv(process33.argv.slice(2));
|
|
8282
8415
|
var delegatedExitCode = delegateToLocalCli({
|
|
8283
8416
|
argv,
|
|
8284
8417
|
selfPath: fileURLToPath2(import.meta.url),
|
|
8285
8418
|
selfVersion: package_default.version
|
|
8286
8419
|
});
|
|
8287
8420
|
if (delegatedExitCode !== null) {
|
|
8288
|
-
|
|
8421
|
+
process33.exit(delegatedExitCode);
|
|
8289
8422
|
}
|
|
8290
8423
|
program.parse(argv, { from: "user" });
|
|
8291
8424
|
//# sourceMappingURL=bin.js.map
|