8000 fix: add `kit` check in `drizzle` add-on by AdrianGonz97 · Pull Request #574 · sveltejs/cli · GitHub
[go: up one dir, main page]

Skip to content

fix: add kit check in drizzle add-on #574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
8000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix drizzle setup
  • Loading branch information
AdrianGonz97 committed May 23, 2025
commit afa7ce6441384bd44edde7800dbc0defa68294d3
7 changes: 5 additions & 2 deletions packages/addons/drizzle/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,17 @@ export default defineAddon({
options,
setup: ({ kit, unsupported, cwd, typescript }) => {
const ext = typescript ? 'ts' : 'js';
if (!kit) unsupported('Requires SvelteKit');
if (!kit) {
return unsupported('Requires SvelteKit');
}

const baseDBPath = path.resolve(kit!.libDirectory, 'server', 'db');
const baseDBPath = path.resolve(kit.libDirectory, 'server', 'db');
const paths = {
'drizzle config': path.relative(cwd, path.resolve(cwd, `drizzle.config.${ext}`)),
'database schema': path.relative(cwd, path.resolve(baseDBPath, `schema.${ext}`)),
database: path.relative(cwd, path.resolve(baseDBPath, `index.${ext}`))
};

for (const [fileType, filePath] of Object.entries(paths)) {
if (fs.existsSync(filePath)) {
unsupported(`Preexisting ${fileType} file at '${filePath}'`);
Expand Down
5 changes: 1 addition & 4 deletions packages/cli/commands/add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,7 @@ export async function runAddCommand(

// prepare official addons
let workspace = await createWorkspace({ cwd: options.cwd });
const addonSetupResults = setupAddons(
selectedAddons.map((a) => a.addon),
workspace
);
const addonSetupResults = setupAddons(officialAddons, workspace);

// prompt which addons to apply
if (selectedAddons.length === 0) {
Expand Down
Loading
0