vela 0.13.1 → 0.13.3
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 +227 -167
- package/dist/bin.js.map +4 -4
- package/package.json +5 -5
package/dist/bin.js
CHANGED
|
@@ -21,7 +21,7 @@ import pc42 from "picocolors";
|
|
|
21
21
|
// package.json
|
|
22
22
|
var package_default = {
|
|
23
23
|
name: "vela",
|
|
24
|
-
version: "0.13.
|
|
24
|
+
version: "0.13.3",
|
|
25
25
|
type: "module",
|
|
26
26
|
description: "A CLI for creating and updating SvelteKit projects",
|
|
27
27
|
license: "MIT",
|
|
@@ -57,7 +57,7 @@ var package_default = {
|
|
|
57
57
|
dependencies: {
|
|
58
58
|
"@clack/prompts": "^1.7.0",
|
|
59
59
|
"@faker-js/faker": "^10.6.0",
|
|
60
|
-
"@velastack/patterns": "^0.2.
|
|
60
|
+
"@velastack/patterns": "^0.2.9",
|
|
61
61
|
"@velastack/pocketbase-codegen": "^0.1.0",
|
|
62
62
|
"annotate-json-schema": "^0.1.0",
|
|
63
63
|
commander: "^13.1.0",
|
|
@@ -70,7 +70,7 @@ var package_default = {
|
|
|
70
70
|
"package-manager-detector": "^1.8.0",
|
|
71
71
|
picocolors: "^1.1.1",
|
|
72
72
|
pocketbase: "^0.28.0",
|
|
73
|
-
"pocketbase-server": "^0.40.
|
|
73
|
+
"pocketbase-server": "^0.40.5-beta.1",
|
|
74
74
|
stripe: "^19.3.0",
|
|
75
75
|
svelte: "^5.56.10",
|
|
76
76
|
tar: "^7.5.22",
|
|
@@ -80,11 +80,11 @@ var package_default = {
|
|
|
80
80
|
},
|
|
81
81
|
devDependencies: {
|
|
82
82
|
"@types/cross-spawn": "^6.0.6",
|
|
83
|
-
"@types/node": "^
|
|
83
|
+
"@types/node": "^26.5.1",
|
|
84
84
|
esbuild: "^0.28.2",
|
|
85
85
|
prettier: "^3.9.6",
|
|
86
86
|
shellcheck: "^4.1.0",
|
|
87
|
-
typescript: "^
|
|
87
|
+
typescript: "^7.0.2",
|
|
88
88
|
vite: "^8.2.2",
|
|
89
89
|
vitest: "^5.0.1"
|
|
90
90
|
},
|
|
@@ -315,8 +315,8 @@ function dropTemplateAdapters(user, template) {
|
|
|
315
315
|
}
|
|
316
316
|
return copy;
|
|
317
317
|
}
|
|
318
|
-
function readPackageJson(
|
|
319
|
-
return JSON.parse(fs.readFileSync(
|
|
318
|
+
function readPackageJson(path48) {
|
|
319
|
+
return JSON.parse(fs.readFileSync(path48, "utf8"));
|
|
320
320
|
}
|
|
321
321
|
var PACKAGE_NAME_PLACEHOLDER = /~TODO~/g;
|
|
322
322
|
var APP_NAME_PLACEHOLDER = /~APP_NAME~/g;
|
|
@@ -334,12 +334,12 @@ function fillTemplatePlaceholders(raw, values) {
|
|
|
334
334
|
function escapeSingleQuoted(value) {
|
|
335
335
|
return value.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
336
336
|
}
|
|
337
|
-
function readTemplatePackageJson(
|
|
338
|
-
const raw = fillTemplatePlaceholders(fs.readFileSync(
|
|
337
|
+
function readTemplatePackageJson(path48, values) {
|
|
338
|
+
const raw = fillTemplatePlaceholders(fs.readFileSync(path48, "utf8"), values);
|
|
339
339
|
return JSON.parse(raw);
|
|
340
340
|
}
|
|
341
|
-
function writePackageJson(
|
|
342
|
-
fs.writeFileSync(
|
|
341
|
+
function writePackageJson(path48, pkg) {
|
|
342
|
+
fs.writeFileSync(path48, JSON.stringify(pkg, null, " ") + "\n");
|
|
343
343
|
}
|
|
344
344
|
function toValidPackageName(name) {
|
|
345
345
|
return name.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z0-9~.-]+/g, "-");
|
|
@@ -2692,7 +2692,7 @@ async function runPattern(slug2, argv, input, report4) {
|
|
|
2692
2692
|
}
|
|
2693
2693
|
checkProviderInput(pattern, argv, input);
|
|
2694
2694
|
const { workspaceRootDir, features } = await getWorkspace();
|
|
2695
|
-
const
|
|
2695
|
+
const log50 = p9.taskLog({ title: report4.task.title });
|
|
2696
2696
|
let result;
|
|
2697
2697
|
try {
|
|
2698
2698
|
result = await pattern.generate({
|
|
@@ -2712,11 +2712,11 @@ async function runPattern(slug2, argv, input, report4) {
|
|
|
2712
2712
|
});
|
|
2713
2713
|
return collections2;
|
|
2714
2714
|
},
|
|
2715
|
-
logger: { info: (message) =>
|
|
2715
|
+
logger: { info: (message) => log50.message(message) }
|
|
2716
2716
|
});
|
|
2717
|
-
|
|
2717
|
+
log50.success(report4.task.success);
|
|
2718
2718
|
} catch (e) {
|
|
2719
|
-
|
|
2719
|
+
log50.error(report4.task.error);
|
|
2720
2720
|
throw e;
|
|
2721
2721
|
}
|
|
2722
2722
|
const rel = (f) => toRelative(workspaceRootDir, f);
|
|
@@ -2749,9 +2749,36 @@ async function runPattern(slug2, argv, input, report4) {
|
|
|
2749
2749
|
});
|
|
2750
2750
|
}
|
|
2751
2751
|
|
|
2752
|
+
// src/lib/form-ui.ts
|
|
2753
|
+
import path17 from "node:path";
|
|
2754
|
+
var FORM_UIS = ["shadcn", "plain"];
|
|
2755
|
+
function detectFormInput(root) {
|
|
2756
|
+
const pkg = readPackageJson(path17.join(root, "package.json"));
|
|
2757
|
+
const hasDep = (name) => Boolean(pkg.dependencies?.[name] || pkg.devDependencies?.[name]);
|
|
2758
|
+
const shadcn = readComponentsJson(root) !== void 0 && (hasDep("shadcn-svelte") || hasDep("bits-ui"));
|
|
2759
|
+
return {
|
|
2760
|
+
ui: shadcn ? "shadcn" : "plain",
|
|
2761
|
+
flash: hasDep("sveltekit-flash-message"),
|
|
2762
|
+
serverTests: hasDep("supertest")
|
|
2763
|
+
};
|
|
2764
|
+
}
|
|
2765
|
+
function resolveFormInput(root, requested) {
|
|
2766
|
+
const detected = detectFormInput(root);
|
|
2767
|
+
if (requested === void 0) return detected;
|
|
2768
|
+
if (!FORM_UIS.includes(requested)) {
|
|
2769
|
+
throw new Error(`Unknown --ui "${requested}". Expected one of: ${FORM_UIS.join(", ")}.`);
|
|
2770
|
+
}
|
|
2771
|
+
if (requested === "shadcn" && detected.ui !== "shadcn") {
|
|
2772
|
+
throw new Error(
|
|
2773
|
+
"--ui shadcn needs a shadcn-svelte project (a components.json and the shadcn-svelte package). Run `vela bless` to set one up, or use --ui plain."
|
|
2774
|
+
);
|
|
2775
|
+
}
|
|
2776
|
+
return { ...detected, ui: requested };
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2752
2779
|
// src/lib/ai-flow.ts
|
|
2753
2780
|
import fs18 from "node:fs";
|
|
2754
|
-
import
|
|
2781
|
+
import path18 from "node:path";
|
|
2755
2782
|
import * as p13 from "@clack/prompts";
|
|
2756
2783
|
import pc4 from "picocolors";
|
|
2757
2784
|
|
|
@@ -3026,17 +3053,20 @@ function specToArgv(spec) {
|
|
|
3026
3053
|
return collectionSpecToArgv(spec);
|
|
3027
3054
|
}
|
|
3028
3055
|
function writeLayoutSidecar(workspaceRootDir, modelName, layout) {
|
|
3029
|
-
const dir =
|
|
3056
|
+
const dir = path18.join(workspaceRootDir, "data", "ai-form-layouts");
|
|
3030
3057
|
fs18.mkdirSync(dir, { recursive: true });
|
|
3031
|
-
const file =
|
|
3058
|
+
const file = path18.join(dir, `${modelName}.json`);
|
|
3032
3059
|
fs18.writeFileSync(file, JSON.stringify(layout, null, 2) + "\n");
|
|
3033
|
-
return
|
|
3060
|
+
return path18.relative(workspaceRootDir, file);
|
|
3034
3061
|
}
|
|
3035
3062
|
|
|
3036
3063
|
// src/commands/generate/form.ts
|
|
3037
3064
|
var form = new Command5("form").description("generate a form from a model").argument("[model]", 'model name (e.g. "contact")').argument("[fields...]", 'field definitions (e.g. "name:text", "email:email")').option("--remote", "generate a form backed by a remote PocketBase collection").option(
|
|
3038
3065
|
"--route <route>",
|
|
3039
3066
|
'place the form at a custom route (e.g. "(app)/[team_id]/projects/new"). Defaults to the model name under (app)/(public).'
|
|
3067
|
+
).option(
|
|
3068
|
+
"--ui <ui>",
|
|
3069
|
+
'markup to generate: "shadcn" components or "plain" HTML. Defaults to shadcn when the project has shadcn-svelte, plain otherwise.'
|
|
3040
3070
|
).option(
|
|
3041
3071
|
"--ai <description>",
|
|
3042
3072
|
"design the form with AI from a natural-language description (two stages: schema \u2192 layout)"
|
|
@@ -3069,6 +3099,11 @@ var form = new Command5("form").description("generate a form from a model").argu
|
|
|
3069
3099
|
argv = [model, ...fields];
|
|
3070
3100
|
modelName = model;
|
|
3071
3101
|
}
|
|
3102
|
+
const { workspaceRootDir } = await getWorkspace();
|
|
3103
|
+
const formInput = resolveFormInput(workspaceRootDir, options.ui);
|
|
3104
|
+
if (formInput.ui === "plain" && !options.ui) {
|
|
3105
|
+
p14.log.info("shadcn-svelte not detected: generating a plain HTML form.");
|
|
3106
|
+
}
|
|
3072
3107
|
const slug2 = options.remote ? "generate-form-remote" : "generate-form";
|
|
3073
3108
|
const nextSteps = [
|
|
3074
3109
|
"Edit the form fields and validation in the generated +page.svelte.",
|
|
@@ -3082,7 +3117,7 @@ var form = new Command5("form").description("generate a form from a model").argu
|
|
|
3082
3117
|
await runPattern(
|
|
3083
3118
|
slug2,
|
|
3084
3119
|
argv,
|
|
3085
|
-
{ route: options.route },
|
|
3120
|
+
{ route: options.route, ...formInput },
|
|
3086
3121
|
{
|
|
3087
3122
|
summary: `Created ${modelName} form.`,
|
|
3088
3123
|
nextSteps,
|
|
@@ -3644,7 +3679,7 @@ import pc5 from "picocolors";
|
|
|
3644
3679
|
|
|
3645
3680
|
// src/lib/deploy-config.ts
|
|
3646
3681
|
import fs19 from "node:fs";
|
|
3647
|
-
import
|
|
3682
|
+
import path19 from "node:path";
|
|
3648
3683
|
import crypto from "node:crypto";
|
|
3649
3684
|
import { pathToFileURL } from "node:url";
|
|
3650
3685
|
var CONFIG_BASENAMES = [
|
|
@@ -3655,7 +3690,7 @@ var CONFIG_BASENAMES = [
|
|
|
3655
3690
|
];
|
|
3656
3691
|
function findConfigFile(workspaceRootDir) {
|
|
3657
3692
|
for (const name of CONFIG_BASENAMES) {
|
|
3658
|
-
const file =
|
|
3693
|
+
const file = path19.join(workspaceRootDir, name);
|
|
3659
3694
|
if (fs19.existsSync(file)) return file;
|
|
3660
3695
|
}
|
|
3661
3696
|
return null;
|
|
@@ -3671,7 +3706,7 @@ async function loadDeployConfig(workspaceRootDir) {
|
|
|
3671
3706
|
const mod = await import(url);
|
|
3672
3707
|
const config = mod.default;
|
|
3673
3708
|
if (!config || typeof config !== "object") {
|
|
3674
|
-
throw new Error(`${
|
|
3709
|
+
throw new Error(`${path19.basename(file)} must export a config object as its default export.`);
|
|
3675
3710
|
}
|
|
3676
3711
|
return config;
|
|
3677
3712
|
} finally {
|
|
@@ -3684,15 +3719,15 @@ async function transpileToTemp(file) {
|
|
|
3684
3719
|
const { outputText } = ts.transpileModule(source, {
|
|
3685
3720
|
compilerOptions: { module: ts.ModuleKind.ESNext, target: ts.ScriptTarget.ES2022 }
|
|
3686
3721
|
});
|
|
3687
|
-
const temp =
|
|
3688
|
-
|
|
3722
|
+
const temp = path19.join(
|
|
3723
|
+
path19.dirname(file),
|
|
3689
3724
|
`.velastack.config.${crypto.randomBytes(4).toString("hex")}.mjs`
|
|
3690
3725
|
);
|
|
3691
3726
|
fs19.writeFileSync(temp, outputText);
|
|
3692
3727
|
return pathToFileURL(temp).href;
|
|
3693
3728
|
}
|
|
3694
3729
|
function projectFilePath(workspaceRootDir) {
|
|
3695
|
-
return
|
|
3730
|
+
return path19.join(workspaceRootDir, ".vela", "project.json");
|
|
3696
3731
|
}
|
|
3697
3732
|
function readProjectFile(workspaceRootDir) {
|
|
3698
3733
|
const file = projectFilePath(workspaceRootDir);
|
|
@@ -3705,7 +3740,7 @@ function readProjectFile(workspaceRootDir) {
|
|
|
3705
3740
|
}
|
|
3706
3741
|
function writeProjectFile(workspaceRootDir, data) {
|
|
3707
3742
|
const file = projectFilePath(workspaceRootDir);
|
|
3708
|
-
fs19.mkdirSync(
|
|
3743
|
+
fs19.mkdirSync(path19.dirname(file), { recursive: true });
|
|
3709
3744
|
fs19.writeFileSync(file, JSON.stringify(data, null, 2) + "\n");
|
|
3710
3745
|
}
|
|
3711
3746
|
function resolveAppIdentity(workspaceRootDir, config = {}) {
|
|
@@ -3731,11 +3766,11 @@ function readAppIdentity(workspaceRootDir, config = {}) {
|
|
|
3731
3766
|
}
|
|
3732
3767
|
function defaultProjectName(workspaceRootDir) {
|
|
3733
3768
|
try {
|
|
3734
|
-
const pkg = readPackageJson(
|
|
3769
|
+
const pkg = readPackageJson(path19.join(workspaceRootDir, "package.json"));
|
|
3735
3770
|
if (typeof pkg.name === "string" && pkg.name.trim()) return pkg.name.trim();
|
|
3736
3771
|
} catch {
|
|
3737
3772
|
}
|
|
3738
|
-
return
|
|
3773
|
+
return path19.basename(workspaceRootDir);
|
|
3739
3774
|
}
|
|
3740
3775
|
function slug(value) {
|
|
3741
3776
|
return value.toLowerCase().replace(/^@/, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 32) || "app";
|
|
@@ -3807,14 +3842,14 @@ function randomSuffix() {
|
|
|
3807
3842
|
|
|
3808
3843
|
// src/lib/artifact.ts
|
|
3809
3844
|
import fs21 from "node:fs";
|
|
3810
|
-
import
|
|
3845
|
+
import path21 from "node:path";
|
|
3811
3846
|
import { detect as detect4 } from "package-manager-detector";
|
|
3812
3847
|
import { resolveCommand as resolveCommand4 } from "package-manager-detector/commands";
|
|
3813
3848
|
|
|
3814
3849
|
// src/lib/ssh.ts
|
|
3815
3850
|
import fs20 from "node:fs";
|
|
3816
3851
|
import os4 from "node:os";
|
|
3817
|
-
import
|
|
3852
|
+
import path20 from "node:path";
|
|
3818
3853
|
import crypto3 from "node:crypto";
|
|
3819
3854
|
import process13 from "node:process";
|
|
3820
3855
|
import { spawn as spawn2 } from "node:child_process";
|
|
@@ -3857,9 +3892,9 @@ var SshSession = class {
|
|
|
3857
3892
|
}
|
|
3858
3893
|
async open() {
|
|
3859
3894
|
if (this.controlPath) return;
|
|
3860
|
-
const dir =
|
|
3895
|
+
const dir = path20.join(os4.tmpdir(), "vela-ssh");
|
|
3861
3896
|
fs20.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
3862
|
-
const socket =
|
|
3897
|
+
const socket = path20.join(dir, `${crypto3.randomBytes(6).toString("hex")}.sock`);
|
|
3863
3898
|
this.controlPath = socket;
|
|
3864
3899
|
const args = [
|
|
3865
3900
|
...this.sshArgs(),
|
|
@@ -4149,11 +4184,11 @@ function collectArtifact(cwd, config = {}) {
|
|
|
4149
4184
|
const outputDir = config.outputDir ?? DEFAULT_OUTPUT_DIR;
|
|
4150
4185
|
const entries = [];
|
|
4151
4186
|
const add2 = (rel, remoteDir = "") => {
|
|
4152
|
-
const localPath =
|
|
4187
|
+
const localPath = path21.join(cwd, rel);
|
|
4153
4188
|
if (fs21.existsSync(localPath)) entries.push({ localPath, remoteDir });
|
|
4154
4189
|
};
|
|
4155
|
-
const buildPath =
|
|
4156
|
-
if (!fs21.existsSync(
|
|
4190
|
+
const buildPath = path21.join(cwd, outputDir);
|
|
4191
|
+
if (!fs21.existsSync(path21.join(buildPath, "index.js"))) {
|
|
4157
4192
|
throw new BuildError(
|
|
4158
4193
|
`No ${outputDir}/index.js to deploy.
|
|
4159
4194
|
|
|
@@ -4167,7 +4202,7 @@ matches where it writes), then deploy again.`
|
|
|
4167
4202
|
add2("package-lock.json");
|
|
4168
4203
|
add2(".npmrc");
|
|
4169
4204
|
add2(MIGRATIONS_DIR);
|
|
4170
|
-
const hooks =
|
|
4205
|
+
const hooks = path21.join(cwd, DATA_DIR, "hooks");
|
|
4171
4206
|
if (fs21.existsSync(hooks)) entries.push({ localPath: hooks, remoteDir: "hooks" });
|
|
4172
4207
|
for (const extra of config.include ?? []) add2(extra);
|
|
4173
4208
|
return entries;
|
|
@@ -4210,7 +4245,7 @@ function sshOptionsFrom(options) {
|
|
|
4210
4245
|
// src/lib/remote.ts
|
|
4211
4246
|
import crypto4 from "node:crypto";
|
|
4212
4247
|
import fs22 from "node:fs";
|
|
4213
|
-
import
|
|
4248
|
+
import path22 from "node:path";
|
|
4214
4249
|
import process14 from "node:process";
|
|
4215
4250
|
var VELA_ROOT = "/var/lib/vela";
|
|
4216
4251
|
var VELA_ETC = "/etc/vela";
|
|
@@ -4223,19 +4258,19 @@ function instanceHasBackend(state) {
|
|
|
4223
4258
|
return state.backend ?? Boolean(state.pbPort);
|
|
4224
4259
|
}
|
|
4225
4260
|
function serverTemplatesDir() {
|
|
4226
|
-
return
|
|
4261
|
+
return path22.join(templatesDir(), "server");
|
|
4227
4262
|
}
|
|
4228
4263
|
var DIGEST_LENGTH = 12;
|
|
4229
4264
|
function serverScriptsDigest(dir = serverTemplatesDir()) {
|
|
4230
4265
|
const hash = crypto4.createHash("sha256");
|
|
4231
4266
|
for (const file of listFiles(dir).sort()) {
|
|
4232
|
-
hash.update(file).update("\0").update(fs22.readFileSync(
|
|
4267
|
+
hash.update(file).update("\0").update(fs22.readFileSync(path22.join(dir, file))).update("\0");
|
|
4233
4268
|
}
|
|
4234
4269
|
return hash.digest("hex").slice(0, DIGEST_LENGTH);
|
|
4235
4270
|
}
|
|
4236
4271
|
function listFiles(root, prefix = "") {
|
|
4237
4272
|
const files = [];
|
|
4238
|
-
for (const entry of fs22.readdirSync(
|
|
4273
|
+
for (const entry of fs22.readdirSync(path22.join(root, prefix), { withFileTypes: true })) {
|
|
4239
4274
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
4240
4275
|
if (entry.isDirectory()) files.push(...listFiles(root, rel));
|
|
4241
4276
|
else if (entry.isFile()) files.push(rel);
|
|
@@ -4875,7 +4910,7 @@ Set ${pc7.cyan("POCKETBASE_SUPERUSER_EMAIL")} and ${pc7.cyan("POCKETBASE_SUPERUS
|
|
|
4875
4910
|
|
|
4876
4911
|
// src/lib/s3-settings.ts
|
|
4877
4912
|
import fs25 from "node:fs";
|
|
4878
|
-
import
|
|
4913
|
+
import path23 from "node:path";
|
|
4879
4914
|
var VIRTUAL_HOSTED = [/\.amazonaws\.com$/i, /\.r2\.cloudflarestorage\.com$/i];
|
|
4880
4915
|
function defaultForcePathStyle(endpoint) {
|
|
4881
4916
|
let host;
|
|
@@ -4913,7 +4948,7 @@ async function hasLocalUploads(session, instance, workspaceRootDir) {
|
|
|
4913
4948
|
});
|
|
4914
4949
|
return result.stdout.trim().length > 0;
|
|
4915
4950
|
}
|
|
4916
|
-
return hasFile(
|
|
4951
|
+
return hasFile(path23.join(workspaceRootDir, DATA_DIR, "storage"));
|
|
4917
4952
|
}
|
|
4918
4953
|
function hasFile(dir) {
|
|
4919
4954
|
let entries;
|
|
@@ -4924,7 +4959,7 @@ function hasFile(dir) {
|
|
|
4924
4959
|
}
|
|
4925
4960
|
for (const entry of entries) {
|
|
4926
4961
|
if (entry.isFile()) return true;
|
|
4927
|
-
if (entry.isDirectory() && hasFile(
|
|
4962
|
+
if (entry.isDirectory() && hasFile(path23.join(dir, entry.name))) return true;
|
|
4928
4963
|
}
|
|
4929
4964
|
return false;
|
|
4930
4965
|
}
|
|
@@ -5964,18 +5999,18 @@ function uiAddReport(requested, outcome) {
|
|
|
5964
5999
|
var add = new Command48("add").description("add ui components (shadcn-svelte items and vela components such as data-table)").argument("<components...>", "the components to add").option("--overwrite", "replace components that already exist", false).configureHelp(helpConfig).action(
|
|
5965
6000
|
(components, options) => runCommand(async () => {
|
|
5966
6001
|
const { workspaceRootDir } = await getWorkspace();
|
|
5967
|
-
const
|
|
6002
|
+
const log50 = p29.taskLog({ title: "Adding UI components..." });
|
|
5968
6003
|
let outcome;
|
|
5969
6004
|
try {
|
|
5970
6005
|
outcome = await installComponents({
|
|
5971
6006
|
root: workspaceRootDir,
|
|
5972
6007
|
components,
|
|
5973
6008
|
overwrite: options.overwrite,
|
|
5974
|
-
logger: { info: (message) =>
|
|
6009
|
+
logger: { info: (message) => log50.message(message) }
|
|
5975
6010
|
});
|
|
5976
|
-
|
|
6011
|
+
log50.success("UI components ready");
|
|
5977
6012
|
} catch (e) {
|
|
5978
|
-
|
|
6013
|
+
log50.error("Could not add UI components");
|
|
5979
6014
|
throw e;
|
|
5980
6015
|
}
|
|
5981
6016
|
reportResult(uiAddReport(components, outcome));
|
|
@@ -5989,13 +6024,13 @@ import { applyBaseColor } from "@velastack/patterns";
|
|
|
5989
6024
|
var base = new Command49("base").description("change the base (gray) palette").argument("<color>", `base color to use (${BASE_COLORS.join(", ")})`).configureHelp(helpConfig).action(
|
|
5990
6025
|
(color) => runCommand(async () => {
|
|
5991
6026
|
const { workspaceRootDir } = await getWorkspace();
|
|
5992
|
-
const
|
|
6027
|
+
const log50 = p30.taskLog({ title: `Applying the ${color} palette...` });
|
|
5993
6028
|
let outcome;
|
|
5994
6029
|
try {
|
|
5995
6030
|
outcome = await applyBaseColor({ root: workspaceRootDir, color });
|
|
5996
|
-
|
|
6031
|
+
log50.success("Palette applied");
|
|
5997
6032
|
} catch (e) {
|
|
5998
|
-
|
|
6033
|
+
log50.error("Could not change the base color");
|
|
5999
6034
|
throw e;
|
|
6000
6035
|
}
|
|
6001
6036
|
reportResult({
|
|
@@ -6102,14 +6137,14 @@ var style = new Command51("style").description("switch the shadcn-svelte style,
|
|
|
6102
6137
|
const { workspaceRootDir } = await getWorkspace();
|
|
6103
6138
|
const spinner8 = p32.spinner();
|
|
6104
6139
|
spinner8.start(`Reading the ${name} registry...`);
|
|
6105
|
-
let
|
|
6140
|
+
let log50;
|
|
6106
6141
|
let outcome;
|
|
6107
6142
|
try {
|
|
6108
6143
|
outcome = await switchStyle({
|
|
6109
6144
|
root: workspaceRootDir,
|
|
6110
6145
|
style: name,
|
|
6111
6146
|
font: options.font,
|
|
6112
|
-
logger: { info: (message) =>
|
|
6147
|
+
logger: { info: (message) => log50?.message(message) },
|
|
6113
6148
|
confirm: async (components) => {
|
|
6114
6149
|
spinner8.stop(`Read the ${name} registry`);
|
|
6115
6150
|
if (components.length > 0) {
|
|
@@ -6126,13 +6161,13 @@ ${components.map((c) => `- ${c}`).join("\n")}`
|
|
|
6126
6161
|
const ok = await p32.confirm({ message: `Switch to ${name}?`, initialValue: false });
|
|
6127
6162
|
if (p32.isCancel(ok) || !ok) return false;
|
|
6128
6163
|
}
|
|
6129
|
-
|
|
6164
|
+
log50 = p32.taskLog({ title: `Switching to the ${name} style...` });
|
|
6130
6165
|
return true;
|
|
6131
6166
|
}
|
|
6132
6167
|
});
|
|
6133
6168
|
} catch (e) {
|
|
6134
6169
|
spinner8.stop(`Could not switch to ${name}`);
|
|
6135
|
-
|
|
6170
|
+
log50?.error("Could not switch style");
|
|
6136
6171
|
throw e;
|
|
6137
6172
|
}
|
|
6138
6173
|
spinner8.stop(`Read the ${name} registry`);
|
|
@@ -6144,7 +6179,7 @@ ${components.map((c) => `- ${c}`).join("\n")}`
|
|
|
6144
6179
|
p32.cancel("Operation cancelled.");
|
|
6145
6180
|
return;
|
|
6146
6181
|
}
|
|
6147
|
-
|
|
6182
|
+
log50?.success("Style switched");
|
|
6148
6183
|
reportResult(uiStyleReport(outcome));
|
|
6149
6184
|
}, "Failed to switch style.")
|
|
6150
6185
|
);
|
|
@@ -6156,13 +6191,13 @@ import { applyTheme } from "@velastack/patterns";
|
|
|
6156
6191
|
var theme = new Command52("theme").description("change the accent color, keeping the base palette").argument("<accent>", `accent to use (${THEMES.join(", ")})`).configureHelp(helpConfig).action(
|
|
6157
6192
|
(accent) => runCommand(async () => {
|
|
6158
6193
|
const { workspaceRootDir } = await getWorkspace();
|
|
6159
|
-
const
|
|
6194
|
+
const log50 = p33.taskLog({ title: `Applying the ${accent} accent...` });
|
|
6160
6195
|
let outcome;
|
|
6161
6196
|
try {
|
|
6162
6197
|
outcome = await applyTheme({ root: workspaceRootDir, theme: accent });
|
|
6163
|
-
|
|
6198
|
+
log50.success("Accent applied");
|
|
6164
6199
|
} catch (e) {
|
|
6165
|
-
|
|
6200
|
+
log50.error("Could not change the accent");
|
|
6166
6201
|
throw e;
|
|
6167
6202
|
}
|
|
6168
6203
|
reportResult({
|
|
@@ -6185,7 +6220,7 @@ import { Command as Command56 } from "commander";
|
|
|
6185
6220
|
|
|
6186
6221
|
// src/commands/legal/terms.ts
|
|
6187
6222
|
import fs26 from "node:fs";
|
|
6188
|
-
import
|
|
6223
|
+
import path24 from "node:path";
|
|
6189
6224
|
import { Command as Command54 } from "commander";
|
|
6190
6225
|
import * as p35 from "@clack/prompts";
|
|
6191
6226
|
|
|
@@ -6844,22 +6879,22 @@ async function termsAction() {
|
|
|
6844
6879
|
mobileApp,
|
|
6845
6880
|
contact
|
|
6846
6881
|
});
|
|
6847
|
-
const termsPage =
|
|
6882
|
+
const termsPage = path24.join(
|
|
6848
6883
|
workspaceRootDir,
|
|
6849
6884
|
publicRoutesDir,
|
|
6850
6885
|
LEGAL_DIR,
|
|
6851
6886
|
"terms",
|
|
6852
6887
|
"+page.svelte"
|
|
6853
6888
|
);
|
|
6854
|
-
const termsPageTs =
|
|
6855
|
-
fs26.mkdirSync(
|
|
6889
|
+
const termsPageTs = path24.join(workspaceRootDir, publicRoutesDir, LEGAL_DIR, "terms", "+page.ts");
|
|
6890
|
+
fs26.mkdirSync(path24.dirname(termsPage), { recursive: true });
|
|
6856
6891
|
fs26.writeFileSync(termsPage, html);
|
|
6857
6892
|
fs26.writeFileSync(
|
|
6858
6893
|
termsPageTs,
|
|
6859
6894
|
pageMetaTagsLoader("Terms of Service", `Terms of Service for ${core.websiteName}`)
|
|
6860
6895
|
);
|
|
6861
|
-
const relativeTermsPage =
|
|
6862
|
-
const relativeTermsPageTs =
|
|
6896
|
+
const relativeTermsPage = path24.relative(workspaceRootDir, termsPage);
|
|
6897
|
+
const relativeTermsPageTs = path24.relative(workspaceRootDir, termsPageTs);
|
|
6863
6898
|
reportResult({
|
|
6864
6899
|
summary: "Generated placeholder terms and conditions.",
|
|
6865
6900
|
filesCreated: [relativeTermsPage, relativeTermsPageTs],
|
|
@@ -6874,7 +6909,7 @@ var terms = new Command54("terms").description("generate placeholder terms and c
|
|
|
6874
6909
|
|
|
6875
6910
|
// src/commands/legal/privacy.ts
|
|
6876
6911
|
import fs27 from "node:fs";
|
|
6877
|
-
import
|
|
6912
|
+
import path25 from "node:path";
|
|
6878
6913
|
import { Command as Command55 } from "commander";
|
|
6879
6914
|
import * as p36 from "@clack/prompts";
|
|
6880
6915
|
var mapLabels = {
|
|
@@ -7587,28 +7622,28 @@ async function privacyAction() {
|
|
|
7587
7622
|
kids,
|
|
7588
7623
|
retention
|
|
7589
7624
|
});
|
|
7590
|
-
const privacyPage =
|
|
7625
|
+
const privacyPage = path25.join(
|
|
7591
7626
|
workspaceRootDir,
|
|
7592
7627
|
publicRoutesDir,
|
|
7593
7628
|
LEGAL_DIR,
|
|
7594
7629
|
"privacy",
|
|
7595
7630
|
"+page.svelte"
|
|
7596
7631
|
);
|
|
7597
|
-
const privacyPageTs =
|
|
7632
|
+
const privacyPageTs = path25.join(
|
|
7598
7633
|
workspaceRootDir,
|
|
7599
7634
|
publicRoutesDir,
|
|
7600
7635
|
LEGAL_DIR,
|
|
7601
7636
|
"privacy",
|
|
7602
7637
|
"+page.ts"
|
|
7603
7638
|
);
|
|
7604
|
-
fs27.mkdirSync(
|
|
7639
|
+
fs27.mkdirSync(path25.dirname(privacyPage), { recursive: true });
|
|
7605
7640
|
fs27.writeFileSync(privacyPage, html);
|
|
7606
7641
|
fs27.writeFileSync(
|
|
7607
7642
|
privacyPageTs,
|
|
7608
7643
|
pageMetaTagsLoader("Privacy Policy", `Privacy Policy for ${core.websiteName}`)
|
|
7609
7644
|
);
|
|
7610
|
-
const relativePrivacyPage =
|
|
7611
|
-
const relativePrivacyPageTs =
|
|
7645
|
+
const relativePrivacyPage = path25.relative(workspaceRootDir, privacyPage);
|
|
7646
|
+
const relativePrivacyPageTs = path25.relative(workspaceRootDir, privacyPageTs);
|
|
7612
7647
|
reportResult({
|
|
7613
7648
|
summary: "Generated placeholder privacy policy.",
|
|
7614
7649
|
filesCreated: [relativePrivacyPage, relativePrivacyPageTs],
|
|
@@ -7632,7 +7667,7 @@ import { Command as Command57 } from "commander";
|
|
|
7632
7667
|
|
|
7633
7668
|
// src/lib/data.ts
|
|
7634
7669
|
import fs28 from "node:fs";
|
|
7635
|
-
import
|
|
7670
|
+
import path26 from "node:path";
|
|
7636
7671
|
import { ClientResponseError } from "pocketbase";
|
|
7637
7672
|
|
|
7638
7673
|
// src/lib/collections.ts
|
|
@@ -7669,14 +7704,14 @@ function dependencyOrder(collections2, startingCollectionId) {
|
|
|
7669
7704
|
|
|
7670
7705
|
// src/lib/data.ts
|
|
7671
7706
|
function dataDir(cwd, kind) {
|
|
7672
|
-
return
|
|
7707
|
+
return path26.join(cwd, DATA_DIR, kind);
|
|
7673
7708
|
}
|
|
7674
7709
|
function getDataFiles(cwd, kind) {
|
|
7675
7710
|
const dir = dataDir(cwd, kind);
|
|
7676
7711
|
if (!fs28.existsSync(dir)) return [];
|
|
7677
7712
|
return fs28.readdirSync(dir).filter((file) => file.endsWith(".json")).sort((a, b) => a.localeCompare(b)).map((file) => ({
|
|
7678
7713
|
collectionName: file.replace(/\.json$/i, "").replace(/^\d+[-_]?/, ""),
|
|
7679
|
-
filePath:
|
|
7714
|
+
filePath: path26.join(dir, file)
|
|
7680
7715
|
}));
|
|
7681
7716
|
}
|
|
7682
7717
|
function getSeedFiles(cwd) {
|
|
@@ -7723,7 +7758,7 @@ function describeError(e) {
|
|
|
7723
7758
|
return e instanceof Error ? e.message : String(e);
|
|
7724
7759
|
}
|
|
7725
7760
|
function label3(cwd, filePath, count) {
|
|
7726
|
-
return `${
|
|
7761
|
+
return `${path26.relative(cwd, filePath)} (${count} records)`;
|
|
7727
7762
|
}
|
|
7728
7763
|
async function createRecords(pb, kind, cwd, { collectionName, filePath }) {
|
|
7729
7764
|
const records = readRecords(filePath);
|
|
@@ -7731,7 +7766,7 @@ async function createRecords(pb, kind, cwd, { collectionName, filePath }) {
|
|
|
7731
7766
|
try {
|
|
7732
7767
|
await pb.collection(collectionName).create(record);
|
|
7733
7768
|
} catch (e) {
|
|
7734
|
-
throw new DataLoadError(kind,
|
|
7769
|
+
throw new DataLoadError(kind, path26.relative(cwd, filePath), index, e);
|
|
7735
7770
|
}
|
|
7736
7771
|
}
|
|
7737
7772
|
return records.length;
|
|
@@ -7906,7 +7941,7 @@ var reset = new Command59("reset").description("clear and reload fixtures").conf
|
|
|
7906
7941
|
|
|
7907
7942
|
// src/commands/fixtures/generate.ts
|
|
7908
7943
|
import fs29 from "node:fs";
|
|
7909
|
-
import
|
|
7944
|
+
import path27 from "node:path";
|
|
7910
7945
|
import { Command as Command60, InvalidArgumentError } from "commander";
|
|
7911
7946
|
import * as p37 from "@clack/prompts";
|
|
7912
7947
|
import { annotate } from "annotate-json-schema";
|
|
@@ -7945,7 +7980,7 @@ async function generateFixtureFiles(pb, workspaceRootDir, opts) {
|
|
|
7945
7980
|
const fixturesDir = dataDir(workspaceRootDir, "fixtures");
|
|
7946
7981
|
fs29.mkdirSync(fixturesDir, { recursive: true });
|
|
7947
7982
|
for (const file of fs29.readdirSync(fixturesDir)) {
|
|
7948
|
-
if (file.endsWith(".json")) fs29.unlinkSync(
|
|
7983
|
+
if (file.endsWith(".json")) fs29.unlinkSync(path27.join(fixturesDir, file));
|
|
7949
7984
|
}
|
|
7950
7985
|
if (opts.seed !== void 0) faker.seed(opts.seed);
|
|
7951
7986
|
const generator = createGenerator({
|
|
@@ -8012,8 +8047,8 @@ async function generateFixtureFiles(pb, workspaceRootDir, opts) {
|
|
|
8012
8047
|
items.push(record);
|
|
8013
8048
|
}
|
|
8014
8049
|
const filename = `${padZeros(fileIndex, 2)}-${collection.name}.json`;
|
|
8015
|
-
fs29.writeFileSync(
|
|
8016
|
-
writtenFiles.push(`${
|
|
8050
|
+
fs29.writeFileSync(path27.join(fixturesDir, filename), JSON.stringify(items, null, 2));
|
|
8051
|
+
writtenFiles.push(`${path27.join(DATA_DIR, "fixtures", filename)} (${items.length} records)`);
|
|
8017
8052
|
fileIndex++;
|
|
8018
8053
|
}
|
|
8019
8054
|
return { writtenFiles, warnings };
|
|
@@ -8161,7 +8196,7 @@ var load2 = new Command63("load").description("load seeds into the database").op
|
|
|
8161
8196
|
|
|
8162
8197
|
// src/commands/seeds/save.ts
|
|
8163
8198
|
import fs30 from "node:fs";
|
|
8164
|
-
import
|
|
8199
|
+
import path28 from "node:path";
|
|
8165
8200
|
import { Command as Command64 } from "commander";
|
|
8166
8201
|
var padZeros2 = (num, length) => num.toString().padStart(length, "0");
|
|
8167
8202
|
function filterSystemFields(record, systemFieldNames) {
|
|
@@ -8184,7 +8219,7 @@ var save = new Command64("save").description("save the current data as seeds").o
|
|
|
8184
8219
|
fs30.mkdirSync(seedsPath, { recursive: true });
|
|
8185
8220
|
if (opts.force) {
|
|
8186
8221
|
for (const file of fs30.readdirSync(seedsPath)) {
|
|
8187
|
-
if (file.endsWith(".json")) fs30.unlinkSync(
|
|
8222
|
+
if (file.endsWith(".json")) fs30.unlinkSync(path28.join(seedsPath, file));
|
|
8188
8223
|
}
|
|
8189
8224
|
}
|
|
8190
8225
|
const saved = [];
|
|
@@ -8213,12 +8248,12 @@ var save = new Command64("save").description("save the current data as seeds").o
|
|
|
8213
8248
|
const filtered = records.map(
|
|
8214
8249
|
(r) => filterSystemFields(r, systemFieldNames)
|
|
8215
8250
|
);
|
|
8216
|
-
const relativeSeedPath =
|
|
8251
|
+
const relativeSeedPath = path28.join(
|
|
8217
8252
|
DATA_DIR,
|
|
8218
8253
|
"seeds",
|
|
8219
8254
|
`${padZeros2(count, 2)}-${collectionName}.json`
|
|
8220
8255
|
);
|
|
8221
|
-
const seedPath =
|
|
8256
|
+
const seedPath = path28.join(workspaceRootDir, relativeSeedPath);
|
|
8222
8257
|
fs30.writeFileSync(seedPath, JSON.stringify(filtered, null, 2));
|
|
8223
8258
|
saved.push(`${relativeSeedPath} (${filtered.length} records)`);
|
|
8224
8259
|
count++;
|
|
@@ -8357,7 +8392,7 @@ import { Command as Command75 } from "commander";
|
|
|
8357
8392
|
import { Command as Command70 } from "commander";
|
|
8358
8393
|
|
|
8359
8394
|
// src/lib/migrate.ts
|
|
8360
|
-
import
|
|
8395
|
+
import path29 from "node:path";
|
|
8361
8396
|
import process23 from "node:process";
|
|
8362
8397
|
import { x as x2 } from "tinyexec";
|
|
8363
8398
|
async function runPocketbaseMigrate(args) {
|
|
@@ -8368,9 +8403,9 @@ async function runPocketbaseMigrate(args) {
|
|
|
8368
8403
|
binaryPath,
|
|
8369
8404
|
[
|
|
8370
8405
|
"--dir",
|
|
8371
|
-
|
|
8406
|
+
path29.join(cwd, DATA_DIR),
|
|
8372
8407
|
"--migrationsDir",
|
|
8373
|
-
|
|
8408
|
+
path29.join(cwd, MIGRATIONS_DIR),
|
|
8374
8409
|
"migrate",
|
|
8375
8410
|
...args
|
|
8376
8411
|
],
|
|
@@ -8419,7 +8454,7 @@ var down = new Command71("down").alias("rollback").description("revert the last
|
|
|
8419
8454
|
|
|
8420
8455
|
// src/commands/migrate/create.ts
|
|
8421
8456
|
import fs31 from "node:fs";
|
|
8422
|
-
import
|
|
8457
|
+
import path30 from "node:path";
|
|
8423
8458
|
import process24 from "node:process";
|
|
8424
8459
|
import { Command as Command72 } from "commander";
|
|
8425
8460
|
var create2 = new Command72("create").alias("new").description("create a new blank migration").argument("<name>", "migration name (snake_case)").configureHelp(helpConfig).action(
|
|
@@ -8431,7 +8466,7 @@ var create2 = new Command72("create").alias("new").description("create a new bla
|
|
|
8431
8466
|
const added = [...after].filter((f) => !before.has(f));
|
|
8432
8467
|
reportResult({
|
|
8433
8468
|
summary: `Created blank migration ${name}.`,
|
|
8434
|
-
filesCreated: added.map((f) =>
|
|
8469
|
+
filesCreated: added.map((f) => path30.join(MIGRATIONS_DIR, f)),
|
|
8435
8470
|
nextSteps: [
|
|
8436
8471
|
`Open the new file in ${MIGRATIONS_DIR}/ and fill in the up/down handlers.`,
|
|
8437
8472
|
"Run `vela migrate up` to apply the migration once the handlers are written."
|
|
@@ -8440,14 +8475,14 @@ var create2 = new Command72("create").alias("new").description("create a new bla
|
|
|
8440
8475
|
}, "Failed to create migration.")
|
|
8441
8476
|
);
|
|
8442
8477
|
function listMigrationFiles(cwd) {
|
|
8443
|
-
const dir =
|
|
8478
|
+
const dir = path30.join(cwd, MIGRATIONS_DIR);
|
|
8444
8479
|
if (!fs31.existsSync(dir)) return /* @__PURE__ */ new Set();
|
|
8445
8480
|
return new Set(fs31.readdirSync(dir).filter((f) => /\.[jt]s$/.test(f)));
|
|
8446
8481
|
}
|
|
8447
8482
|
|
|
8448
8483
|
// src/commands/migrate/collections.ts
|
|
8449
8484
|
import fs32 from "node:fs";
|
|
8450
|
-
import
|
|
8485
|
+
import path31 from "node:path";
|
|
8451
8486
|
import process25 from "node:process";
|
|
8452
8487
|
import { Command as Command73 } from "commander";
|
|
8453
8488
|
var collections = new Command73("collections").alias("snapshot").description("snapshot local collections into a new migration").configureHelp(helpConfig).action(
|
|
@@ -8465,7 +8500,7 @@ var collections = new Command73("collections").alias("snapshot").description("sn
|
|
|
8465
8500
|
}
|
|
8466
8501
|
reportResult({
|
|
8467
8502
|
summary: "Snapshotted local collections into a new migration.",
|
|
8468
|
-
filesCreated: added.map((f) =>
|
|
8503
|
+
filesCreated: added.map((f) => path31.join(MIGRATIONS_DIR, f)),
|
|
8469
8504
|
nextSteps: [
|
|
8470
8505
|
`Review the generated snapshot in ${MIGRATIONS_DIR}/.`,
|
|
8471
8506
|
"Commit the snapshot so teammates pick up the new schema.",
|
|
@@ -8475,7 +8510,7 @@ var collections = new Command73("collections").alias("snapshot").description("sn
|
|
|
8475
8510
|
}, "Failed to snapshot collections.")
|
|
8476
8511
|
);
|
|
8477
8512
|
function listMigrationFiles2(cwd) {
|
|
8478
|
-
const dir =
|
|
8513
|
+
const dir = path31.join(cwd, MIGRATIONS_DIR);
|
|
8479
8514
|
if (!fs32.existsSync(dir)) return /* @__PURE__ */ new Set();
|
|
8480
8515
|
return new Set(fs32.readdirSync(dir).filter((f) => /\.[jt]s$/.test(f)));
|
|
8481
8516
|
}
|
|
@@ -8497,15 +8532,39 @@ var migrate = new Command75("migrate").description("manage database migrations")
|
|
|
8497
8532
|
|
|
8498
8533
|
// src/commands/dev.ts
|
|
8499
8534
|
import fs33 from "node:fs";
|
|
8500
|
-
import
|
|
8535
|
+
import path33 from "node:path";
|
|
8501
8536
|
import process27 from "node:process";
|
|
8502
8537
|
import { performance } from "node:perf_hooks";
|
|
8503
8538
|
import { Command as Command76, InvalidArgumentError as InvalidArgumentError4 } from "commander";
|
|
8504
8539
|
import pc15 from "picocolors";
|
|
8505
8540
|
import PocketBase4 from "pocketbase";
|
|
8506
8541
|
|
|
8542
|
+
// src/lib/pocketbase-log-filter.ts
|
|
8543
|
+
import { Transform } from "node:stream";
|
|
8544
|
+
var ANSI = /\x1b\[[0-9;]*m/g;
|
|
8545
|
+
var AUTH_LOOKUP = /^\[\d+(?:\.\d+)?ms\] SELECT [`"]?_superusers[`"]?\.\* FROM [`"]?_superusers[`"]? WHERE [`"]?_superusers[`"]?\.[`"]?id[`"]?\s*=\s*'[^']*' LIMIT 1$/;
|
|
8546
|
+
function isAuthLookupLine(line) {
|
|
8547
|
+
return AUTH_LOOKUP.test(line.replace(ANSI, "").trim());
|
|
8548
|
+
}
|
|
8549
|
+
function createPocketbaseLogFilter() {
|
|
8550
|
+
let pending = "";
|
|
8551
|
+
return new Transform({
|
|
8552
|
+
transform(chunk, _encoding, callback) {
|
|
8553
|
+
const lines = (pending + chunk.toString()).split("\n");
|
|
8554
|
+
pending = lines.pop() ?? "";
|
|
8555
|
+
const kept = lines.filter((line) => !isAuthLookupLine(line));
|
|
8556
|
+
callback(null, kept.length ? kept.join("\n") + "\n" : void 0);
|
|
8557
|
+
},
|
|
8558
|
+
flush(callback) {
|
|
8559
|
+
const rest = pending;
|
|
8560
|
+
pending = "";
|
|
8561
|
+
callback(null, rest && !isAuthLookupLine(rest) ? rest : void 0);
|
|
8562
|
+
}
|
|
8563
|
+
});
|
|
8564
|
+
}
|
|
8565
|
+
|
|
8507
8566
|
// src/lib/vite.ts
|
|
8508
|
-
import
|
|
8567
|
+
import path32 from "node:path";
|
|
8509
8568
|
import process26 from "node:process";
|
|
8510
8569
|
import { createRequire as createRequire2 } from "node:module";
|
|
8511
8570
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
@@ -8525,7 +8584,7 @@ function viteVersionError(version) {
|
|
|
8525
8584
|
}
|
|
8526
8585
|
function resolveProjectVite(cwd) {
|
|
8527
8586
|
try {
|
|
8528
|
-
return createRequire2(
|
|
8587
|
+
return createRequire2(path32.join(cwd, "package.json")).resolve("vite");
|
|
8529
8588
|
} catch {
|
|
8530
8589
|
return null;
|
|
8531
8590
|
}
|
|
@@ -8549,13 +8608,13 @@ function parsePort(value) {
|
|
|
8549
8608
|
}
|
|
8550
8609
|
return port;
|
|
8551
8610
|
}
|
|
8552
|
-
var dev = new Command76("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) => {
|
|
8611
|
+
var dev = new Command76("dev").description("start the development server").option("--open [path]", "open the app in a browser once the server is ready").option("--host [host]", "expose the server on the network").option("--port <port>", "port to listen on", parsePort).option("--strictPort", "exit if the port is already in use instead of taking the next one").option("--cors", "enable CORS").option("--force", "re-bundle dependencies, ignoring the optimizer cache").option("--all-sql", "also print the auth lookup PocketBase runs on every request").configureHelp(helpConfig).action(async (options) => {
|
|
8553
8612
|
const cwd = process27.cwd();
|
|
8554
8613
|
process27.env.VELA_DATA_DIR ??= localDataDir(cwd);
|
|
8555
8614
|
const startTime = performance.now();
|
|
8556
8615
|
const { createServer, version } = await loadVite(cwd);
|
|
8557
|
-
const viteMetadataDir =
|
|
8558
|
-
const viteMetadataFile =
|
|
8616
|
+
const viteMetadataDir = path33.join(cwd, "node_modules", ".vite");
|
|
8617
|
+
const viteMetadataFile = path33.join(viteMetadataDir, "_pocketbase_metadata.json");
|
|
8559
8618
|
let pbProc;
|
|
8560
8619
|
const backend3 = hasBackend(cwd);
|
|
8561
8620
|
const needsStart = backend3 && !process27.env.POCKETBASE_URL;
|
|
@@ -8564,17 +8623,18 @@ var dev = new Command76("dev").description("start the development server").optio
|
|
|
8564
8623
|
if (fs33.existsSync(viteMetadataFile)) fs33.rmSync(viteMetadataFile);
|
|
8565
8624
|
};
|
|
8566
8625
|
if (needsStart) {
|
|
8567
|
-
const dataDir2 =
|
|
8626
|
+
const dataDir2 = path33.join(cwd, DATA_DIR);
|
|
8568
8627
|
const started = await startPocketbaseServe({
|
|
8569
8628
|
dataDir: dataDir2,
|
|
8570
8629
|
migrationsDir: MIGRATIONS_DIR,
|
|
8571
|
-
hooksDir:
|
|
8630
|
+
hooksDir: path33.join(dataDir2, "hooks"),
|
|
8572
8631
|
dev: true,
|
|
8573
8632
|
stdio: "pipe"
|
|
8574
8633
|
});
|
|
8575
8634
|
pbProc = started.proc;
|
|
8576
8635
|
process27.env.POCKETBASE_URL = started.url;
|
|
8577
|
-
pbProc.stdout?.pipe(process27.stdout);
|
|
8636
|
+
if (options.allSql) pbProc.stdout?.pipe(process27.stdout);
|
|
8637
|
+
else pbProc.stdout?.pipe(createPocketbaseLogFilter()).pipe(process27.stdout);
|
|
8578
8638
|
pbProc.stderr?.pipe(process27.stderr);
|
|
8579
8639
|
pbProc.on("error", (err) => console.error("PocketBase error:", err));
|
|
8580
8640
|
pbProc.on("exit", (code) => console.log(`PocketBase exited with code ${code}`));
|
|
@@ -8632,9 +8692,9 @@ var dev = new Command76("dev").description("start the development server").optio
|
|
|
8632
8692
|
});
|
|
8633
8693
|
async function startWatchingTypes(cwd, pb) {
|
|
8634
8694
|
const { processTypes } = await import("@velastack/pocketbase-codegen");
|
|
8635
|
-
const typesDir =
|
|
8636
|
-
const pocketbaseDir =
|
|
8637
|
-
const pocketbaseTypes =
|
|
8695
|
+
const typesDir = path33.resolve(cwd, ".svelte-kit", "types");
|
|
8696
|
+
const pocketbaseDir = path33.join(typesDir, "pocketbase");
|
|
8697
|
+
const pocketbaseTypes = path33.join(pocketbaseDir, "$types.d.ts");
|
|
8638
8698
|
const regenerate = () => processTypes(pb, typesDir).catch(() => {
|
|
8639
8699
|
});
|
|
8640
8700
|
await regenerate();
|
|
@@ -8656,7 +8716,7 @@ async function startWatchingTypes(cwd, pb) {
|
|
|
8656
8716
|
|
|
8657
8717
|
// src/commands/build.ts
|
|
8658
8718
|
import fs34 from "node:fs";
|
|
8659
|
-
import
|
|
8719
|
+
import path34 from "node:path";
|
|
8660
8720
|
import process29 from "node:process";
|
|
8661
8721
|
import { Command as Command77 } from "commander";
|
|
8662
8722
|
import * as p42 from "@clack/prompts";
|
|
@@ -8694,7 +8754,7 @@ function splitHosts(value) {
|
|
|
8694
8754
|
}
|
|
8695
8755
|
|
|
8696
8756
|
// src/commands/build.ts
|
|
8697
|
-
var PRERENDERED_DIR =
|
|
8757
|
+
var PRERENDERED_DIR = path34.join(".svelte-kit", "output", "prerendered");
|
|
8698
8758
|
var build = new Command77("build").description("build the app").configureHelp(helpConfig).option("-t, --target <target>", "which copy of the app to build for", PRODUCTION_TARGET).action(async (options) => {
|
|
8699
8759
|
const cwd = process29.cwd();
|
|
8700
8760
|
applyBuildEnv(cwd);
|
|
@@ -8707,11 +8767,11 @@ var build = new Command77("build").description("build the app").configureHelp(he
|
|
|
8707
8767
|
};
|
|
8708
8768
|
if (needsStart) {
|
|
8709
8769
|
await ensureSuperuser(cwd);
|
|
8710
|
-
const dataDir2 =
|
|
8770
|
+
const dataDir2 = path34.join(cwd, DATA_DIR);
|
|
8711
8771
|
const started = await startPocketbaseServe({
|
|
8712
8772
|
dataDir: dataDir2,
|
|
8713
8773
|
migrationsDir: MIGRATIONS_DIR,
|
|
8714
|
-
hooksDir:
|
|
8774
|
+
hooksDir: path34.join(dataDir2, "hooks"),
|
|
8715
8775
|
dev: true
|
|
8716
8776
|
});
|
|
8717
8777
|
pbProc = started.proc;
|
|
@@ -8750,7 +8810,7 @@ async function originForBuild(cwd, target) {
|
|
|
8750
8810
|
}
|
|
8751
8811
|
}
|
|
8752
8812
|
function warnIfPrerendered(cwd) {
|
|
8753
|
-
const dir =
|
|
8813
|
+
const dir = path34.join(cwd, PRERENDERED_DIR);
|
|
8754
8814
|
if (!fs34.existsSync(dir) || fs34.readdirSync(dir).length === 0) return;
|
|
8755
8815
|
p42.log.warn(
|
|
8756
8816
|
`Prerendered pages were built with no domain configured, so their canonical
|
|
@@ -8761,7 +8821,7 @@ Set one with ${pc16.cyan("vela deploy --domain example.com")}, or pass ${pc16.cy
|
|
|
8761
8821
|
}
|
|
8762
8822
|
|
|
8763
8823
|
// src/commands/preview.ts
|
|
8764
|
-
import
|
|
8824
|
+
import path35 from "node:path";
|
|
8765
8825
|
import process30 from "node:process";
|
|
8766
8826
|
import { Command as Command78 } from "commander";
|
|
8767
8827
|
import { x as x4 } from "tinyexec";
|
|
@@ -8776,11 +8836,11 @@ var preview = new Command78("preview").description("preview the built app").conf
|
|
|
8776
8836
|
if (pbProc?.pid) pbProc.kill();
|
|
8777
8837
|
};
|
|
8778
8838
|
if (needsStart) {
|
|
8779
|
-
const dataDir2 =
|
|
8839
|
+
const dataDir2 = path35.join(cwd, DATA_DIR);
|
|
8780
8840
|
const started = await startPocketbaseServe({
|
|
8781
8841
|
dataDir: dataDir2,
|
|
8782
8842
|
migrationsDir: MIGRATIONS_DIR,
|
|
8783
|
-
hooksDir:
|
|
8843
|
+
hooksDir: path35.join(dataDir2, "hooks"),
|
|
8784
8844
|
dev: true
|
|
8785
8845
|
});
|
|
8786
8846
|
pbProc = started.proc;
|
|
@@ -8806,12 +8866,12 @@ var preview = new Command78("preview").description("preview the built app").conf
|
|
|
8806
8866
|
});
|
|
8807
8867
|
|
|
8808
8868
|
// src/commands/sync.ts
|
|
8809
|
-
import
|
|
8869
|
+
import path36 from "node:path";
|
|
8810
8870
|
import { Command as Command79 } from "commander";
|
|
8811
8871
|
var sync = new Command79("sync").description("sync types from the database").configureHelp(helpConfig).action(
|
|
8812
8872
|
() => runCommand(async () => {
|
|
8813
8873
|
const { workspaceRootDir } = await getWorkspace();
|
|
8814
|
-
const typesDir =
|
|
8874
|
+
const typesDir = path36.join(workspaceRootDir, ".svelte-kit", "types");
|
|
8815
8875
|
const { processTypes } = await import("@velastack/pocketbase-codegen");
|
|
8816
8876
|
await withPocketbase(workspaceRootDir, async (pb) => {
|
|
8817
8877
|
await processTypes(pb, typesDir);
|
|
@@ -8873,7 +8933,7 @@ var provision = addSshOptions(
|
|
|
8873
8933
|
);
|
|
8874
8934
|
|
|
8875
8935
|
// src/commands/deploy.ts
|
|
8876
|
-
import
|
|
8936
|
+
import path39 from "node:path";
|
|
8877
8937
|
import fs37 from "node:fs";
|
|
8878
8938
|
import { Command as Command81, Option as Option2 } from "commander";
|
|
8879
8939
|
import * as p44 from "@clack/prompts";
|
|
@@ -8882,12 +8942,12 @@ import * as v8 from "valibot";
|
|
|
8882
8942
|
|
|
8883
8943
|
// src/lib/pocketbase-settings.ts
|
|
8884
8944
|
import fs35 from "node:fs";
|
|
8885
|
-
import
|
|
8945
|
+
import path37 from "node:path";
|
|
8886
8946
|
import process31 from "node:process";
|
|
8887
8947
|
import PocketBase5 from "pocketbase";
|
|
8888
8948
|
var COPIED_KEYS = ["appName", "senderName", "senderAddress"];
|
|
8889
8949
|
async function readLocalMeta(cwd) {
|
|
8890
|
-
const dataDir2 =
|
|
8950
|
+
const dataDir2 = path37.join(cwd, DATA_DIR);
|
|
8891
8951
|
if (!fs35.existsSync(dataDir2)) return null;
|
|
8892
8952
|
const email3 = process31.env.POCKETBASE_SUPERUSER_EMAIL;
|
|
8893
8953
|
const password11 = process31.env.POCKETBASE_SUPERUSER_PASSWORD;
|
|
@@ -8897,7 +8957,7 @@ async function readLocalMeta(cwd) {
|
|
|
8897
8957
|
const started = await startPocketbaseServe({
|
|
8898
8958
|
dataDir: dataDir2,
|
|
8899
8959
|
migrationsDir: MIGRATIONS_DIR,
|
|
8900
|
-
hooksDir:
|
|
8960
|
+
hooksDir: path37.join(dataDir2, "hooks")
|
|
8901
8961
|
});
|
|
8902
8962
|
proc = started.proc;
|
|
8903
8963
|
const pb = new PocketBase5(started.url);
|
|
@@ -8940,7 +9000,7 @@ async function seedRemoteMeta(session, instance, local, appURL) {
|
|
|
8940
9000
|
|
|
8941
9001
|
// src/lib/adapter.ts
|
|
8942
9002
|
import fs36 from "node:fs";
|
|
8943
|
-
import
|
|
9003
|
+
import path38 from "node:path";
|
|
8944
9004
|
import {
|
|
8945
9005
|
Project as Project2,
|
|
8946
9006
|
QuoteKind as QuoteKind2,
|
|
@@ -8996,7 +9056,7 @@ function resolveKitTarget(root) {
|
|
|
8996
9056
|
}
|
|
8997
9057
|
const sveltePath = probeFirstExisting(root, SVELTE_CONFIG_CANDIDATES);
|
|
8998
9058
|
if (sveltePath) {
|
|
8999
|
-
const name =
|
|
9059
|
+
const name = path38.basename(sveltePath);
|
|
9000
9060
|
if (sveltePath.endsWith(".cjs")) {
|
|
9001
9061
|
throw new AdapterError(`${name} is CommonJS, which vela does not edit.`);
|
|
9002
9062
|
}
|
|
@@ -9016,7 +9076,7 @@ function resolveKitTarget(root) {
|
|
|
9016
9076
|
};
|
|
9017
9077
|
}
|
|
9018
9078
|
if (vite?.sveltekitCall) {
|
|
9019
|
-
const name =
|
|
9079
|
+
const name = path38.basename(vite.filePath);
|
|
9020
9080
|
if (vite.nonObjectArg) {
|
|
9021
9081
|
throw new AdapterError(`${name} passes sveltekit() something other than an object literal.`);
|
|
9022
9082
|
}
|
|
@@ -9069,7 +9129,7 @@ function inspectAdapter(target) {
|
|
|
9069
9129
|
async function ensureNodeAdapter(root, { install = true } = {}) {
|
|
9070
9130
|
const target = resolveKitTarget(root);
|
|
9071
9131
|
const { info, importDecl } = inspectAdapter(target);
|
|
9072
|
-
const name =
|
|
9132
|
+
const name = path38.basename(target.filePath);
|
|
9073
9133
|
const outcome = {
|
|
9074
9134
|
previous: info.kind,
|
|
9075
9135
|
removedDeps: [],
|
|
@@ -9102,7 +9162,7 @@ vela deploy runs the app as a Node server, which needs ${ADAPTER_NODE}:`
|
|
|
9102
9162
|
break;
|
|
9103
9163
|
}
|
|
9104
9164
|
if (outcome.configFile) saveTarget(target);
|
|
9105
|
-
const pkgPath =
|
|
9165
|
+
const pkgPath = path38.join(root, "package.json");
|
|
9106
9166
|
if (fs36.existsSync(pkgPath)) {
|
|
9107
9167
|
const pkg = readPackageJson(pkgPath);
|
|
9108
9168
|
const { changed, removed } = adoptNodeAdapter(pkg);
|
|
@@ -9155,7 +9215,7 @@ function addAdapter(target) {
|
|
|
9155
9215
|
const taken = importOf(target.sourceFile, "adapter") ?? target.sourceFile.getVariableDeclaration("adapter");
|
|
9156
9216
|
if (taken) {
|
|
9157
9217
|
throw new AdapterError(
|
|
9158
|
-
`${
|
|
9218
|
+
`${path38.basename(target.filePath)} already binds the name \`adapter\` to something that is not the SvelteKit adapter.`
|
|
9159
9219
|
);
|
|
9160
9220
|
}
|
|
9161
9221
|
target.sourceFile.addImportDeclaration({
|
|
@@ -9566,7 +9626,7 @@ function isDirectory(target) {
|
|
|
9566
9626
|
async function reportEmptyEnvironment(session, instance, workspaceRootDir) {
|
|
9567
9627
|
const remote = await readRemoteEnv(session, instance);
|
|
9568
9628
|
if (Object.keys(remote).length > 0) return;
|
|
9569
|
-
if (!fs37.existsSync(
|
|
9629
|
+
if (!fs37.existsSync(path39.join(workspaceRootDir, ".env"))) return;
|
|
9570
9630
|
p44.log.warn(
|
|
9571
9631
|
`This app has no production environment variables yet.
|
|
9572
9632
|
|
|
@@ -9584,7 +9644,7 @@ async function serverTimeOrLocal(session) {
|
|
|
9584
9644
|
}
|
|
9585
9645
|
|
|
9586
9646
|
// src/commands/link.ts
|
|
9587
|
-
import
|
|
9647
|
+
import path40 from "node:path";
|
|
9588
9648
|
import process32 from "node:process";
|
|
9589
9649
|
import { Command as Command82 } from "commander";
|
|
9590
9650
|
import * as p45 from "@clack/prompts";
|
|
@@ -9647,12 +9707,12 @@ async function promptProjectName(workspaceRootDir) {
|
|
|
9647
9707
|
}
|
|
9648
9708
|
function defaultProjectName2(workspaceRootDir) {
|
|
9649
9709
|
try {
|
|
9650
|
-
const pkg = readPackageJson(
|
|
9710
|
+
const pkg = readPackageJson(path40.join(workspaceRootDir, "package.json"));
|
|
9651
9711
|
const name = pkg.name;
|
|
9652
9712
|
if (typeof name === "string" && name.trim()) return name.trim();
|
|
9653
9713
|
} catch {
|
|
9654
9714
|
}
|
|
9655
|
-
return
|
|
9715
|
+
return path40.basename(workspaceRootDir);
|
|
9656
9716
|
}
|
|
9657
9717
|
|
|
9658
9718
|
// src/commands/env.ts
|
|
@@ -9784,7 +9844,7 @@ var envUnset = addTargetOptions(
|
|
|
9784
9844
|
|
|
9785
9845
|
// src/commands/env/import.ts
|
|
9786
9846
|
import fs38 from "node:fs";
|
|
9787
|
-
import
|
|
9847
|
+
import path41 from "node:path";
|
|
9788
9848
|
import process34 from "node:process";
|
|
9789
9849
|
import { Command as Command86 } from "commander";
|
|
9790
9850
|
import * as p49 from "@clack/prompts";
|
|
@@ -9830,7 +9890,7 @@ var envImport = addTargetOptions(
|
|
|
9830
9890
|
)
|
|
9831
9891
|
);
|
|
9832
9892
|
function resolve(file) {
|
|
9833
|
-
return
|
|
9893
|
+
return path41.resolve(process34.cwd(), file);
|
|
9834
9894
|
}
|
|
9835
9895
|
function read(resolved, shown) {
|
|
9836
9896
|
if (!fs38.existsSync(resolved)) throw new Error(`${shown} does not exist.`);
|
|
@@ -10112,7 +10172,7 @@ import { Command as Command98 } from "commander";
|
|
|
10112
10172
|
|
|
10113
10173
|
// src/commands/backup/create.ts
|
|
10114
10174
|
import fs39 from "node:fs";
|
|
10115
|
-
import
|
|
10175
|
+
import path42 from "node:path";
|
|
10116
10176
|
import { Command as Command93 } from "commander";
|
|
10117
10177
|
import * as p53 from "@clack/prompts";
|
|
10118
10178
|
import pc26 from "picocolors";
|
|
@@ -10266,12 +10326,12 @@ Your bucket's own versioning is what protects the uploaded files.`
|
|
|
10266
10326
|
}, "Failed to create the backup.")
|
|
10267
10327
|
);
|
|
10268
10328
|
async function download(ctx, key, outputDir) {
|
|
10269
|
-
const dir =
|
|
10329
|
+
const dir = path42.resolve(ctx.workspaceRootDir, outputDir);
|
|
10270
10330
|
fs39.mkdirSync(dir, { recursive: true });
|
|
10271
|
-
const destination =
|
|
10331
|
+
const destination = path42.join(dir, key);
|
|
10272
10332
|
if (!ctx.session) {
|
|
10273
|
-
fs39.copyFileSync(
|
|
10274
|
-
return
|
|
10333
|
+
fs39.copyFileSync(path42.join(ctx.workspaceRootDir, "data", "backups", key), destination);
|
|
10334
|
+
return path42.relative(ctx.workspaceRootDir, destination);
|
|
10275
10335
|
}
|
|
10276
10336
|
const spinner8 = p53.spinner();
|
|
10277
10337
|
spinner8.start(`Downloading ${key}`);
|
|
@@ -10282,7 +10342,7 @@ async function download(ctx, key, outputDir) {
|
|
|
10282
10342
|
throw error;
|
|
10283
10343
|
}
|
|
10284
10344
|
spinner8.stop(`Downloaded ${key}`);
|
|
10285
|
-
return
|
|
10345
|
+
return path42.relative(ctx.workspaceRootDir, destination);
|
|
10286
10346
|
}
|
|
10287
10347
|
|
|
10288
10348
|
// src/commands/backup/list.ts
|
|
@@ -10317,7 +10377,7 @@ Take one with ${pc27.cyan("vela backup create")}.`
|
|
|
10317
10377
|
|
|
10318
10378
|
// src/commands/backup/download.ts
|
|
10319
10379
|
import fs40 from "node:fs";
|
|
10320
|
-
import
|
|
10380
|
+
import path43 from "node:path";
|
|
10321
10381
|
import { Command as Command95 } from "commander";
|
|
10322
10382
|
import * as p55 from "@clack/prompts";
|
|
10323
10383
|
import pc28 from "picocolors";
|
|
@@ -10344,11 +10404,11 @@ Run ${pc28.cyan("vela backup list")} to see what it does have.`
|
|
|
10344
10404
|
Fetch it from the bucket directly \u2014 vela does not hold its credentials.`
|
|
10345
10405
|
);
|
|
10346
10406
|
}
|
|
10347
|
-
const dir =
|
|
10407
|
+
const dir = path43.resolve(ctx.workspaceRootDir, options.output);
|
|
10348
10408
|
fs40.mkdirSync(dir, { recursive: true });
|
|
10349
|
-
const destination =
|
|
10409
|
+
const destination = path43.join(dir, key);
|
|
10350
10410
|
if (!ctx.session) {
|
|
10351
|
-
fs40.copyFileSync(
|
|
10411
|
+
fs40.copyFileSync(path43.join(ctx.workspaceRootDir, "data", "backups", key), destination);
|
|
10352
10412
|
} else {
|
|
10353
10413
|
const spinner8 = p55.spinner();
|
|
10354
10414
|
spinner8.start(`Downloading ${key} (${formatBytes(found.size)})`);
|
|
@@ -10362,7 +10422,7 @@ Fetch it from the bucket directly \u2014 vela does not hold its credentials.`
|
|
|
10362
10422
|
}
|
|
10363
10423
|
reportResult({
|
|
10364
10424
|
summary: `Saved ${key} from ${ctx.targetName}.`,
|
|
10365
|
-
filesCreated: [
|
|
10425
|
+
filesCreated: [path43.relative(ctx.workspaceRootDir, destination)]
|
|
10366
10426
|
});
|
|
10367
10427
|
});
|
|
10368
10428
|
}, "Failed to download the backup.")
|
|
@@ -10458,7 +10518,7 @@ var backup = new Command98("backup").description("back up the database and uploa
|
|
|
10458
10518
|
|
|
10459
10519
|
// src/commands/restore.ts
|
|
10460
10520
|
import fs41 from "node:fs";
|
|
10461
|
-
import
|
|
10521
|
+
import path44 from "node:path";
|
|
10462
10522
|
import process37 from "node:process";
|
|
10463
10523
|
import { Command as Command99 } from "commander";
|
|
10464
10524
|
import * as p58 from "@clack/prompts";
|
|
@@ -10504,7 +10564,7 @@ var restore = addLockWaitOption(
|
|
|
10504
10564
|
});
|
|
10505
10565
|
p58.log.success(
|
|
10506
10566
|
`Restored ${pc31.cyan(`${ctx.appName} (${ctx.targetName})`)} from ${pc31.cyan(
|
|
10507
|
-
local ?
|
|
10567
|
+
local ? path44.basename(local) : key
|
|
10508
10568
|
)}.`
|
|
10509
10569
|
);
|
|
10510
10570
|
if (result?.storageCarriedOver) {
|
|
@@ -10570,21 +10630,21 @@ Take one with ${pc31.cyan("vela backup create")}, or pass the path to an archive
|
|
|
10570
10630
|
}
|
|
10571
10631
|
async function stage(ctx, file) {
|
|
10572
10632
|
const dir = remotePaths.restoreStage(ctx.instance);
|
|
10573
|
-
const remote = `${dir}/${
|
|
10633
|
+
const remote = `${dir}/${path44.basename(file)}`;
|
|
10574
10634
|
const spinner8 = p58.spinner();
|
|
10575
|
-
spinner8.start(`Uploading ${
|
|
10635
|
+
spinner8.start(`Uploading ${path44.basename(file)}`);
|
|
10576
10636
|
try {
|
|
10577
10637
|
await ctx.session.script(`mkdir -p "$1"`, { args: [dir] });
|
|
10578
10638
|
await ctx.session.upload([file], dir);
|
|
10579
10639
|
} catch (error) {
|
|
10580
|
-
spinner8.stop(`Could not upload ${
|
|
10640
|
+
spinner8.stop(`Could not upload ${path44.basename(file)}.`);
|
|
10581
10641
|
throw error;
|
|
10582
10642
|
}
|
|
10583
|
-
spinner8.stop(`Uploaded ${
|
|
10643
|
+
spinner8.stop(`Uploaded ${path44.basename(file)}`);
|
|
10584
10644
|
return remote;
|
|
10585
10645
|
}
|
|
10586
10646
|
async function confirm13(appName, targetName, envTag, from) {
|
|
10587
|
-
const what = `${pc31.cyan(`${appName} (${targetName})`)} from ${pc31.cyan(
|
|
10647
|
+
const what = `${pc31.cyan(`${appName} (${targetName})`)} from ${pc31.cyan(path44.basename(from))}`;
|
|
10588
10648
|
if (isProd(envTag)) {
|
|
10589
10649
|
const answer = await p58.text({
|
|
10590
10650
|
message: `This replaces the database and uploads of ${what}. Type the app name to confirm`,
|
|
@@ -10695,7 +10755,7 @@ Release and domain are shown from what this project recorded.`
|
|
|
10695
10755
|
}
|
|
10696
10756
|
|
|
10697
10757
|
// src/commands/test.ts
|
|
10698
|
-
import
|
|
10758
|
+
import path45 from "node:path";
|
|
10699
10759
|
import process38 from "node:process";
|
|
10700
10760
|
import { Command as Command101 } from "commander";
|
|
10701
10761
|
import PocketBase6 from "pocketbase";
|
|
@@ -10708,15 +10768,15 @@ var testServer = new Command101("test:server").description("run server tests").a
|
|
|
10708
10768
|
const cwd = process38.cwd();
|
|
10709
10769
|
const email3 = `test-${Math.random().toString(36).slice(2)}@example.com`;
|
|
10710
10770
|
const password11 = "password";
|
|
10711
|
-
const testDataDir =
|
|
10771
|
+
const testDataDir = path45.join(cwd, "test-data");
|
|
10712
10772
|
fs42.rmSync(testDataDir, { recursive: true, force: true });
|
|
10713
10773
|
const { stop, url } = await launchPocketbase(cwd, {
|
|
10714
10774
|
dir: testDataDir,
|
|
10715
|
-
migrationsDir:
|
|
10775
|
+
migrationsDir: path45.join(cwd, MIGRATIONS_DIR),
|
|
10716
10776
|
// The app's PocketBase hooks (slug generation, personal teams, …) are part
|
|
10717
10777
|
// of its behaviour; the suite runs against the same server dev and build
|
|
10718
10778
|
// start, so it loads them from the same place.
|
|
10719
|
-
hooksDir:
|
|
10779
|
+
hooksDir: path45.join(cwd, DATA_DIR, "hooks"),
|
|
10720
10780
|
email: email3,
|
|
10721
10781
|
password: password11
|
|
10722
10782
|
});
|
|
@@ -10834,7 +10894,7 @@ function stubPagesPlugin() {
|
|
|
10834
10894
|
|
|
10835
10895
|
// src/commands/routes.ts
|
|
10836
10896
|
import fs43 from "node:fs";
|
|
10837
|
-
import
|
|
10897
|
+
import path46 from "node:path";
|
|
10838
10898
|
import { Command as Command102 } from "commander";
|
|
10839
10899
|
var HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
10840
10900
|
"GET",
|
|
@@ -10848,7 +10908,7 @@ var HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
|
10848
10908
|
]);
|
|
10849
10909
|
var routes = new Command102("routes").description("list routes").configureHelp(helpConfig).action(async () => {
|
|
10850
10910
|
const { workspaceRootDir, routesDir } = await getWorkspace();
|
|
10851
|
-
const routesRoot =
|
|
10911
|
+
const routesRoot = path46.join(workspaceRootDir, routesDir);
|
|
10852
10912
|
const found = walk(routesRoot, routesRoot).filter((r) => r.methods.length > 0);
|
|
10853
10913
|
found.sort((a, b) => a.urlPattern.localeCompare(b.urlPattern));
|
|
10854
10914
|
printTable(found);
|
|
@@ -10858,20 +10918,20 @@ function walk(root, dir) {
|
|
|
10858
10918
|
const routes2 = [];
|
|
10859
10919
|
const hasLeaf = entries.some((e) => e.isFile() && isRouteFile(e.name));
|
|
10860
10920
|
if (hasLeaf) {
|
|
10861
|
-
const id = "/" +
|
|
10921
|
+
const id = "/" + path46.relative(root, dir).split(path46.sep).filter(Boolean).join("/");
|
|
10862
10922
|
const urlPattern = id.replace(/\([^)]+\)\/?/g, "").replace(/\/$/, "") || "/";
|
|
10863
10923
|
const methods = /* @__PURE__ */ new Set();
|
|
10864
10924
|
for (const entry of entries) {
|
|
10865
10925
|
if (!entry.isFile()) continue;
|
|
10866
10926
|
if (entry.name.endsWith("+page.svelte")) methods.add("GET");
|
|
10867
10927
|
if (entry.name.endsWith("+server.ts") || entry.name.endsWith("+server.js") || entry.name.endsWith("+page.server.ts") || entry.name.endsWith("+page.server.js")) {
|
|
10868
|
-
extractMethods(
|
|
10928
|
+
extractMethods(path46.join(dir, entry.name)).forEach((m) => methods.add(m));
|
|
10869
10929
|
}
|
|
10870
10930
|
}
|
|
10871
10931
|
routes2.push({ id: id || "/", urlPattern, methods: [...methods] });
|
|
10872
10932
|
}
|
|
10873
10933
|
for (const entry of entries) {
|
|
10874
|
-
if (entry.isDirectory()) routes2.push(...walk(root,
|
|
10934
|
+
if (entry.isDirectory()) routes2.push(...walk(root, path46.join(dir, entry.name)));
|
|
10875
10935
|
}
|
|
10876
10936
|
return routes2;
|
|
10877
10937
|
}
|
|
@@ -11059,7 +11119,7 @@ import pc36 from "picocolors";
|
|
|
11059
11119
|
|
|
11060
11120
|
// src/lib/cms-backend.ts
|
|
11061
11121
|
import { createRequire as createRequire3 } from "node:module";
|
|
11062
|
-
import
|
|
11122
|
+
import path47 from "node:path";
|
|
11063
11123
|
import process41 from "node:process";
|
|
11064
11124
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
11065
11125
|
import pc35 from "picocolors";
|
|
@@ -11067,7 +11127,7 @@ var DEFAULT_PROJECT = "default";
|
|
|
11067
11127
|
async function loadBackendModule(root) {
|
|
11068
11128
|
let entry;
|
|
11069
11129
|
try {
|
|
11070
|
-
entry = createRequire3(
|
|
11130
|
+
entry = createRequire3(path47.join(root, "package.json")).resolve("@velastack/cms/backend");
|
|
11071
11131
|
} catch {
|
|
11072
11132
|
throw new Error(
|
|
11073
11133
|
`@velastack/cms is not installed in this project.
|
|
@@ -11085,8 +11145,8 @@ async function withCmsBackend(fn, cwd = process41.cwd()) {
|
|
|
11085
11145
|
const { createCmsBackend } = await loadBackendModule(root);
|
|
11086
11146
|
const dataDir2 = localDataDir(root);
|
|
11087
11147
|
const backend3 = createCmsBackend({
|
|
11088
|
-
dbPath:
|
|
11089
|
-
uploadDir:
|
|
11148
|
+
dbPath: path47.join(dataDir2, "cms.sqlite"),
|
|
11149
|
+
uploadDir: path47.join(dataDir2, "uploads")
|
|
11090
11150
|
});
|
|
11091
11151
|
try {
|
|
11092
11152
|
return await fn(backend3);
|
|
@@ -11347,14 +11407,14 @@ program.hook("preAction", (_thisCommand, actionCommand) => {
|
|
|
11347
11407
|
if (isStub(actionCommand)) return;
|
|
11348
11408
|
const envRoot = findWorkspaceRoot() ?? process45.cwd();
|
|
11349
11409
|
dotenv2.config({ path: nodePath.join(envRoot, ".env"), quiet: true });
|
|
11350
|
-
const
|
|
11351
|
-
if (NO_BACKEND_COMMMANDS.has(
|
|
11352
|
-
const top =
|
|
11410
|
+
const path48 = getCommandPath(actionCommand);
|
|
11411
|
+
if (NO_BACKEND_COMMMANDS.has(path48)) return;
|
|
11412
|
+
const top = path48.split(" ", 1)[0];
|
|
11353
11413
|
if (NO_BACKEND_COMMMANDS.has(top)) return;
|
|
11354
11414
|
if (!hasBackend()) {
|
|
11355
11415
|
if (BACKEND_OPTIONAL_COMMANDS.has(top)) return;
|
|
11356
11416
|
p67.log.error(
|
|
11357
|
-
`${pc42.cyan(`vela ${
|
|
11417
|
+
`${pc42.cyan(`vela ${path48}`)} needs a backend, and this project does not have one.
|
|
11358
11418
|
|
|
11359
11419
|
Static projects have no database to talk to.
|
|
11360
11420
|
|
|
@@ -11364,7 +11424,7 @@ To add a backend to this project, run ${pc42.cyan("vela bless")}.`
|
|
|
11364
11424
|
p67.cancel("Operation failed.");
|
|
11365
11425
|
process45.exit(1);
|
|
11366
11426
|
}
|
|
11367
|
-
if (SELF_CREDENTIALED_COMMANDS.has(
|
|
11427
|
+
if (SELF_CREDENTIALED_COMMANDS.has(path48)) return;
|
|
11368
11428
|
if (!process45.env.POCKETBASE_SUPERUSER_EMAIL || !process45.env.POCKETBASE_SUPERUSER_PASSWORD) {
|
|
11369
11429
|
p67.log.error(
|
|
11370
11430
|
`PocketBase superuser credentials are required.
|