@tatara/cli 0.2.0 → 0.4.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.
Files changed (46) hide show
  1. package/dist/bin.mjs +221 -19
  2. package/package.json +1 -1
  3. package/templates/features/admin/files/src/apps/admin/server.ts +3 -2
  4. package/templates/features/admin/files/src/modules/example/routes/admin-greeting.routes.ts +1 -1
  5. package/templates/features/auth/files/src/core/auth/middleware.ts +1 -1
  6. package/templates/features/auth/files/src/core/auth/routes/me.routes.ts +1 -1
  7. package/templates/features/auth-keycloak/files/src/core/auth/tests/keycloak-tokens.test.ts +1 -1
  8. package/templates/features/auth-keycloak/files+auth-orgs/src/core/auth/tests/keycloak-organizations.test.ts +1 -1
  9. package/templates/features/authz/files/src/core/authz/db/seed.ts +1 -1
  10. package/templates/features/authz/files/src/core/authz/middleware.ts +1 -1
  11. package/templates/features/authz/files/src/core/authz/routes/authorization.routes.ts +1 -1
  12. package/templates/features/authz/files/src/core/authz/services/grants.ts +1 -1
  13. package/templates/features/authz/files/src/core/authz/services/members.ts +1 -1
  14. package/templates/features/authz/files/src/core/authz/services/roles.ts +1 -1
  15. package/templates/features/authz/files+drizzle/src/core/authz/db/store.ts +1 -1
  16. package/templates/features/authz/files+prisma/src/core/authz/db/store.ts +1 -1
  17. package/templates/features/base/files/src/apps/api/server.ts +3 -2
  18. package/templates/features/base/files/src/core/http/app.ts +22 -41
  19. package/templates/features/base/files/src/core/http/routes.ts +7 -11
  20. package/templates/features/base/files/src/modules/example/routes/greeting.routes.ts +1 -1
  21. package/templates/features/base/files/tests/helpers/api.ts +3 -47
  22. package/templates/features/better-auth/files/src/core/auth/auth.ts +1 -1
  23. package/templates/features/better-auth/files/src/core/auth/db/seed.ts +1 -1
  24. package/templates/features/better-auth/files/tests/helpers/auth.ts +1 -1
  25. package/templates/features/db/files/tests/global-setup.ts +4 -16
  26. package/templates/features/db/files+mysql+drizzle/src/core/db/admin.ts +2 -53
  27. package/templates/features/db/files+mysql+prisma/src/core/db/admin.ts +7 -78
  28. package/templates/features/db/files+postgres/src/core/db/admin.ts +2 -50
  29. package/templates/features/drizzle/files+mysql/src/core/db/migrate.ts +1 -13
  30. package/templates/features/drizzle/files+postgres/src/core/db/migrate.ts +1 -13
  31. package/templates/features/prisma/files/src/core/db/migrate.ts +1 -13
  32. package/templates/generators/module/files/src/modules/__moduleKebab__/routes/__moduleKebab__.routes.ts +1 -1
  33. package/templates/generators/resource/files/src/modules/__moduleKebab__/routes/__nameKebab__.routes.ts +1 -1
  34. package/templates/generators/resource/files+drizzle/src/modules/__moduleKebab__/services/__nameKebab__.service.ts +3 -3
  35. package/templates/generators/resource/files+prisma/src/modules/__moduleKebab__/services/__nameKebab__.service.ts +3 -3
  36. package/templates/generators/route/files/src/modules/__moduleKebab__/routes/__nameKebab__.routes.ts +1 -1
  37. package/templates/versions.json +4 -1
  38. package/templates/features/base/files/src/core/http/errors.ts +0 -79
  39. package/templates/features/base/files/src/core/http/middleware/error-handler.ts +0 -36
  40. package/templates/features/base/files/src/core/http/middleware/request-context.ts +0 -24
  41. package/templates/features/base/files/src/core/http/middleware/validation.ts +0 -17
  42. package/templates/features/base/files/src/core/http/response.ts +0 -72
  43. package/templates/features/base/files/src/core/http/server.ts +0 -15
  44. package/templates/features/db/files/src/core/db/id.ts +0 -13
  45. package/templates/features/db/files/src/core/db/seed.ts +0 -14
  46. package/templates/features/db/files/tests/helpers/database-url.ts +0 -9
@@ -1,15 +0,0 @@
1
- import { serve } from "@hono/node-server";
2
- import type { OpenAPIHono } from "@hono/zod-openapi";
3
- import type { AppEnv } from "#core/http/context";
4
- import { logger } from "#core/logging/logger";
5
- import { handleSignals, onShutdown } from "@tatara/core";
6
-
7
- /** Starts an HTTP app; on shutdown stops accepting connections and drains in-flight requests. */
8
- export function startServer(app: OpenAPIHono<AppEnv>, port: number, name: string) {
9
- const server = serve({ fetch: app.fetch, port }, (info) => {
10
- logger.info({ port: info.port, app: name }, `${name} listening on http://localhost:${info.port}`);
11
- });
12
- onShutdown(`${name}-http`, () => new Promise<void>((resolve) => server.close(() => resolve())));
13
- handleSignals(logger);
14
- return server;
15
- }
@@ -1,13 +0,0 @@
1
- import { randomFillSync } from "node:crypto";
2
-
3
- /** UUIDv7: random but time-ordered, so sorting by id is sorting by creation time. */
4
- export function newId(): string {
5
- const bytes = new Uint8Array(16);
6
- randomFillSync(bytes);
7
- const ms = BigInt(Date.now());
8
- for (let i = 0; i < 6; i++) bytes[i] = Number((ms >> BigInt(8 * (5 - i))) & 0xffn);
9
- bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x70;
10
- bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80;
11
- const hex = [...bytes].map((b) => b.toString(16).padStart(2, "0")).join("");
12
- return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
13
- }
@@ -1,14 +0,0 @@
1
- import type { Logger } from "#core/logging/logger";
2
-
3
- export interface SeedDefinition {
4
- name: string;
5
- /** lower runs first */
6
- order?: number;
7
- /** must be idempotent: seeds run on every `tatara dev` */
8
- run(ctx: { logger: Logger }): Promise<void>;
9
- }
10
-
11
- /** Default export of every `db/seed.ts`; discovered by `tatara sync`. */
12
- export function defineSeed(definition: SeedDefinition): SeedDefinition {
13
- return definition;
14
- }
@@ -1,9 +0,0 @@
1
- /** Number of Vitest workers; global setup prepares one database per worker. */
2
- export const TEST_WORKERS = 4;
3
-
4
- /** postgres://…/app_test → postgres://…/app_test_<worker> */
5
- export function workerDatabaseUrl(baseUrl: string, worker: number | string): string {
6
- const url = new URL(baseUrl);
7
- url.pathname = `${url.pathname}_${worker}`;
8
- return url.toString();
9
- }