sv 0.12.0 → 0.12.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.
@@ -1,4 +1,4 @@
1
- import { $ as OptionValues, C as Addon, G as PackageManager, I as SetupResult, K as Workspace, j as LoadedAddon } from "./core-DjIj3YV4.mjs";
1
+ import { H as Workspace, N as SetupResult, O as LoadedAddon, V as PackageManager, Y as OptionValues, b as Addon } from "./core-VSHdSalh.mjs";
2
2
 
3
3
  //#region lib/addons/_engine/add.d.ts
4
4
  type InstallOptions<Addons extends AddonMap> = {
@@ -1,12 +1,12 @@
1
1
  import { r as __require, t as __commonJSMin } from "./chunk-BcJDCUAU.mjs";
2
- import { _ as getSharedFiles, a as installOption, c as up$1, d as Option, g as dist, h as sanitizeName, i as installDependencies, m as templates, n as addPnpmBuildDependencies, o as packageManagerPrompt, p as create$1, r as detectPackageManager, s as any, t as AGENT_NAMES, u as Command } from "./package-manager-DYfxv5nk.mjs";
3
- import { $ as createPrinter, A as addNamespace$1, B as appendFromString, C as createDefault, Ct as Rt, D as addDefault, E as declaration, Et as qt, F as overrideProperties, G as parseExpression, H as createLiteral, I as property, J as addSlot, K as parseStatement, L as append, M as remove, N as createCall, O as addEmpty, Ot as Ct, P as create$2, R as create$3, S as addNamespace, St as R, T as createIdentifier, Tt as kt, U as createSpread, V as appendStatement, W as hasTypeProperty, Y as ensureScript, Z as addAtRule, _t as Lt, a as getPackageJson, at as defineAddon, b as addGlobalAppInterface, bt as Pt, c as writeFile, ct as walk, et as addEslintConfigPrettier, f as packageScriptsUpsert, ft as q, gt as Ie, h as addAttribute, ht as resolveCommand, i as formatFiles, it as splitVersion, j as find, k as addNamed, l as parse$1, m as upsert, n as commonFilePaths, nt as getNodeTypesVersion, o as installPackages, ot as defineAddonOptions, q as addFragment, r as fileExists, rt as isVersionUnsupportedBelow, s as readFile, st as getErrorHint, t as color, tt as addToDemoPage, u as arrayUpsert, ut as dedent_default, v as addPlugin, vt as Mt, w as createNamed, wt as Wt, x as addHooksHandle, xt as Qt, y as getConfig, yt as Nt, z as addJsDocTypeComment } from "./utils-CnfD6Z1s.mjs";
2
+ import { A as addNamespace$1, C as createDefault, Ct as R, D as addDefault, Dt as qt, E as declaration, Et as kt, F as overrideProperties, G as isVersionUnsupportedBelow, H as addEslintConfigPrettier, I as property, J as defineAddonOptions, K as splitVersion, L as append, M as remove, N as createCall, O as addEmpty, P as create$1, Q as ensureScript, R as create$2, S as addNamespace, St as Qt, T as createIdentifier, Tt as Wt, U as addToDemoPage, V as createPrinter, W as getNodeTypesVersion, X as addFragment, Y as getErrorHint, Z as addSlot, _t as Ie, a as getPackageJson, at as createTypeProperty, b as addGlobalAppInterface, bt as Nt, c as writeFile, ct as parseStatement, et as addJsDocTypeComment, f as packageScriptsUpsert, gt as resolveCommand, h as addAttribute, i as formatFiles, it as createSpread, j as find, k as addNamed, kt as Ct, l as parse$1, lt as dedent_default, m as upsert, n as commonFilePaths, nt as appendStatement, o as installPackages, ot as hasTypeProperty, pt as q, q as defineAddon, r as fileExists, rt as createLiteral, s as readFile, st as parseExpression, t as color, tt as appendFromString, u as arrayUpsert, ut as walk, v as addPlugin, vt as Lt, w as createNamed, wt as Rt, x as addHooksHandle, xt as Pt, y as getConfig, yt as Mt, z as addAtRule } from "./utils-D-OWcBXG.mjs";
3
+ import { _ as getSharedFiles, a as installOption, c as up$1, d as Option, g as dist, h as sanitizeName, i as installDependencies, m as templates, n as addPnpmBuildDependencies, o as packageManagerPrompt, p as create$3, r as detectPackageManager, s as any, t as AGENT_NAMES, u as Command } from "./package-manager-B3sMOeTk.mjs";
4
4
  import fs, { existsSync, readFileSync } from "node:fs";
5
5
  import path, { dirname, join } from "node:path";
6
- import { fileURLToPath } from "node:url";
7
6
  import process$1 from "node:process";
8
7
  import { promisify } from "node:util";
9
8
  import { exec } from "node:child_process";
9
+ import { fileURLToPath } from "node:url";
10
10
  import crypto from "node:crypto";
11
11
  import { platform } from "node:os";
12
12
  import { pipeline } from "node:stream/promises";
@@ -676,7 +676,7 @@ var better_auth_default = defineAddon({
676
676
  imports: ["drizzleAdapter"]
677
677
  });
678
678
  addNamed(ast, {
679
- from: "better-auth",
679
+ from: "better-auth/minimal",
680
680
  imports: ["betterAuth"]
681
681
  });
682
682
  const authConfig = dedent_default`
@@ -727,39 +727,19 @@ var better_auth_default = defineAddon({
727
727
  return generateCode();
728
728
  });
729
729
  sv.file("src/app.d.ts", (content) => {
730
- const { ast, generateCode } = parse$1.script(content);
730
+ const { ast, comments, generateCode } = parse$1.script(content);
731
731
  addNamed(ast, {
732
732
  imports: ["User", "Session"],
733
- from: "better-auth",
733
+ from: "better-auth/minimal",
734
734
  isType: true
735
735
  });
736
736
  const locals = addGlobalAppInterface(ast, { name: "Locals" });
737
737
  if (!locals) throw new Error("Failed detecting `locals` interface in `src/app.d.ts`");
738
+ comments.remove((c) => c.type === "Line" && c.value.trim() === "interface Locals {}");
738
739
  const user = locals.body.body.find((prop) => hasTypeProperty(prop, { name: "user" }));
739
740
  const session = locals.body.body.find((prop) => hasTypeProperty(prop, { name: "session" }));
740
- function addProps(name$1, value, optional$1 = false) {
741
- return {
742
- type: "TSPropertySignature",
743
- key: {
744
- type: "Identifier",
745
- name: name$1
746
- },
747
- computed: false,
748
- optional: optional$1,
749
- typeAnnotation: {
750
- type: "TSTypeAnnotation",
751
- typeAnnotation: {
752
- type: "TSTypeReference",
753
- typeName: {
754
- type: "Identifier",
755
- name: value
756
- }
757
- }
758
- }
759
- };
760
- }
761
- if (!user) locals.body.body.push(addProps("user", "User", true));
762
- if (!session) locals.body.body.push(addProps("session", "Session", true));
741
+ if (!user) locals.body.body.push(createTypeProperty("user", "User", true));
742
+ if (!session) locals.body.body.push(createTypeProperty("session", "Session", true));
763
743
  return generateCode();
764
744
  });
765
745
  sv.file(`src/hooks.server.${language}`, (content) => {
@@ -882,7 +862,7 @@ var better_auth_default = defineAddon({
882
862
  ${ts("import type { Actions } from './$types';")}
883
863
  ${ts("import type { PageServerLoad } from './$types';")}
884
864
  import { auth } from '$lib/server/auth';
885
- ${needsAPIError ? "import { APIError } from 'better-auth';" : ""}
865
+ ${needsAPIError ? "import { APIError } from 'better-auth/api';" : ""}
886
866
 
887
867
  export const load${ts(": PageServerLoad")} = async (event) => {
888
868
  if (event.locals.user) {
@@ -1401,7 +1381,7 @@ var drizzle_default = defineAddon({
1401
1381
  args: ["client"],
1402
1382
  useIdentifiers: true
1403
1383
  });
1404
- const paramObject = create$2({ schema: createIdentifier("schema") });
1384
+ const paramObject = create$1({ schema: createIdentifier("schema") });
1405
1385
  if (options$8.database === "mysql") {
1406
1386
  const mode = options$8.mysql === "planetscale" ? "planetscale" : "default";
1407
1387
  property(paramObject, {
@@ -1439,7 +1419,7 @@ function generateEnvFileContent(content, opts, isExample) {
1439
1419
  const comment = ["Drizzle"];
1440
1420
  if (opts.docker) value = `"${opts.database === "mysql" ? "mysql" : "postgres"}://root:mysecretpassword@localhost:${PORTS[opts.database]}/local"`;
1441
1421
  else if (opts.sqlite === "better-sqlite3" || opts.sqlite === "libsql") value = opts.sqlite === "libsql" ? "file:local.db" : "local.db";
1442
- else if (opts.sqlite === "turso") {
1422
+ else if (opts.sqlite === "turso") if (isExample) {
1443
1423
  value = "\"libsql://db-name-user.turso.io\"";
1444
1424
  comment.push("Replace with your DB credentials!", {
1445
1425
  text: "A local DB can also be used in dev as well",
@@ -1448,7 +1428,11 @@ function generateEnvFileContent(content, opts, isExample) {
1448
1428
  text: `${DB_URL_KEY}="file:local.db"`,
1449
1429
  mode: "append"
1450
1430
  });
1451
- } else if (opts.database === "mysql") {
1431
+ } else {
1432
+ value = "\"file:local.db\"";
1433
+ comment.push("Replace with your DB credentials!", `${DB_URL_KEY}="libsql://db-name-user.turso.io"`, "A local DB can also be used in dev as well");
1434
+ }
1435
+ else if (opts.database === "mysql") {
1452
1436
  value = "\"mysql://user:password@host:port/db-name\"";
1453
1437
  comment.push("Replace with your DB credentials!");
1454
1438
  } else if (opts.database === "postgresql") {
@@ -1508,9 +1492,9 @@ var eslint_default = defineAddon({
1508
1492
  eslintConfigs.push(createSpread(svelteConfig));
1509
1493
  const globalsBrowser = createSpread(parseExpression("globals.browser"));
1510
1494
  const globalsNode = createSpread(parseExpression("globals.node"));
1511
- const globalsObjLiteral = create$2({});
1495
+ const globalsObjLiteral = create$1({});
1512
1496
  globalsObjLiteral.properties = [globalsBrowser, globalsNode];
1513
- const rules = create$2({ "\"no-undef\"": "off" });
1497
+ const rules = create$1({ "\"no-undef\"": "off" });
1514
1498
  if (rules.properties[0].type !== "Property") throw new Error("rules.properties[0].type !== \"Property\"");
1515
1499
  comments.add(rules.properties[0].key, {
1516
1500
  type: "Line",
@@ -1520,13 +1504,13 @@ var eslint_default = defineAddon({
1520
1504
  type: "Line",
1521
1505
  value: " see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors"
1522
1506
  });
1523
- const globalsConfig = create$2({
1507
+ const globalsConfig = create$1({
1524
1508
  languageOptions: { globals: globalsObjLiteral },
1525
1509
  rules: typescript ? rules : void 0
1526
1510
  });
1527
1511
  eslintConfigs.push(globalsConfig);
1528
1512
  if (typescript) {
1529
- const svelteTSParserConfig = create$2({
1513
+ const svelteTSParserConfig = create$1({
1530
1514
  files: [
1531
1515
  "**/*.svelte",
1532
1516
  "**/*.svelte.ts",
@@ -1541,7 +1525,7 @@ var eslint_default = defineAddon({
1541
1525
  });
1542
1526
  eslintConfigs.push(svelteTSParserConfig);
1543
1527
  } else {
1544
- const svelteTSParserConfig = create$2({
1528
+ const svelteTSParserConfig = create$1({
1545
1529
  files: ["**/*.svelte", "**/*.svelte.js"],
1546
1530
  languageOptions: { parserOptions: { svelteConfig: createIdentifier("svelteConfig") } }
1547
1531
  });
@@ -1556,7 +1540,7 @@ var eslint_default = defineAddon({
1556
1540
  tsConfigCall.arguments.push(...eslintConfigs);
1557
1541
  exportExpression = tsConfigCall;
1558
1542
  } else {
1559
- const eslintArray = create$3();
1543
+ const eslintArray = create$2();
1560
1544
  eslintConfigs.map((x) => append(eslintArray, x));
1561
1545
  exportExpression = eslintArray;
1562
1546
  }
@@ -1760,14 +1744,14 @@ var mdsvex_default = defineAddon({
1760
1744
  from: "mdsvex",
1761
1745
  imports: ["mdsvex"]
1762
1746
  });
1763
- const { value: exportDefault } = createDefault(ast, { fallback: create$2({}) });
1747
+ const { value: exportDefault } = createDefault(ast, { fallback: create$1({}) });
1764
1748
  let preprocessorArray = property(exportDefault, {
1765
1749
  name: "preprocess",
1766
- fallback: create$3()
1750
+ fallback: create$2()
1767
1751
  });
1768
1752
  if (!(preprocessorArray.type === "ArrayExpression")) {
1769
1753
  const previousElement = preprocessorArray;
1770
- preprocessorArray = create$3();
1754
+ preprocessorArray = create$2();
1771
1755
  append(preprocessorArray, previousElement);
1772
1756
  overrideProperties(exportDefault, { preprocess: preprocessorArray });
1773
1757
  }
@@ -1778,7 +1762,7 @@ var mdsvex_default = defineAddon({
1778
1762
  append(preprocessorArray, mdsvexCall);
1779
1763
  const extensionsArray = property(exportDefault, {
1780
1764
  name: "extensions",
1781
- fallback: create$3()
1765
+ fallback: create$2()
1782
1766
  });
1783
1767
  append(extensionsArray, ".svelte");
1784
1768
  append(extensionsArray, ".svx");
@@ -2210,14 +2194,14 @@ var sveltekit_adapter_default = defineAddon({
2210
2194
  from: adapter.package,
2211
2195
  as: adapterName
2212
2196
  });
2213
- const { value: config } = createDefault(ast, { fallback: create$2({}) });
2197
+ const { value: config } = createDefault(ast, { fallback: create$1({}) });
2214
2198
  overrideProperties(config, { kit: { adapter: createCall({
2215
2199
  name: adapterName,
2216
2200
  args: [],
2217
2201
  useIdentifiers: true
2218
2202
  }) } });
2219
2203
  if (adapter.package !== "@sveltejs/adapter-auto") {
2220
- const fallback = create$2({});
2204
+ const fallback = create$1({});
2221
2205
  const cfgKitValue = property(config, {
2222
2206
  name: "kit",
2223
2207
  fallback
@@ -2270,10 +2254,11 @@ var sveltekit_adapter_default = defineAddon({
2270
2254
  return generateCode();
2271
2255
  });
2272
2256
  sv.file("src/app.d.ts", (content) => {
2273
- const { ast, generateCode } = parse$1.script(content);
2257
+ const { ast, comments, generateCode } = parse$1.script(content);
2274
2258
  const platform$1 = addGlobalAppInterface(ast, { name: "Platform" });
2275
2259
  if (!platform$1) throw new Error("Failed detecting `platform` interface in `src/app.d.ts`");
2276
- platform$1.body.body.push(createCloudflarePlatformType("env", "Env"), createCloudflarePlatformType("ctx", "ExecutionContext"), createCloudflarePlatformType("caches", "CacheStorage"), createCloudflarePlatformType("cf", "IncomingRequestCfProperties", true));
2260
+ comments.remove((c) => c.type === "Line" && c.value.trim() === "interface Platform {}");
2261
+ platform$1.body.body.push(createTypeProperty("env", "Env"), createTypeProperty("ctx", "ExecutionContext"), createTypeProperty("caches", "CacheStorage"), createTypeProperty("cf", "IncomingRequestCfProperties", true));
2277
2262
  return generateCode();
2278
2263
  });
2279
2264
  }
@@ -2288,27 +2273,6 @@ var sveltekit_adapter_default = defineAddon({
2288
2273
  return toReturn;
2289
2274
  }
2290
2275
  });
2291
- function createCloudflarePlatformType(name$1, value, optional$1 = false) {
2292
- return {
2293
- type: "TSPropertySignature",
2294
- key: {
2295
- type: "Identifier",
2296
- name: name$1
2297
- },
2298
- computed: false,
2299
- optional: optional$1,
2300
- typeAnnotation: {
2301
- type: "TSTypeAnnotation",
2302
- typeAnnotation: {
2303
- type: "TSTypeReference",
2304
- typeName: {
2305
- type: "Identifier",
2306
- name: value
2307
- }
2308
- }
2309
- }
2310
- };
2311
- }
2312
2276
 
2313
2277
  //#endregion
2314
2278
  //#region lib/addons/tailwindcss.ts
@@ -2495,7 +2459,7 @@ var vitest_addon_default = defineAddon({
2495
2459
  }
2496
2460
  sv.file(files.viteConfig, (content) => {
2497
2461
  const { ast, generateCode } = parse$1.script(content);
2498
- const clientObjectExpression = create$2({
2462
+ const clientObjectExpression = create$1({
2499
2463
  extends: `./${files.viteConfig}`,
2500
2464
  test: {
2501
2465
  name: "client",
@@ -2514,7 +2478,7 @@ var vitest_addon_default = defineAddon({
2514
2478
  exclude: ["src/lib/server/**"]
2515
2479
  }
2516
2480
  });
2517
- const serverObjectExpression = create$2({
2481
+ const serverObjectExpression = create$1({
2518
2482
  extends: `./${files.viteConfig}`,
2519
2483
  test: {
2520
2484
  name: "server",
@@ -2526,11 +2490,11 @@ var vitest_addon_default = defineAddon({
2526
2490
  const viteConfig = getConfig(ast);
2527
2491
  const testObject = property(viteConfig, {
2528
2492
  name: "test",
2529
- fallback: create$2({ expect: { requireAssertions: true } })
2493
+ fallback: create$1({ expect: { requireAssertions: true } })
2530
2494
  });
2531
2495
  const workspaceArray = property(testObject, {
2532
2496
  name: "projects",
2533
- fallback: create$3()
2497
+ fallback: create$2()
2534
2498
  });
2535
2499
  if (componentTesting) append(workspaceArray, clientObjectExpression);
2536
2500
  if (unitTesting) append(workspaceArray, serverObjectExpression);
@@ -2773,7 +2737,7 @@ function setupPlaygroundProject(url, playground, cwd$1, installDependencies$1) {
2773
2737
  const svelteConfigPath = path.join(cwd$1, commonFilePaths.svelteConfig);
2774
2738
  const svelteConfig = fs.readFileSync(svelteConfigPath, "utf-8");
2775
2739
  const { ast: ast$1, generateCode: generateCode$1 } = parse$1.script(svelteConfig);
2776
- const { value: config } = createDefault(ast$1, { fallback: create$2({}) });
2740
+ const { value: config } = createDefault(ast$1, { fallback: create$1({}) });
2777
2741
  overrideProperties(config, { compilerOptions: { experimental: { async: true } } });
2778
2742
  fs.writeFileSync(svelteConfigPath, generateCode$1(), "utf-8");
2779
2743
  };
@@ -2819,7 +2783,7 @@ async function createWorkspace({ cwd: cwd$1, packageManager, override }) {
2819
2783
  }
2820
2784
  }
2821
2785
  for (const [key, value] of Object.entries(dependencies)) dependencies[key] = value.replaceAll(/[^\d|.]/g, "");
2822
- const kit = override?.kit ? override.kit : dependencies["@sveltejs/kit"] ? parseKitOptions(resolvedCwd) : void 0;
2786
+ const kit = override?.kit ? override.kit : dependencies["@sveltejs/kit"] ? parseKitOptions(resolvedCwd, svelteConfig) : void 0;
2823
2787
  const stylesheet = kit ? `${kit.routesDirectory}/layout.css` : "src/app.css";
2824
2788
  return {
2825
2789
  cwd: resolvedCwd,
@@ -2861,11 +2825,11 @@ function findWorkspaceRoot(cwd$1) {
2861
2825
  }
2862
2826
  return cwd$1;
2863
2827
  }
2864
- function parseKitOptions(cwd$1) {
2865
- const configSource = readFile(cwd$1, commonFilePaths.svelteConfig);
2828
+ function parseKitOptions(cwd$1, svelteConfigPath) {
2829
+ const configSource = readFile(cwd$1, svelteConfigPath);
2866
2830
  const { ast } = parse$1.script(configSource);
2867
2831
  const defaultExport = ast.body.find((s) => s.type === "ExportDefaultDeclaration");
2868
- if (!defaultExport) throw Error(`Missing default export in \`${commonFilePaths.svelteConfig}\``);
2832
+ if (!defaultExport) throw Error(`Missing default export in \`${svelteConfigPath}\``);
2869
2833
  let objectExpression;
