diff --git a/.changeset/sweet-moose-raise.md b/.changeset/sweet-moose-raise.md new file mode 100644 index 000000000..614802bd2 --- /dev/null +++ b/.changeset/sweet-moose-raise.md @@ -0,0 +1,5 @@ +--- +"sv": patch +--- + +fix: install `@better-auth/cli` as a dev dependency diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 833531cd5..9eed6f024 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,7 +29,7 @@ Linux users, you will have to ensure 'sudo' is not required. See [docker post in ```sh git clone https://github.com/sveltejs/cli.git cd cli -pnpm install +pnpm i ``` ## Build and run diff --git a/documentation/docs/10-introduction/10-overview.md b/documentation/docs/10-introduction/10-overview.md index 564bcf969..67a4316db 100644 --- a/documentation/docs/10-introduction/10-overview.md +++ b/documentation/docs/10-introduction/10-overview.md @@ -6,7 +6,7 @@ The command line interface (CLI), `sv`, is a toolkit for creating and maintainin ## Usage -The easiest way to run `sv` is with [`npx`](https://docs.npmjs.com/cli/v8/commands/npx) (or the equivalent command if you're using a different package manager — for example, `pnpx` if you're using [pnpm](https://pnpm.io/)): +The easiest way to run `sv` is with [`npx`](https://docs.npmjs.com/cli/v8/commands/npx) (or the equivalent command if you're using a different package manager — for example, `pnpm dlx` if you're using [pnpm](https://pnpm.io/)): ```sh npx sv diff --git a/documentation/docs/10-introduction/20-faq.md b/documentation/docs/10-introduction/20-faq.md index e3aaa7f78..275d23488 100644 --- a/documentation/docs/10-introduction/20-faq.md +++ b/documentation/docs/10-introduction/20-faq.md @@ -7,7 +7,7 @@ title: Frequently asked questions Running `sv` looks slightly different for each package manager. Here is a list of the most common commands: - **npm** : `npx sv create` -- **pnpm** : `pnpx sv create` or `pnpm dlx sv create` +- **pnpm** : `pnpm dlx sv create` - **Bun** : `bunx sv create` - **Deno** : `deno run npm:sv create` - **Yarn** : `yarn dlx sv create` diff --git a/packages/sv/src/addons/better-auth.ts b/packages/sv/src/addons/better-auth.ts index cd55b0277..1670c4d37 100644 --- a/packages/sv/src/addons/better-auth.ts +++ b/packages/sv/src/addons/better-auth.ts @@ -51,6 +51,7 @@ export default defineAddon({ let drizzleDialect: Dialect; sv.devDependency('better-auth', '^1.4.18'); + sv.devDependency('@better-auth/cli', '^1.4.18'); sv.file(`drizzle.config.${language}`, (content) => { const { ast, generateCode } = parse.script(content); @@ -134,7 +135,7 @@ export default defineAddon({ json.packageScriptsUpsert( data, 'auth:schema', - `npx @better-auth/cli generate --config ${authConfigPath} --output ${authSchemaPath} --yes` + `better-auth generate --config ${authConfigPath} --output ${authSchemaPath} --yes` ); return generateCode(); }); diff --git a/packages/sv/src/cli/tests/cli.ts b/packages/sv/src/cli/tests/cli.ts index 4b8564853..61fa5e05c 100644 --- a/packages/sv/src/cli/tests/cli.ts +++ b/packages/sv/src/cli/tests/cli.ts @@ -108,6 +108,11 @@ describe('cli', () => { generated = generated.replaceAll('\r\n', '\n'); // make it work on Windows too if (!generated.endsWith('\n')) generated += '\n'; // ensure trailing newline + // Normalize sv version in README.md to avoid snapshot drift + if (relativeFile === 'README.md') { + generated = generated.replace(/sv@\d+\.\d+\.\d+/g, 'sv@0.0.0'); + } + await expect(generated).toMatchFileSnapshot( path.resolve(snapPath, relativeFile), `file "${relativeFile}" does not match snapshot` diff --git a/packages/sv/src/cli/tests/snapshots/create-only/README.md b/packages/sv/src/cli/tests/snapshots/create-only/README.md index 2709fe8ef..7844bbfc6 100644 --- a/packages/sv/src/cli/tests/snapshots/create-only/README.md +++ b/packages/sv/src/cli/tests/snapshots/create-only/README.md @@ -15,7 +15,7 @@ To recreate this project with the same configuration: ```sh # recreate this project -npx sv create --template minimal --types ts --no-install packages/sv/.test-output/cli/create-only +npx sv@0.0.0 create --template minimal --types ts --no-install packages/sv/.test-output/cli/create-only ``` ## Developing diff --git a/packages/sv/src/cli/tests/snapshots/create-with-all-addons/README.md b/packages/sv/src/cli/tests/snapshots/create-with-all-addons/README.md index 639b5c0c7..c65e1b6f7 100644 --- a/packages/sv/src/cli/tests/snapshots/create-with-all-addons/README.md +++ b/packages/sv/src/cli/tests/snapshots/create-with-all-addons/README.md @@ -15,7 +15,7 @@ To recreate this project with the same configuration: ```sh # recreate this project -npx sv create --template minimal --types ts --add prettier eslint vitest="usages:unit,component" playwright tailwindcss="plugins:typography,forms" sveltekit-adapter="adapter:node" devtools-json drizzle="database:sqlite+sqlite:libsql" better-auth="demo:password,github" mdsvex paraglide="languageTags:en,es+demo:yes" mcp="ide:claude-code,cursor,gemini,opencode,vscode,other+setup:local" --no-install packages/sv/.test-output/cli/create-with-all-addons +npx sv@0.0.0 create --template minimal --types ts --add prettier eslint vitest="usages:unit,component" playwright tailwindcss="plugins:typography,forms" sveltekit-adapter="adapter:node" devtools-json drizzle="database:sqlite+sqlite:libsql" better-auth="demo:password,github" mdsvex paraglide="languageTags:en,es+demo:yes" mcp="ide:claude-code,cursor,gemini,opencode,vscode,other+setup:local" --no-install packages/sv/.test-output/cli/create-with-all-addons ``` ## Developing diff --git a/packages/sv/src/cli/tests/snapshots/create-with-all-addons/package.json b/packages/sv/src/cli/tests/snapshots/create-with-all-addons/package.json index 27d02f979..5cd80f37d 100644 --- a/packages/sv/src/cli/tests/snapshots/create-with-all-addons/package.json +++ b/packages/sv/src/cli/tests/snapshots/create-with-all-addons/package.json @@ -19,9 +19,10 @@ "db:generate": "drizzle-kit generate", "db:migrate": "drizzle-kit migrate", "db:studio": "drizzle-kit studio", - "auth:schema": "npx @better-auth/cli generate --config src/lib/server/auth.ts --output src/lib/server/db/auth.schema.ts --yes" + "auth:schema": "better-auth generate --config src/lib/server/auth.ts --output src/lib/server/db/auth.schema.ts --yes" }, "devDependencies": { + "@better-auth/cli": "^1.4.18", "@eslint/compat": "^2.0.2", "@eslint/js": "^9.39.2", "@inlang/paraglide-js": "^2.10.0", diff --git a/packages/sv/src/core/common.ts b/packages/sv/src/core/common.ts index aea103306..036557986 100644 --- a/packages/sv/src/core/common.ts +++ b/packages/sv/src/core/common.ts @@ -144,7 +144,7 @@ export function buildAndLogArgs( args: string[], lastArgs: string[] = [] ): string { - const allArgs = ['sv', command, ...args]; + const allArgs = [`sv@${pkg.version}`, command, ...args]; // Handle install option if (agent === null || agent === undefined) allArgs.push('--no-install');