From f5ce27b8cb1adf78ab275528660f14d22f763d2c Mon Sep 17 00:00:00 2001 From: Scott Wu Date: Sat, 22 Nov 2025 22:06:52 +0800 Subject: [PATCH 01/17] fix typo --- packages/cli/commands/add/workspace.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cli/commands/add/workspace.ts b/packages/cli/commands/add/workspace.ts index b00d13c2..a4d0835f 100644 --- a/packages/cli/commands/add/workspace.ts +++ b/packages/cli/commands/add/workspace.ts @@ -28,8 +28,8 @@ export async function createWorkspace({ const viteConfig = fs.existsSync(viteConfigPath) ? commonFilePaths.viteConfigTS : commonFilePaths.viteConfig; - const sveteConfigPath = path.join(resolvedCwd, commonFilePaths.svelteConfigTS); - const svelteConfig = fs.existsSync(sveteConfigPath) + const svelteConfigPath = path.join(resolvedCwd, commonFilePaths.svelteConfigTS); + const svelteConfig = fs.existsSync(svelteConfigPath) ? commonFilePaths.svelteConfigTS : commonFilePaths.svelteConfig; From 63399b4d4e0c9a10e733ed27c04efe8c02fd246e Mon Sep 17 00:00:00 2001 From: Scott Wu Date: Sat, 22 Nov 2025 22:51:36 +0800 Subject: [PATCH 02/17] initial attempt --- packages/cli/commands/add/workspace.ts | 7 ++++++- packages/cli/commands/create.ts | 8 -------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/cli/commands/add/workspace.ts b/packages/cli/commands/add/workspace.ts index a4d0835f..c3d41a91 100644 --- a/packages/cli/commands/add/workspace.ts +++ b/packages/cli/commands/add/workspace.ts @@ -59,7 +59,12 @@ export async function createWorkspace({ dependencies[key] = value.replaceAll(/[^\d|.]/g, ''); } - const kit = dependencies['@sveltejs/kit'] ? parseKitOptions(resolvedCwd) : undefined; + // dependencies['@sveltejs/kit'] is always undefined + const kit = dependencies['@sveltejs/kit'] ? parseKitOptions(resolvedCwd) : { + routesDirectory: 'src/routes', + libDirectory: 'src/lib' + }; + const stylesheet: `${string}/layout.css` | 'src/app.css' = kit ? `${kit.routesDirectory}/layout.css` : 'src/app.css'; diff --git a/packages/cli/commands/create.ts b/packages/cli/commands/create.ts index ddf6e3ba..7ecb3110 100644 --- a/packages/cli/commands/create.ts +++ b/packages/cli/commands/create.ts @@ -359,7 +359,6 @@ interface CreateVirtualWorkspaceOptions { export async function createVirtualWorkspace({ cwd, - template, packageManager, type }: CreateVirtualWorkspaceOptions): Promise { @@ -373,16 +372,9 @@ export async function createVirtualWorkspace({ svelteConfig: type === 'typescript' ? commonFilePaths.svelteConfigTS : commonFilePaths.svelteConfig }, - kit: undefined, dependencyVersion: () => undefined }; - if (template === 'minimal' || template === 'demo' || template === 'library') { - virtualWorkspace.kit = { - routesDirectory: 'src/routes', - libDirectory: 'src/lib' - }; - } return virtualWorkspace; } From 9c45643f552279a143dc3f669723b731ba1f849c Mon Sep 17 00:00:00 2001 From: Scott Wu Date: Sat, 22 Nov 2025 22:58:51 +0800 Subject: [PATCH 03/17] reuse stylesheet variable --- packages/addons/prettier/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/addons/prettier/index.ts b/packages/addons/prettier/index.ts index 813345c0..39de2119 100644 --- a/packages/addons/prettier/index.ts +++ b/packages/addons/prettier/index.ts @@ -7,7 +7,7 @@ export default defineAddon({ shortDescription: 'formatter', homepage: 'https://prettier.io', options: {}, - run: ({ sv, dependencyVersion, kit, files }) => { + run: ({ sv, dependencyVersion, files }) => { const tailwindcssInstalled = Boolean(dependencyVersion('tailwindcss')); if (tailwindcssInstalled) sv.devDependency('prettier-plugin-tailwindcss', '^0.7.1'); @@ -53,7 +53,7 @@ export default defineAddon({ if (!plugins.includes('prettier-plugin-tailwindcss')) { data.plugins.unshift('prettier-plugin-tailwindcss'); } - data.tailwindStylesheet ??= kit ? `${kit?.routesDirectory}/layout.css` : './src/app.css'; + data.tailwindStylesheet ??= files.getRelative({ to: files.stylesheet }); } if (!plugins.includes('prettier-plugin-svelte')) { data.plugins.unshift('prettier-plugin-svelte'); From ba437a829cea5014641b22dc77d4c226a3eae4aa Mon Sep 17 00:00:00 2001 From: Scott Wu Date: Sat, 22 Nov 2025 23:06:04 +0800 Subject: [PATCH 04/17] cleanup --- packages/cli/commands/add/workspace.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/cli/commands/add/workspace.ts b/packages/cli/commands/add/workspace.ts index c3d41a91..861056df 100644 --- a/packages/cli/commands/add/workspace.ts +++ b/packages/cli/commands/add/workspace.ts @@ -59,15 +59,10 @@ export async function createWorkspace({ dependencies[key] = value.replaceAll(/[^\d|.]/g, ''); } - // dependencies['@sveltejs/kit'] is always undefined const kit = dependencies['@sveltejs/kit'] ? parseKitOptions(resolvedCwd) : { routesDirectory: 'src/routes', libDirectory: 'src/lib' }; - - const stylesheet: `${string}/layout.css` | 'src/app.css' = kit - ? `${kit.routesDirectory}/layout.css` - : 'src/app.css'; return { cwd: resolvedCwd, @@ -76,7 +71,7 @@ export async function createWorkspace({ files: { viteConfig, svelteConfig, - stylesheet, + stylesheet: kit ? `${kit.routesDirectory}/layout.css` : 'src/app.css', package: 'package.json', gitignore: '.gitignore', prettierignore: '.prettierignore', From 2d6922913f0c8a5152bfedee2aca71c59036f578 Mon Sep 17 00:00:00 2001 From: Scott Wu Date: Sat, 22 Nov 2025 23:06:20 +0800 Subject: [PATCH 05/17] lint --- packages/cli/commands/add/workspace.ts | 10 ++++++---- packages/cli/commands/create.ts | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/cli/commands/add/workspace.ts b/packages/cli/commands/add/workspace.ts index 861056df..c04e8479 100644 --- a/packages/cli/commands/add/workspace.ts +++ b/packages/cli/commands/add/workspace.ts @@ -59,10 +59,12 @@ export async function createWorkspace({ dependencies[key] = value.replaceAll(/[^\d|.]/g, ''); } - const kit = dependencies['@sveltejs/kit'] ? parseKitOptions(resolvedCwd) : { - routesDirectory: 'src/routes', - libDirectory: 'src/lib' - }; + const kit = dependencies['@sveltejs/kit'] + ? parseKitOptions(resolvedCwd) + : { + routesDirectory: 'src/routes', + libDirectory: 'src/lib' + }; return { cwd: resolvedCwd, diff --git a/packages/cli/commands/create.ts b/packages/cli/commands/create.ts index 7ecb3110..15085498 100644 --- a/packages/cli/commands/create.ts +++ b/packages/cli/commands/create.ts @@ -375,6 +375,5 @@ export async function createVirtualWorkspace({ dependencyVersion: () => undefined }; - return virtualWorkspace; } From e41cf949c92e7c17b8e39e0251f95703335d426c Mon Sep 17 00:00:00 2001 From: Scott Wu Date: Sun, 23 Nov 2025 01:43:36 +0800 Subject: [PATCH 06/17] rerun test From 5b760cd3af9f8e7c860484a83e249d1b0932fe29 Mon Sep 17 00:00:00 2001 From: Scott Wu Date: Sun, 23 Nov 2025 01:54:07 +0800 Subject: [PATCH 07/17] . --- packages/cli/commands/create.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/cli/commands/create.ts b/packages/cli/commands/create.ts index 15085498..8830fc8f 100644 --- a/packages/cli/commands/create.ts +++ b/packages/cli/commands/create.ts @@ -359,6 +359,7 @@ interface CreateVirtualWorkspaceOptions { export async function createVirtualWorkspace({ cwd, + template, packageManager, type }: CreateVirtualWorkspaceOptions): Promise { @@ -372,8 +373,16 @@ export async function createVirtualWorkspace({ svelteConfig: type === 'typescript' ? commonFilePaths.svelteConfigTS : commonFilePaths.svelteConfig }, + kit: undefined, dependencyVersion: () => undefined }; + // check if it is a kit project + if (template === 'minimal' || template === 'demo' || template === 'library') { + virtualWorkspace.kit = { + routesDirectory: 'src/routes', + libDirectory: 'src/lib' + }; + } return virtualWorkspace; } From d0d9cbcd20cb364680539de15630482190009c90 Mon Sep 17 00:00:00 2001 From: Scott Wu Date: Sun, 23 Nov 2025 01:58:18 +0800 Subject: [PATCH 08/17] lint --- packages/cli/commands/create.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/commands/create.ts b/packages/cli/commands/create.ts index 8830fc8f..572d100a 100644 --- a/packages/cli/commands/create.ts +++ b/packages/cli/commands/create.ts @@ -376,7 +376,7 @@ export async function createVirtualWorkspace({ kit: undefined, dependencyVersion: () => undefined }; - // check if it is a kit project + // check if it is a kit project if (template === 'minimal' || template === 'demo' || template === 'library') { virtualWorkspace.kit = { routesDirectory: 'src/routes', From 0ec89fa43ba8b7bf246029bd7fbd8358b4081ecc Mon Sep 17 00:00:00 2001 From: jycouet Date: Sat, 22 Nov 2025 21:54:10 +0100 Subject: [PATCH 09/17] option to override for virtual workspace --- packages/cli/commands/add/workspace.ts | 23 +++++++++++++++-------- packages/cli/commands/create.ts | 24 +++++++++++++----------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/packages/cli/commands/add/workspace.ts b/packages/cli/commands/add/workspace.ts index c04e8479..4cb47cb5 100644 --- a/packages/cli/commands/add/workspace.ts +++ b/packages/cli/commands/add/workspace.ts @@ -11,10 +11,14 @@ import { getUserAgent } from '../../utils/package-manager.ts'; type CreateWorkspaceOptions = { cwd: string; packageManager?: PackageManager; + override?: { + kit?: Workspace['kit']; + }; }; export async function createWorkspace({ cwd, - packageManager + packageManager, + override }: CreateWorkspaceOptions): Promise { const resolvedCwd = path.resolve(cwd); @@ -59,12 +63,15 @@ export async function createWorkspace({ dependencies[key] = value.replaceAll(/[^\d|.]/g, ''); } - const kit = dependencies['@sveltejs/kit'] - ? parseKitOptions(resolvedCwd) - : { - routesDirectory: 'src/routes', - libDirectory: 'src/lib' - }; + const kit = override?.kit + ? override.kit + : dependencies['@sveltejs/kit'] + ? parseKitOptions(resolvedCwd) + : undefined; + + const stylesheet: `${string}/layout.css` | 'src/app.css' = kit + ? `${kit.routesDirectory}/layout.css` + : 'src/app.css'; return { cwd: resolvedCwd, @@ -73,7 +80,7 @@ export async function createWorkspace({ files: { viteConfig, svelteConfig, - stylesheet: kit ? `${kit.routesDirectory}/layout.css` : 'src/app.css', + stylesheet, package: 'package.json', gitignore: '.gitignore', prettierignore: '.prettierignore', diff --git a/packages/cli/commands/create.ts b/packages/cli/commands/create.ts index 572d100a..8bb2c31b 100644 --- a/packages/cli/commands/create.ts +++ b/packages/cli/commands/create.ts @@ -363,7 +363,18 @@ export async function createVirtualWorkspace({ packageManager, type }: CreateVirtualWorkspaceOptions): Promise { - const tentativeWorkspace = await createWorkspace({ cwd, packageManager }); + let kit: Workspace['kit'] | undefined = undefined; + + // These are our default project structure so we know that it's a kit project + if (template === 'minimal' || template === 'demo' || template === 'library') { + kit = { + routesDirectory: 'src/routes', + libDirectory: 'src/lib' + }; + } + + const tentativeWorkspace = await createWorkspace({ cwd, packageManager, override: { kit } }); + const virtualWorkspace: Workspace = { ...tentativeWorkspace, typescript: type === 'typescript', @@ -372,17 +383,8 @@ export async function createVirtualWorkspace({ viteConfig: type === 'typescript' ? commonFilePaths.viteConfigTS : commonFilePaths.viteConfig, svelteConfig: type === 'typescript' ? commonFilePaths.svelteConfigTS : commonFilePaths.svelteConfig - }, - kit: undefined, - dependencyVersion: () => undefined + } }; - // check if it is a kit project - if (template === 'minimal' || template === 'demo' || template === 'library') { - virtualWorkspace.kit = { - routesDirectory: 'src/routes', - libDirectory: 'src/lib' - }; - } return virtualWorkspace; } From b35d736ba886a9c5a53996e0ca2e24ea4e7c0a6f Mon Sep 17 00:00:00 2001 From: jycouet Date: Sat, 22 Nov 2025 22:15:00 +0100 Subject: [PATCH 10/17] adding a cli test will all addons --- packages/cli/tests/cli.ts | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/packages/cli/tests/cli.ts b/packages/cli/tests/cli.ts index e93a21c4..156674de 100644 --- a/packages/cli/tests/cli.ts +++ b/packages/cli/tests/cli.ts @@ -16,9 +16,32 @@ beforeAll(() => { }); describe('cli', () => { - it('should be able to create a new project with cli command', async () => { + const testCases = [ + { projectName: 'create-only', args: ['--no-add-ons'] }, + { + projectName: 'create-with-all-addons', + args: [ + '--add', + 'prettier', + 'eslint', + 'vitest=usages:unit,component', + 'playwright', + 'tailwindcss=plugins:typography,forms', + 'sveltekit-adapter=adapter:node', + 'devtools-json', + 'drizzle=database:sqlite+sqlite:libsql', + 'lucia=demo:yes', + 'mdsvex', + 'paraglide=languageTags:en,es+demo:yes', + 'mcp=ide:claude-code,cursor,gemini,opencode,vscode,other+setup:local' + ] + } + ]; + + it.for(testCases)('should create a new project with name $projectName', async (testCase) => { + const { projectName, args } = testCase; const svBinPath = path.resolve(monoRepoPath, 'packages', 'cli', 'dist', 'bin.js'); - const testOutputPath = path.resolve(monoRepoPath, '.test-output', 'cli', 'test-project'); + const testOutputPath = path.resolve(monoRepoPath, '.test-output', 'cli', projectName); const result = await exec( 'node', @@ -31,7 +54,7 @@ describe('cli', () => { '--types', 'ts', '--no-install', - '--no-add-ons' + ...args ], { nodeOptions: { stdio: 'ignore' } } ); @@ -45,6 +68,6 @@ describe('cli', () => { // package.json has a name const packageJsonPath = path.resolve(testOutputPath, 'package.json'); const packageJson = parseJson(fs.readFileSync(packageJsonPath, 'utf-8')); - expect(packageJson.name).toBe('test-project'); + expect(packageJson.name).toBe(projectName); }); }); From 98d7fe033b05c56c5fa5ebd086d25ab3e9b45cc4 Mon Sep 17 00:00:00 2001 From: Scott Wu Date: Sun, 23 Nov 2025 11:30:23 +0800 Subject: [PATCH 11/17] make it an object --- packages/cli/commands/create.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cli/commands/create.ts b/packages/cli/commands/create.ts index 8bb2c31b..c6fd624d 100644 --- a/packages/cli/commands/create.ts +++ b/packages/cli/commands/create.ts @@ -363,17 +363,17 @@ export async function createVirtualWorkspace({ packageManager, type }: CreateVirtualWorkspaceOptions): Promise { - let kit: Workspace['kit'] | undefined = undefined; + const override: { kit?: Workspace['kit'] } = {}; // These are our default project structure so we know that it's a kit project if (template === 'minimal' || template === 'demo' || template === 'library') { - kit = { + override.kit = { routesDirectory: 'src/routes', libDirectory: 'src/lib' }; } - const tentativeWorkspace = await createWorkspace({ cwd, packageManager, override: { kit } }); + const tentativeWorkspace = await createWorkspace({ cwd, packageManager, override }); const virtualWorkspace: Workspace = { ...tentativeWorkspace, From 00880b46347d3c64769699a62c600ac8106b38ad Mon Sep 17 00:00:00 2001 From: Scott Wu Date: Sun, 23 Nov 2025 01:12:59 +0800 Subject: [PATCH 12/17] fix --- packages/cli/commands/create.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/cli/commands/create.ts b/packages/cli/commands/create.ts index c6fd624d..9056e385 100644 --- a/packages/cli/commands/create.ts +++ b/packages/cli/commands/create.ts @@ -374,16 +374,27 @@ export async function createVirtualWorkspace({ } const tentativeWorkspace = await createWorkspace({ cwd, packageManager, override }); + const resolvedCwd = path.resolve(cwd); + + // This is not linked with typescript detection + const viteConfigPath = path.join(resolvedCwd, commonFilePaths.viteConfigTS); + const viteConfig = fs.existsSync(viteConfigPath) + ? commonFilePaths.viteConfigTS + : commonFilePaths.viteConfig; + const svelteConfigPath = path.join(resolvedCwd, commonFilePaths.svelteConfigTS); + const svelteConfig = fs.existsSync(svelteConfigPath) + ? commonFilePaths.svelteConfigTS + : commonFilePaths.svelteConfig; const virtualWorkspace: Workspace = { ...tentativeWorkspace, typescript: type === 'typescript', files: { ...tentativeWorkspace.files, - viteConfig: type === 'typescript' ? commonFilePaths.viteConfigTS : commonFilePaths.viteConfig, - svelteConfig: - type === 'typescript' ? commonFilePaths.svelteConfigTS : commonFilePaths.svelteConfig - } + viteConfig, + svelteConfig + }, + dependencyVersion: () => undefined }; return virtualWorkspace; From b329f1f6105066e5be9197cbfc4e9523ea58a29c Mon Sep 17 00:00:00 2001 From: Scott Wu Date: Sun, 23 Nov 2025 11:40:34 +0800 Subject: [PATCH 13/17] remove duplicate logic --- packages/cli/commands/create.ts | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/packages/cli/commands/create.ts b/packages/cli/commands/create.ts index 9056e385..d56ba43a 100644 --- a/packages/cli/commands/create.ts +++ b/packages/cli/commands/create.ts @@ -374,26 +374,10 @@ export async function createVirtualWorkspace({ } const tentativeWorkspace = await createWorkspace({ cwd, packageManager, override }); - const resolvedCwd = path.resolve(cwd); - - // This is not linked with typescript detection - const viteConfigPath = path.join(resolvedCwd, commonFilePaths.viteConfigTS); - const viteConfig = fs.existsSync(viteConfigPath) - ? commonFilePaths.viteConfigTS - : commonFilePaths.viteConfig; - const svelteConfigPath = path.join(resolvedCwd, commonFilePaths.svelteConfigTS); - const svelteConfig = fs.existsSync(svelteConfigPath) - ? commonFilePaths.svelteConfigTS - : commonFilePaths.svelteConfig; const virtualWorkspace: Workspace = { ...tentativeWorkspace, typescript: type === 'typescript', - files: { - ...tentativeWorkspace.files, - viteConfig, - svelteConfig - }, dependencyVersion: () => undefined }; From 447ab7c1223153e05a13cff930ae0204b540669f Mon Sep 17 00:00:00 2001 From: Scott Wu Date: Sun, 23 Nov 2025 11:58:59 +0800 Subject: [PATCH 14/17] lint --- packages/cli/commands/create.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/cli/commands/create.ts b/packages/cli/commands/create.ts index d56ba43a..58fce84d 100644 --- a/packages/cli/commands/create.ts +++ b/packages/cli/commands/create.ts @@ -37,7 +37,6 @@ import { sanitizeAddons, type SelectedAddon } from './add/index.ts'; -import { commonFilePaths } from './add/utils.ts'; import { createWorkspace } from './add/workspace.ts'; const langs = ['ts', 'jsdoc'] as const; From eced1b2dafdb880e1559e323b5fe1efd75d1a423 Mon Sep 17 00:00:00 2001 From: Scott Wu Date: Sun, 23 Nov 2025 13:33:48 +0800 Subject: [PATCH 15/17] rerun ci From c642452bcc8793e86472ab0045c5b2ec687c6bfe Mon Sep 17 00:00:00 2001 From: Manuel Serret Date: Sun, 23 Nov 2025 07:58:14 +0100 Subject: [PATCH 16/17] fix --- packages/cli/commands/create.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/cli/commands/create.ts b/packages/cli/commands/create.ts index 58fce84d..0217d702 100644 --- a/packages/cli/commands/create.ts +++ b/packages/cli/commands/create.ts @@ -38,6 +38,7 @@ import { type SelectedAddon } from './add/index.ts'; import { createWorkspace } from './add/workspace.ts'; +import { commonFilePaths } from './add/utils.ts'; const langs = ['ts', 'jsdoc'] as const; const langMap: Record = { @@ -377,8 +378,14 @@ export async function createVirtualWorkspace({ const virtualWorkspace: Workspace = { ...tentativeWorkspace, typescript: type === 'typescript', - dependencyVersion: () => undefined + dependencyVersion: () => undefined, + files: { + ...tentativeWorkspace.files, + viteConfig: type === 'typescript' ? commonFilePaths.viteConfigTS : commonFilePaths.viteConfig, + svelteConfig: commonFilePaths.svelteConfig // currently we always use js files, never typescript files + } }; + console.log(virtualWorkspace); return virtualWorkspace; } From 5bb0a398681f460174f695c1a5a01f35300c07c5 Mon Sep 17 00:00:00 2001 From: Manuel Serret Date: Sun, 23 Nov 2025 07:59:01 +0100 Subject: [PATCH 17/17] make diff smaller --- packages/cli/commands/create.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/cli/commands/create.ts b/packages/cli/commands/create.ts index 0217d702..1ec4c6c5 100644 --- a/packages/cli/commands/create.ts +++ b/packages/cli/commands/create.ts @@ -37,8 +37,8 @@ import { sanitizeAddons, type SelectedAddon } from './add/index.ts'; -import { createWorkspace } from './add/workspace.ts'; import { commonFilePaths } from './add/utils.ts'; +import { createWorkspace } from './add/workspace.ts'; const langs = ['ts', 'jsdoc'] as const; const langMap: Record = { @@ -386,6 +386,5 @@ export async function createVirtualWorkspace({ } }; - console.log(virtualWorkspace); return virtualWorkspace; }