vela 0.10.3 → 0.10.4
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
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/bin.ts
|
|
4
|
-
import
|
|
4
|
+
import process32 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.4",
|
|
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
|
|
171
|
+
import process31 from "node:process";
|
|
172
172
|
import * as p42 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 pc21 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, "-");
|
|
@@ -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,35 @@ async function startWatchingTypes(cwd, pb) {
|
|
|
6709
6748
|
}
|
|
6710
6749
|
|
|
6711
6750
|
// src/commands/build.ts
|
|
6712
|
-
import
|
|
6713
|
-
import
|
|
6751
|
+
import path34 from "node:path";
|
|
6752
|
+
import process22 from "node:process";
|
|
6714
6753
|
import { Command as Command67 } from "commander";
|
|
6715
6754
|
import { x as x3 } from "tinyexec";
|
|
6716
6755
|
import { detect as detect5 } from "package-manager-detector";
|
|
6717
6756
|
import { resolveCommand as resolveCommand5 } from "package-manager-detector/commands";
|
|
6718
6757
|
var build = new Command67("build").description("build the app").configureHelp(helpConfig).action(async () => {
|
|
6719
|
-
|
|
6720
|
-
const cwd =
|
|
6758
|
+
process22.env.VITE_BUILD = "true";
|
|
6759
|
+
const cwd = process22.cwd();
|
|
6721
6760
|
let pbProc;
|
|
6722
|
-
const needsStart = hasBackend(cwd) && !
|
|
6761
|
+
const needsStart = hasBackend(cwd) && !process22.env.POCKETBASE_URL;
|
|
6723
6762
|
const cleanup = () => {
|
|
6724
6763
|
if (pbProc?.pid) pbProc.kill();
|
|
6725
6764
|
};
|
|
6726
6765
|
if (needsStart) {
|
|
6727
6766
|
await ensureSuperuser(cwd);
|
|
6728
|
-
const dataDir =
|
|
6767
|
+
const dataDir = path34.join(cwd, DATA_DIR);
|
|
6729
6768
|
const started = await startPocketbaseServe({
|
|
6730
6769
|
dataDir,
|
|
6731
6770
|
migrationsDir: MIGRATIONS_DIR,
|
|
6732
|
-
hooksDir:
|
|
6771
|
+
hooksDir: path34.join(dataDir, "hooks"),
|
|
6733
6772
|
dev: true
|
|
6734
6773
|
});
|
|
6735
6774
|
pbProc = started.proc;
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
|
|
6775
|
+
process22.env.POCKETBASE_URL = started.url;
|
|
6776
|
+
process22.on("exit", cleanup);
|
|
6777
|
+
process22.on("SIGINT", () => {
|
|
6739
6778
|
cleanup();
|
|
6740
|
-
|
|
6779
|
+
process22.exit(0);
|
|
6741
6780
|
});
|
|
6742
6781
|
}
|
|
6743
6782
|
try {
|
|
@@ -6755,33 +6794,33 @@ var build = new Command67("build").description("build the app").configureHelp(he
|
|
|
6755
6794
|
});
|
|
6756
6795
|
|
|
6757
6796
|
// src/commands/preview.ts
|
|
6758
|
-
import
|
|
6759
|
-
import
|
|
6797
|
+
import path35 from "node:path";
|
|
6798
|
+
import process23 from "node:process";
|
|
6760
6799
|
import { Command as Command68 } from "commander";
|
|
6761
6800
|
import { x as x4 } from "tinyexec";
|
|
6762
6801
|
import { detect as detect6 } from "package-manager-detector";
|
|
6763
6802
|
import { resolveCommand as resolveCommand6 } from "package-manager-detector/commands";
|
|
6764
6803
|
var preview = new Command68("preview").description("preview the built app").configureHelp(helpConfig).action(async () => {
|
|
6765
|
-
const cwd =
|
|
6804
|
+
const cwd = process23.cwd();
|
|
6766
6805
|
let pbProc;
|
|
6767
|
-
const needsStart = hasBackend(cwd) && !
|
|
6806
|
+
const needsStart = hasBackend(cwd) && !process23.env.POCKETBASE_URL;
|
|
6768
6807
|
const cleanup = () => {
|
|
6769
6808
|
if (pbProc?.pid) pbProc.kill();
|
|
6770
6809
|
};
|
|
6771
6810
|
if (needsStart) {
|
|
6772
|
-
const dataDir =
|
|
6811
|
+
const dataDir = path35.join(cwd, DATA_DIR);
|
|
6773
6812
|
const started = await startPocketbaseServe({
|
|
6774
6813
|
dataDir,
|
|
6775
6814
|
migrationsDir: MIGRATIONS_DIR,
|
|
6776
|
-
hooksDir:
|
|
6815
|
+
hooksDir: path35.join(dataDir, "hooks"),
|
|
6777
6816
|
dev: true
|
|
6778
6817
|
});
|
|
6779
6818
|
pbProc = started.proc;
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6819
|
+
process23.env.POCKETBASE_URL = started.url;
|
|
6820
|
+
process23.on("exit", cleanup);
|
|
6821
|
+
process23.on("SIGINT", () => {
|
|
6783
6822
|
cleanup();
|
|
6784
|
-
|
|
6823
|
+
process23.exit(0);
|
|
6785
6824
|
});
|
|
6786
6825
|
}
|
|
6787
6826
|
try {
|
|
@@ -6799,12 +6838,12 @@ var preview = new Command68("preview").description("preview the built app").conf
|
|
|
6799
6838
|
});
|
|
6800
6839
|
|
|
6801
6840
|
// src/commands/sync.ts
|
|
6802
|
-
import
|
|
6841
|
+
import path36 from "node:path";
|
|
6803
6842
|
import { Command as Command69 } from "commander";
|
|
6804
6843
|
var sync = new Command69("sync").description("sync types from the database").configureHelp(helpConfig).action(
|
|
6805
6844
|
() => runCommand(async () => {
|
|
6806
6845
|
const { workspaceRootDir } = await getWorkspace();
|
|
6807
|
-
const typesDir =
|
|
6846
|
+
const typesDir = path36.join(workspaceRootDir, ".svelte-kit", "types");
|
|
6808
6847
|
const { processTypes } = await import("@velastack/pocketbase-codegen");
|
|
6809
6848
|
await withPocketbase(workspaceRootDir, async (pb) => {
|
|
6810
6849
|
await processTypes(pb, typesDir);
|
|
@@ -6816,7 +6855,7 @@ var sync = new Command69("sync").description("sync types from the database").con
|
|
|
6816
6855
|
// src/commands/provision.ts
|
|
6817
6856
|
import { Command as Command70 } from "commander";
|
|
6818
6857
|
import * as p30 from "@clack/prompts";
|
|
6819
|
-
import
|
|
6858
|
+
import pc9 from "picocolors";
|
|
6820
6859
|
import * as v6 from "valibot";
|
|
6821
6860
|
var OptionsSchema2 = v6.object({
|
|
6822
6861
|
...SSH_OPTION_SCHEMA,
|
|
@@ -6829,8 +6868,8 @@ var provision = addSshOptions(
|
|
|
6829
6868
|
(target, raw) => runCommand(async () => {
|
|
6830
6869
|
const options = parseOptions(OptionsSchema2, raw);
|
|
6831
6870
|
const pbVersion = options.pbVersion ?? pocketbaseVersion();
|
|
6832
|
-
p30.intro(
|
|
6833
|
-
p30.log.info(`Target ${
|
|
6871
|
+
p30.intro(pc9.bgCyan(pc9.black(" vela provision ")));
|
|
6872
|
+
p30.log.info(`Target ${pc9.cyan(target)}`);
|
|
6834
6873
|
await withSsh(target, sshOptionsFrom(options), async (session) => {
|
|
6835
6874
|
await session.detectElevation();
|
|
6836
6875
|
const existing = await readServerInfo(session);
|
|
@@ -6861,22 +6900,22 @@ var provision = addSshOptions(
|
|
|
6861
6900
|
PocketBase ${result?.pocketbase ?? pbVersion}`
|
|
6862
6901
|
);
|
|
6863
6902
|
});
|
|
6864
|
-
p30.outro(`Deploy with ${
|
|
6903
|
+
p30.outro(`Deploy with ${pc9.cyan(`vela deploy --server ${target}`)}`);
|
|
6865
6904
|
}, "Failed to provision.")
|
|
6866
6905
|
);
|
|
6867
6906
|
|
|
6868
6907
|
// src/commands/deploy.ts
|
|
6869
|
-
import
|
|
6908
|
+
import path39 from "node:path";
|
|
6870
6909
|
import fs33 from "node:fs";
|
|
6871
6910
|
import { Command as Command71 } from "commander";
|
|
6872
6911
|
import * as p31 from "@clack/prompts";
|
|
6873
|
-
import
|
|
6912
|
+
import pc10 from "picocolors";
|
|
6874
6913
|
import * as v7 from "valibot";
|
|
6875
6914
|
|
|
6876
6915
|
// src/lib/pocketbase-settings.ts
|
|
6877
6916
|
import fs31 from "node:fs";
|
|
6878
|
-
import
|
|
6879
|
-
import
|
|
6917
|
+
import path37 from "node:path";
|
|
6918
|
+
import process24 from "node:process";
|
|
6880
6919
|
import PocketBase4 from "pocketbase";
|
|
6881
6920
|
|
|
6882
6921
|
// src/lib/remote-pocketbase.ts
|
|
@@ -6924,17 +6963,17 @@ async function withRemotePocketbase(session, instance, fn) {
|
|
|
6924
6963
|
// src/lib/pocketbase-settings.ts
|
|
6925
6964
|
var COPIED_KEYS = ["appName", "senderName", "senderAddress"];
|
|
6926
6965
|
async function readLocalMeta(cwd) {
|
|
6927
|
-
const dataDir =
|
|
6966
|
+
const dataDir = path37.join(cwd, DATA_DIR);
|
|
6928
6967
|
if (!fs31.existsSync(dataDir)) return null;
|
|
6929
|
-
const email3 =
|
|
6930
|
-
const password10 =
|
|
6968
|
+
const email3 = process24.env.POCKETBASE_SUPERUSER_EMAIL;
|
|
6969
|
+
const password10 = process24.env.POCKETBASE_SUPERUSER_PASSWORD;
|
|
6931
6970
|
if (!email3 || !password10) return null;
|
|
6932
6971
|
let proc;
|
|
6933
6972
|
try {
|
|
6934
6973
|
const started = await startPocketbaseServe({
|
|
6935
6974
|
dataDir,
|
|
6936
6975
|
migrationsDir: MIGRATIONS_DIR,
|
|
6937
|
-
hooksDir:
|
|
6976
|
+
hooksDir: path37.join(dataDir, "hooks")
|
|
6938
6977
|
});
|
|
6939
6978
|
proc = started.proc;
|
|
6940
6979
|
const pb = new PocketBase4(started.url);
|
|
@@ -6964,7 +7003,7 @@ async function seedRemoteMeta(session, instance, local, appURL) {
|
|
|
6964
7003
|
|
|
6965
7004
|
// src/lib/artifact.ts
|
|
6966
7005
|
import fs32 from "node:fs";
|
|
6967
|
-
import
|
|
7006
|
+
import path38 from "node:path";
|
|
6968
7007
|
import { detect as detect7 } from "package-manager-detector";
|
|
6969
7008
|
import { resolveCommand as resolveCommand7 } from "package-manager-detector/commands";
|
|
6970
7009
|
var DEFAULT_OUTPUT_DIR = "build";
|
|
@@ -7001,11 +7040,11 @@ function collectArtifact(cwd, config = {}) {
|
|
|
7001
7040
|
const outputDir = config.outputDir ?? DEFAULT_OUTPUT_DIR;
|
|
7002
7041
|
const entries = [];
|
|
7003
7042
|
const add2 = (rel, remoteDir = "") => {
|
|
7004
|
-
const localPath =
|
|
7043
|
+
const localPath = path38.join(cwd, rel);
|
|
7005
7044
|
if (fs32.existsSync(localPath)) entries.push({ localPath, remoteDir });
|
|
7006
7045
|
};
|
|
7007
|
-
const buildPath =
|
|
7008
|
-
if (!fs32.existsSync(
|
|
7046
|
+
const buildPath = path38.join(cwd, outputDir);
|
|
7047
|
+
if (!fs32.existsSync(path38.join(buildPath, "index.js"))) {
|
|
7009
7048
|
throw new BuildError(
|
|
7010
7049
|
`No ${outputDir}/index.js after the build.
|
|
7011
7050
|
|
|
@@ -7018,7 +7057,7 @@ the adapter in your Vite or Svelte config, then build again.`
|
|
|
7018
7057
|
add2("package-lock.json");
|
|
7019
7058
|
add2(".npmrc");
|
|
7020
7059
|
add2(MIGRATIONS_DIR);
|
|
7021
|
-
const hooks =
|
|
7060
|
+
const hooks = path38.join(cwd, DATA_DIR, "hooks");
|
|
7022
7061
|
if (fs32.existsSync(hooks)) entries.push({ localPath: hooks, remoteDir: "hooks" });
|
|
7023
7062
|
for (const extra of config.include ?? []) add2(extra);
|
|
7024
7063
|
return entries;
|
|
@@ -7051,14 +7090,14 @@ var deploy = addTargetOptions(
|
|
|
7051
7090
|
const options = parseOptions(OptionsSchema3, raw);
|
|
7052
7091
|
const backend3 = hasBackend();
|
|
7053
7092
|
const release = releaseId();
|
|
7054
|
-
p31.intro(
|
|
7093
|
+
p31.intro(pc10.bgCyan(pc10.black(" vela deploy ")));
|
|
7055
7094
|
await withTarget(
|
|
7056
7095
|
raw,
|
|
7057
7096
|
{
|
|
7058
7097
|
remote: async (ctx) => {
|
|
7059
7098
|
const { session, instance, workspaceRootDir, config } = ctx;
|
|
7060
7099
|
p31.log.info(
|
|
7061
|
-
`${
|
|
7100
|
+
`${pc10.cyan(ctx.appName)} ${pc10.dim("\u2192")} ${pc10.cyan(ctx.targetName)} ${pc10.dim(`(${ctx.server})`)}`
|
|
7062
7101
|
);
|
|
7063
7102
|
const [existing] = await readInstanceStates(session, instance);
|
|
7064
7103
|
const domain = options.domain ?? ctx.binding.domain ?? config.deploy?.domain ?? existing?.domain ?? "";
|
|
@@ -7070,7 +7109,7 @@ var deploy = addTargetOptions(
|
|
|
7070
7109
|
tunnel = await openDatabaseTunnel(session, instance, existing);
|
|
7071
7110
|
buildEnv = tunnel.env;
|
|
7072
7111
|
p31.log.info(
|
|
7073
|
-
`Building against the ${
|
|
7112
|
+
`Building against the ${pc10.cyan(ctx.targetName)} database on ${ctx.server} ${pc10.dim(`(port ${tunnel.pbPort})`)}`
|
|
7074
7113
|
);
|
|
7075
7114
|
} else if (backend3) {
|
|
7076
7115
|
await ensureSuperuser(workspaceRootDir);
|
|
@@ -7084,7 +7123,7 @@ var deploy = addTargetOptions(
|
|
|
7084
7123
|
}
|
|
7085
7124
|
const entries = collectArtifact(workspaceRootDir, config.deploy ?? {});
|
|
7086
7125
|
const sha = await gitSha(workspaceRootDir);
|
|
7087
|
-
p31.log.step(`Uploading release ${
|
|
7126
|
+
p31.log.step(`Uploading release ${pc10.dim(release)}`);
|
|
7088
7127
|
await uploadRelease(session, instance, release, entries);
|
|
7089
7128
|
p31.log.step("Activating");
|
|
7090
7129
|
const result = await runServerScript(session, "apply.sh", {
|
|
@@ -7119,7 +7158,7 @@ var deploy = addTargetOptions(
|
|
|
7119
7158
|
if (!existing) await reportEmptyEnvironment(session, instance, workspaceRootDir);
|
|
7120
7159
|
const url = result?.url ?? "";
|
|
7121
7160
|
p31.log.success(
|
|
7122
|
-
`Deployed ${
|
|
7161
|
+
`Deployed ${pc10.cyan(ctx.appName)} ${pc10.dim(release)}
|
|
7123
7162
|
|
|
7124
7163
|
URL ${url}
|
|
7125
7164
|
Port ${result?.webPort ?? "?"}${backend3 ? ` (PocketBase ${result?.pbPort ?? "?"})` : ""}`
|
|
@@ -7135,21 +7174,21 @@ var deploy = addTargetOptions(
|
|
|
7135
7174
|
`Created the PocketBase superuser this app authenticates as.
|
|
7136
7175
|
|
|
7137
7176
|
Its credentials are stored in the environment on the server. To use
|
|
7138
|
-
your own instead, ${
|
|
7177
|
+
your own instead, ${pc10.cyan("vela env set POCKETBASE_SUPERUSER_PASSWORD")}
|
|
7139
7178
|
and deploy again.`
|
|
7140
7179
|
);
|
|
7141
7180
|
}
|
|
7142
7181
|
if (!domain) {
|
|
7143
7182
|
p31.log.warn(
|
|
7144
7183
|
`No domain configured, so nothing is proxied to this app yet.
|
|
7145
|
-
Redeploy with ${
|
|
7184
|
+
Redeploy with ${pc10.cyan("--domain example.com")} once DNS points at ${ctx.server}.`
|
|
7146
7185
|
);
|
|
7147
7186
|
}
|
|
7148
7187
|
}
|
|
7149
7188
|
},
|
|
7150
7189
|
{ project: options.project, askDomain: true, label: "deploy" }
|
|
7151
7190
|
);
|
|
7152
|
-
p31.outro(`${
|
|
7191
|
+
p31.outro(`${pc10.cyan("vela status")} to see what is running`);
|
|
7153
7192
|
}, "Failed to deploy.")
|
|
7154
7193
|
);
|
|
7155
7194
|
async function copyLocalBranding(session, instance, workspaceRootDir, appURL) {
|
|
@@ -7162,7 +7201,7 @@ async function copyLocalBranding(session, instance, workspaceRootDir, appURL) {
|
|
|
7162
7201
|
if (outcome.deployed && !outcome.restarted) {
|
|
7163
7202
|
p31.log.warn(
|
|
7164
7203
|
`Copied ${copied.join(", ")}, but the app did not restart to pick them up.
|
|
7165
|
-
${
|
|
7204
|
+
${pc10.dim(outcome.error ?? "")}`
|
|
7166
7205
|
);
|
|
7167
7206
|
return;
|
|
7168
7207
|
}
|
|
@@ -7170,7 +7209,7 @@ ${pc9.dim(outcome.error ?? "")}`
|
|
|
7170
7209
|
} catch (err) {
|
|
7171
7210
|
p31.log.warn(
|
|
7172
7211
|
`Could not copy this project's PocketBase settings across.
|
|
7173
|
-
Set them in the admin panel instead. ${
|
|
7212
|
+
Set them in the admin panel instead. ${pc10.dim(String(err))}`
|
|
7174
7213
|
);
|
|
7175
7214
|
}
|
|
7176
7215
|
}
|
|
@@ -7229,18 +7268,18 @@ function isDirectory(target) {
|
|
|
7229
7268
|
async function reportEmptyEnvironment(session, instance, workspaceRootDir) {
|
|
7230
7269
|
const remote = await readRemoteEnv(session, instance);
|
|
7231
7270
|
if (Object.keys(remote).length > 0) return;
|
|
7232
|
-
if (!fs33.existsSync(
|
|
7271
|
+
if (!fs33.existsSync(path39.join(workspaceRootDir, ".env"))) return;
|
|
7233
7272
|
p31.log.warn(
|
|
7234
7273
|
`This app has no production environment variables yet.
|
|
7235
7274
|
|
|
7236
|
-
Local ${
|
|
7237
|
-
${
|
|
7275
|
+
Local ${pc10.cyan(".env")} values are not uploaded by a deploy. Set them with
|
|
7276
|
+
${pc10.cyan("vela env set KEY")}, or copy a file across with ${pc10.cyan("vela env import .env.production")}.`
|
|
7238
7277
|
);
|
|
7239
7278
|
}
|
|
7240
7279
|
|
|
7241
7280
|
// src/commands/link.ts
|
|
7242
|
-
import
|
|
7243
|
-
import
|
|
7281
|
+
import path40 from "node:path";
|
|
7282
|
+
import process25 from "node:process";
|
|
7244
7283
|
import { Command as Command72 } from "commander";
|
|
7245
7284
|
import * as p32 from "@clack/prompts";
|
|
7246
7285
|
|
|
@@ -7340,7 +7379,7 @@ async function pickExistingProject(projects) {
|
|
|
7340
7379
|
});
|
|
7341
7380
|
if (p32.isCancel(choice)) {
|
|
7342
7381
|
p32.cancel("Operation cancelled.");
|
|
7343
|
-
|
|
7382
|
+
process25.exit(0);
|
|
7344
7383
|
}
|
|
7345
7384
|
return choice;
|
|
7346
7385
|
}
|
|
@@ -7355,7 +7394,7 @@ async function pickTeam(teams3) {
|
|
|
7355
7394
|
});
|
|
7356
7395
|
if (p32.isCancel(choice)) {
|
|
7357
7396
|
p32.cancel("Operation cancelled.");
|
|
7358
|
-
|
|
7397
|
+
process25.exit(0);
|
|
7359
7398
|
}
|
|
7360
7399
|
return teams3.find((team) => team.id === choice);
|
|
7361
7400
|
}
|
|
@@ -7370,18 +7409,18 @@ async function promptProjectName(workspaceRootDir) {
|
|
|
7370
7409
|
});
|
|
7371
7410
|
if (p32.isCancel(value)) {
|
|
7372
7411
|
p32.cancel("Operation cancelled.");
|
|
7373
|
-
|
|
7412
|
+
process25.exit(0);
|
|
7374
7413
|
}
|
|
7375
7414
|
return value.trim();
|
|
7376
7415
|
}
|
|
7377
7416
|
function defaultProjectName2(workspaceRootDir) {
|
|
7378
7417
|
try {
|
|
7379
|
-
const pkg = readPackageJson(
|
|
7418
|
+
const pkg = readPackageJson(path40.join(workspaceRootDir, "package.json"));
|
|
7380
7419
|
const name = pkg.name;
|
|
7381
7420
|
if (typeof name === "string" && name.trim()) return name.trim();
|
|
7382
7421
|
} catch {
|
|
7383
7422
|
}
|
|
7384
|
-
return
|
|
7423
|
+
return path40.basename(workspaceRootDir);
|
|
7385
7424
|
}
|
|
7386
7425
|
|
|
7387
7426
|
// src/commands/env.ts
|
|
@@ -7390,12 +7429,12 @@ import { Command as Command77 } from "commander";
|
|
|
7390
7429
|
// src/commands/env/list.ts
|
|
7391
7430
|
import { Command as Command73 } from "commander";
|
|
7392
7431
|
import * as p34 from "@clack/prompts";
|
|
7393
|
-
import
|
|
7432
|
+
import pc12 from "picocolors";
|
|
7394
7433
|
|
|
7395
7434
|
// src/lib/local-env.ts
|
|
7396
7435
|
import fs34 from "node:fs";
|
|
7397
7436
|
import * as p33 from "@clack/prompts";
|
|
7398
|
-
import
|
|
7437
|
+
import pc11 from "picocolors";
|
|
7399
7438
|
function readLocalEnv(envFile) {
|
|
7400
7439
|
if (!fs34.existsSync(envFile)) return {};
|
|
7401
7440
|
return readLocalEnvFile(envFile);
|
|
@@ -7424,12 +7463,12 @@ async function applyLocalEnvChange(ctx, changed) {
|
|
|
7424
7463
|
} else {
|
|
7425
7464
|
p33.log.warn(
|
|
7426
7465
|
`The local database still has the old superuser.
|
|
7427
|
-
Set both ${
|
|
7466
|
+
Set both ${pc11.cyan("POCKETBASE_SUPERUSER_EMAIL")} and ${pc11.cyan("POCKETBASE_SUPERUSER_PASSWORD")} to reconcile it.`
|
|
7428
7467
|
);
|
|
7429
7468
|
}
|
|
7430
7469
|
}
|
|
7431
7470
|
if (getPocketbaseMetadata(ctx.workspaceRootDir)) {
|
|
7432
|
-
p33.log.info(`Restart ${
|
|
7471
|
+
p33.log.info(`Restart ${pc11.cyan("vela dev")} to pick this up.`);
|
|
7433
7472
|
}
|
|
7434
7473
|
}
|
|
7435
7474
|
|
|
@@ -7457,21 +7496,21 @@ var envList = addTargetOptions(
|
|
|
7457
7496
|
);
|
|
7458
7497
|
function report(keys, where) {
|
|
7459
7498
|
if (keys.length === 0) {
|
|
7460
|
-
p34.log.info(`No environment variables configured ${
|
|
7499
|
+
p34.log.info(`No environment variables configured ${pc12.dim(`(${where})`)}.`);
|
|
7461
7500
|
return;
|
|
7462
7501
|
}
|
|
7463
7502
|
p34.log.info(
|
|
7464
|
-
`Environment ${
|
|
7503
|
+
`Environment ${pc12.dim(`(${where})`)}
|
|
7465
7504
|
|
|
7466
7505
|
` + keys.sort().map((key) => ` ${key}`).join("\n")
|
|
7467
7506
|
);
|
|
7468
7507
|
}
|
|
7469
7508
|
|
|
7470
7509
|
// src/commands/env/set.ts
|
|
7471
|
-
import
|
|
7510
|
+
import process26 from "node:process";
|
|
7472
7511
|
import { Command as Command74 } from "commander";
|
|
7473
7512
|
import * as p35 from "@clack/prompts";
|
|
7474
|
-
import
|
|
7513
|
+
import pc13 from "picocolors";
|
|
7475
7514
|
var envSet = addTargetOptions(
|
|
7476
7515
|
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
7516
|
"local"
|
|
@@ -7483,14 +7522,14 @@ var envSet = addTargetOptions(
|
|
|
7483
7522
|
local: async (ctx) => {
|
|
7484
7523
|
const resolved = await resolveValue(key, value);
|
|
7485
7524
|
setLocalEnv(ctx.envFile, key, resolved);
|
|
7486
|
-
p35.log.success(`${key} updated ${
|
|
7525
|
+
p35.log.success(`${key} updated ${pc13.dim("(local)")}`);
|
|
7487
7526
|
await applyLocalEnvChange(ctx, [key]);
|
|
7488
7527
|
},
|
|
7489
7528
|
remote: async (ctx) => {
|
|
7490
7529
|
const resolved = await resolveValue(key, value);
|
|
7491
7530
|
const env2 = await readRemoteEnv(ctx.session, ctx.instance);
|
|
7492
7531
|
await writeRemoteEnv(ctx.session, ctx.instance, { ...env2, [key]: resolved });
|
|
7493
|
-
p35.log.success(`${key} updated ${
|
|
7532
|
+
p35.log.success(`${key} updated ${pc13.dim(`(${ctx.targetName})`)}`);
|
|
7494
7533
|
await applyEnvRestart(ctx, [key]);
|
|
7495
7534
|
}
|
|
7496
7535
|
},
|
|
@@ -7505,12 +7544,12 @@ async function resolveValue(key, value) {
|
|
|
7505
7544
|
}
|
|
7506
7545
|
async function promptValue(key) {
|
|
7507
7546
|
const value = await p35.password({
|
|
7508
|
-
message: `Value for ${
|
|
7547
|
+
message: `Value for ${pc13.cyan(key)}`,
|
|
7509
7548
|
validate: (input) => !input?.length ? "Required" : void 0
|
|
7510
7549
|
});
|
|
7511
7550
|
if (p35.isCancel(value)) {
|
|
7512
7551
|
p35.cancel("Operation cancelled.");
|
|
7513
|
-
|
|
7552
|
+
process26.exit(0);
|
|
7514
7553
|
}
|
|
7515
7554
|
return value;
|
|
7516
7555
|
}
|
|
@@ -7518,7 +7557,7 @@ async function promptValue(key) {
|
|
|
7518
7557
|
// src/commands/env/unset.ts
|
|
7519
7558
|
import { Command as Command75 } from "commander";
|
|
7520
7559
|
import * as p36 from "@clack/prompts";
|
|
7521
|
-
import
|
|
7560
|
+
import pc14 from "picocolors";
|
|
7522
7561
|
var envUnset = addTargetOptions(
|
|
7523
7562
|
new Command75("unset").description("remove an environment variable").argument("<key>", "variable name").configureHelp(helpConfig),
|
|
7524
7563
|
"local"
|
|
@@ -7533,7 +7572,7 @@ var envUnset = addTargetOptions(
|
|
|
7533
7572
|
return;
|
|
7534
7573
|
}
|
|
7535
7574
|
unsetLocalEnv(ctx.envFile, key);
|
|
7536
|
-
p36.log.success(`${key} removed ${
|
|
7575
|
+
p36.log.success(`${key} removed ${pc14.dim("(local)")}`);
|
|
7537
7576
|
await applyLocalEnvChange(ctx, [key]);
|
|
7538
7577
|
},
|
|
7539
7578
|
remote: async (ctx) => {
|
|
@@ -7544,7 +7583,7 @@ var envUnset = addTargetOptions(
|
|
|
7544
7583
|
}
|
|
7545
7584
|
delete env2[key];
|
|
7546
7585
|
await writeRemoteEnv(ctx.session, ctx.instance, env2);
|
|
7547
|
-
p36.log.success(`${key} removed ${
|
|
7586
|
+
p36.log.success(`${key} removed ${pc14.dim(`(${ctx.targetName})`)}`);
|
|
7548
7587
|
await applyEnvRestart(ctx, [key]);
|
|
7549
7588
|
}
|
|
7550
7589
|
},
|
|
@@ -7556,11 +7595,11 @@ var envUnset = addTargetOptions(
|
|
|
7556
7595
|
|
|
7557
7596
|
// src/commands/env/import.ts
|
|
7558
7597
|
import fs35 from "node:fs";
|
|
7559
|
-
import
|
|
7560
|
-
import
|
|
7598
|
+
import path41 from "node:path";
|
|
7599
|
+
import process27 from "node:process";
|
|
7561
7600
|
import { Command as Command76 } from "commander";
|
|
7562
7601
|
import * as p37 from "@clack/prompts";
|
|
7563
|
-
import
|
|
7602
|
+
import pc15 from "picocolors";
|
|
7564
7603
|
var envImport = addTargetOptions(
|
|
7565
7604
|
new Command76("import").description("merge a dotenv file into the environment").argument("<file>", "dotenv file to read").configureHelp(helpConfig),
|
|
7566
7605
|
"local"
|
|
@@ -7577,22 +7616,22 @@ var envImport = addTargetOptions(
|
|
|
7577
7616
|
const incoming = read(source, file);
|
|
7578
7617
|
const keys = Object.keys(incoming);
|
|
7579
7618
|
if (keys.length === 0) return;
|
|
7580
|
-
p37.log.step(`Importing ${keys.length} variable(s) from ${
|
|
7619
|
+
p37.log.step(`Importing ${keys.length} variable(s) from ${pc15.cyan(file)}`);
|
|
7581
7620
|
editLocalEnv(
|
|
7582
7621
|
ctx.envFile,
|
|
7583
7622
|
(content) => keys.reduce((acc, key) => upsertEnvVar(acc, key, incoming[key]), content)
|
|
7584
7623
|
);
|
|
7585
|
-
p37.log.success(`${keys.length} variable(s) updated ${
|
|
7624
|
+
p37.log.success(`${keys.length} variable(s) updated ${pc15.dim("(local)")}`);
|
|
7586
7625
|
await applyLocalEnvChange(ctx, keys);
|
|
7587
7626
|
},
|
|
7588
7627
|
remote: async (ctx) => {
|
|
7589
7628
|
const incoming = read(resolve(file), file);
|
|
7590
7629
|
const keys = Object.keys(incoming);
|
|
7591
7630
|
if (keys.length === 0) return;
|
|
7592
|
-
p37.log.step(`Importing ${keys.length} variable(s) from ${
|
|
7631
|
+
p37.log.step(`Importing ${keys.length} variable(s) from ${pc15.cyan(file)}`);
|
|
7593
7632
|
const existing = await readRemoteEnv(ctx.session, ctx.instance);
|
|
7594
7633
|
await writeRemoteEnv(ctx.session, ctx.instance, { ...existing, ...incoming });
|
|
7595
|
-
p37.log.success(`${keys.length} variable(s) updated ${
|
|
7634
|
+
p37.log.success(`${keys.length} variable(s) updated ${pc15.dim(`(${ctx.targetName})`)}`);
|
|
7596
7635
|
await applyEnvRestart(ctx, keys);
|
|
7597
7636
|
}
|
|
7598
7637
|
},
|
|
@@ -7602,7 +7641,7 @@ var envImport = addTargetOptions(
|
|
|
7602
7641
|
)
|
|
7603
7642
|
);
|
|
7604
7643
|
function resolve(file) {
|
|
7605
|
-
return
|
|
7644
|
+
return path41.resolve(process27.cwd(), file);
|
|
7606
7645
|
}
|
|
7607
7646
|
function read(resolved, shown) {
|
|
7608
7647
|
if (!fs35.existsSync(resolved)) throw new Error(`${shown} does not exist.`);
|
|
@@ -7617,7 +7656,7 @@ var env = new Command77("env").description("manage environment variables, locall
|
|
|
7617
7656
|
// src/commands/status.ts
|
|
7618
7657
|
import { Command as Command78 } from "commander";
|
|
7619
7658
|
import * as p38 from "@clack/prompts";
|
|
7620
|
-
import
|
|
7659
|
+
import pc16 from "picocolors";
|
|
7621
7660
|
var status = addTargetOptions(
|
|
7622
7661
|
new Command78("status").description("show what is deployed").configureHelp(helpConfig),
|
|
7623
7662
|
"production"
|
|
@@ -7658,7 +7697,7 @@ function report2(states, json) {
|
|
|
7658
7697
|
}
|
|
7659
7698
|
}
|
|
7660
7699
|
function describe(state) {
|
|
7661
|
-
const health = (value) => value === "active" ?
|
|
7700
|
+
const health = (value) => value === "active" ? pc16.green(value) : pc16.red(value || "inactive");
|
|
7662
7701
|
const rows = [
|
|
7663
7702
|
["Instance", state.instance],
|
|
7664
7703
|
["Environment", state.env],
|
|
@@ -7673,13 +7712,13 @@ function describe(state) {
|
|
|
7673
7712
|
...state.gitSha ? [["Commit", state.gitSha.slice(0, 12)]] : []
|
|
7674
7713
|
];
|
|
7675
7714
|
const width = Math.max(...rows.map(([label]) => label.length));
|
|
7676
|
-
return
|
|
7715
|
+
return pc16.cyan(state.name) + "\n\n" + rows.map(([label, value]) => ` ${label.padEnd(width)} ${value}`).join("\n");
|
|
7677
7716
|
}
|
|
7678
7717
|
|
|
7679
7718
|
// src/commands/rollback.ts
|
|
7680
7719
|
import { Command as Command79 } from "commander";
|
|
7681
7720
|
import * as p39 from "@clack/prompts";
|
|
7682
|
-
import
|
|
7721
|
+
import pc17 from "picocolors";
|
|
7683
7722
|
var rollback = addTargetOptions(
|
|
7684
7723
|
new Command79("rollback").description("put the previous release back").configureHelp(helpConfig),
|
|
7685
7724
|
"production"
|
|
@@ -7691,7 +7730,7 @@ var rollback = addTargetOptions(
|
|
|
7691
7730
|
{
|
|
7692
7731
|
remote: async (ctx) => {
|
|
7693
7732
|
p39.log.step(
|
|
7694
|
-
`Rolling back ${
|
|
7733
|
+
`Rolling back ${pc17.cyan(ctx.appName)} ${pc17.dim(`(${ctx.targetName})`)} on ${ctx.server}`
|
|
7695
7734
|
);
|
|
7696
7735
|
const result = await runServerScript(
|
|
7697
7736
|
ctx.session,
|
|
@@ -7702,7 +7741,7 @@ var rollback = addTargetOptions(
|
|
|
7702
7741
|
}
|
|
7703
7742
|
);
|
|
7704
7743
|
p39.log.success(
|
|
7705
|
-
`Rolled back to ${
|
|
7744
|
+
`Rolled back to ${pc17.cyan(result?.release ?? "the previous release")}` + (result?.from ? ` ${pc17.dim(`(was ${result.from})`)}` : "")
|
|
7706
7745
|
);
|
|
7707
7746
|
}
|
|
7708
7747
|
},
|
|
@@ -7754,10 +7793,10 @@ var logs = addTargetOptions(
|
|
|
7754
7793
|
import { Command as Command82 } from "commander";
|
|
7755
7794
|
|
|
7756
7795
|
// src/commands/admin/create.ts
|
|
7757
|
-
import
|
|
7796
|
+
import process28 from "node:process";
|
|
7758
7797
|
import { Command as Command81 } from "commander";
|
|
7759
7798
|
import * as p40 from "@clack/prompts";
|
|
7760
|
-
import
|
|
7799
|
+
import pc18 from "picocolors";
|
|
7761
7800
|
var MIN_PASSWORD = 10;
|
|
7762
7801
|
var adminCreate = addTargetOptions(
|
|
7763
7802
|
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),
|
|
@@ -7789,7 +7828,7 @@ var adminCreate = addTargetOptions(
|
|
|
7789
7828
|
if (metadata) signIn = `http://${metadata.viteHost}:${metadata.vitePort}`;
|
|
7790
7829
|
}
|
|
7791
7830
|
p40.log.info(
|
|
7792
|
-
signIn ? `Sign in at ${
|
|
7831
|
+
signIn ? `Sign in at ${pc18.cyan(`${signIn}/admin`)}` : `Sign in at ${pc18.cyan("/admin")} once ${pc18.cyan("vela dev")} is running.`
|
|
7793
7832
|
);
|
|
7794
7833
|
},
|
|
7795
7834
|
remote: async (ctx) => {
|
|
@@ -7803,7 +7842,7 @@ var adminCreate = addTargetOptions(
|
|
|
7803
7842
|
);
|
|
7804
7843
|
const base2 = state?.domain ? `https://${state.domain.split(",")[0].trim()}` : "";
|
|
7805
7844
|
p40.log.info(
|
|
7806
|
-
base2 ? `Sign in at ${
|
|
7845
|
+
base2 ? `Sign in at ${pc18.cyan(`${base2}/admin`)}` : `Sign in at ${pc18.cyan("/admin")} once a domain is configured for this target.`
|
|
7807
7846
|
);
|
|
7808
7847
|
}
|
|
7809
7848
|
},
|
|
@@ -7821,14 +7860,14 @@ async function upsertSuperuser(pb, email3, password10) {
|
|
|
7821
7860
|
});
|
|
7822
7861
|
if (p40.isCancel(confirmed) || !confirmed) {
|
|
7823
7862
|
p40.cancel("Operation cancelled.");
|
|
7824
|
-
|
|
7863
|
+
process28.exit(0);
|
|
7825
7864
|
}
|
|
7826
7865
|
await pb.collection("_superusers").update(existing, { password: password10, passwordConfirm: password10 });
|
|
7827
|
-
p40.log.success(`Password reset for ${
|
|
7866
|
+
p40.log.success(`Password reset for ${pc18.cyan(email3)}`);
|
|
7828
7867
|
return;
|
|
7829
7868
|
}
|
|
7830
7869
|
await pb.collection("_superusers").create({ email: email3, password: password10, passwordConfirm: password10 });
|
|
7831
|
-
p40.log.success(`${
|
|
7870
|
+
p40.log.success(`${pc18.cyan(email3)} can now sign in`);
|
|
7832
7871
|
}
|
|
7833
7872
|
async function findSuperuser(pb, email3) {
|
|
7834
7873
|
try {
|
|
@@ -7845,7 +7884,7 @@ async function promptEmail() {
|
|
|
7845
7884
|
});
|
|
7846
7885
|
if (p40.isCancel(value)) {
|
|
7847
7886
|
p40.cancel("Operation cancelled.");
|
|
7848
|
-
|
|
7887
|
+
process28.exit(0);
|
|
7849
7888
|
}
|
|
7850
7889
|
return value.trim();
|
|
7851
7890
|
}
|
|
@@ -7856,7 +7895,7 @@ async function promptPassword2() {
|
|
|
7856
7895
|
});
|
|
7857
7896
|
if (p40.isCancel(value)) {
|
|
7858
7897
|
p40.cancel("Operation cancelled.");
|
|
7859
|
-
|
|
7898
|
+
process28.exit(0);
|
|
7860
7899
|
}
|
|
7861
7900
|
const again = await p40.password({
|
|
7862
7901
|
message: "Password again",
|
|
@@ -7864,7 +7903,7 @@ async function promptPassword2() {
|
|
|
7864
7903
|
});
|
|
7865
7904
|
if (p40.isCancel(again)) {
|
|
7866
7905
|
p40.cancel("Operation cancelled.");
|
|
7867
|
-
|
|
7906
|
+
process28.exit(0);
|
|
7868
7907
|
}
|
|
7869
7908
|
return value;
|
|
7870
7909
|
}
|
|
@@ -7875,7 +7914,7 @@ var admin = new Command82("admin").description("manage admin panel logins").conf
|
|
|
7875
7914
|
// src/commands/targets.ts
|
|
7876
7915
|
import { Command as Command83 } from "commander";
|
|
7877
7916
|
import * as p41 from "@clack/prompts";
|
|
7878
|
-
import
|
|
7917
|
+
import pc19 from "picocolors";
|
|
7879
7918
|
import * as v8 from "valibot";
|
|
7880
7919
|
var OptionsSchema4 = v8.object({
|
|
7881
7920
|
...SSH_OPTION_SCHEMA,
|
|
@@ -7947,9 +7986,9 @@ function report3(rows, offline) {
|
|
|
7947
7986
|
const domain = width("DOMAIN", (row) => row.domain);
|
|
7948
7987
|
const header = `${"TARGET".padEnd(target)} ${"SERVER".padEnd(server)} ${"DOMAIN".padEnd(domain)} RELEASE`;
|
|
7949
7988
|
const lines = rows.map(
|
|
7950
|
-
(row) => `${row.kind === "local" ?
|
|
7989
|
+
(row) => `${row.kind === "local" ? pc19.dim(row.target.padEnd(target)) : pc19.cyan(row.target.padEnd(target))} ${row.server.padEnd(server)} ${row.domain.padEnd(domain)} ${row.release}`
|
|
7951
7990
|
);
|
|
7952
|
-
p41.log.info(`${
|
|
7991
|
+
p41.log.info(`${pc19.dim(header)}
|
|
7953
7992
|
${lines.join("\n")}`);
|
|
7954
7993
|
const unreachable = rows.filter((row) => row.kind === "remote" && !row.reachable);
|
|
7955
7994
|
if (!offline && unreachable.length > 0) {
|
|
@@ -7961,33 +8000,33 @@ Release and domain are shown from what this project recorded.`
|
|
|
7961
8000
|
}
|
|
7962
8001
|
|
|
7963
8002
|
// src/commands/test.ts
|
|
7964
|
-
import
|
|
7965
|
-
import
|
|
8003
|
+
import path42 from "node:path";
|
|
8004
|
+
import process29 from "node:process";
|
|
7966
8005
|
import { Command as Command84 } from "commander";
|
|
7967
8006
|
import PocketBase5 from "pocketbase";
|
|
7968
|
-
import
|
|
8007
|
+
import pc20 from "picocolors";
|
|
7969
8008
|
import { x as x5 } from "tinyexec";
|
|
7970
8009
|
import { detect as detect8 } from "package-manager-detector";
|
|
7971
8010
|
import { resolveCommand as resolveCommand8 } from "package-manager-detector/commands";
|
|
7972
8011
|
import fs36 from "node:fs";
|
|
7973
8012
|
var testServer = new Command84("test:server").description("run server tests").allowUnknownOption(true).allowExcessArguments(true).configureHelp(helpConfig).action(async (_opts, cmd) => {
|
|
7974
|
-
const cwd =
|
|
8013
|
+
const cwd = process29.cwd();
|
|
7975
8014
|
const email3 = `test-${Math.random().toString(36).slice(2)}@example.com`;
|
|
7976
8015
|
const password10 = "password";
|
|
7977
|
-
const testDataDir =
|
|
8016
|
+
const testDataDir = path42.join(cwd, "test-data");
|
|
7978
8017
|
fs36.rmSync(testDataDir, { recursive: true, force: true });
|
|
7979
8018
|
const { stop, url } = await launchPocketbase(cwd, {
|
|
7980
8019
|
dir: testDataDir,
|
|
7981
|
-
migrationsDir:
|
|
8020
|
+
migrationsDir: path42.join(cwd, "migrations"),
|
|
7982
8021
|
email: email3,
|
|
7983
8022
|
password: password10
|
|
7984
8023
|
});
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
console.log(`${
|
|
7990
|
-
const { createServer } = await
|
|
8024
|
+
process29.env.POCKETBASE_URL = url;
|
|
8025
|
+
process29.env.POCKETBASE_SUPERUSER_EMAIL = email3;
|
|
8026
|
+
process29.env.POCKETBASE_SUPERUSER_PASSWORD = password10;
|
|
8027
|
+
process29.env.TEST = "true";
|
|
8028
|
+
console.log(`${pc20.greenBright("\u2713")} Created test database`);
|
|
8029
|
+
const { createServer } = await loadVite(cwd);
|
|
7991
8030
|
const vite = await createServer({
|
|
7992
8031
|
mode: "test",
|
|
7993
8032
|
plugins: [stubPagesPlugin()],
|
|
@@ -7995,9 +8034,9 @@ var testServer = new Command84("test:server").description("run server tests").al
|
|
|
7995
8034
|
});
|
|
7996
8035
|
const vitePort = await findFreePort();
|
|
7997
8036
|
await vite.listen(vitePort);
|
|
7998
|
-
|
|
7999
|
-
console.log(`${
|
|
8000
|
-
console.log(`${
|
|
8037
|
+
process29.env.VITE_TEST_URL = `http://localhost:${vitePort}`;
|
|
8038
|
+
console.log(`${pc20.greenBright("\u2713")} Started Vite: http://localhost:${vitePort}`);
|
|
8039
|
+
console.log(`${pc20.greenBright("\u2713")} Started PocketBase: ${url}`);
|
|
8001
8040
|
const cleanup = async () => {
|
|
8002
8041
|
stop();
|
|
8003
8042
|
await vite.close();
|
|
@@ -8008,8 +8047,8 @@ var testServer = new Command84("test:server").description("run server tests").al
|
|
|
8008
8047
|
await authWithRetries(pb, email3, password10);
|
|
8009
8048
|
} catch (e) {
|
|
8010
8049
|
await cleanup();
|
|
8011
|
-
console.error(`${
|
|
8012
|
-
|
|
8050
|
+
console.error(`${pc20.redBright("\u2717")} Auth failed: ${e.message}`);
|
|
8051
|
+
process29.exit(1);
|
|
8013
8052
|
}
|
|
8014
8053
|
const extraArgs = (cmd.parent?.args ?? []).slice(1);
|
|
8015
8054
|
let filter = extraArgs.find((arg) => !arg.startsWith("-"));
|
|
@@ -8027,7 +8066,7 @@ var testServer = new Command84("test:server").description("run server tests").al
|
|
|
8027
8066
|
const resolvedArgs = resolved.args.slice();
|
|
8028
8067
|
if (pm === "npm") resolvedArgs.unshift("--yes");
|
|
8029
8068
|
await x5(resolved.command, resolvedArgs, {
|
|
8030
|
-
nodeOptions: { cwd, stdio: "inherit", env: { ...
|
|
8069
|
+
nodeOptions: { cwd, stdio: "inherit", env: { ...process29.env, CI: "1" } },
|
|
8031
8070
|
throwOnError: true
|
|
8032
8071
|
});
|
|
8033
8072
|
} catch {
|
|
@@ -8054,7 +8093,7 @@ function stubPagesPlugin() {
|
|
|
8054
8093
|
|
|
8055
8094
|
// src/commands/routes.ts
|
|
8056
8095
|
import fs37 from "node:fs";
|
|
8057
|
-
import
|
|
8096
|
+
import path43 from "node:path";
|
|
8058
8097
|
import { Command as Command85 } from "commander";
|
|
8059
8098
|
var HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
8060
8099
|
"GET",
|
|
@@ -8068,7 +8107,7 @@ var HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
|
8068
8107
|
]);
|
|
8069
8108
|
var routes = new Command85("routes").description("list routes").configureHelp(helpConfig).action(async () => {
|
|
8070
8109
|
const { workspaceRootDir, routesDir } = await getWorkspace();
|
|
8071
|
-
const routesRoot =
|
|
8110
|
+
const routesRoot = path43.join(workspaceRootDir, routesDir);
|
|
8072
8111
|
const found = walk(routesRoot, routesRoot).filter((r) => r.methods.length > 0);
|
|
8073
8112
|
found.sort((a, b) => a.urlPattern.localeCompare(b.urlPattern));
|
|
8074
8113
|
printTable(found);
|
|
@@ -8078,20 +8117,20 @@ function walk(root, dir) {
|
|
|
8078
8117
|
const routes2 = [];
|
|
8079
8118
|
const hasLeaf = entries.some((e) => e.isFile() && isRouteFile(e.name));
|
|
8080
8119
|
if (hasLeaf) {
|
|
8081
|
-
const id = "/" +
|
|
8120
|
+
const id = "/" + path43.relative(root, dir).split(path43.sep).filter(Boolean).join("/");
|
|
8082
8121
|
const urlPattern = id.replace(/\([^)]+\)\/?/g, "").replace(/\/$/, "") || "/";
|
|
8083
8122
|
const methods = /* @__PURE__ */ new Set();
|
|
8084
8123
|
for (const entry of entries) {
|
|
8085
8124
|
if (!entry.isFile()) continue;
|
|
8086
8125
|
if (entry.name.endsWith("+page.svelte")) methods.add("GET");
|
|
8087
8126
|
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(
|
|
8127
|
+
extractMethods(path43.join(dir, entry.name)).forEach((m) => methods.add(m));
|
|
8089
8128
|
}
|
|
8090
8129
|
}
|
|
8091
8130
|
routes2.push({ id: id || "/", urlPattern, methods: [...methods] });
|
|
8092
8131
|
}
|
|
8093
8132
|
for (const entry of entries) {
|
|
8094
|
-
if (entry.isDirectory()) routes2.push(...walk(root,
|
|
8133
|
+
if (entry.isDirectory()) routes2.push(...walk(root, path43.join(dir, entry.name)));
|
|
8095
8134
|
}
|
|
8096
8135
|
return routes2;
|
|
8097
8136
|
}
|
|
@@ -8141,13 +8180,13 @@ function printTable(routes2) {
|
|
|
8141
8180
|
}
|
|
8142
8181
|
|
|
8143
8182
|
// src/commands/i18n.ts
|
|
8144
|
-
import
|
|
8183
|
+
import process30 from "node:process";
|
|
8145
8184
|
import { Command as Command86 } from "commander";
|
|
8146
8185
|
import { x as x6 } from "tinyexec";
|
|
8147
8186
|
import { detect as detect9 } from "package-manager-detector";
|
|
8148
8187
|
import { resolveCommand as resolveCommand9 } from "package-manager-detector/commands";
|
|
8149
8188
|
async function runWuchale(extraArgs) {
|
|
8150
|
-
const cwd =
|
|
8189
|
+
const cwd = process30.cwd();
|
|
8151
8190
|
const pm = (await detect9({ cwd }))?.name ?? "npm";
|
|
8152
8191
|
const resolved = resolveCommand9(pm, "execute", ["wuchale", ...extraArgs]);
|
|
8153
8192
|
const args = resolved.args.slice();
|
|
@@ -8197,37 +8236,37 @@ var BACKEND_OPTIONAL_COMMANDS = /* @__PURE__ */ new Set(["dev", "build", "previe
|
|
|
8197
8236
|
var program = new Command87().name(package_default.name).description(package_default.description).version(package_default.version, "-v, --version").configureHelp(helpConfig);
|
|
8198
8237
|
program.hook("preAction", (_thisCommand, actionCommand) => {
|
|
8199
8238
|
if (isStub(actionCommand)) return;
|
|
8200
|
-
const envRoot = findWorkspaceRoot() ??
|
|
8239
|
+
const envRoot = findWorkspaceRoot() ?? process31.cwd();
|
|
8201
8240
|
dotenv2.config({ path: nodePath.join(envRoot, ".env"), quiet: true });
|
|
8202
|
-
const
|
|
8203
|
-
if (NO_BACKEND_COMMMANDS.has(
|
|
8204
|
-
const top =
|
|
8241
|
+
const path44 = getCommandPath(actionCommand);
|
|
8242
|
+
if (NO_BACKEND_COMMMANDS.has(path44)) return;
|
|
8243
|
+
const top = path44.split(" ", 1)[0];
|
|
8205
8244
|
if (NO_BACKEND_COMMMANDS.has(top)) return;
|
|
8206
8245
|
if (!hasBackend()) {
|
|
8207
8246
|
if (BACKEND_OPTIONAL_COMMANDS.has(top)) return;
|
|
8208
8247
|
p42.log.error(
|
|
8209
|
-
`${
|
|
8248
|
+
`${pc21.cyan(`vela ${path44}`)} needs a backend, and this project does not have one.
|
|
8210
8249
|
|
|
8211
8250
|
Static projects have no database to talk to.
|
|
8212
8251
|
|
|
8213
|
-
To add a backend to this project, run ${
|
|
8252
|
+
To add a backend to this project, run ${pc21.cyan("vela bless")}.`
|
|
8214
8253
|
);
|
|
8215
8254
|
p42.log.message();
|
|
8216
8255
|
p42.cancel("Operation failed.");
|
|
8217
|
-
|
|
8256
|
+
process31.exit(1);
|
|
8218
8257
|
}
|
|
8219
|
-
if (!
|
|
8258
|
+
if (!process31.env.POCKETBASE_SUPERUSER_EMAIL || !process31.env.POCKETBASE_SUPERUSER_PASSWORD) {
|
|
8220
8259
|
p42.log.error(
|
|
8221
8260
|
`PocketBase superuser credentials are required.
|
|
8222
8261
|
|
|
8223
|
-
Set ${
|
|
8262
|
+
Set ${pc21.cyan("POCKETBASE_SUPERUSER_EMAIL")} and ${pc21.cyan("POCKETBASE_SUPERUSER_PASSWORD")} in your .env file.
|
|
8224
8263
|
|
|
8225
|
-
To set up a new project, run ${
|
|
8226
|
-
To set up an existing project, run ${
|
|
8264
|
+
To set up a new project, run ${pc21.cyan("vela create")}.
|
|
8265
|
+
To set up an existing project, run ${pc21.cyan("vela bless")}.`
|
|
8227
8266
|
);
|
|
8228
8267
|
p42.log.message();
|
|
8229
8268
|
p42.cancel("Operation failed.");
|
|
8230
|
-
|
|
8269
|
+
process31.exit(1);
|
|
8231
8270
|
}
|
|
8232
8271
|
});
|
|
8233
8272
|
function getCommandPath(cmd) {
|
|
@@ -8278,14 +8317,14 @@ for (const command of [
|
|
|
8278
8317
|
}
|
|
8279
8318
|
|
|
8280
8319
|
// src/bin.ts
|
|
8281
|
-
var argv = normalizeArgv(
|
|
8320
|
+
var argv = normalizeArgv(process32.argv.slice(2));
|
|
8282
8321
|
var delegatedExitCode = delegateToLocalCli({
|
|
8283
8322
|
argv,
|
|
8284
8323
|
selfPath: fileURLToPath2(import.meta.url),
|
|
8285
8324
|
selfVersion: package_default.version
|
|
8286
8325
|
});
|
|
8287
8326
|
if (delegatedExitCode !== null) {
|
|
8288
|
-
|
|
8327
|
+
process32.exit(delegatedExitCode);
|
|
8289
8328
|
}
|
|
8290
8329
|
program.parse(argv, { from: "user" });
|
|
8291
8330
|
//# sourceMappingURL=bin.js.map
|