vela 0.10.1 → 0.10.2

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.1",
10
+ version: "0.10.2",
11
11
  type: "module",
12
12
  description: "A CLI for creating and updating SvelteKit projects",
13
13
  license: "MIT",
@@ -93,6 +93,13 @@ var package_default = {
93
93
  ]
94
94
  };
95
95
 
96
+ // src/lib/argv.ts
97
+ function normalizeArgv(argv2) {
98
+ const separator = argv2.indexOf("--");
99
+ if (separator === -1) return argv2;
100
+ return [...argv2.slice(0, separator), ...argv2.slice(separator + 1)];
101
+ }
102
+
96
103
  // src/lib/delegate.ts
97
104
  import fs from "node:fs";
98
105
  import path from "node:path";
@@ -140,18 +147,18 @@ function readLocalCli(pkgPath) {
140
147
  function isRecord(value) {
141
148
  return typeof value === "object" && value !== null;
142
149
  }
143
- function isDelegatable(argv) {
144
- const first = argv.find((arg) => !arg.startsWith("-"));
150
+ function isDelegatable(argv2) {
151
+ const first = argv2.find((arg) => !arg.startsWith("-"));
145
152
  return first === void 0 || !NO_DELEGATE_COMMANDS.has(first);
146
153
  }
147
154
  function delegateToLocalCli(opts) {
148
155
  const env = opts.env ?? process2.env;
149
156
  if (env[NO_DELEGATE_ENV]) return null;
150
- const argv = opts.argv ?? process2.argv.slice(2);
151
- if (!isDelegatable(argv)) return null;
157
+ const argv2 = opts.argv ?? process2.argv.slice(2);
158
+ if (!isDelegatable(argv2)) return null;
152
159
  const local = findLocalCli(opts.cwd ?? process2.cwd(), opts.selfPath);
153
160
  if (!local || local.version === opts.selfVersion) return null;
154
- const result = spawnSync(process2.execPath, [local.binPath, ...argv], {
161
+ const result = spawnSync(process2.execPath, [local.binPath, ...argv2], {
155
162
  stdio: "inherit",
156
163
  env: { ...env, [NO_DELEGATE_ENV]: "1" }
157
164
  });
@@ -1681,7 +1688,7 @@ import { bySlug } from "@velastack/patterns";
1681
1688
  function toRelative(root, filePath) {
1682
1689
  return path13.isAbsolute(filePath) ? path13.relative(root, filePath) : filePath;
1683
1690
  }
1684
- async function runPattern(slug, argv, input, report) {
1691
+ async function runPattern(slug, argv2, input, report) {
1685
1692
  const pattern = bySlug[slug];
1686
1693
  if (!pattern) {
1687
1694
  throw new Error(`Unknown pattern: ${slug}`);
@@ -1691,7 +1698,7 @@ async function runPattern(slug, argv, input, report) {
1691
1698
  let result;
1692
1699
  try {
1693
1700
  result = await pattern.generate({
1694
- argv,
1701
+ argv: argv2,
1695
1702
  env: "runtime",
1696
1703
  root: workspaceRootDir,
1697
1704
  features,
@@ -1918,7 +1925,7 @@ function typeArg(field) {
1918
1925
  return null;
1919
1926
  }
1920
1927
  function collectionSpecToArgv(spec) {
1921
- const argv = [spec.name];
1928
+ const argv2 = [spec.name];
1922
1929
  for (const field of spec.fields) {
1923
1930
  const type = typeArg(field);
1924
1931
  if (type === null) {
@@ -1928,9 +1935,9 @@ function collectionSpecToArgv(spec) {
1928
1935
  continue;
1929
1936
  }
1930
1937
  const required = field.required ? "!" : "";
1931
- argv.push(`${field.name}:${type}${required}`);
1938
+ argv2.push(`${field.name}:${type}${required}`);
1932
1939
  }
1933
- return argv;
1940
+ return argv2;
1934
1941
  }
1935
1942
 
1936
1943
  // src/lib/ai-grid.ts
@@ -2083,7 +2090,7 @@ var form = new Command4("form").description("generate a form from a model").argu
2083
2090
  "design the form with AI from a natural-language description (two stages: schema \u2192 layout)"
2084
2091
  ).allowUnknownOption(true).configureHelp(helpConfig).action(
2085
2092
  (model, fields, options) => runCommand(async () => {
2086
- let argv;
2093
+ let argv2;
2087
2094
  let modelName;
2088
2095
  let sidecarPath = null;
2089
2096
  if (options.ai) {
@@ -2100,14 +2107,14 @@ var form = new Command4("form").description("generate a form from a model").argu
2100
2107
  p11.cancel("Aborted before any files were written.");
2101
2108
  return;
2102
2109
  }
2103
- argv = specToArgv(stage.model);
2110
+ argv2 = specToArgv(stage.model);
2104
2111
  modelName = stage.model.name;
2105
2112
  sidecarPath = writeLayoutSidecar(stage.workspaceRootDir, modelName, layout);
2106
2113
  } else {
2107
2114
  if (!model) {
2108
2115
  throw new Error("Missing required argument: model. Pass a model name or use --ai.");
2109
2116
  }
2110
- argv = [model, ...fields];
2117
+ argv2 = [model, ...fields];
2111
2118
  modelName = model;
2112
2119
  }
2113
2120
  const slug = options.remote ? "generate-form-remote" : "generate-form";
@@ -2122,7 +2129,7 @@ var form = new Command4("form").description("generate a form from a model").argu
2122
2129
  }
2123
2130
  await runPattern(
2124
2131
  slug,
2125
- argv,
2132
+ argv2,
2126
2133
  { route: options.route },
2127
2134
  {
2128
2135
  summary: `Created ${modelName} form.`,
@@ -2142,7 +2149,7 @@ import { Command as Command5 } from "commander";
2142
2149
  import * as p12 from "@clack/prompts";
2143
2150
  var schema = new Command5("schema").description("generate a schema from a model").argument("[model]", "model name").argument("[fields...]", "field definitions").option("--ai <description>", "design the schema with AI from a natural-language description").allowUnknownOption(true).configureHelp(helpConfig).action(
2144
2151
  (model, fields, options) => runCommand(async () => {
2145
- let argv;
2152
+ let argv2;
2146
2153
  let modelName;
2147
2154
  if (options.ai) {
2148
2155
  if (model) {
@@ -2153,18 +2160,18 @@ var schema = new Command5("schema").description("generate a schema from a model"
2153
2160
  p12.cancel("Aborted before any files were written.");
2154
2161
  return;
2155
2162
  }
2156
- argv = specToArgv(stage.model);
2163
+ argv2 = specToArgv(stage.model);
2157
2164
  modelName = stage.model.name;
2158
2165
  } else {
2159
2166
  if (!model) {
2160
2167
  throw new Error("Missing required argument: model. Pass a model name or use --ai.");
2161
2168
  }
2162
- argv = [model, ...fields];
2169
+ argv2 = [model, ...fields];
2163
2170
  modelName = model;
2164
2171
  }
2165
2172
  await runPattern(
2166
2173
  "generate-schema",
2167
- argv,
2174
+ argv2,
2168
2175
  {},
2169
2176
  {
2170
2177
  summary: `Created ${modelName} schema.`,
@@ -2219,7 +2226,7 @@ var scaffold = new Command7("scaffold").description("generate a full CRUD scaffo
2219
2226
  "design the scaffold with AI from a natural-language description (two stages: schema \u2192 layout)"
2220
2227
  ).allowUnknownOption(true).configureHelp(helpConfig).action(
2221
2228
  (model, fields, options) => runCommand(async () => {
2222
- let argv;
2229
+ let argv2;
2223
2230
  let modelName;
2224
2231
  let sidecarPath = null;
2225
2232
  if (options.ai) {
@@ -2236,14 +2243,14 @@ var scaffold = new Command7("scaffold").description("generate a full CRUD scaffo
2236
2243
  p13.cancel("Aborted before any files were written.");
2237
2244
  return;
2238
2245
  }
2239
- argv = specToArgv(stage.model);
2246
+ argv2 = specToArgv(stage.model);
2240
2247
  modelName = stage.model.name;
2241
2248
  sidecarPath = writeLayoutSidecar(stage.workspaceRootDir, modelName, layout);
2242
2249
  } else {
2243
2250
  if (!model) {
2244
2251
  throw new Error("Missing required argument: model. Pass a model name or use --ai.");
2245
2252
  }
2246
- argv = [model, ...fields];
2253
+ argv2 = [model, ...fields];
2247
2254
  modelName = model;
2248
2255
  }
2249
2256
  const slug = options.remote ? "generate-scaffold-remote" : "generate-scaffold";
@@ -2259,7 +2266,7 @@ var scaffold = new Command7("scaffold").description("generate a full CRUD scaffo
2259
2266
  }
2260
2267
  await runPattern(
2261
2268
  slug,
2262
- argv,
2269
+ argv2,
2263
2270
  { route: options.route },
2264
2271
  {
2265
2272
  summary: `Created ${modelName} scaffold.`,
@@ -5619,7 +5626,7 @@ function parsePort(value) {
5619
5626
  }
5620
5627
  return port;
5621
5628
  }
5622
- var dev = new Command65("dev").description("start the development server").option("--open", "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).configureHelp(helpConfig).action(async (options) => {
5629
+ var dev = new Command65("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) => {
5623
5630
  const cwd = process17.cwd();
5624
5631
  const startTime = performance.now();
5625
5632
  const { createServer, version } = await import("vite");
@@ -5657,7 +5664,13 @@ var dev = new Command65("dev").description("start the development server").optio
5657
5664
  if (options.open !== void 0) serverOptions.open = options.open;
5658
5665
  if (options.host !== void 0) serverOptions.host = options.host;
5659
5666
  if (options.port !== void 0) serverOptions.port = options.port;
5660
- const server = await createServer({ server: serverOptions });
5667
+ if (options.cors !== void 0) serverOptions.cors = options.cors;
5668
+ if (options.strictPort !== void 0) serverOptions.strictPort = options.strictPort;
5669
+ const inlineConfig = {
5670
+ server: serverOptions
5671
+ };
5672
+ if (options.force !== void 0) inlineConfig.forceOptimizeDeps = options.force;
5673
+ const server = await createServer(inlineConfig);
5661
5674
  server.httpServer?.on("listening", async () => {
5662
5675
  if (!backend3) return;
5663
5676
  const { address, port: vitePort } = server.httpServer.address();
@@ -6271,12 +6284,14 @@ for (const command of [
6271
6284
  }
6272
6285
 
6273
6286
  // src/bin.ts
6287
+ var argv = normalizeArgv(process24.argv.slice(2));
6274
6288
  var delegatedExitCode = delegateToLocalCli({
6289
+ argv,
6275
6290
  selfPath: fileURLToPath2(import.meta.url),
6276
6291
  selfVersion: package_default.version
6277
6292
  });
6278
6293
  if (delegatedExitCode !== null) {
6279
6294
  process24.exit(delegatedExitCode);
6280
6295
  }
6281
- program.parse();
6296
+ program.parse(argv, { from: "user" });
6282
6297
  //# sourceMappingURL=bin.js.map