sv 0.5.3 → 0.5.4

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
@@ -25,7 +25,7 @@ import require$$0$3 from 'events';
25
25
  import { t as templates, c as create$2 } from './index-A89HFWzv.js';
26
26
 
27
27
  var name = "sv";
28
- var version = "0.5.3";
28
+ var version = "0.5.4";
29
29
  var type = "module";
30
30
  var description = "A CLI for creating and updating SvelteKit projects";
31
31
  var license = "MIT";
@@ -45201,56 +45201,59 @@ function __extends(d, b) {
45201
45201
  }
45202
45202
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
45203
45203
  }
45204
+ typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
45205
+ var e = new Error(message);
45206
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
45207
+ };
45208
+ var whitespace = /\s/;
45209
+ var number = /-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/;
45210
+ function spaces(n) {
45211
+ var result2 = "";
45212
+ while (n--)
45213
+ result2 += " ";
45214
+ return result2;
45215
+ }
45216
+ function rangeContains(range, index2) {
45217
+ return range.start <= index2 && index2 < range.end;
45218
+ }
45204
45219
  function getLocator$2(source, options2) {
45205
45220
  if (options2 === void 0) {
45206
45221
  options2 = {};
45207
45222
  }
45208
- var offsetLine = options2.offsetLine || 0;
45209
- var offsetColumn = options2.offsetColumn || 0;
45210
- var originalLines = source.split("\n");
45223
+ var _a2 = options2.offsetLine, offsetLine = _a2 === void 0 ? 0 : _a2, _b = options2.offsetColumn, offsetColumn = _b === void 0 ? 0 : _b;
45211
45224
  var start = 0;
45212
- var lineRanges = originalLines.map(function(line, i2) {
45225
+ var ranges = source.split("\n").map(function(line, i2) {
45213
45226
  var end = start + line.length + 1;
45214
45227
  var range = { start, end, line: i2 };
45215
45228
  start = end;
45216
45229
  return range;
45217
45230
  });
45218
45231
  var i = 0;
45219
- function rangeContains(range, index2) {
45220
- return range.start <= index2 && index2 < range.end;
45221
- }
45222
- function getLocation(range, index2) {
45223
- return { line: offsetLine + range.line, column: offsetColumn + index2 - range.start, character: index2 };
45224
- }
45225
- function locate2(search, startIndex) {
45232
+ function locator(search, index2) {
45226
45233
  if (typeof search === "string") {
45227
- search = source.indexOf(search, startIndex || 0);
45234
+ search = source.indexOf(search, index2 !== null && index2 !== void 0 ? index2 : 0);
45228
45235
  }
45229
- var range = lineRanges[i];
45236
+ if (search === -1)
45237
+ return void 0;
45238
+ var range = ranges[i];
45230
45239
  var d = search >= range.end ? 1 : -1;
45231
45240
  while (range) {
45232
- if (rangeContains(range, search))
45233
- return getLocation(range, search);
45241
+ if (rangeContains(range, search)) {
45242
+ return {
45243
+ line: offsetLine + range.line,
45244
+ column: offsetColumn + search - range.start,
45245
+ character: search
45246
+ };
45247
+ }
45234
45248
  i += d;
45235
- range = lineRanges[i];
45249
+ range = ranges[i];
45236
45250
  }
45237
45251
  }
45238
- return locate2;
45252
+ return locator;
45239
45253
  }
45240
45254
  function locate(source, search, options2) {
45241
- if (typeof options2 === "number") {
45242
- throw new Error("locate takes a { startIndex, offsetLine, offsetColumn } object as the third argument");
45243
- }
45244
45255
  return getLocator$2(source, options2)(search, options2 && options2.startIndex);
45245
45256
  }
45246
- var whitespace = /\s/;
45247
- var number = /-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/;
45248
- function spaces(n) {
45249
- var result2 = "";
45250
- while (n--)
45251
- result2 += " ";
45252
- return result2;
45253
- }
45254
45257
  function parse(str, opts) {
45255
45258
  var parser2 = new Parser3(str, opts);
45256
45259
  return parser2.value;
@@ -45535,7 +45538,7 @@ function stringifyValue(value, indentation, indentString, newlines) {
45535
45538
  return stringifyValue(element, indentation + indentString, indentString);
45536
45539
  });
45537
45540
  {
45538
- return "[\n".concat(indentation + indentString) + elements.join(",\n".concat(indentation + indentString)) + "\n".concat(indentation, "]");
45541
+ return "[".concat(indentation + indentString) + elements.join(",".concat(indentation + indentString)) + "".concat(indentation, "]");
45539
45542
  }
45540
45543
  } else if (type === "object") {
45541
45544
  var keys = Object.keys(value);
@@ -50478,11 +50481,11 @@ ${sessionType}`);
50478
50481
  // DEMO
50479
50482
  // login/register
50480
50483
  {
50481
- name: ({ kit: kit2, typescript }) => `${kit2.routesDirectory}/demo/login/+page.server.${typescript ? "ts" : "js"}`,
50484
+ name: ({ kit: kit2, typescript }) => `${kit2.routesDirectory}/demo/lucia/login/+page.server.${typescript ? "ts" : "js"}`,
50482
50485
  condition: ({ options: options2 }) => options2.demo,
50483
50486
  content({ content, typescript, kit: kit2 }) {
50484
50487
  if (content) {
50485
- const filePath = `${kit2.routesDirectory}/demo/login/+page.server.${typescript ? "ts" : "js"}`;
50488
+ const filePath = `${kit2.routesDirectory}/demo/lucia/login/+page.server.${typescript ? "ts" : "js"}`;
50486
50489
  log.warn(`Existing ${picocolors.yellow(filePath)} file. Could not update.`);
50487
50490
  return content;
50488
50491
  }
@@ -50500,7 +50503,7 @@ ${sessionType}`);
50500
50503
  `)}
50501
50504
  export const load${ts(": PageServerLoad")} = async (event) => {
50502
50505
  if (event.locals.user) {
50503
- return redirect(302, '/demo');
50506
+ return redirect(302, '/demo/lucia');
50504
50507
  }
50505
50508
  return {};
50506
50509
  };
@@ -50547,7 +50550,7 @@ ${sessionType}`);
50547
50550
  secure: !dev
50548
50551
  });
