create-authhero 0.16.0 → 0.18.0

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.
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env node
2
- import { Command as x } from "commander";
3
- import c from "inquirer";
4
- import i from "fs";
5
- import f from "path";
6
- import { spawn as D } from "child_process";
7
- const b = new x(), n = {
2
+ import { Command as A } from "commander";
3
+ import m from "inquirer";
4
+ import s from "fs";
5
+ import i from "path";
6
+ import { spawn as b } from "child_process";
7
+ const D = new A(), c = {
8
8
  local: {
9
9
  name: "Local (SQLite)",
10
10
  description: "Local development setup with SQLite database - great for getting started",
11
11
  templateDir: "local",
12
- packageJson: (r) => ({
13
- name: r,
12
+ packageJson: (o) => ({
13
+ name: o,
14
14
  version: "1.0.0",
15
15
  type: "module",
16
16
  scripts: {
@@ -42,21 +42,22 @@ const b = new x(), n = {
42
42
  name: "Cloudflare Simple (Single Tenant)",
43
43
  description: "Single-tenant Cloudflare Workers setup with D1 database",
44
44
  templateDir: "cloudflare-simple",
45
- packageJson: (r) => ({
46
- name: r,
45
+ packageJson: (o) => ({
46
+ name: o,
47
47
  version: "1.0.0",
48
48
  type: "module",
49
49
  scripts: {
50
- "dev:local": "wrangler dev --port 3000 --local-protocol https",
51
- "dev:remote": "wrangler dev --port 3000 --local-protocol https --remote",
52
- dev: "wrangler dev --port 3000 --local-protocol https",
53
- deploy: "wrangler deploy",
50
+ "copy-assets": "node copy-assets.js",
51
+ dev: "npm run copy-assets && wrangler dev --port 3000 --local-protocol https",
52
+ "dev:remote": "npm run copy-assets && wrangler dev --port 3000 --local-protocol https --remote --config wrangler.local.toml",
53
+ deploy: "npm run copy-assets && wrangler deploy --config wrangler.local.toml",
54
54
  "db:migrate:local": "wrangler d1 migrations apply AUTH_DB --local",
55
- "db:migrate:remote": "wrangler d1 migrations apply AUTH_DB --remote",
55
+ "db:migrate:remote": "wrangler d1 migrations apply AUTH_DB --remote --config wrangler.local.toml",
56
56
  migrate: "wrangler d1 migrations apply AUTH_DB --local",
57
57
  "seed:local": "node seed-helper.js",
58
58
  "seed:remote": "node seed-helper.js '' '' remote",
59
- seed: "node seed-helper.js"
59
+ seed: "node seed-helper.js",
60
+ setup: "cp wrangler.toml wrangler.local.toml && cp .dev.vars.example .dev.vars && echo '✅ Created wrangler.local.toml and .dev.vars - update with your IDs'"
60
61
  },
61
62
  dependencies: {
62
63
  "@authhero/drizzle": "latest",
@@ -82,21 +83,22 @@ const b = new x(), n = {
82
83
  name: "Cloudflare Multi-Tenant (Production)",
83
84
  description: "Production-grade multi-tenant setup with D1 database and tenant management",
84
85
  templateDir: "cloudflare-multitenant",
85
- packageJson: (r) => ({
86
- name: r,
86
+ packageJson: (o) => ({
87
+ name: o,
87
88
  version: "1.0.0",
88
89
  type: "module",
89
90
  scripts: {
90
- "dev:local": "wrangler dev --port 3000 --local-protocol https",
91
- "dev:remote": "wrangler dev --port 3000 --local-protocol https --remote",
92
- dev: "wrangler dev --port 3000 --local-protocol https",
93
- deploy: "wrangler deploy",
91
+ "copy-assets": "node copy-assets.js",
92
+ dev: "npm run copy-assets && wrangler dev --port 3000 --local-protocol https",
93
+ "dev:remote": "npm run copy-assets && wrangler dev --port 3000 --local-protocol https --remote --config wrangler.local.toml",
94
+ deploy: "npm run copy-assets && wrangler deploy --config wrangler.local.toml",
94
95
  "db:migrate:local": "wrangler d1 migrations apply AUTH_DB --local",
95
- "db:migrate:remote": "wrangler d1 migrations apply AUTH_DB --remote",
96
+ "db:migrate:remote": "wrangler d1 migrations apply AUTH_DB --remote --config wrangler.local.toml",
96
97
  migrate: "wrangler d1 migrations apply AUTH_DB --local",
97
98
  "seed:local": "node seed-helper.js",
98
99
  "seed:remote": "node seed-helper.js '' '' remote",
99
- seed: "node seed-helper.js"
100
+ seed: "node seed-helper.js",
101
+ setup: "cp wrangler.toml wrangler.local.toml && cp .dev.vars.example .dev.vars && echo '✅ Created wrangler.local.toml and .dev.vars - update with your IDs'"
100
102
  },
101
103
  dependencies: {
102
104
  "@authhero/drizzle": "latest",
@@ -119,13 +121,13 @@ const b = new x(), n = {
119
121
  seedFile: "seed.ts"
120
122
  }
121
123
  };
122
- function A(r, a) {
123
- i.readdirSync(r).forEach((o) => {
124
- const t = f.join(r, o), e = f.join(a, o);
125
- i.lstatSync(t).isDirectory() ? (i.mkdirSync(e, { recursive: !0 }), A(t, e)) : i.copyFileSync(t, e);
124
+ function j(o, e) {
125
+ s.readdirSync(o).forEach((n) => {
126
+ const a = i.join(o, n), t = i.join(e, n);
127
+ s.lstatSync(a).isDirectory() ? (s.mkdirSync(t, { recursive: !0 }), j(a, t)) : s.copyFileSync(a, t);
126
128
  });
127
129
  }
128
- function $() {
130
+ function I() {
129
131
  return `import { SqliteDialect, Kysely } from "kysely";
130
132
  import Database from "better-sqlite3";
131
133
  import createAdapters from "@authhero/kysely-adapter";
@@ -159,44 +161,158 @@ async function main() {
159
161
  main().catch(console.error);
160
162
  `;
161
163
  }
162
- function v(r, a) {
163
- return new Promise((s, o) => {
164
- const t = D(r, [], {
165
- cwd: a,
164
+ function x(o) {
165
+ const e = i.join(o, ".github", "workflows");
166
+ s.mkdirSync(e, { recursive: !0 });
167
+ const r = `name: Unit tests
168
+
169
+ on: push
170
+
171
+ jobs:
172
+ test:
173
+ runs-on: ubuntu-latest
174
+ steps:
175
+ - uses: actions/checkout@v4
176
+
177
+ - name: Setup Node.js
178
+ uses: actions/setup-node@v4
179
+ with:
180
+ node-version: "22"
181
+ cache: "npm"
182
+
183
+ - name: Install dependencies
184
+ run: npm ci
185
+
186
+ - run: npm run type-check
187
+ - run: npm test
188
+ `, n = `name: Deploy to Dev
189
+
190
+ on:
191
+ push:
192
+ branches:
193
+ - main
194
+
195
+ jobs:
196
+ release:
197
+ name: Release and Deploy
198
+ runs-on: ubuntu-latest
199
+ steps:
200
+ - name: Checkout
201
+ uses: actions/checkout@v4
202
+ with:
203
+ fetch-depth: 0
204
+
205
+ - name: Setup Node.js
206
+ uses: actions/setup-node@v4
207
+ with:
208
+ node-version: "22"
209
+ cache: "npm"
210
+
211
+ - name: Install dependencies
212
+ run: npm ci
213
+
214
+ - name: Release
215
+ env:
216
+ GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
217
+ run: npx semantic-release
218
+
219
+ - name: Deploy to Cloudflare (Dev)
220
+ uses: cloudflare/wrangler-action@v3
221
+ with:
222
+ apiToken: \${{ secrets.CLOUDFLARE_API_TOKEN }}
223
+ command: deploy
224
+ `, a = `name: Deploy to Production
225
+
226
+ on:
227
+ release:
228
+ types: ["released"]
229
+
230
+ jobs:
231
+ deploy:
232
+ name: Deploy to Production
233
+ runs-on: ubuntu-latest
234
+ steps:
235
+ - name: Checkout
236
+ uses: actions/checkout@v4
237
+
238
+ - name: Setup Node.js
239
+ uses: actions/setup-node@v4
240
+ with:
241
+ node-version: "22"
242
+ cache: "npm"
243
+
244
+ - name: Install dependencies
245
+ run: npm ci
246
+
247
+ - name: Deploy to Cloudflare (Production)
248
+ uses: cloudflare/wrangler-action@v3
249
+ with:
250
+ apiToken: \${{ secrets.PROD_CLOUDFLARE_API_TOKEN }}
251
+ command: deploy --env production
252
+ `;
253
+ s.writeFileSync(i.join(e, "unit-tests.yml"), r), s.writeFileSync(i.join(e, "deploy-dev.yml"), n), s.writeFileSync(i.join(e, "release.yml"), a), console.log("\\n📦 GitHub CI workflows created!");
254
+ }
255
+ function C(o) {
256
+ const e = {
257
+ branches: ["main"],
258
+ plugins: [
259
+ "@semantic-release/commit-analyzer",
260
+ "@semantic-release/release-notes-generator",
261
+ "@semantic-release/github"
262
+ ]
263
+ };
264
+ s.writeFileSync(
265
+ i.join(o, ".releaserc.json"),
266
+ JSON.stringify(e, null, 2)
267
+ );
268
+ const r = i.join(o, "package.json"), n = JSON.parse(s.readFileSync(r, "utf-8"));
269
+ n.devDependencies = {
270
+ ...n.devDependencies,
271
+ "semantic-release": "^24.0.0"
272
+ }, n.scripts = {
273
+ ...n.scripts,
274
+ test: 'echo "No tests yet"',
275
+ "type-check": "tsc --noEmit"
276
+ }, s.writeFileSync(r, JSON.stringify(n, null, 2));
277
+ }
278
+ function v(o, e) {
279
+ return new Promise((r, n) => {
280
+ const a = b(o, [], {
281
+ cwd: e,
166
282
  shell: !0,
167
283
  stdio: "inherit"
168
284
  });
169
- t.on("close", (e) => {
170
- e === 0 ? s() : o(new Error(`Command failed with exit code ${e}`));
171
- }), t.on("error", o);
285
+ a.on("close", (t) => {
286
+ t === 0 ? r() : n(new Error(`Command failed with exit code ${t}`));
287
+ }), a.on("error", n);
172
288
  });
173
289
  }
174
- function S(r, a, s) {
175
- return new Promise((o, t) => {
176
- const e = D(r, [], {
177
- cwd: a,
290
+ function S(o, e, r) {
291
+ return new Promise((n, a) => {
292
+ const t = b(o, [], {
293
+ cwd: e,
178
294
  shell: !0,
179
295
  stdio: "inherit",
180
- env: { ...process.env, ...s }
296
+ env: { ...process.env, ...r }
181
297
  });
182
- e.on("close", (g) => {
183
- g === 0 ? o() : t(new Error(`Command failed with exit code ${g}`));
184
- }), e.on("error", t);
298
+ t.on("close", (f) => {
299
+ f === 0 ? n() : a(new Error(`Command failed with exit code ${f}`));
300
+ }), t.on("error", a);
185
301
  });
186
302
  }
187
- b.version("1.0.0").description("Create a new AuthHero project").argument("[project-name]", "name of the project").option(
303
+ D.version("1.0.0").description("Create a new AuthHero project").argument("[project-name]", "name of the project").option(
188
304
  "-t, --template <type>",
189
305
  "template type: local, cloudflare-simple, or cloudflare-multitenant"
190
306
  ).option("-e, --email <email>", "admin email address").option("-p, --password <password>", "admin password (min 8 characters)").option(
191
307
  "--package-manager <pm>",
192
308
  "package manager to use: npm, yarn, pnpm, or bun"
193
- ).option("--skip-install", "skip installing dependencies").option("--skip-migrate", "skip running database migrations").option("--skip-seed", "skip seeding the database").option("--skip-start", "skip starting the development server").option("--remote", "use remote mode for cloudflare-simple (production D1)").option("-y, --yes", "skip all prompts and use defaults/provided options").action(async (r, a) => {
194
- const s = a.yes === !0;
309
+ ).option("--skip-install", "skip installing dependencies").option("--skip-migrate", "skip running database migrations").option("--skip-seed", "skip seeding the database").option("--skip-start", "skip starting the development server").option("--github-ci", "include GitHub CI workflows with semantic versioning").option("-y, --yes", "skip all prompts and use defaults/provided options").action(async (o, e) => {
310
+ const r = e.yes === !0;
195
311
  console.log(`
196
312
  🔐 Welcome to AuthHero!
197
313
  `);
198
- let o = r;
199
- o || (s ? (o = "auth-server", console.log(`Using default project name: ${o}`)) : o = (await c.prompt([
314
+ let n = o;
315
+ n || (r ? (n = "auth-server", console.log(`Using default project name: ${n}`)) : n = (await m.prompt([
200
316
  {
201
317
  type: "input",
202
318
  name: "projectName",
@@ -205,60 +321,76 @@ b.version("1.0.0").description("Create a new AuthHero project").argument("[proje
205
321
  validate: (p) => p !== "" || "Project name cannot be empty"
206
322
  }
207
323
  ])).projectName);
208
- const t = f.join(process.cwd(), o);
209
- i.existsSync(t) && (console.error(`❌ Project "${o}" already exists.`), process.exit(1));
210
- let e;
211
- a.template ? (["local", "cloudflare-simple", "cloudflare-multitenant"].includes(
212
- a.template
213
- ) || (console.error(`❌ Invalid template: ${a.template}`), console.error(
324
+ const a = i.join(process.cwd(), n);
325
+ s.existsSync(a) && (console.error(`❌ Project "${n}" already exists.`), process.exit(1));
326
+ let t;
327
+ e.template ? (["local", "cloudflare-simple", "cloudflare-multitenant"].includes(
328
+ e.template
329
+ ) || (console.error(`❌ Invalid template: ${e.template}`), console.error(
214
330
  "Valid options: local, cloudflare-simple, cloudflare-multitenant"
215
- ), process.exit(1)), e = a.template, console.log(`Using template: ${n[e].name}`)) : e = (await c.prompt([
331
+ ), process.exit(1)), t = e.template, console.log(`Using template: ${c[t].name}`)) : t = (await m.prompt([
216
332
  {
217
333
  type: "list",
218
334
  name: "setupType",
219
335
  message: "Select your setup type:",
220
336
  choices: [
221
337
  {
222
- name: `${n.local.name}
223
- ${n.local.description}`,
338
+ name: `${c.local.name}
339
+ ${c.local.description}`,
224
340
  value: "local",
225
- short: n.local.name
341
+ short: c.local.name
226
342
  },
227
343
  {
228
- name: `${n["cloudflare-simple"].name}
229
- ${n["cloudflare-simple"].description}`,
344
+ name: `${c["cloudflare-simple"].name}
345
+ ${c["cloudflare-simple"].description}`,
230
346
  value: "cloudflare-simple",
231
- short: n["cloudflare-simple"].name
347
+ short: c["cloudflare-simple"].name
232
348
  },
233
349
  {
234
- name: `${n["cloudflare-multitenant"].name}
235
- ${n["cloudflare-multitenant"].description}`,
350
+ name: `${c["cloudflare-multitenant"].name}
351
+ ${c["cloudflare-multitenant"].description}`,
236
352
  value: "cloudflare-multitenant",
237
- short: n["cloudflare-multitenant"].name
353
+ short: c["cloudflare-multitenant"].name
238
354
  }
239
355
  ]
240
356
  }
241
357
  ])).setupType;
242
- const g = n[e];
243
- i.mkdirSync(t, { recursive: !0 }), i.writeFileSync(
244
- f.join(t, "package.json"),
245
- JSON.stringify(g.packageJson(o), null, 2)
358
+ const f = c[t];
359
+ s.mkdirSync(a, { recursive: !0 }), s.writeFileSync(
360
+ i.join(a, "package.json"),
361
+ JSON.stringify(f.packageJson(n), null, 2)
246
362
  );
247
- const k = f.join(
363
+ const k = i.join(
248
364
  import.meta.url.replace("file://", "").replace("/create-authhero.js", ""),
249
- g.templateDir
365
+ f.templateDir
250
366
  );
251
- if (i.existsSync(k) ? A(k, t) : (console.error(`❌ Template directory not found: ${k}`), process.exit(1)), e === "local") {
252
- const l = $();
253
- i.writeFileSync(f.join(t, "src/seed.ts"), l);
367
+ if (s.existsSync(k) ? j(k, a) : (console.error(`❌ Template directory not found: ${k}`), process.exit(1)), t === "cloudflare-simple" || t === "cloudflare-multitenant") {
368
+ const l = i.join(a, "wrangler.toml"), p = i.join(a, "wrangler.local.toml");
369
+ s.existsSync(l) && s.copyFileSync(l, p);
370
+ const d = i.join(a, ".dev.vars.example"), u = i.join(a, ".dev.vars");
371
+ s.existsSync(d) && s.copyFileSync(d, u), console.log(
372
+ "📁 Created wrangler.local.toml and .dev.vars for local development"
373
+ );
374
+ }
375
+ let y = !1;
376
+ if ((t === "cloudflare-simple" || t === "cloudflare-multitenant") && (e.githubCi !== void 0 ? (y = e.githubCi, y && console.log("Including GitHub CI workflows with semantic versioning")) : r || (y = (await m.prompt([
377
+ {
378
+ type: "confirm",
379
+ name: "includeGithubCi",
380
+ message: "Would you like to include GitHub CI with semantic versioning?",
381
+ default: !1
382
+ }
383
+ ])).includeGithubCi), y && (x(a), C(a))), t === "local") {
384
+ const l = I();
385
+ s.writeFileSync(i.join(a, "src/seed.ts"), l);
254
386
  }
255
387
  console.log(
256
388
  `
257
- ✅ Project "${o}" has been created with ${g.name} setup!
389
+ ✅ Project "${n}" has been created with ${f.name} setup!
258
390
  `
259
391
  );
260
392
  let h;
261
- if (a.skipInstall ? h = !1 : s ? h = !0 : h = (await c.prompt([
393
+ if (e.skipInstall ? h = !1 : r ? h = !0 : h = (await m.prompt([
262
394
  {
263
395
  type: "confirm",
264
396
  name: "shouldInstall",
@@ -267,9 +399,9 @@ b.version("1.0.0").description("Create a new AuthHero project").argument("[proje
267
399
  }
268
400
  ])).shouldInstall, h) {
269
401
  let l;
270
- a.packageManager ? (["npm", "yarn", "pnpm", "bun"].includes(a.packageManager) || (console.error(
271
- `❌ Invalid package manager: ${a.packageManager}`
272
- ), console.error("Valid options: npm, yarn, pnpm, bun"), process.exit(1)), l = a.packageManager) : s ? l = "pnpm" : l = (await c.prompt([
402
+ e.packageManager ? (["npm", "yarn", "pnpm", "bun"].includes(e.packageManager) || (console.error(
403
+ `❌ Invalid package manager: ${e.packageManager}`
404
+ ), console.error("Valid options: npm, yarn, pnpm, bun"), process.exit(1)), l = e.packageManager) : r ? l = "pnpm" : l = (await m.prompt([
273
405
  {
274
406
  type: "list",
275
407
  name: "packageManager",
@@ -287,35 +419,13 @@ b.version("1.0.0").description("Create a new AuthHero project").argument("[proje
287
419
  `);
288
420
  try {
289
421
  const p = l === "pnpm" ? "pnpm install --ignore-workspace" : `${l} install`;
290
- await v(p, t), e === "local" && (console.log(`
422
+ if (await v(p, a), t === "local" && (console.log(`
291
423
  🔧 Building native modules...
292
- `), await v("npm rebuild better-sqlite3", t)), console.log(`
424
+ `), await v("npm rebuild better-sqlite3", a)), console.log(`
293
425
  ✅ Dependencies installed successfully!
294
- `);
295
- let y = a.remote ? "remote" : "local";
296
- if (e === "local" || e === "cloudflare-simple" || e === "cloudflare-multitenant") {
297
- (e === "cloudflare-simple" || e === "cloudflare-multitenant") && !s && !a.remote && (y = (await c.prompt([
298
- {
299
- type: "list",
300
- name: "mode",
301
- message: "Would you like to run in local mode or remote mode?",
302
- choices: [
303
- {
304
- name: "Local (using local D1 database)",
305
- value: "local",
306
- short: "Local"
307
- },
308
- {
309
- name: "Remote (using production D1 database)",
310
- value: "remote",
311
- short: "Remote"
312
- }
313
- ],
314
- default: "local"
315
- }
316
- ])).mode);
426
+ `), t === "local" || t === "cloudflare-simple" || t === "cloudflare-multitenant") {
317
427
  let u;
318
- if (a.skipMigrate && a.skipSeed ? u = !1 : s ? u = !a.skipMigrate || !a.skipSeed : u = (await c.prompt([
428
+ if (e.skipMigrate && e.skipSeed ? u = !1 : r ? u = !e.skipMigrate || !e.skipSeed : u = (await m.prompt([
319
429
  {
320
430
  type: "confirm",
321
431
  name: "shouldSetup",
@@ -323,73 +433,61 @@ b.version("1.0.0").description("Create a new AuthHero project").argument("[proje
323
433
  default: !0
324
434
  }
325
435
  ])).shouldSetup, u) {
326
- let d;
327
- if (a.email && a.password ? (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a.email) || (console.error("❌ Invalid email address provided"), process.exit(1)), a.password.length < 8 && (console.error("❌ Password must be at least 8 characters"), process.exit(1)), d = {
328
- username: a.email,
329
- password: a.password
330
- }, console.log(`Using admin email: ${a.email}`)) : d = await c.prompt([
436
+ let g;
437
+ e.email && e.password ? (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.email) || (console.error("❌ Invalid email address provided"), process.exit(1)), e.password.length < 8 && (console.error("❌ Password must be at least 8 characters"), process.exit(1)), g = {
438
+ username: e.email,
439
+ password: e.password
440
+ }, console.log(`Using admin email: ${e.email}`)) : g = await m.prompt([
331
441
  {
332
442
  type: "input",
333
443
  name: "username",
334
444
  message: "Admin email:",
335
445
  default: "admin@example.com",
336
- validate: (m) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(m) || "Please enter a valid email address"
446
+ validate: (w) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(w) || "Please enter a valid email address"
337
447
  },
338
448
  {
339
449
  type: "password",
340
450
  name: "password",
341
451
  message: "Admin password:",
342
452
  mask: "*",
343
- validate: (m) => m.length < 8 ? "Password must be at least 8 characters" : !0
453
+ validate: (w) => w.length < 8 ? "Password must be at least 8 characters" : !0
344
454
  }
345
- ]), !a.skipMigrate) {
346
- console.log(`
455
+ ]), e.skipMigrate || (console.log(`
347
456
  🔄 Running migrations...
348
- `);
349
- const m = (e === "cloudflare-simple" || e === "cloudflare-multitenant") && y === "remote" ? `${l} run db:migrate:remote` : `${l} run migrate`;
350
- await v(m, t);
351
- }
352
- if (!a.skipSeed)
353
- if (console.log(`
457
+ `), await v(`${l} run migrate`, a)), e.skipSeed || (console.log(`
354
458
  🌱 Seeding database...
355
- `), e === "local")
356
- await S(
357
- `${l} run seed`,
358
- t,
359
- {
360
- ADMIN_EMAIL: d.username,
361
- ADMIN_PASSWORD: d.password
362
- }
363
- );
364
- else {
365
- const m = y === "remote" ? `${l} run seed:remote` : `${l} run seed:local`;
366
- await S(m, t, {
367
- ADMIN_EMAIL: d.username,
368
- ADMIN_PASSWORD: d.password
369
- });
459
+ `), t === "local" ? await S(
460
+ `${l} run seed`,
461
+ a,
462
+ {
463
+ ADMIN_EMAIL: g.username,
464
+ ADMIN_PASSWORD: g.password
370
465
  }
466
+ ) : await S(
467
+ `${l} run seed:local`,
468
+ a,
469
+ {
470
+ ADMIN_EMAIL: g.username,
471
+ ADMIN_PASSWORD: g.password
472
+ }
473
+ ));
371
474
  }
372
475
  }
373
- let w;
374
- if (a.skipStart || s ? w = !1 : w = (await c.prompt([
476
+ let d;
477
+ e.skipStart || r ? d = !1 : d = (await m.prompt([
375
478
  {
376
479
  type: "confirm",
377
480
  name: "shouldStart",
378
481
  message: "Would you like to start the development server?",
379
482
  default: !0
380
483
  }
381
- ])).shouldStart, w) {
382
- console.log(
383
- `
484
+ ])).shouldStart, d && (console.log(
485
+ `
384
486
  🚀 Starting development server on https://localhost:3000 ...
385
487
  `
386
- );
387
- const u = (e === "cloudflare-simple" || e === "cloudflare-multitenant") && y === "remote" ? `${l} run dev:remote` : `${l} run dev`;
388
- await v(u, t);
389
- }
390
- s && !w && (console.log(`
488
+ ), await v(`${l} run dev`, a)), r && !d && (console.log(`
391
489
  ✅ Setup complete!`), console.log(`
392
- To start the development server:`), console.log(` cd ${o}`), console.log((e === "cloudflare-simple" || e === "cloudflare-multitenant") && y === "remote" ? " npm run dev:remote" : " npm run dev"), (e === "cloudflare-simple" || e === "cloudflare-multitenant") && console.log(
490
+ To start the development server:`), console.log(` cd ${n}`), console.log(" npm run dev"), (t === "cloudflare-simple" || t === "cloudflare-multitenant") && console.log(
393
491
  `
394
492
  Server will be available at: https://localhost:3000`
395
493
  ));
@@ -398,9 +496,9 @@ Server will be available at: https://localhost:3000`
398
496
  ❌ An error occurred:`, p), process.exit(1);
399
497
  }
400
498
  }
401
- h || (console.log("Next steps:"), console.log(` cd ${o}`), e === "local" ? (console.log(" npm install"), console.log(" npm run migrate"), console.log(
499
+ h || (console.log("Next steps:"), console.log(` cd ${n}`), t === "local" ? (console.log(" npm install"), console.log(" npm run migrate"), console.log(
402
500
  " ADMIN_EMAIL=admin@example.com ADMIN_PASSWORD=yourpassword npm run seed"
403
- ), console.log(" npm run dev")) : (e === "cloudflare-simple" || e === "cloudflare-multitenant") && (console.log(" npm install"), console.log(
501
+ ), console.log(" npm run dev")) : (t === "cloudflare-simple" || t === "cloudflare-multitenant") && (console.log(" npm install"), console.log(
404
502
  " npm run migrate # or npm run db:migrate:remote for production"
405
503
  ), console.log(
406
504
  " ADMIN_EMAIL=admin@example.com ADMIN_PASSWORD=yourpassword npm run seed"
@@ -409,4 +507,4 @@ Server will be available at: https://localhost:3000`)), console.log(`
409
507
  For more information, visit: https://authhero.net/docs
410
508
  `));
411
509
  });
412
- b.parse(process.argv);
510
+ D.parse(process.argv);
@@ -2,6 +2,7 @@ import { Context } from "hono";
2
2
  import { HTTPException } from "hono/http-exception";
3
3
  import { AuthHeroConfig, init } from "authhero";
4
4
  import { swaggerUI } from "@hono/swagger-ui";
5
+ import { serveStatic } from "@hono/node-server/serve-static";
5
6
 
6
7
  export default function createApp(config: AuthHeroConfig) {
7
8
  const { app } = init(config);
@@ -20,7 +21,15 @@ export default function createApp(config: AuthHeroConfig) {
20
21
  status: "running",
21
22
  });
22
23
  })
23
- .get("/docs", swaggerUI({ url: "/api/v2/spec" }));
24
+ .get("/docs", swaggerUI({ url: "/api/v2/spec" }))
25
+ // Serve static assets (widget, CSS, JS) from authhero package
26
+ .get(
27
+ "/u/*",
28
+ serveStatic({
29
+ root: "./node_modules/authhero/dist/assets/u",
30
+ rewriteRequestPath: (path) => path.replace("/u", ""),
31
+ }),
32
+ );
24
33
 
25
34
  return app;
26
35
  }
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "https://github.com/markusahlstrand/authhero"
7
7
  },
8
- "version": "0.16.0",
8
+ "version": "0.18.0",
9
9
  "type": "module",
10
10
  "main": "dist/create-authhero.js",
11
11
  "bin": {