sv 0.12.4 → 0.12.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/bin.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { f as program, l as from, r as detectPackageManager, u as Command } from "./package-manager-BYzDyeam.mjs";
|
|
3
|
-
import { a as helpConfig, i as forwardExitCode, n as add, o as name, r as create, s as version } from "./engine-
|
|
3
|
+
import { a as helpConfig, i as forwardExitCode, n as add, o as name, r as create, s as version } from "./engine-BhL6exbo.mjs";
|
|
4
4
|
import { color, resolveCommand } from "@sveltejs/sv-utils";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
import { execSync } from "node:child_process";
|
|
@@ -685,12 +685,11 @@ function addEslintConfigPrettier(content) {
|
|
|
685
685
|
if (eslintConfig.type !== "ArrayExpression" && eslintConfig.type !== "CallExpression") return content;
|
|
686
686
|
const prettier = js.common.parseExpression("prettier");
|
|
687
687
|
const sveltePrettierConfig = js.common.parseExpression(`${svelteImportName}.configs.prettier`);
|
|
688
|
-
const configSpread = js.common.createSpread(sveltePrettierConfig);
|
|
689
688
|
const nodesToInsert = [];
|
|
690
689
|
if (!js.common.contains(eslintConfig, prettier)) nodesToInsert.push(prettier);
|
|
691
|
-
if (!js.common.contains(eslintConfig,
|
|
690
|
+
if (!js.common.contains(eslintConfig, sveltePrettierConfig)) nodesToInsert.push(sveltePrettierConfig);
|
|
692
691
|
const elements = eslintConfig.type === "ArrayExpression" ? eslintConfig.elements : eslintConfig.arguments;
|
|
693
|
-
const idx = elements.findIndex((el) => el?.type === "
|
|
692
|
+
const idx = elements.findIndex((el) => el?.type === "MemberExpression" && el.object.type === "MemberExpression" && el.object.property.type === "Identifier" && el.object.property.name === "configs" && el.object.object.type === "Identifier" && el.object.object.name === svelteImportName);
|
|
694
693
|
if (idx !== -1) elements.splice(idx + 1, 0, ...nodesToInsert);
|
|
695
694
|
else elements.push(...nodesToInsert);
|
|
696
695
|
return generateCode();
|
|
@@ -759,8 +758,8 @@ var better_auth_default = defineAddon({
|
|
|
759
758
|
const demoGithub = options$8.demo.includes("github");
|
|
760
759
|
const hasDemo = demoPassword || demoGithub;
|
|
761
760
|
let drizzleDialect;
|
|
762
|
-
sv.devDependency("better-auth", "
|
|
763
|
-
sv.devDependency("@better-auth/cli", "
|
|
761
|
+
sv.devDependency("better-auth", "~1.4.21");
|
|
762
|
+
sv.devDependency("@better-auth/cli", "~1.4.21");
|
|
764
763
|
sv.file(`drizzle.config.${language}`, (content) => {
|
|
765
764
|
const { ast, generateCode } = parse.script(content);
|
|
766
765
|
const isProp = (name$1, node) => node.key.type === "Identifier" && node.key.name === name$1;
|
|
@@ -1605,10 +1604,10 @@ var eslint_default = defineAddon({
|
|
|
1605
1604
|
eslintConfigs.push(jsConfig);
|
|
1606
1605
|
if (typescript) {
|
|
1607
1606
|
const tsConfig = js.common.parseExpression("ts.configs.recommended");
|
|
1608
|
-
eslintConfigs.push(
|
|
1607
|
+
eslintConfigs.push(tsConfig);
|
|
1609
1608
|
}
|
|
1610
1609
|
const svelteConfig = js.common.parseExpression("svelte.configs.recommended");
|
|
1611
|
-
eslintConfigs.push(
|
|
1610
|
+
eslintConfigs.push(svelteConfig);
|
|
1612
1611
|
const globalsBrowser = js.common.createSpread(js.common.parseExpression("globals.browser"));
|
|
1613
1612
|
const globalsNode = js.common.createSpread(js.common.parseExpression("globals.node"));
|
|
1614
1613
|
const globalsObjLiteral = js.object.create({});
|
|
@@ -1650,25 +1649,21 @@ var eslint_default = defineAddon({
|
|
|
1650
1649
|
});
|
|
1651
1650
|
eslintConfigs.push(svelteTSParserConfig);
|
|
1652
1651
|
}
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
tsConfigCall.arguments.push(...eslintConfigs);
|
|
1660
|
-
exportExpression = tsConfigCall;
|
|
1661
|
-
} else {
|
|
1652
|
+
const exportExpression = js.functions.createCall({
|
|
1653
|
+
name: "defineConfig",
|
|
1654
|
+
args: []
|
|
1655
|
+
});
|
|
1656
|
+
if (typescript) exportExpression.arguments.push(...eslintConfigs);
|
|
1657
|
+
else {
|
|
1662
1658
|
const eslintArray = js.array.create();
|
|
1663
1659
|
eslintConfigs.map((x) => js.array.append(eslintArray, x));
|
|
1664
|
-
exportExpression
|
|
1660
|
+
exportExpression.arguments.push(eslintArray);
|
|
1665
1661
|
}
|
|
1666
|
-
const { value: defaultExport
|
|
1662
|
+
const { value: defaultExport } = js.exports.createDefault(ast, { fallback: exportExpression });
|
|
1667
1663
|
if (defaultExport !== exportExpression) {
|
|
1668
1664
|
R.warn("An eslint config is already defined. Skipping initialization.");
|
|
1669
1665
|
return content;
|
|
1670
1666
|
}
|
|
1671
|
-
if (!typescript) js.common.addJsDocTypeComment(astNode, comments, { type: "import('eslint').Linter.Config[]" });
|
|
1672
1667
|
if (typescript) js.imports.addDefault(ast, {
|
|
1673
1668
|
from: "typescript-eslint",
|
|
1674
1669
|
as: "ts"
|
|
@@ -1677,7 +1672,7 @@ var eslint_default = defineAddon({
|
|
|
1677
1672
|
from: "globals",
|
|
1678
1673
|
as: "globals"
|
|
1679
1674
|
});
|
|
1680
|
-
|
|
1675
|
+
js.imports.addNamed(ast, {
|
|
1681
1676
|
from: "eslint/config",
|
|
1682
1677
|
imports: ["defineConfig"]
|
|
1683
1678
|
});
|
|
@@ -1800,9 +1795,13 @@ var mcp_default = defineAddon({
|
|
|
1800
1795
|
},
|
|
1801
1796
|
opencode: {
|
|
1802
1797
|
agentPath: "AGENTS.md",
|
|
1803
|
-
configPath: "opencode.json",
|
|
1798
|
+
configPath: ".opencode/opencode.json",
|
|
1804
1799
|
schema: "https://opencode.ai/config.json",
|
|
1805
|
-
customData: { plugin: ["@sveltejs/opencode"] }
|
|
1800
|
+
customData: { plugin: ["@sveltejs/opencode"] },
|
|
1801
|
+
extraFiles: [{
|
|
1802
|
+
path: ".opencode/svelte.json",
|
|
1803
|
+
data: { $schema: "https://svelte.dev/opencode/schema.json" }
|
|
1804
|
+
}]
|
|
1806
1805
|
},
|
|
1807
1806
|
vscode: {
|
|
1808
1807
|
agentPath: "AGENTS.md",
|
|
@@ -1818,7 +1817,7 @@ var mcp_default = defineAddon({
|
|
|
1818
1817
|
const value = configurator[ide];
|
|
1819
1818
|
if (value === void 0) continue;
|
|
1820
1819
|
if ("other" in value) continue;
|
|
1821
|
-
const { mcpOptions, agentPath, configPath, schema, customData } = value;
|
|
1820
|
+
const { mcpOptions, agentPath, configPath, schema, customData, extraFiles } = value;
|
|
1822
1821
|
if (!filesAdded.includes(agentPath)) sv.file(agentPath, (content) => {
|
|
1823
1822
|
if (content) {
|
|
1824
1823
|
filesExistingAlready.push(agentPath);
|
|
@@ -1838,6 +1837,11 @@ var mcp_default = defineAddon({
|
|
|
1838
1837
|
}
|
|
1839
1838
|
return generateCode();
|
|
1840
1839
|
});
|
|
1840
|
+
if (extraFiles) for (const extra of extraFiles) sv.file(extra.path, (content) => {
|
|
1841
|
+
const { data, generateCode } = parse.json(content);
|
|
1842
|
+
for (const [key, value$1] of Object.entries(extra.data)) data[key] = value$1;
|
|
1843
|
+
return generateCode();
|
|
1844
|
+
});
|
|
1841
1845
|
}
|
|
1842
1846
|
if (filesExistingAlready.length > 0) R.warn(`${filesExistingAlready.map((path$2) => color.path(path$2)).join(", ")} already exists, we didn't touch ${filesExistingAlready.length > 1 ? "them" : "it"}. See ${color.website("https://svelte.dev/docs/mcp/overview#Usage")} for manual setup.`);
|
|
1843
1847
|
},
|
|
@@ -2084,7 +2088,7 @@ var playwright_default = defineAddon({
|
|
|
2084
2088
|
shortDescription: "browser testing",
|
|
2085
2089
|
homepage: "https://playwright.dev",
|
|
2086
2090
|
options: {},
|
|
2087
|
-
run: ({ sv, language, files }) => {
|
|
2091
|
+
run: ({ sv, language, files, kit }) => {
|
|
2088
2092
|
sv.devDependency("@playwright/test", "^1.58.2");
|
|
2089
2093
|
sv.file(files.package, (content) => {
|
|
2090
2094
|
const { data, generateCode } = parse.json(content);
|
|
@@ -2096,13 +2100,26 @@ var playwright_default = defineAddon({
|
|
|
2096
2100
|
if (!content) return content;
|
|
2097
2101
|
return text.upsert(content, "test-results", { comment: "Playwright" });
|
|
2098
2102
|
});
|
|
2099
|
-
|
|
2103
|
+
const testDir = kit ? `${kit.routesDirectory}/demo/playwright` : "src";
|
|
2104
|
+
const testRoute = kit ? "/demo/playwright" : "/";
|
|
2105
|
+
if (kit) {
|
|
2106
|
+
sv.file(`${kit.routesDirectory}/demo/+page.svelte`, (content) => {
|
|
2107
|
+
return addToDemoPage(content, "playwright", language);
|
|
2108
|
+
});
|
|
2109
|
+
sv.file(`${testDir}/+page.svelte`, (content) => {
|
|
2110
|
+
if (content) return content;
|
|
2111
|
+
return dedent`
|
|
2112
|
+
<h1>Playwright e2e test demo</h1>
|
|
2113
|
+
`;
|
|
2114
|
+
});
|
|
2115
|
+
}
|
|
2116
|
+
sv.file(`${testDir}/${kit ? "page" : "app"}.svelte.e2e.${language}`, (content) => {
|
|
2100
2117
|
if (content) return content;
|
|
2101
2118
|
return dedent`
|
|
2102
2119
|
import { expect, test } from '@playwright/test';
|
|
2103
2120
|
|
|
2104
|
-
test('
|
|
2105
|
-
await page.goto('
|
|
2121
|
+
test('has expected h1', async ({ page }) => {
|
|
2122
|
+
await page.goto('${testRoute}');
|
|
2106
2123
|
await expect(page.locator('h1')).toBeVisible();
|
|
2107
2124
|
});
|
|
2108
2125
|
`;
|
|
@@ -2116,7 +2133,7 @@ var playwright_default = defineAddon({
|
|
|
2116
2133
|
command: "npm run build && npm run preview",
|
|
2117
2134
|
port: 4173
|
|
2118
2135
|
},
|
|
2119
|
-
|
|
2136
|
+
testMatch: "**/*.e2e.{ts,js}"
|
|
2120
2137
|
};
|
|
2121
2138
|
if (defaultExport.type === "CallExpression" && defaultExport.arguments[0]?.type === "ObjectExpression") {
|
|
2122
2139
|
js.imports.addNamed(ast, {
|
|
@@ -2128,6 +2145,13 @@ var playwright_default = defineAddon({
|
|
|
2128
2145
|
else R.warn("Unexpected playwright config for playwright add-on. Could not update.");
|
|
2129
2146
|
return generateCode();
|
|
2130
2147
|
});
|
|
2148
|
+
},
|
|
2149
|
+
nextSteps: ({ kit }) => {
|
|
2150
|
+
const steps = [];
|
|
2151
|
+
steps.push(`Run ${color.command("npx playwright install")} to download browsers`);
|
|
2152
|
+
if (kit) steps.push(`Visit ${color.route("/demo/playwright")} to see the demo page`);
|
|
2153
|
+
steps.push(`Run ${color.command("npm run test:e2e")} to execute the example tests`);
|
|
2154
|
+
return steps;
|
|
2131
2155
|
}
|
|
2132
2156
|
});
|
|
2133
2157
|
|
|
@@ -2558,37 +2582,60 @@ var vitest_addon_default = defineAddon({
|
|
|
2558
2582
|
json.packageScriptsUpsert(data, "test", "npm run test:unit -- --run", { mode: "prepend" });
|
|
2559
2583
|
return generateCode();
|
|
2560
2584
|
});
|
|
2561
|
-
|
|
2585
|
+
const examplesDir = (kit ? kit.libDirectory : "src/lib") + "/vitest-examples";
|
|
2586
|
+
const typed = language === "ts";
|
|
2587
|
+
if (unitTesting || componentTesting) sv.file(`${examplesDir}/greet.${language}`, (content) => {
|
|
2588
|
+
if (content) return content;
|
|
2589
|
+
return dedent`
|
|
2590
|
+
export function greet(${typed ? "name: string" : "name"})${typed ? ": string" : ""} {
|
|
2591
|
+
return 'Hello, ' + name + '!';
|
|
2592
|
+
}
|
|
2593
|
+
`;
|
|
2594
|
+
});
|
|
2595
|
+
if (unitTesting) sv.file(`${examplesDir}/greet.spec.${language}`, (content) => {
|
|
2562
2596
|
if (content) return content;
|
|
2563
2597
|
return dedent`
|
|
2564
2598
|
import { describe, it, expect } from 'vitest';
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2599
|
+
import { greet } from './greet';
|
|
2600
|
+
|
|
2601
|
+
describe('greet', () => {
|
|
2602
|
+
it('returns a greeting', () => {
|
|
2603
|
+
expect(greet('Svelte')).toBe('Hello, Svelte!');
|
|
2569
2604
|
});
|
|
2570
2605
|
});
|
|
2571
2606
|
`;
|
|
2572
2607
|
});
|
|
2573
2608
|
if (componentTesting) {
|
|
2574
|
-
|
|
2575
|
-
sv.file(fileName, (content) => {
|
|
2609
|
+
sv.file(`${examplesDir}/Welcome.svelte`, (content) => {
|
|
2576
2610
|
if (content) return content;
|
|
2577
2611
|
return dedent`
|
|
2578
|
-
|
|
2579
|
-
import {
|
|
2580
|
-
import { render } from 'vitest-browser-svelte';
|
|
2581
|
-
${kit ? "import Page from './+page.svelte';" : "import App from './App.svelte';"}
|
|
2612
|
+
<script>
|
|
2613
|
+
import { greet } from './greet';
|
|
2582
2614
|
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2615
|
+
let { host = 'SvelteKit', guest = 'Vitest' } = $props();
|
|
2616
|
+
<\/script>
|
|
2617
|
+
|
|
2618
|
+
<h1>{greet(host)}</h1>
|
|
2619
|
+
<p>{greet(guest)}</p>
|
|
2620
|
+
`;
|
|
2621
|
+
});
|
|
2622
|
+
sv.file(`${examplesDir}/Welcome.svelte.spec.${language}`, (content) => {
|
|
2623
|
+
if (content) return content;
|
|
2624
|
+
return dedent`
|
|
2625
|
+
import { page } from 'vitest/browser';
|
|
2626
|
+
import { describe, expect, it } from 'vitest';
|
|
2627
|
+
import { render } from 'vitest-browser-svelte';
|
|
2628
|
+
import Welcome from './Welcome.svelte';
|
|
2629
|
+
|
|
2630
|
+
describe('Welcome.svelte', () => {
|
|
2631
|
+
it('renders greetings for host and guest', async () => {
|
|
2632
|
+
render(Welcome, { host: 'SvelteKit', guest: 'Vitest' });
|
|
2633
|
+
|
|
2634
|
+
await expect.element(page.getByRole('heading', { level: 1 })).toHaveTextContent('Hello, SvelteKit!');
|
|
2635
|
+
await expect.element(page.getByText('Hello, Vitest!')).toBeInTheDocument();
|
|
2590
2636
|
});
|
|
2591
|
-
|
|
2637
|
+
});
|
|
2638
|
+
`;
|
|
2592
2639
|
});
|
|
2593
2640
|
}
|
|
2594
2641
|
sv.file(files.viteConfig, (content) => {
|
|
@@ -2695,7 +2742,7 @@ function getAddonDetails(id) {
|
|
|
2695
2742
|
//#endregion
|
|
2696
2743
|
//#region package.json
|
|
2697
2744
|
var name = "sv";
|
|
2698
|
-
var version = "0.12.
|
|
2745
|
+
var version = "0.12.6";
|
|
2699
2746
|
|
|
2700
2747
|
//#endregion
|
|
2701
2748
|
//#region src/core/errors.ts
|
package/dist/shared.json
CHANGED
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"typescript"
|
|
85
85
|
],
|
|
86
86
|
"exclude": [],
|
|
87
|
-
"contents": "import adapter from '@sveltejs/adapter-auto';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\t// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.\n\t\t// If your environment is not supported, or you settled on a specific environment, switch out the adapter.\n\t\t// See https://svelte.dev/docs/kit/adapters for more information about adapters.\n\t\tadapter: adapter()\n\t}\n};\n\nexport default config;\n"
|
|
87
|
+
"contents": "import adapter from '@sveltejs/adapter-auto';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\t// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.\n\t\t// If your environment is not supported, or you settled on a specific environment, switch out the adapter.\n\t\t// See https://svelte.dev/docs/kit/adapters for more information about adapters.\n\t\tadapter: adapter()\n\t},\n\tvitePlugin: {\n\t\tdynamicCompileOptions: ({ filename }) => ({ runes: !filename.includes('node_modules') })\n\t}\n};\n\nexport default config;\n"
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
90
|
"name": "tsconfig.json",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"exclude": [
|
|
101
101
|
"typescript"
|
|
102
102
|
],
|
|
103
|
-
"contents": "import adapter from '@sveltejs/adapter-auto';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\t// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.\n\t\t// If your environment is not supported, or you settled on a specific environment, switch out the adapter.\n\t\t// See https://svelte.dev/docs/kit/adapters for more information about adapters.\n\t\tadapter: adapter()\n\t}\n};\n\nexport default config;\n"
|
|
103
|
+
"contents": "import adapter from '@sveltejs/adapter-auto';\n\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n\tkit: {\n\t\t// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.\n\t\t// If your environment is not supported, or you settled on a specific environment, switch out the adapter.\n\t\t// See https://svelte.dev/docs/kit/adapters for more information about adapters.\n\t\tadapter: adapter()\n\t},\n\tvitePlugin: {\n\t\tdynamicCompileOptions: ({ filename }) => ({ runes: !filename.includes('node_modules') })\n\t}\n};\n\nexport default config;\n"
|
|
104
104
|
},
|
|
105
105
|
{
|
|
106
106
|
"name": "vite.config.ts",
|
package/dist/src/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { p as create } from "../package-manager-BYzDyeam.mjs";
|
|
2
|
-
import { c as officialAddons, l as defineAddon, t as add, u as defineAddonOptions } from "../engine-
|
|
2
|
+
import { c as officialAddons, l as defineAddon, t as add, u as defineAddonOptions } from "../engine-BhL6exbo.mjs";
|
|
3
3
|
|
|
4
4
|
export { add, create, defineAddon, defineAddonOptions, officialAddons };
|