2870
2834
  if (defaultExport.declaration.type === "Identifier") {
2871
2835
  const identifier = defaultExport.declaration;
@@ -2875,16 +2839,16 @@ function parseKitOptions(cwd$1) {
2875
2839
  if (declarator?.init?.type !== "ObjectExpression") continue;
2876
2840
  objectExpression = declarator.init;
2877
2841
  }
2878
- if (!objectExpression) throw Error(`Unable to find svelte config object expression from \`${commonFilePaths.svelteConfig}\``);
2842
+ if (!objectExpression) throw Error(`Unable to find svelte config object expression from \`${svelteConfigPath}\``);
2879
2843
  } else if (defaultExport.declaration.type === "ObjectExpression") objectExpression = defaultExport.declaration;
2880
- if (!objectExpression) throw new Error(`Unexpected svelte config shape from \`${commonFilePaths.svelteConfig}\``);
2844
+ if (!objectExpression) throw new Error(`Unexpected svelte config shape from \`${svelteConfigPath}\``);
2881
2845
  const kit = property(objectExpression, {
2882
2846
  name: "kit",
2883
- fallback: create$2({})
2847
+ fallback: create$1({})
2884
2848
  });
2885
2849
  const files = property(kit, {
2886
2850
  name: "files",
2887
- fallback: create$2({})
2851
+ fallback: create$1({})
2888
2852
  });
