sv 0.10.4 → 0.10.6

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
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { $ as et, A as parseSvelte, B as isVersionUnsupportedBelow, C as dist, G as De, J, K as Fe, O as parseJson, Q as We, T as resolveCommand, X as T, Y as Ke, Z as Ue, a as getUserAgent, at as Option, b as detect, c as packageManagerPrompt, d as from, et as ke, f as commonFilePaths, g as getPackageJson, h as getHighlighter, i as addPnpmBuildDependencies, it as Command, k as parseScript, lt as __toESM, m as formatFiles, n as templates, nt as Vu, o as installDependencies, ot as program, q as Ge, r as AGENT_NAMES, rt as require_picocolors, s as installOption, t as create$1, tt as ze, u as up$1, w as getSharedFiles } from "./create-DJeT6Cfe.js";
3
- import { a as communityAddonIds, c as officialAddons, d as create$2, f as overrideProperties, i as createWorkspace, l as createDefault, o as getCommunityAddon, r as setupAddons, s as getAddonDetails, t as applyAddons, u as addDefault } from "./install-6J55LDIW.js";
2
+ import { $ as et, A as parseSvelte, B as isVersionUnsupportedBelow, C as dist, G as De, J, K as Fe, O as parseJson, Q as We, T as resolveCommand, X as T, Y as Ke, Z as Ue, a as getUserAgent, at as Option, b as detect, c as packageManagerPrompt, d as from, et as ke, f as commonFilePaths, g as getPackageJson, h as getHighlighter, i as addPnpmBuildDependencies, it as Command, k as parseScript, lt as __toESM, m as formatFiles, n as templates, nt as Vu, o as installDependencies, ot as program, q as Ge, r as AGENT_NAMES, rt as require_picocolors, s as installOption, t as create$1, tt as ze, u as up$1, w as getSharedFiles } from "./create-DTIS6AzL.js";
3
+ import { a as communityAddonIds, c as officialAddons, d as create$2, f as overrideProperties, i as createWorkspace, l as createDefault, o as getCommunityAddon, r as setupAddons, s as getAddonDetails, t as applyAddons, u as addDefault } from "./install-BfCQ4zdp.js";
4
4
  import { exec, execSync } from "node:child_process";
5
5
  import path, { dirname, join } from "node:path";
6
6
  import fs, { existsSync } from "node:fs";
@@ -12,7 +12,7 @@ import { pipeline } from "node:stream/promises";
12
12
 
13
13
  //#region package.json
14
14
  var name = "sv";
15
- var version = "0.10.4";
15
+ var version = "0.10.6";
16
16
 
17
17
  //#endregion
18
18
  //#region ../../node_modules/.pnpm/empathic@1.1.0/node_modules/empathic/package.mjs
