@podosoft/podokit 0.14.0 → 0.16.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/README.md +20 -0
- package/dist/add.d.ts +4 -0
- package/dist/add.js +59 -1
- package/dist/create.js +8 -1
- package/dist/deploy-profile.d.ts +92 -0
- package/dist/deploy-profile.js +603 -0
- package/dist/deploy-render.d.ts +18 -0
- package/dist/deploy-render.js +651 -0
- package/dist/deploy.d.ts +65 -0
- package/dist/deploy.js +851 -0
- package/dist/dev.d.ts +1 -0
- package/dist/dev.js +29 -5
- package/dist/index.d.ts +8 -0
- package/dist/index.js +147 -1
- package/dist/lib.d.ts +6 -0
- package/dist/lib.js +18 -1
- package/dist/lockfile.js +3 -0
- package/dist/remove.js +7 -0
- package/dist/templates/fullstack-nest-svelte/AGENTS.md +1 -0
- package/dist/templates/fullstack-nest-svelte/README.md +19 -8
- package/dist/templates/fullstack-nest-svelte/apps/api/Dockerfile +2 -2
- package/dist/templates/fullstack-nest-svelte/apps/api/package.json +1 -0
- package/dist/templates/fullstack-nest-svelte/apps/api/src/config/redis.connection.spec.ts +53 -0
- package/dist/templates/fullstack-nest-svelte/apps/api/src/config/redis.connection.ts +69 -0
- package/dist/templates/fullstack-nest-svelte/apps/api/src/database/migrate.ts +16 -0
- package/dist/templates/fullstack-nest-svelte/apps/api/src/health/health.controller.ts +19 -4
- package/dist/templates/fullstack-nest-svelte/apps/api/src/health/health.module.ts +5 -1
- package/dist/templates/fullstack-nest-svelte/apps/api/src/health/readiness.service.spec.ts +22 -0
- package/dist/templates/fullstack-nest-svelte/apps/api/src/health/readiness.service.ts +33 -0
- package/dist/templates/fullstack-nest-svelte/apps/web/Dockerfile +2 -2
- package/dist/templates/fullstack-nest-svelte/apps/web/src/app.html +2 -0
- package/dist/templates/fullstack-nest-svelte/compose.dev.yaml +3 -5
- package/dist/templates/fullstack-nest-svelte/dot-agents/skills/podokit-deploy/SKILL.md +20 -0
- package/dist/templates/fullstack-nest-svelte/dot-agents/skills/podokit-deploy/agents/openai.yaml +4 -0
- package/dist/templates/fullstack-nest-svelte/dot-agents/skills/podokit-deploy/references/profile.md +37 -0
- package/dist/templates/fullstack-nest-svelte/dot-agents/skills/podokit-deploy/references/rollback.md +18 -0
- package/dist/templates/fullstack-nest-svelte/dot-claude/skills/podokit-deploy/SKILL.md +8 -0
- package/dist/templates/fullstack-nest-svelte/dot-env.example +6 -0
- package/dist/templates/fullstack-nest-svelte/infra/k3s/api-deployment.yaml +1 -1
- package/dist/templates/fullstack-nest-svelte/infra/k3s/ingress.yaml +0 -4
- package/dist/templates/fullstack-nest-svelte/tests/playwright.config.ts +6 -4
- package/dist/templates/fullstack-nest-svelte/tests/playwright.extensions.ts +44 -0
- package/dist/templates/modules/admin-dashboard/files/apps/web/src/lib/components/account-menu.svelte +35 -4
- package/dist/templates/modules/admin-dashboard/files/apps/web/src/lib/components/data-table.svelte +33 -4
- package/dist/templates/modules/admin-dashboard/files/apps/web/src/lib/components/site-runtime.svelte +6 -0
- package/dist/templates/modules/admin-dashboard/files/apps/web/src/routes/(admin)/admin/users/+page.svelte +18 -10
- package/dist/templates/modules/admin-dashboard/files/dot-claude/skills/podokit-data-table/SKILL.md +11 -6
- package/dist/templates/modules/admin-dashboard/files/tests/api/audit.api.spec.ts +18 -8
- package/dist/templates/modules/admin-dashboard/files/tests/api/users-admin.api.spec.ts +15 -9
- package/dist/templates/modules/admin-dashboard/files/tests/helpers/accounts.ts +1 -0
- package/dist/templates/modules/admin-dashboard/files/tests/helpers/disposable-users.ts +83 -0
- package/dist/templates/modules/admin-dashboard/files/tests/playwright.config.ts +13 -10
- package/dist/templates/modules/admin-dashboard/files/tests/seed.setup.ts +69 -3
- package/dist/templates/modules/admin-dashboard/files/tests/seed.teardown.ts +46 -0
- package/dist/templates/modules/admin-dashboard/files/tests/ui/data-table.ui.spec.ts +13 -0
- package/dist/templates/modules/admin-dashboard/files/tests/ui/email-admin.ui.spec.ts +3 -6
- package/dist/templates/modules/admin-dashboard/files/tests/ui/users-crud.ui.spec.ts +34 -28
- package/dist/templates/modules/admin-dashboard/files/tests/ui/users.ui.spec.ts +29 -39
- package/dist/templates/modules/admin-dashboard/module.manifest.json +1 -1
- package/dist/templates/modules/api-key-auth/files/apps/api/src/api-key/api-key-verifier.spec.ts +36 -0
- package/dist/templates/modules/api-key-auth/files/apps/api/src/api-key/api-key-verifier.ts +20 -0
- package/dist/templates/modules/api-key-auth/files/apps/api/src/api-key/api-key.guard.spec.ts +49 -0
- package/dist/templates/modules/api-key-auth/files/apps/api/src/api-key/api-key.guard.ts +3 -11
- package/dist/templates/modules/api-key-auth/files/apps/api/src/api-key/api-key.module.ts +3 -1
- package/dist/templates/modules/api-key-auth/module.manifest.json +1 -1
- package/dist/templates/modules/auth/files/apps/api/src/auth/auth-environment.ts +32 -0
- package/dist/templates/modules/auth/files/apps/api/src/auth/auth.runtime.spec.ts +35 -0
- package/dist/templates/modules/auth/files/apps/api/src/auth/auth.ts +3 -2
- package/dist/templates/modules/auth/files/apps/api/src/health/health.controller.ts +19 -4
- package/dist/templates/modules/bullmq/files/apps/api/src/jobs/queue.ts +4 -5
- package/dist/templates/modules/bullmq/module.manifest.json +4 -1
- package/dist/templates/modules/job-progress/files/apps/api/src/progress/progress.bridge.spec.ts +36 -0
- package/dist/templates/modules/job-progress/files/apps/api/src/progress/progress.bridge.ts +26 -5
- package/dist/templates/modules/object-storage-s3/files/apps/api/src/storage/storage.service.spec.ts +35 -0
- package/dist/templates/modules/object-storage-s3/files/apps/api/src/storage/storage.service.ts +21 -2
- package/dist/templates/modules/object-storage-s3/module.manifest.json +3 -0
- package/dist/templates/modules/rate-limit/files/apps/api/src/rate-limit/rate-limit.config.spec.ts +85 -0
- package/dist/templates/modules/rate-limit/files/apps/api/src/rate-limit/rate-limit.config.ts +110 -0
- package/dist/templates/modules/rate-limit/files/apps/api/src/rate-limit/rate-limit.identity.spec.ts +132 -0
- package/dist/templates/modules/rate-limit/files/apps/api/src/rate-limit/rate-limit.identity.ts +100 -0
- package/dist/templates/modules/rate-limit/files/apps/api/src/rate-limit/rate-limit.module.integration.spec.ts +91 -0
- package/dist/templates/modules/rate-limit/files/apps/api/src/rate-limit/rate-limit.module.spec.ts +228 -0
- package/dist/templates/modules/rate-limit/files/apps/api/src/rate-limit/rate-limit.module.ts +97 -38
- package/dist/templates/modules/rate-limit/files/tests/api/rate-limit.api.spec.ts +11 -6
- package/dist/templates/modules/rate-limit/module.manifest.json +23 -9
- package/dist/templates/modules/redis/files/apps/api/src/redis/redis.service.spec.ts +28 -0
- package/dist/templates/modules/redis/files/apps/api/src/redis/redis.service.ts +52 -11
- package/dist/templates/modules/redis/module.manifest.json +16 -1
- package/dist/templates/modules/sse/files/apps/api/src/events/events.controller.ts +17 -3
- package/dist/templates/modules/sse/files/apps/api/src/events/events.module.ts +9 -2
- package/dist/templates/modules/sse/files/apps/api/src/events/events.service.spec.ts +61 -0
- package/dist/templates/modules/sse/files/apps/api/src/events/events.service.ts +44 -4
- package/dist/templates/modules/sse/files/apps/api/src/events/events.transport.redis.spec.ts +42 -0
- package/dist/templates/modules/sse/files/apps/api/src/events/events.transport.spec.ts +97 -0
- package/dist/templates/modules/sse/files/apps/api/src/events/events.transport.ts +165 -0
- package/dist/templates/modules/sse/files/tests/api/events.api.spec.ts +41 -0
- package/dist/templates/modules/sse/module.manifest.json +16 -3
- package/dist/templates/todo/AGENTS.md +1 -0
- package/dist/templates/todo/README.md +12 -8
- package/dist/templates/todo/apps/api/Dockerfile +2 -2
- package/dist/templates/todo/apps/api/package.json +1 -0
- package/dist/templates/todo/apps/api/src/config/redis.connection.spec.ts +53 -0
- package/dist/templates/todo/apps/api/src/config/redis.connection.ts +69 -0
- package/dist/templates/todo/apps/api/src/database/migrate.ts +16 -0
- package/dist/templates/todo/apps/api/src/health/health.controller.ts +19 -4
- package/dist/templates/todo/apps/api/src/health/health.module.ts +5 -1
- package/dist/templates/todo/apps/api/src/health/readiness.service.spec.ts +22 -0
- package/dist/templates/todo/apps/api/src/health/readiness.service.ts +33 -0
- package/dist/templates/todo/apps/web/Dockerfile +2 -2
- package/dist/templates/todo/compose.dev.yaml +3 -5
- package/dist/templates/todo/dot-agents/skills/podokit-deploy/SKILL.md +20 -0
- package/dist/templates/todo/dot-agents/skills/podokit-deploy/agents/openai.yaml +4 -0
- package/dist/templates/todo/dot-agents/skills/podokit-deploy/references/profile.md +28 -0
- package/dist/templates/todo/dot-agents/skills/podokit-deploy/references/rollback.md +5 -0
- package/dist/templates/todo/dot-claude/skills/podokit-deploy/SKILL.md +8 -0
- package/dist/templates/todo/dot-env.example +6 -0
- package/dist/templates/todo/infra/k3s/api-deployment.yaml +1 -1
- package/dist/templates/todo/infra/k3s/ingress.yaml +0 -4
- package/dist/templates/todo/tests/playwright.config.ts +6 -4
- package/dist/templates/todo/tests/playwright.extensions.ts +44 -0
- package/dist/update.js +17 -13
- package/package.json +2 -2
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export interface RedisConnectionOptions {
|
|
2
|
+
host: string;
|
|
3
|
+
port: number;
|
|
4
|
+
db: number;
|
|
5
|
+
username?: string;
|
|
6
|
+
password?: string;
|
|
7
|
+
tls?: Record<string, never>;
|
|
8
|
+
lazyConnect?: boolean;
|
|
9
|
+
enableReadyCheck?: boolean;
|
|
10
|
+
enableOfflineQueue?: boolean;
|
|
11
|
+
maxRetriesPerRequest?: number | null;
|
|
12
|
+
connectTimeout?: number;
|
|
13
|
+
commandTimeout?: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function integer(name: string, value: string | undefined, fallback: number): number {
|
|
17
|
+
if (value === undefined || value === "") return fallback;
|
|
18
|
+
const parsed = Number(value);
|
|
19
|
+
if (!Number.isInteger(parsed) || parsed < 0) {
|
|
20
|
+
throw new Error(`${name} must be a non-negative integer`);
|
|
21
|
+
}
|
|
22
|
+
return parsed;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function decoded(value: string, name: string): string {
|
|
26
|
+
try {
|
|
27
|
+
return decodeURIComponent(value);
|
|
28
|
+
} catch {
|
|
29
|
+
throw new Error(`${name} contains invalid percent encoding`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function fromUrl(value: string): RedisConnectionOptions {
|
|
34
|
+
let url: URL;
|
|
35
|
+
try {
|
|
36
|
+
url = new URL(value);
|
|
37
|
+
} catch {
|
|
38
|
+
throw new Error("REDIS_URL must be a valid redis:// or rediss:// URL");
|
|
39
|
+
}
|
|
40
|
+
if (url.protocol !== "redis:" && url.protocol !== "rediss:") {
|
|
41
|
+
throw new Error("REDIS_URL must use the redis:// or rediss:// protocol");
|
|
42
|
+
}
|
|
43
|
+
const dbPath = url.pathname.replace(/^\/+/, "");
|
|
44
|
+
return {
|
|
45
|
+
host: url.hostname || "localhost",
|
|
46
|
+
port: integer("REDIS_URL port", url.port, 6379),
|
|
47
|
+
db: integer("REDIS_URL database", dbPath, 0),
|
|
48
|
+
...(url.username ? { username: decoded(url.username, "REDIS_URL username") } : {}),
|
|
49
|
+
...(url.password ? { password: decoded(url.password, "REDIS_URL password") } : {}),
|
|
50
|
+
...(url.protocol === "rediss:" ? { tls: {} } : {}),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function redisConnectionOptions(
|
|
55
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
56
|
+
overrides: Partial<RedisConnectionOptions> = {},
|
|
57
|
+
): RedisConnectionOptions {
|
|
58
|
+
const base = env.REDIS_URL
|
|
59
|
+
? fromUrl(env.REDIS_URL)
|
|
60
|
+
: {
|
|
61
|
+
host: env.REDIS_HOST ?? "localhost",
|
|
62
|
+
port: integer("REDIS_PORT", env.REDIS_PORT, 6379),
|
|
63
|
+
db: integer("REDIS_DB", env.REDIS_DB, 0),
|
|
64
|
+
...(env.REDIS_USERNAME ? { username: env.REDIS_USERNAME } : {}),
|
|
65
|
+
...(env.REDIS_PASSWORD ? { password: env.REDIS_PASSWORD } : {}),
|
|
66
|
+
...(env.REDIS_TLS === "true" ? { tls: {} } : {}),
|
|
67
|
+
};
|
|
68
|
+
return { ...base, ...overrides };
|
|
69
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import dataSource from "./data-source";
|
|
2
|
+
|
|
3
|
+
async function migrate(): Promise<void> {
|
|
4
|
+
await dataSource.initialize();
|
|
5
|
+
try {
|
|
6
|
+
await dataSource.runMigrations({ transaction: "all" });
|
|
7
|
+
} finally {
|
|
8
|
+
await dataSource.destroy();
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
void migrate().catch((error: unknown) => {
|
|
13
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
14
|
+
process.stderr.write(`Migration failed: ${message}\n`);
|
|
15
|
+
process.exitCode = 1;
|
|
16
|
+
});
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { Controller, Get, ServiceUnavailableException } from "@nestjs/common";
|
|
2
2
|
import { InjectDataSource } from "@nestjs/typeorm";
|
|
3
3
|
import { DataSource } from "typeorm";
|
|
4
|
+
import { ReadinessService, type ReadinessStatus } from "./readiness.service";
|
|
5
|
+
|
|
6
|
+
interface ReadinessResponse {
|
|
7
|
+
status: "ready";
|
|
8
|
+
db: "up";
|
|
9
|
+
checks: Record<string, ReadinessStatus>;
|
|
10
|
+
}
|
|
4
11
|
|
|
5
12
|
@Controller("health")
|
|
6
13
|
export class HealthController {
|
|
7
|
-
constructor(
|
|
14
|
+
constructor(
|
|
15
|
+
@InjectDataSource() private readonly dataSource: DataSource,
|
|
16
|
+
private readonly readinessService: ReadinessService,
|
|
17
|
+
) {}
|
|
8
18
|
|
|
9
19
|
@Get()
|
|
10
20
|
liveness(): { status: string; uptime: number; timestamp: string } {
|
|
@@ -12,12 +22,17 @@ export class HealthController {
|
|
|
12
22
|
}
|
|
13
23
|
|
|
14
24
|
@Get("ready")
|
|
15
|
-
async readiness(): Promise<
|
|
25
|
+
async readiness(): Promise<ReadinessResponse> {
|
|
26
|
+
let db: ReadinessStatus = "up";
|
|
16
27
|
try {
|
|
17
28
|
await this.dataSource.query("SELECT 1");
|
|
18
|
-
return { status: "ready", db: "up" };
|
|
19
29
|
} catch {
|
|
20
|
-
|
|
30
|
+
db = "down";
|
|
31
|
+
}
|
|
32
|
+
const checks = await this.readinessService.run();
|
|
33
|
+
if (db === "down" || Object.values(checks).includes("down")) {
|
|
34
|
+
throw new ServiceUnavailableException({ status: "degraded", db, checks });
|
|
21
35
|
}
|
|
36
|
+
return { status: "ready", db: "up", checks };
|
|
22
37
|
}
|
|
23
38
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { Module } from "@nestjs/common";
|
|
1
|
+
import { Global, Module } from "@nestjs/common";
|
|
2
2
|
import { HealthController } from "./health.controller";
|
|
3
|
+
import { ReadinessService } from "./readiness.service";
|
|
3
4
|
|
|
5
|
+
@Global()
|
|
4
6
|
@Module({
|
|
5
7
|
controllers: [HealthController],
|
|
8
|
+
providers: [ReadinessService],
|
|
9
|
+
exports: [ReadinessService],
|
|
6
10
|
})
|
|
7
11
|
export class HealthModule {}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { describe, expect, it } from "@jest/globals";
|
|
2
|
+
import { ReadinessService } from "./readiness.service";
|
|
3
|
+
|
|
4
|
+
describe("ReadinessService", () => {
|
|
5
|
+
it("runs registered checks and removes them with the returned callback", async () => {
|
|
6
|
+
const service = new ReadinessService();
|
|
7
|
+
const unregister = service.register("cache", () => Promise.resolve());
|
|
8
|
+
service.register("events", () => Promise.reject(new Error("unavailable")));
|
|
9
|
+
|
|
10
|
+
await expect(service.run()).resolves.toEqual({ cache: "up", events: "down" });
|
|
11
|
+
unregister();
|
|
12
|
+
await expect(service.run()).resolves.toEqual({ events: "down" });
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("rejects duplicate names", () => {
|
|
16
|
+
const service = new ReadinessService();
|
|
17
|
+
service.register("cache", () => Promise.resolve());
|
|
18
|
+
expect(() => service.register("cache", () => Promise.resolve())).toThrow(
|
|
19
|
+
'Readiness check "cache" is already registered',
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Injectable } from "@nestjs/common";
|
|
2
|
+
|
|
3
|
+
export type ReadinessStatus = "up" | "down";
|
|
4
|
+
export type ReadinessCheck = () => Promise<void>;
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class ReadinessService {
|
|
8
|
+
private readonly checks = new Map<string, ReadinessCheck>();
|
|
9
|
+
|
|
10
|
+
register(name: string, check: ReadinessCheck): () => void {
|
|
11
|
+
if (this.checks.has(name)) {
|
|
12
|
+
throw new Error(`Readiness check "${name}" is already registered`);
|
|
13
|
+
}
|
|
14
|
+
this.checks.set(name, check);
|
|
15
|
+
return () => {
|
|
16
|
+
this.checks.delete(name);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async run(): Promise<Record<string, ReadinessStatus>> {
|
|
21
|
+
const results = await Promise.all(
|
|
22
|
+
[...this.checks].map(async ([name, check]): Promise<[string, ReadinessStatus]> => {
|
|
23
|
+
try {
|
|
24
|
+
await check();
|
|
25
|
+
return [name, "up"];
|
|
26
|
+
} catch {
|
|
27
|
+
return [name, "down"];
|
|
28
|
+
}
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
31
|
+
return Object.fromEntries(results);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -16,11 +16,11 @@ RUN npm run build --workspace=apps/web
|
|
|
16
16
|
FROM node:22-alpine AS runtime
|
|
17
17
|
WORKDIR /app
|
|
18
18
|
ENV NODE_ENV=production
|
|
19
|
-
RUN addgroup -S app && adduser -S
|
|
19
|
+
RUN addgroup -S -g 101 app && adduser -S -D -H -u 100 -G app app
|
|
20
20
|
COPY --from=build /app/node_modules ./node_modules
|
|
21
21
|
COPY --from=deps /app/apps/web ./apps/web
|
|
22
22
|
COPY --from=build /app/apps/web/build ./apps/web/build
|
|
23
23
|
WORKDIR /app/apps/web
|
|
24
|
-
USER
|
|
24
|
+
USER 100:101
|
|
25
25
|
EXPOSE 3000
|
|
26
26
|
CMD ["node", "build"]
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
# Containerized development environment.
|
|
2
2
|
#
|
|
3
|
-
# podo dev watch
|
|
4
|
-
# podo dev watch --profile cache --profile storage \
|
|
5
|
-
# --profile queue # with modules
|
|
3
|
+
# podo dev watch # installed modules activate their required profiles
|
|
6
4
|
#
|
|
7
5
|
# A user-level PodoKit gateway owns loopback :80 and routes each *.localhost host
|
|
8
6
|
# to this stack. The legacy per-project Traefik service is opt-in only.
|
|
9
7
|
# api/postgres/redis/minio have NO published ports — they talk by service name
|
|
10
8
|
# on the internal network, so this stack never collides with other projects.
|
|
11
9
|
#
|
|
12
|
-
# Core services (traefik, web, api, postgres) always run.
|
|
13
|
-
#
|
|
10
|
+
# Core services (traefik, web, api, postgres) always run. PodoKit activates
|
|
11
|
+
# module-specific profiles from .podokit/manifest.json:
|
|
14
12
|
# --profile cache redis (redis / rate-limit / bullmq modules)
|
|
15
13
|
# --profile storage minio (object-storage-s3 / file-upload modules)
|
|
16
14
|
# --profile queue worker (bullmq / job-progress modules)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: podokit-deploy
|
|
3
|
+
description: Plan, inspect, apply, verify, and roll back PodoKit Kubernetes releases with an explicit deployment profile and confirmation hash. Use when an agent needs to initialize a .podokit/deploy profile, diagnose a target cluster, preview a release, perform an approved deployment, inspect rollout state, verify public endpoints, or prepare an application rollback.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Deploy a PodoKit application
|
|
7
|
+
|
|
8
|
+
1. Run `npx @podosoft/podokit status`, `npx @podosoft/podokit diff`, and `npx @podosoft/podokit doctor`. Stop if managed-file conflicts or unsupported framework versions could make the image unreliable.
|
|
9
|
+
2. Read [references/profile.md](references/profile.md) before creating or changing a deployment profile.
|
|
10
|
+
3. Run `npx @podosoft/podokit deploy doctor --profile <name>`. Resolve every failure without printing Secret values.
|
|
11
|
+
4. Run `npx @podosoft/podokit deploy plan --profile <name> --release <stable-semver> --json`.
|
|
12
|
+
5. Show the user the context, cluster fingerprint result, namespace, Helm release, exact images, current revision and status, actions, migration warning, and plan hash.
|
|
13
|
+
6. Do not apply until the user explicitly approves that exact plan.
|
|
14
|
+
7. Apply with `npx @podosoft/podokit deploy apply --profile <name> --release <stable-semver> --confirm <plan-hash>`.
|
|
15
|
+
8. Run `npx @podosoft/podokit deploy status --profile <name> --json` and `npx @podosoft/podokit deploy verify --profile <name> --json`.
|
|
16
|
+
9. Report the exact images, Helm revision, ready replicas, restart totals, and verification result.
|
|
17
|
+
|
|
18
|
+
For rollback, read [references/rollback.md](references/rollback.md), preview the target revision without `--confirm`, show the new plan hash, and obtain explicit approval.
|
|
19
|
+
|
|
20
|
+
Never create or rotate cluster credentials, registry credentials, DNS, virtual machines, Kubernetes Secrets, or backup repositories. Never put a password, token, private key, connection URL containing credentials, or Secret value in a profile, command argument, log, or report.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Deployment profile
|
|
2
|
+
|
|
3
|
+
The profile at `.podokit/deploy/<name>.json` is application-owned and contains no Secret values.
|
|
4
|
+
|
|
5
|
+
Initialize it with an explicit kubeconfig context:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx @podosoft/podokit deploy init --profile production --context production --host app.example.com
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Review the target, immutable API/web repositories, exposure, workloads, dependency modes, API/optional web Secret names and required keys, non-sensitive runtime configuration, and verification checks before planning.
|
|
12
|
+
|
|
13
|
+
The cluster namespace and referenced Secrets must already exist. PodoKit asks `kubectl` to output only Secret key names and never prints or stores their values; the Kubernetes client still materializes the Secret while evaluating that output.
|
|
14
|
+
|
|
15
|
+
Required keys:
|
|
16
|
+
|
|
17
|
+
| Secret | Required keys |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| API | Profile-declared keys plus enabled dependency connection keys: `POSTGRES_USER`, `POSTGRES_PASSWORD`, `POSTGRES_DB`, `REDIS_PASSWORD`, `S3_ACCESS_KEY_ID`, `S3_SECRET_ACCESS_KEY` |
|
|
20
|
+
| web | Only explicitly declared web keys; omitted by default |
|
|
21
|
+
| PostgreSQL dependency | `POSTGRES_USER`, `POSTGRES_PASSWORD`, `POSTGRES_DB` |
|
|
22
|
+
| Redis dependency | `REDIS_PASSWORD` |
|
|
23
|
+
| Object storage dependency | `MINIO_ROOT_USER`, `MINIO_ROOT_PASSWORD`, `S3_ACCESS_KEY_ID`, `S3_SECRET_ACCESS_KEY` |
|
|
24
|
+
| image pull | A `kubernetes.io/dockerconfigjson` Secret |
|
|
25
|
+
|
|
26
|
+
Use `inCluster` when the generated Helm release should manage a dependency, `external` when application configuration points to an existing service, and `disabled` only when the application does not require it.
|
|
27
|
+
|
|
28
|
+
Use the same stable SemVer tag for API and web. `latest`, branch tags, and empty tags are rejected. Planning resolves every deployed tag to an immutable registry digest through Docker Buildx.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Application rollback
|
|
2
|
+
|
|
3
|
+
Preview the selected revision without `--confirm`, show the resulting plan hash, and obtain explicit approval before rerunning the command with that hash.
|
|
4
|
+
|
|
5
|
+
Rollback changes only the application Helm release. It does not reverse database migrations, change the dependency release, delete PersistentVolumeClaims, or delete Secrets. If the old application is incompatible with the current database schema, prepare a forward fix instead.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: podokit-deploy
|
|
3
|
+
description: Plan, inspect, apply, verify, and roll back PodoKit Kubernetes releases with an explicit profile and confirmation hash. Use for Kubernetes deployment and rollback work in a generated PodoKit project.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# PodoKit deployment
|
|
7
|
+
|
|
8
|
+
Read and follow the canonical skill at `../../../.agents/skills/podokit-deploy/SKILL.md`.
|
|
@@ -19,3 +19,9 @@ CORS_ORIGIN=http://localhost:5001
|
|
|
19
19
|
# docker compose --profile cache up
|
|
20
20
|
REDIS_HOST=localhost
|
|
21
21
|
REDIS_PORT=6379
|
|
22
|
+
# REDIS_URL takes precedence over the individual settings below.
|
|
23
|
+
# REDIS_URL=rediss://user:password@cache.example.com:6380/0
|
|
24
|
+
REDIS_DB=0
|
|
25
|
+
# REDIS_USERNAME=
|
|
26
|
+
# REDIS_PASSWORD=
|
|
27
|
+
REDIS_TLS=false
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { defineConfig, devices } from "@playwright/test";
|
|
2
|
+
import { loadPlaywrightProjects } from "./playwright.extensions";
|
|
2
3
|
|
|
3
4
|
// The suite runs against a live stack: web on E2E_BASE_URL (proxying /api/* to
|
|
4
5
|
// the API). Start it first (see docs/testing.md) — locally via the dev harness,
|
|
5
6
|
// in CI via scripts/e2e-ci.mjs. Two projects: `api` (request-only, backend e2e)
|
|
6
7
|
// and `ui` (chromium, pages). Files are routed by suffix (*.api/*.ui.spec.ts).
|
|
7
8
|
const baseURL = process.env.E2E_BASE_URL ?? "http://localhost:5001";
|
|
9
|
+
const coreProjects = [
|
|
10
|
+
{ name: "api", testMatch: /.*\.api\.spec\.ts/ },
|
|
11
|
+
{ name: "ui", testMatch: /.*\.ui\.spec\.ts/, use: { ...devices["Desktop Chrome"] } },
|
|
12
|
+
];
|
|
8
13
|
|
|
9
14
|
export default defineConfig({
|
|
10
15
|
testDir: ".",
|
|
@@ -18,8 +23,5 @@ export default defineConfig({
|
|
|
18
23
|
trace: "on-first-retry",
|
|
19
24
|
screenshot: "only-on-failure",
|
|
20
25
|
},
|
|
21
|
-
projects: [
|
|
22
|
-
{ name: "api", testMatch: /.*\.api\.spec\.ts/ },
|
|
23
|
-
{ name: "ui", testMatch: /.*\.ui\.spec\.ts/, use: { ...devices["Desktop Chrome"] } },
|
|
24
|
-
],
|
|
26
|
+
projects: [...coreProjects, ...loadPlaywrightProjects(coreProjects)],
|
|
25
27
|
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import type { TestConfig } from "@playwright/test";
|
|
5
|
+
|
|
6
|
+
type Projects = NonNullable<TestConfig["projects"]>;
|
|
7
|
+
|
|
8
|
+
const requireFromTests = createRequire(__filename);
|
|
9
|
+
|
|
10
|
+
function projectName(project: unknown): string | null {
|
|
11
|
+
if (typeof project !== "object" || project === null || !("name" in project)) return null;
|
|
12
|
+
return typeof project.name === "string" && project.name.length > 0 ? project.name : null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Merge application-owned Playwright projects into PodoKit's managed config.
|
|
17
|
+
* The optional CommonJS file stays owned so applications can add devices and
|
|
18
|
+
* browsers without creating a 3-way merge hotspot in playwright.config.ts.
|
|
19
|
+
*/
|
|
20
|
+
export function loadPlaywrightProjects(coreProjects: Projects): Projects {
|
|
21
|
+
const extensionPath = join(__dirname, "playwright.projects.cjs");
|
|
22
|
+
if (!existsSync(extensionPath)) return [];
|
|
23
|
+
|
|
24
|
+
const loaded = requireFromTests(extensionPath) as unknown;
|
|
25
|
+
if (!Array.isArray(loaded)) {
|
|
26
|
+
throw new Error("tests/playwright.projects.cjs must export an array of Playwright projects.");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const names = new Set(
|
|
30
|
+
coreProjects.map((project) => projectName(project)).filter((name): name is string => name !== null),
|
|
31
|
+
);
|
|
32
|
+
for (const project of loaded) {
|
|
33
|
+
const name = projectName(project);
|
|
34
|
+
if (!name) {
|
|
35
|
+
throw new Error("Every project in tests/playwright.projects.cjs must have a non-empty name.");
|
|
36
|
+
}
|
|
37
|
+
if (names.has(name)) {
|
|
38
|
+
throw new Error(`Duplicate Playwright project name: ${name}`);
|
|
39
|
+
}
|
|
40
|
+
names.add(name);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return loaded as Projects;
|
|
44
|
+
}
|
package/dist/update.js
CHANGED
|
@@ -91,20 +91,24 @@ function planUpdate(projectRoot, templatesDir) {
|
|
|
91
91
|
const locked = lock.files[path];
|
|
92
92
|
const newText = treeText(newTree, path);
|
|
93
93
|
const disk = diskContent(projectRoot, path);
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
: locked?.tier ??
|
|
103
|
-
(newText !== null
|
|
104
|
-
? (0, lockfile_1.classifyTier)(path, newText, ownedGlobs, managedOverrides)
|
|
105
|
-
: "managed");
|
|
94
|
+
// Use the same ownership precedence as lockfile classification. In
|
|
95
|
+
// particular, an exact path recorded by `podo eject` must keep winning over
|
|
96
|
+
// a module's managed override, while managed overrides may still reclaim a
|
|
97
|
+
// path covered only by a broad owned glob.
|
|
98
|
+
const controlledByTarget = managedOverrides.some((glob) => (0, lockfile_1.matchGlob)(path, glob)) ||
|
|
99
|
+
ownedGlobs.some((glob) => (0, lockfile_1.matchGlob)(path, glob));
|
|
100
|
+
const classified = (0, lockfile_1.classifyTier)(path, newText ?? disk ?? "", ownedGlobs, managedOverrides);
|
|
101
|
+
const tier = controlledByTarget ? classified : locked?.tier ?? classified;
|
|
106
102
|
if (tier === "owned") {
|
|
107
|
-
|
|
103
|
+
const explicitlyOwned = ownedGlobs.some((glob) => !glob.includes("*") && (0, lockfile_1.matchGlob)(path, glob));
|
|
104
|
+
changes.push({
|
|
105
|
+
path,
|
|
106
|
+
tier,
|
|
107
|
+
action: "skip",
|
|
108
|
+
note: explicitlyOwned && disk === null && newText !== null
|
|
109
|
+
? "explicitly owned — missing or relocated; not restored"
|
|
110
|
+
: "owned — never modified",
|
|
111
|
+
});
|
|
108
112
|
continue;
|
|
109
113
|
}
|
|
110
114
|
// File removed upstream.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@podosoft/podokit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "An opinionated but extensible starter toolkit and CLI for full-stack TypeScript apps with NestJS, SvelteKit, TailwindCSS, shadcn-svelte, Docker, and k3s.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -44,6 +44,6 @@
|
|
|
44
44
|
"test": "vitest run"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@podosoft/podokit-template-engine": "^0.4.
|
|
47
|
+
"@podosoft/podokit-template-engine": "^0.4.2"
|
|
48
48
|
}
|
|
49
49
|
}
|