sv 0.10.5 → 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-jbRIQkth.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.5";
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
  /**
@@ -1551,8 +1543,9 @@ async function createProject(cwd, options$1) {
1551
1543
  T.success("Project created");
1552
1544
  let addOnNextSteps = [];
1553
1545
  let argsFormattedAddons = [];
1546
+ let addOnFilesToFormat = [];
1554
1547
  if (options$1.addOns || options$1.add.length > 0) {
1555
- const { nextSteps, argsFormattedAddons: argsFormatted$1 } = await runAddonsApply({
1548
+ const { nextSteps, argsFormattedAddons: argsFormatted$1, filesToFormat } = await runAddonsApply({
1556
1549
  answersOfficial,
1557
1550
  answersCommunity,
1558
1551
  options: {
@@ -1568,6 +1561,7 @@ async function createProject(cwd, options$1) {
1568
1561
  fromCommand: "create"
1569
1562
  });
1570
1563
  argsFormattedAddons = argsFormatted$1;
1564
+ addOnFilesToFormat = filesToFormat;
1571
1565
  addOnNextSteps = nextSteps;
1572
1566
  }
1573
1567
  const packageManager = options$1.install === false ? null : options$1.install === true ? await packageManagerPrompt(projectPath) : options$1.install;
@@ -1579,7 +1573,14 @@ async function createProject(cwd, options$1) {
1579
1573
  if (argsFormattedAddons.length > 0) argsFormatted.push("--add", ...argsFormattedAddons);
1580
1574
  logArgs(packageManager, "create", argsFormatted, [directory]);
1581
1575
  await addPnpmBuildDependencies(projectPath, packageManager, ["esbuild"]);
1582
- 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
+ }
1583
1584
  return {
1584
1585
  directory: projectPath,
1585
1586
  addOnNextSteps,
@@ -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,13 +3059,16 @@ 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) {
3061
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");
3062
3070
  const { files, pnpmBuildDependencies, cancels } = await runAddon({
3063
- workspace: await createWorkspace({
3064
- cwd: workspace.cwd,
3065
- packageManager: workspace.packageManager
3066
- }),
3071
+ workspace: addonWorkspace,
3067
3072
  workspaceOptions,
3068
3073
  addon,
3069
3074
  multiple: ordered.length > 1
@@ -3074,7 +3079,7 @@ async function applyAddons({ addons, workspace, addonSetupResults, options: opti
3074
3079
  else status[addon.id] = cancels;
3075
3080
  }
3076
3081
  return {
3077
- filesToFormat: Array.from(filesToFormat),
3082
+ filesToFormat: hasFormatter ? Array.from(filesToFormat) : [],
3078
3083
  pnpmBuildDependencies: allPnpmBuildDependencies,
3079
3084
  status
3080
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-jbRIQkth.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sv",
3
- "version": "0.10.5",
3
+ "version": "0.10.6",
4
4
  "type": "module",
5
5
  "description": "A CLI for creating and updating SvelteKit projects",
6
6
  "license": "MIT",