create-authenik8-app 2.4.14 → 2.4.15
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/README.md +34 -516
- package/dist/src/bin/cli.d.ts +3 -0
- package/dist/src/bin/cli.d.ts.map +1 -0
- package/dist/src/bin/cli.js +112 -0
- package/dist/src/bin/cli.js.map +1 -0
- package/dist/src/bin/index.js +108 -23
- package/dist/src/bin/index.js.map +1 -1
- package/dist/src/commands/add/apply.d.ts +6 -0
- package/dist/src/commands/add/apply.d.ts.map +1 -0
- package/dist/src/commands/add/apply.js +123 -0
- package/dist/src/commands/add/apply.js.map +1 -0
- package/dist/src/commands/add/ci.d.ts +6 -0
- package/dist/src/commands/add/ci.d.ts.map +1 -0
- package/dist/src/commands/add/ci.js +108 -0
- package/dist/src/commands/add/ci.js.map +1 -0
- package/dist/src/commands/add/context.d.ts +5 -0
- package/dist/src/commands/add/context.d.ts.map +1 -0
- package/dist/src/commands/add/context.js +19 -0
- package/dist/src/commands/add/context.js.map +1 -0
- package/dist/src/commands/add/diff.d.ts +4 -0
- package/dist/src/commands/add/diff.d.ts.map +1 -0
- package/dist/src/commands/add/diff.js +114 -0
- package/dist/src/commands/add/diff.js.map +1 -0
- package/dist/src/commands/add/index.d.ts +6 -0
- package/dist/src/commands/add/index.d.ts.map +1 -0
- package/dist/src/commands/add/index.js +61 -0
- package/dist/src/commands/add/index.js.map +1 -0
- package/dist/src/commands/add/output.d.ts +5 -0
- package/dist/src/commands/add/output.d.ts.map +1 -0
- package/dist/src/commands/add/output.js +58 -0
- package/dist/src/commands/add/output.js.map +1 -0
- package/dist/src/commands/add/plan.d.ts +6 -0
- package/dist/src/commands/add/plan.d.ts.map +1 -0
- package/dist/src/commands/add/plan.js +93 -0
- package/dist/src/commands/add/plan.js.map +1 -0
- package/dist/src/commands/add/registry.d.ts +4 -0
- package/dist/src/commands/add/registry.d.ts.map +1 -0
- package/dist/src/commands/add/registry.js +37 -0
- package/dist/src/commands/add/registry.js.map +1 -0
- package/dist/src/commands/add/types.d.ts +37 -0
- package/dist/src/commands/add/types.d.ts.map +1 -0
- package/dist/src/commands/add/types.js +2 -0
- package/dist/src/commands/add/types.js.map +1 -0
- package/dist/src/commands/doctor/checks.d.ts +3 -0
- package/dist/src/commands/doctor/checks.d.ts.map +1 -0
- package/dist/src/commands/doctor/checks.js +353 -0
- package/dist/src/commands/doctor/checks.js.map +1 -0
- package/dist/src/commands/doctor/context.d.ts +5 -0
- package/dist/src/commands/doctor/context.d.ts.map +1 -0
- package/dist/src/commands/doctor/context.js +134 -0
- package/dist/src/commands/doctor/context.js.map +1 -0
- package/dist/src/commands/doctor/index.d.ts +9 -0
- package/dist/src/commands/doctor/index.d.ts.map +1 -0
- package/dist/src/commands/doctor/index.js +80 -0
- package/dist/src/commands/doctor/index.js.map +1 -0
- package/dist/src/commands/doctor/output.d.ts +4 -0
- package/dist/src/commands/doctor/output.d.ts.map +1 -0
- package/dist/src/commands/doctor/output.js +53 -0
- package/dist/src/commands/doctor/output.js.map +1 -0
- package/dist/src/commands/doctor/postGeneration.d.ts +7 -0
- package/dist/src/commands/doctor/postGeneration.d.ts.map +1 -0
- package/dist/src/commands/doctor/postGeneration.js +22 -0
- package/dist/src/commands/doctor/postGeneration.js.map +1 -0
- package/dist/src/commands/doctor/services.d.ts +5 -0
- package/dist/src/commands/doctor/services.d.ts.map +1 -0
- package/dist/src/commands/doctor/services.js +80 -0
- package/dist/src/commands/doctor/services.js.map +1 -0
- package/dist/src/commands/doctor/types.d.ts +69 -0
- package/dist/src/commands/doctor/types.d.ts.map +1 -0
- package/dist/src/commands/doctor/types.js +2 -0
- package/dist/src/commands/doctor/types.js.map +1 -0
- package/dist/src/commands/upgrade/context.d.ts +5 -0
- package/dist/src/commands/upgrade/context.d.ts.map +1 -0
- package/dist/src/commands/upgrade/context.js +57 -0
- package/dist/src/commands/upgrade/context.js.map +1 -0
- package/dist/src/commands/upgrade/index.d.ts +7 -0
- package/dist/src/commands/upgrade/index.d.ts.map +1 -0
- package/dist/src/commands/upgrade/index.js +35 -0
- package/dist/src/commands/upgrade/index.js.map +1 -0
- package/dist/src/commands/upgrade/migrations.d.ts +4 -0
- package/dist/src/commands/upgrade/migrations.d.ts.map +1 -0
- package/dist/src/commands/upgrade/migrations.js +22 -0
- package/dist/src/commands/upgrade/migrations.js.map +1 -0
- package/dist/src/commands/upgrade/output.d.ts +4 -0
- package/dist/src/commands/upgrade/output.d.ts.map +1 -0
- package/dist/src/commands/upgrade/output.js +52 -0
- package/dist/src/commands/upgrade/output.js.map +1 -0
- package/dist/src/commands/upgrade/plan.d.ts +3 -0
- package/dist/src/commands/upgrade/plan.d.ts.map +1 -0
- package/dist/src/commands/upgrade/plan.js +119 -0
- package/dist/src/commands/upgrade/plan.js.map +1 -0
- package/dist/src/commands/upgrade/types.d.ts +48 -0
- package/dist/src/commands/upgrade/types.d.ts.map +1 -0
- package/dist/src/commands/upgrade/types.js +2 -0
- package/dist/src/commands/upgrade/types.js.map +1 -0
- package/dist/src/lib/args.d.ts +21 -0
- package/dist/src/lib/args.d.ts.map +1 -1
- package/dist/src/lib/args.js +119 -1
- package/dist/src/lib/args.js.map +1 -1
- package/dist/src/lib/constants.d.ts +1 -1
- package/dist/src/lib/constants.d.ts.map +1 -1
- package/dist/src/lib/constants.js +3 -1
- package/dist/src/lib/constants.js.map +1 -1
- package/dist/src/lib/expressOAuth.d.ts +10 -0
- package/dist/src/lib/expressOAuth.d.ts.map +1 -0
- package/dist/src/lib/expressOAuth.js +164 -0
- package/dist/src/lib/expressOAuth.js.map +1 -0
- package/dist/src/lib/interruption.d.ts +14 -0
- package/dist/src/lib/interruption.d.ts.map +1 -0
- package/dist/src/lib/interruption.js +16 -0
- package/dist/src/lib/interruption.js.map +1 -0
- package/dist/src/lib/nonInteractive.d.ts +8 -0
- package/dist/src/lib/nonInteractive.d.ts.map +1 -0
- package/dist/src/lib/nonInteractive.js +111 -0
- package/dist/src/lib/nonInteractive.js.map +1 -0
- package/dist/src/lib/oauth.d.ts +9 -0
- package/dist/src/lib/oauth.d.ts.map +1 -0
- package/dist/src/lib/oauth.js +62 -0
- package/dist/src/lib/oauth.js.map +1 -0
- package/dist/src/lib/onboarding.d.ts +8 -0
- package/dist/src/lib/onboarding.d.ts.map +1 -0
- package/dist/src/lib/onboarding.js +35 -0
- package/dist/src/lib/onboarding.js.map +1 -0
- package/dist/src/lib/packageManagerCommands.d.ts +11 -0
- package/dist/src/lib/packageManagerCommands.d.ts.map +1 -0
- package/dist/src/lib/packageManagerCommands.js +34 -0
- package/dist/src/lib/packageManagerCommands.js.map +1 -0
- package/dist/src/lib/process.d.ts.map +1 -1
- package/dist/src/lib/process.js +9 -0
- package/dist/src/lib/process.js.map +1 -1
- package/dist/src/lib/projectManifest.d.ts +67 -0
- package/dist/src/lib/projectManifest.d.ts.map +1 -0
- package/dist/src/lib/projectManifest.js +134 -0
- package/dist/src/lib/projectManifest.js.map +1 -0
- package/dist/src/lib/release.d.ts +9 -0
- package/dist/src/lib/release.d.ts.map +1 -0
- package/dist/src/lib/release.js +48 -0
- package/dist/src/lib/release.js.map +1 -0
- package/dist/src/lib/rootCommand.d.ts +15 -0
- package/dist/src/lib/rootCommand.d.ts.map +1 -0
- package/dist/src/lib/rootCommand.js +17 -0
- package/dist/src/lib/rootCommand.js.map +1 -0
- package/dist/src/lib/schemas.d.ts +15 -6
- package/dist/src/lib/schemas.d.ts.map +1 -1
- package/dist/src/lib/schemas.js +8 -1
- package/dist/src/lib/schemas.js.map +1 -1
- package/dist/src/lib/semver.d.ts +10 -0
- package/dist/src/lib/semver.d.ts.map +1 -0
- package/dist/src/lib/semver.js +51 -0
- package/dist/src/lib/semver.js.map +1 -0
- package/dist/src/lib/types.d.ts +5 -1
- package/dist/src/lib/types.d.ts.map +1 -1
- package/dist/src/steps/configurePrisma.d.ts.map +1 -1
- package/dist/src/steps/configurePrisma.js +18 -23
- package/dist/src/steps/configurePrisma.js.map +1 -1
- package/dist/src/steps/configureReadme.d.ts +4 -0
- package/dist/src/steps/configureReadme.d.ts.map +1 -0
- package/dist/src/steps/configureReadme.js +22 -0
- package/dist/src/steps/configureReadme.js.map +1 -0
- package/dist/src/steps/createProject.d.ts.map +1 -1
- package/dist/src/steps/createProject.js +16 -170
- package/dist/src/steps/createProject.js.map +1 -1
- package/dist/src/steps/finalSetup.d.ts +3 -2
- package/dist/src/steps/finalSetup.d.ts.map +1 -1
- package/dist/src/steps/finalSetup.js +14 -9
- package/dist/src/steps/finalSetup.js.map +1 -1
- package/dist/src/steps/installDeps.d.ts +1 -0
- package/dist/src/steps/installDeps.d.ts.map +1 -1
- package/dist/src/steps/installDeps.js +11 -0
- package/dist/src/steps/installDeps.js.map +1 -1
- package/dist/src/steps/prompts.d.ts.map +1 -1
- package/dist/src/steps/prompts.js +32 -13
- package/dist/src/steps/prompts.js.map +1 -1
- package/dist/src/utils/output.d.ts.map +1 -1
- package/dist/src/utils/output.js +23 -11
- package/dist/src/utils/output.js.map +1 -1
- package/package.json +5 -4
- package/templates/express-auth/README.md +21 -12
- package/templates/express-auth/package.json +11 -7
- package/templates/express-auth/src/config/redis.ts +109 -0
- package/templates/express-auth/src/server.ts +2 -0
- package/templates/express-auth+/README.md +25 -18
- package/templates/express-auth+/package.json +11 -7
- package/templates/express-auth+/src/auth/auth.ts +2 -0
- package/templates/express-auth+/src/auth/controllers/password.controller.ts +12 -1
- package/templates/express-auth+/src/auth/routes/password.route.ts +1 -0
- package/templates/express-auth+/src/config/redis.ts +109 -0
- package/templates/express-auth+/src/utils/security.ts +12 -0
- package/templates/express-base/README.md +21 -12
- package/templates/express-base/package.json +11 -8
- package/templates/express-base/src/.env.example +1 -1
- package/templates/express-base/src/config/redis.ts +109 -0
- package/templates/express-base/src/server.ts +2 -0
- package/templates/fullstack/.env.example +3 -2
- package/templates/fullstack/PRESET_CONTRACT.md +7 -3
- package/templates/fullstack/README.md +45 -7
- package/templates/fullstack/apps/api/package.json +6 -4
- package/templates/fullstack/apps/api/prisma/migrations/20260721000000_init/migration.sql +163 -0
- package/templates/fullstack/apps/api/prisma/migrations/migration_lock.toml +3 -0
- package/templates/fullstack/apps/api/src/auth/authenik8.ts +13 -4
- package/templates/fullstack/apps/api/src/config/env.ts +9 -1
- package/templates/fullstack/apps/api/src/config/logger.ts +21 -11
- package/templates/fullstack/apps/api/tests/logger.test.ts +43 -0
- package/templates/fullstack/apps/web/package.json +3 -1
- package/templates/fullstack/apps/web/src/App.tsx +1 -1
- package/templates/fullstack/apps/web/src/auth/RouteGuards.tsx +1 -1
- package/templates/fullstack/apps/web/src/components/AppShell.tsx +90 -45
- package/templates/fullstack/apps/web/src/components/AuthShell.tsx +10 -7
- package/templates/fullstack/apps/web/src/components/Page.tsx +6 -3
- package/templates/fullstack/apps/web/src/features/projects/ProjectPages.tsx +1 -1
- package/templates/fullstack/apps/web/src/main.tsx +13 -6
- package/templates/fullstack/apps/web/src/pages/DashboardPage.tsx +163 -23
- package/templates/fullstack/apps/web/src/pages/StatusPages.tsx +1 -1
- package/templates/fullstack/apps/web/src/pages/auth/LoginPage.tsx +93 -17
- package/templates/fullstack/apps/web/src/pages/auth/OAuthCallbackPage.tsx +1 -1
- package/templates/fullstack/apps/web/src/pages/auth/RecoveryPages.tsx +1 -1
- package/templates/fullstack/apps/web/src/pages/auth/RegisterPage.tsx +1 -1
- package/templates/fullstack/apps/web/src/pages/auth/VerifyEmailPage.tsx +1 -1
- package/templates/fullstack/apps/web/src/styles.css +119 -43
- package/templates/fullstack/apps/web/vite.config.ts +12 -0
- package/templates/fullstack/docker-compose.yml +2 -2
- package/templates/fullstack/gitignore.template +1 -0
- package/templates/fullstack/package.json +17 -8
- package/templates/fullstack/scripts/run-local.mjs +157 -0
- package/templates/prisma/postgresql/.env.example +1 -2
- package/templates/prisma/sqlite/.env.example +1 -2
- package/templates/prisma/sqlite/client.ts +2 -2
|
@@ -7,6 +7,18 @@ const apiProxy = {
|
|
|
7
7
|
|
|
8
8
|
export default defineConfig({
|
|
9
9
|
plugins: [react()],
|
|
10
|
+
build: {
|
|
11
|
+
rollupOptions: {
|
|
12
|
+
output: {
|
|
13
|
+
manualChunks(id) {
|
|
14
|
+
if (id.includes("/@astryxdesign/")) return "astryx-vendor";
|
|
15
|
+
if (id.includes("/react-router") || id.includes("/react-dom/") || id.includes("/react/")) return "react-vendor";
|
|
16
|
+
if (id.includes("/@tanstack/")) return "query-vendor";
|
|
17
|
+
if (id.includes("/lucide-react/")) return "icons-vendor";
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
10
22
|
server: {
|
|
11
23
|
port: 5173,
|
|
12
24
|
proxy: apiProxy,
|
|
@@ -6,7 +6,7 @@ services:
|
|
|
6
6
|
POSTGRES_USER: postgres
|
|
7
7
|
POSTGRES_PASSWORD: postgres
|
|
8
8
|
ports:
|
|
9
|
-
- "
|
|
9
|
+
- "127.0.0.1:55432:5432"
|
|
10
10
|
volumes:
|
|
11
11
|
- postgres-data:/var/lib/postgresql/data
|
|
12
12
|
healthcheck:
|
|
@@ -20,7 +20,7 @@ services:
|
|
|
20
20
|
image: redis:7-alpine
|
|
21
21
|
command: redis-server --appendonly yes
|
|
22
22
|
ports:
|
|
23
|
-
- "
|
|
23
|
+
- "127.0.0.1:56379:6379"
|
|
24
24
|
volumes:
|
|
25
25
|
- redis-data:/data
|
|
26
26
|
healthcheck:
|
|
@@ -8,32 +8,41 @@
|
|
|
8
8
|
"packages/*"
|
|
9
9
|
],
|
|
10
10
|
"engines": {
|
|
11
|
-
"node": "^
|
|
11
|
+
"node": "^22.22 || >=24"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
14
|
"build:packages": "npm run build -w @authenik8/contracts && npm run build -w @authenik8/api-client && npm run build -w @authenik8/ui",
|
|
15
|
-
"dev": "
|
|
15
|
+
"dev": "node scripts/run-local.mjs dev",
|
|
16
|
+
"dev:watch": "npm run build:packages && concurrently -n contracts,client,ui,api,web -c blue,green,yellow,cyan,magenta \"npm run dev -w @authenik8/contracts\" \"npm run dev -w @authenik8/api-client\" \"npm run dev -w @authenik8/ui\" \"npm run dev -w @authenik8/api\" \"npm run dev -w @authenik8/web\"",
|
|
16
17
|
"build": "npm run build:packages && npm run build -w @authenik8/web && npm run build -w @authenik8/api",
|
|
17
18
|
"start": "npm run start -w @authenik8/api",
|
|
18
19
|
"test": "npm run build:packages && npm run test -w @authenik8/api && npm run test -w @authenik8/web",
|
|
20
|
+
"pretypecheck": "npm run build:packages",
|
|
19
21
|
"typecheck": "npm run typecheck --workspaces --if-present",
|
|
20
22
|
"db:generate": "npm run prisma:generate -w @authenik8/api",
|
|
21
|
-
"
|
|
22
|
-
"db:
|
|
23
|
-
"db:
|
|
23
|
+
"setup": "node scripts/run-local.mjs setup",
|
|
24
|
+
"db:migrate": "node scripts/run-local.mjs migrate",
|
|
25
|
+
"db:migrate:apply": "npm run prisma:migrate -w @authenik8/api",
|
|
26
|
+
"db:seed": "node scripts/run-local.mjs seed",
|
|
27
|
+
"db:seed:apply": "npm run prisma:seed -w @authenik8/api",
|
|
28
|
+
"db:studio": "node scripts/run-local.mjs studio",
|
|
29
|
+
"db:studio:apply": "npm run prisma:studio -w @authenik8/api",
|
|
24
30
|
"docker:up": "docker compose up -d --wait",
|
|
25
31
|
"docker:down": "docker compose down"
|
|
26
32
|
},
|
|
27
33
|
"devDependencies": {
|
|
34
|
+
"@electric-sql/pglite": "0.4.1",
|
|
35
|
+
"@electric-sql/pglite-socket": "0.1.1",
|
|
28
36
|
"concurrently": "^9.2.1",
|
|
29
37
|
"typescript": "^6.0.3"
|
|
30
38
|
},
|
|
31
39
|
"overrides": {
|
|
32
|
-
"
|
|
40
|
+
"find-my-way": "9.7.0",
|
|
41
|
+
"valibot": "1.4.2"
|
|
33
42
|
},
|
|
34
43
|
"allowScripts": {
|
|
35
|
-
"prisma@7.
|
|
36
|
-
"@prisma/engines@7.
|
|
44
|
+
"prisma@7.9.0": true,
|
|
45
|
+
"@prisma/engines@7.9.0": true,
|
|
37
46
|
"esbuild": true
|
|
38
47
|
}
|
|
39
48
|
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { mkdirSync, readFileSync } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
|
+
const envPath = path.join(projectRoot, ".env");
|
|
8
|
+
const command = process.argv[2];
|
|
9
|
+
const commandScripts = {
|
|
10
|
+
dev: ["db:migrate:apply", "db:seed:apply", "dev:watch"],
|
|
11
|
+
migrate: ["db:migrate:apply"],
|
|
12
|
+
seed: ["db:seed:apply"],
|
|
13
|
+
setup: ["db:migrate:apply", "db:seed:apply"],
|
|
14
|
+
studio: ["db:studio:apply"],
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
function envValue(name) {
|
|
18
|
+
const processValue = process.env[name]?.trim();
|
|
19
|
+
if (processValue) return processValue;
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
const line = readFileSync(envPath, "utf8")
|
|
23
|
+
.split(/\r?\n/)
|
|
24
|
+
.find((candidate) => candidate.startsWith(`${name}=`));
|
|
25
|
+
return line?.slice(name.length + 1).trim().replace(/^(['"])(.*)\1$/, "$2");
|
|
26
|
+
} catch {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
function npmInvocation(script) {
|
|
33
|
+
|
|
34
|
+
if (process.platform === "win32") {
|
|
35
|
+
return {
|
|
36
|
+
executable: process.env.ComSpec ?? "cmd.exe",
|
|
37
|
+
args: ["/d", "/s", "/c", `npm run ${script}`],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
executable: "npm",
|
|
43
|
+
args: ["run", script],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function runScript(script, environment) {
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
//const executable = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
50
|
+
//const child = spawn(executable, ["run", script], {
|
|
51
|
+
const { executable, args } = npmInvocation(script);
|
|
52
|
+
const child = spawn(executable, args,{
|
|
53
|
+
cwd: projectRoot,
|
|
54
|
+
env: environment,
|
|
55
|
+
stdio: "inherit",
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
activeChild = child;
|
|
59
|
+
child.once("error", reject);
|
|
60
|
+
child.once("exit", (code, signal) => {
|
|
61
|
+
activeChild = undefined;
|
|
62
|
+
if (code === 0 || receivedSignal) {
|
|
63
|
+
resolve();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
reject(new Error(`npm run ${script} exited with ${signal ?? code}`));
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function startEmbeddedDatabase() {
|
|
72
|
+
const [{ PGlite }, { PGLiteSocketServer }] = await Promise.all([
|
|
73
|
+
import("@electric-sql/pglite"),
|
|
74
|
+
import("@electric-sql/pglite-socket"),
|
|
75
|
+
]);
|
|
76
|
+
const databaseDirectory = path.join(projectRoot, ".authenik8", "postgres");
|
|
77
|
+
mkdirSync(databaseDirectory, { recursive: true });
|
|
78
|
+
const database = await PGlite.create(databaseDirectory);
|
|
79
|
+
const server = new PGLiteSocketServer({
|
|
80
|
+
db: database,
|
|
81
|
+
host: "127.0.0.1",
|
|
82
|
+
port: 55432,
|
|
83
|
+
maxConnections: 20,
|
|
84
|
+
});
|
|
85
|
+
await server.start();
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
connectionString: `postgresql://postgres:postgres@${server.getServerConn()}/template1?sslmode=disable`,
|
|
89
|
+
async close() {
|
|
90
|
+
await server.stop();
|
|
91
|
+
await database.close();
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (!Object.hasOwn(commandScripts, command)) {
|
|
97
|
+
console.error("Usage: node scripts/run-local.mjs <dev|migrate|seed|setup|studio>");
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let activeChild;
|
|
102
|
+
let receivedSignal;
|
|
103
|
+
for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
104
|
+
process.once(signal, () => {
|
|
105
|
+
receivedSignal = signal;
|
|
106
|
+
activeChild?.kill(signal);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
let database;
|
|
111
|
+
let failed = false;
|
|
112
|
+
try {
|
|
113
|
+
const databaseMode = envValue("AUTHENIK8_LOCAL_DATABASE")?.toLowerCase() || "embedded";
|
|
114
|
+
if (databaseMode !== "embedded" && databaseMode !== "external") {
|
|
115
|
+
throw new Error("AUTHENIK8_LOCAL_DATABASE must be embedded or external");
|
|
116
|
+
}
|
|
117
|
+
const configuredRedisUrl = envValue("REDIS_URL");
|
|
118
|
+
|
|
119
|
+
const environment = { ...process.env,
|
|
120
|
+
REDIS_URL: configuredRedisUrl ||
|
|
121
|
+
(process.env.NODE_ENV === "production" ? process.env.REDIS_URL : "memory://")
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
if (databaseMode === "embedded") {
|
|
126
|
+
console.log("Starting the project-local PostgreSQL database...");
|
|
127
|
+
database = await startEmbeddedDatabase();
|
|
128
|
+
console.log("Project-local PostgreSQL is ready.");
|
|
129
|
+
} else {
|
|
130
|
+
console.log("Using DATABASE_URL from .env.");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
for (const script of commandScripts[command]) {
|
|
134
|
+
if (receivedSignal) break;
|
|
135
|
+
await runScript(script, database
|
|
136
|
+
? {
|
|
137
|
+
...environment,
|
|
138
|
+
DATABASE_URL: database.connectionString,
|
|
139
|
+
}
|
|
140
|
+
: environment);
|
|
141
|
+
}
|
|
142
|
+
} catch (error) {
|
|
143
|
+
failed = true;
|
|
144
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
145
|
+
console.error(`\nLocal startup failed: ${message}`);
|
|
146
|
+
console.error(
|
|
147
|
+
"Using an external PostgreSQL database? Set AUTHENIK8_LOCAL_DATABASE=external and update DATABASE_URL in .env.\n",
|
|
148
|
+
);
|
|
149
|
+
} finally {
|
|
150
|
+
await database?.close();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (failed) {
|
|
154
|
+
process.exitCode = 1;
|
|
155
|
+
} else if (receivedSignal) {
|
|
156
|
+
process.exitCode = receivedSignal === "SIGINT" ? 130 : 143;
|
|
157
|
+
}
|
|
@@ -5,8 +5,7 @@ AUTHENIK8_ISSUER="http://localhost:3000"
|
|
|
5
5
|
AUTHENIK8_AUDIENCE="authenik8-app-api"
|
|
6
6
|
AUTHENIK8_AGENTS={}
|
|
7
7
|
REFRESH_SECRET="replace-with-at-least-32-random-characters"
|
|
8
|
-
|
|
9
|
-
REDIS_PORT="6379"
|
|
8
|
+
REDIS_URL="memory://"
|
|
10
9
|
GOOGLE_CLIENT_ID="change-me-google-client-id"
|
|
11
10
|
GOOGLE_CLIENT_SECRET="change-me-google-client-secret"
|
|
12
11
|
GOOGLE_REDIRECT_URI="http://localhost:3000/auth/google/callback"
|
|
@@ -5,8 +5,7 @@ AUTHENIK8_ISSUER="http://localhost:3000"
|
|
|
5
5
|
AUTHENIK8_AUDIENCE="authenik8-app-api"
|
|
6
6
|
AUTHENIK8_AGENTS={}
|
|
7
7
|
REFRESH_SECRET="replace-with-at-least-32-random-characters"
|
|
8
|
-
|
|
9
|
-
REDIS_PORT="6379"
|
|
8
|
+
REDIS_URL="memory://"
|
|
10
9
|
GOOGLE_CLIENT_ID="change-me-google-client-id"
|
|
11
10
|
GOOGLE_CLIENT_SECRET="change-me-google-client-secret"
|
|
12
11
|
GOOGLE_REDIRECT_URI="http://localhost:3000/auth/google/callback"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "dotenv/config";
|
|
2
|
-
import {
|
|
2
|
+
import { PrismaLibSql } from "@prisma/adapter-libsql";
|
|
3
3
|
import { PrismaClient } from "@prisma/client";
|
|
4
4
|
|
|
5
5
|
const globalForPrisma = globalThis as unknown as {
|
|
6
6
|
prisma: PrismaClient | undefined;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
const adapter = new
|
|
9
|
+
const adapter = new PrismaLibSql({
|
|
10
10
|
url: process.env.DATABASE_URL ?? "file:./dev.db",
|
|
11
11
|
});
|
|
12
12
|
export const prisma = globalForPrisma.prisma ?? new PrismaClient({ adapter });
|