@@ -984,7 +984,8 @@ async function runAddonsApply({ answersOfficial, answersCommunity, options: opti
984
984
  if (!addonSetupResults) addonSetupResults = setupAddons(selectedAddons.length ? selectedAddons.map(({ addon }) => addon) : officialAddons$1, workspace);
985
985
  if (selectedAddons.length === 0) return {
986
986
  nextSteps: [],
987
- argsFormattedAddons: []
987
+ argsFormattedAddons: [],
988
+ filesToFormat: []
988
989
  };
989
990
  const officialDetails = Object.keys(answersOfficial).map((id) => getAddonDetails(id));
990
991
  const commDetails = Object.keys(answersCommunity).map((id) => communityDetails.find((a) => a.id === id));
@@ -1038,21 +1039,11 @@ async function runAddonsApply({ answersOfficial, answersCommunity, options: opti
1038
1039
  if (packageManager) {
1039
1040
  workspace.packageManager = packageManager;
1040
1041
  await installDependencies(packageManager, options$1.cwd);
1041
- }
1042
- if (filesToFormat.length > 0 && packageManager && !!workspace.dependencyVersion("prettier")) {
1043
- const { start, stop } = J();
1044
- start("Formatting modified files");
1045
- try {
1046
- await formatFiles({
1047
- packageManager,
1048
- cwd: options$1.cwd,
1049
- paths: filesToFormat
1050
- });
1051
- stop("Successfully formatted modified files");
1052
- } catch (e) {
1053
- stop("Failed to format files");
1054
- if (e instanceof Error) T.error(e.message);
1055
- }
1042
+ await formatFiles({
1043
+ packageManager,
1044
+ cwd: options$1.cwd,
1045
+ filesToFormat
1046
+ });
1056
1047
  }
1057
1048
  const highlighter = getHighlighter();
1058
1049
  return {
@@ -1069,7 +1060,8 @@ async function runAddonsApply({ answersOfficial, answersCommunity, options: opti
1069
1060
  addonMessage += ` - ${addonNextSteps.join("\n - ")}`;
1070
1061
  return addonMessage;
1071
1062
  }).filter((msg) => msg !== void 0),
1072
- argsFormattedAddons
1063
+ argsFormattedAddons,
1064
+ filesToFormat
1073
1065
  };
1074
1066
  }
1075
1067
  /**
@@ -1520,7 +1512,6 @@ async function createProject(cwd, options$1) {
1520
1512
  const workspace = await createVirtualWorkspace({
1521
1513
  cwd: projectPath,
1522
1514
  template,
1523
- packageManager: "npm",
1524
1515
  type: language
1525
1516
  });
1526
1517
  if (options$1.addOns || options$1.add.length > 0) {
@@ -1552,8 +1543,9 @@ async function createProject(cwd, options$1) {
1552
1543
  T.success("Project created");
1553
1544
  let addOnNextSteps = [];
1554
1545
  let argsFormattedAddons = [];
1546
+ let addOnFilesToFormat = [];
1555
1547
  if (options$1.addOns || options$1.add.length > 0) {
1556
- const { nextSteps, argsFormattedAddons: argsFormatted$1 } = await runAddonsApply({
1548
+ const { nextSteps, argsFormattedAddons: argsFormatted$1, filesToFormat } = await runAddonsApply({
1557
1549
  answersOfficial,
1558
1550
  answersCommunity,
1559
1551
  options: {
@@ -1569,6 +1561,7 @@ async function createProject(cwd, options$1) {
1569
1561
  fromCommand: "create"
1570
1562
  });
1571
1563
  argsFormattedAddons = argsFormatted$1;
1564
+ addOnFilesToFormat = filesToFormat;
1572
1565
  addOnNextSteps = nextSteps;
1573
1566
  }
1574
1567
  const packageManager = options$1.install === false ? null : options$1.install === true ? await packageManagerPrompt(projectPath) : options$1.install;
@@ -1580,7 +1573,14 @@ async function createProject(cwd, options$1) {
1580
1573
  if (argsFormattedAddons.length > 0) argsFormatted.push("--add", ...argsFormattedAddons);
1581
1574
  logArgs(packageManager, "create", argsFormatted, [directory]);
1582
1575
  await addPnpmBuildDependencies(projectPath, packageManager, ["esbuild"]);
1583
- if (packageManager) await installDependencies(packageManager, projectPath);
1576
+ if (packageManager) {
1577
+ await installDependencies(packageManager, projectPath);
1578
+ await formatFiles({
1579
+ packageManager,
1580
+ cwd: projectPath,
1581
+ filesToFormat: addOnFilesToFormat
1582
+ });
1583
+ }
1584
1584
  return {
1585
1585
  directory: projectPath,
1586
1586
  addOnNextSteps,
@@ -1606,7 +1606,7 @@ async function confirmExternalDependencies(dependencies) {
1606
1606
  }
1607
1607
  return installDeps;
1608
1608
  }
1609
- async function createVirtualWorkspace({ cwd, template, packageManager, type }) {
1609
+ async function createVirtualWorkspace({ cwd, template, type }) {
1610
1610
  const override = { dependencies: {} };
1611
1611
  if (template === "minimal" || template === "demo" || template === "library") override.kit = {
1612
1612
  routesDirectory: "src/routes",
@@ -1620,7 +1620,6 @@ async function createVirtualWorkspace({ cwd, template, packageManager, type }) {
1620
1620
  };
1621
1621
  const tentativeWorkspace = await createWorkspace({
1622
1622
  cwd,
1623
- packageManager,
1624
1623
  override
1625
1624
  });
1626
1625
  return {
@@ -32104,20 +32104,35 @@ function getPackageJson(cwd$1) {
32104
32104
  };
32105
32105
  }
32106
32106
  async function formatFiles(options) {
32107
+ if (options.filesToFormat.length === 0) return;
32108
+ const { start, stop } = J();
32109
+ start("Formatting modified files");
32107
32110
  const args = [
32108
32111
  "prettier",
32109
32112
  "--write",
32110
32113
  "--ignore-unknown",
32111
- ...options.paths
32114
+ ...options.filesToFormat
32112
32115
  ];
32113
32116
  const cmd = resolveCommand(options.packageManager, "execute-local", args);
32114
- await be(cmd.command, cmd.args, {
32115
- nodeOptions: {
32116
- cwd: options.cwd,
32117
- stdio: "pipe"
32118
- },
32119
- throwOnError: true
32120
- });
32117
+ try {
32118
+ const result = await be(cmd.command, cmd.args, {
32119
+ nodeOptions: {
32120
+ cwd: options.cwd,
32121
+ stdio: "pipe"
32122
+ },
32123
+ throwOnError: true
32124
+ });
32125
+ if (result.exitCode !== 0) {
32126
+ stop("Failed to format files");
32127
+ T.error(result.stderr);
32128
+ return;
32129
+ }
32130
+ } catch (e$1) {
32131
+ stop("Failed to format files");
32132
+ T.error(e$1?.output?.stderr || "unknown error");
32133
+ return;
32134
+ }
32135
+ stop("Successfully formatted modified files");
32121
32136
  }
32122
32137
  function readFile(cwd$1, filePath) {
32123
32138
  const fullFilePath = path.resolve(cwd$1, filePath);
@@ -1,4 +1,4 @@
1
- import { A as parseSvelte, D as parseHtml, E as parseCss, F as serializeScript, H as dedent_default, I as stripAst, L as Element, M as import_picocolors$1, N as parseHtml$1, O as parseJson, P as parseScript$1, R as Tag, T as resolveCommand, U as defineAddon, V as createPrinter, W as defineAddonOptions, X as T, _ as installPackages, a as getUserAgent, b as detect, f as commonFilePaths, g as getPackageJson, h as getHighlighter, j as MagicString, k as parseScript, l as any, lt as __toESM, p as fileExists, rt as require_picocolors, v as readFile, w as getSharedFiles, x as be, y as writeFile, z as walk } from "./create-DJeT6Cfe.js";
1
+ import { A as parseSvelte, D as parseHtml, E as parseCss, F as serializeScript, H as dedent_default, I as stripAst, L as Element, M as import_picocolors$1, N as parseHtml$1, O as parseJson, P as parseScript$1, R as Tag, T as resolveCommand, U as defineAddon, V as createPrinter, W as defineAddonOptions, X as T, _ as installPackages, a as getUserAgent, b as detect, f as commonFilePaths, g as getPackageJson, h as getHighlighter, j as MagicString, k as parseScript, l as any, lt as __toESM, p as fileExists, rt as require_picocolors, v as readFile, w as getSharedFiles, x as be, y as writeFile, z as walk } from "./create-DTIS6AzL.js";
2
2
  import path from "node:path";
3
3
  import fs from "node:fs";
4
4
  import process from "node:process";
@@ -2464,7 +2464,7 @@ var prettier_default = defineAddon({
2464
2464
  if (!plugins$1.includes("prettier-plugin-tailwindcss")) data.plugins.unshift("prettier-plugin-tailwindcss");
2465
2465
  data.tailwindStylesheet ??= files.getRelative({ to: files.stylesheet });
2466
2466
  }
2467
- if (!plugins$1.includes("prettier-plugin-svelte")) data.plugins.unshift("prettier-plugin-svelte");
2467
+ if (!plugins$1.includes("prettier-plugin-svelte")) data.plugins.push("prettier-plugin-svelte");
2468
2468
  data.overrides ??= [];
2469
2469
  const overrides = data.overrides;
2470
2470
  if (!overrides.find((o) => o?.options?.parser === "svelte")) overrides.push({
@@ -2501,6 +2501,7 @@ function hasEslint(version) {
2501
2501
 
2502
2502
  //#endregion
2503
2503
  //#region ../addons/storybook/index.ts
2504
+ const STORYBOOK_VERSION = "10.1.0";
2504
2505
  var storybook_default = defineAddon({
2505
2506
  id: "storybook",
2506
2507
  shortDescription: "frontend workshop",
@@ -2512,9 +2513,10 @@ var storybook_default = defineAddon({
2512
2513
  },
2513
2514
  run: async ({ sv }) => {
2514
2515
  const args = [
2515
- "create-storybook@latest",
2516
+ `create-storybook@${STORYBOOK_VERSION}`,
2516
2517
  "--skip-install",
2517
- "--no-dev"
2518
+ "--no-dev",
2519
+ "--no-features"
2518
2520
  ];
2519
2521
  if (process.env.NODE_ENV?.toLowerCase() === "test") args.push("--yes");
2520
2522
  await sv.execute(args, "inherit");
@@ -2733,7 +2735,7 @@ var tailwindcss_default = defineAddon({
2733
2735
  const PLUGIN_NAME = "prettier-plugin-tailwindcss";
2734
2736
  data.plugins ??= [];
2735
2737
  const plugins$1 = data.plugins;
2736
- if (!plugins$1.includes(PLUGIN_NAME)) plugins$1.push(PLUGIN_NAME);
2738
+ if (!plugins$1.includes(PLUGIN_NAME)) plugins$1.unshift(PLUGIN_NAME);
2737
2739
  data.tailwindStylesheet ??= files.getRelative({ to: files.stylesheet });
2738
2740
  return generateCode();
2739
2741
  });
@@ -3057,10 +3059,17 @@ async function applyAddons({ addons, workspace, addonSetupResults, options: opti
3057
3059
  const allPnpmBuildDependencies = [];
3058
3060
  const status = {};
3059
3061
  const ordered = orderAddons(Object.entries(addons).map(([, addon]) => addon), addonSetupResults);
3062
+ let hasFormatter = false;
3060
3063
  for (const addon of ordered) {
3064
+ const workspaceOptions = options$7[addon.id] || {};
3065
+ const addonWorkspace = await createWorkspace({
3066
+ cwd: workspace.cwd,
3067
+ packageManager: workspace.packageManager
3068
+ });
3069
+ if (!hasFormatter) hasFormatter = !!addonWorkspace.dependencyVersion("prettier");
3061
3070
  const { files, pnpmBuildDependencies, cancels } = await runAddon({
3062
- workspace,
3063
- workspaceOptions: options$7[addon.id] || {},
3071
+ workspace: addonWorkspace,
3072
+ workspaceOptions,
3064
3073
  addon,
3065
3074
  multiple: ordered.length > 1
3066
3075
  });
@@ -3070,7 +3079,7 @@ async function applyAddons({ addons, workspace, addonSetupResults, options: opti
3070
3079
  else status[addon.id] = cancels;
3071
3080
  }
3072
3081
  return {
3073
- filesToFormat: Array.from(filesToFormat),
3082
+ filesToFormat: hasFormatter ? Array.from(filesToFormat) : [],
3074
3083
  pnpmBuildDependencies: allPnpmBuildDependencies,
3075
3084
  status
3076
3085
  };
package/dist/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as create } from "../create-DJeT6Cfe.js";
2
- import { c as officialAddons, n as installAddon } from "../install-6J55LDIW.js";
1
+ import { t as create } from "../create-DTIS6AzL.js";
2
+ import { c as officialAddons, n as installAddon } from "../install-BfCQ4zdp.js";
3
3
 
4
4
  export { create, installAddon, officialAddons };
@@ -1,4 +1,4 @@
1
- import { S as ve, ct as __require, i as addPnpmBuildDependencies, lt as __toESM, st as __commonJS, t as create, x as be } from "../create-DJeT6Cfe.js";
1
+ import { S as ve, ct as __require, i as addPnpmBuildDependencies, lt as __toESM, st as __commonJS, t as create, x as be } from "../create-DTIS6AzL.js";
2
2
  import path from "node:path";
3
3
  import fs from "node:fs";
4
4
  import process$1 from "node:process";
package/dist/shared.json CHANGED
@@ -137,7 +137,7 @@
137
137
  "typescript"
138
138
  ],
139
139
  "exclude": [],
140
- "contents": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"rewriteRelativeImportExtensions\": true,\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"skipLibCheck\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"module\": \"NodeNext\",\n\t\t\"moduleResolution\": \"NodeNext\"\n\t}\n}\n"
140
+ "contents": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"rewriteRelativeImportExtensions\": true,\n\t\t\"allowJs\": true,\n\t\t\"checkJs\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"skipLibCheck\": true,\n\t\t\"sourceMap\": true,\n\t\t\"strict\": true,\n\t\t\"module\": \"NodeNext\",\n\t\t\"moduleResolution\": \"NodeNext\"\n\t}\n}\n"
141
141
  },
142
142
  {
143
143
  "name": "vite.config.js",
@@ -157,7 +157,7 @@
157
157
  "typescript",
158
158
  "checkjs"
159
159
  ],
160
- "contents": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"esModuleInterop\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"skipLibCheck\": true,\n\t\t\"sourceMap\": true,\n\t\t\"module\": \"NodeNext\",\n\t\t\"moduleResolution\": \"NodeNext\"\n\t}\n}\n"
160
+ "contents": "{\n\t\"extends\": \"./.svelte-kit/tsconfig.json\",\n\t\"compilerOptions\": {\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t\"resolveJsonModule\": true,\n\t\t\"skipLibCheck\": true,\n\t\t\"sourceMap\": true,\n\t\t\"module\": \"NodeNext\",\n\t\t\"moduleResolution\": \"NodeNext\"\n\t}\n}\n"
161
161
  }
162
162
  ]
163
163
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sv",
3
- "version": "0.10.4",
3
+ "version": "0.10.6",
4
4
  "type": "module",
5
5
  "description": "A CLI for creating and updating SvelteKit projects",
6
6
  "license": "MIT",
@@ -36,9 +36,9 @@
36
36
  "ps-tree": "^1.2.0",
37
37
  "tinyexec": "^0.3.2",
38
38
  "valibot": "^0.41.0",
39
- "@sveltejs/create": "0.0.0",
40
39
  "@sveltejs/addons": "0.0.0",
41
- "@sveltejs/cli-core": "0.0.0"
40
+ "@sveltejs/cli-core": "0.0.0",
41
+ "@sveltejs/create": "0.0.0"
42
42
  },
43
43
  "keywords": [
44
44
  "create",