vela 0.10.4 → 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
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",
|
|
@@ -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";
|
|
@@ -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);
|
|
@@ -6748,17 +6748,43 @@ async function startWatchingTypes(cwd, pb) {
|
|
|
6748
6748
|
}
|
|
6749
6749
|
|
|
6750
6750
|
// src/commands/build.ts
|
|
6751
|
+
import fs31 from "node:fs";
|
|
6751
6752
|
import path34 from "node:path";
|
|
6752
|
-
import
|
|
6753
|
+
import process23 from "node:process";
|
|
6753
6754
|
import { Command as Command67 } from "commander";
|
|
6755
|
+
import * as p30 from "@clack/prompts";
|
|
6756
|
+
import pc9 from "picocolors";
|
|
6754
6757
|
import { x as x3 } from "tinyexec";
|
|
6755
6758
|
import { detect as detect5 } from "package-manager-detector";
|
|
6756
6759
|
import { resolveCommand as resolveCommand5 } from "package-manager-detector/commands";
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
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;
|
|
6760
6786
|
let pbProc;
|
|
6761
|
-
const needsStart = hasBackend(cwd) && !
|
|
6787
|
+
const needsStart = hasBackend(cwd) && !process23.env.POCKETBASE_URL;
|
|
6762
6788
|
const cleanup = () => {
|
|
6763
6789
|
if (pbProc?.pid) pbProc.kill();
|
|
6764
6790
|
};
|
|
@@ -6772,11 +6798,11 @@ var build = new Command67("build").description("build the app").configureHelp(he
|
|
|
6772
6798
|
dev: true
|
|
6773
6799
|
});
|
|
6774
6800
|
pbProc = started.proc;
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6801
|
+
process23.env.POCKETBASE_URL = started.url;
|
|
6802
|
+
process23.on("exit", cleanup);
|
|
6803
|
+
process23.on("SIGINT", () => {
|
|
6778
6804
|
cleanup();
|
|
6779
|
-
|
|
6805
|
+
process23.exit(0);
|
|
6780
6806
|
});
|
|
6781
6807
|
}
|
|
6782
6808
|
try {
|
|
@@ -6791,19 +6817,42 @@ var build = new Command67("build").description("build the app").configureHelp(he
|
|
|
6791
6817
|
} finally {
|
|
6792
6818
|
cleanup();
|
|
6793
6819
|
}
|
|
6820
|
+
if (!origin) warnIfPrerendered(cwd);
|
|
6794
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
|
+
}
|
|
6795
6844
|
|
|
6796
6845
|
// src/commands/preview.ts
|
|
6797
6846
|
import path35 from "node:path";
|
|
6798
|
-
import
|
|
6847
|
+
import process24 from "node:process";
|
|
6799
6848
|
import { Command as Command68 } from "commander";
|
|
6800
6849
|
import { x as x4 } from "tinyexec";
|
|
6801
6850
|
import { detect as detect6 } from "package-manager-detector";
|
|
6802
6851
|
import { resolveCommand as resolveCommand6 } from "package-manager-detector/commands";
|
|
6803
6852
|
var preview = new Command68("preview").description("preview the built app").configureHelp(helpConfig).action(async () => {
|
|
6804
|
-
const cwd =
|
|
6853
|
+
const cwd = process24.cwd();
|
|
6805
6854
|
let pbProc;
|
|
6806
|
-
const needsStart = hasBackend(cwd) && !
|
|
6855
|
+
const needsStart = hasBackend(cwd) && !process24.env.POCKETBASE_URL;
|
|
6807
6856
|
const cleanup = () => {
|
|
6808
6857
|
if (pbProc?.pid) pbProc.kill();
|
|
6809
6858
|
};
|
|
@@ -6816,11 +6865,11 @@ var preview = new Command68("preview").description("preview the built app").conf
|
|
|
6816
6865
|
dev: true
|
|
6817
6866
|
});
|
|
6818
6867
|
pbProc = started.proc;
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6868
|
+
process24.env.POCKETBASE_URL = started.url;
|
|
6869
|
+
process24.on("exit", cleanup);
|
|
6870
|
+
process24.on("SIGINT", () => {
|
|
6822
6871
|
cleanup();
|
|
6823
|
-
|
|
6872
|
+
process24.exit(0);
|
|
6824
6873
|
});
|
|
6825
6874
|
}
|
|
6826
6875
|
try {
|
|
@@ -6854,8 +6903,8 @@ var sync = new Command69("sync").description("sync types from the database").con
|
|
|
6854
6903
|
|
|
6855
6904
|
// src/commands/provision.ts
|
|
6856
6905
|
import { Command as Command70 } from "commander";
|
|
6857
|
-
import * as
|
|
6858
|
-
import
|
|
6906
|
+
import * as p31 from "@clack/prompts";
|
|
6907
|
+
import pc10 from "picocolors";
|
|
6859
6908
|
import * as v6 from "valibot";
|
|
6860
6909
|
var OptionsSchema2 = v6.object({
|
|
6861
6910
|
...SSH_OPTION_SCHEMA,
|
|
@@ -6868,19 +6917,19 @@ var provision = addSshOptions(
|
|
|
6868
6917
|
(target, raw) => runCommand(async () => {
|
|
6869
6918
|
const options = parseOptions(OptionsSchema2, raw);
|
|
6870
6919
|
const pbVersion = options.pbVersion ?? pocketbaseVersion();
|
|
6871
|
-
|
|
6872
|
-
|
|
6920
|
+
p31.intro(pc10.bgCyan(pc10.black(" vela provision ")));
|
|
6921
|
+
p31.log.info(`Target ${pc10.cyan(target)}`);
|
|
6873
6922
|
await withSsh(target, sshOptionsFrom(options), async (session) => {
|
|
6874
6923
|
await session.detectElevation();
|
|
6875
6924
|
const existing = await readServerInfo(session);
|
|
6876
6925
|
if (existing) {
|
|
6877
|
-
|
|
6926
|
+
p31.log.info(
|
|
6878
6927
|
`Already provisioned by vela ${existing.cliVersion} on ${existing.provisionedAt}. Bringing it up to date.`
|
|
6879
6928
|
);
|
|
6880
6929
|
}
|
|
6881
|
-
|
|
6930
|
+
p31.log.step("Uploading server scripts");
|
|
6882
6931
|
await syncServerScripts(session);
|
|
6883
|
-
|
|
6932
|
+
p31.log.step("Running provision");
|
|
6884
6933
|
const result = await runServerScript(session, "provision.sh", {
|
|
6885
6934
|
args: [
|
|
6886
6935
|
"--pb-version",
|
|
@@ -6892,7 +6941,7 @@ var provision = addSshOptions(
|
|
|
6892
6941
|
],
|
|
6893
6942
|
stream: true
|
|
6894
6943
|
});
|
|
6895
|
-
|
|
6944
|
+
p31.log.success(
|
|
6896
6945
|
`${target} is ready.
|
|
6897
6946
|
|
|
6898
6947
|
Node ${result?.node ?? "installed"}
|
|
@@ -6900,22 +6949,22 @@ var provision = addSshOptions(
|
|
|
6900
6949
|
PocketBase ${result?.pocketbase ?? pbVersion}`
|
|
6901
6950
|
);
|
|
6902
6951
|
});
|
|
6903
|
-
|
|
6952
|
+
p31.outro(`Deploy with ${pc10.cyan(`vela deploy --server ${target}`)}`);
|
|
6904
6953
|
}, "Failed to provision.")
|
|
6905
6954
|
);
|
|
6906
6955
|
|
|
6907
6956
|
// src/commands/deploy.ts
|
|
6908
6957
|
import path39 from "node:path";
|
|
6909
|
-
import
|
|
6910
|
-
import { Command as Command71 } from "commander";
|
|
6911
|
-
import * as
|
|
6912
|
-
import
|
|
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";
|
|
6913
6962
|
import * as v7 from "valibot";
|
|
6914
6963
|
|
|
6915
6964
|
// src/lib/pocketbase-settings.ts
|
|
6916
|
-
import
|
|
6965
|
+
import fs32 from "node:fs";
|
|
6917
6966
|
import path37 from "node:path";
|
|
6918
|
-
import
|
|
6967
|
+
import process25 from "node:process";
|
|
6919
6968
|
import PocketBase4 from "pocketbase";
|
|
6920
6969
|
|
|
6921
6970
|
// src/lib/remote-pocketbase.ts
|
|
@@ -6964,9 +7013,9 @@ async function withRemotePocketbase(session, instance, fn) {
|
|
|
6964
7013
|
var COPIED_KEYS = ["appName", "senderName", "senderAddress"];
|
|
6965
7014
|
async function readLocalMeta(cwd) {
|
|
6966
7015
|
const dataDir = path37.join(cwd, DATA_DIR);
|
|
6967
|
-
if (!
|
|
6968
|
-
const email3 =
|
|
6969
|
-
const password10 =
|
|
7016
|
+
if (!fs32.existsSync(dataDir)) return null;
|
|
7017
|
+
const email3 = process25.env.POCKETBASE_SUPERUSER_EMAIL;
|
|
7018
|
+
const password10 = process25.env.POCKETBASE_SUPERUSER_PASSWORD;
|
|
6970
7019
|
if (!email3 || !password10) return null;
|
|
6971
7020
|
let proc;
|
|
6972
7021
|
try {
|
|
@@ -6986,6 +7035,19 @@ async function readLocalMeta(cwd) {
|
|
|
6986
7035
|
proc?.kill();
|
|
6987
7036
|
}
|
|
6988
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
|
+
}
|
|
6989
7051
|
async function seedRemoteMeta(session, instance, local, appURL) {
|
|
6990
7052
|
const patch = {};
|
|
6991
7053
|
for (const key of COPIED_KEYS) {
|
|
@@ -7002,7 +7064,7 @@ async function seedRemoteMeta(session, instance, local, appURL) {
|
|
|
7002
7064
|
}
|
|
7003
7065
|
|
|
7004
7066
|
// src/lib/artifact.ts
|
|
7005
|
-
import
|
|
7067
|
+
import fs33 from "node:fs";
|
|
7006
7068
|
import path38 from "node:path";
|
|
7007
7069
|
import { detect as detect7 } from "package-manager-detector";
|
|
7008
7070
|
import { resolveCommand as resolveCommand7 } from "package-manager-detector/commands";
|
|
@@ -7041,10 +7103,10 @@ function collectArtifact(cwd, config = {}) {
|
|
|
7041
7103
|
const entries = [];
|
|
7042
7104
|
const add2 = (rel, remoteDir = "") => {
|
|
7043
7105
|
const localPath = path38.join(cwd, rel);
|
|
7044
|
-
if (
|
|
7106
|
+
if (fs33.existsSync(localPath)) entries.push({ localPath, remoteDir });
|
|
7045
7107
|
};
|
|
7046
7108
|
const buildPath = path38.join(cwd, outputDir);
|
|
7047
|
-
if (!
|
|
7109
|
+
if (!fs33.existsSync(path38.join(buildPath, "index.js"))) {
|
|
7048
7110
|
throw new BuildError(
|
|
7049
7111
|
`No ${outputDir}/index.js after the build.
|
|
7050
7112
|
|
|
@@ -7058,7 +7120,7 @@ the adapter in your Vite or Svelte config, then build again.`
|
|
|
7058
7120
|
add2(".npmrc");
|
|
7059
7121
|
add2(MIGRATIONS_DIR);
|
|
7060
7122
|
const hooks = path38.join(cwd, DATA_DIR, "hooks");
|
|
7061
|
-
if (
|
|
7123
|
+
if (fs33.existsSync(hooks)) entries.push({ localPath: hooks, remoteDir: "hooks" });
|
|
7062
7124
|
for (const extra of config.include ?? []) add2(extra);
|
|
7063
7125
|
return entries;
|
|
7064
7126
|
}
|
|
@@ -7082,39 +7144,57 @@ var OptionsSchema3 = v7.object({
|
|
|
7082
7144
|
var deploy = addTargetOptions(
|
|
7083
7145
|
new Command71("deploy").description("deploy the app").configureHelp(helpConfig),
|
|
7084
7146
|
"production"
|
|
7085
|
-
).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").
|
|
7086
|
-
|
|
7087
|
-
|
|
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
|
+
)
|
|
7088
7156
|
).action(
|
|
7089
7157
|
(raw) => runCommand(async () => {
|
|
7090
7158
|
const options = parseOptions(OptionsSchema3, raw);
|
|
7091
7159
|
const backend3 = hasBackend();
|
|
7092
7160
|
const release = releaseId();
|
|
7093
|
-
|
|
7161
|
+
p32.intro(pc11.bgCyan(pc11.black(" vela deploy ")));
|
|
7094
7162
|
await withTarget(
|
|
7095
7163
|
raw,
|
|
7096
7164
|
{
|
|
7097
7165
|
remote: async (ctx) => {
|
|
7098
7166
|
const { session, instance, workspaceRootDir, config } = ctx;
|
|
7099
|
-
|
|
7100
|
-
`${
|
|
7167
|
+
p32.log.info(
|
|
7168
|
+
`${pc11.cyan(ctx.appName)} ${pc11.dim("\u2192")} ${pc11.cyan(ctx.targetName)} ${pc11.dim(`(${ctx.server})`)}`
|
|
7101
7169
|
);
|
|
7102
7170
|
const [existing] = await readInstanceStates(session, instance);
|
|
7103
7171
|
const domain = options.domain ?? ctx.binding.domain ?? config.deploy?.domain ?? existing?.domain ?? "";
|
|
7104
|
-
const
|
|
7172
|
+
const askedForRemoteDb = options.remoteDb ?? config.deploy?.buildAgainstRemote;
|
|
7173
|
+
const remoteDb = askedForRemoteDb ?? Boolean(existing?.pbPort);
|
|
7105
7174
|
if (options.build !== false) {
|
|
7106
|
-
|
|
7175
|
+
const origin = normalizeOrigin(process.env.VELA_ORIGIN ?? domain);
|
|
7176
|
+
let buildEnv = origin ? { VELA_ORIGIN: origin } : {};
|
|
7107
7177
|
let tunnel = null;
|
|
7108
7178
|
if (backend3 && remoteDb) {
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
|
|
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})`)}`
|
|
7113
7193
|
);
|
|
7114
7194
|
} else if (backend3) {
|
|
7115
7195
|
await ensureSuperuser(workspaceRootDir);
|
|
7116
7196
|
}
|
|
7117
|
-
|
|
7197
|
+
p32.log.step("Building");
|
|
7118
7198
|
try {
|
|
7119
7199
|
await runBuild(workspaceRootDir, config.deploy?.buildCommand, buildEnv);
|
|
7120
7200
|
} finally {
|
|
@@ -7123,9 +7203,9 @@ var deploy = addTargetOptions(
|
|
|
7123
7203
|
}
|
|
7124
7204
|
const entries = collectArtifact(workspaceRootDir, config.deploy ?? {});
|
|
7125
7205
|
const sha = await gitSha(workspaceRootDir);
|
|
7126
|
-
|
|
7206
|
+
p32.log.step(`Uploading release ${pc11.dim(release)}`);
|
|
7127
7207
|
await uploadRelease(session, instance, release, entries);
|
|
7128
|
-
|
|
7208
|
+
p32.log.step("Activating");
|
|
7129
7209
|
const result = await runServerScript(session, "apply.sh", {
|
|
7130
7210
|
args: [
|
|
7131
7211
|
instance,
|
|
@@ -7157,8 +7237,8 @@ var deploy = addTargetOptions(
|
|
|
7157
7237
|
});
|
|
7158
7238
|
if (!existing) await reportEmptyEnvironment(session, instance, workspaceRootDir);
|
|
7159
7239
|
const url = result?.url ?? "";
|
|
7160
|
-
|
|
7161
|
-
`Deployed ${
|
|
7240
|
+
p32.log.success(
|
|
7241
|
+
`Deployed ${pc11.cyan(ctx.appName)} ${pc11.dim(release)}
|
|
7162
7242
|
|
|
7163
7243
|
URL ${url}
|
|
7164
7244
|
Port ${result?.webPort ?? "?"}${backend3 ? ` (PocketBase ${result?.pbPort ?? "?"})` : ""}`
|
|
@@ -7170,27 +7250,41 @@ var deploy = addTargetOptions(
|
|
|
7170
7250
|
workspaceRootDir,
|
|
7171
7251
|
domain ? result?.url ?? "" : ""
|
|
7172
7252
|
);
|
|
7173
|
-
|
|
7253
|
+
p32.log.info(
|
|
7174
7254
|
`Created the PocketBase superuser this app authenticates as.
|
|
7175
7255
|
|
|
7176
7256
|
Its credentials are stored in the environment on the server. To use
|
|
7177
|
-
your own instead, ${
|
|
7257
|
+
your own instead, ${pc11.cyan("vela env set POCKETBASE_SUPERUSER_PASSWORD")}
|
|
7178
7258
|
and deploy again.`
|
|
7179
7259
|
);
|
|
7260
|
+
} else if (backend3 && domain) {
|
|
7261
|
+
await reportAppURLDrift(session, instance, domain);
|
|
7180
7262
|
}
|
|
7181
7263
|
if (!domain) {
|
|
7182
|
-
|
|
7264
|
+
p32.log.warn(
|
|
7183
7265
|
`No domain configured, so nothing is proxied to this app yet.
|
|
7184
|
-
Redeploy with ${
|
|
7266
|
+
Redeploy with ${pc11.cyan("--domain example.com")} once DNS points at ${ctx.server}.`
|
|
7185
7267
|
);
|
|
7186
7268
|
}
|
|
7187
7269
|
}
|
|
7188
7270
|
},
|
|
7189
7271
|
{ project: options.project, askDomain: true, label: "deploy" }
|
|
7190
7272
|
);
|
|
7191
|
-
|
|
7273
|
+
p32.outro(`${pc11.cyan("vela status")} to see what is running`);
|
|
7192
7274
|
}, "Failed to deploy.")
|
|
7193
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
|
+
}
|
|
7194
7288
|
async function copyLocalBranding(session, instance, workspaceRootDir, appURL) {
|
|
7195
7289
|
const local = await readLocalMeta(workspaceRootDir);
|
|
7196
7290
|
if (!local) return;
|
|
@@ -7199,17 +7293,17 @@ async function copyLocalBranding(session, instance, workspaceRootDir, appURL) {
|
|
|
7199
7293
|
if (copied.length === 0) return;
|
|
7200
7294
|
const outcome = await restartInstance(session, instance);
|
|
7201
7295
|
if (outcome.deployed && !outcome.restarted) {
|
|
7202
|
-
|
|
7296
|
+
p32.log.warn(
|
|
7203
7297
|
`Copied ${copied.join(", ")}, but the app did not restart to pick them up.
|
|
7204
|
-
${
|
|
7298
|
+
${pc11.dim(outcome.error ?? "")}`
|
|
7205
7299
|
);
|
|
7206
7300
|
return;
|
|
7207
7301
|
}
|
|
7208
|
-
|
|
7302
|
+
p32.log.success(`Copied ${copied.join(", ")} from this project's database`);
|
|
7209
7303
|
} catch (err) {
|
|
7210
|
-
|
|
7304
|
+
p32.log.warn(
|
|
7211
7305
|
`Could not copy this project's PocketBase settings across.
|
|
7212
|
-
Set them in the admin panel instead. ${
|
|
7306
|
+
Set them in the admin panel instead. ${pc11.dim(String(err))}`
|
|
7213
7307
|
);
|
|
7214
7308
|
}
|
|
7215
7309
|
}
|
|
@@ -7260,7 +7354,7 @@ async function uploadRelease(session, instance, release, entries) {
|
|
|
7260
7354
|
}
|
|
7261
7355
|
function isDirectory(target) {
|
|
7262
7356
|
try {
|
|
7263
|
-
return
|
|
7357
|
+
return fs34.statSync(target).isDirectory();
|
|
7264
7358
|
} catch {
|
|
7265
7359
|
return false;
|
|
7266
7360
|
}
|
|
@@ -7268,20 +7362,20 @@ function isDirectory(target) {
|
|
|
7268
7362
|
async function reportEmptyEnvironment(session, instance, workspaceRootDir) {
|
|
7269
7363
|
const remote = await readRemoteEnv(session, instance);
|
|
7270
7364
|
if (Object.keys(remote).length > 0) return;
|
|
7271
|
-
if (!
|
|
7272
|
-
|
|
7365
|
+
if (!fs34.existsSync(path39.join(workspaceRootDir, ".env"))) return;
|
|
7366
|
+
p32.log.warn(
|
|
7273
7367
|
`This app has no production environment variables yet.
|
|
7274
7368
|
|
|
7275
|
-
Local ${
|
|
7276
|
-
${
|
|
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")}.`
|
|
7277
7371
|
);
|
|
7278
7372
|
}
|
|
7279
7373
|
|
|
7280
7374
|
// src/commands/link.ts
|
|
7281
7375
|
import path40 from "node:path";
|
|
7282
|
-
import
|
|
7376
|
+
import process26 from "node:process";
|
|
7283
7377
|
import { Command as Command72 } from "commander";
|
|
7284
|
-
import * as
|
|
7378
|
+
import * as p33 from "@clack/prompts";
|
|
7285
7379
|
|
|
7286
7380
|
// src/lib/velastack-api.ts
|
|
7287
7381
|
async function apiFetch(apiKey, pathAndQuery, init) {
|
|
@@ -7337,7 +7431,7 @@ async function linkProject() {
|
|
|
7337
7431
|
const { workspaceRootDir } = await getWorkspace();
|
|
7338
7432
|
const existing = readProjectConfig(workspaceRootDir);
|
|
7339
7433
|
if (existing) {
|
|
7340
|
-
|
|
7434
|
+
p33.log.success(`Linked to ${existing.projectName}.`);
|
|
7341
7435
|
return;
|
|
7342
7436
|
}
|
|
7343
7437
|
const apiKey = requireApiKey();
|
|
@@ -7364,10 +7458,10 @@ async function linkProject() {
|
|
|
7364
7458
|
projectName = created.name;
|
|
7365
7459
|
}
|
|
7366
7460
|
writeProjectConfig(workspaceRootDir, { projectId, teamId, projectName });
|
|
7367
|
-
|
|
7461
|
+
p33.log.success(`Linked to ${projectName}.`);
|
|
7368
7462
|
}
|
|
7369
7463
|
async function pickExistingProject(projects) {
|
|
7370
|
-
const choice = await
|
|
7464
|
+
const choice = await p33.select({
|
|
7371
7465
|
message: "Select a project",
|
|
7372
7466
|
options: [
|
|
7373
7467
|
...projects.map((pr) => ({
|
|
@@ -7377,39 +7471,39 @@ async function pickExistingProject(projects) {
|
|
|
7377
7471
|
{ value: CREATE_NEW, label: "Create a new project" }
|
|
7378
7472
|
]
|
|
7379
7473
|
});
|
|
7380
|
-
if (
|
|
7381
|
-
|
|
7382
|
-
|
|
7474
|
+
if (p33.isCancel(choice)) {
|
|
7475
|
+
p33.cancel("Operation cancelled.");
|
|
7476
|
+
process26.exit(0);
|
|
7383
7477
|
}
|
|
7384
7478
|
return choice;
|
|
7385
7479
|
}
|
|
7386
7480
|
async function pickTeam(teams3) {
|
|
7387
7481
|
if (teams3.length === 1) return teams3[0];
|
|
7388
|
-
const choice = await
|
|
7482
|
+
const choice = await p33.select({
|
|
7389
7483
|
message: "Select a team",
|
|
7390
7484
|
options: teams3.map((team) => ({
|
|
7391
7485
|
value: team.id,
|
|
7392
7486
|
label: team.is_personal ? `${team.name} (personal)` : team.name
|
|
7393
7487
|
}))
|
|
7394
7488
|
});
|
|
7395
|
-
if (
|
|
7396
|
-
|
|
7397
|
-
|
|
7489
|
+
if (p33.isCancel(choice)) {
|
|
7490
|
+
p33.cancel("Operation cancelled.");
|
|
7491
|
+
process26.exit(0);
|
|
7398
7492
|
}
|
|
7399
7493
|
return teams3.find((team) => team.id === choice);
|
|
7400
7494
|
}
|
|
7401
7495
|
async function promptProjectName(workspaceRootDir) {
|
|
7402
7496
|
const defaultValue = defaultProjectName2(workspaceRootDir);
|
|
7403
|
-
const value = await
|
|
7497
|
+
const value = await p33.text({
|
|
7404
7498
|
message: "Project name",
|
|
7405
7499
|
defaultValue,
|
|
7406
7500
|
initialValue: defaultValue,
|
|
7407
7501
|
placeholder: defaultValue,
|
|
7408
7502
|
validate: (v9) => !v9?.trim() ? "Required" : void 0
|
|
7409
7503
|
});
|
|
7410
|
-
if (
|
|
7411
|
-
|
|
7412
|
-
|
|
7504
|
+
if (p33.isCancel(value)) {
|
|
7505
|
+
p33.cancel("Operation cancelled.");
|
|
7506
|
+
process26.exit(0);
|
|
7413
7507
|
}
|
|
7414
7508
|
return value.trim();
|
|
7415
7509
|
}
|
|
@@ -7428,21 +7522,21 @@ import { Command as Command77 } from "commander";
|
|
|
7428
7522
|
|
|
7429
7523
|
// src/commands/env/list.ts
|
|
7430
7524
|
import { Command as Command73 } from "commander";
|
|
7431
|
-
import * as
|
|
7432
|
-
import
|
|
7525
|
+
import * as p35 from "@clack/prompts";
|
|
7526
|
+
import pc13 from "picocolors";
|
|
7433
7527
|
|
|
7434
7528
|
// src/lib/local-env.ts
|
|
7435
|
-
import
|
|
7436
|
-
import * as
|
|
7437
|
-
import
|
|
7529
|
+
import fs35 from "node:fs";
|
|
7530
|
+
import * as p34 from "@clack/prompts";
|
|
7531
|
+
import pc12 from "picocolors";
|
|
7438
7532
|
function readLocalEnv(envFile) {
|
|
7439
|
-
if (!
|
|
7533
|
+
if (!fs35.existsSync(envFile)) return {};
|
|
7440
7534
|
return readLocalEnvFile(envFile);
|
|
7441
7535
|
}
|
|
7442
7536
|
function editLocalEnv(envFile, edit) {
|
|
7443
|
-
const before =
|
|
7537
|
+
const before = fs35.existsSync(envFile) ? fs35.readFileSync(envFile, "utf8") : "";
|
|
7444
7538
|
const after = edit(before);
|
|
7445
|
-
if (after !== before)
|
|
7539
|
+
if (after !== before) fs35.writeFileSync(envFile, after);
|
|
7446
7540
|
}
|
|
7447
7541
|
function setLocalEnv(envFile, key, value) {
|
|
7448
7542
|
editLocalEnv(envFile, (content) => upsertEnvVar(content, key, value));
|
|
@@ -7459,16 +7553,16 @@ async function applyLocalEnvChange(ctx, changed) {
|
|
|
7459
7553
|
process.env.POCKETBASE_SUPERUSER_EMAIL = email3;
|
|
7460
7554
|
process.env.POCKETBASE_SUPERUSER_PASSWORD = password10;
|
|
7461
7555
|
await ensureSuperuser(ctx.workspaceRootDir);
|
|
7462
|
-
|
|
7556
|
+
p34.log.success("Local superuser updated to match");
|
|
7463
7557
|
} else {
|
|
7464
|
-
|
|
7558
|
+
p34.log.warn(
|
|
7465
7559
|
`The local database still has the old superuser.
|
|
7466
|
-
Set both ${
|
|
7560
|
+
Set both ${pc12.cyan("POCKETBASE_SUPERUSER_EMAIL")} and ${pc12.cyan("POCKETBASE_SUPERUSER_PASSWORD")} to reconcile it.`
|
|
7467
7561
|
);
|
|
7468
7562
|
}
|
|
7469
7563
|
}
|
|
7470
7564
|
if (getPocketbaseMetadata(ctx.workspaceRootDir)) {
|
|
7471
|
-
|
|
7565
|
+
p34.log.info(`Restart ${pc12.cyan("vela dev")} to pick this up.`);
|
|
7472
7566
|
}
|
|
7473
7567
|
}
|
|
7474
7568
|
|
|
@@ -7496,21 +7590,21 @@ var envList = addTargetOptions(
|
|
|
7496
7590
|
);
|
|
7497
7591
|
function report(keys, where) {
|
|
7498
7592
|
if (keys.length === 0) {
|
|
7499
|
-
|
|
7593
|
+
p35.log.info(`No environment variables configured ${pc13.dim(`(${where})`)}.`);
|
|
7500
7594
|
return;
|
|
7501
7595
|
}
|
|
7502
|
-
|
|
7503
|
-
`Environment ${
|
|
7596
|
+
p35.log.info(
|
|
7597
|
+
`Environment ${pc13.dim(`(${where})`)}
|
|
7504
7598
|
|
|
7505
7599
|
` + keys.sort().map((key) => ` ${key}`).join("\n")
|
|
7506
7600
|
);
|
|
7507
7601
|
}
|
|
7508
7602
|
|
|
7509
7603
|
// src/commands/env/set.ts
|
|
7510
|
-
import
|
|
7604
|
+
import process27 from "node:process";
|
|
7511
7605
|
import { Command as Command74 } from "commander";
|
|
7512
|
-
import * as
|
|
7513
|
-
import
|
|
7606
|
+
import * as p36 from "@clack/prompts";
|
|
7607
|
+
import pc14 from "picocolors";
|
|
7514
7608
|
var envSet = addTargetOptions(
|
|
7515
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),
|
|
7516
7610
|
"local"
|
|
@@ -7522,14 +7616,14 @@ var envSet = addTargetOptions(
|
|
|
7522
7616
|
local: async (ctx) => {
|
|
7523
7617
|
const resolved = await resolveValue(key, value);
|
|
7524
7618
|
setLocalEnv(ctx.envFile, key, resolved);
|
|
7525
|
-
|
|
7619
|
+
p36.log.success(`${key} updated ${pc14.dim("(local)")}`);
|
|
7526
7620
|
await applyLocalEnvChange(ctx, [key]);
|
|
7527
7621
|
},
|
|
7528
7622
|
remote: async (ctx) => {
|
|
7529
7623
|
const resolved = await resolveValue(key, value);
|
|
7530
7624
|
const env2 = await readRemoteEnv(ctx.session, ctx.instance);
|
|
7531
7625
|
await writeRemoteEnv(ctx.session, ctx.instance, { ...env2, [key]: resolved });
|
|
7532
|
-
|
|
7626
|
+
p36.log.success(`${key} updated ${pc14.dim(`(${ctx.targetName})`)}`);
|
|
7533
7627
|
await applyEnvRestart(ctx, [key]);
|
|
7534
7628
|
}
|
|
7535
7629
|
},
|
|
@@ -7543,21 +7637,21 @@ async function resolveValue(key, value) {
|
|
|
7543
7637
|
return value ?? await promptValue(key);
|
|
7544
7638
|
}
|
|
7545
7639
|
async function promptValue(key) {
|
|
7546
|
-
const value = await
|
|
7547
|
-
message: `Value for ${
|
|
7640
|
+
const value = await p36.password({
|
|
7641
|
+
message: `Value for ${pc14.cyan(key)}`,
|
|
7548
7642
|
validate: (input) => !input?.length ? "Required" : void 0
|
|
7549
7643
|
});
|
|
7550
|
-
if (
|
|
7551
|
-
|
|
7552
|
-
|
|
7644
|
+
if (p36.isCancel(value)) {
|
|
7645
|
+
p36.cancel("Operation cancelled.");
|
|
7646
|
+
process27.exit(0);
|
|
7553
7647
|
}
|
|
7554
7648
|
return value;
|
|
7555
7649
|
}
|
|
7556
7650
|
|
|
7557
7651
|
// src/commands/env/unset.ts
|
|
7558
7652
|
import { Command as Command75 } from "commander";
|
|
7559
|
-
import * as
|
|
7560
|
-
import
|
|
7653
|
+
import * as p37 from "@clack/prompts";
|
|
7654
|
+
import pc15 from "picocolors";
|
|
7561
7655
|
var envUnset = addTargetOptions(
|
|
7562
7656
|
new Command75("unset").description("remove an environment variable").argument("<key>", "variable name").configureHelp(helpConfig),
|
|
7563
7657
|
"local"
|
|
@@ -7568,22 +7662,22 @@ var envUnset = addTargetOptions(
|
|
|
7568
7662
|
{
|
|
7569
7663
|
local: async (ctx) => {
|
|
7570
7664
|
if (!(key in readLocalEnv(ctx.envFile))) {
|
|
7571
|
-
|
|
7665
|
+
p37.log.info(`${key} is not set \u2014 nothing to remove.`);
|
|
7572
7666
|
return;
|
|
7573
7667
|
}
|
|
7574
7668
|
unsetLocalEnv(ctx.envFile, key);
|
|
7575
|
-
|
|
7669
|
+
p37.log.success(`${key} removed ${pc15.dim("(local)")}`);
|
|
7576
7670
|
await applyLocalEnvChange(ctx, [key]);
|
|
7577
7671
|
},
|
|
7578
7672
|
remote: async (ctx) => {
|
|
7579
7673
|
const env2 = await readRemoteEnv(ctx.session, ctx.instance);
|
|
7580
7674
|
if (!(key in env2)) {
|
|
7581
|
-
|
|
7675
|
+
p37.log.info(`${key} is not set \u2014 nothing to remove.`);
|
|
7582
7676
|
return;
|
|
7583
7677
|
}
|
|
7584
7678
|
delete env2[key];
|
|
7585
7679
|
await writeRemoteEnv(ctx.session, ctx.instance, env2);
|
|
7586
|
-
|
|
7680
|
+
p37.log.success(`${key} removed ${pc15.dim(`(${ctx.targetName})`)}`);
|
|
7587
7681
|
await applyEnvRestart(ctx, [key]);
|
|
7588
7682
|
}
|
|
7589
7683
|
},
|
|
@@ -7594,12 +7688,12 @@ var envUnset = addTargetOptions(
|
|
|
7594
7688
|
);
|
|
7595
7689
|
|
|
7596
7690
|
// src/commands/env/import.ts
|
|
7597
|
-
import
|
|
7691
|
+
import fs36 from "node:fs";
|
|
7598
7692
|
import path41 from "node:path";
|
|
7599
|
-
import
|
|
7693
|
+
import process28 from "node:process";
|
|
7600
7694
|
import { Command as Command76 } from "commander";
|
|
7601
|
-
import * as
|
|
7602
|
-
import
|
|
7695
|
+
import * as p38 from "@clack/prompts";
|
|
7696
|
+
import pc16 from "picocolors";
|
|
7603
7697
|
var envImport = addTargetOptions(
|
|
7604
7698
|
new Command76("import").description("merge a dotenv file into the environment").argument("<file>", "dotenv file to read").configureHelp(helpConfig),
|
|
7605
7699
|
"local"
|
|
@@ -7616,22 +7710,22 @@ var envImport = addTargetOptions(
|
|
|
7616
7710
|
const incoming = read(source, file);
|
|
7617
7711
|
const keys = Object.keys(incoming);
|
|
7618
7712
|
if (keys.length === 0) return;
|
|
7619
|
-
|
|
7713
|
+
p38.log.step(`Importing ${keys.length} variable(s) from ${pc16.cyan(file)}`);
|
|
7620
7714
|
editLocalEnv(
|
|
7621
7715
|
ctx.envFile,
|
|
7622
7716
|
(content) => keys.reduce((acc, key) => upsertEnvVar(acc, key, incoming[key]), content)
|
|
7623
7717
|
);
|
|
7624
|
-
|
|
7718
|
+
p38.log.success(`${keys.length} variable(s) updated ${pc16.dim("(local)")}`);
|
|
7625
7719
|
await applyLocalEnvChange(ctx, keys);
|
|
7626
7720
|
},
|
|
7627
7721
|
remote: async (ctx) => {
|
|
7628
7722
|
const incoming = read(resolve(file), file);
|
|
7629
7723
|
const keys = Object.keys(incoming);
|
|
7630
7724
|
if (keys.length === 0) return;
|
|
7631
|
-
|
|
7725
|
+
p38.log.step(`Importing ${keys.length} variable(s) from ${pc16.cyan(file)}`);
|
|
7632
7726
|
const existing = await readRemoteEnv(ctx.session, ctx.instance);
|
|
7633
7727
|
await writeRemoteEnv(ctx.session, ctx.instance, { ...existing, ...incoming });
|
|
7634
|
-
|
|
7728
|
+
p38.log.success(`${keys.length} variable(s) updated ${pc16.dim(`(${ctx.targetName})`)}`);
|
|
7635
7729
|
await applyEnvRestart(ctx, keys);
|
|
7636
7730
|
}
|
|
7637
7731
|
},
|
|
@@ -7641,12 +7735,12 @@ var envImport = addTargetOptions(
|
|
|
7641
7735
|
)
|
|
7642
7736
|
);
|
|
7643
7737
|
function resolve(file) {
|
|
7644
|
-
return path41.resolve(
|
|
7738
|
+
return path41.resolve(process28.cwd(), file);
|
|
7645
7739
|
}
|
|
7646
7740
|
function read(resolved, shown) {
|
|
7647
|
-
if (!
|
|
7741
|
+
if (!fs36.existsSync(resolved)) throw new Error(`${shown} does not exist.`);
|
|
7648
7742
|
const incoming = readLocalEnvFile(resolved);
|
|
7649
|
-
if (Object.keys(incoming).length === 0)
|
|
7743
|
+
if (Object.keys(incoming).length === 0) p38.log.info(`${shown} has no variables to import.`);
|
|
7650
7744
|
return incoming;
|
|
7651
7745
|
}
|
|
7652
7746
|
|
|
@@ -7655,8 +7749,8 @@ var env = new Command77("env").description("manage environment variables, locall
|
|
|
7655
7749
|
|
|
7656
7750
|
// src/commands/status.ts
|
|
7657
7751
|
import { Command as Command78 } from "commander";
|
|
7658
|
-
import * as
|
|
7659
|
-
import
|
|
7752
|
+
import * as p39 from "@clack/prompts";
|
|
7753
|
+
import pc17 from "picocolors";
|
|
7660
7754
|
var status = addTargetOptions(
|
|
7661
7755
|
new Command78("status").description("show what is deployed").configureHelp(helpConfig),
|
|
7662
7756
|
"production"
|
|
@@ -7689,15 +7783,15 @@ function report2(states, json) {
|
|
|
7689
7783
|
return;
|
|
7690
7784
|
}
|
|
7691
7785
|
if (states.length === 0) {
|
|
7692
|
-
|
|
7786
|
+
p39.log.info("Nothing is deployed here yet.");
|
|
7693
7787
|
return;
|
|
7694
7788
|
}
|
|
7695
7789
|
for (const state of states) {
|
|
7696
|
-
|
|
7790
|
+
p39.log.info(describe(state));
|
|
7697
7791
|
}
|
|
7698
7792
|
}
|
|
7699
7793
|
function describe(state) {
|
|
7700
|
-
const health = (value) => value === "active" ?
|
|
7794
|
+
const health = (value) => value === "active" ? pc17.green(value) : pc17.red(value || "inactive");
|
|
7701
7795
|
const rows = [
|
|
7702
7796
|
["Instance", state.instance],
|
|
7703
7797
|
["Environment", state.env],
|
|
@@ -7712,13 +7806,13 @@ function describe(state) {
|
|
|
7712
7806
|
...state.gitSha ? [["Commit", state.gitSha.slice(0, 12)]] : []
|
|
7713
7807
|
];
|
|
7714
7808
|
const width = Math.max(...rows.map(([label]) => label.length));
|
|
7715
|
-
return
|
|
7809
|
+
return pc17.cyan(state.name) + "\n\n" + rows.map(([label, value]) => ` ${label.padEnd(width)} ${value}`).join("\n");
|
|
7716
7810
|
}
|
|
7717
7811
|
|
|
7718
7812
|
// src/commands/rollback.ts
|
|
7719
7813
|
import { Command as Command79 } from "commander";
|
|
7720
|
-
import * as
|
|
7721
|
-
import
|
|
7814
|
+
import * as p40 from "@clack/prompts";
|
|
7815
|
+
import pc18 from "picocolors";
|
|
7722
7816
|
var rollback = addTargetOptions(
|
|
7723
7817
|
new Command79("rollback").description("put the previous release back").configureHelp(helpConfig),
|
|
7724
7818
|
"production"
|
|
@@ -7729,8 +7823,8 @@ var rollback = addTargetOptions(
|
|
|
7729
7823
|
raw,
|
|
7730
7824
|
{
|
|
7731
7825
|
remote: async (ctx) => {
|
|
7732
|
-
|
|
7733
|
-
`Rolling back ${
|
|
7826
|
+
p40.log.step(
|
|
7827
|
+
`Rolling back ${pc18.cyan(ctx.appName)} ${pc18.dim(`(${ctx.targetName})`)} on ${ctx.server}`
|
|
7734
7828
|
);
|
|
7735
7829
|
const result = await runServerScript(
|
|
7736
7830
|
ctx.session,
|
|
@@ -7740,8 +7834,8 @@ var rollback = addTargetOptions(
|
|
|
7740
7834
|
stream: true
|
|
7741
7835
|
}
|
|
7742
7836
|
);
|
|
7743
|
-
|
|
7744
|
-
`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})`)}` : "")
|
|
7745
7839
|
);
|
|
7746
7840
|
}
|
|
7747
7841
|
},
|
|
@@ -7793,10 +7887,10 @@ var logs = addTargetOptions(
|
|
|
7793
7887
|
import { Command as Command82 } from "commander";
|
|
7794
7888
|
|
|
7795
7889
|
// src/commands/admin/create.ts
|
|
7796
|
-
import
|
|
7890
|
+
import process29 from "node:process";
|
|
7797
7891
|
import { Command as Command81 } from "commander";
|
|
7798
|
-
import * as
|
|
7799
|
-
import
|
|
7892
|
+
import * as p41 from "@clack/prompts";
|
|
7893
|
+
import pc19 from "picocolors";
|
|
7800
7894
|
var MIN_PASSWORD = 10;
|
|
7801
7895
|
var adminCreate = addTargetOptions(
|
|
7802
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),
|
|
@@ -7827,8 +7921,8 @@ var adminCreate = addTargetOptions(
|
|
|
7827
7921
|
const metadata = getPocketbaseMetadata(ctx.workspaceRootDir);
|
|
7828
7922
|
if (metadata) signIn = `http://${metadata.viteHost}:${metadata.vitePort}`;
|
|
7829
7923
|
}
|
|
7830
|
-
|
|
7831
|
-
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.`
|
|
7832
7926
|
);
|
|
7833
7927
|
},
|
|
7834
7928
|
remote: async (ctx) => {
|
|
@@ -7841,8 +7935,8 @@ var adminCreate = addTargetOptions(
|
|
|
7841
7935
|
(pb) => upsertSuperuser(pb, address, password10)
|
|
7842
7936
|
);
|
|
7843
7937
|
const base2 = state?.domain ? `https://${state.domain.split(",")[0].trim()}` : "";
|
|
7844
|
-
|
|
7845
|
-
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.`
|
|
7846
7940
|
);
|
|
7847
7941
|
}
|
|
7848
7942
|
},
|
|
@@ -7854,20 +7948,20 @@ var adminCreate = addTargetOptions(
|
|
|
7854
7948
|
async function upsertSuperuser(pb, email3, password10) {
|
|
7855
7949
|
const existing = await findSuperuser(pb, email3);
|
|
7856
7950
|
if (existing) {
|
|
7857
|
-
const confirmed = await
|
|
7858
|
-
message: `${email3}
|
|
7951
|
+
const confirmed = await p41.confirm({
|
|
7952
|
+
message: `${email3} already has an account, update its password?`,
|
|
7859
7953
|
initialValue: false
|
|
7860
7954
|
});
|
|
7861
|
-
if (
|
|
7862
|
-
|
|
7863
|
-
|
|
7955
|
+
if (p41.isCancel(confirmed) || !confirmed) {
|
|
7956
|
+
p41.cancel("Operation cancelled.");
|
|
7957
|
+
process29.exit(0);
|
|
7864
7958
|
}
|
|
7865
7959
|
await pb.collection("_superusers").update(existing, { password: password10, passwordConfirm: password10 });
|
|
7866
|
-
|
|
7960
|
+
p41.log.success(`Password updated for ${pc19.cyan(email3)}, you can sign in now`);
|
|
7867
7961
|
return;
|
|
7868
7962
|
}
|
|
7869
7963
|
await pb.collection("_superusers").create({ email: email3, password: password10, passwordConfirm: password10 });
|
|
7870
|
-
|
|
7964
|
+
p41.log.success(`${pc19.cyan(email3)} can now sign in`);
|
|
7871
7965
|
}
|
|
7872
7966
|
async function findSuperuser(pb, email3) {
|
|
7873
7967
|
try {
|
|
@@ -7878,32 +7972,32 @@ async function findSuperuser(pb, email3) {
|
|
|
7878
7972
|
}
|
|
7879
7973
|
}
|
|
7880
7974
|
async function promptEmail() {
|
|
7881
|
-
const value = await
|
|
7975
|
+
const value = await p41.text({
|
|
7882
7976
|
message: "Email to sign in with",
|
|
7883
7977
|
validate: (input) => input?.includes("@") ? void 0 : "An email address is required"
|
|
7884
7978
|
});
|
|
7885
|
-
if (
|
|
7886
|
-
|
|
7887
|
-
|
|
7979
|
+
if (p41.isCancel(value)) {
|
|
7980
|
+
p41.cancel("Operation cancelled.");
|
|
7981
|
+
process29.exit(0);
|
|
7888
7982
|
}
|
|
7889
7983
|
return value.trim();
|
|
7890
7984
|
}
|
|
7891
7985
|
async function promptPassword2() {
|
|
7892
|
-
const value = await
|
|
7986
|
+
const value = await p41.password({
|
|
7893
7987
|
message: "Password",
|
|
7894
7988
|
validate: (input) => (input?.length ?? 0) >= MIN_PASSWORD ? void 0 : `At least ${MIN_PASSWORD} characters is required`
|
|
7895
7989
|
});
|
|
7896
|
-
if (
|
|
7897
|
-
|
|
7898
|
-
|
|
7990
|
+
if (p41.isCancel(value)) {
|
|
7991
|
+
p41.cancel("Operation cancelled.");
|
|
7992
|
+
process29.exit(0);
|
|
7899
7993
|
}
|
|
7900
|
-
const again = await
|
|
7994
|
+
const again = await p41.password({
|
|
7901
7995
|
message: "Password again",
|
|
7902
7996
|
validate: (input) => input === value ? void 0 : "The two do not match"
|
|
7903
7997
|
});
|
|
7904
|
-
if (
|
|
7905
|
-
|
|
7906
|
-
|
|
7998
|
+
if (p41.isCancel(again)) {
|
|
7999
|
+
p41.cancel("Operation cancelled.");
|
|
8000
|
+
process29.exit(0);
|
|
7907
8001
|
}
|
|
7908
8002
|
return value;
|
|
7909
8003
|
}
|
|
@@ -7913,8 +8007,8 @@ var admin = new Command82("admin").description("manage admin panel logins").conf
|
|
|
7913
8007
|
|
|
7914
8008
|
// src/commands/targets.ts
|
|
7915
8009
|
import { Command as Command83 } from "commander";
|
|
7916
|
-
import * as
|
|
7917
|
-
import
|
|
8010
|
+
import * as p42 from "@clack/prompts";
|
|
8011
|
+
import pc20 from "picocolors";
|
|
7918
8012
|
import * as v8 from "valibot";
|
|
7919
8013
|
var OptionsSchema4 = v8.object({
|
|
7920
8014
|
...SSH_OPTION_SCHEMA,
|
|
@@ -7986,13 +8080,13 @@ function report3(rows, offline) {
|
|
|
7986
8080
|
const domain = width("DOMAIN", (row) => row.domain);
|
|
7987
8081
|
const header = `${"TARGET".padEnd(target)} ${"SERVER".padEnd(server)} ${"DOMAIN".padEnd(domain)} RELEASE`;
|
|
7988
8082
|
const lines = rows.map(
|
|
7989
|
-
(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}`
|
|
7990
8084
|
);
|
|
7991
|
-
|
|
8085
|
+
p42.log.info(`${pc20.dim(header)}
|
|
7992
8086
|
${lines.join("\n")}`);
|
|
7993
8087
|
const unreachable = rows.filter((row) => row.kind === "remote" && !row.reachable);
|
|
7994
8088
|
if (!offline && unreachable.length > 0) {
|
|
7995
|
-
|
|
8089
|
+
p42.log.warn(
|
|
7996
8090
|
`Could not reach ${unreachable.map((row) => row.server).join(", ")}.
|
|
7997
8091
|
Release and domain are shown from what this project recorded.`
|
|
7998
8092
|
);
|
|
@@ -8001,31 +8095,31 @@ Release and domain are shown from what this project recorded.`
|
|
|
8001
8095
|
|
|
8002
8096
|
// src/commands/test.ts
|
|
8003
8097
|
import path42 from "node:path";
|
|
8004
|
-
import
|
|
8098
|
+
import process30 from "node:process";
|
|
8005
8099
|
import { Command as Command84 } from "commander";
|
|
8006
8100
|
import PocketBase5 from "pocketbase";
|
|
8007
|
-
import
|
|
8101
|
+
import pc21 from "picocolors";
|
|
8008
8102
|
import { x as x5 } from "tinyexec";
|
|
8009
8103
|
import { detect as detect8 } from "package-manager-detector";
|
|
8010
8104
|
import { resolveCommand as resolveCommand8 } from "package-manager-detector/commands";
|
|
8011
|
-
import
|
|
8105
|
+
import fs37 from "node:fs";
|
|
8012
8106
|
var testServer = new Command84("test:server").description("run server tests").allowUnknownOption(true).allowExcessArguments(true).configureHelp(helpConfig).action(async (_opts, cmd) => {
|
|
8013
|
-
const cwd =
|
|
8107
|
+
const cwd = process30.cwd();
|
|
8014
8108
|
const email3 = `test-${Math.random().toString(36).slice(2)}@example.com`;
|
|
8015
8109
|
const password10 = "password";
|
|
8016
8110
|
const testDataDir = path42.join(cwd, "test-data");
|
|
8017
|
-
|
|
8111
|
+
fs37.rmSync(testDataDir, { recursive: true, force: true });
|
|
8018
8112
|
const { stop, url } = await launchPocketbase(cwd, {
|
|
8019
8113
|
dir: testDataDir,
|
|
8020
8114
|
migrationsDir: path42.join(cwd, "migrations"),
|
|
8021
8115
|
email: email3,
|
|
8022
8116
|
password: password10
|
|
8023
8117
|
});
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
console.log(`${
|
|
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`);
|
|
8029
8123
|
const { createServer } = await loadVite(cwd);
|
|
8030
8124
|
const vite = await createServer({
|
|
8031
8125
|
mode: "test",
|
|
@@ -8034,21 +8128,21 @@ var testServer = new Command84("test:server").description("run server tests").al
|
|
|
8034
8128
|
});
|
|
8035
8129
|
const vitePort = await findFreePort();
|
|
8036
8130
|
await vite.listen(vitePort);
|
|
8037
|
-
|
|
8038
|
-
console.log(`${
|
|
8039
|
-
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}`);
|
|
8040
8134
|
const cleanup = async () => {
|
|
8041
8135
|
stop();
|
|
8042
8136
|
await vite.close();
|
|
8043
|
-
|
|
8137
|
+
fs37.rmSync(testDataDir, { recursive: true, force: true });
|
|
8044
8138
|
};
|
|
8045
8139
|
const pb = new PocketBase5(url);
|
|
8046
8140
|
try {
|
|
8047
8141
|
await authWithRetries(pb, email3, password10);
|
|
8048
8142
|
} catch (e) {
|
|
8049
8143
|
await cleanup();
|
|
8050
|
-
console.error(`${
|
|
8051
|
-
|
|
8144
|
+
console.error(`${pc21.redBright("\u2717")} Auth failed: ${e.message}`);
|
|
8145
|
+
process30.exit(1);
|
|
8052
8146
|
}
|
|
8053
8147
|
const extraArgs = (cmd.parent?.args ?? []).slice(1);
|
|
8054
8148
|
let filter = extraArgs.find((arg) => !arg.startsWith("-"));
|
|
@@ -8066,7 +8160,7 @@ var testServer = new Command84("test:server").description("run server tests").al
|
|
|
8066
8160
|
const resolvedArgs = resolved.args.slice();
|
|
8067
8161
|
if (pm === "npm") resolvedArgs.unshift("--yes");
|
|
8068
8162
|
await x5(resolved.command, resolvedArgs, {
|
|
8069
|
-
nodeOptions: { cwd, stdio: "inherit", env: { ...
|
|
8163
|
+
nodeOptions: { cwd, stdio: "inherit", env: { ...process30.env, CI: "1" } },
|
|
8070
8164
|
throwOnError: true
|
|
8071
8165
|
});
|
|
8072
8166
|
} catch {
|
|
@@ -8092,7 +8186,7 @@ function stubPagesPlugin() {
|
|
|
8092
8186
|
}
|
|
8093
8187
|
|
|
8094
8188
|
// src/commands/routes.ts
|
|
8095
|
-
import
|
|
8189
|
+
import fs38 from "node:fs";
|
|
8096
8190
|
import path43 from "node:path";
|
|
8097
8191
|
import { Command as Command85 } from "commander";
|
|
8098
8192
|
var HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
@@ -8113,7 +8207,7 @@ var routes = new Command85("routes").description("list routes").configureHelp(he
|
|
|
8113
8207
|
printTable(found);
|
|
8114
8208
|
});
|
|
8115
8209
|
function walk(root, dir) {
|
|
8116
|
-
const entries =
|
|
8210
|
+
const entries = fs38.readdirSync(dir, { withFileTypes: true });
|
|
8117
8211
|
const routes2 = [];
|
|
8118
8212
|
const hasLeaf = entries.some((e) => e.isFile() && isRouteFile(e.name));
|
|
8119
8213
|
if (hasLeaf) {
|
|
@@ -8139,7 +8233,7 @@ function isRouteFile(name) {
|
|
|
8139
8233
|
}
|
|
8140
8234
|
function extractMethods(file) {
|
|
8141
8235
|
try {
|
|
8142
|
-
const content =
|
|
8236
|
+
const content = fs38.readFileSync(file, "utf8");
|
|
8143
8237
|
const methods = [];
|
|
8144
8238
|
const exportRegex = /export\s+(?:const|async\s+function|function)\s+(\w+)/g;
|
|
8145
8239
|
let match;
|
|
@@ -8180,13 +8274,13 @@ function printTable(routes2) {
|
|
|
8180
8274
|
}
|
|
8181
8275
|
|
|
8182
8276
|
// src/commands/i18n.ts
|
|
8183
|
-
import
|
|
8277
|
+
import process31 from "node:process";
|
|
8184
8278
|
import { Command as Command86 } from "commander";
|
|
8185
8279
|
import { x as x6 } from "tinyexec";
|
|
8186
8280
|
import { detect as detect9 } from "package-manager-detector";
|
|
8187
8281
|
import { resolveCommand as resolveCommand9 } from "package-manager-detector/commands";
|
|
8188
8282
|
async function runWuchale(extraArgs) {
|
|
8189
|
-
const cwd =
|
|
8283
|
+
const cwd = process31.cwd();
|
|
8190
8284
|
const pm = (await detect9({ cwd }))?.name ?? "npm";
|
|
8191
8285
|
const resolved = resolveCommand9(pm, "execute", ["wuchale", ...extraArgs]);
|
|
8192
8286
|
const args = resolved.args.slice();
|
|
@@ -8236,7 +8330,7 @@ var BACKEND_OPTIONAL_COMMANDS = /* @__PURE__ */ new Set(["dev", "build", "previe
|
|
|
8236
8330
|
var program = new Command87().name(package_default.name).description(package_default.description).version(package_default.version, "-v, --version").configureHelp(helpConfig);
|
|
8237
8331
|
program.hook("preAction", (_thisCommand, actionCommand) => {
|
|
8238
8332
|
if (isStub(actionCommand)) return;
|
|
8239
|
-
const envRoot = findWorkspaceRoot() ??
|
|
8333
|
+
const envRoot = findWorkspaceRoot() ?? process32.cwd();
|
|
8240
8334
|
dotenv2.config({ path: nodePath.join(envRoot, ".env"), quiet: true });
|
|
8241
8335
|
const path44 = getCommandPath(actionCommand);
|
|
8242
8336
|
if (NO_BACKEND_COMMMANDS.has(path44)) return;
|
|
@@ -8244,29 +8338,29 @@ program.hook("preAction", (_thisCommand, actionCommand) => {
|
|
|
8244
8338
|
if (NO_BACKEND_COMMMANDS.has(top)) return;
|
|
8245
8339
|
if (!hasBackend()) {
|
|
8246
8340
|
if (BACKEND_OPTIONAL_COMMANDS.has(top)) return;
|
|
8247
|
-
|
|
8248
|
-
`${
|
|
8341
|
+
p43.log.error(
|
|
8342
|
+
`${pc22.cyan(`vela ${path44}`)} needs a backend, and this project does not have one.
|
|
8249
8343
|
|
|
8250
8344
|
Static projects have no database to talk to.
|
|
8251
8345
|
|
|
8252
|
-
To add a backend to this project, run ${
|
|
8346
|
+
To add a backend to this project, run ${pc22.cyan("vela bless")}.`
|
|
8253
8347
|
);
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8348
|
+
p43.log.message();
|
|
8349
|
+
p43.cancel("Operation failed.");
|
|
8350
|
+
process32.exit(1);
|
|
8257
8351
|
}
|
|
8258
|
-
if (!
|
|
8259
|
-
|
|
8352
|
+
if (!process32.env.POCKETBASE_SUPERUSER_EMAIL || !process32.env.POCKETBASE_SUPERUSER_PASSWORD) {
|
|
8353
|
+
p43.log.error(
|
|
8260
8354
|
`PocketBase superuser credentials are required.
|
|
8261
8355
|
|
|
8262
|
-
Set ${
|
|
8356
|
+
Set ${pc22.cyan("POCKETBASE_SUPERUSER_EMAIL")} and ${pc22.cyan("POCKETBASE_SUPERUSER_PASSWORD")} in your .env file.
|
|
8263
8357
|
|
|
8264
|
-
To set up a new project, run ${
|
|
8265
|
-
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")}.`
|
|
8266
8360
|
);
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8361
|
+
p43.log.message();
|
|
8362
|
+
p43.cancel("Operation failed.");
|
|
8363
|
+
process32.exit(1);
|
|
8270
8364
|
}
|
|
8271
8365
|
});
|
|
8272
8366
|
function getCommandPath(cmd) {
|
|
@@ -8317,14 +8411,14 @@ for (const command of [
|
|
|
8317
8411
|
}
|
|
8318
8412
|
|
|
8319
8413
|
// src/bin.ts
|
|
8320
|
-
var argv = normalizeArgv(
|
|
8414
|
+
var argv = normalizeArgv(process33.argv.slice(2));
|
|
8321
8415
|
var delegatedExitCode = delegateToLocalCli({
|
|
8322
8416
|
argv,
|
|
8323
8417
|
selfPath: fileURLToPath2(import.meta.url),
|
|
8324
8418
|
selfVersion: package_default.version
|
|
8325
8419
|
});
|
|
8326
8420
|
if (delegatedExitCode !== null) {
|
|
8327
|
-
|
|
8421
|
+
process33.exit(delegatedExitCode);
|
|
8328
8422
|
}
|
|
8329
8423
|
program.parse(argv, { from: "user" });
|
|
8330
8424
|
//# sourceMappingURL=bin.js.map
|