create-authhero 0.30.0 → 0.31.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,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { Command as U } from "commander";
2
+ import { Command as R } from "commander";
3
3
  import u from "inquirer";
4
- import s from "fs";
4
+ import a from "fs";
5
5
  import l from "path";
6
- import { spawn as _ } from "child_process";
7
- const I = new U(), p = {
6
+ import { spawn as I } from "child_process";
7
+ const T = new R(), p = {
8
8
  local: {
9
9
  name: "Local (SQLite)",
10
10
  description: "Local development setup with SQLite database - great for getting started",
@@ -134,13 +134,13 @@ const I = new U(), p = {
134
134
  }
135
135
  };
136
136
  function E(o, e) {
137
- s.readdirSync(o).forEach((n) => {
138
- const t = l.join(o, n), a = l.join(e, n);
139
- s.lstatSync(t).isDirectory() ? (s.mkdirSync(a, { recursive: !0 }), E(t, a)) : s.copyFileSync(t, a);
137
+ a.readdirSync(o).forEach((n) => {
138
+ const t = l.join(o, n), s = l.join(e, n);
139
+ a.lstatSync(t).isDirectory() ? (a.mkdirSync(s, { recursive: !0 }), E(t, s)) : a.copyFileSync(t, s);
140
140
  });
141
141
  }
142
- function j(o, e = !1, r = "authhero-local") {
143
- const n = o ? "control_plane" : "main", t = o ? "Control Plane" : "Main", a = [
142
+ function U(o, e = !1, r = "authhero-local") {
143
+ const n = o ? "control_plane" : "main", t = o ? "Control Plane" : "Main", s = [
144
144
  "https://manage.authhero.net/auth-callback",
145
145
  "https://local.authhero.net/auth-callback",
146
146
  "http://localhost:5173/auth-callback",
@@ -148,7 +148,7 @@ function j(o, e = !1, r = "authhero-local") {
148
148
  ], c = e ? [
149
149
  `https://localhost.emobix.co.uk:8443/test/a/${r}/callback`,
150
150
  `https://localhost:8443/test/a/${r}/callback`
151
- ] : [], g = [...a, ...c], w = [
151
+ ] : [], g = [...s, ...c], w = [
152
152
  "https://manage.authhero.net",
153
153
  "https://local.authhero.net",
154
154
  "http://localhost:5173",
@@ -210,7 +210,7 @@ function j(o, e = !1, r = "authhero-local") {
210
210
  // This is required for OIDCC-5.4 (VerifyScopesReturnedInUserInfoClaims) test
211
211
  try {
212
212
  await adapters.users.create("${n}", {
213
- user_id: "auth2|conformance-user",
213
+ user_id: \`\${USERNAME_PASSWORD_PROVIDER}|conformance-user\`,
214
214
  email: "conformance@example.com",
215
215
  email_verified: true,
216
216
  name: "Conformance Test User",
@@ -227,7 +227,7 @@ function j(o, e = !1, r = "authhero-local") {
227
227
  zoneinfo: "Europe/London",
228
228
  locale: "en-US",
229
229
  connection: "Username-Password-Authentication",
230
- provider: "auth2",
230
+ provider: USERNAME_PASSWORD_PROVIDER,
231
231
  is_social: false,
232
232
  });
233
233
  console.log("✅ Created conformance test user (conformance@example.com)");
@@ -245,7 +245,7 @@ function j(o, e = !1, r = "authhero-local") {
245
245
  const bcrypt = await import("bcryptjs");
246
246
  const hashedPassword = await bcrypt.hash("ConformanceTest123!", 10);
247
247
  await adapters.passwords.create("${n}", {
248
- user_id: "auth2|conformance-user",
248
+ user_id: \`\${USERNAME_PASSWORD_PROVIDER}|conformance-user\`,
249
249
  password: hashedPassword,
250
250
  });
251
251
  console.log("✅ Created password for conformance test user");
@@ -289,7 +289,7 @@ ${b}
289
289
  main().catch(console.error);
290
290
  `;
291
291
  }
292
- function L(o) {
292
+ function O(o) {
293
293
  return o ? `import { Context } from "hono";
294
294
  import { swaggerUI } from "@hono/swagger-ui";
295
295
  import { AuthHeroConfig, DataAdapters } from "authhero";
@@ -393,7 +393,7 @@ export default function createApp(config: AuthHeroConfig) {
393
393
  }
394
394
  `;
395
395
  }
396
- function R(o) {
396
+ function j(o) {
397
397
  return `import { D1Dialect } from "kysely-d1";
398
398
  import { Kysely } from "kysely";
399
399
  import createAdapters from "@authhero/kysely-adapter";
@@ -453,7 +453,7 @@ export default {
453
453
  };
454
454
  `;
455
455
  }
456
- function O(o) {
456
+ function L(o) {
457
457
  return o ? `import { Context } from "hono";
458
458
  import { swaggerUI } from "@hono/swagger-ui";
459
459
  import { AuthHeroConfig, DataAdapters } from "authhero";
@@ -681,20 +681,20 @@ main().catch(console.error);
681
681
  }
682
682
  function H(o, e) {
683
683
  const r = l.join(o, "src");
684
- s.writeFileSync(
684
+ a.writeFileSync(
685
685
  l.join(r, "app.ts"),
686
686
  $(e)
687
- ), s.writeFileSync(
687
+ ), a.writeFileSync(
688
688
  l.join(r, "seed.ts"),
689
689
  M(e)
690
690
  );
691
691
  }
692
- function x(o) {
692
+ function D(o) {
693
693
  console.log("\\n" + "─".repeat(50)), console.log("🔐 AuthHero deployed to AWS!"), console.log("📚 Check SST output for your API URL"), console.log("🌐 Portal available at https://local.authhero.net"), console.log(o ? "🏢 Multi-tenant mode enabled with control_plane tenant" : "🏠 Single-tenant mode with 'main' tenant"), console.log("─".repeat(50) + "\\n");
694
694
  }
695
695
  function F(o) {
696
696
  const e = l.join(o, ".github", "workflows");
697
- s.mkdirSync(e, { recursive: !0 });
697
+ a.mkdirSync(e, { recursive: !0 });
698
698
  const r = `name: Unit tests
699
699
 
700
700
  on: push
@@ -781,7 +781,7 @@ jobs:
781
781
  apiToken: \${{ secrets.PROD_CLOUDFLARE_API_TOKEN }}
782
782
  command: deploy --env production
783
783
  `;
784
- s.writeFileSync(l.join(e, "unit-tests.yml"), r), s.writeFileSync(l.join(e, "deploy-dev.yml"), n), s.writeFileSync(l.join(e, "release.yml"), t), console.log("\\n📦 GitHub CI workflows created!");
784
+ a.writeFileSync(l.join(e, "unit-tests.yml"), r), a.writeFileSync(l.join(e, "deploy-dev.yml"), n), a.writeFileSync(l.join(e, "release.yml"), t), console.log("\\n📦 GitHub CI workflows created!");
785
785
  }
786
786
  function W(o) {
787
787
  const e = {
@@ -792,11 +792,11 @@ function W(o) {
792
792
  "@semantic-release/github"
793
793
  ]
794
794
  };
795
- s.writeFileSync(
795
+ a.writeFileSync(
796
796
  l.join(o, ".releaserc.json"),
797
797
  JSON.stringify(e, null, 2)
798
798
  );
799
- const r = l.join(o, "package.json"), n = JSON.parse(s.readFileSync(r, "utf-8"));
799
+ const r = l.join(o, "package.json"), n = JSON.parse(a.readFileSync(r, "utf-8"));
800
800
  n.devDependencies = {
801
801
  ...n.devDependencies,
802
802
  "semantic-release": "^24.0.0"
@@ -804,54 +804,54 @@ function W(o) {
804
804
  ...n.scripts,
805
805
  test: 'echo "No tests yet"',
806
806
  "type-check": "tsc --noEmit"
807
- }, s.writeFileSync(r, JSON.stringify(n, null, 2));
807
+ }, a.writeFileSync(r, JSON.stringify(n, null, 2));
808
808
  }
809
- function S(o, e) {
809
+ function A(o, e) {
810
810
  return new Promise((r, n) => {
811
- const t = _(o, [], {
811
+ const t = I(o, [], {
812
812
  cwd: e,
813
813
  shell: !0,
814
814
  stdio: "inherit"
815
815
  });
816
- t.on("close", (a) => {
817
- a === 0 ? r() : n(new Error(`Command failed with exit code ${a}`));
816
+ t.on("close", (s) => {
817
+ s === 0 ? r() : n(new Error(`Command failed with exit code ${s}`));
818
818
  }), t.on("error", n);
819
819
  });
820
820
  }
821
- function N(o, e, r) {
821
+ function _(o, e, r) {
822
822
  return new Promise((n, t) => {
823
- const a = _(o, [], {
823
+ const s = I(o, [], {
824
824
  cwd: e,
825
825
  shell: !0,
826
826
  stdio: "inherit",
827
827
  env: { ...process.env, ...r }
828
828
  });
829
- a.on("close", (c) => {
829
+ s.on("close", (c) => {
830
830
  c === 0 ? n() : t(new Error(`Command failed with exit code ${c}`));
831
- }), a.on("error", t);
831
+ }), s.on("error", t);
832
832
  });
833
833
  }
834
834
  function q(o, e) {
835
835
  const r = l.join(o, "src");
836
- s.writeFileSync(
836
+ a.writeFileSync(
837
837
  l.join(r, "app.ts"),
838
- O(e)
839
- ), s.writeFileSync(
838
+ L(e)
839
+ ), a.writeFileSync(
840
840
  l.join(r, "seed.ts"),
841
- R(e)
841
+ j(e)
842
842
  );
843
843
  }
844
- function D(o) {
844
+ function x(o) {
845
845
  console.log(`
846
846
  ` + "─".repeat(50)), console.log("🔐 AuthHero server running at https://localhost:3000"), console.log("📚 API documentation available at https://localhost:3000/docs"), console.log("🌐 Portal available at https://local.authhero.net"), console.log(o ? "🏢 Multi-tenant mode enabled with control_plane tenant" : "🏠 Single-tenant mode with 'main' tenant"), console.log("─".repeat(50) + `
847
847
  `);
848
848
  }
849
- function T(o) {
849
+ function N(o) {
850
850
  console.log(`
851
851
  ` + "─".repeat(50)), console.log("✅ Self-signed certificates generated with openssl"), console.log("⚠️ You may need to trust the certificate in your browser"), console.log("🔐 AuthHero server running at https://localhost:3000"), console.log("📚 API documentation available at https://localhost:3000/docs"), console.log("🌐 Portal available at https://local.authhero.net"), console.log(o ? "🏢 Multi-tenant mode enabled with control_plane tenant" : "🏠 Single-tenant mode with 'main' tenant"), console.log("─".repeat(50) + `
852
852
  `);
853
853
  }
854
- I.version("1.0.0").description("Create a new AuthHero project").argument("[project-name]", "name of the project").option("-t, --template <type>", "template type: local or cloudflare").option("-e, --email <email>", "admin email address").option("-p, --password <password>", "admin password (min 8 characters)").option(
854
+ T.version("1.0.0").description("Create a new AuthHero project").argument("[project-name]", "name of the project").option("-t, --template <type>", "template type: local or cloudflare").option("-e, --email <email>", "admin email address").option("-p, --password <password>", "admin password (min 8 characters)").option(
855
855
  "--package-manager <pm>",
856
856
  "package manager to use: npm, yarn, pnpm, or bun"
857
857
  ).option("--multi-tenant", "enable multi-tenant mode").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("--conformance", "add OpenID conformance suite test clients").option(
@@ -873,9 +873,9 @@ I.version("1.0.0").description("Create a new AuthHero project").argument("[proje
873
873
  }
874
874
  ])).projectName);
875
875
  const t = l.join(process.cwd(), n);
876
- s.existsSync(t) && (console.error(`❌ Project "${n}" already exists.`), process.exit(1));
877
- let a;
878
- e.template ? (["local", "cloudflare", "aws-sst"].includes(e.template) || (console.error(`❌ Invalid template: ${e.template}`), console.error("Valid options: local, cloudflare, aws-sst"), process.exit(1)), a = e.template, console.log(`Using template: ${p[a].name}`)) : a = (await u.prompt([
876
+ a.existsSync(t) && (console.error(`❌ Project "${n}" already exists.`), process.exit(1));
877
+ let s;
878
+ e.template ? (["local", "cloudflare", "aws-sst"].includes(e.template) || (console.error(`❌ Invalid template: ${e.template}`), console.error("Valid options: local, cloudflare, aws-sst"), process.exit(1)), s = e.template, console.log(`Using template: ${p[s].name}`)) : s = (await u.prompt([
879
879
  {
880
880
  type: "list",
881
881
  name: "setupType",
@@ -918,8 +918,8 @@ I.version("1.0.0").description("Create a new AuthHero project").argument("[proje
918
918
  );
919
919
  const C = e.workspace || !1;
920
920
  C && console.log("Workspace mode: enabled (using workspace:* dependencies)");
921
- const y = p[a];
922
- s.mkdirSync(t, { recursive: !0 }), s.writeFileSync(
921
+ const y = p[s];
922
+ a.mkdirSync(t, { recursive: !0 }), a.writeFileSync(
923
923
  l.join(t, "package.json"),
924
924
  JSON.stringify(y.packageJson(n, c, g, C), null, 2)
925
925
  );
@@ -927,33 +927,33 @@ I.version("1.0.0").description("Create a new AuthHero project").argument("[proje
927
927
  import.meta.url.replace("file://", "").replace("/create-authhero.js", ""),
928
928
  b
929
929
  );
930
- if (s.existsSync(k) ? E(k, t) : (console.error(`❌ Template directory not found: ${k}`), process.exit(1)), a === "cloudflare" && q(t, c), a === "cloudflare") {
930
+ if (a.existsSync(k) ? E(k, t) : (console.error(`❌ Template directory not found: ${k}`), process.exit(1)), s === "cloudflare" && q(t, c), s === "cloudflare") {
931
931
  const i = l.join(t, "wrangler.toml"), d = l.join(t, "wrangler.local.toml");
932
- s.existsSync(i) && s.copyFileSync(i, d);
932
+ a.existsSync(i) && a.copyFileSync(i, d);
933
933
  const m = l.join(t, ".dev.vars.example"), f = l.join(t, ".dev.vars");
934
- s.existsSync(m) && s.copyFileSync(m, f), console.log(
934
+ a.existsSync(m) && a.copyFileSync(m, f), console.log(
935
935
  "📁 Created wrangler.local.toml and .dev.vars for local development"
936
936
  );
937
937
  }
938
- let A = !1;
939
- if (a === "cloudflare" && (e.githubCi !== void 0 ? (A = e.githubCi, A && console.log("Including GitHub CI workflows with semantic versioning")) : r || (A = (await u.prompt([
938
+ let S = !1;
939
+ if (s === "cloudflare" && (e.githubCi !== void 0 ? (S = e.githubCi, S && console.log("Including GitHub CI workflows with semantic versioning")) : r || (S = (await u.prompt([
940
940
  {
941
941
  type: "confirm",
942
942
  name: "includeGithubCi",
943
943
  message: "Would you like to include GitHub CI with semantic versioning?",
944
944
  default: !1
945
945
  }
946
- ])).includeGithubCi), A && (F(t), W(t))), a === "local") {
947
- const i = j(
946
+ ])).includeGithubCi), S && (F(t), W(t))), s === "local") {
947
+ const i = U(
948
948
  c,
949
949
  g,
950
950
  w
951
951
  );
952
- s.writeFileSync(l.join(t, "src/seed.ts"), i);
953
- const d = L(c);
954
- s.writeFileSync(l.join(t, "src/app.ts"), d);
952
+ a.writeFileSync(l.join(t, "src/seed.ts"), i);
953
+ const d = O(c);
954
+ a.writeFileSync(l.join(t, "src/app.ts"), d);
955
955
  }
956
- if (a === "aws-sst" && H(t, c), g) {
956
+ if (s === "aws-sst" && H(t, c), g) {
957
957
  const i = {
958
958
  alias: w,
959
959
  description: "AuthHero Conformance Test",
@@ -972,7 +972,7 @@ I.version("1.0.0").description("Create a new AuthHero project").argument("[proje
972
972
  resourceUrl: "http://host.docker.internal:3000/userinfo"
973
973
  }
974
974
  };
975
- s.writeFileSync(
975
+ a.writeFileSync(
976
976
  l.join(t, "conformance-config.json"),
977
977
  JSON.stringify(i, null, 2)
978
978
  ), console.log(
@@ -1015,11 +1015,11 @@ I.version("1.0.0").description("Create a new AuthHero project").argument("[proje
1015
1015
  `);
1016
1016
  try {
1017
1017
  const d = i === "pnpm" ? "pnpm install --ignore-workspace" : `${i} install`;
1018
- if (await S(d, t), a === "local" && (console.log(`
1018
+ if (await A(d, t), s === "local" && (console.log(`
1019
1019
  🔧 Building native modules...
1020
- `), await S("npm rebuild better-sqlite3", t)), console.log(`
1020
+ `), await A("npm rebuild better-sqlite3", t)), console.log(`
1021
1021
  ✅ Dependencies installed successfully!
1022
- `), a === "local" || a === "cloudflare") {
1022
+ `), s === "local" || s === "cloudflare") {
1023
1023
  let f;
1024
1024
  if (e.skipMigrate && e.skipSeed ? f = !1 : r ? f = !e.skipMigrate || !e.skipSeed : f = (await u.prompt([
1025
1025
  {
@@ -1049,16 +1049,16 @@ I.version("1.0.0").description("Create a new AuthHero project").argument("[proje
1049
1049
  }
1050
1050
  ]), e.skipMigrate || (console.log(`
1051
1051
  🔄 Running migrations...
1052
- `), await S(`${i} run migrate`, t)), e.skipSeed || (console.log(`
1052
+ `), await A(`${i} run migrate`, t)), e.skipSeed || (console.log(`
1053
1053
  🌱 Seeding database...
1054
- `), a === "local" ? await N(
1054
+ `), s === "local" ? await _(
1055
1055
  `${i} run seed`,
1056
1056
  t,
1057
1057
  {
1058
1058
  ADMIN_USERNAME: h.username,
1059
1059
  ADMIN_PASSWORD: h.password
1060
1060
  }
1061
- ) : await N(
1061
+ ) : await _(
1062
1062
  `${i} run seed:local`,
1063
1063
  t,
1064
1064
  {
@@ -1076,22 +1076,22 @@ I.version("1.0.0").description("Create a new AuthHero project").argument("[proje
1076
1076
  message: "Would you like to start the development server?",
1077
1077
  default: !0
1078
1078
  }
1079
- ])).shouldStart, m && (a === "cloudflare" ? D(c) : a === "aws-sst" ? x(c) : T(c), console.log(`🚀 Starting development server...
1080
- `), await S(`${i} run dev`, t)), r && !m && (console.log(`
1079
+ ])).shouldStart, m && (s === "cloudflare" ? x(c) : s === "aws-sst" ? D(c) : N(c), console.log(`🚀 Starting development server...
1080
+ `), await A(`${i} run dev`, t)), r && !m && (console.log(`
1081
1081
  ✅ Setup complete!`), console.log(`
1082
- To start the development server:`), console.log(` cd ${n}`), console.log(" npm run dev"), a === "cloudflare" ? D(c) : a === "aws-sst" ? x(c) : T(c));
1082
+ To start the development server:`), console.log(` cd ${n}`), console.log(" npm run dev"), s === "cloudflare" ? x(c) : s === "aws-sst" ? D(c) : N(c));
1083
1083
  } catch (d) {
1084
1084
  console.error(`
1085
1085
  ❌ An error occurred:`, d), process.exit(1);
1086
1086
  }
1087
1087
  }
1088
- v || (console.log("Next steps:"), console.log(` cd ${n}`), a === "local" ? (console.log(" npm install"), console.log(" npm run migrate"), console.log(
1088
+ v || (console.log("Next steps:"), console.log(` cd ${n}`), s === "local" ? (console.log(" npm install"), console.log(" npm run migrate"), console.log(
1089
1089
  " npm run seed # defaults to admin/admin"
1090
- ), console.log(" npm run dev")) : a === "cloudflare" ? (console.log(" npm install"), console.log(
1090
+ ), console.log(" npm run dev")) : s === "cloudflare" ? (console.log(" npm install"), console.log(
1091
1091
  " npm run migrate # or npm run db:migrate:remote for production"
1092
1092
  ), console.log(
1093
1093
  " npm run seed # defaults to admin/admin"
1094
- ), console.log(" npm run dev # or npm run dev:remote for production")) : a === "aws-sst" && (console.log(" npm install"), console.log(" npm run dev # Deploys to AWS in development mode"), console.log(" # After deploy, get TABLE_NAME from output, then:"), console.log(
1094
+ ), console.log(" npm run dev # or npm run dev:remote for production")) : s === "aws-sst" && (console.log(" npm install"), console.log(" npm run dev # Deploys to AWS in development mode"), console.log(" # After deploy, get TABLE_NAME from output, then:"), console.log(
1095
1095
  " TABLE_NAME=<your-table> npm run seed # defaults to admin/admin"
1096
1096
  )), console.log(`
1097
1097
  Server will be available at: https://localhost:3000`), console.log("Portal available at: https://local.authhero.net"), g && (console.log(`
@@ -1105,4 +1105,4 @@ Server will be available at: https://localhost:3000`), console.log("Portal avail
1105
1105
  For more information, visit: https://authhero.net/docs
1106
1106
  `));
1107
1107
  });
1108
- I.parse(process.argv);
1108
+ T.parse(process.argv);
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.30.0",
8
+ "version": "0.31.0",
9
9
  "type": "module",
10
10
  "main": "dist/create-authhero.js",
11
11
  "bin": {