@holo-js/cli 0.1.7 → 0.1.9
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/bin/holo.mjs +19 -17
- package/dist/{broadcast-2SYWLGDX.mjs → broadcast-VR46UZEL.mjs} +4 -4
- package/dist/{cache-FEKU2TK4.mjs → cache-ETOIQ5IG.mjs} +4 -4
- package/dist/{cache-migrations-7RLM2QIS.mjs → cache-migrations-2GGI4TJK.mjs} +5 -5
- package/dist/{chunk-2SE5STJ2.mjs → chunk-7JR73TOH.mjs} +1 -1
- package/dist/{chunk-42ASVV4I.mjs → chunk-ASTSSSL2.mjs} +14 -4
- package/dist/{chunk-3KLRV6JF.mjs → chunk-HB4Q7VYK.mjs} +3 -3
- package/dist/{chunk-GEMG3HIO.mjs → chunk-IMOGEKB4.mjs} +398 -158
- package/dist/{chunk-PWTS5LZZ.mjs → chunk-SRPGIWCF.mjs} +1 -1
- package/dist/{chunk-GWW5VBKY.mjs → chunk-WRZFATUT.mjs} +102 -88
- package/dist/{config-IZR77Y5M.mjs → config-ARLE6PKR.mjs} +2 -2
- package/dist/{dev-KBHPQSHI.mjs → dev-6RG5SSZ7.mjs} +5 -5
- package/dist/{discovery-BKA2Z6PR.mjs → discovery-FCVGQQVD.mjs} +2 -2
- package/dist/{generators-K7A7MNY6.mjs → generators-UI2LJK3O.mjs} +5 -5
- package/dist/index.mjs +19 -17
- package/dist/{media-migrations-RBF4QZZ5.mjs → media-migrations-JQSDCC7S.mjs} +5 -5
- package/dist/{queue-PSPL63KS.mjs → queue-BY3PLH4I.mjs} +6 -6
- package/dist/{queue-migrations-3PI7RAB3.mjs → queue-migrations-YZUKEZK7.mjs} +5 -5
- package/dist/{runtime-PGE4HSSF.mjs → runtime-BI343WHS.mjs} +5 -5
- package/dist/{scaffold-AR5QZYMK.mjs → scaffold-UBOS2NZR.mjs} +3 -3
- package/dist/{security-JEV55QRY.mjs → security-TYPVOYGF.mjs} +4 -4
- package/package.json +7 -7
|
@@ -342,22 +342,6 @@ function renderNuxtConfig() {
|
|
|
342
342
|
""
|
|
343
343
|
].join("\n");
|
|
344
344
|
}
|
|
345
|
-
function renderNuxtHealthRoute() {
|
|
346
|
-
return [
|
|
347
|
-
"export default defineEventHandler(async () => {",
|
|
348
|
-
" const app = await holo.getApp()",
|
|
349
|
-
"",
|
|
350
|
-
" return {",
|
|
351
|
-
" ok: true,",
|
|
352
|
-
" app: app.config.app.name,",
|
|
353
|
-
" env: app.config.app.env,",
|
|
354
|
-
" models: app.registry?.models.length ?? 0,",
|
|
355
|
-
" commands: app.registry?.commands.length ?? 0,",
|
|
356
|
-
" }",
|
|
357
|
-
"})",
|
|
358
|
-
""
|
|
359
|
-
].join("\n");
|
|
360
|
-
}
|
|
361
345
|
function renderNuxtCurrentAuthRoute() {
|
|
362
346
|
return [
|
|
363
347
|
"import auth, { check, isAuthError, provider, user } from '@holo-js/auth'",
|
|
@@ -535,44 +519,34 @@ function renderNextRouteBridge(modulePath, methods) {
|
|
|
535
519
|
}
|
|
536
520
|
function renderNextHoloHelper() {
|
|
537
521
|
return [
|
|
538
|
-
"import {
|
|
522
|
+
"import { dirname, resolve } from 'node:path'",
|
|
523
|
+
"import { fileURLToPath } from 'node:url'",
|
|
524
|
+
"import { createNextHoloHelpers } from '@holo-js/adapter-next/runtime'",
|
|
525
|
+
"",
|
|
526
|
+
"const projectRoot = resolve(dirname(fileURLToPath(import.meta.url)), '../../..')",
|
|
539
527
|
"",
|
|
540
|
-
"export const holo = createNextHoloHelpers()",
|
|
528
|
+
"export const holo = createNextHoloHelpers({ projectRoot })",
|
|
541
529
|
""
|
|
542
530
|
].join("\n");
|
|
543
531
|
}
|
|
544
|
-
function
|
|
545
|
-
return renderNextRouteBridge("../../../../.holo-js/generated/next/health-route", ["GET"]);
|
|
546
|
-
}
|
|
547
|
-
function renderNextGeneratedHealthRoute() {
|
|
532
|
+
function renderNextRuntimeBootstrap() {
|
|
548
533
|
return [
|
|
549
|
-
"import {
|
|
534
|
+
"import { dirname, resolve } from 'node:path'",
|
|
535
|
+
"import { fileURLToPath } from 'node:url'",
|
|
536
|
+
"import { createNextHoloHelpers } from '@holo-js/adapter-next/runtime'",
|
|
550
537
|
"",
|
|
551
|
-
"
|
|
552
|
-
"
|
|
538
|
+
"const projectRoot = resolve(dirname(fileURLToPath(import.meta.url)), '../../..')",
|
|
539
|
+
"const holo = createNextHoloHelpers({ projectRoot })",
|
|
553
540
|
"",
|
|
554
|
-
"
|
|
555
|
-
" ok: true,",
|
|
556
|
-
" app: app.config.app.name,",
|
|
557
|
-
" env: app.config.app.env,",
|
|
558
|
-
" models: app.registry?.models.length ?? 0,",
|
|
559
|
-
" commands: app.registry?.commands.length ?? 0,",
|
|
560
|
-
" })",
|
|
561
|
-
"}",
|
|
541
|
+
"await holo.getApp()",
|
|
562
542
|
""
|
|
563
543
|
].join("\n");
|
|
564
544
|
}
|
|
565
545
|
function renderNextCurrentAuthRoute() {
|
|
566
|
-
return renderNextRouteBridge("../../../../.holo-js/generated/next/auth-user-route", ["GET"]);
|
|
567
|
-
}
|
|
568
|
-
function renderNextGeneratedCurrentAuthRoute() {
|
|
569
546
|
return [
|
|
570
547
|
"import auth, { check, isAuthError, provider, user } from '@holo-js/auth'",
|
|
571
|
-
"import { holo } from '../../../server/holo'",
|
|
572
548
|
"",
|
|
573
549
|
"export async function GET(request: Request) {",
|
|
574
|
-
" await holo.getApp()",
|
|
575
|
-
"",
|
|
576
550
|
" const guard = new URL(request.url).searchParams.get('guard') ?? undefined",
|
|
577
551
|
" try {",
|
|
578
552
|
" const guardAuth = guard ? auth.guard(guard) : undefined",
|
|
@@ -605,7 +579,7 @@ function renderNextHostedAuthLoginRoute(spec) {
|
|
|
605
579
|
function renderNextGeneratedHostedAuthLoginRoute(spec) {
|
|
606
580
|
return [
|
|
607
581
|
`import { ${spec.loginFunction} } from '${spec.packageName}'`,
|
|
608
|
-
"import { holo } from '
|
|
582
|
+
"import { holo } from './holo'",
|
|
609
583
|
"",
|
|
610
584
|
"export async function GET(request: Request) {",
|
|
611
585
|
" await holo.getApp()",
|
|
@@ -621,7 +595,7 @@ function renderNextHostedAuthRegisterRoute(spec) {
|
|
|
621
595
|
function renderNextGeneratedHostedAuthRegisterRoute(spec) {
|
|
622
596
|
return [
|
|
623
597
|
`import { ${spec.registerFunction} } from '${spec.packageName}'`,
|
|
624
|
-
"import { holo } from '
|
|
598
|
+
"import { holo } from './holo'",
|
|
625
599
|
"",
|
|
626
600
|
"export async function GET(request: Request) {",
|
|
627
601
|
" await holo.getApp()",
|
|
@@ -637,7 +611,7 @@ function renderNextHostedAuthCallbackRoute(spec) {
|
|
|
637
611
|
function renderNextGeneratedHostedAuthCallbackRoute(spec) {
|
|
638
612
|
return [
|
|
639
613
|
`import { ${spec.callbackFunction} } from '${spec.packageName}'`,
|
|
640
|
-
"import { holo } from '
|
|
614
|
+
"import { holo } from './holo'",
|
|
641
615
|
"",
|
|
642
616
|
"export async function GET(request: Request) {",
|
|
643
617
|
" await holo.getApp()",
|
|
@@ -659,7 +633,7 @@ function renderNextGeneratedHostedAuthLogoutRoute(spec) {
|
|
|
659
633
|
return [
|
|
660
634
|
"import { provider } from '@holo-js/auth'",
|
|
661
635
|
`import { ${spec.logoutFunction} } from '${spec.packageName}'`,
|
|
662
|
-
"import { holo } from '
|
|
636
|
+
"import { holo } from './holo'",
|
|
663
637
|
"",
|
|
664
638
|
"export async function POST(request: Request) {",
|
|
665
639
|
" await holo.getApp()",
|
|
@@ -700,7 +674,7 @@ function renderNextStorageRoute() {
|
|
|
700
674
|
function renderNextGeneratedStorageRoute() {
|
|
701
675
|
return [
|
|
702
676
|
"import { createPublicStorageResponse } from '@holo-js/storage'",
|
|
703
|
-
"import { holo } from '
|
|
677
|
+
"import { holo } from './holo'",
|
|
704
678
|
"",
|
|
705
679
|
"export async function GET(request: Request) {",
|
|
706
680
|
" const app = await holo.getApp()",
|
|
@@ -715,7 +689,7 @@ function renderNextBroadcastAuthRoute() {
|
|
|
715
689
|
function renderNextGeneratedBroadcastAuthRoute() {
|
|
716
690
|
return [
|
|
717
691
|
"import { renderBroadcastAuthResponse } from '@holo-js/broadcast/auth'",
|
|
718
|
-
"import { holo } from '
|
|
692
|
+
"import { holo } from './holo'",
|
|
719
693
|
"",
|
|
720
694
|
"export async function POST(request: Request) {",
|
|
721
695
|
" const app = await holo.getApp()",
|
|
@@ -736,22 +710,35 @@ function renderNextGeneratedBroadcastAuthRoute() {
|
|
|
736
710
|
}
|
|
737
711
|
function renderNextManagedRouteFiles(options = {}) {
|
|
738
712
|
return [
|
|
739
|
-
{ path: ".holo-js/generated/next/
|
|
740
|
-
|
|
713
|
+
{ path: ".holo-js/generated/next/holo.ts", contents: renderNextHoloHelper() },
|
|
714
|
+
{ path: ".holo-js/generated/next/bootstrap.mjs", contents: renderNextRuntimeBootstrap() },
|
|
741
715
|
...options.storageEnabled ? [{ path: ".holo-js/generated/next/storage-route.ts", contents: renderNextGeneratedStorageRoute() }] : [],
|
|
742
716
|
...options.broadcastAuthEnabled ? [{ path: ".holo-js/generated/next/broadcast-auth-route.ts", contents: renderNextGeneratedBroadcastAuthRoute() }] : []
|
|
743
717
|
];
|
|
744
718
|
}
|
|
745
719
|
function renderNextManagedHostedAuthRouteFiles(features) {
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
return [
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
720
|
+
const providers = getRequestedHostedAuthProviders(features);
|
|
721
|
+
if (providers.length === 0) {
|
|
722
|
+
return [];
|
|
723
|
+
}
|
|
724
|
+
return [
|
|
725
|
+
{ path: ".holo-js/generated/next/holo.ts", contents: renderNextHoloHelper() },
|
|
726
|
+
{ path: ".holo-js/generated/next/bootstrap.mjs", contents: renderNextRuntimeBootstrap() },
|
|
727
|
+
...providers.flatMap((provider) => {
|
|
728
|
+
const spec = HOSTED_AUTH_PROVIDERS[provider];
|
|
729
|
+
return [
|
|
730
|
+
{ path: `.holo-js/generated/next/auth-${provider}-login-route.ts`, contents: renderNextGeneratedHostedAuthLoginRoute(spec) },
|
|
731
|
+
{ path: `.holo-js/generated/next/auth-${provider}-register-route.ts`, contents: renderNextGeneratedHostedAuthRegisterRoute(spec) },
|
|
732
|
+
{ path: `.holo-js/generated/next/auth-${provider}-callback-route.ts`, contents: renderNextGeneratedHostedAuthCallbackRoute(spec) },
|
|
733
|
+
{ path: `.holo-js/generated/next/auth-${provider}-logout-route.ts`, contents: renderNextGeneratedHostedAuthLogoutRoute(spec) }
|
|
734
|
+
];
|
|
735
|
+
})
|
|
736
|
+
];
|
|
737
|
+
}
|
|
738
|
+
function renderSvelteManagedRuntimeFiles() {
|
|
739
|
+
return [
|
|
740
|
+
{ path: ".holo-js/generated/sveltekit/holo.ts", contents: renderSvelteHoloHelper() }
|
|
741
|
+
];
|
|
755
742
|
}
|
|
756
743
|
function renderSvelteConfig() {
|
|
757
744
|
return [
|
|
@@ -896,108 +883,61 @@ function renderSveltePage(projectName) {
|
|
|
896
883
|
}
|
|
897
884
|
function renderSvelteHoloHelper() {
|
|
898
885
|
return [
|
|
886
|
+
"import { dirname, resolve } from 'node:path'",
|
|
887
|
+
"import { fileURLToPath } from 'node:url'",
|
|
899
888
|
"import { createSvelteKitHoloHelpers } from '@holo-js/adapter-sveltekit'",
|
|
900
889
|
"",
|
|
901
|
-
"
|
|
902
|
-
""
|
|
903
|
-
].join("\n");
|
|
904
|
-
}
|
|
905
|
-
function renderSvelteHealthRoute() {
|
|
906
|
-
return [
|
|
907
|
-
"import { json } from '@sveltejs/kit'",
|
|
908
|
-
"import { holo } from '$lib/server/holo'",
|
|
909
|
-
"",
|
|
910
|
-
"export async function GET() {",
|
|
911
|
-
" const app = await holo.getApp()",
|
|
890
|
+
"const projectRoot = resolve(dirname(fileURLToPath(import.meta.url)), '../../..')",
|
|
912
891
|
"",
|
|
913
|
-
"
|
|
914
|
-
" ok: true,",
|
|
915
|
-
" app: app.config.app.name,",
|
|
916
|
-
" env: app.config.app.env,",
|
|
917
|
-
" models: app.registry?.models.length ?? 0,",
|
|
918
|
-
" commands: app.registry?.commands.length ?? 0,",
|
|
919
|
-
" })",
|
|
920
|
-
"}",
|
|
921
|
-
""
|
|
922
|
-
].join("\n");
|
|
923
|
-
}
|
|
924
|
-
function renderSvelteCurrentAuthRoute() {
|
|
925
|
-
return [
|
|
926
|
-
"import { json } from '@sveltejs/kit'",
|
|
927
|
-
"import auth, { check, isAuthError, provider, user } from '@holo-js/auth'",
|
|
928
|
-
"",
|
|
929
|
-
"export async function GET({ url }: { url: URL }) {",
|
|
930
|
-
" const guard = url.searchParams.get('guard') ?? undefined",
|
|
931
|
-
" try {",
|
|
932
|
-
" const guardAuth = guard ? auth.guard(guard) : undefined",
|
|
933
|
-
"",
|
|
934
|
-
" return json({",
|
|
935
|
-
" authenticated: guardAuth ? await guardAuth.check() : await check(),",
|
|
936
|
-
" guard: guard ?? 'web',",
|
|
937
|
-
" provider: guardAuth ? await guardAuth.provider() : await provider(),",
|
|
938
|
-
" user: guardAuth ? await guardAuth.user() : await user(),",
|
|
939
|
-
" })",
|
|
940
|
-
" } catch (error) {",
|
|
941
|
-
" if (isAuthError(error) && error.code === 'guard_not_configured') {",
|
|
942
|
-
" return json({",
|
|
943
|
-
" authenticated: false,",
|
|
944
|
-
" guard: guard ?? 'web',",
|
|
945
|
-
" provider: null,",
|
|
946
|
-
" user: null,",
|
|
947
|
-
" }, { status: 400 })",
|
|
948
|
-
" }",
|
|
949
|
-
"",
|
|
950
|
-
" throw error",
|
|
951
|
-
" }",
|
|
952
|
-
"}",
|
|
892
|
+
"export const holo = createSvelteKitHoloHelpers({ projectRoot })",
|
|
953
893
|
""
|
|
954
894
|
].join("\n");
|
|
955
895
|
}
|
|
956
896
|
function renderSvelteHostedAuthLoginRoute(spec) {
|
|
957
897
|
return [
|
|
958
898
|
`import { ${spec.loginFunction} } from '${spec.packageName}'`,
|
|
959
|
-
"import type {
|
|
899
|
+
"import type { RequestEvent } from '@sveltejs/kit'",
|
|
960
900
|
"",
|
|
961
|
-
"export
|
|
901
|
+
"export async function GET(event: RequestEvent) {",
|
|
962
902
|
` return await ${spec.loginFunction}(event)`,
|
|
963
|
-
"}
|
|
903
|
+
"}",
|
|
964
904
|
""
|
|
965
905
|
].join("\n");
|
|
966
906
|
}
|
|
967
907
|
function renderSvelteHostedAuthRegisterRoute(spec) {
|
|
968
908
|
return [
|
|
969
909
|
`import { ${spec.registerFunction} } from '${spec.packageName}'`,
|
|
970
|
-
"import type {
|
|
910
|
+
"import type { RequestEvent } from '@sveltejs/kit'",
|
|
971
911
|
"",
|
|
972
|
-
"export
|
|
912
|
+
"export async function GET(event: RequestEvent) {",
|
|
973
913
|
` return await ${spec.registerFunction}(event)`,
|
|
974
|
-
"}
|
|
914
|
+
"}",
|
|
975
915
|
""
|
|
976
916
|
].join("\n");
|
|
977
917
|
}
|
|
978
918
|
function renderSvelteHostedAuthCallbackRoute(spec) {
|
|
979
919
|
return [
|
|
980
|
-
"import { redirect, type
|
|
920
|
+
"import { redirect, type RequestEvent } from '@sveltejs/kit'",
|
|
981
921
|
`import { ${spec.callbackFunction} } from '${spec.packageName}'`,
|
|
982
922
|
"",
|
|
983
|
-
"export
|
|
923
|
+
"export async function GET(event: RequestEvent) {",
|
|
984
924
|
` const { error } = await ${spec.callbackFunction}(event)`,
|
|
985
925
|
" if (error) {",
|
|
986
926
|
" throw redirect(303, `/login?error=${encodeURIComponent(error.code)}`)",
|
|
987
927
|
" }",
|
|
988
928
|
"",
|
|
989
929
|
" throw redirect(303, '/')",
|
|
990
|
-
"}
|
|
930
|
+
"}",
|
|
991
931
|
""
|
|
992
932
|
].join("\n");
|
|
993
933
|
}
|
|
994
934
|
function renderSvelteHostedAuthLogoutRoute(spec) {
|
|
995
935
|
return [
|
|
996
|
-
"import { redirect, type
|
|
936
|
+
"import { redirect, type RequestEvent } from '@sveltejs/kit'",
|
|
997
937
|
"import { provider } from '@holo-js/auth'",
|
|
998
938
|
`import { ${spec.logoutFunction} } from '${spec.packageName}'`,
|
|
999
939
|
"",
|
|
1000
|
-
"export
|
|
940
|
+
"export async function POST(event: RequestEvent) {",
|
|
1001
941
|
" let currentProvider: string | null",
|
|
1002
942
|
" try {",
|
|
1003
943
|
" currentProvider = await provider()",
|
|
@@ -1015,7 +955,7 @@ function renderSvelteHostedAuthLogoutRoute(spec) {
|
|
|
1015
955
|
" }",
|
|
1016
956
|
"",
|
|
1017
957
|
" throw redirect(303, data.url)",
|
|
1018
|
-
"}
|
|
958
|
+
"}",
|
|
1019
959
|
""
|
|
1020
960
|
].join("\n");
|
|
1021
961
|
}
|
|
@@ -1025,7 +965,8 @@ function renderSvelteHostedAuthRouteFiles(provider) {
|
|
|
1025
965
|
{ path: `src/routes/api/auth/${provider}/login/+server.ts`, contents: renderSvelteHostedAuthLoginRoute(spec) },
|
|
1026
966
|
{ path: `src/routes/api/auth/${provider}/register/+server.ts`, contents: renderSvelteHostedAuthRegisterRoute(spec) },
|
|
1027
967
|
{ path: `src/routes/api/auth/${provider}/callback/+server.ts`, contents: renderSvelteHostedAuthCallbackRoute(spec) },
|
|
1028
|
-
{ path: `src/routes/api/auth/${provider}/logout/+server.ts`, contents: renderSvelteHostedAuthLogoutRoute(spec) }
|
|
968
|
+
{ path: `src/routes/api/auth/${provider}/logout/+server.ts`, contents: renderSvelteHostedAuthLogoutRoute(spec) },
|
|
969
|
+
...renderSvelteManagedRuntimeFiles()
|
|
1029
970
|
];
|
|
1030
971
|
}
|
|
1031
972
|
function renderAuthProviderRouteFiles(framework, features) {
|
|
@@ -1043,7 +984,8 @@ function renderAuthRouteFiles(framework) {
|
|
|
1043
984
|
if (framework === "next") {
|
|
1044
985
|
return [
|
|
1045
986
|
{ path: "app/api/auth/user/route.ts", contents: renderNextCurrentAuthRoute() },
|
|
1046
|
-
{ path: ".holo-js/generated/next/
|
|
987
|
+
{ path: ".holo-js/generated/next/holo.ts", contents: renderNextHoloHelper() },
|
|
988
|
+
{ path: ".holo-js/generated/next/bootstrap.mjs", contents: renderNextRuntimeBootstrap() }
|
|
1047
989
|
];
|
|
1048
990
|
}
|
|
1049
991
|
if (framework === "nuxt") {
|
|
@@ -1052,21 +994,9 @@ function renderAuthRouteFiles(framework) {
|
|
|
1052
994
|
];
|
|
1053
995
|
}
|
|
1054
996
|
return [
|
|
1055
|
-
|
|
997
|
+
...renderSvelteManagedRuntimeFiles()
|
|
1056
998
|
];
|
|
1057
999
|
}
|
|
1058
|
-
function renderSvelteStorageRoute() {
|
|
1059
|
-
return [
|
|
1060
|
-
"import { holo } from '$lib/server/holo'",
|
|
1061
|
-
"import { createPublicStorageResponse } from '@holo-js/storage'",
|
|
1062
|
-
"",
|
|
1063
|
-
"export async function GET({ request }: { request: Request }) {",
|
|
1064
|
-
" const app = await holo.getApp()",
|
|
1065
|
-
" return createPublicStorageResponse(app.projectRoot, app.config.storage, request)",
|
|
1066
|
-
"}",
|
|
1067
|
-
""
|
|
1068
|
-
].join("\n");
|
|
1069
|
-
}
|
|
1070
1000
|
function renderFrameworkFiles(options) {
|
|
1071
1001
|
const optionalPackages = normalizeScaffoldOptionalPackages(options.optionalPackages);
|
|
1072
1002
|
const storageEnabled = optionalPackages.includes("storage");
|
|
@@ -1075,7 +1005,6 @@ function renderFrameworkFiles(options) {
|
|
|
1075
1005
|
return [
|
|
1076
1006
|
{ path: "app/app.vue", contents: renderNuxtAppVue(options.projectName) },
|
|
1077
1007
|
{ path: "nuxt.config.ts", contents: renderNuxtConfig() },
|
|
1078
|
-
{ path: "server/api/holo/health.get.ts", contents: renderNuxtHealthRoute() },
|
|
1079
1008
|
{ path: "shared/.gitkeep", contents: "" },
|
|
1080
1009
|
...authEnabled ? renderAuthRouteFiles("nuxt") : []
|
|
1081
1010
|
];
|
|
@@ -1086,10 +1015,8 @@ function renderFrameworkFiles(options) {
|
|
|
1086
1015
|
{ path: "next-env.d.ts", contents: renderNextEnvDts() },
|
|
1087
1016
|
{ path: "app/layout.tsx", contents: renderNextLayout(options.projectName) },
|
|
1088
1017
|
{ path: "app/page.tsx", contents: renderNextPage(options.projectName) },
|
|
1089
|
-
{ path: "app/api/holo/health/route.ts", contents: renderNextHealthRoute() },
|
|
1090
1018
|
...authEnabled ? [{ path: "app/api/auth/user/route.ts", contents: renderNextCurrentAuthRoute() }] : [],
|
|
1091
1019
|
...storageEnabled ? [{ path: "app/storage/[[...path]]/route.ts", contents: renderNextStorageRoute() }] : [],
|
|
1092
|
-
{ path: "server/holo.ts", contents: renderNextHoloHelper() },
|
|
1093
1020
|
...renderNextManagedRouteFiles({ authEnabled, storageEnabled })
|
|
1094
1021
|
];
|
|
1095
1022
|
}
|
|
@@ -1100,10 +1027,8 @@ function renderFrameworkFiles(options) {
|
|
|
1100
1027
|
{ path: "src/hooks.server.ts", contents: renderSvelteServerUserHooks() },
|
|
1101
1028
|
{ path: "src/app.html", contents: renderSvelteAppHtml() },
|
|
1102
1029
|
{ path: "src/routes/+page.svelte", contents: renderSveltePage(options.projectName) },
|
|
1103
|
-
{ path: "src/routes/api/holo/health/+server.ts", contents: renderSvelteHealthRoute() },
|
|
1104
1030
|
...authEnabled ? renderAuthRouteFiles("sveltekit") : [],
|
|
1105
|
-
...
|
|
1106
|
-
{ path: "src/lib/server/holo.ts", contents: renderSvelteHoloHelper() }
|
|
1031
|
+
...renderSvelteManagedRuntimeFiles()
|
|
1107
1032
|
];
|
|
1108
1033
|
}
|
|
1109
1034
|
function renderFrameworkRunner(options) {
|
|
@@ -1118,6 +1043,7 @@ function renderFrameworkRunner(options) {
|
|
|
1118
1043
|
"const manifestPath = fileURLToPath(new URL('./project.json', import.meta.url))",
|
|
1119
1044
|
"const projectRoot = resolve(dirname(manifestPath), '../..')",
|
|
1120
1045
|
"const runtimeSchemaPath = resolve(projectRoot, '.holo-js/generated/schema.mjs')",
|
|
1046
|
+
"const nextRuntimeBootstrapPath = resolve(projectRoot, '.holo-js/generated/next/bootstrap.mjs')",
|
|
1121
1047
|
"const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'))",
|
|
1122
1048
|
"const framework = String(manifest.framework ?? '')",
|
|
1123
1049
|
`const commandName = ${JSON.stringify(commandName)}`,
|
|
@@ -1337,8 +1263,15 @@ function renderFrameworkRunner(options) {
|
|
|
1337
1263
|
" while (true) {",
|
|
1338
1264
|
" const stderrLines = []",
|
|
1339
1265
|
" const childEnv = { ...process.env }",
|
|
1340
|
-
"
|
|
1341
|
-
"
|
|
1266
|
+
" const preloads = [runtimeSchemaPath]",
|
|
1267
|
+
" if (framework === 'next') {",
|
|
1268
|
+
" preloads.push(nextRuntimeBootstrapPath)",
|
|
1269
|
+
" }",
|
|
1270
|
+
" const preloadOptions = preloads",
|
|
1271
|
+
" .filter(path => existsSync(path))",
|
|
1272
|
+
" .map(path => `--import=${pathToFileURL(path).href}`)",
|
|
1273
|
+
" if (preloadOptions.length > 0) {",
|
|
1274
|
+
" const preload = preloadOptions.join(' ')",
|
|
1342
1275
|
" childEnv.NODE_OPTIONS = childEnv.NODE_OPTIONS",
|
|
1343
1276
|
" ? `${childEnv.NODE_OPTIONS} ${preload}`",
|
|
1344
1277
|
" : preload",
|
|
@@ -1401,13 +1334,13 @@ function renderFrameworkRunner(options) {
|
|
|
1401
1334
|
|
|
1402
1335
|
// src/project/registry.ts
|
|
1403
1336
|
import { constants as fsConstants } from "fs";
|
|
1404
|
-
import { access, mkdir as mkdir2, readFile as readFile2, readdir, writeFile as writeFile2 } from "fs/promises";
|
|
1337
|
+
import { access, mkdir as mkdir2, readFile as readFile2, readdir as readdir2, writeFile as writeFile2 } from "fs/promises";
|
|
1405
1338
|
import { dirname as dirname3, extname, join, resolve as resolve3 } from "path";
|
|
1406
1339
|
import { loadConfigDirectory } from "@holo-js/config";
|
|
1407
1340
|
import { DEFAULT_HOLO_PROJECT_PATHS, renderGeneratedSchemaRuntimeModule } from "@holo-js/db";
|
|
1408
1341
|
|
|
1409
1342
|
// src/project/registry-svelte.ts
|
|
1410
|
-
import { mkdir, readFile,
|
|
1343
|
+
import { mkdir, readdir, readFile, rm, writeFile } from "fs/promises";
|
|
1411
1344
|
import { dirname as dirname2, resolve as resolve2 } from "path";
|
|
1412
1345
|
function renderManagedSvelteHooksModule() {
|
|
1413
1346
|
return [
|
|
@@ -1454,22 +1387,151 @@ function renderManagedSvelteHooksModule() {
|
|
|
1454
1387
|
""
|
|
1455
1388
|
].join("\n");
|
|
1456
1389
|
}
|
|
1457
|
-
function renderManagedSvelteServerHooksModule() {
|
|
1458
|
-
|
|
1390
|
+
function renderManagedSvelteServerHooksModule(features) {
|
|
1391
|
+
const imports = [
|
|
1459
1392
|
"// Generated by holo prepare. Do not edit.",
|
|
1460
1393
|
"",
|
|
1461
|
-
"import { error as svelteKitError, type Handle, type HandleFetch, type HandleServerError } from '@sveltejs/kit'",
|
|
1394
|
+
"import { error as svelteKitError, type Handle, type HandleFetch, type HandleServerError, type RequestEvent } from '@sveltejs/kit'",
|
|
1462
1395
|
"import { adapterSvelteKitInternals, runWithSvelteKitRequestEvent } from '@holo-js/adapter-sveltekit'",
|
|
1463
1396
|
"import { sequence } from '@sveltejs/kit/hooks'",
|
|
1464
|
-
"import {
|
|
1397
|
+
...features.authEnabled ? ["import auth, { check, isAuthError, provider, user } from '@holo-js/auth'"] : [],
|
|
1398
|
+
...features.broadcastEnabled ? ["import { renderBroadcastAuthResponse } from '@holo-js/broadcast/auth'"] : [],
|
|
1399
|
+
...features.storageEnabled ? ["import { createPublicStorageResponse } from '@holo-js/storage'"] : [],
|
|
1400
|
+
...features.clerkEnabled ? ["import { completeClerkAuth, loginWithClerk, logoutWithClerk, registerWithClerk } from '@holo-js/auth-clerk'"] : [],
|
|
1401
|
+
...features.workosEnabled ? ["import { completeWorkosAuth, loginWithWorkos, logoutWithWorkos, registerWithWorkos } from '@holo-js/auth-workos'"] : [],
|
|
1402
|
+
"import { holo } from './sveltekit/holo'",
|
|
1465
1403
|
"import * as userHooks from '../../src/hooks.server'",
|
|
1466
|
-
""
|
|
1404
|
+
""
|
|
1405
|
+
];
|
|
1406
|
+
const routeHandlers = [
|
|
1407
|
+
...features.authEnabled ? ["handleHoloCurrentAuthRoute"] : [],
|
|
1408
|
+
...features.storageEnabled ? ["handleHoloStorageRoute"] : [],
|
|
1409
|
+
...features.broadcastEnabled ? ["handleHoloBroadcastAuthRoute"] : [],
|
|
1410
|
+
...features.clerkEnabled ? [
|
|
1411
|
+
"handleHoloClerkLoginRoute",
|
|
1412
|
+
"handleHoloClerkRegisterRoute",
|
|
1413
|
+
"handleHoloClerkCallbackRoute",
|
|
1414
|
+
"handleHoloClerkLogoutRoute"
|
|
1415
|
+
] : [],
|
|
1416
|
+
...features.workosEnabled ? [
|
|
1417
|
+
"handleHoloWorkosLoginRoute",
|
|
1418
|
+
"handleHoloWorkosRegisterRoute",
|
|
1419
|
+
"handleHoloWorkosCallbackRoute",
|
|
1420
|
+
"handleHoloWorkosLogoutRoute"
|
|
1421
|
+
] : []
|
|
1422
|
+
];
|
|
1423
|
+
return [
|
|
1424
|
+
...imports,
|
|
1467
1425
|
"const serverHooks = userHooks as {",
|
|
1468
1426
|
" handle?: Handle",
|
|
1469
1427
|
" handleError?: HandleServerError",
|
|
1470
1428
|
" handleFetch?: HandleFetch",
|
|
1471
1429
|
"}",
|
|
1472
1430
|
"",
|
|
1431
|
+
"type HoloApp = Awaited<ReturnType<typeof holo.getApp>>",
|
|
1432
|
+
"type HoloRouteHandler = (event: RequestEvent, app: HoloApp) => Promise<Response | undefined>",
|
|
1433
|
+
"",
|
|
1434
|
+
"function isRoute(event: RequestEvent, method: string, paths: readonly string[]): boolean {",
|
|
1435
|
+
" return event.request.method.toUpperCase() === method && paths.includes(event.url.pathname)",
|
|
1436
|
+
"}",
|
|
1437
|
+
"",
|
|
1438
|
+
"function redirectResponse(event: RequestEvent, location: string): Response {",
|
|
1439
|
+
" return Response.redirect(new URL(location, event.url), 303)",
|
|
1440
|
+
"}",
|
|
1441
|
+
"",
|
|
1442
|
+
"function normalizeRoutePrefix(value: string | undefined, fallback: string): string {",
|
|
1443
|
+
" const raw = value?.trim() ?? fallback",
|
|
1444
|
+
" if (!raw || raw === '/') {",
|
|
1445
|
+
" return fallback",
|
|
1446
|
+
" }",
|
|
1447
|
+
"",
|
|
1448
|
+
" return `/${raw.replace(/^\\/+|\\/+$/g, '')}`",
|
|
1449
|
+
"}",
|
|
1450
|
+
"",
|
|
1451
|
+
"function pathMatchesPrefix(pathname: string, prefix: string): boolean {",
|
|
1452
|
+
" return pathname === prefix || pathname.startsWith(`${prefix}/`)",
|
|
1453
|
+
"}",
|
|
1454
|
+
"",
|
|
1455
|
+
...features.authEnabled ? [
|
|
1456
|
+
"async function handleHoloCurrentAuthRoute(event: RequestEvent): Promise<Response | undefined> {",
|
|
1457
|
+
" if (!isRoute(event, 'GET', ['/api/auth/user'])) {",
|
|
1458
|
+
" return undefined",
|
|
1459
|
+
" }",
|
|
1460
|
+
"",
|
|
1461
|
+
" const guard = event.url.searchParams.get('guard') ?? undefined",
|
|
1462
|
+
" try {",
|
|
1463
|
+
" const guardAuth = guard ? auth.guard(guard) : undefined",
|
|
1464
|
+
"",
|
|
1465
|
+
" return Response.json({",
|
|
1466
|
+
" authenticated: guardAuth ? await guardAuth.check() : await check(),",
|
|
1467
|
+
" guard: guard ?? 'web',",
|
|
1468
|
+
" provider: guardAuth ? await guardAuth.provider() : await provider(),",
|
|
1469
|
+
" user: guardAuth ? await guardAuth.user() : await user(),",
|
|
1470
|
+
" })",
|
|
1471
|
+
" } catch (error) {",
|
|
1472
|
+
" if (isAuthError(error) && error.code === 'guard_not_configured') {",
|
|
1473
|
+
" return Response.json({",
|
|
1474
|
+
" authenticated: false,",
|
|
1475
|
+
" guard: guard ?? 'web',",
|
|
1476
|
+
" provider: null,",
|
|
1477
|
+
" user: null,",
|
|
1478
|
+
" }, { status: 400 })",
|
|
1479
|
+
" }",
|
|
1480
|
+
"",
|
|
1481
|
+
" throw error",
|
|
1482
|
+
" }",
|
|
1483
|
+
"}",
|
|
1484
|
+
""
|
|
1485
|
+
] : [],
|
|
1486
|
+
...features.storageEnabled ? [
|
|
1487
|
+
"async function handleHoloStorageRoute(event: RequestEvent, app: HoloApp): Promise<Response | undefined> {",
|
|
1488
|
+
" if (event.request.method.toUpperCase() !== 'GET') {",
|
|
1489
|
+
" return undefined",
|
|
1490
|
+
" }",
|
|
1491
|
+
"",
|
|
1492
|
+
" const prefix = normalizeRoutePrefix(app.config.storage.routePrefix, '/storage')",
|
|
1493
|
+
" if (!pathMatchesPrefix(event.url.pathname, prefix)) {",
|
|
1494
|
+
" return undefined",
|
|
1495
|
+
" }",
|
|
1496
|
+
"",
|
|
1497
|
+
" return createPublicStorageResponse(app.projectRoot, app.config.storage, event.request)",
|
|
1498
|
+
"}",
|
|
1499
|
+
""
|
|
1500
|
+
] : [],
|
|
1501
|
+
...features.broadcastEnabled ? [
|
|
1502
|
+
"async function handleHoloBroadcastAuthRoute(event: RequestEvent, app: HoloApp): Promise<Response | undefined> {",
|
|
1503
|
+
" if (!isRoute(event, 'POST', ['/broadcasting/auth'])) {",
|
|
1504
|
+
" return undefined",
|
|
1505
|
+
" }",
|
|
1506
|
+
"",
|
|
1507
|
+
" const auth = await holo.getAuth()",
|
|
1508
|
+
" return await renderBroadcastAuthResponse(event.request, {",
|
|
1509
|
+
" resolveUser: async () => await auth?.user(),",
|
|
1510
|
+
" channelAuth: {",
|
|
1511
|
+
" registry: {",
|
|
1512
|
+
" projectRoot: app.projectRoot,",
|
|
1513
|
+
" channels: app.registry?.channels ?? [],",
|
|
1514
|
+
" },",
|
|
1515
|
+
" },",
|
|
1516
|
+
" })",
|
|
1517
|
+
"}",
|
|
1518
|
+
""
|
|
1519
|
+
] : [],
|
|
1520
|
+
...features.clerkEnabled ? renderSvelteHostedAuthHookRoutes("clerk", "Clerk") : [],
|
|
1521
|
+
...features.workosEnabled ? renderSvelteHostedAuthHookRoutes("workos", "Workos") : [],
|
|
1522
|
+
`const holoRouteHandlers: readonly HoloRouteHandler[] = [${routeHandlers.join(", ")}]`,
|
|
1523
|
+
"",
|
|
1524
|
+
"async function handleHoloRoute(event: RequestEvent, app: HoloApp): Promise<Response | undefined> {",
|
|
1525
|
+
" for (const handler of holoRouteHandlers) {",
|
|
1526
|
+
" const response = await handler(event, app)",
|
|
1527
|
+
" if (response) {",
|
|
1528
|
+
" return response",
|
|
1529
|
+
" }",
|
|
1530
|
+
" }",
|
|
1531
|
+
"",
|
|
1532
|
+
" return undefined",
|
|
1533
|
+
"}",
|
|
1534
|
+
"",
|
|
1473
1535
|
"function isHoloAuthorizationHttpError(cause: unknown): cause is Error & { readonly decision: { readonly status: 403 | 404 } } {",
|
|
1474
1536
|
" if (!(cause instanceof Error) || cause.name !== 'AuthorizationError') {",
|
|
1475
1537
|
" return false",
|
|
@@ -1484,9 +1546,14 @@ function renderManagedSvelteServerHooksModule() {
|
|
|
1484
1546
|
"}",
|
|
1485
1547
|
"",
|
|
1486
1548
|
"const holoHandle: Handle = ({ event, resolve }) => runWithSvelteKitRequestEvent(event, async () => {",
|
|
1487
|
-
" await holo.getApp()",
|
|
1549
|
+
" const app = await holo.getApp()",
|
|
1488
1550
|
"",
|
|
1489
1551
|
" try {",
|
|
1552
|
+
" const holoRouteResponse = await handleHoloRoute(event, app)",
|
|
1553
|
+
" if (holoRouteResponse) {",
|
|
1554
|
+
" return holoRouteResponse",
|
|
1555
|
+
" }",
|
|
1556
|
+
"",
|
|
1490
1557
|
" const response = await resolve(event)",
|
|
1491
1558
|
" return await adapterSvelteKitInternals.mapValidationActionResponse(event, response)",
|
|
1492
1559
|
" } catch (cause) {",
|
|
@@ -1531,6 +1598,63 @@ function renderManagedSvelteServerHooksModule() {
|
|
|
1531
1598
|
""
|
|
1532
1599
|
].join("\n");
|
|
1533
1600
|
}
|
|
1601
|
+
function renderSvelteHostedAuthHookRoutes(providerName, functionSuffix) {
|
|
1602
|
+
return [
|
|
1603
|
+
`async function handleHolo${functionSuffix}LoginRoute(event: RequestEvent): Promise<Response | undefined> {`,
|
|
1604
|
+
` if (!isRoute(event, 'GET', ['/api/auth/${providerName}/login'])) {`,
|
|
1605
|
+
" return undefined",
|
|
1606
|
+
" }",
|
|
1607
|
+
"",
|
|
1608
|
+
` return await loginWith${functionSuffix}(event)`,
|
|
1609
|
+
"}",
|
|
1610
|
+
"",
|
|
1611
|
+
`async function handleHolo${functionSuffix}RegisterRoute(event: RequestEvent): Promise<Response | undefined> {`,
|
|
1612
|
+
` if (!isRoute(event, 'GET', ['/api/auth/${providerName}/register'])) {`,
|
|
1613
|
+
" return undefined",
|
|
1614
|
+
" }",
|
|
1615
|
+
"",
|
|
1616
|
+
` return await registerWith${functionSuffix}(event)`,
|
|
1617
|
+
"}",
|
|
1618
|
+
"",
|
|
1619
|
+
`async function handleHolo${functionSuffix}CallbackRoute(event: RequestEvent): Promise<Response | undefined> {`,
|
|
1620
|
+
` if (!isRoute(event, 'GET', ['/api/auth/${providerName}/callback'])) {`,
|
|
1621
|
+
" return undefined",
|
|
1622
|
+
" }",
|
|
1623
|
+
"",
|
|
1624
|
+
` const { error } = await complete${functionSuffix}Auth(event)`,
|
|
1625
|
+
" if (error) {",
|
|
1626
|
+
" return redirectResponse(event, `/login?error=${encodeURIComponent(error.code)}`)",
|
|
1627
|
+
" }",
|
|
1628
|
+
"",
|
|
1629
|
+
" return redirectResponse(event, '/')",
|
|
1630
|
+
"}",
|
|
1631
|
+
"",
|
|
1632
|
+
`async function handleHolo${functionSuffix}LogoutRoute(event: RequestEvent): Promise<Response | undefined> {`,
|
|
1633
|
+
` if (!isRoute(event, 'POST', ['/api/auth/${providerName}/logout'])) {`,
|
|
1634
|
+
" return undefined",
|
|
1635
|
+
" }",
|
|
1636
|
+
"",
|
|
1637
|
+
" let currentProvider: string | null",
|
|
1638
|
+
" try {",
|
|
1639
|
+
" currentProvider = await provider()",
|
|
1640
|
+
" } catch {",
|
|
1641
|
+
" return redirectResponse(event, '/')",
|
|
1642
|
+
" }",
|
|
1643
|
+
"",
|
|
1644
|
+
` if (currentProvider !== '${providerName}') {`,
|
|
1645
|
+
" return redirectResponse(event, '/')",
|
|
1646
|
+
" }",
|
|
1647
|
+
"",
|
|
1648
|
+
` const { data, error } = await logoutWith${functionSuffix}(event)`,
|
|
1649
|
+
" if (error) {",
|
|
1650
|
+
" return Response.json({ data, error }, { status: error.status })",
|
|
1651
|
+
" }",
|
|
1652
|
+
"",
|
|
1653
|
+
" return redirectResponse(event, data.url)",
|
|
1654
|
+
"}",
|
|
1655
|
+
""
|
|
1656
|
+
];
|
|
1657
|
+
}
|
|
1534
1658
|
function renderSvelteDefaultHooksModule() {
|
|
1535
1659
|
return [
|
|
1536
1660
|
"export {}",
|
|
@@ -1594,10 +1718,7 @@ async function readFileIfPresent(path) {
|
|
|
1594
1718
|
}
|
|
1595
1719
|
}
|
|
1596
1720
|
async function unlinkIfPresent(path) {
|
|
1597
|
-
|
|
1598
|
-
await unlink(path);
|
|
1599
|
-
} catch {
|
|
1600
|
-
}
|
|
1721
|
+
await rm(path, { force: true });
|
|
1601
1722
|
}
|
|
1602
1723
|
async function pathExists(path) {
|
|
1603
1724
|
return await readFileIfPresent(path) !== void 0;
|
|
@@ -1682,7 +1803,7 @@ async function writeFileIfChanged(path, contents) {
|
|
|
1682
1803
|
await mkdir(dirname2(path), { recursive: true });
|
|
1683
1804
|
await writeFile(path, contents, "utf8");
|
|
1684
1805
|
}
|
|
1685
|
-
async function ensureSvelteManagedHooks(projectRoot) {
|
|
1806
|
+
async function ensureSvelteManagedHooks(projectRoot, features) {
|
|
1686
1807
|
const hooksPath = resolve2(projectRoot, "src/hooks.ts");
|
|
1687
1808
|
const hooksServerPath = resolve2(projectRoot, "src/hooks.server.ts");
|
|
1688
1809
|
const generatedHooksPath = resolve2(projectRoot, GENERATED_SVELTE_HOOKS_PATH);
|
|
@@ -1716,9 +1837,52 @@ async function ensureSvelteManagedHooks(projectRoot) {
|
|
|
1716
1837
|
await writeFileIfChanged(hooksServerPath, renderSvelteDefaultServerHooksModule());
|
|
1717
1838
|
}
|
|
1718
1839
|
await writeFileIfChanged(generatedHooksPath, renderManagedSvelteHooksModule());
|
|
1719
|
-
await writeFileIfChanged(generatedServerHooksPath, renderManagedSvelteServerHooksModule());
|
|
1840
|
+
await writeFileIfChanged(generatedServerHooksPath, renderManagedSvelteServerHooksModule(features));
|
|
1720
1841
|
await ensureSvelteConfigHooksOverride(projectRoot);
|
|
1721
1842
|
}
|
|
1843
|
+
async function removeLegacyManagedHoloHelper(path, managedContents) {
|
|
1844
|
+
const contents = await readFileIfPresent(path);
|
|
1845
|
+
const trimmedContents = contents?.trim();
|
|
1846
|
+
const trimmedManagedContents = managedContents.trim();
|
|
1847
|
+
const isLegacyManagedHelper = trimmedContents === [
|
|
1848
|
+
"import { createNextHoloHelpers } from '@holo-js/adapter-next'",
|
|
1849
|
+
"",
|
|
1850
|
+
"export const holo = createNextHoloHelpers()"
|
|
1851
|
+
].join("\n") || trimmedContents === [
|
|
1852
|
+
"import { createSvelteKitHoloHelpers } from '@holo-js/adapter-sveltekit'",
|
|
1853
|
+
"",
|
|
1854
|
+
"export const holo = createSvelteKitHoloHelpers()"
|
|
1855
|
+
].join("\n");
|
|
1856
|
+
if (trimmedContents === trimmedManagedContents || isLegacyManagedHelper) {
|
|
1857
|
+
await unlinkIfPresent(path);
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
async function removeLegacyManagedRoute(path, markerGroups) {
|
|
1861
|
+
const contents = await readFileIfPresent(path);
|
|
1862
|
+
if (contents && markerGroups.some((markers) => markers.every((marker) => contents.includes(marker)))) {
|
|
1863
|
+
await unlinkIfPresent(path);
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
async function directoryContainsText(path, pattern) {
|
|
1867
|
+
const entries = await readdir(path, { withFileTypes: true }).catch(() => []);
|
|
1868
|
+
for (const entry of entries) {
|
|
1869
|
+
const entryPath = resolve2(path, entry.name);
|
|
1870
|
+
if (entry.isDirectory()) {
|
|
1871
|
+
if (await directoryContainsText(entryPath, pattern)) {
|
|
1872
|
+
return true;
|
|
1873
|
+
}
|
|
1874
|
+
continue;
|
|
1875
|
+
}
|
|
1876
|
+
if (!entry.isFile() || !/\.[cm]?[jt]s$/.test(entry.name)) {
|
|
1877
|
+
continue;
|
|
1878
|
+
}
|
|
1879
|
+
const contents = await readFileIfPresent(entryPath);
|
|
1880
|
+
if (contents?.includes(pattern)) {
|
|
1881
|
+
return true;
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
return false;
|
|
1885
|
+
}
|
|
1722
1886
|
async function ensureNextManagedRoutes(projectRoot) {
|
|
1723
1887
|
const authEnabled = await pathExists(resolve2(projectRoot, "app/api/auth/user/route.ts"));
|
|
1724
1888
|
const storageEnabled = await pathExists(resolve2(projectRoot, "app/storage/[[...path]]/route.ts"));
|
|
@@ -1739,6 +1903,79 @@ async function ensureNextManagedRoutes(projectRoot) {
|
|
|
1739
1903
|
for (const file of files) {
|
|
1740
1904
|
await writeFileIfChanged(resolve2(projectRoot, file.path), file.contents);
|
|
1741
1905
|
}
|
|
1906
|
+
await removeLegacyManagedHoloHelper(resolve2(projectRoot, "server/holo.ts"), renderNextHoloHelper());
|
|
1907
|
+
}
|
|
1908
|
+
function isRecord2(value) {
|
|
1909
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1910
|
+
}
|
|
1911
|
+
async function readProjectDependencies(projectRoot) {
|
|
1912
|
+
const contents = await readFileIfPresent(resolve2(projectRoot, "package.json"));
|
|
1913
|
+
if (!contents) {
|
|
1914
|
+
return /* @__PURE__ */ new Set();
|
|
1915
|
+
}
|
|
1916
|
+
const manifest = JSON.parse(contents);
|
|
1917
|
+
if (!isRecord2(manifest)) {
|
|
1918
|
+
return /* @__PURE__ */ new Set();
|
|
1919
|
+
}
|
|
1920
|
+
const dependencies = isRecord2(manifest.dependencies) ? Object.keys(manifest.dependencies) : [];
|
|
1921
|
+
const devDependencies = isRecord2(manifest.devDependencies) ? Object.keys(manifest.devDependencies) : [];
|
|
1922
|
+
return /* @__PURE__ */ new Set([...dependencies, ...devDependencies]);
|
|
1923
|
+
}
|
|
1924
|
+
async function resolveSvelteManagedFeatures(projectRoot) {
|
|
1925
|
+
const dependencies = await readProjectDependencies(projectRoot);
|
|
1926
|
+
return {
|
|
1927
|
+
authEnabled: dependencies.has("@holo-js/auth"),
|
|
1928
|
+
broadcastEnabled: dependencies.has("@holo-js/broadcast"),
|
|
1929
|
+
storageEnabled: dependencies.has("@holo-js/storage"),
|
|
1930
|
+
clerkEnabled: dependencies.has("@holo-js/auth-clerk"),
|
|
1931
|
+
workosEnabled: dependencies.has("@holo-js/auth-workos")
|
|
1932
|
+
};
|
|
1933
|
+
}
|
|
1934
|
+
async function ensureSvelteManagedRuntime(projectRoot) {
|
|
1935
|
+
const files = renderSvelteManagedRuntimeFiles();
|
|
1936
|
+
for (const file of files) {
|
|
1937
|
+
await writeFileIfChanged(resolve2(projectRoot, file.path), file.contents);
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
async function ensureSvelteManagedRoutes(projectRoot) {
|
|
1941
|
+
await removeLegacyManagedRoute(
|
|
1942
|
+
resolve2(projectRoot, "src/routes/api/holo/health/+server.ts"),
|
|
1943
|
+
[
|
|
1944
|
+
["app.registry?.models.length ?? 0", "app.registry?.commands.length ?? 0"],
|
|
1945
|
+
[".holo-js/generated/sveltekit/health-route"]
|
|
1946
|
+
]
|
|
1947
|
+
);
|
|
1948
|
+
await removeLegacyManagedRoute(
|
|
1949
|
+
resolve2(projectRoot, "src/routes/api/holo/+server.ts"),
|
|
1950
|
+
[
|
|
1951
|
+
["app.registry?.models.length ?? 0", "app.registry?.commands.length ?? 0"],
|
|
1952
|
+
[".holo-js/generated/sveltekit/health-route"]
|
|
1953
|
+
]
|
|
1954
|
+
);
|
|
1955
|
+
await removeLegacyManagedRoute(
|
|
1956
|
+
resolve2(projectRoot, "src/routes/api/auth/user/+server.ts"),
|
|
1957
|
+
[
|
|
1958
|
+
["authenticated:", "guard:", "provider:", "user:"],
|
|
1959
|
+
[".holo-js/generated/sveltekit/auth-user-route"]
|
|
1960
|
+
]
|
|
1961
|
+
);
|
|
1962
|
+
await removeLegacyManagedRoute(
|
|
1963
|
+
resolve2(projectRoot, "src/routes/storage/[...path]/+server.ts"),
|
|
1964
|
+
[
|
|
1965
|
+
["createPublicStorageResponse", "app.config.storage"],
|
|
1966
|
+
[".holo-js/generated/sveltekit/storage-route"]
|
|
1967
|
+
]
|
|
1968
|
+
);
|
|
1969
|
+
await removeLegacyManagedRoute(
|
|
1970
|
+
resolve2(projectRoot, "src/routes/broadcasting/auth/+server.ts"),
|
|
1971
|
+
[
|
|
1972
|
+
["renderBroadcastAuthResponse", "channelAuth"],
|
|
1973
|
+
[".holo-js/generated/sveltekit/broadcast-auth-route"]
|
|
1974
|
+
]
|
|
1975
|
+
);
|
|
1976
|
+
if (!await directoryContainsText(resolve2(projectRoot, "src"), "$lib/server/holo")) {
|
|
1977
|
+
await removeLegacyManagedHoloHelper(resolve2(projectRoot, "src/lib/server/holo.ts"), renderSvelteHoloHelper());
|
|
1978
|
+
}
|
|
1742
1979
|
}
|
|
1743
1980
|
async function syncManagedFrameworkArtifacts(projectRoot) {
|
|
1744
1981
|
let manifest;
|
|
@@ -1749,7 +1986,10 @@ async function syncManagedFrameworkArtifacts(projectRoot) {
|
|
|
1749
1986
|
return;
|
|
1750
1987
|
}
|
|
1751
1988
|
if (manifest.framework === "sveltekit") {
|
|
1752
|
-
await
|
|
1989
|
+
const features = await resolveSvelteManagedFeatures(projectRoot);
|
|
1990
|
+
await ensureSvelteManagedRuntime(projectRoot);
|
|
1991
|
+
await ensureSvelteManagedHooks(projectRoot, features);
|
|
1992
|
+
await ensureSvelteManagedRoutes(projectRoot);
|
|
1753
1993
|
}
|
|
1754
1994
|
if (manifest.framework === "next") {
|
|
1755
1995
|
await ensureNextManagedRoutes(projectRoot);
|
|
@@ -2292,7 +2532,7 @@ function getConfigExtensionPriority(fileName) {
|
|
|
2292
2532
|
}
|
|
2293
2533
|
async function collectProjectConfigEntries(projectRoot) {
|
|
2294
2534
|
const configDir = resolve3(projectRoot, "config");
|
|
2295
|
-
const entries = await
|
|
2535
|
+
const entries = await readdir2(configDir, { withFileTypes: true }).catch(() => []);
|
|
2296
2536
|
const selectedByName = /* @__PURE__ */ new Map();
|
|
2297
2537
|
for (const entry of entries) {
|
|
2298
2538
|
if (!entry.isFile()) {
|