vela 0.13.2 → 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 +199 -164
- package/dist/bin.js.map +4 -4
- package/package.json +4 -4
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",
|
|
@@ -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,7 +8532,7 @@ 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";
|
|
@@ -8529,7 +8564,7 @@ function createPocketbaseLogFilter() {
|
|
|
8529
8564
|
}
|
|
8530
8565
|
|
|
8531
8566
|
// src/lib/vite.ts
|
|
8532
|
-
import
|
|
8567
|
+
import path32 from "node:path";
|
|
8533
8568
|
import process26 from "node:process";
|
|
8534
8569
|
import { createRequire as createRequire2 } from "node:module";
|
|
8535
8570
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
@@ -8549,7 +8584,7 @@ function viteVersionError(version) {
|
|
|
8549
8584
|
}
|
|
8550
8585
|
function resolveProjectVite(cwd) {
|
|
8551
8586
|
try {
|
|
8552
|
-
return createRequire2(
|
|
8587
|
+
return createRequire2(path32.join(cwd, "package.json")).resolve("vite");
|
|
8553
8588
|
} catch {
|
|
8554
8589
|
return null;
|
|
8555
8590
|
}
|
|
@@ -8578,8 +8613,8 @@ var dev = new Command76("dev").description("start the development server").optio
|
|
|
8578
8613
|
process27.env.VELA_DATA_DIR ??= localDataDir(cwd);
|
|
8579
8614
|
const startTime = performance.now();
|
|
8580
8615
|
const { createServer, version } = await loadVite(cwd);
|
|
8581
|
-
const viteMetadataDir =
|
|
8582
|
-
const viteMetadataFile =
|
|
8616
|
+
const viteMetadataDir = path33.join(cwd, "node_modules", ".vite");
|
|
8617
|
+
const viteMetadataFile = path33.join(viteMetadataDir, "_pocketbase_metadata.json");
|
|
8583
8618
|
let pbProc;
|
|
8584
8619
|
const backend3 = hasBackend(cwd);
|
|
8585
8620
|
const needsStart = backend3 && !process27.env.POCKETBASE_URL;
|
|
@@ -8588,11 +8623,11 @@ var dev = new Command76("dev").description("start the development server").optio
|
|
|
8588
8623
|
if (fs33.existsSync(viteMetadataFile)) fs33.rmSync(viteMetadataFile);
|
|
8589
8624
|
};
|
|
8590
8625
|
if (needsStart) {
|
|
8591
|
-
const dataDir2 =
|
|
8626
|
+
const dataDir2 = path33.join(cwd, DATA_DIR);
|
|
8592
8627
|
const started = await startPocketbaseServe({
|
|
8593
8628
|
dataDir: dataDir2,
|
|
8594
8629
|
migrationsDir: MIGRATIONS_DIR,
|
|
8595
|
-
hooksDir:
|
|
8630
|
+
hooksDir: path33.join(dataDir2, "hooks"),
|
|
8596
8631
|
dev: true,
|
|
8597
8632
|
stdio: "pipe"
|
|
8598
8633
|
});
|
|
@@ -8657,9 +8692,9 @@ var dev = new Command76("dev").description("start the development server").optio
|
|
|
8657
8692
|
});
|
|
8658
8693
|
async function startWatchingTypes(cwd, pb) {
|
|
8659
8694
|
const { processTypes } = await import("@velastack/pocketbase-codegen");
|
|
8660
|
-
const typesDir =
|
|
8661
|
-
const pocketbaseDir =
|
|
8662
|
-
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");
|
|
8663
8698
|
const regenerate = () => processTypes(pb, typesDir).catch(() => {
|
|
8664
8699
|
});
|
|
8665
8700
|
await regenerate();
|
|
@@ -8681,7 +8716,7 @@ async function startWatchingTypes(cwd, pb) {
|
|
|
8681
8716
|
|
|
8682
8717
|
// src/commands/build.ts
|
|
8683
8718
|
import fs34 from "node:fs";
|
|
8684
|
-
import
|
|
8719
|
+
import path34 from "node:path";
|
|
8685
8720
|
import process29 from "node:process";
|
|
8686
8721
|
import { Command as Command77 } from "commander";
|
|
8687
8722
|
import * as p42 from "@clack/prompts";
|
|
@@ -8719,7 +8754,7 @@ function splitHosts(value) {
|
|
|
8719
8754
|
}
|
|
8720
8755
|
|
|
8721
8756
|
// src/commands/build.ts
|
|
8722
|
-
var PRERENDERED_DIR =
|
|
8757
|
+
var PRERENDERED_DIR = path34.join(".svelte-kit", "output", "prerendered");
|
|
8723
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) => {
|
|
8724
8759
|
const cwd = process29.cwd();
|
|
8725
8760
|
applyBuildEnv(cwd);
|
|
@@ -8732,11 +8767,11 @@ var build = new Command77("build").description("build the app").configureHelp(he
|
|
|
8732
8767
|
};
|
|
8733
8768
|
if (needsStart) {
|
|
8734
8769
|
await ensureSuperuser(cwd);
|
|
8735
|
-
const dataDir2 =
|
|
8770
|
+
const dataDir2 = path34.join(cwd, DATA_DIR);
|
|
8736
8771
|
const started = await startPocketbaseServe({
|
|
8737
8772
|
dataDir: dataDir2,
|
|
8738
8773
|
migrationsDir: MIGRATIONS_DIR,
|
|
8739
|
-
hooksDir:
|
|
8774
|
+
hooksDir: path34.join(dataDir2, "hooks"),
|
|
8740
8775
|
dev: true
|
|
8741
8776
|
});
|
|
8742
8777
|
pbProc = started.proc;
|
|
@@ -8775,7 +8810,7 @@ async function originForBuild(cwd, target) {
|
|
|
8775
8810
|
}
|
|
8776
8811
|
}
|
|
8777
8812
|
function warnIfPrerendered(cwd) {
|
|
8778
|
-
const dir =
|
|
8813
|
+
const dir = path34.join(cwd, PRERENDERED_DIR);
|
|
8779
8814
|
if (!fs34.existsSync(dir) || fs34.readdirSync(dir).length === 0) return;
|
|
8780
8815
|
p42.log.warn(
|
|
8781
8816
|
`Prerendered pages were built with no domain configured, so their canonical
|
|
@@ -8786,7 +8821,7 @@ Set one with ${pc16.cyan("vela deploy --domain example.com")}, or pass ${pc16.cy
|
|
|
8786
8821
|
}
|
|
8787
8822
|
|
|
8788
8823
|
// src/commands/preview.ts
|
|
8789
|
-
import
|
|
8824
|
+
import path35 from "node:path";
|
|
8790
8825
|
import process30 from "node:process";
|
|
8791
8826
|
import { Command as Command78 } from "commander";
|
|
8792
8827
|
import { x as x4 } from "tinyexec";
|
|
@@ -8801,11 +8836,11 @@ var preview = new Command78("preview").description("preview the built app").conf
|
|
|
8801
8836
|
if (pbProc?.pid) pbProc.kill();
|
|
8802
8837
|
};
|
|
8803
8838
|
if (needsStart) {
|
|
8804
|
-
const dataDir2 =
|
|
8839
|
+
const dataDir2 = path35.join(cwd, DATA_DIR);
|
|
8805
8840
|
const started = await startPocketbaseServe({
|
|
8806
8841
|
dataDir: dataDir2,
|
|
8807
8842
|
migrationsDir: MIGRATIONS_DIR,
|
|
8808
|
-
hooksDir:
|
|
8843
|
+
hooksDir: path35.join(dataDir2, "hooks"),
|
|
8809
8844
|
dev: true
|
|
8810
8845
|
});
|
|
8811
8846
|
pbProc = started.proc;
|
|
@@ -8831,12 +8866,12 @@ var preview = new Command78("preview").description("preview the built app").conf
|
|
|
8831
8866
|
});
|
|
8832
8867
|
|
|
8833
8868
|
// src/commands/sync.ts
|
|
8834
|
-
import
|
|
8869
|
+
import path36 from "node:path";
|
|
8835
8870
|
import { Command as Command79 } from "commander";
|
|
8836
8871
|
var sync = new Command79("sync").description("sync types from the database").configureHelp(helpConfig).action(
|
|
8837
8872
|
() => runCommand(async () => {
|
|
8838
8873
|
const { workspaceRootDir } = await getWorkspace();
|
|
8839
|
-
const typesDir =
|
|
8874
|
+
const typesDir = path36.join(workspaceRootDir, ".svelte-kit", "types");
|
|
8840
8875
|
const { processTypes } = await import("@velastack/pocketbase-codegen");
|
|
8841
8876
|
await withPocketbase(workspaceRootDir, async (pb) => {
|
|
8842
8877
|
await processTypes(pb, typesDir);
|
|
@@ -8898,7 +8933,7 @@ var provision = addSshOptions(
|
|
|
8898
8933
|
);
|
|
8899
8934
|
|
|
8900
8935
|
// src/commands/deploy.ts
|
|
8901
|
-
import
|
|
8936
|
+
import path39 from "node:path";
|
|
8902
8937
|
import fs37 from "node:fs";
|
|
8903
8938
|
import { Command as Command81, Option as Option2 } from "commander";
|
|
8904
8939
|
import * as p44 from "@clack/prompts";
|
|
@@ -8907,12 +8942,12 @@ import * as v8 from "valibot";
|
|
|
8907
8942
|
|
|
8908
8943
|
// src/lib/pocketbase-settings.ts
|
|
8909
8944
|
import fs35 from "node:fs";
|
|
8910
|
-
import
|
|
8945
|
+
import path37 from "node:path";
|
|
8911
8946
|
import process31 from "node:process";
|
|
8912
8947
|
import PocketBase5 from "pocketbase";
|
|
8913
8948
|
var COPIED_KEYS = ["appName", "senderName", "senderAddress"];
|
|
8914
8949
|
async function readLocalMeta(cwd) {
|
|
8915
|
-
const dataDir2 =
|
|
8950
|
+
const dataDir2 = path37.join(cwd, DATA_DIR);
|
|
8916
8951
|
if (!fs35.existsSync(dataDir2)) return null;
|
|
8917
8952
|
const email3 = process31.env.POCKETBASE_SUPERUSER_EMAIL;
|
|
8918
8953
|
const password11 = process31.env.POCKETBASE_SUPERUSER_PASSWORD;
|
|
@@ -8922,7 +8957,7 @@ async function readLocalMeta(cwd) {
|
|
|
8922
8957
|
const started = await startPocketbaseServe({
|
|
8923
8958
|
dataDir: dataDir2,
|
|
8924
8959
|
migrationsDir: MIGRATIONS_DIR,
|
|
8925
|
-
hooksDir:
|
|
8960
|
+
hooksDir: path37.join(dataDir2, "hooks")
|
|
8926
8961
|
});
|
|
8927
8962
|
proc = started.proc;
|
|
8928
8963
|
const pb = new PocketBase5(started.url);
|
|
@@ -8965,7 +9000,7 @@ async function seedRemoteMeta(session, instance, local, appURL) {
|
|
|
8965
9000
|
|
|
8966
9001
|
// src/lib/adapter.ts
|
|
8967
9002
|
import fs36 from "node:fs";
|
|
8968
|
-
import
|
|
9003
|
+
import path38 from "node:path";
|
|
8969
9004
|
import {
|
|
8970
9005
|
Project as Project2,
|
|
8971
9006
|
QuoteKind as QuoteKind2,
|
|
@@ -9021,7 +9056,7 @@ function resolveKitTarget(root) {
|
|
|
9021
9056
|
}
|
|
9022
9057
|
const sveltePath = probeFirstExisting(root, SVELTE_CONFIG_CANDIDATES);
|
|
9023
9058
|
if (sveltePath) {
|
|
9024
|
-
const name =
|
|
9059
|
+
const name = path38.basename(sveltePath);
|
|
9025
9060
|
if (sveltePath.endsWith(".cjs")) {
|
|
9026
9061
|
throw new AdapterError(`${name} is CommonJS, which vela does not edit.`);
|
|
9027
9062
|
}
|
|
@@ -9041,7 +9076,7 @@ function resolveKitTarget(root) {
|
|
|
9041
9076
|
};
|
|
9042
9077
|
}
|
|
9043
9078
|
if (vite?.sveltekitCall) {
|
|
9044
|
-
const name =
|
|
9079
|
+
const name = path38.basename(vite.filePath);
|
|
9045
9080
|
if (vite.nonObjectArg) {
|
|
9046
9081
|
throw new AdapterError(`${name} passes sveltekit() something other than an object literal.`);
|
|
9047
9082
|
}
|
|
@@ -9094,7 +9129,7 @@ function inspectAdapter(target) {
|
|
|
9094
9129
|
async function ensureNodeAdapter(root, { install = true } = {}) {
|
|
9095
9130
|
const target = resolveKitTarget(root);
|
|
9096
9131
|
const { info, importDecl } = inspectAdapter(target);
|
|
9097
|
-
const name =
|
|
9132
|
+
const name = path38.basename(target.filePath);
|
|
9098
9133
|
const outcome = {
|
|
9099
9134
|
previous: info.kind,
|
|
9100
9135
|
removedDeps: [],
|
|
@@ -9127,7 +9162,7 @@ vela deploy runs the app as a Node server, which needs ${ADAPTER_NODE}:`
|
|
|
9127
9162
|
break;
|
|
9128
9163
|
}
|
|
9129
9164
|
if (outcome.configFile) saveTarget(target);
|
|
9130
|
-
const pkgPath =
|
|
9165
|
+
const pkgPath = path38.join(root, "package.json");
|
|
9131
9166
|
if (fs36.existsSync(pkgPath)) {
|
|
9132
9167
|
const pkg = readPackageJson(pkgPath);
|
|
9133
9168
|
const { changed, removed } = adoptNodeAdapter(pkg);
|
|
@@ -9180,7 +9215,7 @@ function addAdapter(target) {
|
|
|
9180
9215
|
const taken = importOf(target.sourceFile, "adapter") ?? target.sourceFile.getVariableDeclaration("adapter");
|
|
9181
9216
|
if (taken) {
|
|
9182
9217
|
throw new AdapterError(
|
|
9183
|
-
`${
|
|
9218
|
+
`${path38.basename(target.filePath)} already binds the name \`adapter\` to something that is not the SvelteKit adapter.`
|
|
9184
9219
|
);
|
|
9185
9220
|
}
|
|
9186
9221
|
target.sourceFile.addImportDeclaration({
|
|
@@ -9591,7 +9626,7 @@ function isDirectory(target) {
|
|
|
9591
9626
|
async function reportEmptyEnvironment(session, instance, workspaceRootDir) {
|
|
9592
9627
|
const remote = await readRemoteEnv(session, instance);
|
|
9593
9628
|
if (Object.keys(remote).length > 0) return;
|
|
9594
|
-
if (!fs37.existsSync(
|
|
9629
|
+
if (!fs37.existsSync(path39.join(workspaceRootDir, ".env"))) return;
|
|
9595
9630
|
p44.log.warn(
|
|
9596
9631
|
`This app has no production environment variables yet.
|
|
9597
9632
|
|
|
@@ -9609,7 +9644,7 @@ async function serverTimeOrLocal(session) {
|
|
|
9609
9644
|
}
|
|
9610
9645
|
|
|
9611
9646
|
// src/commands/link.ts
|
|
9612
|
-
import
|
|
9647
|
+
import path40 from "node:path";
|
|
9613
9648
|
import process32 from "node:process";
|
|
9614
9649
|
import { Command as Command82 } from "commander";
|
|
9615
9650
|
import * as p45 from "@clack/prompts";
|
|
@@ -9672,12 +9707,12 @@ async function promptProjectName(workspaceRootDir) {
|
|
|
9672
9707
|
}
|
|
9673
9708
|
function defaultProjectName2(workspaceRootDir) {
|
|
9674
9709
|
try {
|
|
9675
|
-
const pkg = readPackageJson(
|
|
9710
|
+
const pkg = readPackageJson(path40.join(workspaceRootDir, "package.json"));
|
|
9676
9711
|
const name = pkg.name;
|
|
9677
9712
|
if (typeof name === "string" && name.trim()) return name.trim();
|
|
9678
9713
|
} catch {
|
|
9679
9714
|
}
|
|
9680
|
-
return
|
|
9715
|
+
return path40.basename(workspaceRootDir);
|
|
9681
9716
|
}
|
|
9682
9717
|
|
|
9683
9718
|
// src/commands/env.ts
|
|
@@ -9809,7 +9844,7 @@ var envUnset = addTargetOptions(
|
|
|
9809
9844
|
|
|
9810
9845
|
// src/commands/env/import.ts
|
|
9811
9846
|
import fs38 from "node:fs";
|
|
9812
|
-
import
|
|
9847
|
+
import path41 from "node:path";
|
|
9813
9848
|
import process34 from "node:process";
|
|
9814
9849
|
import { Command as Command86 } from "commander";
|
|
9815
9850
|
import * as p49 from "@clack/prompts";
|
|
@@ -9855,7 +9890,7 @@ var envImport = addTargetOptions(
|
|
|
9855
9890
|
)
|
|
9856
9891
|
);
|
|
9857
9892
|
function resolve(file) {
|
|
9858
|
-
return
|
|
9893
|
+
return path41.resolve(process34.cwd(), file);
|
|
9859
9894
|
}
|
|
9860
9895
|
function read(resolved, shown) {
|
|
9861
9896
|
if (!fs38.existsSync(resolved)) throw new Error(`${shown} does not exist.`);
|
|
@@ -10137,7 +10172,7 @@ import { Command as Command98 } from "commander";
|
|
|
10137
10172
|
|
|
10138
10173
|
// src/commands/backup/create.ts
|
|
10139
10174
|
import fs39 from "node:fs";
|
|
10140
|
-
import
|
|
10175
|
+
import path42 from "node:path";
|
|
10141
10176
|
import { Command as Command93 } from "commander";
|
|
10142
10177
|
import * as p53 from "@clack/prompts";
|
|
10143
10178
|
import pc26 from "picocolors";
|
|
@@ -10291,12 +10326,12 @@ Your bucket's own versioning is what protects the uploaded files.`
|
|
|
10291
10326
|
}, "Failed to create the backup.")
|
|
10292
10327
|
);
|
|
10293
10328
|
async function download(ctx, key, outputDir) {
|
|
10294
|
-
const dir =
|
|
10329
|
+
const dir = path42.resolve(ctx.workspaceRootDir, outputDir);
|
|
10295
10330
|
fs39.mkdirSync(dir, { recursive: true });
|
|
10296
|
-
const destination =
|
|
10331
|
+
const destination = path42.join(dir, key);
|
|
10297
10332
|
if (!ctx.session) {
|
|
10298
|
-
fs39.copyFileSync(
|
|
10299
|
-
return
|
|
10333
|
+
fs39.copyFileSync(path42.join(ctx.workspaceRootDir, "data", "backups", key), destination);
|
|
10334
|
+
return path42.relative(ctx.workspaceRootDir, destination);
|
|
10300
10335
|
}
|
|
10301
10336
|
const spinner8 = p53.spinner();
|
|
10302
10337
|
spinner8.start(`Downloading ${key}`);
|
|
@@ -10307,7 +10342,7 @@ async function download(ctx, key, outputDir) {
|
|
|
10307
10342
|
throw error;
|
|
10308
10343
|
}
|
|
10309
10344
|
spinner8.stop(`Downloaded ${key}`);
|
|
10310
|
-
return
|
|
10345
|
+
return path42.relative(ctx.workspaceRootDir, destination);
|
|
10311
10346
|
}
|
|
10312
10347
|
|
|
10313
10348
|
// src/commands/backup/list.ts
|
|
@@ -10342,7 +10377,7 @@ Take one with ${pc27.cyan("vela backup create")}.`
|
|
|
10342
10377
|
|
|
10343
10378
|
// src/commands/backup/download.ts
|
|
10344
10379
|
import fs40 from "node:fs";
|
|
10345
|
-
import
|
|
10380
|
+
import path43 from "node:path";
|
|
10346
10381
|
import { Command as Command95 } from "commander";
|
|
10347
10382
|
import * as p55 from "@clack/prompts";
|
|
10348
10383
|
import pc28 from "picocolors";
|
|
@@ -10369,11 +10404,11 @@ Run ${pc28.cyan("vela backup list")} to see what it does have.`
|
|
|
10369
10404
|
Fetch it from the bucket directly \u2014 vela does not hold its credentials.`
|
|
10370
10405
|
);
|
|
10371
10406
|
}
|
|
10372
|
-
const dir =
|
|
10407
|
+
const dir = path43.resolve(ctx.workspaceRootDir, options.output);
|
|
10373
10408
|
fs40.mkdirSync(dir, { recursive: true });
|
|
10374
|
-
const destination =
|
|
10409
|
+
const destination = path43.join(dir, key);
|
|
10375
10410
|
if (!ctx.session) {
|
|
10376
|
-
fs40.copyFileSync(
|
|
10411
|
+
fs40.copyFileSync(path43.join(ctx.workspaceRootDir, "data", "backups", key), destination);
|
|
10377
10412
|
} else {
|
|
10378
10413
|
const spinner8 = p55.spinner();
|
|
10379
10414
|
spinner8.start(`Downloading ${key} (${formatBytes(found.size)})`);
|
|
@@ -10387,7 +10422,7 @@ Fetch it from the bucket directly \u2014 vela does not hold its credentials.`
|
|
|
10387
10422
|
}
|
|
10388
10423
|
reportResult({
|
|
10389
10424
|
summary: `Saved ${key} from ${ctx.targetName}.`,
|
|
10390
|
-
filesCreated: [
|
|
10425
|
+
filesCreated: [path43.relative(ctx.workspaceRootDir, destination)]
|
|
10391
10426
|
});
|
|
10392
10427
|
});
|
|
10393
10428
|
}, "Failed to download the backup.")
|
|
@@ -10483,7 +10518,7 @@ var backup = new Command98("backup").description("back up the database and uploa
|
|
|
10483
10518
|
|
|
10484
10519
|
// src/commands/restore.ts
|
|
10485
10520
|
import fs41 from "node:fs";
|
|
10486
|
-
import
|
|
10521
|
+
import path44 from "node:path";
|
|
10487
10522
|
import process37 from "node:process";
|
|
10488
10523
|
import { Command as Command99 } from "commander";
|
|
10489
10524
|
import * as p58 from "@clack/prompts";
|
|
@@ -10529,7 +10564,7 @@ var restore = addLockWaitOption(
|
|
|
10529
10564
|
});
|
|
10530
10565
|
p58.log.success(
|
|
10531
10566
|
`Restored ${pc31.cyan(`${ctx.appName} (${ctx.targetName})`)} from ${pc31.cyan(
|
|
10532
|
-
local ?
|
|
10567
|
+
local ? path44.basename(local) : key
|
|
10533
10568
|
)}.`
|
|
10534
10569
|
);
|
|
10535
10570
|
if (result?.storageCarriedOver) {
|
|
@@ -10595,21 +10630,21 @@ Take one with ${pc31.cyan("vela backup create")}, or pass the path to an archive
|
|
|
10595
10630
|
}
|
|
10596
10631
|
async function stage(ctx, file) {
|
|
10597
10632
|
const dir = remotePaths.restoreStage(ctx.instance);
|
|
10598
|
-
const remote = `${dir}/${
|
|
10633
|
+
const remote = `${dir}/${path44.basename(file)}`;
|
|
10599
10634
|
const spinner8 = p58.spinner();
|
|
10600
|
-
spinner8.start(`Uploading ${
|
|
10635
|
+
spinner8.start(`Uploading ${path44.basename(file)}`);
|
|
10601
10636
|
try {
|
|
10602
10637
|
await ctx.session.script(`mkdir -p "$1"`, { args: [dir] });
|
|
10603
10638
|
await ctx.session.upload([file], dir);
|
|
10604
10639
|
} catch (error) {
|
|
10605
|
-
spinner8.stop(`Could not upload ${
|
|
10640
|
+
spinner8.stop(`Could not upload ${path44.basename(file)}.`);
|
|
10606
10641
|
throw error;
|
|
10607
10642
|
}
|
|
10608
|
-
spinner8.stop(`Uploaded ${
|
|
10643
|
+
spinner8.stop(`Uploaded ${path44.basename(file)}`);
|
|
10609
10644
|
return remote;
|
|
10610
10645
|
}
|
|
10611
10646
|
async function confirm13(appName, targetName, envTag, from) {
|
|
10612
|
-
const what = `${pc31.cyan(`${appName} (${targetName})`)} from ${pc31.cyan(
|
|
10647
|
+
const what = `${pc31.cyan(`${appName} (${targetName})`)} from ${pc31.cyan(path44.basename(from))}`;
|
|
10613
10648
|
if (isProd(envTag)) {
|
|
10614
10649
|
const answer = await p58.text({
|
|
10615
10650
|
message: `This replaces the database and uploads of ${what}. Type the app name to confirm`,
|
|
@@ -10720,7 +10755,7 @@ Release and domain are shown from what this project recorded.`
|
|
|
10720
10755
|
}
|
|
10721
10756
|
|
|
10722
10757
|
// src/commands/test.ts
|
|
10723
|
-
import
|
|
10758
|
+
import path45 from "node:path";
|
|
10724
10759
|
import process38 from "node:process";
|
|
10725
10760
|
import { Command as Command101 } from "commander";
|
|
10726
10761
|
import PocketBase6 from "pocketbase";
|
|
@@ -10733,15 +10768,15 @@ var testServer = new Command101("test:server").description("run server tests").a
|
|
|
10733
10768
|
const cwd = process38.cwd();
|
|
10734
10769
|
const email3 = `test-${Math.random().toString(36).slice(2)}@example.com`;
|
|
10735
10770
|
const password11 = "password";
|
|
10736
|
-
const testDataDir =
|
|
10771
|
+
const testDataDir = path45.join(cwd, "test-data");
|
|
10737
10772
|
fs42.rmSync(testDataDir, { recursive: true, force: true });
|
|
10738
10773
|
const { stop, url } = await launchPocketbase(cwd, {
|
|
10739
10774
|
dir: testDataDir,
|
|
10740
|
-
migrationsDir:
|
|
10775
|
+
migrationsDir: path45.join(cwd, MIGRATIONS_DIR),
|
|
10741
10776
|
// The app's PocketBase hooks (slug generation, personal teams, …) are part
|
|
10742
10777
|
// of its behaviour; the suite runs against the same server dev and build
|
|
10743
10778
|
// start, so it loads them from the same place.
|
|
10744
|
-
hooksDir:
|
|
10779
|
+
hooksDir: path45.join(cwd, DATA_DIR, "hooks"),
|
|
10745
10780
|
email: email3,
|
|
10746
10781
|
password: password11
|
|
10747
10782
|
});
|
|
@@ -10859,7 +10894,7 @@ function stubPagesPlugin() {
|
|
|
10859
10894
|
|
|
10860
10895
|
// src/commands/routes.ts
|
|
10861
10896
|
import fs43 from "node:fs";
|
|
10862
|
-
import
|
|
10897
|
+
import path46 from "node:path";
|
|
10863
10898
|
import { Command as Command102 } from "commander";
|
|
10864
10899
|
var HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
10865
10900
|
"GET",
|
|
@@ -10873,7 +10908,7 @@ var HTTP_METHODS = /* @__PURE__ */ new Set([
|
|
|
10873
10908
|
]);
|
|
10874
10909
|
var routes = new Command102("routes").description("list routes").configureHelp(helpConfig).action(async () => {
|
|
10875
10910
|
const { workspaceRootDir, routesDir } = await getWorkspace();
|
|
10876
|
-
const routesRoot =
|
|
10911
|
+
const routesRoot = path46.join(workspaceRootDir, routesDir);
|
|
10877
10912
|
const found = walk(routesRoot, routesRoot).filter((r) => r.methods.length > 0);
|
|
10878
10913
|
found.sort((a, b) => a.urlPattern.localeCompare(b.urlPattern));
|
|
10879
10914
|
printTable(found);
|
|
@@ -10883,20 +10918,20 @@ function walk(root, dir) {
|
|
|
10883
10918
|
const routes2 = [];
|
|
10884
10919
|
const hasLeaf = entries.some((e) => e.isFile() && isRouteFile(e.name));
|
|
10885
10920
|
if (hasLeaf) {
|
|
10886
|
-
const id = "/" +
|
|
10921
|
+
const id = "/" + path46.relative(root, dir).split(path46.sep).filter(Boolean).join("/");
|
|
10887
10922
|
const urlPattern = id.replace(/\([^)]+\)\/?/g, "").replace(/\/$/, "") || "/";
|
|
10888
10923
|
const methods = /* @__PURE__ */ new Set();
|
|
10889
10924
|
for (const entry of entries) {
|
|
10890
10925
|
if (!entry.isFile()) continue;
|
|
10891
10926
|
if (entry.name.endsWith("+page.svelte")) methods.add("GET");
|
|
10892
10927
|
if (entry.name.endsWith("+server.ts") || entry.name.endsWith("+server.js") || entry.name.endsWith("+page.server.ts") || entry.name.endsWith("+page.server.js")) {
|
|
10893
|
-
extractMethods(
|
|
10928
|
+
extractMethods(path46.join(dir, entry.name)).forEach((m) => methods.add(m));
|
|
10894
10929
|
}
|
|
10895
10930
|
}
|
|
10896
10931
|
routes2.push({ id: id || "/", urlPattern, methods: [...methods] });
|
|
10897
10932
|
}
|
|
10898
10933
|
for (const entry of entries) {
|
|
10899
|
-
if (entry.isDirectory()) routes2.push(...walk(root,
|
|
10934
|
+
if (entry.isDirectory()) routes2.push(...walk(root, path46.join(dir, entry.name)));
|
|
10900
10935
|
}
|
|
10901
10936
|
return routes2;
|
|
10902
10937
|
}
|
|
@@ -11084,7 +11119,7 @@ import pc36 from "picocolors";
|
|
|
11084
11119
|
|
|
11085
11120
|
// src/lib/cms-backend.ts
|
|
11086
11121
|
import { createRequire as createRequire3 } from "node:module";
|
|
11087
|
-
import
|
|
11122
|
+
import path47 from "node:path";
|
|
11088
11123
|
import process41 from "node:process";
|
|
11089
11124
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
11090
11125
|
import pc35 from "picocolors";
|
|
@@ -11092,7 +11127,7 @@ var DEFAULT_PROJECT = "default";
|
|
|
11092
11127
|
async function loadBackendModule(root) {
|
|
11093
11128
|
let entry;
|
|
11094
11129
|
try {
|
|
11095
|
-
entry = createRequire3(
|
|
11130
|
+
entry = createRequire3(path47.join(root, "package.json")).resolve("@velastack/cms/backend");
|
|
11096
11131
|
} catch {
|
|
11097
11132
|
throw new Error(
|
|
11098
11133
|
`@velastack/cms is not installed in this project.
|
|
@@ -11110,8 +11145,8 @@ async function withCmsBackend(fn, cwd = process41.cwd()) {
|
|
|
11110
11145
|
const { createCmsBackend } = await loadBackendModule(root);
|
|
11111
11146
|
const dataDir2 = localDataDir(root);
|
|
11112
11147
|
const backend3 = createCmsBackend({
|
|
11113
|
-
dbPath:
|
|
11114
|
-
uploadDir:
|
|
11148
|
+
dbPath: path47.join(dataDir2, "cms.sqlite"),
|
|
11149
|
+
uploadDir: path47.join(dataDir2, "uploads")
|
|
11115
11150
|
});
|
|
11116
11151
|
try {
|
|
11117
11152
|
return await fn(backend3);
|
|
@@ -11372,14 +11407,14 @@ program.hook("preAction", (_thisCommand, actionCommand) => {
|
|
|
11372
11407
|
if (isStub(actionCommand)) return;
|
|
11373
11408
|
const envRoot = findWorkspaceRoot() ?? process45.cwd();
|
|
11374
11409
|
dotenv2.config({ path: nodePath.join(envRoot, ".env"), quiet: true });
|
|
11375
|
-
const
|
|
11376
|
-
if (NO_BACKEND_COMMMANDS.has(
|
|
11377
|
-
const top =
|
|
11410
|
+
const path48 = getCommandPath(actionCommand);
|
|
11411
|
+
if (NO_BACKEND_COMMMANDS.has(path48)) return;
|
|
11412
|
+
const top = path48.split(" ", 1)[0];
|
|
11378
11413
|
if (NO_BACKEND_COMMMANDS.has(top)) return;
|
|
11379
11414
|
if (!hasBackend()) {
|
|
11380
11415
|
if (BACKEND_OPTIONAL_COMMANDS.has(top)) return;
|
|
11381
11416
|
p67.log.error(
|
|
11382
|
-
`${pc42.cyan(`vela ${
|
|
11417
|
+
`${pc42.cyan(`vela ${path48}`)} needs a backend, and this project does not have one.
|
|
11383
11418
|
|
|
11384
11419
|
Static projects have no database to talk to.
|
|
11385
11420
|
|
|
@@ -11389,7 +11424,7 @@ To add a backend to this project, run ${pc42.cyan("vela bless")}.`
|
|
|
11389
11424
|
p67.cancel("Operation failed.");
|
|
11390
11425
|
process45.exit(1);
|
|
11391
11426
|
}
|
|
11392
|
-
if (SELF_CREDENTIALED_COMMANDS.has(
|
|
11427
|
+
if (SELF_CREDENTIALED_COMMANDS.has(path48)) return;
|
|
11393
11428
|
if (!process45.env.POCKETBASE_SUPERUSER_EMAIL || !process45.env.POCKETBASE_SUPERUSER_PASSWORD) {
|
|
11394
11429
|
p67.log.error(
|
|
11395
11430
|
`PocketBase superuser credentials are required.
|