sv 0.9.5 → 0.9.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/{addons-CkfbAJXX.js → addons-C1BtYuVp.js} +97 -29
- package/dist/bin.js +81 -20
- package/dist/index.js +1 -1
- package/package.json +3 -3
|
@@ -436,7 +436,9 @@ __export(imports_exports, {
|
|
|
436
436
|
addDefault: () => addDefault,
|
|
437
437
|
addEmpty: () => addEmpty,
|
|
438
438
|
addNamed: () => addNamed,
|
|
439
|
-
addNamespace: () => addNamespace
|
|
439
|
+
addNamespace: () => addNamespace,
|
|
440
|
+
find: () => find,
|
|
441
|
+
remove: () => remove
|
|
440
442
|
});
|
|
441
443
|
function addEmpty(node, options$6) {
|
|
442
444
|
const expectedImportDeclaration = {
|
|
@@ -533,6 +535,42 @@ function addImportIfNecessary(node, expectedImportDeclaration) {
|
|
|
533
535
|
const importDeclaration = importDeclarations.find((item) => areNodesEqual(item, expectedImportDeclaration));
|
|
534
536
|
if (!importDeclaration) node.body.unshift(expectedImportDeclaration);
|
|
535
537
|
}
|
|
538
|
+
function find(ast, options$6) {
|
|
539
|
+
let alias = options$6.name;
|
|
540
|
+
let statement;
|
|
541
|
+
walk(ast, null, { ImportDeclaration(node) {
|
|
542
|
+
if (node.specifiers && node.source.value === options$6.from) {
|
|
543
|
+
const specifier = node.specifiers.find((sp) => sp.type === "ImportSpecifier" && sp.imported.type === "Identifier" && sp.imported.name === options$6.name);
|
|
544
|
+
if (specifier) {
|
|
545
|
+
statement = node;
|
|
546
|
+
alias = specifier.local?.name ?? alias;
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
} });
|
|
551
|
+
if (statement) return {
|
|
552
|
+
statement,
|
|
553
|
+
alias
|
|
554
|
+
};
|
|
555
|
+
return {
|
|
556
|
+
statement: undefined,
|
|
557
|
+
alias: undefined
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
function remove(ast, options$6) {
|
|
561
|
+
const statement = options$6.statement ?? find(ast, {
|
|
562
|
+
name: options$6.name,
|
|
563
|
+
from: options$6.from
|
|
564
|
+
}).statement;
|
|
565
|
+
if (!statement) return;
|
|
566
|
+
if (statement.specifiers?.length === 1) {
|
|
567
|
+
const idxToRemove = ast.body.indexOf(statement);
|
|
568
|
+
ast.body.splice(idxToRemove, 1);
|
|
569
|
+
} else {
|
|
570
|
+
const idxToRemove = statement.specifiers?.findIndex((s) => s.type === "ImportSpecifier" && s.imported.type === "Identifier" && s.imported.name === options$6.name);
|
|
571
|
+
if (idxToRemove !== undefined && idxToRemove !== -1) statement.specifiers?.splice(idxToRemove, 1);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
536
574
|
var variables_exports = {};
|
|
537
575
|
__export(variables_exports, {
|
|
538
576
|
createIdentifier: () => createIdentifier,
|
|
@@ -596,7 +634,8 @@ function createDefault(node, options$6) {
|
|
|
596
634
|
node.body.push(exportNode);
|
|
597
635
|
return {
|
|
598
636
|
astNode: exportNode,
|
|
599
|
-
value: options$6.fallback
|
|
637
|
+
value: options$6.fallback,
|
|
638
|
+
isFallback: true
|
|
600
639
|
};
|
|
601
640
|
}
|
|
602
641
|
const exportDefaultDeclaration = existingNode;
|
|
@@ -614,13 +653,15 @@ function createDefault(node, options$6) {
|
|
|
614
653
|
const value = variableDeclarator.init;
|
|
615
654
|
return {
|
|
616
655
|
astNode: exportDefaultDeclaration,
|
|
617
|
-
value
|
|
656
|
+
value,
|
|
657
|
+
isFallback: false
|
|
618
658
|
};
|
|
619
659
|
}
|
|
620
660
|
const declaration$1 = exportDefaultDeclaration.declaration;
|
|
621
661
|
return {
|
|
622
662
|
astNode: exportDefaultDeclaration,
|
|
623
|
-
value: declaration$1
|
|
663
|
+
value: declaration$1,
|
|
664
|
+
isFallback: false
|
|
624
665
|
};
|
|
625
666
|
}
|
|
626
667
|
function createNamed(node, options$6) {
|
|
@@ -825,20 +866,35 @@ function isFunctionDeclaration(node, funcName) {
|
|
|
825
866
|
return node.type === "FunctionDeclaration" && node.id?.name === funcName;
|
|
826
867
|
}
|
|
827
868
|
var vite_exports = {};
|
|
828
|
-
__export(vite_exports, {
|
|
829
|
-
|
|
869
|
+
__export(vite_exports, {
|
|
870
|
+
addPlugin: () => addPlugin,
|
|
871
|
+
getConfig: () => getConfig
|
|
872
|
+
});
|
|
873
|
+
function isConfigWrapper(callExpression, knownWrappers) {
|
|
874
|
+
if (callExpression.callee.type !== "Identifier") return false;
|
|
875
|
+
const calleeName = callExpression.callee.name;
|
|
876
|
+
if (knownWrappers.includes(calleeName)) return true;
|
|
877
|
+
const isObjectCall = callExpression.arguments.length === 1 && callExpression.arguments[0]?.type === "ObjectExpression";
|
|
878
|
+
return knownWrappers.includes(calleeName) || isObjectCall;
|
|
879
|
+
}
|
|
880
|
+
function exportDefaultConfig(ast, options$6) {
|
|
830
881
|
const { fallback, ignoreWrapper } = options$6;
|
|
831
882
|
let fallbackExpression;
|
|
832
|
-
if (fallback) fallbackExpression = typeof fallback === "string" ? parseExpression(fallback) : fallback;
|
|
883
|
+
if (fallback) fallbackExpression = typeof fallback.code === "string" ? parseExpression(fallback.code) : fallback.code;
|
|
833
884
|
else fallbackExpression = create({});
|
|
834
|
-
const { value } = createDefault(ast, { fallback: fallbackExpression });
|
|
885
|
+
const { value, isFallback } = createDefault(ast, { fallback: fallbackExpression });
|
|
886
|
+
if (isFallback) options$6.fallback?.additional?.(ast);
|
|
835
887
|
const rootObject = value.type === "TSSatisfiesExpression" ? value.expression : value;
|
|
836
888
|
let configObject;
|
|
837
|
-
if (!
|
|
889
|
+
if (!("arguments" in rootObject) || !Array.isArray(rootObject.arguments)) {
|
|
890
|
+
configObject = rootObject;
|
|
891
|
+
return configObject;
|
|
892
|
+
}
|
|
893
|
+
if (rootObject.type !== "CallExpression" || rootObject.callee.type !== "Identifier") {
|
|
838
894
|
configObject = rootObject;
|
|
839
895
|
return configObject;
|
|
840
896
|
}
|
|
841
|
-
if (rootObject
|
|
897
|
+
if (!isConfigWrapper(rootObject, ignoreWrapper)) {
|
|
842
898
|
configObject = rootObject;
|
|
843
899
|
return configObject;
|
|
844
900
|
}
|
|
@@ -880,19 +936,24 @@ function addInArrayOfObject(ast, options$6) {
|
|
|
880
936
|
else append(targetArray, expression);
|
|
881
937
|
}
|
|
882
938
|
const addPlugin = (ast, options$6) => {
|
|
883
|
-
|
|
884
|
-
from: "vite",
|
|
885
|
-
imports: { defineConfig: "defineConfig" }
|
|
886
|
-
});
|
|
887
|
-
const configObject = exportDefaultConfig(ast, {
|
|
888
|
-
fallback: "defineConfig()",
|
|
889
|
-
ignoreWrapper: "defineConfig"
|
|
890
|
-
});
|
|
939
|
+
const configObject = getConfig(ast);
|
|
891
940
|
addInArrayOfObject(configObject, {
|
|
892
941
|
arrayProperty: "plugins",
|
|
893
942
|
...options$6
|
|
894
943
|
});
|
|
895
944
|
};
|
|
945
|
+
const getConfig = (ast) => {
|
|
946
|
+
return exportDefaultConfig(ast, {
|
|
947
|
+
fallback: {
|
|
948
|
+
code: "defineConfig()",
|
|
949
|
+
additional: (ast$1) => addNamed(ast$1, {
|
|
950
|
+
imports: ["defineConfig"],
|
|
951
|
+
from: "vite"
|
|
952
|
+
})
|
|
953
|
+
},
|
|
954
|
+
ignoreWrapper: ["defineConfig"]
|
|
955
|
+
});
|
|
956
|
+
};
|
|
896
957
|
|
|
897
958
|
//#endregion
|
|
898
959
|
//#region packages/cli/commands/add/utils.ts
|
|
@@ -5679,17 +5740,8 @@ var vitest_addon_default = defineAddon({
|
|
|
5679
5740
|
exclude: ["src/**/*.svelte.{test,spec}.{js,ts}"]
|
|
5680
5741
|
}
|
|
5681
5742
|
});
|
|
5682
|
-
const
|
|
5683
|
-
|
|
5684
|
-
args: []
|
|
5685
|
-
});
|
|
5686
|
-
const { value: defineWorkspaceCall } = exports_exports.createDefault(ast, { fallback: defineConfigFallback });
|
|
5687
|
-
if (defineWorkspaceCall.type !== "CallExpression") T$2.warn("Unexpected vite config. Could not update.");
|
|
5688
|
-
const vitestConfig = function_exports.getArgument(defineWorkspaceCall, {
|
|
5689
|
-
index: 0,
|
|
5690
|
-
fallback: object_exports.create({})
|
|
5691
|
-
});
|
|
5692
|
-
const testObject = object_exports.property(vitestConfig, {
|
|
5743
|
+
const viteConfig = vite_exports.getConfig(ast);
|
|
5744
|
+
const testObject = object_exports.property(viteConfig, {
|
|
5693
5745
|
name: "test",
|
|
5694
5746
|
fallback: object_exports.create({ expect: { requireAssertions: true } })
|
|
5695
5747
|
});
|
|
@@ -5699,6 +5751,22 @@ var vitest_addon_default = defineAddon({
|
|
|
5699
5751
|
});
|
|
5700
5752
|
if (componentTesting) array_exports.append(workspaceArray, clientObjectExpression);
|
|
5701
5753
|
if (unitTesting) array_exports.append(workspaceArray, serverObjectExpression);
|
|
5754
|
+
const importName = "defineConfig";
|
|
5755
|
+
const { statement, alias } = imports_exports.find(ast, {
|
|
5756
|
+
name: importName,
|
|
5757
|
+
from: "vite"
|
|
5758
|
+
});
|
|
5759
|
+
if (statement) {
|
|
5760
|
+
imports_exports.addNamed(ast, {
|
|
5761
|
+
imports: { defineConfig: alias },
|
|
5762
|
+
from: "vitest/config"
|
|
5763
|
+
});
|
|
5764
|
+
imports_exports.remove(ast, {
|
|
5765
|
+
name: importName,
|
|
5766
|
+
from: "vite",
|
|
5767
|
+
statement
|
|
5768
|
+
});
|
|
5769
|
+
}
|
|
5702
5770
|
return generateCode();
|
|
5703
5771
|
});
|
|
5704
5772
|
}
|
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-
|
|
3
|
+
import { applyAddons, communityAddonIds, createWorkspace, formatFiles, getAddonDetails, getCommunityAddon, getHighlighter, isVersionUnsupportedBelow, officialAddons, setupAddons } from "./addons-C1BtYuVp.js";
|
|
4
4
|
import { createRequire } from "module";
|
|
5
5
|
import fs, { existsSync } from "node:fs";
|
|
6
6
|
import path, { dirname, join } from "node:path";
|
|
@@ -13,7 +13,7 @@ import { pipeline } from "node:stream/promises";
|
|
|
13
13
|
|
|
14
14
|
//#region packages/cli/package.json
|
|
15
15
|
var name = "sv";
|
|
16
|
-
var version$1 = "0.9.
|
|
16
|
+
var version$1 = "0.9.6";
|
|
17
17
|
var type = "module";
|
|
18
18
|
var description = "A CLI for creating and updating SvelteKit projects";
|
|
19
19
|
var license = "MIT";
|
|
@@ -22247,7 +22247,9 @@ __export(imports_exports, {
|
|
|
22247
22247
|
addDefault: () => addDefault,
|
|
22248
22248
|
addEmpty: () => addEmpty,
|
|
22249
22249
|
addNamed: () => addNamed,
|
|
22250
|
-
addNamespace: () => addNamespace
|
|
22250
|
+
addNamespace: () => addNamespace,
|
|
22251
|
+
find: () => find,
|
|
22252
|
+
remove: () => remove
|
|
22251
22253
|
});
|
|
22252
22254
|
function addEmpty(node, options$1) {
|
|
22253
22255
|
const expectedImportDeclaration = {
|
|
@@ -22344,6 +22346,42 @@ function addImportIfNecessary(node, expectedImportDeclaration) {
|
|
|
22344
22346
|
const importDeclaration = importDeclarations.find((item) => areNodesEqual(item, expectedImportDeclaration));
|
|
22345
22347
|
if (!importDeclaration) node.body.unshift(expectedImportDeclaration);
|
|
22346
22348
|
}
|
|
22349
|
+
function find(ast, options$1) {
|
|
22350
|
+
let alias = options$1.name;
|
|
22351
|
+
let statement;
|
|
22352
|
+
walk(ast, null, { ImportDeclaration(node) {
|
|
22353
|
+
if (node.specifiers && node.source.value === options$1.from) {
|
|
22354
|
+
const specifier = node.specifiers.find((sp) => sp.type === "ImportSpecifier" && sp.imported.type === "Identifier" && sp.imported.name === options$1.name);
|
|
22355
|
+
if (specifier) {
|
|
22356
|
+
statement = node;
|
|
22357
|
+
alias = specifier.local?.name ?? alias;
|
|
22358
|
+
return;
|
|
22359
|
+
}
|
|
22360
|
+
}
|
|
22361
|
+
} });
|
|
22362
|
+
if (statement) return {
|
|
22363
|
+
statement,
|
|
22364
|
+
alias
|
|
22365
|
+
};
|
|
22366
|
+
return {
|
|
22367
|
+
statement: undefined,
|
|
22368
|
+
alias: undefined
|
|
22369
|
+
};
|
|
22370
|
+
}
|
|
22371
|
+
function remove(ast, options$1) {
|
|
22372
|
+
const statement = options$1.statement ?? find(ast, {
|
|
22373
|
+
name: options$1.name,
|
|
22374
|
+
from: options$1.from
|
|
22375
|
+
}).statement;
|
|
22376
|
+
if (!statement) return;
|
|
22377
|
+
if (statement.specifiers?.length === 1) {
|
|
22378
|
+
const idxToRemove = ast.body.indexOf(statement);
|
|
22379
|
+
ast.body.splice(idxToRemove, 1);
|
|
22380
|
+
} else {
|
|
22381
|
+
const idxToRemove = statement.specifiers?.findIndex((s) => s.type === "ImportSpecifier" && s.imported.type === "Identifier" && s.imported.name === options$1.name);
|
|
22382
|
+
if (idxToRemove !== undefined && idxToRemove !== -1) statement.specifiers?.splice(idxToRemove, 1);
|
|
22383
|
+
}
|
|
22384
|
+
}
|
|
22347
22385
|
var variables_exports = {};
|
|
22348
22386
|
__export(variables_exports, {
|
|
22349
22387
|
createIdentifier: () => createIdentifier,
|
|
@@ -22407,7 +22445,8 @@ function createDefault(node, options$1) {
|
|
|
22407
22445
|
node.body.push(exportNode);
|
|
22408
22446
|
return {
|
|
22409
22447
|
astNode: exportNode,
|
|
22410
|
-
value: options$1.fallback
|
|
22448
|
+
value: options$1.fallback,
|
|
22449
|
+
isFallback: true
|
|
22411
22450
|
};
|
|
22412
22451
|
}
|
|
22413
22452
|
const exportDefaultDeclaration = existingNode;
|
|
@@ -22425,13 +22464,15 @@ function createDefault(node, options$1) {
|
|
|
22425
22464
|
const value = variableDeclarator.init;
|
|
22426
22465
|
return {
|
|
22427
22466
|
astNode: exportDefaultDeclaration,
|
|
22428
|
-
value
|
|
22467
|
+
value,
|
|
22468
|
+
isFallback: false
|
|
22429
22469
|
};
|
|
22430
22470
|
}
|
|
22431
22471
|
const declaration$1 = exportDefaultDeclaration.declaration;
|
|
22432
22472
|
return {
|
|
22433
22473
|
astNode: exportDefaultDeclaration,
|
|
22434
|
-
value: declaration$1
|
|
22474
|
+
value: declaration$1,
|
|
22475
|
+
isFallback: false
|
|
22435
22476
|
};
|
|
22436
22477
|
}
|
|
22437
22478
|
function createNamed(node, options$1) {
|
|
@@ -22636,20 +22677,35 @@ function isFunctionDeclaration(node, funcName) {
|
|
|
22636
22677
|
return node.type === "FunctionDeclaration" && node.id?.name === funcName;
|
|
22637
22678
|
}
|
|
22638
22679
|
var vite_exports = {};
|
|
22639
|
-
__export(vite_exports, {
|
|
22640
|
-
|
|
22680
|
+
__export(vite_exports, {
|
|
22681
|
+
addPlugin: () => addPlugin,
|
|
22682
|
+
getConfig: () => getConfig
|
|
22683
|
+
});
|
|
22684
|
+
function isConfigWrapper(callExpression, knownWrappers) {
|
|
22685
|
+
if (callExpression.callee.type !== "Identifier") return false;
|
|
22686
|
+
const calleeName = callExpression.callee.name;
|
|
22687
|
+
if (knownWrappers.includes(calleeName)) return true;
|
|
22688
|
+
const isObjectCall = callExpression.arguments.length === 1 && callExpression.arguments[0]?.type === "ObjectExpression";
|
|
22689
|
+
return knownWrappers.includes(calleeName) || isObjectCall;
|
|
22690
|
+
}
|
|
22691
|
+
function exportDefaultConfig(ast, options$1) {
|
|
22641
22692
|
const { fallback, ignoreWrapper } = options$1;
|
|
22642
22693
|
let fallbackExpression;
|
|
22643
|
-
if (fallback) fallbackExpression = typeof fallback === "string" ? parseExpression(fallback) : fallback;
|
|
22694
|
+
if (fallback) fallbackExpression = typeof fallback.code === "string" ? parseExpression(fallback.code) : fallback.code;
|
|
22644
22695
|
else fallbackExpression = create$2({});
|
|
22645
|
-
const { value } = createDefault(ast, { fallback: fallbackExpression });
|
|
22696
|
+
const { value, isFallback } = createDefault(ast, { fallback: fallbackExpression });
|
|
22697
|
+
if (isFallback) options$1.fallback?.additional?.(ast);
|
|
22646
22698
|
const rootObject = value.type === "TSSatisfiesExpression" ? value.expression : value;
|
|
22647
22699
|
let configObject;
|
|
22648
|
-
if (!
|
|
22700
|
+
if (!("arguments" in rootObject) || !Array.isArray(rootObject.arguments)) {
|
|
22701
|
+
configObject = rootObject;
|
|
22702
|
+
return configObject;
|
|
22703
|
+
}
|
|
22704
|
+
if (rootObject.type !== "CallExpression" || rootObject.callee.type !== "Identifier") {
|
|
22649
22705
|
configObject = rootObject;
|
|
22650
22706
|
return configObject;
|
|
22651
22707
|
}
|
|
22652
|
-
if (rootObject
|
|
22708
|
+
if (!isConfigWrapper(rootObject, ignoreWrapper)) {
|
|
22653
22709
|
configObject = rootObject;
|
|
22654
22710
|
return configObject;
|
|
22655
22711
|
}
|
|
@@ -22691,19 +22747,24 @@ function addInArrayOfObject(ast, options$1) {
|
|
|
22691
22747
|
else append(targetArray, expression);
|
|
22692
22748
|
}
|
|
22693
22749
|
const addPlugin = (ast, options$1) => {
|
|
22694
|
-
|
|
22695
|
-
from: "vite",
|
|
22696
|
-
imports: { defineConfig: "defineConfig" }
|
|
22697
|
-
});
|
|
22698
|
-
const configObject = exportDefaultConfig(ast, {
|
|
22699
|
-
fallback: "defineConfig()",
|
|
22700
|
-
ignoreWrapper: "defineConfig"
|
|
22701
|
-
});
|
|
22750
|
+
const configObject = getConfig(ast);
|
|
22702
22751
|
addInArrayOfObject(configObject, {
|
|
22703
22752
|
arrayProperty: "plugins",
|
|
22704
22753
|
...options$1
|
|
22705
22754
|
});
|
|
22706
22755
|
};
|
|
22756
|
+
const getConfig = (ast) => {
|
|
22757
|
+
return exportDefaultConfig(ast, {
|
|
22758
|
+
fallback: {
|
|
22759
|
+
code: "defineConfig()",
|
|
22760
|
+
additional: (ast$1) => addNamed(ast$1, {
|
|
22761
|
+
imports: ["defineConfig"],
|
|
22762
|
+
from: "vite"
|
|
22763
|
+
})
|
|
22764
|
+
},
|
|
22765
|
+
ignoreWrapper: ["defineConfig"]
|
|
22766
|
+
});
|
|
22767
|
+
};
|
|
22707
22768
|
var BitSet = class BitSet$1 {
|
|
22708
22769
|
constructor(arg) {
|
|
22709
22770
|
this.bits = arg instanceof BitSet$1 ? arg.bits.slice() : [];
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sv",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A CLI for creating and updating SvelteKit projects",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"ps-tree": "^1.2.0",
|
|
37
37
|
"tinyexec": "^0.3.2",
|
|
38
38
|
"valibot": "^0.41.0",
|
|
39
|
-
"@sveltejs/addons": "0.0.0",
|
|
40
39
|
"@sveltejs/create": "0.0.0",
|
|
41
|
-
"@sveltejs/cli-core": "0.0.0"
|
|
40
|
+
"@sveltejs/cli-core": "0.0.0",
|
|
41
|
+
"@sveltejs/addons": "0.0.0"
|
|
42
42
|
},
|
|
43
43
|
"keywords": [
|
|
44
44
|
"create",
|