create-authhero 0.41.1 → 0.42.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/cloudflare/copy-assets.js +2 -2
- package/dist/create-authhero.js +119 -101
- package/dist/local/src/app.ts +1 -1
- package/dist/local/src/index.ts +8 -1
- package/package.json +1 -1
|
@@ -86,12 +86,12 @@ try {
|
|
|
86
86
|
);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
// Copy admin UI files from @authhero/
|
|
89
|
+
// Copy admin UI files from @authhero/admin package
|
|
90
90
|
const adminSourceDir = path.join(
|
|
91
91
|
__dirname,
|
|
92
92
|
"node_modules",
|
|
93
93
|
"@authhero",
|
|
94
|
-
"
|
|
94
|
+
"admin",
|
|
95
95
|
"dist",
|
|
96
96
|
);
|
|
97
97
|
|
package/dist/create-authhero.js
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
import { Command as R } from "commander";
|
|
3
3
|
import m from "inquirer";
|
|
4
4
|
import i from "fs";
|
|
5
|
-
import
|
|
5
|
+
import a from "path";
|
|
6
6
|
import { fileURLToPath as O } from "url";
|
|
7
7
|
import { spawn as U } from "child_process";
|
|
8
|
-
const
|
|
8
|
+
const N = new R(), p = {
|
|
9
9
|
local: {
|
|
10
10
|
name: "Local (SQLite)",
|
|
11
11
|
description: "Local development setup with SQLite database - great for getting started",
|
|
12
12
|
templateDir: "local",
|
|
13
|
-
packageJson: (
|
|
13
|
+
packageJson: (s, e, o, r, n) => {
|
|
14
14
|
const t = r ? "workspace:*" : "latest";
|
|
15
15
|
return {
|
|
16
|
-
name:
|
|
16
|
+
name: s,
|
|
17
17
|
version: "1.0.0",
|
|
18
18
|
type: "module",
|
|
19
19
|
scripts: {
|
|
@@ -24,7 +24,7 @@ const T = new R(), p = {
|
|
|
24
24
|
},
|
|
25
25
|
dependencies: {
|
|
26
26
|
"@authhero/kysely-adapter": t,
|
|
27
|
-
...n && { "@authhero/
|
|
27
|
+
...n && { "@authhero/admin": t },
|
|
28
28
|
"@authhero/widget": t,
|
|
29
29
|
"@hono/swagger-ui": "^0.5.0",
|
|
30
30
|
"@hono/zod-openapi": "^0.19.0",
|
|
@@ -50,10 +50,10 @@ const T = new R(), p = {
|
|
|
50
50
|
name: "Cloudflare Workers (D1)",
|
|
51
51
|
description: "Cloudflare Workers setup with D1 database",
|
|
52
52
|
templateDir: "cloudflare",
|
|
53
|
-
packageJson: (
|
|
53
|
+
packageJson: (s, e, o, r, n) => {
|
|
54
54
|
const t = r ? "workspace:*" : "latest";
|
|
55
55
|
return {
|
|
56
|
-
name:
|
|
56
|
+
name: s,
|
|
57
57
|
version: "1.0.0",
|
|
58
58
|
type: "module",
|
|
59
59
|
scripts: {
|
|
@@ -73,7 +73,7 @@ const T = new R(), p = {
|
|
|
73
73
|
dependencies: {
|
|
74
74
|
"@authhero/drizzle": t,
|
|
75
75
|
"@authhero/kysely-adapter": t,
|
|
76
|
-
...n && { "@authhero/
|
|
76
|
+
...n && { "@authhero/admin": t },
|
|
77
77
|
"@authhero/widget": t,
|
|
78
78
|
"@hono/swagger-ui": "^0.5.0",
|
|
79
79
|
"@hono/zod-openapi": "^0.19.0",
|
|
@@ -99,10 +99,10 @@ const T = new R(), p = {
|
|
|
99
99
|
name: "AWS SST (Lambda + DynamoDB)",
|
|
100
100
|
description: "Serverless AWS deployment with Lambda, DynamoDB, and SST",
|
|
101
101
|
templateDir: "aws-sst",
|
|
102
|
-
packageJson: (
|
|
102
|
+
packageJson: (s, e, o, r, n) => {
|
|
103
103
|
const t = r ? "workspace:*" : "latest";
|
|
104
104
|
return {
|
|
105
|
-
name:
|
|
105
|
+
name: s,
|
|
106
106
|
version: "1.0.0",
|
|
107
107
|
type: "module",
|
|
108
108
|
scripts: {
|
|
@@ -114,7 +114,7 @@ const T = new R(), p = {
|
|
|
114
114
|
},
|
|
115
115
|
dependencies: {
|
|
116
116
|
"@authhero/aws": t,
|
|
117
|
-
...n && { "@authhero/
|
|
117
|
+
...n && { "@authhero/admin": t },
|
|
118
118
|
"@authhero/widget": t,
|
|
119
119
|
"@aws-sdk/client-dynamodb": "^3.0.0",
|
|
120
120
|
"@aws-sdk/lib-dynamodb": "^3.0.0",
|
|
@@ -137,14 +137,14 @@ const T = new R(), p = {
|
|
|
137
137
|
seedFile: "seed.ts"
|
|
138
138
|
}
|
|
139
139
|
};
|
|
140
|
-
function P(
|
|
141
|
-
i.readdirSync(
|
|
142
|
-
const n =
|
|
140
|
+
function P(s, e) {
|
|
141
|
+
i.readdirSync(s).forEach((r) => {
|
|
142
|
+
const n = a.join(s, r), t = a.join(e, r);
|
|
143
143
|
i.lstatSync(n).isDirectory() ? (i.mkdirSync(t, { recursive: !0 }), P(n, t)) : i.copyFileSync(n, t);
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
|
-
function
|
|
147
|
-
const n =
|
|
146
|
+
function $(s, e = !1, o = "authhero-local", r) {
|
|
147
|
+
const n = s ? "control_plane" : "main", t = s ? "Control Plane" : "Main", c = [
|
|
148
148
|
"https://manage.authhero.net/auth-callback",
|
|
149
149
|
"https://local.authhero.net/auth-callback",
|
|
150
150
|
"http://localhost:5173/auth-callback",
|
|
@@ -165,10 +165,23 @@ function L(a, e = !1, o = "authhero-local", r) {
|
|
|
165
165
|
// The OIDCC basic test plan calls /token without an audience param. AuthHero
|
|
166
166
|
// requires either an explicit audience or a tenant default_audience to mint
|
|
167
167
|
// an access token, so set one here for the conformance setup.
|
|
168
|
+
// enable_dynamic_client_registration is required by the OIDCC dynamic plan,
|
|
169
|
+
// which has the suite register its own client via /oidc/register. The
|
|
170
|
+
// OIDCC dynamic_client variant uses open DCR (no Initial Access Token), so
|
|
171
|
+
// dcr_require_initial_access_token must be flipped off — the AuthHero
|
|
172
|
+
// default is to require an IAT. Existing flags (e.g.
|
|
173
|
+
// inherit_global_permissions_in_organizations set by seed for the
|
|
174
|
+
// control-plane tenant) are merged in so the update doesn't clobber.
|
|
175
|
+
const existingTenant = await adapters.tenants.get("${n}");
|
|
168
176
|
await adapters.tenants.update("${n}", {
|
|
169
177
|
default_audience: "urn:authhero:management",
|
|
178
|
+
flags: {
|
|
179
|
+
...(existingTenant?.flags ?? {}),
|
|
180
|
+
enable_dynamic_client_registration: true,
|
|
181
|
+
dcr_require_initial_access_token: false,
|
|
182
|
+
},
|
|
170
183
|
});
|
|
171
|
-
console.log("✅ Set tenant default_audience for conformance");
|
|
184
|
+
console.log("✅ Set tenant default_audience and enabled DCR for conformance");
|
|
172
185
|
|
|
173
186
|
const conformanceCallbacks = [
|
|
174
187
|
"https://localhost.emobix.co.uk:8443/test/a/${o}/callback",
|
|
@@ -183,39 +196,44 @@ function L(a, e = !1, o = "authhero-local", r) {
|
|
|
183
196
|
"https://localhost.emobix.co.uk:8443",
|
|
184
197
|
];
|
|
185
198
|
|
|
186
|
-
|
|
187
|
-
|
|
199
|
+
// Strict OIDC 5.4: scope-driven claims (profile/email/address/phone) belong
|
|
200
|
+
// in /userinfo whenever an access_token is co-issued at /authorize. The OIDF
|
|
201
|
+
// suite enforces this via EnsureIdTokenDoesNotContainEmailForScopeEmail;
|
|
202
|
+
// running the conformance tenant under Auth0-compatible defaults would WARN.
|
|
203
|
+
const conformanceClientSpecs = [
|
|
204
|
+
{
|
|
188
205
|
client_id: "conformance-test",
|
|
189
206
|
client_secret: "conformanceTestSecret123",
|
|
190
207
|
name: "Conformance Test Client",
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
web_origins: conformanceWebOrigins,
|
|
194
|
-
});
|
|
195
|
-
console.log("✅ Created conformance-test client");
|
|
196
|
-
} catch (e: any) {
|
|
197
|
-
if (e.message?.includes("UNIQUE constraint")) {
|
|
198
|
-
console.log("ℹ️ conformance-test client already exists");
|
|
199
|
-
} else {
|
|
200
|
-
throw e;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
try {
|
|
205
|
-
await adapters.clients.create("${n}", {
|
|
208
|
+
},
|
|
209
|
+
{
|
|
206
210
|
client_id: "conformance-test2",
|
|
207
211
|
client_secret: "conformanceTestSecret456",
|
|
208
212
|
name: "Conformance Test Client 2",
|
|
213
|
+
},
|
|
214
|
+
];
|
|
215
|
+
for (const spec of conformanceClientSpecs) {
|
|
216
|
+
const desired = {
|
|
217
|
+
name: spec.name,
|
|
218
|
+
client_secret: spec.client_secret,
|
|
209
219
|
callbacks: conformanceCallbacks,
|
|
210
220
|
allowed_logout_urls: conformanceLogoutUrls,
|
|
211
221
|
web_origins: conformanceWebOrigins,
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
222
|
+
auth0_conformant: false,
|
|
223
|
+
};
|
|
224
|
+
// Idempotent reconcile: prior runs may have created the client with stale
|
|
225
|
+
// callbacks/web_origins after this seed file was changed. Update existing
|
|
226
|
+
// records in place rather than just logging "already exists".
|
|
227
|
+
const existing = await adapters.clients.get("${n}", spec.client_id);
|
|
228
|
+
if (existing) {
|
|
229
|
+
await adapters.clients.update("${n}", spec.client_id, desired);
|
|
230
|
+
console.log(\`🔄 Updated \${spec.client_id} client\`);
|
|
217
231
|
} else {
|
|
218
|
-
|
|
232
|
+
await adapters.clients.create("${n}", {
|
|
233
|
+
client_id: spec.client_id,
|
|
234
|
+
...desired,
|
|
235
|
+
});
|
|
236
|
+
console.log(\`✅ Created \${spec.client_id} client\`);
|
|
219
237
|
}
|
|
220
238
|
}
|
|
221
239
|
|
|
@@ -334,7 +352,7 @@ async function main() {
|
|
|
334
352
|
adminPassword,
|
|
335
353
|
tenantId: "${n}",
|
|
336
354
|
tenantName: "${t}",
|
|
337
|
-
isControlPlane: ${!!
|
|
355
|
+
isControlPlane: ${!!s},
|
|
338
356
|
clientId: "default",
|
|
339
357
|
callbacks: ${JSON.stringify(f)},
|
|
340
358
|
allowedLogoutUrls: ${JSON.stringify(y)},
|
|
@@ -376,12 +394,12 @@ main().catch((err) => {
|
|
|
376
394
|
});
|
|
377
395
|
`;
|
|
378
396
|
}
|
|
379
|
-
function
|
|
397
|
+
function L(s, e) {
|
|
380
398
|
const o = e ? `import fs from "fs";
|
|
381
399
|
` : "", r = e ? `
|
|
382
400
|
const adminDistPath = path.resolve(
|
|
383
401
|
__dirname,
|
|
384
|
-
"../node_modules/@authhero/
|
|
402
|
+
"../node_modules/@authhero/admin/dist",
|
|
385
403
|
);
|
|
386
404
|
const adminIndexPath = path.join(adminDistPath, "index.html");
|
|
387
405
|
` : "", n = e ? `
|
|
@@ -394,7 +412,7 @@ const adminIndexPath = path.join(adminDistPath, "index.html");
|
|
|
394
412
|
.replace(/href="\\.\\//g, 'href="/admin/');
|
|
395
413
|
const configJson = JSON.stringify({
|
|
396
414
|
domain: issuer.replace(/\\/$/, ""),
|
|
397
|
-
clientId: ${
|
|
415
|
+
clientId: ${s ? "CONTROL_PLANE_CLIENT_ID," : '"default",'}
|
|
398
416
|
basePath: "/admin",
|
|
399
417
|
}).replace(/</g, "\\\\u003c");
|
|
400
418
|
configWithHandlers.adminIndexHtml = rawHtml.replace(
|
|
@@ -407,7 +425,7 @@ const adminIndexPath = path.join(adminDistPath, "index.html");
|
|
|
407
425
|
});
|
|
408
426
|
}
|
|
409
427
|
` : "";
|
|
410
|
-
return
|
|
428
|
+
return s ? `import { Context } from "hono";
|
|
411
429
|
import { swaggerUI } from "@hono/swagger-ui";
|
|
412
430
|
import { AuthHeroConfig, DataAdapters } from "authhero";
|
|
413
431
|
import { serveStatic } from "@hono/node-server/serve-static";
|
|
@@ -512,7 +530,7 @@ ${n}
|
|
|
512
530
|
}
|
|
513
531
|
`;
|
|
514
532
|
}
|
|
515
|
-
function j(
|
|
533
|
+
function j(s) {
|
|
516
534
|
return `import { D1Dialect } from "kysely-d1";
|
|
517
535
|
import { Kysely } from "kysely";
|
|
518
536
|
import createAdapters from "@authhero/kysely-adapter";
|
|
@@ -539,9 +557,9 @@ export default {
|
|
|
539
557
|
adminUsername,
|
|
540
558
|
adminPassword,
|
|
541
559
|
issuer,
|
|
542
|
-
tenantId: "${
|
|
543
|
-
tenantName: "${
|
|
544
|
-
isControlPlane: ${!!
|
|
560
|
+
tenantId: "${s ? "control_plane" : "main"}",
|
|
561
|
+
tenantName: "${s ? "Control Plane" : "Main"}",
|
|
562
|
+
isControlPlane: ${!!s},
|
|
545
563
|
clientId: "default",
|
|
546
564
|
});
|
|
547
565
|
|
|
@@ -573,11 +591,11 @@ export default {
|
|
|
573
591
|
};
|
|
574
592
|
`;
|
|
575
593
|
}
|
|
576
|
-
function H(
|
|
594
|
+
function H(s, e) {
|
|
577
595
|
const o = e ? `import adminIndexHtml from "./admin-index-html";
|
|
578
596
|
` : "", r = e ? ` adminIndexHtml,
|
|
579
597
|
` : "";
|
|
580
|
-
return
|
|
598
|
+
return s ? `import { Context } from "hono";
|
|
581
599
|
import { swaggerUI } from "@hono/swagger-ui";
|
|
582
600
|
import { AuthHeroConfig, DataAdapters } from "authhero";
|
|
583
601
|
import { initMultiTenant } from "@authhero/multi-tenancy";
|
|
@@ -658,8 +676,8 @@ ${r} });
|
|
|
658
676
|
}
|
|
659
677
|
`;
|
|
660
678
|
}
|
|
661
|
-
function
|
|
662
|
-
return
|
|
679
|
+
function F(s) {
|
|
680
|
+
return s ? `import { Context } from "hono";
|
|
663
681
|
import { swaggerUI } from "@hono/swagger-ui";
|
|
664
682
|
import { AuthHeroConfig, DataAdapters } from "authhero";
|
|
665
683
|
import { initMultiTenant } from "@authhero/multi-tenancy";
|
|
@@ -764,7 +782,7 @@ export default function createApp(config: AppConfig) {
|
|
|
764
782
|
}
|
|
765
783
|
`;
|
|
766
784
|
}
|
|
767
|
-
function
|
|
785
|
+
function M(s) {
|
|
768
786
|
return `import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
|
|
769
787
|
import { DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb";
|
|
770
788
|
import createAdapters from "@authhero/aws";
|
|
@@ -793,9 +811,9 @@ async function main() {
|
|
|
793
811
|
await seed(adapters, {
|
|
794
812
|
adminUsername,
|
|
795
813
|
adminPassword,
|
|
796
|
-
tenantId: "${
|
|
797
|
-
tenantName: "${
|
|
798
|
-
isControlPlane: ${!!
|
|
814
|
+
tenantId: "${s ? "control_plane" : "main"}",
|
|
815
|
+
tenantName: "${s ? "Control Plane" : "Main"}",
|
|
816
|
+
isControlPlane: ${!!s},
|
|
799
817
|
});
|
|
800
818
|
|
|
801
819
|
console.log("✅ Database seeded successfully!");
|
|
@@ -804,21 +822,21 @@ async function main() {
|
|
|
804
822
|
main().catch(console.error);
|
|
805
823
|
`;
|
|
806
824
|
}
|
|
807
|
-
function W(
|
|
808
|
-
const o =
|
|
825
|
+
function W(s, e) {
|
|
826
|
+
const o = a.join(s, "src");
|
|
809
827
|
i.writeFileSync(
|
|
810
|
-
|
|
811
|
-
M(e)
|
|
812
|
-
), i.writeFileSync(
|
|
813
|
-
s.join(o, "seed.ts"),
|
|
828
|
+
a.join(o, "app.ts"),
|
|
814
829
|
F(e)
|
|
830
|
+
), i.writeFileSync(
|
|
831
|
+
a.join(o, "seed.ts"),
|
|
832
|
+
M(e)
|
|
815
833
|
);
|
|
816
834
|
}
|
|
817
835
|
function k() {
|
|
818
836
|
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");
|
|
819
837
|
}
|
|
820
|
-
function q(
|
|
821
|
-
const e =
|
|
838
|
+
function q(s) {
|
|
839
|
+
const e = a.join(s, ".github", "workflows");
|
|
822
840
|
i.mkdirSync(e, { recursive: !0 });
|
|
823
841
|
const o = `name: Unit tests
|
|
824
842
|
|
|
@@ -906,9 +924,9 @@ jobs:
|
|
|
906
924
|
apiToken: \${{ secrets.PROD_CLOUDFLARE_API_TOKEN }}
|
|
907
925
|
command: deploy --env production
|
|
908
926
|
`;
|
|
909
|
-
i.writeFileSync(
|
|
927
|
+
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!");
|
|
910
928
|
}
|
|
911
|
-
function J(
|
|
929
|
+
function J(s) {
|
|
912
930
|
const e = {
|
|
913
931
|
branches: ["main"],
|
|
914
932
|
plugins: [
|
|
@@ -918,10 +936,10 @@ function J(a) {
|
|
|
918
936
|
]
|
|
919
937
|
};
|
|
920
938
|
i.writeFileSync(
|
|
921
|
-
|
|
939
|
+
a.join(s, ".releaserc.json"),
|
|
922
940
|
JSON.stringify(e, null, 2)
|
|
923
941
|
);
|
|
924
|
-
const o =
|
|
942
|
+
const o = a.join(s, "package.json"), r = JSON.parse(i.readFileSync(o, "utf-8"));
|
|
925
943
|
r.devDependencies = {
|
|
926
944
|
...r.devDependencies,
|
|
927
945
|
"semantic-release": "^24.0.0"
|
|
@@ -931,9 +949,9 @@ function J(a) {
|
|
|
931
949
|
"type-check": "tsc --noEmit"
|
|
932
950
|
}, i.writeFileSync(o, JSON.stringify(r, null, 2));
|
|
933
951
|
}
|
|
934
|
-
function
|
|
952
|
+
function A(s, e) {
|
|
935
953
|
return new Promise((o, r) => {
|
|
936
|
-
const n = U(
|
|
954
|
+
const n = U(s, [], {
|
|
937
955
|
cwd: e,
|
|
938
956
|
shell: !0,
|
|
939
957
|
stdio: "inherit"
|
|
@@ -943,13 +961,13 @@ function b(a, e) {
|
|
|
943
961
|
}), n.on("error", r);
|
|
944
962
|
});
|
|
945
963
|
}
|
|
946
|
-
function z(
|
|
947
|
-
const r =
|
|
964
|
+
function z(s, e, o) {
|
|
965
|
+
const r = a.join(s, "src");
|
|
948
966
|
i.writeFileSync(
|
|
949
|
-
|
|
967
|
+
a.join(r, "app.ts"),
|
|
950
968
|
H(e, o)
|
|
951
969
|
), i.writeFileSync(
|
|
952
|
-
|
|
970
|
+
a.join(r, "seed.ts"),
|
|
953
971
|
j(e)
|
|
954
972
|
);
|
|
955
973
|
}
|
|
@@ -958,12 +976,12 @@ function D() {
|
|
|
958
976
|
` + "─".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) + `
|
|
959
977
|
`);
|
|
960
978
|
}
|
|
961
|
-
function
|
|
979
|
+
function T() {
|
|
962
980
|
console.log(`
|
|
963
981
|
` + "─".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) + `
|
|
964
982
|
`);
|
|
965
983
|
}
|
|
966
|
-
|
|
984
|
+
N.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(
|
|
967
985
|
"--package-manager <pm>",
|
|
968
986
|
"package manager to use: npm, yarn, pnpm, or bun"
|
|
969
987
|
).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(
|
|
@@ -972,12 +990,12 @@ T.version("1.0.0").description("Create a new AuthHero project").argument("[proje
|
|
|
972
990
|
).option(
|
|
973
991
|
"--workspace",
|
|
974
992
|
"use workspace:* dependencies for local monorepo development"
|
|
975
|
-
).option("-y, --yes", "skip all prompts and use defaults/provided options").action(async (
|
|
993
|
+
).option("-y, --yes", "skip all prompts and use defaults/provided options").action(async (s, e) => {
|
|
976
994
|
const o = e.yes === !0;
|
|
977
995
|
console.log(`
|
|
978
996
|
🔐 Welcome to AuthHero!
|
|
979
997
|
`);
|
|
980
|
-
let r =
|
|
998
|
+
let r = s;
|
|
981
999
|
r || (o ? (r = "auth-server", console.log(`Using default project name: ${r}`)) : r = (await m.prompt([
|
|
982
1000
|
{
|
|
983
1001
|
type: "input",
|
|
@@ -987,7 +1005,7 @@ T.version("1.0.0").description("Create a new AuthHero project").argument("[proje
|
|
|
987
1005
|
validate: (u) => u !== "" || "Project name cannot be empty"
|
|
988
1006
|
}
|
|
989
1007
|
])).projectName);
|
|
990
|
-
const n =
|
|
1008
|
+
const n = a.join(process.cwd(), r);
|
|
991
1009
|
i.existsSync(n) && (console.error(`❌ Project "${r}" already exists.`), process.exit(1));
|
|
992
1010
|
let t;
|
|
993
1011
|
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([
|
|
@@ -1043,7 +1061,7 @@ T.version("1.0.0").description("Create a new AuthHero project").argument("[proje
|
|
|
1043
1061
|
C && console.log("Workspace mode: enabled (using workspace:* dependencies)");
|
|
1044
1062
|
const y = p[t];
|
|
1045
1063
|
i.mkdirSync(n, { recursive: !0 }), i.writeFileSync(
|
|
1046
|
-
|
|
1064
|
+
a.join(n, "package.json"),
|
|
1047
1065
|
JSON.stringify(
|
|
1048
1066
|
y.packageJson(
|
|
1049
1067
|
r,
|
|
@@ -1056,40 +1074,40 @@ T.version("1.0.0").description("Create a new AuthHero project").argument("[proje
|
|
|
1056
1074
|
2
|
|
1057
1075
|
)
|
|
1058
1076
|
);
|
|
1059
|
-
const _ = y.templateDir, S =
|
|
1060
|
-
|
|
1061
|
-
|
|
1077
|
+
const _ = y.templateDir, S = a.dirname(O(import.meta.url)), x = [
|
|
1078
|
+
a.join(S, _),
|
|
1079
|
+
a.join(S, "..", "templates", _)
|
|
1062
1080
|
], I = x.find((l) => i.existsSync(l));
|
|
1063
1081
|
if (I ? P(I, n) : (console.error(
|
|
1064
1082
|
`❌ Template directory not found. Looked in:
|
|
1065
1083
|
${x.join(`
|
|
1066
1084
|
`)}`
|
|
1067
1085
|
), process.exit(1)), t === "cloudflare" && z(n, c, d), t === "cloudflare") {
|
|
1068
|
-
const l =
|
|
1086
|
+
const l = a.join(n, "wrangler.toml"), u = a.join(n, "wrangler.local.toml");
|
|
1069
1087
|
i.existsSync(l) && i.copyFileSync(l, u);
|
|
1070
|
-
const g =
|
|
1088
|
+
const g = a.join(n, ".dev.vars.example"), w = a.join(n, ".dev.vars");
|
|
1071
1089
|
i.existsSync(g) && i.copyFileSync(g, w), console.log(
|
|
1072
1090
|
"📁 Created wrangler.local.toml and .dev.vars for local development"
|
|
1073
1091
|
);
|
|
1074
1092
|
}
|
|
1075
|
-
let
|
|
1076
|
-
if (t === "cloudflare" && (e.githubCi !== void 0 ? (
|
|
1093
|
+
let b = !1;
|
|
1094
|
+
if (t === "cloudflare" && (e.githubCi !== void 0 ? (b = e.githubCi, b && console.log("Including GitHub CI workflows with semantic versioning")) : o || (b = (await m.prompt([
|
|
1077
1095
|
{
|
|
1078
1096
|
type: "confirm",
|
|
1079
1097
|
name: "includeGithubCi",
|
|
1080
1098
|
message: "Would you like to include GitHub CI with semantic versioning?",
|
|
1081
1099
|
default: !1
|
|
1082
1100
|
}
|
|
1083
|
-
])).includeGithubCi),
|
|
1084
|
-
const l =
|
|
1101
|
+
])).includeGithubCi), b && (q(n), J(n))), t === "local") {
|
|
1102
|
+
const l = $(
|
|
1085
1103
|
c,
|
|
1086
1104
|
f,
|
|
1087
1105
|
h,
|
|
1088
1106
|
d
|
|
1089
1107
|
);
|
|
1090
|
-
i.writeFileSync(
|
|
1091
|
-
const u =
|
|
1092
|
-
i.writeFileSync(
|
|
1108
|
+
i.writeFileSync(a.join(n, "src/seed.ts"), l);
|
|
1109
|
+
const u = L(c, d);
|
|
1110
|
+
i.writeFileSync(a.join(n, "src/app.ts"), u);
|
|
1093
1111
|
}
|
|
1094
1112
|
if (t === "aws-sst" && W(n, c), f) {
|
|
1095
1113
|
const l = {
|
|
@@ -1111,7 +1129,7 @@ T.version("1.0.0").description("Create a new AuthHero project").argument("[proje
|
|
|
1111
1129
|
}
|
|
1112
1130
|
};
|
|
1113
1131
|
i.writeFileSync(
|
|
1114
|
-
|
|
1132
|
+
a.join(n, "conformance-config.json"),
|
|
1115
1133
|
JSON.stringify(l, null, 2)
|
|
1116
1134
|
), console.log(
|
|
1117
1135
|
"📝 Created conformance-config.json for OpenID Conformance Suite"
|
|
@@ -1153,9 +1171,9 @@ T.version("1.0.0").description("Create a new AuthHero project").argument("[proje
|
|
|
1153
1171
|
`);
|
|
1154
1172
|
try {
|
|
1155
1173
|
const u = l === "pnpm" ? "pnpm install --ignore-workspace" : `${l} install`;
|
|
1156
|
-
if (await
|
|
1174
|
+
if (await A(u, n), t === "local" && (console.log(`
|
|
1157
1175
|
🔧 Building native modules...
|
|
1158
|
-
`), await
|
|
1176
|
+
`), await A("npm rebuild better-sqlite3", n)), console.log(`
|
|
1159
1177
|
✅ Dependencies installed successfully!
|
|
1160
1178
|
`), (t === "local" || t === "cloudflare") && !e.skipMigrate) {
|
|
1161
1179
|
let w;
|
|
@@ -1168,7 +1186,7 @@ T.version("1.0.0").description("Create a new AuthHero project").argument("[proje
|
|
|
1168
1186
|
}
|
|
1169
1187
|
])).shouldMigrate, w && (console.log(`
|
|
1170
1188
|
🔄 Running migrations...
|
|
1171
|
-
`), await
|
|
1189
|
+
`), await A(`${l} run migrate`, n));
|
|
1172
1190
|
}
|
|
1173
1191
|
let g;
|
|
1174
1192
|
e.skipStart || o ? g = !1 : g = (await m.prompt([
|
|
@@ -1178,10 +1196,10 @@ T.version("1.0.0").description("Create a new AuthHero project").argument("[proje
|
|
|
1178
1196
|
message: "Would you like to start the development server?",
|
|
1179
1197
|
default: !0
|
|
1180
1198
|
}
|
|
1181
|
-
])).shouldStart, g && (t === "cloudflare" ? D() : t === "aws-sst" ? k() :
|
|
1182
|
-
`), await
|
|
1199
|
+
])).shouldStart, g && (t === "cloudflare" ? D() : t === "aws-sst" ? k() : T(), console.log(`🚀 Starting development server...
|
|
1200
|
+
`), await A(`${l} run dev`, n)), o && !g && (console.log(`
|
|
1183
1201
|
✅ Setup complete!`), console.log(`
|
|
1184
|
-
To start the development server:`), console.log(` cd ${r}`), console.log(" npm run dev"), t === "cloudflare" ? D() : t === "aws-sst" ? k() :
|
|
1202
|
+
To start the development server:`), console.log(` cd ${r}`), console.log(" npm run dev"), t === "cloudflare" ? D() : t === "aws-sst" ? k() : T());
|
|
1185
1203
|
} catch (u) {
|
|
1186
1204
|
console.error(`
|
|
1187
1205
|
❌ An error occurred:`, u), process.exit(1);
|
|
@@ -1208,4 +1226,4 @@ Server will be available at: http://localhost:3000`), f && (console.log(`
|
|
|
1208
1226
|
For more information, visit: https://authhero.net/docs
|
|
1209
1227
|
`));
|
|
1210
1228
|
});
|
|
1211
|
-
|
|
1229
|
+
N.parse(process.argv);
|
package/dist/local/src/app.ts
CHANGED
package/dist/local/src/index.ts
CHANGED
|
@@ -27,7 +27,14 @@ function ensureCertificates() {
|
|
|
27
27
|
execFileSync("which", ["mkcert"], { stdio: "ignore" });
|
|
28
28
|
execFileSync(
|
|
29
29
|
"mkcert",
|
|
30
|
-
[
|
|
30
|
+
[
|
|
31
|
+
"-key-file",
|
|
32
|
+
keyPath,
|
|
33
|
+
"-cert-file",
|
|
34
|
+
certPath,
|
|
35
|
+
"localhost",
|
|
36
|
+
"127.0.0.1",
|
|
37
|
+
],
|
|
31
38
|
{ stdio: "inherit" },
|
|
32
39
|
);
|
|
33
40
|
console.log("✅ Certificates generated with mkcert");
|