sv 0.9.13 → 0.9.15

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.
@@ -1,4 +1,4 @@
1
- import { A as dedent_default, C as serializeScript, D as walk, E as Tag, G as any, J as require_picocolors, M as defineAddonOptions, R as T, S as parseScript$1, T as Element, _ as parseScript, b as import_picocolors$2, et as __toESM, f as detect, g as parseJson, h as parseHtml, j as defineAddon, k as createPrinter, m as parseCss, o as getUserAgent, p as resolveCommand, u as be, v as parseSvelte, w as stripAst, x as parseHtml$1, y as MagicString } from "./create-Bt2-1pFJ.js";
1
+ import { A as dedent_default, C as serializeScript, D as walk, E as Tag, G as any, J as require_picocolors, M as defineAddonOptions, R as T, S as parseScript$1, T as Element, _ as parseScript, a as getUserAgent, b as import_picocolors$2, et as __toESM, f as getSharedFiles, g as parseJson, h as parseHtml, j as defineAddon, k as createPrinter, l as detect, m as parseCss, p as resolveCommand, u as be, v as parseSvelte, w as stripAst, x as parseHtml$1, y as MagicString } from "./create-BOEKhcVU.js";
2
2
  import path from "node:path";
3
3
  import fs from "node:fs";
4
4
  import process from "node:process";
@@ -773,11 +773,17 @@ function addEslintConfigPrettier(content) {
773
773
  else elements.push(...nodesToInsert);
774
774
  return generateCode();
775
775
  }
