create-authhero 0.40.0 → 0.41.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.
- package/dist/create-authhero.js +85 -80
- package/package.json +2 -1
package/dist/create-authhero.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { Command as
|
|
2
|
+
import { Command as R } from "commander";
|
|
3
3
|
import m from "inquirer";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
4
|
+
import i from "fs";
|
|
5
|
+
import a from "path";
|
|
6
|
+
import { fileURLToPath as U } from "url";
|
|
7
|
+
import { spawn as O } from "child_process";
|
|
8
|
+
const T = new R(), p = {
|
|
8
9
|
local: {
|
|
9
10
|
name: "Local (SQLite)",
|
|
10
11
|
description: "Local development setup with SQLite database - great for getting started",
|
|
@@ -136,13 +137,13 @@ const D = new P(), p = {
|
|
|
136
137
|
seedFile: "seed.ts"
|
|
137
138
|
}
|
|
138
139
|
};
|
|
139
|
-
function
|
|
140
|
-
|
|
141
|
-
const n =
|
|
142
|
-
|
|
140
|
+
function P(s, e) {
|
|
141
|
+
i.readdirSync(s).forEach((r) => {
|
|
142
|
+
const n = a.join(s, r), t = a.join(e, r);
|
|
143
|
+
i.lstatSync(n).isDirectory() ? (i.mkdirSync(t, { recursive: !0 }), P(n, t)) : i.copyFileSync(n, t);
|
|
143
144
|
});
|
|
144
145
|
}
|
|
145
|
-
function
|
|
146
|
+
function L(s, e = !1, o = "authhero-local", r) {
|
|
146
147
|
const n = s ? "control_plane" : "main", t = s ? "Control Plane" : "Main", c = [
|
|
147
148
|
"https://manage.authhero.net/auth-callback",
|
|
148
149
|
"https://local.authhero.net/auth-callback",
|
|
@@ -157,7 +158,7 @@ function R(s, e = !1, o = "authhero-local", r) {
|
|
|
157
158
|
"https://local.authhero.net",
|
|
158
159
|
"http://localhost:5173",
|
|
159
160
|
"http://localhost:3000"
|
|
160
|
-
], C = e ? ["https://localhost:8443/", "https://localhost.emobix.co.uk:8443/"] : [], y = [...h, ...C],
|
|
161
|
+
], C = e ? ["https://localhost:8443/", "https://localhost.emobix.co.uk:8443/"] : [], y = [...h, ...C], A = e ? `
|
|
161
162
|
// Create OpenID Conformance Suite test clients and user
|
|
162
163
|
console.log("Creating conformance test clients and user...");
|
|
163
164
|
|
|
@@ -361,7 +362,7 @@ async function main() {
|
|
|
361
362
|
await adapters.users.update(seedResult.tenantId, seedResult.userId, userProfile);
|
|
362
363
|
console.log(\`✅ Updated profile of user "\${seedResult.username}"\`);
|
|
363
364
|
}
|
|
364
|
-
${
|
|
365
|
+
${A}
|
|
365
366
|
await db.destroy();
|
|
366
367
|
}
|
|
367
368
|
|
|
@@ -371,7 +372,7 @@ main().catch((err) => {
|
|
|
371
372
|
});
|
|
372
373
|
`;
|
|
373
374
|
}
|
|
374
|
-
function
|
|
375
|
+
function $(s, e) {
|
|
375
376
|
const o = e ? `import fs from "fs";
|
|
376
377
|
` : "", r = e ? `
|
|
377
378
|
const adminDistPath = path.resolve(
|
|
@@ -507,7 +508,7 @@ ${n}
|
|
|
507
508
|
}
|
|
508
509
|
`;
|
|
509
510
|
}
|
|
510
|
-
function
|
|
511
|
+
function j(s) {
|
|
511
512
|
return `import { D1Dialect } from "kysely-d1";
|
|
512
513
|
import { Kysely } from "kysely";
|
|
513
514
|
import createAdapters from "@authhero/kysely-adapter";
|
|
@@ -568,7 +569,7 @@ export default {
|
|
|
568
569
|
};
|
|
569
570
|
`;
|
|
570
571
|
}
|
|
571
|
-
function
|
|
572
|
+
function H(s, e) {
|
|
572
573
|
const o = e ? `import adminIndexHtml from "./admin-index-html";
|
|
573
574
|
` : "", r = e ? ` adminIndexHtml,
|
|
574
575
|
` : "";
|
|
@@ -653,7 +654,7 @@ ${r} });
|
|
|
653
654
|
}
|
|
654
655
|
`;
|
|
655
656
|
}
|
|
656
|
-
function
|
|
657
|
+
function F(s) {
|
|
657
658
|
return s ? `import { Context } from "hono";
|
|
658
659
|
import { swaggerUI } from "@hono/swagger-ui";
|
|
659
660
|
import { AuthHeroConfig, DataAdapters } from "authhero";
|
|
@@ -759,7 +760,7 @@ export default function createApp(config: AppConfig) {
|
|
|
759
760
|
}
|
|
760
761
|
`;
|
|
761
762
|
}
|
|
762
|
-
function
|
|
763
|
+
function M(s) {
|
|
763
764
|
return `import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
|
|
764
765
|
import { DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb";
|
|
765
766
|
import createAdapters from "@authhero/aws";
|
|
@@ -799,22 +800,22 @@ async function main() {
|
|
|
799
800
|
main().catch(console.error);
|
|
800
801
|
`;
|
|
801
802
|
}
|
|
802
|
-
function
|
|
803
|
-
const o =
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
),
|
|
808
|
-
|
|
809
|
-
|
|
803
|
+
function W(s, e) {
|
|
804
|
+
const o = a.join(s, "src");
|
|
805
|
+
i.writeFileSync(
|
|
806
|
+
a.join(o, "app.ts"),
|
|
807
|
+
F(e)
|
|
808
|
+
), i.writeFileSync(
|
|
809
|
+
a.join(o, "seed.ts"),
|
|
810
|
+
M(e)
|
|
810
811
|
);
|
|
811
812
|
}
|
|
812
|
-
function
|
|
813
|
+
function I() {
|
|
813
814
|
console.log("\\n" + "─".repeat(50)), console.log("🔐 AuthHero deployed to AWS!"), console.log("📚 Check SST output for your API URL"), console.log("🚀 Open your server URL /setup to complete initial setup"), console.log("🌐 Portal available at https://local.authhero.net"), console.log("─".repeat(50) + "\\n");
|
|
814
815
|
}
|
|
815
|
-
function
|
|
816
|
-
const e =
|
|
817
|
-
|
|
816
|
+
function q(s) {
|
|
817
|
+
const e = a.join(s, ".github", "workflows");
|
|
818
|
+
i.mkdirSync(e, { recursive: !0 });
|
|
818
819
|
const o = `name: Unit tests
|
|
819
820
|
|
|
820
821
|
on: push
|
|
@@ -901,9 +902,9 @@ jobs:
|
|
|
901
902
|
apiToken: \${{ secrets.PROD_CLOUDFLARE_API_TOKEN }}
|
|
902
903
|
command: deploy --env production
|
|
903
904
|
`;
|
|
904
|
-
|
|
905
|
+
i.writeFileSync(a.join(e, "unit-tests.yml"), o), i.writeFileSync(a.join(e, "deploy-dev.yml"), r), i.writeFileSync(a.join(e, "release.yml"), n), console.log("\\n📦 GitHub CI workflows created!");
|
|
905
906
|
}
|
|
906
|
-
function
|
|
907
|
+
function J(s) {
|
|
907
908
|
const e = {
|
|
908
909
|
branches: ["main"],
|
|
909
910
|
plugins: [
|
|
@@ -912,11 +913,11 @@ function M(s) {
|
|
|
912
913
|
"@semantic-release/github"
|
|
913
914
|
]
|
|
914
915
|
};
|
|
915
|
-
|
|
916
|
-
|
|
916
|
+
i.writeFileSync(
|
|
917
|
+
a.join(s, ".releaserc.json"),
|
|
917
918
|
JSON.stringify(e, null, 2)
|
|
918
919
|
);
|
|
919
|
-
const o =
|
|
920
|
+
const o = a.join(s, "package.json"), r = JSON.parse(i.readFileSync(o, "utf-8"));
|
|
920
921
|
r.devDependencies = {
|
|
921
922
|
...r.devDependencies,
|
|
922
923
|
"semantic-release": "^24.0.0"
|
|
@@ -924,11 +925,11 @@ function M(s) {
|
|
|
924
925
|
...r.scripts,
|
|
925
926
|
test: 'echo "No tests yet"',
|
|
926
927
|
"type-check": "tsc --noEmit"
|
|
927
|
-
},
|
|
928
|
+
}, i.writeFileSync(o, JSON.stringify(r, null, 2));
|
|
928
929
|
}
|
|
929
|
-
function
|
|
930
|
+
function b(s, e) {
|
|
930
931
|
return new Promise((o, r) => {
|
|
931
|
-
const n =
|
|
932
|
+
const n = O(s, [], {
|
|
932
933
|
cwd: e,
|
|
933
934
|
shell: !0,
|
|
934
935
|
stdio: "inherit"
|
|
@@ -938,27 +939,27 @@ function _(s, e) {
|
|
|
938
939
|
}), n.on("error", r);
|
|
939
940
|
});
|
|
940
941
|
}
|
|
941
|
-
function
|
|
942
|
-
const r =
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
),
|
|
947
|
-
|
|
948
|
-
|
|
942
|
+
function z(s, e, o) {
|
|
943
|
+
const r = a.join(s, "src");
|
|
944
|
+
i.writeFileSync(
|
|
945
|
+
a.join(r, "app.ts"),
|
|
946
|
+
H(e, o)
|
|
947
|
+
), i.writeFileSync(
|
|
948
|
+
a.join(r, "seed.ts"),
|
|
949
|
+
j(e)
|
|
949
950
|
);
|
|
950
951
|
}
|
|
951
|
-
function
|
|
952
|
+
function D() {
|
|
952
953
|
console.log(`
|
|
953
954
|
` + "─".repeat(50)), console.log("🔐 AuthHero server running at https://localhost:3000"), console.log("🚀 Open https://localhost:3000/setup to complete initial setup"), console.log("─".repeat(50) + `
|
|
954
955
|
`);
|
|
955
956
|
}
|
|
956
|
-
function
|
|
957
|
+
function N() {
|
|
957
958
|
console.log(`
|
|
958
959
|
` + "─".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 http://localhost:3000"), console.log("📚 API documentation available at http://localhost:3000/docs"), console.log("🚀 Open http://localhost:3000/setup to complete initial setup"), console.log("─".repeat(50) + `
|
|
959
960
|
`);
|
|
960
961
|
}
|
|
961
|
-
|
|
962
|
+
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(
|
|
962
963
|
"--package-manager <pm>",
|
|
963
964
|
"package manager to use: npm, yarn, pnpm, or bun"
|
|
964
965
|
).option("--multi-tenant", "enable multi-tenant mode").option("--admin-ui", "include admin UI at /admin").option("--skip-install", "skip installing dependencies").option("--skip-migrate", "skip running database migrations").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(
|
|
@@ -982,8 +983,8 @@ D.version("1.0.0").description("Create a new AuthHero project").argument("[proje
|
|
|
982
983
|
validate: (u) => u !== "" || "Project name cannot be empty"
|
|
983
984
|
}
|
|
984
985
|
])).projectName);
|
|
985
|
-
const n =
|
|
986
|
-
|
|
986
|
+
const n = a.join(process.cwd(), r);
|
|
987
|
+
i.existsSync(n) && (console.error(`❌ Project "${r}" already exists.`), process.exit(1));
|
|
987
988
|
let t;
|
|
988
989
|
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)), t = e.template, console.log(`Using template: ${p[t].name}`)) : t = (await m.prompt([
|
|
989
990
|
{
|
|
@@ -1037,8 +1038,8 @@ D.version("1.0.0").description("Create a new AuthHero project").argument("[proje
|
|
|
1037
1038
|
const C = e.workspace || !1;
|
|
1038
1039
|
C && console.log("Workspace mode: enabled (using workspace:* dependencies)");
|
|
1039
1040
|
const y = p[t];
|
|
1040
|
-
|
|
1041
|
-
|
|
1041
|
+
i.mkdirSync(n, { recursive: !0 }), i.writeFileSync(
|
|
1042
|
+
a.join(n, "package.json"),
|
|
1042
1043
|
JSON.stringify(
|
|
1043
1044
|
y.packageJson(
|
|
1044
1045
|
r,
|
|
@@ -1051,38 +1052,42 @@ D.version("1.0.0").description("Create a new AuthHero project").argument("[proje
|
|
|
1051
1052
|
2
|
|
1052
1053
|
)
|
|
1053
1054
|
);
|
|
1054
|
-
const
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
);
|
|
1058
|
-
if (
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1055
|
+
const A = y.templateDir, S = a.dirname(U(import.meta.url)), x = [
|
|
1056
|
+
a.join(S, A),
|
|
1057
|
+
a.join(S, "..", "templates", A)
|
|
1058
|
+
], k = x.find((l) => i.existsSync(l));
|
|
1059
|
+
if (k ? P(k, n) : (console.error(
|
|
1060
|
+
`❌ Template directory not found. Looked in:
|
|
1061
|
+
${x.join(`
|
|
1062
|
+
`)}`
|
|
1063
|
+
), process.exit(1)), t === "cloudflare" && z(n, c, d), t === "cloudflare") {
|
|
1064
|
+
const l = a.join(n, "wrangler.toml"), u = a.join(n, "wrangler.local.toml");
|
|
1065
|
+
i.existsSync(l) && i.copyFileSync(l, u);
|
|
1066
|
+
const g = a.join(n, ".dev.vars.example"), w = a.join(n, ".dev.vars");
|
|
1067
|
+
i.existsSync(g) && i.copyFileSync(g, w), console.log(
|
|
1063
1068
|
"📁 Created wrangler.local.toml and .dev.vars for local development"
|
|
1064
1069
|
);
|
|
1065
1070
|
}
|
|
1066
|
-
let
|
|
1067
|
-
if (t === "cloudflare" && (e.githubCi !== void 0 ? (
|
|
1071
|
+
let _ = !1;
|
|
1072
|
+
if (t === "cloudflare" && (e.githubCi !== void 0 ? (_ = e.githubCi, _ && console.log("Including GitHub CI workflows with semantic versioning")) : o || (_ = (await m.prompt([
|
|
1068
1073
|
{
|
|
1069
1074
|
type: "confirm",
|
|
1070
1075
|
name: "includeGithubCi",
|
|
1071
1076
|
message: "Would you like to include GitHub CI with semantic versioning?",
|
|
1072
1077
|
default: !1
|
|
1073
1078
|
}
|
|
1074
|
-
])).includeGithubCi),
|
|
1075
|
-
const l =
|
|
1079
|
+
])).includeGithubCi), _ && (q(n), J(n))), t === "local") {
|
|
1080
|
+
const l = L(
|
|
1076
1081
|
c,
|
|
1077
1082
|
f,
|
|
1078
1083
|
h,
|
|
1079
1084
|
d
|
|
1080
1085
|
);
|
|
1081
|
-
|
|
1082
|
-
const u =
|
|
1083
|
-
|
|
1086
|
+
i.writeFileSync(a.join(n, "src/seed.ts"), l);
|
|
1087
|
+
const u = $(c, d);
|
|
1088
|
+
i.writeFileSync(a.join(n, "src/app.ts"), u);
|
|
1084
1089
|
}
|
|
1085
|
-
if (t === "aws-sst" &&
|
|
1090
|
+
if (t === "aws-sst" && W(n, c), f) {
|
|
1086
1091
|
const l = {
|
|
1087
1092
|
alias: h,
|
|
1088
1093
|
description: "AuthHero Conformance Test",
|
|
@@ -1101,17 +1106,17 @@ D.version("1.0.0").description("Create a new AuthHero project").argument("[proje
|
|
|
1101
1106
|
resourceUrl: "http://host.docker.internal:3000/userinfo"
|
|
1102
1107
|
}
|
|
1103
1108
|
};
|
|
1104
|
-
|
|
1105
|
-
|
|
1109
|
+
i.writeFileSync(
|
|
1110
|
+
a.join(n, "conformance-config.json"),
|
|
1106
1111
|
JSON.stringify(l, null, 2)
|
|
1107
1112
|
), console.log(
|
|
1108
1113
|
"📝 Created conformance-config.json for OpenID Conformance Suite"
|
|
1109
1114
|
);
|
|
1110
1115
|
}
|
|
1111
|
-
const
|
|
1116
|
+
const E = c ? "multi-tenant" : "single-tenant";
|
|
1112
1117
|
console.log(
|
|
1113
1118
|
`
|
|
1114
|
-
✅ Project "${r}" has been created with ${y.name} (${
|
|
1119
|
+
✅ Project "${r}" has been created with ${y.name} (${E}) setup!
|
|
1115
1120
|
`
|
|
1116
1121
|
);
|
|
1117
1122
|
let v;
|
|
@@ -1144,9 +1149,9 @@ D.version("1.0.0").description("Create a new AuthHero project").argument("[proje
|
|
|
1144
1149
|
`);
|
|
1145
1150
|
try {
|
|
1146
1151
|
const u = l === "pnpm" ? "pnpm install --ignore-workspace" : `${l} install`;
|
|
1147
|
-
if (await
|
|
1152
|
+
if (await b(u, n), t === "local" && (console.log(`
|
|
1148
1153
|
🔧 Building native modules...
|
|
1149
|
-
`), await
|
|
1154
|
+
`), await b("npm rebuild better-sqlite3", n)), console.log(`
|
|
1150
1155
|
✅ Dependencies installed successfully!
|
|
1151
1156
|
`), (t === "local" || t === "cloudflare") && !e.skipMigrate) {
|
|
1152
1157
|
let w;
|
|
@@ -1159,7 +1164,7 @@ D.version("1.0.0").description("Create a new AuthHero project").argument("[proje
|
|
|
1159
1164
|
}
|
|
1160
1165
|
])).shouldMigrate, w && (console.log(`
|
|
1161
1166
|
🔄 Running migrations...
|
|
1162
|
-
`), await
|
|
1167
|
+
`), await b(`${l} run migrate`, n));
|
|
1163
1168
|
}
|
|
1164
1169
|
let g;
|
|
1165
1170
|
e.skipStart || o ? g = !1 : g = (await m.prompt([
|
|
@@ -1169,10 +1174,10 @@ D.version("1.0.0").description("Create a new AuthHero project").argument("[proje
|
|
|
1169
1174
|
message: "Would you like to start the development server?",
|
|
1170
1175
|
default: !0
|
|
1171
1176
|
}
|
|
1172
|
-
])).shouldStart, g && (t === "cloudflare" ?
|
|
1173
|
-
`), await
|
|
1177
|
+
])).shouldStart, g && (t === "cloudflare" ? D() : t === "aws-sst" ? I() : N(), console.log(`🚀 Starting development server...
|
|
1178
|
+
`), await b(`${l} run dev`, n)), o && !g && (console.log(`
|
|
1174
1179
|
✅ Setup complete!`), console.log(`
|
|
1175
|
-
To start the development server:`), console.log(` cd ${r}`), console.log(" npm run dev"), t === "cloudflare" ?
|
|
1180
|
+
To start the development server:`), console.log(` cd ${r}`), console.log(" npm run dev"), t === "cloudflare" ? D() : t === "aws-sst" ? I() : N());
|
|
1176
1181
|
} catch (u) {
|
|
1177
1182
|
console.error(`
|
|
1178
1183
|
❌ An error occurred:`, u), process.exit(1);
|
|
@@ -1199,4 +1204,4 @@ Server will be available at: http://localhost:3000`), f && (console.log(`
|
|
|
1199
1204
|
For more information, visit: https://authhero.net/docs
|
|
1200
1205
|
`));
|
|
1201
1206
|
});
|
|
1202
|
-
|
|
1207
|
+
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.
|
|
8
|
+
"version": "0.41.0",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"main": "dist/create-authhero.js",
|
|
11
11
|
"bin": {
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
21
21
|
"@types/inquirer": "^9.0.7",
|
|
22
22
|
"@types/node": "^20.14.9",
|
|
23
|
+
"tsx": "^4.19.4",
|
|
23
24
|
"typescript": "^5.5.2",
|
|
24
25
|
"vite": "^5.3.2"
|
|
25
26
|
},
|