sv 0.9.4 → 0.9.5

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 { Element, T, Tag, __commonJS, __export, __toESM, __toESM$1, be, detect, esm_exports, getUserAgent, parseCss$1, parseHtml, parseHtml$1, parseJson$1, parseScript, parseScript$1, parseSvelte, require_picocolors, require_picocolors$1, resolveCommand, serializeScript, stripAst, up, walk, walk_exports } from "./package-manager-DO5R9a6p.js";
1
+ import { Element, T, Tag, __commonJS, __export, __toESM, __toESM$1, be, detect, esm_exports, getUserAgent, parseCss$1, parseHtml, parseHtml$1, parseJson$1, parseScript, parseScript$1, parseSvelte, require_picocolors as require_picocolors$1, require_picocolors$1 as require_picocolors, resolveCommand, serializeScript, stripAst, up, walk, walk_exports } from "./package-manager-DO5R9a6p.js";
2
2
  import fs, { existsSync, lstatSync, readdirSync } from "node:fs";
3
3
  import path, { dirname, join } from "node:path";
4
4
  import process$1, { stdin, stdout } from "node:process";
@@ -288,25 +288,23 @@ else node.elements.unshift(element);
288
288
  }
289
289
  var object_exports = {};
290
290
  __export(object_exports, {
291
- addProperties: () => addProperties,
292
291
  create: () => create,
293
292
  overrideProperties: () => overrideProperties,
294
- overrideProperty: () => overrideProperty,
295
293
  property: () => property,
296
- removeProperty: () => removeProperty
294
+ propertyNode: () => propertyNode
297
295
  });