776
- function addToDemoPage(content, path$1) {
777
- const { template, generateCode } = parseSvelte(content);
778
- for (const node of template.ast.childNodes) if (node.type === "tag" && node.attribs["href"] === `/demo/${path$1}`) return content;
779
- const newLine = template.source ? "\n" : "";
780
- return generateCode({ template: template.source + `${newLine}<a href="/demo/${path$1}">${path$1}</a>` });
776
+ function addToDemoPage(existingContent, path$1, typescript) {
777
+ const { script, template, generateCode } = parseSvelte(existingContent, { typescript });
778
+ for (const node of template.ast.childNodes) if (node.type === "tag" && node.attribs["href"].includes(`/demo/${path$1}`)) return existingContent;
779
+ addNamed(script.ast, {
780
+ imports: ["resolve"],
781
+ from: "$app/paths"
782
+ });
783
+ return generateCode({
784
+ script: script.generateCode(),
785
+ template: `<a href={resolve('/demo/${path$1}')}>${path$1}</a>\n${template.source}`
786
+ });
781
787
  }
782
788
  /**
783
789
  * Returns the corresponding `@types/node` version for the version of Node.js running in the current process.
@@ -886,7 +892,7 @@ var drizzle_default = defineAddon({
886
892
  runsAfter("prettier");
887
893
  if (!kit) return unsupported("Requires SvelteKit");
888
894
  },
889
- run: ({ sv, typescript, options: options$7, kit, dependencyVersion, cwd, cancel }) => {
895
+ run: ({ sv, typescript, options: options$7, kit, dependencyVersion, cwd, cancel, files }) => {
890
896
  if (!kit) throw new Error("SvelteKit is required");
891
897
  const ext = typescript ? "ts" : "js";
892
898
  const baseDBPath = path.resolve(cwd, kit.libDirectory, "server", "db");
@@ -896,10 +902,10 @@ var drizzle_default = defineAddon({
896
902
  database: path.resolve(baseDBPath, `index.${ext}`)
897
903
  };
898
904
  for (const [fileType, filePath] of Object.entries(paths)) if (fs.existsSync(filePath)) return cancel(`Preexisting ${fileType} file at '${filePath}'`);
899
- sv.devDependency("drizzle-orm", "^0.44.6");
900
- sv.devDependency("drizzle-kit", "^0.31.5");
905
+ sv.devDependency("drizzle-orm", "^0.44.7");
906
+ sv.devDependency("drizzle-kit", "^0.31.7");
901
907
  sv.devDependency("@types/node", getNodeTypesVersion());
902
- if (options$7.mysql === "mysql2") sv.dependency("mysql2", "^3.15.2");
908
+ if (options$7.mysql === "mysql2") sv.dependency("mysql2", "^3.15.3");
903
909
  if (options$7.mysql === "planetscale") sv.dependency("@planetscale/database", "^1.19.0");
904
910
  if (options$7.postgresql === "neon") sv.dependency("@neondatabase/serverless", "^1.0.2");
905
911
  if (options$7.postgresql === "postgres.js") sv.dependency("postgres", "^3.4.7");
@@ -960,7 +966,7 @@ var drizzle_default = defineAddon({
960
966
  return content;
961
967
  });
962
968
  }
963
- sv.file("package.json", (content) => {
969
+ sv.file(files.package, (content) => {
964
970
  const { data, generateCode } = parseJson(content);
965
971
  data.scripts ??= {};
966
972
  const scripts = data.scripts;
@@ -971,11 +977,11 @@ var drizzle_default = defineAddon({
971
977
  scripts["db:studio"] ??= "drizzle-kit studio";
972
978
  return generateCode();
973
979
  });
974
- if (Boolean(dependencyVersion("prettier"))) sv.file(".prettierignore", (content) => {
980
+ if (Boolean(dependencyVersion("prettier"))) sv.file(files.prettierignore, (content) => {
975
981
  if (!content.includes(`/drizzle/`)) return content.trimEnd() + "\n/drizzle/";
976
982
  return content;
977
983
  });
978
- if (options$7.database === "sqlite") sv.file(".gitignore", (content) => {
984
+ if (options$7.database === "sqlite") sv.file(files.gitignore, (content) => {
979
985
  if (content.length === 0) return content;
980
986
  if (!content.includes("\n*.db")) content = content.trimEnd() + "\n\n# SQLite\n*.db";
981
987
  return content;
@@ -1220,17 +1226,17 @@ var eslint_default = defineAddon({
1220
1226
  shortDescription: "linter",
1221
1227
  homepage: "https://eslint.org",
1222
1228
  options: {},
1223
- run: ({ sv, typescript, dependencyVersion }) => {
1229
+ run: ({ sv, typescript, dependencyVersion, files }) => {
1224
1230
  const prettierInstalled = Boolean(dependencyVersion("prettier"));
1225
- sv.devDependency("eslint", "^9.38.0");
1231
+ sv.devDependency("eslint", "^9.39.1");
1226
1232
  sv.devDependency("@eslint/compat", "^1.4.0");
1227
- sv.devDependency("eslint-plugin-svelte", "^3.12.4");
1228
- sv.devDependency("globals", "^16.4.0");
1229
- sv.devDependency("@eslint/js", "^9.38.0");
1233
+ sv.devDependency("eslint-plugin-svelte", "^3.13.0");
1234
+ sv.devDependency("globals", "^16.5.0");
1235
+ sv.devDependency("@eslint/js", "^9.39.1");
1230
1236
  sv.devDependency("@types/node", getNodeTypesVersion());
1231
- if (typescript) sv.devDependency("typescript-eslint", "^8.46.1");
1237
+ if (typescript) sv.devDependency("typescript-eslint", "^8.47.0");
1232
1238
  if (prettierInstalled) sv.devDependency("eslint-config-prettier", "^10.1.8");
1233
- sv.file("package.json", (content) => {
1239
+ sv.file(files.package, (content) => {
1234
1240
  const { data, generateCode } = parseJson(content);
1235
1241
  data.scripts ??= {};
1236
1242
  const scripts = data.scripts;
@@ -1239,14 +1245,14 @@ var eslint_default = defineAddon({
1239
1245
  if (!scripts["lint"].includes(LINT_CMD)) scripts["lint"] += ` && ${LINT_CMD}`;
1240
1246
  return generateCode();
1241
1247
  });
1242
- sv.file(".vscode/settings.json", (content) => {
1248
+ sv.file(files.vscodeSettings, (content) => {
1243
1249
  if (!content) return content;
1244
1250
  const { data, generateCode } = parseJson(content);
1245
1251
  const validate = data["eslint.validate"];
1246
1252
  if (validate && !validate.includes("svelte")) validate.push("svelte");
1247
1253
  return generateCode();
1248
1254
  });
1249
- sv.file("eslint.config.js", (content) => {
1255
+ sv.file(files.eslintConfig, (content) => {
1250
1256
  const { ast, generateCode } = parseScript(content);
1251
1257
  const eslintConfigs = [];
1252
1258
  addDefault(ast, {
@@ -1354,7 +1360,7 @@ var eslint_default = defineAddon({
1354
1360
  });
1355
1361
  return generateCode();
1356
1362
  });
1357
- if (prettierInstalled) sv.file("eslint.config.js", addEslintConfigPrettier);
1363
+ if (prettierInstalled) sv.file(files.eslintConfig, addEslintConfigPrettier);
1358
1364
  }
1359
1365
  });
1360
1366
 
@@ -1656,7 +1662,7 @@ var lucia_default = defineAddon({
1656
1662
  });
1657
1663
  if (options$7.demo) {
1658
1664
  sv.file(`${kit?.routesDirectory}/demo/+page.svelte`, (content) => {
1659
- return addToDemoPage(content, "lucia");
1665
+ return addToDemoPage(content, "lucia", typescript);
1660
1666
  });
1661
1667
  sv.file(`${kit.routesDirectory}/demo/lucia/login/+page.server.${ext}`, (content) => {
1662
1668
  if (content) {
@@ -2064,7 +2070,7 @@ var paraglide_default = defineAddon({
2064
2070
  const ext = typescript ? "ts" : "js";
2065
2071
  if (!kit) throw new Error("SvelteKit is required");
2066
2072
  const paraglideOutDir = "src/lib/paraglide";
2067
- sv.devDependency("@inlang/paraglide-js", "^2.4.0");
2073
+ sv.devDependency("@inlang/paraglide-js", "^2.5.0");
2068
2074
  sv.file("project.inlang/settings.json", (content) => {
2069
2075
  if (content) return content;
2070
2076
  const { data, generateCode } = parseJson(content);
@@ -2136,14 +2142,14 @@ var paraglide_default = defineAddon({
2136
2142
  };
2137
2143
  return generateCode();
2138
2144
  });
2139
- sv.file(".gitignore", (content) => {
2145
+ sv.file(files.gitignore, (content) => {
2140
2146
  if (!content) return content;
2141
2147
  if (!content.includes(`\n${paraglideOutDir}`)) content = content.trimEnd() + `\n\n# Paraglide\n${paraglideOutDir}`;
2142
2148
  return content;
2143
2149
  });
2144
2150
  if (options$7.demo) {
2145
2151
  sv.file(`${kit.routesDirectory}/demo/+page.svelte`, (content) => {
2146
- return addToDemoPage(content, "paraglide");
2152
+ return addToDemoPage(content, "paraglide", typescript);
2147
2153
  });
2148
2154
  sv.file(`${kit.routesDirectory}/demo/paraglide/+page.svelte`, (content) => {
2149
2155
  const { script, template, generateCode } = parseSvelte(content, { typescript });
@@ -2203,6 +2209,94 @@ function parseLanguageTagInput(input) {
2203
2209
  };
2204
2210
  }
2205
2211
 
2212
+ //#endregion
2213
+ //#region commands/add/utils.ts
2214
+ var import_picocolors$1 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
2215
+ function getPackageJson(cwd) {
2216
+ const packageText = readFile(cwd, commonFilePaths.packageJson);
2217
+ if (!packageText) {
2218
+ const pkgPath = path.join(cwd, commonFilePaths.packageJson);
2219
+ throw new Error(`Invalid workspace: missing '${pkgPath}'`);
2220
+ }
2221
+ const { data, generateCode } = parseJson(packageText);
2222
+ return {
2223
+ source: packageText,
2224
+ data,
2225
+ generateCode
2226
+ };
2227
+ }
2228
+ async function formatFiles(options$7) {
2229
+ const args = [
2230
+ "prettier",
2231
+ "--write",
2232
+ "--ignore-unknown",
2233
+ ...options$7.paths
2234
+ ];
2235
+ const cmd = resolveCommand(options$7.packageManager, "execute-local", args);
2236
+ await be(cmd.command, cmd.args, {
2237
+ nodeOptions: {
2238
+ cwd: options$7.cwd,
2239
+ stdio: "pipe"
2240
+ },
2241
+ throwOnError: true
2242
+ });
2243
+ }
2244
+ function readFile(cwd, filePath) {
2245
+ const fullFilePath = path.resolve(cwd, filePath);
2246
+ if (!fileExists(cwd, filePath)) return "";
2247
+ return fs.readFileSync(fullFilePath, "utf8");
2248
+ }
2249
+ function installPackages(dependencies, workspace) {
2250
+ const { data, generateCode } = getPackageJson(workspace.cwd);
2251
+ for (const dependency of dependencies) if (dependency.dev) {
2252
+ data.devDependencies ??= {};
2253
+ data.devDependencies[dependency.pkg] = dependency.version;
2254
+ } else {
2255
+ data.dependencies ??= {};
2256
+ data.dependencies[dependency.pkg] = dependency.version;
2257
+ }
2258
+ if (data.dependencies) data.dependencies = alphabetizeProperties(data.dependencies);
2259
+ if (data.devDependencies) data.devDependencies = alphabetizeProperties(data.devDependencies);
2260
+ writeFile(workspace, commonFilePaths.packageJson, generateCode());
2261
+ return commonFilePaths.packageJson;
2262
+ }
2263
+ function alphabetizeProperties(obj) {
2264
+ const orderedObj = {};
2265
+ const sortedEntries = Object.entries(obj).sort(([a], [b]) => a.localeCompare(b));
2266
+ for (const [key, value] of sortedEntries) orderedObj[key] = value;
2267
+ return orderedObj;
2268
+ }
2269
+ function writeFile(workspace, filePath, content) {
2270
+ const fullFilePath = path.resolve(workspace.cwd, filePath);
2271
+ const fullDirectoryPath = path.dirname(fullFilePath);
2272
+ if (content && !content.endsWith("\n")) content += "\n";
2273
+ if (!fs.existsSync(fullDirectoryPath)) fs.mkdirSync(fullDirectoryPath, { recursive: true });
2274
+ fs.writeFileSync(fullFilePath, content, "utf8");
2275
+ }
2276
+ function fileExists(cwd, filePath) {
2277
+ const fullFilePath = path.resolve(cwd, filePath);
2278
+ return fs.existsSync(fullFilePath);
2279
+ }
2280
+ const commonFilePaths = {
2281
+ packageJson: "package.json",
2282
+ svelteConfig: "svelte.config.js",
2283
+ svelteConfigTS: "svelte.config.ts",
2284
+ jsconfig: "jsconfig.json",
2285
+ tsconfig: "tsconfig.json",
2286
+ viteConfig: "vite.config.js",
2287
+ viteConfigTS: "vite.config.ts"
2288
+ };
2289
+ function getHighlighter() {
2290
+ return {
2291
+ command: (str) => import_picocolors$1.default.bold(import_picocolors$1.default.cyanBright(str)),
2292
+ env: (str) => import_picocolors$1.default.yellow(str),
2293
+ path: (str) => import_picocolors$1.default.green(str),
2294
+ route: (str) => import_picocolors$1.default.bold(str),
2295
+ website: (str) => import_picocolors$1.default.whiteBright(str),
2296
+ optional: (str) => import_picocolors$1.default.gray(str)
2297
+ };
2298
+ }
2299
+
2206
2300
  //#endregion
2207
2301
  //#region ../addons/mcp/index.ts
2208
2302
  const options$3 = defineAddonOptions().add("ide", {
@@ -2273,17 +2367,26 @@ var mcp_default = defineAddon({
2273
2367
  };
2274
2368
  const configurator = {
2275
2369
  "claude-code": {
2276
- filePath: ".mcp.json",
2370
+ agentPath: "CLAUDE.md",
2371
+ mcpPath: ".mcp.json",
2277
2372
  typeLocal: "stdio",
2278
2373
  typeRemote: "http",
2279
2374
  env: true
2280
2375
  },
2281
- cursor: { filePath: ".cursor/mcp.json" },
2282
- gemini: { filePath: ".gemini/settings.json" },
2376
+ cursor: {
2377
+ agentPath: "AGENTS.md",
2378
+ mcpPath: ".cursor/mcp.json"
2379
+ },
2380
+ gemini: {
2381
+ agentPath: "GEMINI.md",
2382
+ schema: "https://raw.githubusercontent.com/google-gemini/gemini-cli/main/schemas/settings.schema.json",
2383
+ mcpPath: ".gemini/settings.json"
2384
+ },
2283
2385
  opencode: {
2386
+ agentPath: "AGENTS.md",
2284
2387
  schema: "https://opencode.ai/config.json",
2285
2388
  mcpServersKey: "mcp",
2286
- filePath: "opencode.json",
2389
+ mcpPath: "opencode.json",
2287
2390
  typeLocal: "local",
2288
2391
  typeRemote: "remote",
2289
2392
  command: [
@@ -2294,19 +2397,31 @@ var mcp_default = defineAddon({
2294
2397
  args: null
2295
2398
  },
2296
2399
  vscode: {
2400
+ agentPath: "AGENTS.md",
2297
2401
  mcpServersKey: "servers",
2298
- filePath: ".vscode/mcp.json"
2402
+ mcpPath: ".vscode/mcp.json"
2299
2403
  },
2300
2404
  other: { other: true }
2301
2405
  };
2406
+ const filesAdded = [];
2407
+ const filesExistingAlready = [];
2408
+ const agentFile = getSharedFiles().filter((file) => file.include.includes("mcp")).find((file) => file.name === "AGENTS.md");
2302
2409
  for (const ide of options$7.ide) {
2303
2410
  const value = configurator[ide];
2304
2411
  if ("other" in value) continue;
2305
- const { mcpServersKey, filePath, typeLocal, typeRemote, env, schema, command, args } = value;
2306
- sv.file(filePath, (content) => {
2412
+ const { mcpServersKey, agentPath, mcpPath, typeLocal, typeRemote, env, schema, command, args } = value;
2413
+ if (!filesAdded.includes(agentPath)) sv.file(agentPath, (content) => {
2414
+ if (content) {
2415
+ filesExistingAlready.push(agentPath);
2416
+ return content;
2417
+ }
2418
+ filesAdded.push(agentPath);
2419
+ return agentFile?.contents ?? "";
2420
+ });
2421
+ sv.file(mcpPath, (content) => {
2307
2422
  const { data, generateCode } = parseJson(content);
2308
2423
  if (schema) data["$schema"] = schema;
2309
- const key = mcpServersKey || "mcpServers";
2424
+ const key = mcpServersKey ?? "mcpServers";
2310
2425
  data[key] ??= {};
2311
2426
  data[key].svelte = options$7.setup === "local" ? getLocalConfig({
2312
2427
  type: typeLocal,
@@ -2317,6 +2432,10 @@ var mcp_default = defineAddon({
2317
2432
  return generateCode();
2318
2433
  });
2319
2434
  }
2435
+ if (filesExistingAlready.length > 0) {
2436
+ const highlighter = getHighlighter();
2437
+ T.warn(`${filesExistingAlready.map((path$1) => highlighter.path(path$1)).join(", ")} already exists, we didn't touch ${filesExistingAlready.length > 1 ? "them" : "it"}. See ${highlighter.website("https://svelte.dev/docs/mcp/overview#Usage")} for manual setup.`);
2438
+ }
2320
2439
  },
2321
2440
  nextSteps({ highlighter, options: options$7 }) {
2322
2441
  const steps = [];
@@ -2332,10 +2451,10 @@ var playwright_default = defineAddon({
2332
2451
  shortDescription: "browser testing",
2333
2452
  homepage: "https://playwright.dev",
2334
2453
  options: {},
2335
- run: ({ sv, typescript }) => {
2454
+ run: ({ sv, typescript, files }) => {
2336
2455
  const ext = typescript ? "ts" : "js";
2337
2456
  sv.devDependency("@playwright/test", "^1.56.1");
2338
- sv.file("package.json", (content) => {
2457
+ sv.file(files.package, (content) => {
2339
2458
  const { data, generateCode } = parseJson(content);
2340
2459
  data.scripts ??= {};
2341
2460
  const scripts = data.scripts;
@@ -2346,7 +2465,7 @@ var playwright_default = defineAddon({
2346
2465
  if (!scripts["test"].includes(RUN_TEST)) scripts["test"] += ` && ${RUN_TEST}`;
2347
2466
  return generateCode();
2348
2467
  });
2349
- sv.file(".gitignore", (content) => {
2468
+ sv.file(files.gitignore, (content) => {
2350
2469
  if (!content) return content;
2351
2470
  if (content.includes("test-results")) return content;
2352
2471
  return "test-results\n" + content.trim();
@@ -2393,12 +2512,12 @@ var prettier_default = defineAddon({
2393
2512
  shortDescription: "formatter",
2394
2513
  homepage: "https://prettier.io",
2395
2514
  options: {},
2396
- run: ({ sv, dependencyVersion }) => {
2515
+ run: ({ sv, dependencyVersion, kit, files }) => {
2397
2516
  const tailwindcssInstalled = Boolean(dependencyVersion("tailwindcss"));
2398
2517
  if (tailwindcssInstalled) sv.devDependency("prettier-plugin-tailwindcss", "^0.7.1");
2399
2518
  sv.devDependency("prettier", "^3.6.2");
2400
2519
  sv.devDependency("prettier-plugin-svelte", "^3.4.0");
2401
- sv.file(".prettierignore", (content) => {
2520
+ sv.file(files.prettierignore, (content) => {
2402
2521
  if (content) return content;
2403
2522
  return dedent_default`
2404
2523
  # Package Managers
@@ -2412,7 +2531,7 @@ var prettier_default = defineAddon({
2412
2531
  /static/
2413
2532
  `;
2414
2533
  });
2415
- sv.file(".prettierrc", (content) => {
2534
+ sv.file(files.prettierrc, (content) => {
2416
2535
  let data, generateCode;
2417
2536
  try {
2418
2537
  ({data, generateCode} = parseJson(content));
@@ -2430,7 +2549,7 @@ var prettier_default = defineAddon({
2430
2549
  const plugins$1 = data.plugins;
2431
2550
  if (tailwindcssInstalled) {
2432
2551
  if (!plugins$1.includes("prettier-plugin-tailwindcss")) data.plugins.unshift("prettier-plugin-tailwindcss");
2433
- data.tailwindStylesheet ??= "./src/app.css";
2552
+ data.tailwindStylesheet ??= kit ? `${kit?.routesDirectory}/layout.css` : "./src/app.css";
2434
2553
  }
2435
2554
  if (!plugins$1.includes("prettier-plugin-svelte")) data.plugins.unshift("prettier-plugin-svelte");
2436
2555
  data.overrides ??= [];
@@ -2443,7 +2562,7 @@ var prettier_default = defineAddon({
2443
2562
  });
2444
2563
  const eslintVersion = dependencyVersion("eslint");
2445
2564
  const eslintInstalled = hasEslint(eslintVersion);
2446
- sv.file("package.json", (content) => {
2565
+ sv.file(files.package, (content) => {
2447
2566
  const { data, generateCode } = parseJson(content);
2448
2567
  data.scripts ??= {};
2449
2568
  const scripts = data.scripts;
@@ -2458,7 +2577,7 @@ var prettier_default = defineAddon({
2458
2577
  if (eslintVersion?.startsWith(SUPPORTED_ESLINT_VERSION) === false) T.warn(`An older major version of ${import_picocolors$2.default.yellow("eslint")} was detected. Skipping ${import_picocolors$2.default.yellow("eslint-config-prettier")} installation.`);
2459
2578
  if (eslintInstalled) {
2460
2579
  sv.devDependency("eslint-config-prettier", "^10.1.8");
2461
- sv.file("eslint.config.js", addEslintConfigPrettier);
2580
+ sv.file(files.eslintConfig, addEslintConfigPrettier);
2462
2581
  }
2463
2582
  }
2464
2583
  });
@@ -2511,7 +2630,7 @@ const adapters = [
2511
2630
  {
2512
2631
  id: "vercel",
2513
2632
  package: "@sveltejs/adapter-vercel",
2514
- version: "^6.0.0"
2633
+ version: "^6.1.1"
2515
2634
  },
2516
2635
  {
2517
2636
  id: "cloudflare",
@@ -2545,7 +2664,7 @@ var sveltekit_adapter_default = defineAddon({
2545
2664
  },
2546
2665
  run: ({ sv, options: options$7, files }) => {
2547
2666
  const adapter = adapters.find((a) => a.id === options$7.adapter);
2548
- sv.file("package.json", (content) => {
2667
+ sv.file(files.package, (content) => {
2549
2668
  const { data, generateCode } = parseJson(content);
2550
2669
  const devDeps = data["devDependencies"];
2551
2670
  for (const pkg of Object.keys(devDeps)) if (pkg.startsWith("@sveltejs/adapter-")) delete devDeps[pkg];
@@ -2617,8 +2736,8 @@ var tailwindcss_default = defineAddon({
2617
2736
  options: options$1,
2618
2737
  run: ({ sv, options: options$7, files, typescript, kit, dependencyVersion }) => {
2619
2738
  const prettierInstalled = Boolean(dependencyVersion("prettier"));
2620
- sv.devDependency("tailwindcss", "^4.1.14");
2621
- sv.devDependency("@tailwindcss/vite", "^4.1.14");
2739
+ sv.devDependency("tailwindcss", "^4.1.17");
2740
+ sv.devDependency("@tailwindcss/vite", "^4.1.17");
2622
2741
  sv.pnpmBuildDependency("@tailwindcss/oxide");
2623
2742
  if (prettierInstalled) sv.devDependency("prettier-plugin-tailwindcss", "^0.7.1");
2624
2743
  for (const plugin of plugins) {
@@ -2638,7 +2757,7 @@ var tailwindcss_default = defineAddon({
2638
2757
  });
2639
2758
  return generateCode();
2640
2759
  });
2641
- sv.file("src/app.css", (content) => {
2760
+ sv.file(files.stylesheet, (content) => {
2642
2761
  let atRules = parseCss(content).ast.nodes.filter((node) => node.type === "atrule");
2643
2762
  const findAtRule = (name, params) => atRules.find((rule) => rule.name === name && rule.params.replace(/['"]/g, "") === params);
2644
2763
  let code = content;
@@ -2656,34 +2775,53 @@ var tailwindcss_default = defineAddon({
2656
2775
  }
2657
2776
  return code;
2658
2777
  });
2659
- if (!kit) sv.file("src/App.svelte", (content) => {
2660
- const { script, generateCode } = parseSvelte(content, { typescript });
2661
- addEmpty(script.ast, { from: "./app.css" });
2662
- return generateCode({ script: script.generateCode() });
2663
- });
2664
- else sv.file(`${kit?.routesDirectory}/+layout.svelte`, (content) => {
2665
- const { script, template, generateCode } = parseSvelte(content, { typescript });
2666
- addEmpty(script.ast, { from: "../app.css" });
2667
- if (content.length === 0) {
2668
- const svelteVersion = dependencyVersion("svelte");
2669
- if (!svelteVersion) throw new Error("Failed to determine svelte version");
2670
- addSlot(script.ast, {
2671
- htmlAst: template.ast,
2672
- svelteVersion
2778
+ if (!kit) {
2779
+ const appSvelte = "src/App.svelte";
2780
+ const stylesheetRelative = files.getRelative({
2781
+ from: appSvelte,
2782
+ to: files.stylesheet
2783
+ });
2784
+ sv.file(appSvelte, (content) => {
2785
+ const { script, generateCode } = parseSvelte(content, { typescript });
2786
+ addEmpty(script.ast, { from: stylesheetRelative });
2787
+ return generateCode({ script: script.generateCode() });
2788
+ });
2789
+ } else {
2790
+ const layoutSvelte = `${kit?.routesDirectory}/+layout.svelte`;
2791
+ const stylesheetRelative = files.getRelative({
2792
+ from: layoutSvelte,
2793
+ to: files.stylesheet
2794
+ });
2795
+ sv.file(layoutSvelte, (content) => {
2796
+ const { script, template, generateCode } = parseSvelte(content, { typescript });
2797
+ addEmpty(script.ast, { from: stylesheetRelative });
2798
+ if (content.length === 0) {
2799
+ const svelteVersion = dependencyVersion("svelte");
2800
+ if (!svelteVersion) throw new Error("Failed to determine svelte version");
2801
+ addSlot(script.ast, {
2802
+ htmlAst: template.ast,
2803
+ svelteVersion
2804
+ });
2805
+ }
2806
+ return generateCode({
2807
+ script: script.generateCode(),
2808
+ template: content.length === 0 ? template.generateCode() : void 0
2673
2809
  });
2674
- }
2675
- return generateCode({
2676
- script: script.generateCode(),
2677
- template: content.length === 0 ? template.generateCode() : void 0
2678
2810
  });
2811
+ }
2812
+ sv.file(files.vscodeSettings, (content) => {
2813
+ const { data, generateCode } = parseJson(content);
2814
+ data["files.associations"] ??= {};
2815
+ data["files.associations"]["*.css"] = "tailwindcss";
2816
+ return generateCode();
2679
2817
  });
2680
- if (prettierInstalled) sv.file(".prettierrc", (content) => {
2818
+ if (prettierInstalled) sv.file(files.prettierrc, (content) => {
2681
2819
  const { data, generateCode } = parseJson(content);
2682
2820
  const PLUGIN_NAME = "prettier-plugin-tailwindcss";
2683
2821
  data.plugins ??= [];
2684
2822
  const plugins$1 = data.plugins;
2685
2823
  if (!plugins$1.includes(PLUGIN_NAME)) plugins$1.push(PLUGIN_NAME);
2686
- data.tailwindStylesheet ??= "./src/app.css";
2824
+ data.tailwindStylesheet ??= files.getRelative({ to: files.stylesheet });
2687
2825
  return generateCode();
2688
2826
  });
2689
2827
  }
@@ -2704,22 +2842,24 @@ const options = defineAddonOptions().add("usages", {
2704
2842
  }],
2705
2843
  required: true
2706
2844
  }).build();
2845
+ let vitestV3Installed = false;
2707
2846
  var vitest_addon_default = defineAddon({
2708
2847
  id: "vitest",
2709
2848
  shortDescription: "unit testing",
2710
2849
  homepage: "https://vitest.dev",
2711
2850
  options,
2712
- run: ({ sv, files, typescript, kit, options: options$7 }) => {
2851
+ run: ({ sv, files, typescript, kit, options: options$7, dependencyVersion }) => {
2713
2852
  const ext = typescript ? "ts" : "js";
2714
2853
  const unitTesting = options$7.usages.includes("unit");
2715
2854
  const componentTesting = options$7.usages.includes("component");
2716
- sv.devDependency("vitest", "^4.0.5");
2855
+ vitestV3Installed = (dependencyVersion("vitest") ?? "").replaceAll("^", "").replaceAll("~", "")?.startsWith("3.");
2856
+ sv.devDependency("vitest", "^4.0.10");
2717
2857
  if (componentTesting) {
2718
- sv.devDependency("@vitest/browser-playwright", "^4.0.5");
2858
+ sv.devDependency("@vitest/browser-playwright", "^4.0.10");
2719
2859
  sv.devDependency("vitest-browser-svelte", "^2.0.1");
2720
2860
  sv.devDependency("playwright", "^1.56.1");
2721
2861
  }
2722
- sv.file("package.json", (content) => {
2862
+ sv.file(files.package, (content) => {
2723
2863
  const { data, generateCode } = parseJson(content);
2724
2864
  data.scripts ??= {};
2725
2865
  const scripts = data.scripts;
@@ -2826,6 +2966,18 @@ var vitest_addon_default = defineAddon({
2826
2966
  }
2827
2967
  return generateCode();
2828
2968
  });
2969
+ },
2970
+ nextSteps: ({ highlighter, typescript, options: options$7 }) => {
2971
+ const toReturn = [];
2972
+ if (vitestV3Installed) {
2973
+ if (options$7.usages.includes("component")) {
2974
+ toReturn.push(`Uninstall ${highlighter.command("@vitest/browser")} package`);
2975
+ toReturn.push(`Update usage from ${highlighter.command("'@vitest/browser...'")} to ${highlighter.command("'vitest/browser'")}`);
2976
+ }
2977
+ toReturn.push(`${highlighter.optional("Optional")} Check ${highlighter.path("./vite.config.ts")} and remove duplicate project definitions`);
2978
+ toReturn.push(`${highlighter.optional("Optional")} Remove ${highlighter.path("./vitest-setup-client" + (typescript ? ".ts" : ".js"))} file`);
2979
+ }
2980
+ return toReturn;
2829
2981
  }
2830
2982
  });
2831
2983
 
@@ -2861,93 +3013,6 @@ async function getCommunityAddon(name) {
2861
3013
  return details;
2862
3014
  }
2863
3015
 
2864
- //#endregion
2865
- //#region commands/add/utils.ts
2866
- var import_picocolors$1 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
2867
- function getPackageJson(cwd) {
2868
- const packageText = readFile(cwd, commonFilePaths.packageJson);
2869
- if (!packageText) {
2870
- const pkgPath = path.join(cwd, commonFilePaths.packageJson);
2871
- throw new Error(`Invalid workspace: missing '${pkgPath}'`);
2872
- }
2873
- const { data, generateCode } = parseJson(packageText);
2874
- return {
2875
- source: packageText,
2876
- data,
2877
- generateCode
2878
- };
2879
- }
2880
- async function formatFiles(options$7) {
2881
- const args = [
2882
- "prettier",
2883
- "--write",
2884
- "--ignore-unknown",
2885
- ...options$7.paths
2886
- ];
2887
- const cmd = resolveCommand(options$7.packageManager, "execute-local", args);
2888
- await be(cmd.command, cmd.args, {
2889
- nodeOptions: {
2890
- cwd: options$7.cwd,
2891
- stdio: "pipe"
2892
- },
2893
- throwOnError: true
2894
- });
2895
- }
2896
- function readFile(cwd, filePath) {
2897
- const fullFilePath = path.resolve(cwd, filePath);
2898
- if (!fileExists(cwd, filePath)) return "";
2899
- return fs.readFileSync(fullFilePath, "utf8");
2900
- }
2901
- function installPackages(dependencies, workspace) {
2902
- const { data, generateCode } = getPackageJson(workspace.cwd);
2903
- for (const dependency of dependencies) if (dependency.dev) {
2904
- data.devDependencies ??= {};
2905
- data.devDependencies[dependency.pkg] = dependency.version;
2906
- } else {
2907
- data.dependencies ??= {};
2908
- data.dependencies[dependency.pkg] = dependency.version;
2909
- }
2910
- if (data.dependencies) data.dependencies = alphabetizeProperties(data.dependencies);
2911
- if (data.devDependencies) data.devDependencies = alphabetizeProperties(data.devDependencies);
2912
- writeFile(workspace, commonFilePaths.packageJson, generateCode());
2913
- return commonFilePaths.packageJson;
2914
- }
2915
- function alphabetizeProperties(obj) {
2916
- const orderedObj = {};
2917
- const sortedEntries = Object.entries(obj).sort(([a], [b]) => a.localeCompare(b));
2918
- for (const [key, value] of sortedEntries) orderedObj[key] = value;
2919
- return orderedObj;
2920
- }
2921
- function writeFile(workspace, filePath, content) {
2922
- const fullFilePath = path.resolve(workspace.cwd, filePath);
2923
- const fullDirectoryPath = path.dirname(fullFilePath);
2924
- if (content && !content.endsWith("\n")) content += "\n";
2925
- if (!fs.existsSync(fullDirectoryPath)) fs.mkdirSync(fullDirectoryPath, { recursive: true });
2926
- fs.writeFileSync(fullFilePath, content, "utf8");
2927
- }
2928
- function fileExists(cwd, filePath) {
2929
- const fullFilePath = path.resolve(cwd, filePath);
2930
- return fs.existsSync(fullFilePath);
2931
- }
2932
- const commonFilePaths = {
2933
- packageJson: "package.json",
2934
- svelteConfig: "svelte.config.js",
2935
- svelteConfigTS: "svelte.config.ts",
2936
- jsconfig: "jsconfig.json",
2937
- tsconfig: "tsconfig.json",
2938
- viteConfig: "vite.config.js",
2939
- viteConfigTS: "vite.config.ts"
2940
- };
2941
- function getHighlighter() {
2942
- return {
2943
- command: (str) => import_picocolors$1.default.bold(import_picocolors$1.default.cyanBright(str)),
2944
- env: (str) => import_picocolors$1.default.yellow(str),
2945
- path: (str) => import_picocolors$1.default.green(str),
2946
- route: (str) => import_picocolors$1.default.bold(str),
2947
- website: (str) => import_picocolors$1.default.whiteBright(str)
2948
- };
2949
- }
2950
-
2951
3016
  //#endregion
2952
3017
  //#region commands/add/workspace.ts
2953
3018
  async function createWorkspace({ cwd, options: options$7 = {}, packageManager }) {
@@ -2974,6 +3039,8 @@ async function createWorkspace({ cwd, options: options$7 = {}, packageManager })
2974
3039
  directory = path.dirname(directory);
2975
3040
  }
2976
3041
  for (const [key, value] of Object.entries(dependencies)) dependencies[key] = value.replaceAll(/[^\d|.]/g, "");
3042
+ const kit = dependencies["@sveltejs/kit"] ? parseKitOptions(resolvedCwd) : void 0;
3043
+ const stylesheet = kit ? `${kit.routesDirectory}/layout.css` : "src/app.css";
2977
3044
  return {
2978
3045
  cwd: resolvedCwd,
2979
3046
  options: options$7,
@@ -2981,9 +3048,22 @@ async function createWorkspace({ cwd, options: options$7 = {}, packageManager })
2981
3048
  typescript: usesTypescript,
2982
3049
  files: {
2983
3050
  viteConfig,
2984
- svelteConfig
3051
+ svelteConfig,
3052
+ stylesheet,
3053
+ package: "package.json",
3054
+ gitignore: ".gitignore",
3055
+ prettierignore: ".prettierignore",
3056
+ prettierrc: ".prettierrc",
3057
+ eslintConfig: "eslint.config.js",
3058
+ vscodeSettings: ".vscode/settings.json",
3059
+ getRelative({ from, to }) {
3060
+ from = from ?? "";
3061
+ let relativePath = path.posix.relative(path.posix.dirname(from), to);
3062
+ if (!relativePath.startsWith(".") && !relativePath.startsWith("/")) relativePath = `./${relativePath}`;
3063
+ return relativePath;
3064
+ }
2985
3065
  },
2986
- kit: dependencies["@sveltejs/kit"] ? parseKitOptions(resolvedCwd) : void 0,
3066
+ kit,
2987
3067
  dependencyVersion: (pkg) => dependencies[pkg]
2988
3068
  };
2989
3069
  }
@@ -3184,4 +3264,4 @@ function orderAddons(addons, setupResults) {
3184
3264
  }
3185
3265
 
3186
3266
  //#endregion
3187
- export { formatFiles as a, getCommunityAddon as c, createDefault as d, addDefault as f, createWorkspace as i, getAddonDetails as l, overrideProperties as m, installAddon as n, getHighlighter as o, create as p, setupAddons as r, communityAddonIds as s, applyAddons as t, officialAddons as u };
3267
+ export { communityAddonIds as a, officialAddons as c, createDefault as d, addDefault as f, createWorkspace as i, formatFiles as l, overrideProperties as m, installAddon as n, getCommunityAddon as o, create as p, setupAddons as r, getAddonDetails as s, applyAddons as t, getHighlighter as u };