50549
50552
 
50550
- return redirect(302, '/demo');
50553
+ return redirect(302, '/demo/lucia');
50551
50554
  },
50552
50555
  register: async (event) => {
50553
50556
  const formData = await event.request.formData();
@@ -50584,7 +50587,7 @@ ${sessionType}`);
50584
50587
  } catch (e) {
50585
50588
  return fail(500, { message: 'An error has occurred' });
50586
50589
  }
50587
- return redirect(302, '/demo');
50590
+ return redirect(302, '/demo/lucia');
50588
50591
  },
50589
50592
  };
50590
50593
 
@@ -50614,11 +50617,11 @@ ${sessionType}`);
50614
50617
  }
50615
50618
  },
50616
50619
  {
50617
- name: ({ kit: kit2 }) => `${kit2.routesDirectory}/demo/login/+page.svelte`,
50620
+ name: ({ kit: kit2 }) => `${kit2.routesDirectory}/demo/lucia/login/+page.svelte`,
50618
50621
  condition: ({ options: options2 }) => options2.demo,
50619
50622
  content({ content, dependencyVersion, typescript, kit: kit2 }) {
50620
50623
  if (content) {
50621
- const filePath = `${kit2.routesDirectory}/demo/login/+page.svelte`;
50624
+ const filePath = `${kit2.routesDirectory}/demo/lucia/login/+page.svelte`;
50622
50625
  log.warn(`Existing ${picocolors.yellow(filePath)} file. Could not update.`);
50623
50626
  return content;
50624
50627
  }
@@ -50630,11 +50633,11 @@ ${sessionType}`);
50630
50633
  },
50631
50634
  // logout
50632
50635
  {
50633
- name: ({ kit: kit2, typescript }) => `${kit2.routesDirectory}/demo/+page.server.${typescript ? "ts" : "js"}`,
50636
+ name: ({ kit: kit2, typescript }) => `${kit2.routesDirectory}/demo/lucia/+page.server.${typescript ? "ts" : "js"}`,
50634
50637
  condition: ({ options: options2 }) => options2.demo,
50635
50638
  content({ content, typescript, kit: kit2 }) {
50636
50639
  if (content) {
50637
- const filePath = `${kit2.routesDirectory}/demo/+page.server.${typescript ? "ts" : "js"}`;
50640
+ const filePath = `${kit2.routesDirectory}/demo/lucia/+page.server.${typescript ? "ts" : "js"}`;
50638
50641
  log.warn(`Existing ${picocolors.yellow(filePath)} file. Could not update.`);
50639
50642
  return content;
50640
50643
  }
@@ -50646,7 +50649,7 @@ ${sessionType}`);
50646
50649
  `)}
50647
50650
  export const load${ts(": PageServerLoad")} = async (event) => {
50648
50651
  if (!event.locals.user) {
50649
- return redirect(302, '/demo/login');
50652
+ return redirect(302, '/demo/lucia/login');
50650
50653
  }
50651
50654
  return { user: event.locals.user };
50652
50655
  };
@@ -50659,18 +50662,18 @@ ${sessionType}`);
50659
50662
  await auth.invalidateSession(event.locals.session.id);
