Skip to content

Commit c8147c5

Browse files
feat: Lucia adder (#30)
* annotate type declarators * migrate lucia adder * lint * a `note` but not dimmed * improve drizzle next steps * less wasteful of space * only prompt to install dependent adder if it's not detected * tweak color * more tweaks * revert drizzle-kit to `0.22.0` to fix `db:push` * migrate lucia * eslint wants to make things look worse * remove todo * missed a spot * lucia logo * remove todo * add auth category * use single quotes * fix cookie `path` * add comment to gitignore * clearer hooks code * Update packages/adders/lucia/config/adder.ts Co-authored-by: Ben McCann <[email protected]> --------- Co-authored-by: Ben McCann <[email protected]>
1 parent b695733 commit c8147c5

File tree

23 files changed

+1011
-42
lines changed

23 files changed

+1011
-42
lines changed

packages/adders/_config/categories.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export type CategoryKeys = 'codeQuality' | 'css' | 'db' | 'testing' | 'additional';
1+
export type CategoryKeys = 'codeQuality' | 'css' | 'db' | 'testing' | 'auth' | 'additional';
22

33
export type CategoryInfo = {
44
id: CategoryKeys;
@@ -31,6 +31,11 @@ export const categories: CategoryDetails = {
3131
name: 'Database',
3232
description: ''
3333
},
34+
auth: {
35+
id: 'auth',
36+
name: 'Auth',
37+
description: ''
38+
},
3439
additional: {
3540
id: 'additional',
3641
name: 'Additional functionality',

packages/adders/_config/official.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { AdderWithoutExplicitArgs } from '@svelte-cli/core';
44
// adders
55
import drizzle from '../drizzle/index.ts';
66
import eslint from '../eslint/index.ts';
7+
import lucia from '../lucia/index.ts';
78
import mdsvex from '../mdsvex/index.ts';
89
import playwright from '../playwright/index.ts';
910
import prettier from '../prettier/index.ts';
@@ -17,6 +18,7 @@ const categories = {
1718
testing: [vitest, playwright],
1819
css: [tailwindcss],
1920
db: [drizzle],
21+
auth: [lucia],
2022
additional: [storybook, mdsvex, routify]
2123
};
2224

packages/adders/drizzle/config/adder.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ export const adder = defineAdderConfig({
2323
options: availableOptions,
2424
integrationType: 'inline',
2525
packages: [
26-
{ name: 'drizzle-orm', version: '^0.31.2', dev: false },
26+
{ name: 'drizzle-orm', version: '^0.33.0', dev: false },
2727
{ name: 'drizzle-kit', version: '^0.22.0', dev: true },
2828
// MySQL
2929
{
3030
name: 'mysql2',
31-
version: '^3.9.8',
31+
version: '^3.11.0',
3232
dev: false,
3333
condition: ({ options }) => options.mysql === 'mysql2'
3434
},
@@ -41,7 +41,7 @@ export const adder = defineAdderConfig({
4141
// PostgreSQL
4242
{
4343
name: '@neondatabase/serverless',
44-
version: '^0.9.3',
44+
version: '^0.9.4',
4545
dev: false,
4646
condition: ({ options }) => options.postgresql === 'neon'
4747
},
@@ -54,19 +54,19 @@ export const adder = defineAdderConfig({
5454
// SQLite
5555
{
5656
name: 'better-sqlite3',
57-
version: '^10.0.0',
57+
version: '^11.1.2',
5858
dev: false,
5959
condition: ({ options }) => options.sqlite === 'better-sqlite3'
6060
},
6161
{
6262
name: '@types/better-sqlite3',
63-
version: '^7.6.10',
63+
version: '^7.6.11',
6464
dev: true,
6565
condition: ({ options }) => options.sqlite === 'better-sqlite3'
6666
},
6767
{
6868
name: '@libsql/client',
69-
version: '^0.6.1',
69+
version: '^0.9.0',
7070
dev: false,
7171
condition: ({ options }) => options.sqlite === 'libsql' || options.sqlite === 'turso'
7272
}
@@ -147,7 +147,9 @@ export const adder = defineAdderConfig({
147147
content: ({ content }) => {
148148
if (content.length === 0) return content;
149149

150-
if (!content.includes('\n*.db')) content = content.trimEnd() + '\n*.db';
150+
if (!content.includes('\n*.db')) {
151+
content = content.trimEnd() + '\n\n# SQLite\n*.db';
152+
}
151153
return content;
152154
}
153155
},
@@ -210,7 +212,6 @@ export const adder = defineAdderConfig({
210212

211213
userSchemaExpression = common.expressionFromString(`sqliteTable('user', {
212214
id: integer('id').primaryKey(),
213-
name: text('name').notNull(),
214215
age: integer('age')
215216
})`);
216217
}
@@ -223,8 +224,7 @@ export const adder = defineAdderConfig({
223224
});
224225

225226
userSchemaExpression = common.expressionFromString(`mysqlTable('user', {
226-
id: serial("id").primaryKey(),
227-
name: text('name').notNull(),
227+
id: serial('id').primaryKey(),
228228
age: int('age'),
229229
})`);
230230
}
@@ -238,7 +238,6 @@ export const adder = defineAdderConfig({
238238

239239
userSchemaExpression = common.expressionFromString(`pgTable('user', {
240240
id: serial('id').primaryKey(),
241-
name: text('name').notNull(),
242241
age: integer('age'),
243242
})`);
244243
}
@@ -257,7 +256,7 @@ export const adder = defineAdderConfig({
257256

258257
// env var checks
259258
const dbURLCheck = common.statementFromString(
260-
'if (!env.DATABASE_URL) throw new Error("DATABASE_URL is not set");'
259+
`if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set');`
261260
);
262261
common.addStatement(ast, dbURLCheck);
263262

@@ -277,7 +276,7 @@ export const adder = defineAdderConfig({
277276
imports.addNamed(ast, '$app/environment', { dev: 'dev' });
278277
// auth token check in prod
279278
const authTokenCheck = common.statementFromString(
280-
'if (!dev && !env.DATABASE_AUTH_TOKEN) throw new Error("DATABASE_AUTH_TOKEN is not set");'
279+
`if (!dev && !env.DATABASE_AUTH_TOKEN) throw new Error('DATABASE_AUTH_TOKEN is not set');`
281280
);
282281
common.addStatement(ast, authTokenCheck);
283282

@@ -329,8 +328,15 @@ export const adder = defineAdderConfig({
329328
}
330329
}
331330
],
332-
nextSteps: () => {
333-
const steps = ['You will need to set DATABASE_URL in your production environment'];
331+
nextSteps: ({ options, colors }) => {
332+
const highlight = (str: string) => colors.bold(colors.cyan(str));
333+
const steps = [
334+
`You will need to set ${colors.yellow('DATABASE_URL')} in your production environment`
335+
];
336+
if (options.docker) {
337+
steps.push(`Run ${highlight('npm run db:start')} to start the docker container`);
338+
}
339+
steps.push(`To update your DB schema, run ${highlight('npm run db:push')}`);
334340

335341
return steps;
336342
}

0 commit comments

Comments
 (0)