sv 0.9.2 → 0.9.3

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.
@@ -1199,8 +1199,22 @@ function orderAddons(addons, setupResults) {
1199
1199
  function defineAddon(config) {
1200
1200
  return config;
1201
1201
  }
1202
- function defineAddonOptions(options$6) {
1203
- return options$6;
1202
+ function defineAddonOptions() {
1203
+ return createOptionBuilder({});
1204
+ }
1205
+ function createOptionBuilder(options$6 = {}) {
1206
+ return {
1207
+ add(key, question) {
1208
+ const newOptions = {
1209
+ ...options$6,
1210
+ [key]: question
1211
+ };
1212
+ return createOptionBuilder(newOptions);
1213
+ },
1214
+ build() {
1215
+ return options$6;
1216
+ }
1217
+ };
1204
1218
  }
1205
1219
  var require_src = __commonJS({ "node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js"(exports, module) {
1206
1220
  const ESC = "\x1B";
@@ -2778,87 +2792,81 @@ const PORTS = {
2778
2792
  postgresql: "5432",
2779
2793
  sqlite: ""
2780
2794
  };
2781
- const options$5 = defineAddonOptions({
2782
- database: {
2783
- question: "Which database would you like to use?",
2784
- type: "select",
2785
- default: "sqlite",
2786
- options: [
2787
- {
2788
- value: "postgresql",
2789
- label: "PostgreSQL"
2790
- },
2791
- {
2792
- value: "mysql",
2793
- label: "MySQL"
2794
- },
2795
- {
2796
- value: "sqlite",
2797
- label: "SQLite"
2798
- }
2799
- ]
2800
- },
2801
- postgresql: {
2802
- question: "Which PostgreSQL client would you like to use?",
2803
- type: "select",
2804
- group: "client",
2805
- default: "postgres.js",
2806
- options: [{
2807
- value: "postgres.js",
2808
- label: "Postgres.JS",
2809
- hint: "recommended for most users"
2810
- }, {
2811
- value: "neon",
2812
- label: "Neon",
2813
- hint: "popular hosted platform"
2814
- }],
2815
- condition: ({ database }) => database === "postgresql"
2816
- },
2817
- mysql: {
2818
- question: "Which MySQL client would you like to use?",
2819
- type: "select",
2820
- group: "client",
2821
- default: "mysql2",
2822
- options: [{
2823
- value: "mysql2",
2824
- hint: "recommended for most users"
2825
- }, {
2826
- value: "planetscale",
2827
- label: "PlanetScale",
2795
+ const options$5 = defineAddonOptions().add("database", {
2796
+ question: "Which database would you like to use?",
2797
+ type: "select",
2798
+ default: "sqlite",
2799
+ options: [
2800
+ {
2801
+ value: "postgresql",
2802
+ label: "PostgreSQL"
2803
+ },
2804
+ {
2805
+ value: "mysql",
2806
+ label: "MySQL"
2807
+ },
2808
+ {
2809
+ value: "sqlite",
2810
+ label: "SQLite"
2811
+ }
2812
+ ]
2813
+ }).add("postgresql", {
2814
+ question: "Which PostgreSQL client would you like to use?",
2815
+ type: "select",
2816
+ group: "client",
2817
+ default: "postgres.js",
2818
+ options: [{
2819
+ value: "postgres.js",
2820
+ label: "Postgres.JS",
2821
+ hint: "recommended for most users"
2822
+ }, {
2823
+ value: "neon",
2824
+ label: "Neon",
2825
+ hint: "popular hosted platform"
2826
+ }],
2827
+ condition: ({ database }) => database === "postgresql"
2828
+ }).add("mysql", {
2829
+ question: "Which MySQL client would you like to use?",
2830
+ type: "select",
2831
+ group: "client",
2832
+ default: "mysql2",
2833
+ options: [{
2834
+ value: "mysql2",
2835
+ hint: "recommended for most users"
2836
+ }, {
2837
+ value: "planetscale",
2838
+ label: "PlanetScale",
2839
+ hint: "popular hosted platform"
2840
+ }],
2841
+ condition: ({ database }) => database === "mysql"
2842
+ }).add("sqlite", {
2843
+ question: "Which SQLite client would you like to use?",
2844
+ type: "select",
2845
+ group: "client",
2846
+ default: "libsql",
2847
+ options: [
2848
+ {
2849
+ value: "better-sqlite3",
2850
+ hint: "for traditional Node environments"
2851
+ },
2852
+ {
2853
+ value: "libsql",
2854
+ label: "libSQL",
2855
+ hint: "for serverless environments"
2856
+ },
2857
+ {
2858
+ value: "turso",
2859
+ label: "Turso",
2828
2860
  hint: "popular hosted platform"
2829
- }],
2830
- condition: ({ database }) => database === "mysql"
2831
- },
2832
- sqlite: {
2833
- question: "Which SQLite client would you like to use?",
2834
- type: "select",
2835
- group: "client",
2836
- default: "libsql",
2837
- options: [
2838
- {
2839
- value: "better-sqlite3",
2840
- hint: "for traditional Node environments"
2841
- },
2842
- {
2843
- value: "libsql",
2844
- label: "libSQL",
2845
- hint: "for serverless environments"
2846
- },
2847
- {
2848
- value: "turso",
2849
- label: "Turso",
2850
- hint: "popular hosted platform"
2851
- }
2852
- ],
2853
- condition: ({ database }) => database === "sqlite"
2854
- },
2855
- docker: {
2856
- question: "Do you want to run the database locally with docker-compose?",
2857
- default: false,
2858
- type: "boolean",
2859
- condition: ({ database, mysql, postgresql }) => database === "mysql" && mysql === "mysql2" || database === "postgresql" && postgresql === "postgres.js"
2860
- }
2861
- });
2861
+ }
2862
+ ],
2863
+ condition: ({ database }) => database === "sqlite"
2864
+ }).add("docker", {
2865
+ question: "Do you want to run the database locally with docker-compose?",
2866
+ default: false,
2867
+ type: "boolean",
2868
+ condition: ({ database, mysql, postgresql }) => database === "mysql" && mysql === "mysql2" || database === "postgresql" && postgresql === "postgres.js"
2869
+ }).build();
2862
2870
  var drizzle_default = defineAddon({
2863
2871
  id: "drizzle",
2864
2872
  shortDescription: "database orm",
@@ -4343,11 +4351,11 @@ const TABLE_TYPE = {
4343
4351
  };
4344
4352
  let drizzleDialect;
4345
4353
  let schemaPath;
4346
- const options$4 = defineAddonOptions({ demo: {
4354
+ const options$4 = defineAddonOptions().add("demo", {
4347
4355
  type: "boolean",
4348
4356
  default: true,
4349
4357
  question: `Do you want to include a demo? ${colors.dim("(includes a login/register page)")}`
4350
- } });
4358
+ }).build();
4351
4359
  var lucia_default = defineAddon({
4352
4360
  id: "lucia",
4353
4361
  shortDescription: "auth guide",
@@ -5016,32 +5024,29 @@ const DEFAULT_INLANG_PROJECT = {
5016
5024
  modules: ["https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@4/dist/index.js", "https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@2/dist/index.js"],
5017
5025
  "plugin.inlang.messageFormat": { pathPattern: "./messages/{locale}.json" }
5018
5026
  };
5019
- const options$3 = defineAddonOptions({
5020
- languageTags: {
5021
- question: `Which languages would you like to support? ${colors.gray("(e.g. en,de-ch)")}`,
5022
- type: "string",
5023
- default: "en, es",
5024
- validate(input) {
5025
- if (!input) return;
5026
- const { invalidLanguageTags, validLanguageTags } = parseLanguageTagInput(input);
5027
- if (invalidLanguageTags.length > 0) if (invalidLanguageTags.length === 1) return `The input "${invalidLanguageTags[0]}" is not a valid IETF BCP 47 language tag`;
5027
+ const options$3 = defineAddonOptions().add("languageTags", {
5028
+ question: `Which languages would you like to support? ${colors.gray("(e.g. en,de-ch)")}`,
5029
+ type: "string",
5030
+ default: "en, es",
5031
+ validate(input) {
5032
+ if (!input) return;
5033
+ const { invalidLanguageTags, validLanguageTags } = parseLanguageTagInput(input);
5034
+ if (invalidLanguageTags.length > 0) if (invalidLanguageTags.length === 1) return `The input "${invalidLanguageTags[0]}" is not a valid IETF BCP 47 language tag`;
5028
5035
  else {
5029
- const listFormat = new Intl.ListFormat("en", {
5030
- style: "long",
5031
- type: "conjunction"
5032
- });
5033
- return `The inputs ${listFormat.format(invalidLanguageTags.map((x$2) => `"${x$2}"`))} are not valid BCP47 language tags`;
5034
- }
5035
- if (validLanguageTags.length === 0) return "Please enter at least one valid BCP47 language tag. Eg: en";
5036
- return undefined;
5036
+ const listFormat = new Intl.ListFormat("en", {
5037
+ style: "long",
5038
+ type: "conjunction"
5039
+ });
5040
+ return `The inputs ${listFormat.format(invalidLanguageTags.map((x$2) => `"${x$2}"`))} are not valid BCP47 language tags`;
5037
5041
  }
5038
- },
5039
- demo: {
5040
- type: "boolean",
5041
- default: true,
5042
- question: "Do you want to include a demo?"
5042
+ if (validLanguageTags.length === 0) return "Please enter at least one valid BCP47 language tag. Eg: en";
5043
+ return undefined;
5043
5044
  }
5044
- });
5045
+ }).add("demo", {
5046
+ type: "boolean",
5047
+ default: true,
5048
+ question: "Do you want to include a demo?"
5049
+ }).build();
5045
5050
  var paraglide_default = defineAddon({
5046
5051
  id: "paraglide",
5047
5052
  shortDescription: "i18n",
@@ -5390,7 +5395,7 @@ const adapters = [
5390
5395
  version: "^5.0.0"
5391
5396
  }
5392
5397
  ];
5393
- const options$2 = defineAddonOptions({ adapter: {
5398
+ const options$2 = defineAddonOptions().add("adapter", {
5394
5399
  type: "select",
5395
5400
  question: "Which SvelteKit adapter would you like to use?",
5396
5401
  options: adapters.map((p$1) => ({
@@ -5399,7 +5404,7 @@ const options$2 = defineAddonOptions({ adapter: {
5399
5404
  hint: p$1.package
5400
5405
  })),
5401
5406
  default: "auto"
5402
- } });
5407
+ }).build();
5403
5408
  var sveltekit_adapter_default = defineAddon({
5404
5409
  id: "sveltekit-adapter",
5405
5410
  alias: "adapter",
@@ -5453,28 +5458,30 @@ var sveltekit_adapter_default = defineAddon({
5453
5458
 
5454
5459
  //#endregion
5455
5460
  //#region packages/addons/tailwindcss/index.ts
5456
- const plugins = [{
5457
- id: "typography",
5458
- package: "@tailwindcss/typography",
5459
- version: "^0.5.15",
5460
- identifier: "typography"
5461
- }, {
5462
- id: "forms",
5463
- package: "@tailwindcss/forms",
5464
- version: "^0.5.9",
5465
- identifier: "forms"
5466
- }];
5467
- const options$1 = defineAddonOptions({ plugins: {
5461
+ function typedEntries(obj) {
5462
+ return Object.entries(obj);
5463
+ }
5464
+ const plugins = {
5465
+ typography: {
5466
+ package: "@tailwindcss/typography",
5467
+ version: "^0.5.15"
5468
+ },
5469
+ forms: {
5470
+ package: "@tailwindcss/forms",
5471
+ version: "^0.5.9"
5472
+ }
5473
+ };
5474
+ const options$1 = defineAddonOptions().add("plugins", {
5468
5475
  type: "multiselect",
5469
5476
  question: "Which plugins would you like to add?",
5470
- options: plugins.map((p$1) => ({
5471
- value: p$1.id,
5472
- label: p$1.id,
5477
+ options: typedEntries(plugins).map(([id, p$1]) => ({
5478
+ value: id,
5479
+ label: id,
5473
5480
  hint: p$1.package
5474
5481
  })),
5475
5482
  default: [],
5476
5483
  required: false
5477
- } });
5484
+ }).build();
5478
5485
  var tailwindcss_default = defineAddon({
5479
5486
  id: "tailwindcss",
5480
5487
  alias: "tailwind",
@@ -5486,8 +5493,8 @@ var tailwindcss_default = defineAddon({
5486
5493
  sv.devDependency("tailwindcss", "^4.0.0");
5487
5494
  sv.devDependency("@tailwindcss/vite", "^4.0.0");
5488
5495
  if (prettierInstalled) sv.devDependency("prettier-plugin-tailwindcss", "^0.6.11");
5489
- for (const plugin of plugins) {
5490
- if (!options$6.plugins.includes(plugin.id)) continue;
5496
+ for (const [id, plugin] of typedEntries(plugins)) {
5497
+ if (!options$6.plugins.includes(id)) continue;
5491
5498
  sv.devDependency(plugin.package, plugin.version);
5492
5499
  }
5493
5500
  sv.file(viteConfigFile, (content) => {
@@ -5514,8 +5521,8 @@ var tailwindcss_default = defineAddon({
5514
5521
  }
5515
5522
  const lastAtRule = atRules.findLast((rule) => ["plugin", "import"].includes(rule.name));
5516
5523
  const pluginPos = lastAtRule.source.end.offset;
5517
- for (const plugin of plugins) {
5518
- if (!options$6.plugins.includes(plugin.id)) continue;
5524
+ for (const [id, plugin] of typedEntries(plugins)) {
5525
+ if (!options$6.plugins.includes(id)) continue;
5519
5526
  const pluginRule = findAtRule("plugin", plugin.package);
5520
5527
  if (!pluginRule) {
5521
5528
  const pluginImport = `\n@plugin '${plugin.package}';`;
@@ -5559,7 +5566,7 @@ else sv.file(`${kit?.routesDirectory}/+layout.svelte`, (content) => {
5559
5566
 
5560
5567
  //#endregion
5561
5568
  //#region packages/addons/vitest-addon/index.ts
5562
- const options = defineAddonOptions({ usages: {
5569
+ const options = defineAddonOptions().add("usages", {
5563
5570
  question: "What do you want to use vitest for?",
5564
5571
  type: "multiselect",
5565
5572
  default: ["unit", "component"],
@@ -5571,7 +5578,7 @@ const options = defineAddonOptions({ usages: {
5571
5578
  label: "component testing"
5572
5579
  }],
5573
5580
  required: true
5574
- } });
5581
+ }).build();
5575
5582
  var vitest_addon_default = defineAddon({
5576
5583
  id: "vitest",
5577
5584
  shortDescription: "unit testing",
package/dist/bin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { AGENT_NAMES, Command, De, Fe, Ge, J, Ke, Option, T, Ue, Vu, We, __toESM$1 as __toESM, addPnpmBuildDependencies, create, detect, et, from, getUserAgent, installDependencies, installOption, ke, packageManagerPrompt, program, require_picocolors$1 as require_picocolors, resolveCommand, templates, up, ze } from "./package-manager-DO5R9a6p.js";
3
- import { applyAddons, communityAddonIds, createWorkspace, formatFiles, getAddonDetails, getCommunityAddon, getHighlighter, isVersionUnsupportedBelow, officialAddons, setupAddons } from "./addons-Ck_pRCRU.js";
3
+ import { applyAddons, communityAddonIds, createWorkspace, formatFiles, getAddonDetails, getCommunityAddon, getHighlighter, isVersionUnsupportedBelow, officialAddons, setupAddons } from "./addons-uHDStNUk.js";
4
4
  import fs, { existsSync } from "node:fs";
5
5
  import path, { dirname, join } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
@@ -12,7 +12,7 @@ import { pipeline } from "node:stream/promises";
12
12
 
13
13
  //#region packages/cli/package.json
14
14
  var name = "sv";
15
- var version = "0.9.2";
15
+ var version = "0.9.3";
16
16
  var type = "module";
17
17
  var description = "A CLI for creating and updating SvelteKit projects";
18
18
  var license = "MIT";
@@ -588,6 +588,16 @@ function forwardExitCode(error) {
588
588
  if (error && typeof error === "object" && "status" in error && typeof error.status === "number") process.exit(error.status);
589
589
  else process.exit(1);
590
590
  }
591
+ function parseAddonOptions(optionFlags) {
592
+ if (optionFlags === undefined || optionFlags === "") return undefined;
593
+ const options$1 = optionFlags.split("+");
594
+ const malformed = options$1.filter((option) => !/.+:.*/.test(option));
595
+ if (malformed.length > 0) {
596
+ const message = `Malformed arguments: The following add-on options: ${malformed.map((o) => `'${o}'`).join(", ")} are missing their option name or value (e.g. 'addon=option1:value1+option2:value2').`;
597
+ throw new Error(message);
598
+ }
599
+ return options$1;
600
+ }
591
601
 
592
602
  //#endregion
593
603
  //#region packages/cli/commands/add/fetch-packages.ts
@@ -745,22 +755,16 @@ const add = new Command("add").description("applies specified add-ons into a pro
745
755
  console.error(`Malformed arguments: Add-on '${addonId}' is repeated multiple times.`);
746
756
  process.exit(1);
747
757
  }
748
- if (optionFlags === undefined) {
758
+ try {
759
+ const options$1 = parseAddonOptions(optionFlags);
749
760
  prev.push({
750
761
  id: addonId,
751
- options: undefined
762
+ options: options$1
752
763
  });
753
- return prev;
754
- }
755
- if (optionFlags.length > 0 && !/.+:.*/.test(optionFlags)) {
756
- console.error(`Malformed arguments: An add-on's option in '${value}' is missing it's option name or value (e.g. 'addon=option:value').`);
764
+ } catch (error) {
765
+ if (error instanceof Error) console.error(error.message);
757
766
  process.exit(1);
758
767
  }
759
- const options$1 = optionFlags.match(/[^+]*:[^:]*(?=\+|$)/g) ?? [];
760
- prev.push({
761
- id: addonId,
762
- options: options$1
763
- });
764
768
  return prev;
765
769
  }).option("-C, --cwd <path>", "path to working directory", defaultCwd).option("--no-git-check", "even if some files are dirty, no prompt will be shown").option("--no-install", "skip installing dependencies").addOption(installOption).configureHelp({
766
770
  ...helpConfig,
@@ -1356,10 +1360,7 @@ async function createProject(cwd, options$1) {
1356
1360
 
1357
1361
  //#endregion
1358
1362
  //#region packages/cli/commands/migrate.ts
1359
- const migrate = new Command("migrate").description("a CLI for migrating Svelte(Kit) codebases").argument("<migration>", "migration to run").option("-C, --cwd <path>", "path to working directory", process.cwd()).configureHelp({ formatHelp() {
1360
- runMigrate(process.cwd(), ["--help"]);
1361
- return "";
1362
- } }).action((migration, options$1) => {
1363
+ const migrate = new Command("migrate").description("a CLI for migrating Svelte(Kit) codebases").argument("[migration]", "migration to run").option("-C, --cwd <path>", "path to working directory", process.cwd()).action((migration, options$1) => {
1363
1364
  runMigrate(options$1.cwd, [migration]);
1364
1365
  });
1365
1366
  function runMigrate(cwd, args) {
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import { create } from "./package-manager-DO5R9a6p.js";
2
- import { installAddon, officialAddons } from "./addons-Ck_pRCRU.js";
2
+ import { installAddon, officialAddons } from "./addons-uHDStNUk.js";
3
3
 
4
4
  export { create, installAddon, officialAddons };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sv",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "type": "module",
5
5
  "description": "A CLI for creating and updating SvelteKit projects",
6
6
  "license": "MIT",
@@ -37,8 +37,8 @@
37
37
  "tinyexec": "^0.3.2",
38
38
  "valibot": "^0.41.0",
39
39
  "@sveltejs/addons": "0.0.0",
40
- "@sveltejs/create": "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",