50660
50663
  event.cookies.delete(auth.sessionCookieName, { path: '/' });
50661
50664
 
50662
- return redirect(302, '/demo/login');
50665
+ return redirect(302, '/demo/lucia/login');
50663
50666
  },
50664
50667
  };
50665
50668
  `;
50666
50669
  }
50667
50670
  },
50668
50671
  {
50669
- name: ({ kit: kit2 }) => `${kit2.routesDirectory}/demo/+page.svelte`,
50672
+ name: ({ kit: kit2 }) => `${kit2.routesDirectory}/demo/lucia/+page.svelte`,
50670
50673
  condition: ({ options: options2 }) => options2.demo,
50671
50674
  content({ content, dependencyVersion, typescript, kit: kit2 }) {
50672
50675
  if (content) {
50673
- const filePath = `${kit2.routesDirectory}/demo/+page.svelte`;
50676
+ const filePath = `${kit2.routesDirectory}/demo/lucia/+page.svelte`;
50674
50677
  log.warn(`Existing ${picocolors.yellow(filePath)} file. Could not update.`);
50675
50678
  return content;
50676
50679
  }
@@ -50684,7 +50687,7 @@ ${sessionType}`);
50684
50687
  nextSteps: ({ highlighter, options: options2 }) => {
50685
50688
  const steps = [`Run ${highlighter.command("npm run db:push")} to update your database schema`];
50686
50689
  if (options2.demo) {
50687
- steps.push(`Visit ${highlighter.route("/demo")} route to view the demo`);
50690
+ steps.push(`Visit ${highlighter.route("/demo/lucia")} route to view the demo`);
50688
50691
  }
50689
50692
  return steps;
50690
50693
  }
@@ -50835,7 +50838,7 @@ const DEFAULT_INLANG_PROJECT = {
50835
50838
  };