2889
2853
  const routes = property(files, {
2890
2854
  name: "routes",
@@ -2903,7 +2867,7 @@ function parseKitOptions(cwd$1) {
2903
2867
  //#endregion
2904
2868
  //#region package.json
2905
2869
  var name = "sv";
2906
- var version = "0.12.0";
2870
+ var version = "0.12.2";
2907
2871
 
2908
2872
  //#endregion
2909
2873
  //#region lib/cli/utils/errors.ts
@@ -3198,7 +3162,7 @@ async function createProject(cwd$1, options$8) {
3198
3162
  loadedAddons = result.loadedAddons;
3199
3163
  answers = result.answers;
3200
3164
  }
3201
- create$1(projectPath, {
3165
+ create$3(projectPath, {
3202
3166
  name: projectName,
3203
3167
  template,
3204
3168
  types: language
package/dist/bin.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { f as program, l as from, r as detectPackageManager, u as Command } from "./package-manager-DYfxv5nk.mjs";
3
- import { ht as resolveCommand, t as color } from "./utils-CnfD6Z1s.mjs";
4
- import { a as helpConfig, i as forwardExitCode, n as add, o as name, r as create, s as version } from "./add-CrUK5jc7.mjs";
2
+ import { gt as resolveCommand, t as color } from "./utils-D-OWcBXG.mjs";
3
+ import { f as program, l as from, r as detectPackageManager, u as Command } from "./package-manager-B3sMOeTk.mjs";
4
+ import { a as helpConfig, i as forwardExitCode, n as add, o as name, r as create, s as version } from "./add-RNKqR0_d.mjs";
5
5
  import process from "node:process";
6
6
  import { execSync } from "node:child_process";
7
7