sv 0.13.1 → 0.13.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.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { a as detectPackageManager, c as name, h as program, l as version, m as Command, n as add, o as forwardExitCode, p as from, r as create, s as helpConfig } from "./engine-lCnxwqd0.mjs";
3
- import { color, resolveCommand } from "@sveltejs/sv-utils";
2
+ import { a as detectPackageManager, c as name, h as program, l as version, m as Command, n as add, o as forwardExitCode, p as from, r as create, s as helpConfig } from "./engine-B8V7JiJ3.mjs";
3
+ import { color, resolveCommandArray } from "@sveltejs/sv-utils";
4
4
  import process from "node:process";
5
5
  import { execSync } from "node:child_process";
6
6
  //#region src/cli/check.ts
@@ -12,8 +12,7 @@ const check = new Command("check").description("a CLI for checking your Svelte c
12
12
  async function runCheck(cwd, args) {
13
13
  const pm = await detectPackageManager(cwd);
14
14
  if (!from(cwd, "svelte-check", true)) {
15
- const cmd = resolveCommand(pm, "add", ["-D", "svelte-check"]);
16
- console.error(`'svelte-check' is not installed locally. Install it with: ${color.command(`${cmd.command} ${cmd.args.join(" ")}`)}`);
15
+ console.error(`'svelte-check' is not installed locally. Install it with: ${color.command(resolveCommandArray(pm, "add", ["-D", "svelte-check"]))}`);
17
16
  process.exit(1);
18
17
  }
19
18
  if (args.includes("--help")) {
@@ -21,8 +20,7 @@ async function runCheck(cwd, args) {
21
20
  console.log("Find here all options for both tools");
22
21
  }
23
22
  try {
24
- const cmd = resolveCommand(pm, "execute-local", ["svelte-check", ...args]);
25
- execSync(`${cmd.command} ${cmd.args.join(" ")}`, {
23
+ execSync(resolveCommandArray(pm, "execute-local", ["svelte-check", ...args]).join(" "), {
26
24
  stdio: "inherit",
27
25
  cwd
28
26
  });
@@ -42,8 +40,7 @@ async function runMigrate(cwd, args) {
42
40
  try {
43
41
  const cmdArgs = ["svelte-migrate@latest", ...args];
44
42
  if (pm === "npm") cmdArgs.unshift("--yes");
45
- const cmd = resolveCommand(pm, "execute", cmdArgs);
46
- execSync(`${cmd.command} ${cmd.args.join(" ")}`, {
43
+ execSync(resolveCommandArray(pm, "execute", cmdArgs).join(" "), {
47
44
  stdio: "inherit",
48
45
  cwd
49
46
  });
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from "node:module";
2
- import { AGENTS, COMMANDS, Walker, color, commonFilePaths, constructCommand, createPrinter, dedent, detect, downloadJson, fileExists, getPackageJson, installPackages, isVersionUnsupportedBelow, js, parse, readFile, resolveCommand, sanitizeName, splitVersion, svelte, text, transforms, writeFile } from "@sveltejs/sv-utils";
2
+ import { AGENTS, COMMANDS, Walker, color, commonFilePaths, constructCommand, createPrinter, dedent, detect, downloadJson, fileExists, getPackageJson, installPackages, isVersionUnsupportedBelow, js, parse, readFile, resolveCommand, resolveCommandArray, sanitizeName, splitVersion, svelte, text, transforms, writeFile } from "@sveltejs/sv-utils";
3
3
  import fs, { existsSync } from "node:fs";
4
4
  import path, { delimiter, dirname, isAbsolute, join, normalize, resolve } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
@@ -5882,14 +5882,21 @@ const addEslintConfigPrettier = transforms.script(({ ast, js }) => {
5882
5882
  });
5883
5883
  const fallbackConfig = js.common.parseExpression("[]");
5884
5884
  const eslintConfig = js.exports.createDefault(ast, { fallback: fallbackConfig }).value;
5885
- if (eslintConfig.type !== "ArrayExpression" && eslintConfig.type !== "CallExpression") return false;
5885
+ let elements = [];
5886
+ if (eslintConfig.type === "ArrayExpression") elements = eslintConfig.elements;
5887
+ else if (eslintConfig.type === "CallExpression") if (eslintConfig.arguments.length === 1 && eslintConfig.arguments[0].type === "ArrayExpression") elements = eslintConfig.arguments[0].elements;
5888
+ else elements = eslintConfig.arguments;
5889
+ else return false;
5886
5890
  const prettier = js.common.parseExpression("prettier");
5887
5891
  const sveltePrettierConfig = js.common.parseExpression(`${svelteImportName}.configs.prettier`);
5888
5892
  const nodesToInsert = [];
5889
5893
  if (!js.common.contains(eslintConfig, prettier)) nodesToInsert.push(prettier);
5890
5894
  if (!js.common.contains(eslintConfig, sveltePrettierConfig)) nodesToInsert.push(sveltePrettierConfig);
5891
- const elements = eslintConfig.type === "ArrayExpression" ? eslintConfig.elements : eslintConfig.arguments;
5892
- const idx = elements.findIndex((el) => el?.type === "MemberExpression" && el.object.type === "MemberExpression" && el.object.property.type === "Identifier" && el.object.property.name === "configs" && el.object.object.type === "Identifier" && el.object.object.name === svelteImportName);
5895
+ const isSvelteConfig = (maybeSpread) => {
5896
+ const el = maybeSpread?.type === "SpreadElement" ? maybeSpread?.argument : maybeSpread;
5897
+ return el?.type === "MemberExpression" && el.object.type === "MemberExpression" && el.object.object.type === "Identifier" && el.object.object.name === svelteImportName && el.object.property.type === "Identifier" && el.object.property.name === "configs";
5898
+ };
5899
+ const idx = elements.findIndex(isSvelteConfig);
5893
5900
  if (idx !== -1) elements.splice(idx + 1, 0, ...nodesToInsert);
5894
5901
  else elements.push(...nodesToInsert);
5895
5902
  });
@@ -6209,7 +6216,7 @@ var better_auth_default = defineAddon({
6209
6216
  ${!d1 ? "import { auth } from '$lib/server/auth';" : ""}
6210
6217
  ${needsAPIError ? "import { APIError } from 'better-auth/api';" : ""}
6211
6218
 
6212
- export const load${ts(": PageServerLoad")} = async (event) => {
6219
+ export const load${ts(": PageServerLoad")} = (event) => {
6213
6220
  if (event.locals.user) {
6214
6221
  return redirect(302, '/demo/better-auth');
6215
6222
  }
@@ -6277,7 +6284,7 @@ var better_auth_default = defineAddon({
6277
6284
  ${ts("import type { PageServerLoad } from './$types';")}
6278
6285
  ${!d1 ? "import { auth } from '$lib/server/auth';" : ""}
6279
6286
 
6280
- export const load${ts(": PageServerLoad")} = async (event) => {
6287
+ export const load${ts(": PageServerLoad")} = (event) => {
6281
6288
  if (!event.locals.user) {
6282
6289
  return redirect(302, '/demo/better-auth/login');
6283
6290
  }
@@ -6312,11 +6319,9 @@ var better_auth_default = defineAddon({
6312
6319
  }
6313
6320
  },
6314
6321
  nextSteps: ({ options, packageManager }) => {
6315
- const { command: authCmd, args: authArgs } = resolveCommand(packageManager, "run", ["auth:schema"]);
6316
- const { command: dbCmd, args: dbArgs } = resolveCommand(packageManager, "run", ["db:push"]);
6317
6322
  const steps = [
6318
- `Run ${color.command(`${authCmd} ${authArgs.join(" ")}`)} to generate the auth schema`,
6319
- `Run ${color.command(`${dbCmd} ${dbArgs.join(" ")}`)} to update your database`,
6323
+ `Run ${color.command(resolveCommandArray(packageManager, "run", ["auth:schema"]))} to generate the auth schema`,
6324
+ `Run ${color.command(resolveCommandArray(packageManager, "run", ["db:push"]))} to update your database`,
6320
6325
  `Check ${color.env("ORIGIN")} & ${color.env("BETTER_AUTH_SECRET")} in ${color.path(".env")} and adjust it to your needs`
6321
6326
  ];
6322
6327
  if (options.demo.includes("github")) steps.push(`Set your ${color.env("GITHUB_CLIENT_ID")} and ${color.env("GITHUB_CLIENT_SECRET")} in ${color.path(".env")}`);
@@ -6650,7 +6655,7 @@ var drizzle_default = defineAddon({
6650
6655
  from: "drizzle-orm/d1",
6651
6656
  imports: ["drizzle"]
6652
6657
  });
6653
- const getDbFn = js.common.parseStatement(`export const getDb = (d1${ts(": D1Database")} => drizzle(d1, { schema });`);
6658
+ const getDbFn = js.common.parseStatement(`export const getDb = (d1${ts(": D1Database")}) => drizzle(d1, { schema });`);
6654
6659
  ast.body.push(getDbFn);
6655
6660
  return;
6656
6661
  }
@@ -6758,21 +6763,17 @@ var drizzle_default = defineAddon({
6758
6763
  const steps = [];
6759
6764
  if (options.database === "d1") {
6760
6765
  const ext = fileExists(cwd, "wrangler.toml") ? "toml" : "jsonc";
6761
- const { command, args } = resolveCommand(packageManager, "run", [
6766
+ steps.push(`Add your ${color.env("CLOUDFLARE_ACCOUNT_ID")}, ${color.env("CLOUDFLARE_DATABASE_ID")}, and ${color.env("CLOUDFLARE_D1_TOKEN")} to ${color.path(".env")}`);
6767
+ steps.push(`Run ${color.command(resolveCommandArray(packageManager, "run", [
6762
6768
  "wrangler",
6763
6769
  "d1",
6764
6770
  "create",
6765
- `<DATABASE_NAME>`
6766
- ]);
6767
- steps.push(`Add your ${color.env("CLOUDFLARE_ACCOUNT_ID")}, ${color.env("CLOUDFLARE_DATABASE_ID")}, and ${color.env("CLOUDFLARE_D1_TOKEN")} to ${color.path(".env")}`);
6768
- steps.push(`Run ${color.command(`${command} ${args.join(" ")}`)} to generate a D1 database ID for your ${color.path(`wrangler.${ext}`)}`);
6769
- }
6770
- if (options.docker) {
6771
- const { command, args } = resolveCommand(packageManager, "run", ["db:start"]);
6772
- steps.push(`Run ${color.command(`${command} ${args.join(" ")}`)} to start the docker container`);
6773
- } else if (options.database !== "d1") steps.push(`Check ${color.env("DATABASE_URL")} in ${color.path(".env")} and adjust it to your needs`);
6774
- const { command, args } = resolveCommand(packageManager, "run", ["db:push"]);
6775
- steps.push(`Run ${color.command(`${command} ${args.join(" ")}`)} to update your database schema`);
6771
+ "<DATABASE_NAME>"
6772
+ ]))} to generate a D1 database ID for your ${color.path(`wrangler.${ext}`)}`);
6773
+ }
6774
+ if (options.docker) steps.push(`Run ${color.command(resolveCommandArray(packageManager, "run", ["db:start"]))} to start the docker container`);
6775
+ else if (options.database !== "d1") steps.push(`Check ${color.env("DATABASE_URL")} in ${color.path(".env")} and adjust it to your needs`);
6776
+ steps.push(`Run ${color.command(resolveCommandArray(packageManager, "run", ["db:push"]))} to update your database schema`);
6776
6777
  return steps;
6777
6778
  }
6778
6779
  });
@@ -6900,6 +6901,17 @@ var eslint_default = defineAddon({
6900
6901
  });
6901
6902
  eslintConfigs.push(svelteTSParserConfig);
6902
6903
  }
6904
+ const rulesOverride = js.object.create({ rules: {} });
6905
+ eslintConfigs.push(rulesOverride);
6906
+ if (rulesOverride.properties[0].type !== "Property") throw new Error("rulesOverride.properties[0].type !== \"Property\"");
6907
+ comments.add(rulesOverride.properties[0].key, {
6908
+ type: "Line",
6909
+ value: " Override or add rule settings here, such as:"
6910
+ });
6911
+ comments.add(rulesOverride.properties[0].key, {
6912
+ type: "Line",
6913
+ value: " 'svelte/button-has-type': 'error'"
6914
+ });
6903
6915
  const exportExpression = js.functions.createCall({
6904
6916
  name: "defineConfig",
6905
6917
  args: []
@@ -7610,10 +7622,7 @@ var sveltekit_adapter_default = defineAddon({
7610
7622
  },
7611
7623
  nextSteps({ options, packageManager }) {
7612
7624
  const steps = [];
7613
- if (options.adapter === "cloudflare") {
7614
- const { command, args } = resolveCommand(packageManager, "run", ["gen"]);
7615
- steps.push(`Run ${color.command(`${command} ${args.join(" ")}`)} to update ${color.addon("cloudflare")} types`);
7616
- }
7625
+ if (options.adapter === "cloudflare") steps.push(`Run ${color.command(resolveCommandArray(packageManager, "run", ["gen"]))} to update ${color.addon("cloudflare")} types`);
7617
7626
  return steps;
7618
7627
  }
7619
7628
  });
@@ -7899,7 +7908,7 @@ function getAddonDetails(id) {
7899
7908
  //#endregion
7900
7909
  //#region package.json
7901
7910
  var name = "sv";
7902
- var version = "0.13.1";
7911
+ var version = "0.13.2";
7903
7912
  //#endregion
7904
7913
  //#region src/core/errors.ts
7905
7914
  var UnsupportedError = class extends Error {
@@ -8046,8 +8055,7 @@ function buildAndLogArgs(agent, command, args, lastArgs = []) {
8046
8055
  ];
8047
8056
  if (agent === null || agent === void 0) allArgs.push("--no-install");
8048
8057
  else allArgs.push("--install", agent);
8049
- const res = resolveCommand(agent ?? "npm", "execute", [...allArgs, ...lastArgs]);
8050
- const message = [res.command, ...res.args].join(" ");
8058
+ const message = resolveCommandArray(agent ?? "npm", "execute", [...allArgs, ...lastArgs]).join(" ");
8051
8059
  R$1.message(color.optional(color.dim(`To skip prompts next time, run:`)));
8052
8060
  R$1.info(color.optional(message), { spacing: -1 });
8053
8061
  return message;
@@ -11391,15 +11399,10 @@ const create = new Command("create").description("Scaffold a new project (--add
11391
11399
  const pathHasSpaces = relative.includes(" ");
11392
11400
  initialSteps.push(` ${i++}: ${color.command(`cd ${pathHasSpaces ? `"${relative}"` : relative}`)}`);
11393
11401
  }
11394
- if (!packageManager) {
11395
- const { args, command } = resolveCommand(pm, "install", []);
11396
- initialSteps.push(` ${i++}: ${color.command(`${command} ${args.join(" ")}`)}`);
11397
- }
11398
- const { args, command } = resolveCommand(pm, "run", ["dev", "--open"]);
11399
- const pmRunCmd = `${command} ${args.join(" ")}`;
11402
+ if (!packageManager) initialSteps.push(` ${i++}: ${color.command(resolveCommandArray(pm, "install", []))}`);
11400
11403
  const steps = [
11401
11404
  ...initialSteps,
11402
- ` ${i++}: ${color.command(pmRunCmd)}`,
11405
+ ` ${i++}: ${color.command(resolveCommandArray(pm, "run", ["dev", "--open"]))}`,
11403
11406
  "",
11404
11407
  `To close the dev server, hit ${color.command("Ctrl-C")}`
11405
11408
  ];
@@ -11522,8 +11525,9 @@ async function createProject(cwd, options) {
11522
11525
  let argsFormattedAddons = [];
11523
11526
  let addOnFilesToFormat = [];
11524
11527
  let addOnSuccessfulAddons = [];
11528
+ let addonSetupResults = {};
11525
11529
  if (template !== "addon" && (options.addOns || options.add.length > 0)) {
11526
- const { argsFormattedAddons: argsFormatted, filesToFormat, successfulAddons } = await runAddonsApply({
11530
+ const { argsFormattedAddons: argsFormatted, filesToFormat, successfulAddons, setupResults } = await runAddonsApply({
11527
11531
  answers,
11528
11532
  options: {
11529
11533
  cwd: projectPath,
@@ -11540,6 +11544,7 @@ async function createProject(cwd, options) {
11540
11544
  argsFormattedAddons = argsFormatted;
11541
11545
  addOnFilesToFormat = filesToFormat;
11542
11546
  addOnSuccessfulAddons = successfulAddons;
11547
+ addonSetupResults = setupResults;
11543
11548
  }
11544
11549
  const packageManager = options.install === false ? null : options.install === true ? await packageManagerPrompt(projectPath) : options.install;
11545
11550
  const argsFormatted = [];
@@ -11551,7 +11556,7 @@ async function createProject(cwd, options) {
11551
11556
  updateReadme(directory, buildAndLogArgs(packageManager, "create", argsFormatted, [directory]));
11552
11557
  updateAgent(directory, language, packageManager ?? "npm", loadedAddons);
11553
11558
  if (packageManager) workspace.packageManager = packageManager;
11554
- const addOnNextSteps = getNextSteps(addOnSuccessfulAddons, workspace, answers);
11559
+ const addOnNextSteps = getNextSteps(addOnSuccessfulAddons, workspace, answers, addonSetupResults);
11555
11560
  await addPnpmBuildDependencies(projectPath, packageManager, ["esbuild"]);
11556
11561
  if (packageManager) {
11557
11562
  await installDependencies(packageManager, projectPath);
@@ -11997,7 +12002,8 @@ async function runAddonsApply({ answers, options, loadedAddons, setupResults, wo
11997
12002
  nextSteps: [],
11998
12003
  argsFormattedAddons: [],
11999
12004
  filesToFormat: [],
12000
- successfulAddons: []
12005
+ successfulAddons: [],
12006
+ setupResults: {}
12001
12007
  };
12002
12008
  const { filesToFormat, pnpmBuildDependencies, status } = await applyAddons({
12003
12009
  loadedAddons,
@@ -12058,15 +12064,16 @@ async function runAddonsApply({ answers, options, loadedAddons, setupResults, wo
12058
12064
  });
12059
12065
  }
12060
12066
  return {
12061
- nextSteps: getNextSteps(successfulAddons, workspace, answers),
12067
+ nextSteps: getNextSteps(successfulAddons, workspace, answers, setupResults),
12062
12068
  argsFormattedAddons,
12063
12069
  filesToFormat,
12064
- successfulAddons
12070
+ successfulAddons,
12071
+ setupResults
12065
12072
  };
12066
12073
  }
12067
- function getNextSteps(loadedAddons, workspace, answers) {
12068
- return loadedAddons.map((loaded) => {
12069
- const addon = loaded.addon;
12074
+ function getNextSteps(loadedAddons, workspace, answers, setupResults) {
12075
+ return orderAddons(loadedAddons.map((l) => l.addon), setupResults).map((loaded) => {
12076
+ const { addon } = loadedAddons.find((l) => l.addon.id === loaded.id);
12070
12077
  if (!addon.nextSteps) return;
12071
12078
  const addonOptions = answers[addon.id];
12072
12079
  const addonNextSteps = addon.nextSteps({
@@ -12337,7 +12344,7 @@ async function runAddon({ addon, loaded, multiple, workspace, workspaceOptions }
12337
12344
  execute: async (commandArgs, stdio) => {
12338
12345
  const { command, args } = resolveCommand(workspace.packageManager, "execute", commandArgs);
12339
12346
  const addonPrefix = multiple ? `${addon.id}: ` : "";
12340
- const executedCommand = `${command} ${args.join(" ")}`;
12347
+ const executedCommand = [command, ...args].join(" ");
12341
12348
  if (!TESTING) R$1.step(`${addonPrefix}Running external command ${color.optional(`(${executedCommand})`)}`);
12342
12349
  if (workspace.packageManager === "npm") args.unshift("--yes");
12343
12350
  try {
@@ -176,7 +176,7 @@ type Addon<Args extends OptionDefinition, Id extends string = string> = {
176
176
  */
177
177
  cancel: (reason: string) => void;
178
178
  }) => MaybePromise<void>; /** Next steps to display after the addon is run. */
179
- nextSteps?: (data: Workspace & {
179
+ nextSteps?: (workspace: Workspace & {
180
180
  options: WorkspaceOptions<Args>;
181
181
  }) => string[];
182
182
  };
@@ -1,4 +1,4 @@
1
- import { A as BooleanQuestion, C as defineAddon, D as WorkspaceOptions, E as Workspace, F as Question, I as SelectQuestion, L as StringQuestion, M as NumberQuestion, N as OptionDefinition, O as createWorkspace, P as OptionValues, R as officialAddons, S as Verification, T as getErrorHint, _ as Scripts, a as Addon, b as TestDefinition, c as AddonReference, d as ConditionDefinition, f as ConfiguredAddon, g as PreparedAddon, h as PackageDefinition, i as add, j as MultiSelectQuestion, k as BaseQuestion, l as AddonResult, m as OptionBuilder, n as InstallOptions, o as AddonDefinition, p as LoadedAddon, r as OptionMap, s as AddonInput, t as AddonMap, u as AddonSource, v as SetupResult, w as defineAddonOptions, x as Tests, y as SvApi } from "../engine-fG9K-byo.mjs";
1
+ import { A as BooleanQuestion, C as defineAddon, D as WorkspaceOptions, E as Workspace, F as Question, I as SelectQuestion, L as StringQuestion, M as NumberQuestion, N as OptionDefinition, O as createWorkspace, P as OptionValues, R as officialAddons, S as Verification, T as getErrorHint, _ as Scripts, a as Addon, b as TestDefinition, c as AddonReference, d as ConditionDefinition, f as ConfiguredAddon, g as PreparedAddon, h as PackageDefinition, i as add, j as MultiSelectQuestion, k as BaseQuestion, l as AddonResult, m as OptionBuilder, n as InstallOptions, o as AddonDefinition, p as LoadedAddon, r as OptionMap, s as AddonInput, t as AddonMap, u as AddonSource, v as SetupResult, w as defineAddonOptions, x as Tests, y as SvApi } from "../engine-DmG_8K_H.mjs";
2
2
 
3
3
  //#region src/create/index.d.ts
4
4
  type TemplateType = (typeof templateTypes)[number];
@@ -1,2 +1,2 @@
1
- import { d as defineAddon, f as defineAddonOptions, t as add, u as officialAddons, v as create } from "../engine-lCnxwqd0.mjs";
1
+ import { d as defineAddon, f as defineAddonOptions, t as add, u as officialAddons, v as create } from "../engine-B8V7JiJ3.mjs";
2
2
  export { add, create, defineAddon, defineAddonOptions, officialAddons };
@@ -1,4 +1,4 @@
1
- import { r as OptionMap, t as AddonMap } from "../engine-fG9K-byo.mjs";
1
+ import { r as OptionMap, t as AddonMap } from "../engine-DmG_8K_H.mjs";
2
2
  import { AgentName } from "@sveltejs/sv-utils";
3
3
  import { Page } from "@playwright/test";
4
4
  import * as vitest from "vitest";
@@ -1,4 +1,4 @@
1
- import { _ as z, b as __require, g as R, i as addPnpmBuildDependencies, t as add, v as create, x as __toESM, y as __commonJSMin } from "../engine-lCnxwqd0.mjs";
1
+ import { _ as z, b as __require, g as R, i as addPnpmBuildDependencies, t as add, v as create, x as __toESM, y as __commonJSMin } from "../engine-B8V7JiJ3.mjs";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import process$1 from "node:process";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sv",
3
- "version": "0.13.1",
3
+ "version": "0.13.2",
4
4
  "type": "module",
5
5
  "description": "A command line interface (CLI) for creating and maintaining Svelte applications",
6
6
  "license": "MIT",
@@ -25,7 +25,7 @@
25
25
  }
26
26
  },
27
27
  "dependencies": {
28
- "@sveltejs/sv-utils": "0.0.4"
28
+ "@sveltejs/sv-utils": "0.0.5"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@clack/prompts": "1.0.0",