50836
50839
  const options$1 = defineAdderOptions({
50837
50840
  availableLanguageTags: {
50838
- question: `Which language tags would you like to support? ${picocolors.gray("(e.g. en,de-ch)")}`,
50841
+ question: `Which languages would you like to support? ${picocolors.gray("(e.g. en,de-ch)")}`,
50839
50842
  type: "string",
50840
50843
  default: "en",
50841
50844
  validate(input) {
@@ -50855,7 +50858,7 @@ const options$1 = defineAdderOptions({
50855
50858
  },
50856
50859
  demo: {
50857
50860
  type: "boolean",
50858
- default: false,
50861
+ default: true,
50859
50862
  question: "Do you want to include a demo?"
50860
50863
  }
50861
50864
  });
@@ -51007,7 +51010,7 @@ var paraglide = defineAdder({
51007
51010
  },
51008
51011
  {
51009
51012
  // add usage example
51010
- name: ({ kit: kit2 }) => `${kit2?.routesDirectory}/+page.svelte`,
51013
+ name: ({ kit: kit2 }) => `${kit2?.routesDirectory}/demo/paraglide/+page.svelte`,
51011
51014
  condition: ({ options: options2 }) => options2.demo,
51012
51015
  content({ content, options: options2, typescript }) {
51013
51016
  const { script, template, generateCode } = parseSvelte(content, { typescript });
@@ -51066,10 +51069,16 @@ ${links}
51066
51069
  fs$3.writeFileSync(fullFilePath, JSON.stringify(jsonData, null, 2) + "\n");
51067
51070
  }
51068
51071
  },
51069
- nextSteps: ({ highlighter }) => [
51070
- `Edit your messages in ${highlighter.path("messages/en.json")}`,
51071
- "Consider installing the Sherlock IDE Extension"
51072
- ]
51072
+ nextSteps: ({ highlighter }) => {
51073
+ const steps = [
51074
+ `Edit your messages in ${highlighter.path("messages/en.json")}`,
51075
+ "Consider installing the Sherlock IDE Extension"
51076
+ ];
51077
+ if (options$1.demo) {
51078
+ steps.push(`Visit ${highlighter.route("/demo/paraglide")} route to view the demo`);
51079
+ }
51080
+ return steps;
51081
+ }
51073
51082
  });
51074
51083
  const isValidLanguageTag = (languageTag) => (
51075
51084
  // Regex vendored in from https://github.com/opral/monorepo/blob/94c2298cc1da5378b908e4c160b0fa71a45caadb/inlang/source-code/versioned-interfaces/language-tag/src/interface.ts#L16
@@ -51358,11 +51367,43 @@ function addImports(ast, imports) {
51358
51367
  return nodes;
51359
51368
  }
51360
51369
 
51370
+ const plugins = [
51371
+ {
51372
+ id: "typography",
51373
+ package: "@tailwindcss/typography",
51374
+ version: "^0.5.15",
51375
+ identifier: "typography"
51376
+ },
51377
+ {
51378
+ id: "forms",
51379
+ package: "@tailwindcss/forms",
51380
+ version: "^0.5.9",
51381
+ identifier: "forms"
51382
+ },
51383
+ {
51384
+ id: "container-queries",
51385
+ package: "@tailwindcss/container-queries",
51386
+ version: "^0.1.1",
51387
+ identifier: "containerQueries"
51388
+ },
51389
+ {
51390
+ id: "aspect-ratio",
51391
+ package: "@tailwindcss/aspect-ratio",
51392
+ version: "^0.4.2",
51393
+ identifier: "aspectRatio"
51394
+ }
51395
+ ];
51396
+ const pluginPackages = plugins.map((x) => ({
51397
+ name: x.package,
51398
+ version: x.version,
51399
+ dev: true,
51400
+ condition: ({ options: options2 }) => options2.plugins.includes(x.id)
51401
+ }));
51361
51402
  const options = defineAdderOptions({
51362
51403
  plugins: {
51363
51404
  type: "multiselect",
51364
51405
  question: "Which plugins would you like to add?",
51365
- options: [{ value: "typography", label: "Typography" }],
51406
+ options: plugins.map((p) => ({ value: p.id, label: p.id, hint: p.package })),
51366
51407
  default: []
51367
51408
  }
51368
51409
  });
@@ -51375,18 +51416,13 @@ var tailwindcss = defineAdder({
51375
51416
  packages: [
51376
51417
  { name: "tailwindcss", version: "^3.4.9", dev: true },
51377
51418
  { name: "autoprefixer", version: "^10.4.20", dev: true },
51378
- {
51379
- name: "@tailwindcss/typography",
51380
- version: "^0.5.14",
51381
- dev: true,
51382
- condition: ({ options: options2 }) => options2.plugins.includes("typography")
51383
- },
51384
51419
  {
51385
51420
  name: "prettier-plugin-tailwindcss",
51386
51421
  version: "^0.6.5",
51387
51422
  dev: true,
51388
51423
  condition: ({ dependencyVersion }) => Boolean(dependencyVersion("prettier"))
51389
- }
51424
+ },
51425
+ ...pluginPackages
51390
51426
  ],
51391
51427
  files: [
51392
51428
  {
@@ -51399,17 +51435,23 @@ var tailwindcss = defineAdder({
51399
51435
  imports.addNamed(ast, "tailwindcss", { Config: "Config" }, true);
51400
51436
  root = common.typeAnnotateExpression(rootExport, "Config");
51401
51437
  }
51402
- const { astNode: exportDeclaration } = exports.defaultExport(ast, root ?? rootExport);
51403
- if (!typescript)
51438
+ const { astNode: exportDeclaration, value: node } = exports.defaultExport(
51439
+ ast,
51440
+ root ?? rootExport
51441
+ );
51442
+ const config = node.type === "TSAsExpression" ? node.expression : node;
51443
+ if (!typescript) {
51404
51444
  common.addJsDocTypeComment(exportDeclaration, "import('tailwindcss').Config");
51405
- const contentArray = object.property(rootExport, "content", array.createEmpty());
51445
+ }
51446
+ const contentArray = object.property(config, "content", array.createEmpty());
51406
51447
  array.push(contentArray, "./src/**/*.{html,js,svelte,ts}");
51407
- const themeObject = object.property(rootExport, "theme", object.createEmpty());
51448
+ const themeObject = object.property(config, "theme", object.createEmpty());
51408
51449
  object.property(themeObject, "extend", object.createEmpty());
51409
- const pluginsArray = object.property(rootExport, "plugins", array.createEmpty());
51410
- if (options2.plugins.includes("typography")) {
51411
- const requireCall = _function.call("require", ["@tailwindcss/typography"]);
51412
- array.push(pluginsArray, requireCall);
51450
+ const pluginsArray = object.property(config, "plugins", array.createEmpty());
51451
+ for (const plugin of plugins) {
51452
+ if (!options2.plugins.includes(plugin.id)) continue;
51453
+ imports.addDefault(ast, plugin.package, plugin.identifier);
51454
+ array.push(pluginsArray, { type: "Identifier", name: plugin.identifier });
51413
51455
  }
51414
51456
  return generateCode();
51415
51457
  }
@@ -51474,8 +51516,8 @@ var tailwindcss = defineAdder({
51474
51516
  const { data, generateCode } = parseJson(content);
51475
51517
  const PLUGIN_NAME = "prettier-plugin-tailwindcss";
51476
51518
  data.plugins ?? (data.plugins = []);
51477
- const plugins = data.plugins;
51478
- if (!plugins.includes(PLUGIN_NAME)) plugins.push(PLUGIN_NAME);
51519
+ const plugins2 = data.plugins;
51520
+ if (!plugins2.includes(PLUGIN_NAME)) plugins2.push(PLUGIN_NAME);
51479
51521
  return generateCode();
51480
51522
  },
51481
51523
  condition: ({ dependencyVersion }) => Boolean(dependencyVersion("prettier"))
@@ -51711,13 +51753,17 @@ function getGlobalPreconditions(cwd, projectType, adders) {
51711
51753
  if (projectType === "svelte" && !supportedEnvironments.svelte) return true;
51712
51754
  return false;
51713
51755
  });
51714
- if (addersForInvalidEnvironment.length == 0) {
51756
+ if (addersForInvalidEnvironment.length === 0) {
51715
51757
  return { success: true, message: void 0 };
51716
51758
  }
51717
- const messages = addersForInvalidEnvironment.map(
51718
- (a) => `"${a.id}" does not support "${projectType}"`
51719
- );
51720
- return { success: false, message: messages.join(" / ") };
51759
+ const messages = addersForInvalidEnvironment.map((a) => {
51760
+ if (projectType === "kit") {
51761
+ return `'${a.id}' does not support SvelteKit`;
51762
+ } else {
51763
+ return `'${a.id}' requires SvelteKit`;
51764
+ }
51765
+ });
51766
+ throw new Error(messages.join("\n"));
51721
51767
  }
51722
51768
  }
51723
51769
  ]
@@ -55178,7 +55224,7 @@ const addersOptions = getAdderOptionFlags();
55178
55224
  const communityDetails = [];
55179
55225
  const defaultPkgPath = up();
55180
55226
  const defaultCwd = defaultPkgPath ? path$3.dirname(defaultPkgPath) : void 0;
55181
- const add = new Command("add").description("applies specified adders into a project").argument("[adder...]", "adders to install").option("-C, --cwd <path>", "path to working directory", defaultCwd).option("--no-install", "skips installing dependencies").option("--no-preconditions", "skips validating preconditions").configureHelp(helpConfig).action((adderArgs, opts) => {
55227
+ const add = new Command("add").description("applies specified integrations into a project").argument("[integration...]", "integrations to install").option("-C, --cwd <path>", "path to working directory", defaultCwd).option("--no-install", "skips installing dependencies").option("--no-preconditions", "skips validating preconditions").configureHelp(helpConfig).action((adderArgs, opts) => {
55182
55228
  if (opts.cwd === void 0) {
55183
55229
  console.error(
55184
55230
  "Invalid workspace: Please verify that you are inside of a Svelte project. You can also specify the working directory with `--cwd <path>`"
@@ -55379,7 +55425,7 @@ Available options: ${communityAdderIds.join(", ")}`
55379
55425
  );
55380
55426
  if (installed) continue;
55381
55427
  const install = await confirm({
55382
- message: `The ${pc.bold(pc.cyan(adder.id))} adder requires ${pc.bold(pc.cyan(depId))} to also be installed. ${pc.green("Install it?")}`
55428
+ message: `The ${pc.bold(pc.cyan(adder.id))} integration requires ${pc.bold(pc.cyan(depId))} to also be setup. ${pc.green("Include it?")}`
55383
55429
  });
55384
55430
  if (install !== true) {
55385
55431
  cancel("Operation cancelled.");
@@ -55573,7 +55619,7 @@ function getAdderOptionFlags() {
55573
55619
  const preset = defaults.join(", ") || "none";
55574
55620
  const option = new Option(
55575
55621
  `--${id} [options...]`,
55576
- `${id} adder options ${pc.dim(`(preset: ${preset})`)}
55622
+ `${id} integration options ${pc.dim(`(preset: ${preset})`)}
55577
55623
  ${choices}`
55578
55624
  ).preset(preset).argParser((value, prev) => {
55579
55625
  prev ?? (prev = []);
@@ -55634,11 +55680,11 @@ const templateOption = new Option("--template <type>", "template to scaffold").c
55634
55680
  const ProjectPathSchema = string();
55635
55681
  const OptionsSchema = strictObject({
55636
55682
  checkTypes: optional(picklist(langs)),
55637
- adders: boolean(),
55683
+ integrations: boolean(),
55638
55684
  install: boolean(),
55639
55685
  template: optional(picklist(templateChoices))
55640
55686
  });
55641
- const create = new Command("create").description("scaffolds a new SvelteKit project").argument("[path]", "where the project will be created", process$1$1.cwd()).addOption(langOption).addOption(templateOption).option("--no-adders", "skips interactive adder installer").option("--no-install", "skips installing dependencies").configureHelp(helpConfig).action((projectPath, opts) => {
55687
+ const create = new Command("create").description("scaffolds a new SvelteKit project").argument("[path]", "where the project will be created", process$1$1.cwd()).addOption(langOption).addOption(templateOption).option("--no-integrations", "skips interactive integration installer").option("--no-install", "skips installing dependencies").configureHelp(helpConfig).action((projectPath, opts) => {
55642
55688
  const cwd = parse$8(ProjectPathSchema, projectPath);
55643
55689
  const options = parse$8(OptionsSchema, opts);
55644
55690
  runCommand(async () => {
@@ -55728,7 +55774,7 @@ async function createProject(cwd, options) {
55728
55774
  types: language
55729
55775
  });
55730
55776
  initSpinner.stop("Project created");
55731
- if (options.adders) {
55777
+ if (options.integrations) {
55732
55778
  await runAddCommand(
55733
55779
  { cwd: projectPath, install: false, preconditions: true, community: [] },
55734
55780
  []