298
296
  function property(node, options$6) {
297
+ return propertyNode(node, options$6).value;
298
+ }
299
+ function propertyNode(node, options$6) {
299
300
  const properties = node.properties.filter((x$2) => x$2.type === "Property");
300
301
  let prop = properties.find((x$2) => x$2.key.name === options$6.name);
301
- let propertyValue;
302
- if (prop) propertyValue = prop.value;
303
- else {
302
+ if (!prop) {
304
303
  let isShorthand = false;
305
304
  if (options$6.fallback.type === "Identifier") {
306
305
  const identifier = options$6.fallback;
307
306
  isShorthand = identifier.name === options$6.name;
308
307
  }
309
- propertyValue = options$6.fallback;
310
308
  prop = {
311
309
  type: "Property",
312
310
  shorthand: isShorthand,
@@ -314,14 +312,32 @@ else {
314
312
  type: "Identifier",
315
313
  name: options$6.name
316
314
  },
317
- value: propertyValue,
315
+ value: options$6.fallback,
318
316
  kind: "init",
319
317
  computed: false,
320
318
  method: false
321
319
  };
322
320
  node.properties.push(prop);
323
321
  }
324
- return propertyValue;
322
+ return prop;
323
+ }
324
+ function create(properties) {
325
+ const objectExpression = {
326
+ type: "ObjectExpression",
327
+ properties: []
328
+ };
329
+ return populateObjectExpression({
330
+ objectExpression,
331
+ properties,
332
+ override: false
333
+ });
334
+ }
335
+ function overrideProperties(objectExpression, properties) {
336
+ populateObjectExpression({
337
+ objectExpression,
338
+ properties,
339
+ override: true
340
+ });
325
341
  }
326
342
  function overrideProperty(node, options$6) {
327
343
  const properties = node.properties.filter((x$2) => x$2.type === "Property");
@@ -333,51 +349,42 @@ function overrideProperty(node, options$6) {
333
349
  prop.value = options$6.value;
334
350
  return options$6.value;
335
351
  }
336
- function overrideProperties(node, options$6) {
337
- for (const [prop, value] of Object.entries(options$6.properties)) {
338
- if (value === undefined) continue;
339
- overrideProperty(node, {
340
- name: prop,
341
- value
342
- });
343
- }
344
- }
345
- function addProperties(node, options$6) {
346
- for (const [prop, value] of Object.entries(options$6.properties)) {
347
- if (value === undefined) continue;
348
- property(node, {
349
- name: prop,
350
- fallback: value
351
- });
352
- }
353
- }
354
- function removeProperty(node, options$6) {
355
- const properties = node.properties.filter((x$2) => x$2.type === "Property");
356
- const propIdx = properties.findIndex((x$2) => x$2.key.name === options$6.name);
357
- if (propIdx !== -1) node.properties.splice(propIdx, 1);
358
- }
359
- function create(properties) {
360
- const objExpression = {
361
- type: "ObjectExpression",
362
- properties: []
363
- };
364
- const getExpression = (value) => {
352
+ function populateObjectExpression(options$6) {
353
+ const getExpression = (value, existingExpression) => {
365
354
  let expression;
366
355
  if (Array.isArray(value)) {
367
356
  expression = create$1();
368
357
  for (const v$2 of value) append(expression, getExpression(v$2));
369
- } else if (typeof value === "object" && value !== null) expression = value.type !== undefined ? value : create(value);
358
+ } else if (typeof value === "object" && value !== null) if (value.type !== undefined) expression = value;
359
+ else if (options$6.override && existingExpression && existingExpression.type === "ObjectExpression") expression = populateObjectExpression({
360
+ objectExpression: existingExpression,
361
+ properties: value,
362
+ override: options$6.override
363
+ });
364
+ else expression = populateObjectExpression({
365
+ objectExpression: create({}),
366
+ properties: value,
367
+ override: options$6.override
368
+ });
370
369
  else expression = createLiteral(value);
371
370
  return expression;
372
371
  };
373
- for (const [prop, value] of Object.entries(properties)) {
372
+ for (const [prop, value] of Object.entries(options$6.properties)) {
374
373
  if (value === undefined) continue;
375
- property(objExpression, {
374
+ if (options$6.override) {
375
+ const existingProperties = options$6.objectExpression.properties.filter((x$2) => x$2.type === "Property");
376
+ const existingProperty = existingProperties.find((x$2) => x$2.key.name === prop);
377
+ const existingExpression = existingProperty?.value.type === "ObjectExpression" ? existingProperty.value : undefined;
378
+ overrideProperty(options$6.objectExpression, {
379
+ name: prop,
380
+ value: getExpression(value, existingExpression)
381
+ });
382
+ } else property(options$6.objectExpression, {
376
383
  name: prop,
377
384
  fallback: getExpression(value)
378
385
  });
379
386
  }
380
- return objExpression;
387
+ return options$6.objectExpression;
381
388
  }
382
389
  var function_exports = {};
383
390
  __export(function_exports, {
@@ -889,7 +896,7 @@ const addPlugin = (ast, options$6) => {
889
896
 
890
897
  //#endregion
891
898
  //#region packages/cli/commands/add/utils.ts
892
- var import_picocolors$5 = __toESM$1(require_picocolors$1(), 1);
899
+ var import_picocolors$5 = __toESM$1(require_picocolors(), 1);
893
900
  function getPackageJson(cwd) {
894
901
  const packageText = readFile(cwd, commonFilePaths.packageJson);
895
902
  if (!packageText) {
@@ -1063,7 +1070,7 @@ function parseKitOptions(cwd) {
1063
1070
 
1064
1071
  //#endregion
1065
1072
  //#region packages/cli/lib/install.ts
1066
- var import_picocolors$4 = __toESM$1(require_picocolors$1(), 1);
1073
+ var import_picocolors$4 = __toESM$1(require_picocolors(), 1);
1067
1074
  async function installAddon({ addons, cwd, options: options$6, packageManager = "npm" }) {
1068
1075
  const workspace = await createWorkspace({
1069
1076
  cwd,
@@ -1271,7 +1278,7 @@ else if (y > 0) ret += `${CSI}${y}B`;
1271
1278
  };
1272
1279
  } });
1273
1280
  var import_src$1 = __toESM(require_src(), 1);
1274
- var import_picocolors$3 = __toESM(require_picocolors(), 1);
1281
+ var import_picocolors$3 = __toESM(require_picocolors$1(), 1);
1275
1282
  function hu({ onlyFirst: e$1 = !1 } = {}) {
1276
1283
  const t = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
1277
1284
  return new RegExp(t, e$1 ? void 0 : "g");
@@ -2006,8 +2013,8 @@ B$1 = new WeakMap(), k$1 = new WeakMap(), I = new WeakMap(), v$1 = new WeakMap()
2006
2013
  e$1 ? this.filteredOptions = D$1.filter((t) => x$1(this, I).call(this, e$1, t)) : this.filteredOptions = [...D$1], m(this, B$1, FD(this.focusedValue, this.filteredOptions)), this.focusedValue = this.filteredOptions[x$1(this, B$1)]?.value, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
2007
2014
  }
2008
2015
  };
2009
- var import_picocolors$1 = __toESM(require_picocolors(), 1);
2010
- var import_picocolors$2 = __toESM(require_picocolors(), 1);
2016
+ var import_picocolors$1 = __toESM(require_picocolors$1(), 1);
2017
+ var import_picocolors$2 = __toESM(require_picocolors$1(), 1);
2011
2018
  var import_src = __toESM(require_src(), 1);
2012
2019
  function Pe() {
2013
2020
  return process$1.platform !== "win32" ? process$1.env.TERM !== "linux" : !!process$1.env.CI || !!process$1.env.WT_SESSION || !!process$1.env.TERMINUS_SUBLIME || process$1.env.ConEmuTask === "{cmd::Cmder}" || process$1.env.TERM_PROGRAM === "Terminus-Sublime" || process$1.env.TERM_PROGRAM === "vscode" || process$1.env.TERM === "xterm-256color" || process$1.env.TERM === "alacritty" || process$1.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
@@ -2708,7 +2715,7 @@ else return true;
2708
2715
  if (version.patch === below.patch) return false;
2709
2716
  return undefined;
2710
2717
  }
2711
- var import_picocolors = __toESM(require_picocolors(), 1);
2718
+ var import_picocolors = __toESM(require_picocolors$1(), 1);
2712
2719
  var colors = import_picocolors.default;
2713
2720
 
2714
2721
  //#endregion
@@ -3197,11 +3204,12 @@ var eslint_default = defineAddon({
3197
3204
  options: {},
3198
3205
  run: ({ sv, typescript, dependencyVersion }) => {
3199
3206
  const prettierInstalled = Boolean(dependencyVersion("prettier"));
3200
- sv.devDependency("eslint", "^9.18.0");
3207
+ sv.devDependency("eslint", "^9.22.0");
3201
3208
  sv.devDependency("@eslint/compat", "^1.2.5");
3202
3209
  sv.devDependency("eslint-plugin-svelte", "^3.0.0");
3203
3210
  sv.devDependency("globals", "^16.0.0");
3204
- sv.devDependency("@eslint/js", "^9.18.0");
3211
+ sv.devDependency("@eslint/js", "^9.22.0");
3212
+ sv.devDependency("@types/node", getNodeTypesVersion());
3205
3213
  if (typescript) sv.devDependency("typescript-eslint", "^8.20.0");
3206
3214
  if (prettierInstalled) sv.devDependency("eslint-config-prettier", "^10.0.1");
3207
3215
  sv.file("package.json", (content) => {
@@ -3282,7 +3290,7 @@ var eslint_default = defineAddon({
3282
3290
  let exportExpression;
3283
3291
  if (typescript) {
3284
3292
  const tsConfigCall = function_exports.createCall({
3285
- name: "ts.config",
3293
+ name: "defineConfig",
3286
3294
  args: []
3287
3295
  });
3288
3296
  tsConfigCall.arguments.push(...eslintConfigs);
@@ -3302,14 +3310,14 @@ var eslint_default = defineAddon({
3302
3310
  from: "typescript-eslint",
3303
3311
  as: "ts"
3304
3312
  });
3305
- imports_exports.addNamed(ast, {
3306
- from: "node:url",
3307
- imports: ["fileURLToPath"]
3308
- });
3309
3313
  imports_exports.addDefault(ast, {
3310
3314
  from: "globals",
3311
3315
  as: "globals"
3312
3316
  });
3317
+ if (typescript) imports_exports.addNamed(ast, {
3318
+ from: "eslint/config",
3319
+ imports: ["defineConfig"]
3320
+ });
3313
3321
  imports_exports.addDefault(ast, {
3314
3322
  from: "eslint-plugin-svelte",
3315
3323
  as: "svelte"
@@ -3322,6 +3330,10 @@ var eslint_default = defineAddon({
3322
3330
  from: "@eslint/compat",
3323
3331
  imports: ["includeIgnoreFile"]
3324
3332
  });
3333
+ imports_exports.addNamed(ast, {
3334
+ from: "node:url",
3335
+ imports: ["fileURLToPath"]
3336
+ });
3325
3337
  return generateCode();
3326
3338
  });
3327
3339
  if (prettierInstalled) sv.file("eslint.config.js", addEslintConfigPrettier);
@@ -4423,16 +4435,16 @@ var lucia_default = defineAddon({
4423
4435
  "integer"
4424
4436
  ]
4425
4437
  });
4426
- object_exports.overrideProperties(userAttributes, { properties: { id: common_exports.parseExpression("text('id').primaryKey()") } });
4427
- if (options$6.demo) object_exports.overrideProperties(userAttributes, { properties: {
4438
+ object_exports.overrideProperties(userAttributes, { id: common_exports.parseExpression("text('id').primaryKey()") });
4439
+ if (options$6.demo) object_exports.overrideProperties(userAttributes, {
4428
4440
  username: common_exports.parseExpression("text('username').notNull().unique()"),
4429
4441
  passwordHash: common_exports.parseExpression("text('password_hash').notNull()")
4430
- } });
4431
- object_exports.overrideProperties(sessionAttributes, { properties: {
4442
+ });
4443
+ object_exports.overrideProperties(sessionAttributes, {
4432
4444
  id: common_exports.parseExpression("text('id').primaryKey()"),
4433
4445
  userId: common_exports.parseExpression("text('user_id').notNull().references(() => user.id)"),
4434
4446
  expiresAt: common_exports.parseExpression("integer('expires_at', { mode: 'timestamp' }).notNull()")
4435
- } });
4447
+ });
4436
4448
  }
4437
4449
  if (drizzleDialect === "mysql") {
4438
4450
  imports_exports.addNamed(ast, {
@@ -4443,16 +4455,16 @@ var lucia_default = defineAddon({
4443
4455
  "datetime"
4444
4456
  ]
4445
4457
  });
4446
- object_exports.overrideProperties(userAttributes, { properties: { id: common_exports.parseExpression("varchar('id', { length: 255 }).primaryKey()") } });
4447
- if (options$6.demo) object_exports.overrideProperties(userAttributes, { properties: {
4458
+ object_exports.overrideProperties(userAttributes, { id: common_exports.parseExpression("varchar('id', { length: 255 }).primaryKey()") });
4459
+ if (options$6.demo) object_exports.overrideProperties(userAttributes, {
4448
4460
  username: common_exports.parseExpression("varchar('username', { length: 32 }).notNull().unique()"),
4449
4461
  passwordHash: common_exports.parseExpression("varchar('password_hash', { length: 255 }).notNull()")
4450
- } });
4451
- object_exports.overrideProperties(sessionAttributes, { properties: {
4462
+ });
4463
+ object_exports.overrideProperties(sessionAttributes, {
4452
4464
  id: common_exports.parseExpression("varchar('id', { length: 255 }).primaryKey()"),
4453
4465
  userId: common_exports.parseExpression("varchar('user_id', { length: 255 }).notNull().references(() => user.id)"),
4454
4466
  expiresAt: common_exports.parseExpression("datetime('expires_at').notNull()")
4455
- } });
4467
+ });
4456
4468
  }
4457
4469
  if (drizzleDialect === "postgresql") {
4458
4470
  imports_exports.addNamed(ast, {
@@ -4463,16 +4475,16 @@ var lucia_default = defineAddon({
4463
4475
  "timestamp"
4464
4476
  ]
4465
4477
  });
4466
- object_exports.overrideProperties(userAttributes, { properties: { id: common_exports.parseExpression("text('id').primaryKey()") } });
4467
- if (options$6.demo) object_exports.overrideProperties(userAttributes, { properties: {
4478
+ object_exports.overrideProperties(userAttributes, { id: common_exports.parseExpression("text('id').primaryKey()") });
4479
+ if (options$6.demo) object_exports.overrideProperties(userAttributes, {
4468
4480
  username: common_exports.parseExpression("text('username').notNull().unique()"),
4469
4481
  passwordHash: common_exports.parseExpression("text('password_hash').notNull()")
4470
- } });
4471
- object_exports.overrideProperties(sessionAttributes, { properties: {
4482
+ });
4483
+ object_exports.overrideProperties(sessionAttributes, {
4472
4484
  id: common_exports.parseExpression("text('id').primaryKey()"),
4473
4485
  userId: common_exports.parseExpression("text('user_id').notNull().references(() => user.id)"),
4474
4486
  expiresAt: common_exports.parseExpression("timestamp('expires_at', { withTimezone: true, mode: 'date' }).notNull()")
4475
- } });
4487
+ });
4476
4488
  }
4477
4489
  let code = generateCode();
4478
4490
  if (typescript) {
@@ -4971,10 +4983,7 @@ var mdsvex_default = defineAddon({
4971
4983
  const previousElement = preprocessorArray;
4972
4984
  preprocessorArray = array_exports.create();
4973
4985
  array_exports.append(preprocessorArray, previousElement);
4974
- object_exports.overrideProperty(exportDefault, {
4975
- name: "preprocess",
4976
- value: preprocessorArray
4977
- });
4986
+ object_exports.overrideProperties(exportDefault, { preprocess: preprocessorArray });
4978
4987
  }
4979
4988
  const mdsvexCall = function_exports.createCall({
4980
4989
  name: "mdsvex",
@@ -5243,19 +5252,19 @@ var playwright_default = defineAddon({
5243
5252
  const defineConfig = common_exports.parseExpression("defineConfig({})");
5244
5253
  const { value: defaultExport } = exports_exports.createDefault(ast, { fallback: defineConfig });
5245
5254
  const config = {
5246
- webServer: object_exports.create({
5255
+ webServer: {
5247
5256
  command: "npm run build && npm run preview",
5248
5257
  port: 4173
5249
- }),
5250
- testDir: common_exports.createLiteral("e2e")
5258
+ },
5259
+ testDir: "e2e"
5251
5260
  };
5252
5261
  if (defaultExport.type === "CallExpression" && defaultExport.arguments[0]?.type === "ObjectExpression") {
5253
5262
  imports_exports.addNamed(ast, {
5254
- from: "@playwright/test",
5255
- imports: ["defineConfig"]
5263
+ imports: ["defineConfig"],
5264
+ from: "@playwright/test"
5256
5265
  });
5257
- object_exports.addProperties(defaultExport.arguments[0], { properties: config });
5258
- } else if (defaultExport.type === "ObjectExpression") object_exports.addProperties(defaultExport, { properties: config });
5266
+ object_exports.overrideProperties(defaultExport.arguments[0], config);
5267
+ } else if (defaultExport.type === "ObjectExpression") object_exports.overrideProperties(defaultExport, config);
5259
5268
  else T$2.warn("Unexpected playwright config for playwright add-on. Could not update.");
5260
5269
  return generateCode();
5261
5270
  });
@@ -5437,20 +5446,23 @@ var sveltekit_adapter_default = defineAddon({
5437
5446
  as: adapterName
5438
5447
  });
5439
5448
  const { value: config } = exports_exports.createDefault(ast, { fallback: object_exports.create({}) });
5440
- const kitConfig = config.properties.find((p$1) => p$1.type === "Property" && p$1.key.type === "Identifier" && p$1.key.name === "kit");
5441
- if (kitConfig && kitConfig.value.type === "ObjectExpression") {
5442
- const adapterProp = kitConfig.value.properties.find((p$1) => p$1.type === "Property" && p$1.key.type === "Identifier" && p$1.key.name === "adapter");
5443
- if (adapterProp) adapterProp.leadingComments = [];
5444
- object_exports.overrideProperties(kitConfig.value, { properties: { adapter: function_exports.createCall({
5445
- name: adapterName,
5446
- args: [],
5447
- useIdentifiers: true
5448
- }) } });
5449
- } else object_exports.addProperties(config, { properties: { kit: object_exports.create({ adapter: function_exports.createCall({
5449
+ object_exports.overrideProperties(config, { kit: { adapter: function_exports.createCall({
5450
5450
  name: adapterName,
5451
5451
  args: [],
5452
5452
  useIdentifiers: true
5453
- }) }) } });
5453
+ }) } });
5454
+ if (adapter.package !== "@sveltejs/adapter-auto") {
5455
+ const fallback = object_exports.create({});
5456
+ const cfgKitValue = object_exports.property(config, {
5457
+ name: "kit",
5458
+ fallback
5459
+ });
5460
+ const cfgAdapter = object_exports.propertyNode(cfgKitValue, {
5461
+ name: "adapter",
5462
+ fallback
5463
+ });
5464
+ cfgAdapter.leadingComments = [];
5465
+ }
5454
5466
  return generateCode();
5455
5467
  });
5456
5468
  }