vela 0.10.6 → 0.10.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -7,7 +7,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
7
7
  // package.json
8
8
  var package_default = {
9
9
  name: "vela",
10
- version: "0.10.6",
10
+ version: "0.10.8",
11
11
  type: "module",
12
12
  description: "A CLI for creating and updating SvelteKit projects",
13
13
  license: "MIT",
@@ -393,6 +393,9 @@ function hasBackend(from = process3.cwd()) {
393
393
  const root = findWorkspaceRoot(from);
394
394
  return root !== null && fs3.existsSync(path2.join(root, DATA_DIR));
395
395
  }
396
+ function localDataDir(from = process3.cwd()) {
397
+ return path2.join(findWorkspaceRoot(from) ?? from, DATA_DIR);
398
+ }
396
399
  async function getWorkspace() {
397
400
  const workspaceRootDir = findWorkspaceRoot();
398
401
  if (!workspaceRootDir) {
@@ -3150,6 +3153,7 @@ function spawnCapture(command, args, opts = {}) {
3150
3153
  import path19 from "node:path";
3151
3154
  var VELA_ROOT = "/var/lib/vela";
3152
3155
  var VELA_ETC = "/etc/vela";
3156
+ var VELA_USER = "vela";
3153
3157
  var SCRIPTS_DIR = `${VELA_ROOT}/scripts`;
3154
3158
  var PROVISIONED_MARKER = `${VELA_ETC}/provisioned`;
3155
3159
  function serverTemplatesDir() {
@@ -6937,6 +6941,7 @@ function parsePort(value) {
6937
6941
  }
6938
6942
  var dev = new Command66("dev").description("start the development server").option("--open [path]", "open the app in a browser once the server is ready").option("--host [host]", "expose the server on the network").option("--port <port>", "port to listen on", parsePort).option("--strictPort", "exit if the port is already in use instead of taking the next one").option("--cors", "enable CORS").option("--force", "re-bundle dependencies, ignoring the optimizer cache").configureHelp(helpConfig).action(async (options) => {
6939
6943
  const cwd = process21.cwd();
6944
+ process21.env.VELA_DATA_DIR ??= localDataDir(cwd);
6940
6945
  const startTime = performance.now();
6941
6946
  const { createServer, version } = await loadVite(cwd);
6942
6947
  const viteMetadataDir = path34.join(cwd, "node_modules", ".vite");
@@ -7050,6 +7055,12 @@ import { x as x3 } from "tinyexec";
7050
7055
  import { detect as detect5 } from "package-manager-detector";
7051
7056
  import { resolveCommand as resolveCommand5 } from "package-manager-detector/commands";
7052
7057
 
7058
+ // src/lib/build-env.ts
7059
+ function applyBuildEnv(cwd, env2 = process.env) {
7060
+ env2.VITE_BUILD = "true";
7061
+ env2.VELA_DATA_DIR ??= localDataDir(cwd);
7062
+ }
7063
+
7053
7064
  // src/lib/origin.ts
7054
7065
  import process22 from "node:process";
7055
7066
  function resolveOrigin(workspaceRootDir, envTag, config = {}) {
@@ -7073,6 +7084,7 @@ function normalizeOrigin(value) {
7073
7084
  var PRERENDERED_DIR = path35.join(".svelte-kit", "output", "prerendered");
7074
7085
  var build = new Command67("build").description("build the app").configureHelp(helpConfig).option("-t, --target <target>", "which copy of the app to build for", PRODUCTION_TARGET).action(async (options) => {
7075
7086
  const cwd = process23.cwd();
7087
+ applyBuildEnv(cwd);
7076
7088
  const origin = await originForBuild(cwd, options.target);
7077
7089
  if (origin) process23.env.VELA_ORIGIN = origin;
7078
7090
  let pbProc;
@@ -7143,6 +7155,7 @@ import { detect as detect6 } from "package-manager-detector";
7143
7155
  import { resolveCommand as resolveCommand6 } from "package-manager-detector/commands";
7144
7156
  var preview = new Command68("preview").description("preview the built app").configureHelp(helpConfig).action(async () => {
7145
7157
  const cwd = process24.cwd();
7158
+ process24.env.VELA_DATA_DIR ??= localDataDir(cwd);
7146
7159
  let pbProc;
7147
7160
  const needsStart = hasBackend(cwd) && !process24.env.POCKETBASE_URL;
7148
7161
  const cleanup = () => {
@@ -8271,6 +8284,16 @@ async function createBackup(pb, key, { pollTimeout = 30 * 6e4 } = {}) {
8271
8284
  PocketBase may still be working on it \u2014 check \`vela logs\` and \`vela backup list\` before trying again.`
8272
8285
  );
8273
8286
  }
8287
+ async function checkpointAppDatabases(session, instance) {
8288
+ await session.script(
8289
+ `command -v sqlite3 >/dev/null 2>&1 || exit 0
8290
+ for db in "$1"/*.db "$1"/*.sqlite; do
8291
+ [ -f "$db-wal" ] || continue
8292
+ runuser -u "$2" -- sqlite3 "$db" 'PRAGMA busy_timeout=5000; PRAGMA wal_checkpoint(TRUNCATE);' >/dev/null 2>&1 || true
8293
+ done`,
8294
+ { args: [remotePaths.pbData(instance), VELA_USER], check: false }
8295
+ );
8296
+ }
8274
8297
  function formatBytes(bytes) {
8275
8298
  const units = ["B", "KB", "MB", "GB", "TB"];
8276
8299
  let value = bytes;
@@ -8318,6 +8341,7 @@ PocketBase leaves ${pc23.cyan("storage/")} out of a backup whenever S3 is on.
8318
8341
  Your bucket's own versioning is what protects the uploaded files.`
8319
8342
  );
8320
8343
  }
8344
+ if (ctx.session) await checkpointAppDatabases(ctx.session, ctx.instance);
8321
8345
  const spinner5 = p43.spinner();
8322
8346
  spinner5.start(`Backing up ${ctx.targetName}`);
8323
8347
  try {
@@ -8808,6 +8832,7 @@ var testServer = new Command91("test:server").description("run server tests").al
8808
8832
  process32.env.POCKETBASE_URL = url;
8809
8833
  process32.env.POCKETBASE_SUPERUSER_EMAIL = email3;
8810
8834
  process32.env.POCKETBASE_SUPERUSER_PASSWORD = password11;
8835
+ process32.env.VELA_DATA_DIR = testDataDir;
8811
8836
  process32.env.TEST = "true";
8812
8837
  console.log(`${pc30.greenBright("\u2713")} Created test database`);
8813
8838
  const { createServer } = await loadVite(cwd);