create-svc 0.1.10 → 0.1.12

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 (171) hide show
  1. package/README.md +51 -47
  2. package/index.ts +2 -2
  3. package/package.json +10 -9
  4. package/src/cli.test.ts +28 -10
  5. package/src/cli.ts +196 -33
  6. package/src/git-bootstrap.test.ts +40 -0
  7. package/src/git-bootstrap.ts +110 -0
  8. package/src/naming.test.ts +1 -0
  9. package/src/naming.ts +23 -0
  10. package/src/post-scaffold.test.ts +19 -0
  11. package/src/post-scaffold.ts +17 -4
  12. package/src/profiles.ts +2 -5
  13. package/src/scaffold.test.ts +232 -41
  14. package/src/scaffold.ts +81 -36
  15. package/src/service.test.ts +30 -0
  16. package/src/service.ts +65 -0
  17. package/src/vault.test.ts +61 -1
  18. package/src/vault.ts +77 -15
  19. package/templates/shared/.github/workflows/ci.yml +2 -1
  20. package/templates/shared/.github/workflows/deploy.yml +2 -0
  21. package/templates/shared/README.md +124 -47
  22. package/templates/shared/grafana/alerts.yaml +54 -0
  23. package/templates/shared/grafana/waitlist-dashboard.json +63 -0
  24. package/templates/shared/scripts/authctl.ts +231 -0
  25. package/templates/shared/scripts/cloudrun/bootstrap.ts +14 -5
  26. package/templates/shared/scripts/cloudrun/cleanup.ts +64 -4
  27. package/templates/shared/scripts/cloudrun/cli.ts +329 -7
  28. package/templates/shared/scripts/cloudrun/config.ts +11 -4
  29. package/templates/shared/scripts/cloudrun/deploy.ts +0 -4
  30. package/templates/shared/scripts/cloudrun/lib.ts +174 -41
  31. package/templates/shared/scripts/cloudrun/neon.ts +45 -0
  32. package/templates/shared/scripts/dev.ts +22 -0
  33. package/templates/shared/scripts/ensure-local-db.ts +3 -0
  34. package/templates/shared/scripts/local-docker.ts +63 -0
  35. package/templates/shared/scripts/local-env.ts +27 -0
  36. package/templates/shared/scripts/seed.ts +73 -0
  37. package/templates/shared/scripts/wait-for-db.ts +32 -0
  38. package/templates/shared/service.config.ts +59 -0
  39. package/templates/shared/service.yaml +24 -44
  40. package/templates/targets/workers/.github/workflows/ci.yml +19 -0
  41. package/templates/targets/workers/.github/workflows/deploy.yml +19 -0
  42. package/templates/targets/workers/Makefile +33 -0
  43. package/templates/targets/workers/README.md +75 -0
  44. package/templates/targets/workers/package.json +35 -0
  45. package/templates/targets/workers/scripts/workers/cli.ts +402 -0
  46. package/templates/targets/workers/src/auth.ts +178 -0
  47. package/templates/targets/workers/src/index.ts +198 -0
  48. package/templates/targets/workers/src/storage.ts +370 -0
  49. package/templates/targets/workers/test/app.test.ts +108 -0
  50. package/templates/targets/workers/tsconfig.json +11 -0
  51. package/templates/targets/workers/wrangler.toml +24 -0
  52. package/templates/variants/bun-connectrpc/Makefile +14 -8
  53. package/templates/variants/bun-connectrpc/gen/protos/waitlist/v1/waitlist_pb.ts +424 -0
  54. package/templates/variants/bun-connectrpc/migrations/0000_init.sql +12 -55
  55. package/templates/variants/bun-connectrpc/package.json +12 -5
  56. package/templates/variants/bun-connectrpc/protos/waitlist/v1/waitlist.proto +91 -0
  57. package/templates/variants/bun-connectrpc/scripts/codegen.ts +1 -1
  58. package/templates/variants/bun-connectrpc/scripts/migrate.ts +4 -1
  59. package/templates/variants/bun-connectrpc/src/auth.ts +200 -0
  60. package/templates/variants/bun-connectrpc/src/db/repository.ts +67 -420
  61. package/templates/variants/bun-connectrpc/src/db/schema.ts +15 -64
  62. package/templates/variants/bun-connectrpc/src/index.ts +76 -176
  63. package/templates/variants/bun-connectrpc/src/temporal/activities.ts +14 -0
  64. package/templates/variants/bun-connectrpc/src/temporal/worker.ts +38 -0
  65. package/templates/variants/bun-connectrpc/src/temporal/workflows.ts +10 -0
  66. package/templates/variants/bun-connectrpc/src/waitlist/service.ts +172 -0
  67. package/templates/variants/bun-connectrpc/src/waitlist/types.ts +45 -0
  68. package/templates/variants/bun-connectrpc/test/app.test.ts +4 -4
  69. package/templates/variants/bun-connectrpc/test/waitlist.integration.test.ts +71 -0
  70. package/templates/variants/bun-hono/Makefile +14 -8
  71. package/templates/variants/bun-hono/migrations/0000_init.sql +12 -55
  72. package/templates/variants/bun-hono/package.json +12 -5
  73. package/templates/variants/bun-hono/scripts/migrate.ts +4 -1
  74. package/templates/variants/bun-hono/src/auth.ts +181 -0
  75. package/templates/variants/bun-hono/src/db/repository.ts +68 -421
  76. package/templates/variants/bun-hono/src/db/schema.ts +15 -64
  77. package/templates/variants/bun-hono/src/index.ts +65 -180
  78. package/templates/variants/bun-hono/src/temporal/activities.ts +14 -0
  79. package/templates/variants/bun-hono/src/temporal/worker.ts +38 -0
  80. package/templates/variants/bun-hono/src/temporal/workflows.ts +10 -0
  81. package/templates/variants/bun-hono/src/waitlist/service.ts +166 -0
  82. package/templates/variants/bun-hono/src/waitlist/types.ts +50 -0
  83. package/templates/variants/bun-hono/test/app.test.ts +72 -41
  84. package/templates/variants/bun-hono/test/waitlist.integration.test.ts +102 -0
  85. package/templates/variants/go-chi/Makefile +27 -11
  86. package/templates/variants/go-chi/atlas.hcl +8 -0
  87. package/templates/variants/go-chi/cmd/server/main.go +21 -10
  88. package/templates/variants/go-chi/go.mod +1 -3
  89. package/templates/variants/go-chi/internal/app/service.go +202 -685
  90. package/templates/variants/go-chi/internal/auth/middleware.go +289 -0
  91. package/templates/variants/go-chi/internal/auth/middleware_test.go +38 -0
  92. package/templates/variants/go-chi/internal/config/config.go +27 -11
  93. package/templates/variants/go-chi/internal/httpapi/routes.go +78 -157
  94. package/templates/variants/go-chi/internal/httpapi/waitlist_integration_test.go +199 -0
  95. package/templates/variants/go-chi/internal/temporal/activities.go +27 -0
  96. package/templates/variants/go-chi/internal/temporal/worker.go +42 -0
  97. package/templates/variants/go-chi/internal/temporal/workflows.go +18 -0
  98. package/templates/variants/go-chi/migrations/0000_init.sql +12 -55
  99. package/templates/variants/go-chi/migrations/atlas.sum +2 -0
  100. package/templates/variants/go-chi/package.json +7 -1
  101. package/templates/variants/go-connectrpc/Makefile +26 -9
  102. package/templates/variants/go-connectrpc/atlas.hcl +8 -0
  103. package/templates/variants/go-connectrpc/buf.gen.yaml +2 -2
  104. package/templates/variants/go-connectrpc/cmd/server/main.go +23 -12
  105. package/templates/variants/go-connectrpc/gen/waitlist/v1/waitlist.pb.go +960 -0
  106. package/templates/variants/go-connectrpc/gen/waitlist/v1/waitlistv1connect/waitlist.connect.go +283 -0
  107. package/templates/variants/go-connectrpc/go.mod +1 -1
  108. package/templates/variants/go-connectrpc/internal/app/service.go +202 -685
  109. package/templates/variants/go-connectrpc/internal/auth/middleware.go +289 -0
  110. package/templates/variants/go-connectrpc/internal/auth/middleware_test.go +38 -0
  111. package/templates/variants/go-connectrpc/internal/config/config.go +27 -11
  112. package/templates/variants/go-connectrpc/internal/connectapi/handler.go +78 -201
  113. package/templates/variants/go-connectrpc/internal/connectapi/waitlist_integration_test.go +122 -0
  114. package/templates/variants/go-connectrpc/internal/httpapi/routes.go +147 -9
  115. package/templates/variants/go-connectrpc/internal/temporal/activities.go +27 -0
  116. package/templates/variants/go-connectrpc/internal/temporal/worker.go +42 -0
  117. package/templates/variants/go-connectrpc/internal/temporal/workflows.go +18 -0
  118. package/templates/variants/go-connectrpc/migrations/0000_init.sql +12 -55
  119. package/templates/variants/go-connectrpc/migrations/atlas.sum +2 -0
  120. package/templates/variants/go-connectrpc/package.json +7 -1
  121. package/templates/variants/go-connectrpc/protos/waitlist/v1/waitlist.proto +93 -0
  122. package/templates/root/.github/workflows/buf-publish.yml +0 -19
  123. package/templates/root/.github/workflows/ci.yml +0 -26
  124. package/templates/root/.github/workflows/deploy.yml +0 -22
  125. package/templates/root/Dockerfile +0 -23
  126. package/templates/root/README.md +0 -69
  127. package/templates/root/buf.gen.yaml +0 -10
  128. package/templates/root/buf.yaml +0 -9
  129. package/templates/root/cmd/server/main.go +0 -44
  130. package/templates/root/gen/dns/v1/dns.pb.go +0 -623
  131. package/templates/root/gen/dns/v1/dnsv1connect/dns.connect.go +0 -192
  132. package/templates/root/go.mod +0 -10
  133. package/templates/root/internal/app/service.go +0 -152
  134. package/templates/root/internal/app/token_source.go +0 -50
  135. package/templates/root/internal/cloudflare/client.go +0 -160
  136. package/templates/root/internal/config/config.go +0 -55
  137. package/templates/root/internal/connectapi/handler.go +0 -79
  138. package/templates/root/internal/httpapi/routes.go +0 -93
  139. package/templates/root/internal/vault/client.go +0 -148
  140. package/templates/root/package.json +0 -12
  141. package/templates/root/protos/dns/v1/dns.proto +0 -58
  142. package/templates/root/scripts/cloudrun/bootstrap.ts +0 -65
  143. package/templates/root/scripts/cloudrun/config.ts +0 -50
  144. package/templates/root/scripts/cloudrun/deploy.ts +0 -41
  145. package/templates/root/scripts/cloudrun/lib.ts +0 -244
  146. package/templates/root/service.yaml +0 -50
  147. package/templates/root/test/go.test.ts +0 -19
  148. package/templates/shared/scripts/cloudrun/integrations.ts +0 -111
  149. package/templates/variants/bun-connectrpc/gen/protos/chat/v1/chat_pb.ts +0 -1078
  150. package/templates/variants/bun-connectrpc/protos/chat/v1/chat.proto +0 -228
  151. package/templates/variants/bun-connectrpc/src/chat/service.ts +0 -384
  152. package/templates/variants/bun-connectrpc/src/chat/types.ts +0 -142
  153. package/templates/variants/bun-connectrpc/src/storage.ts +0 -72
  154. package/templates/variants/bun-connectrpc/src/webhooks.ts +0 -35
  155. package/templates/variants/bun-connectrpc/test/list-messages.integration.test.ts +0 -182
  156. package/templates/variants/bun-hono/src/chat/service.ts +0 -384
  157. package/templates/variants/bun-hono/src/chat/types.ts +0 -142
  158. package/templates/variants/bun-hono/src/storage.ts +0 -72
  159. package/templates/variants/bun-hono/src/webhooks.ts +0 -35
  160. package/templates/variants/bun-hono/test/list-messages.integration.test.ts +0 -256
  161. package/templates/variants/go-chi/buf.gen.yaml +0 -12
  162. package/templates/variants/go-chi/buf.yaml +0 -9
  163. package/templates/variants/go-chi/cmd/migrate/main.go +0 -101
  164. package/templates/variants/go-chi/internal/httpapi/list_messages_integration_test.go +0 -298
  165. package/templates/variants/go-chi/protos/chat/v1/chat.proto +0 -219
  166. package/templates/variants/go-connectrpc/cmd/migrate/main.go +0 -101
  167. package/templates/variants/go-connectrpc/gen/chat/v1/chat.pb.go +0 -2512
  168. package/templates/variants/go-connectrpc/gen/chat/v1/chatv1connect/chat.connect.go +0 -571
  169. package/templates/variants/go-connectrpc/internal/connectapi/list_messages_integration_test.go +0 -216
  170. package/templates/variants/go-connectrpc/protos/chat/v1/chat.proto +0 -232
  171. /package/bin/{create-svc.mjs → service.mjs} +0 -0
package/README.md CHANGED
@@ -1,43 +1,56 @@
1
- # create-svc
1
+ # service
2
2
 
3
- `create-svc` is a local backend bootstrap CLI for generating standalone Cloud Run API services with:
3
+ `service` is a local microservice CLI for generating standalone API services and operating them after generation with the same command name.
4
4
 
5
5
  - a single `microservice` generation path
6
- - a Bun-first backend path built around `hono` and ConnectRPC
6
+ - explicit deploy target selection: Cloud Run or Cloudflare Workers
7
+ - Go or Bun runtime choices where the target supports them
8
+ - HTTP frameworks (`chi` or `hono`) and ConnectRPC variants
7
9
  - standalone package output that does not assume repo bootstrap
8
- - compatibility with future monorepo use in layouts like `apps/<service>`
9
- - a real `service.yaml` manifest
10
- - shared Cloud Run bootstrap, deploy, and cleanup automation
10
+ - a generated `service.config.ts` manifest
11
+ - one `service` CLI for scaffold, create, deploy, migrate, seed, dashboards, doctor, and destroy
11
12
  - local Docker Compose Postgres for first-run development
12
- - Neon-backed remote main, preview, and personal environments
13
- - GCS-backed image attachments
14
- - typed HTTP webhook ingress
15
- - a production API origin at `https://api.<appname>.anmho.com`
13
+ - Neon-backed remote environments
14
+ - a production API origin at `https://api.<service_id>.anmho.com`
16
15
 
17
- Local provisioning intentionally prefers known-good CLIs, especially `gcloud`, over SDK-heavy orchestration for Google Cloud operations.
18
- Terraform, control planes, and platform consoles are optional advanced paths, not default prerequisites.
16
+ Local provisioning intentionally prefers known-good CLIs over SDK-heavy orchestration where that keeps the generated service easier to inspect and repair.
19
17
 
20
18
  npm: <https://www.npmjs.com/package/create-svc>
21
19
 
22
20
  ## Usage
23
21
 
24
22
  ```bash
25
- bun create svc my-service
23
+ service create my-service
26
24
  ```
27
25
 
28
- or:
26
+ Inside a generated service repo, the same command operates that repo:
29
27
 
30
28
  ```bash
31
- bunx create-svc my-service
29
+ cd my-service
30
+ service create
31
+ service deploy
32
+ ```
33
+
34
+ To install from npm:
35
+
36
+ ```bash
37
+ bun add -g create-svc
32
38
  ```
33
39
 
34
40
  For the strict one-command production path:
35
41
 
36
42
  ```bash
37
- bun create svc my-service --profile microservice --bootstrap --yes
43
+ service create my-service --yes
38
44
  ```
39
45
 
40
- `--profile microservice` is accepted as a compatibility no-op. Full app workspaces live in the private GitHub template repos `anmho/create-app-consumer` and `anmho/create-app-saas`.
46
+ `--profile microservice` is accepted as a compatibility no-op. App workspaces live outside this package in private app template repositories.
47
+
48
+ By default, a standalone generated service is initialized as a git repository,
49
+ committed with `Initial commit`, created as a private GitHub repository at
50
+ `anmho/<service-name>`, and pushed to `origin/main`. If the target directory is
51
+ inside an existing git worktree, `service` skips git and GitHub setup so the
52
+ parent repository remains in control. Pass `--no-git` to skip all git and GitHub
53
+ side effects.
41
54
 
42
55
  ## Local Testing
43
56
 
@@ -46,15 +59,14 @@ Without publishing to npm:
46
59
  ```bash
47
60
  bun install
48
61
  npm pack
49
- bunx ./create-svc-*.tgz my-service
62
+ bunx ./create-svc-*.tgz create my-service
50
63
  ```
51
64
 
52
65
  For faster iteration against your working tree:
53
66
 
54
67
  ```bash
55
68
  bun link
56
- bun link create-svc
57
- create-svc my-service
69
+ service create my-service
58
70
  ```
59
71
 
60
72
  During scaffold, the generator can discover:
@@ -62,8 +74,8 @@ During scaffold, the generator can discover:
62
74
  - accessible GCP projects
63
75
  - open billing accounts
64
76
 
65
- Remote `bootstrap` and `deploy` use Neon credentials from `NEON_API_KEY`, or Vault via `VAULT_ADDR` plus `VAULT_TOKEN`, `VAULT_TOKEN_FILE`, or `~/.vault-token`.
66
- Provider runtime credentials can be supplied through environment variables or Vault paths under `secret/prod/providers/*`; generated Cloud Run services receive runtime values through app-project Secret Manager.
77
+ Generated provisioning commands use Neon credentials from `NEON_API_KEY`, or Vault via `VAULT_ADDR` plus `VAULT_TOKEN`, `VAULT_TOKEN_FILE`, or `~/.vault-token`.
78
+ The base waitlist service keeps provider integrations out of the runtime by default; add provider-specific secrets only when the generated service actually uses that provider.
67
79
 
68
80
  Before running generated provisioning commands locally, authenticate `gcloud` on the machine:
69
81
 
@@ -71,13 +83,11 @@ Before running generated provisioning commands locally, authenticate `gcloud` on
71
83
  gcloud auth login
72
84
  ```
73
85
 
74
- ## Generated Backend Package
86
+ ## Generated Service Package
75
87
 
76
88
  First local run:
77
89
 
78
- ```bash
79
- docker compose up -d
80
- ```
90
+ `bun run migrate`, `make migrate`, `bun run dev`, and `make dev` open Docker Desktop when needed, wait for Docker readiness, and start Docker Compose Postgres before touching the local database.
81
91
 
82
92
  For Bun variants:
83
93
 
@@ -87,9 +97,9 @@ bun run dev
87
97
  bun run gen
88
98
  bun run lint
89
99
  bun run test
90
- bun run bootstrap
91
- bun run deploy
92
- bun run cleanup
100
+ service create
101
+ service deploy
102
+ service destroy
93
103
  ```
94
104
 
95
105
  For Go variants:
@@ -100,25 +110,23 @@ make dev
100
110
  make gen
101
111
  make lint
102
112
  make test
103
- make bootstrap
104
- make deploy
105
- make cleanup
113
+ service create
114
+ service deploy
115
+ service destroy
106
116
  ```
107
117
 
108
- The generated package is intended to be consumed by a Next.js web app or a mobile client over HTTPS. In v1, production is expected to live at `https://api.<appname>.anmho.com`, while preview and personal environments keep using deterministic Cloud Run URLs.
118
+ Language-specific tasks such as local running, linting, formatting, testing, and building stay in package scripts or Make targets. Service lifecycle operations are exposed through the generated `service` CLI.
109
119
 
110
- The microservice profile is moving toward a small waitlist/launch service example. The current generated plumbing still includes:
120
+ The generated service is intended to be consumed by a web app, mobile client, or another service over HTTPS. In v1, production is expected to live at `https://api.<service_id>.anmho.com`, while preview and personal environments keep using deterministic platform URLs where appropriate.
111
121
 
112
- - Postgres-backed `users`, `conversations`, `conversation_participants`, and `messages`
113
- - image attachment upload/finalize plumbing via GCS
114
- - generic typed webhook ingestion on plain HTTP
122
+ The generated microservice domain is a small waitlist/launch service example with public submit/status APIs and target-specific scheduled work.
115
123
 
116
124
  ## Development
117
125
 
118
126
  ```bash
119
127
  bun install
120
128
  bun test src scripts
121
- bun run index.ts my-service
129
+ bun run index.ts create my-service
122
130
  ```
123
131
 
124
132
  Validate the generated app matrix against local Docker Compose Postgres:
@@ -129,15 +137,16 @@ bun run validate:generated -- --variant bun-hono
129
137
  bun run validate:generated -- --variant go-connectrpc --keep
130
138
  ```
131
139
 
132
- The validation harness scaffolds generated apps into ignored `bin/generated/run-*` workspaces, runs the generated public commands, starts the local server, and smoke-tests health or typed ConnectRPC clients where applicable.
140
+ The validation harness scaffolds generated services into ignored `bin/generated/run-*` workspaces, runs the generated public commands, starts the local server, and smoke-tests health or typed ConnectRPC clients where applicable.
133
141
 
134
142
  ## npm Trusted Publishing
135
143
 
136
144
  `create-svc` is set up for npm trusted publishing from GitHub Actions, so there is no long-lived npm publish token to store in Vault.
137
145
 
138
146
  Repository workflow:
147
+
139
148
  - [publish.yml](.github/workflows/publish.yml)
140
- - Trigger: Git tags matching `v*`
149
+ - Trigger: pushes to `main`, Git tags matching `v*`, or manual `workflow_dispatch`
141
150
  - CI runtime: Bun for install/test/typecheck, npm for the final publish step
142
151
 
143
152
  npm package setup still has to be configured once in the npm UI to trust this repository and workflow:
@@ -151,11 +160,6 @@ npm package setup still has to be configured once in the npm UI to trust this re
151
160
  - Workflow filename: `publish.yml`
152
161
  5. Save the trusted publisher.
153
162
 
154
- After that, publishing is:
155
-
156
- ```bash
157
- git tag v0.1.10
158
- git push origin v0.1.10
159
- ```
163
+ After that, publishing can be triggered by pushing to `main`, creating a `v*` tag, or running the workflow manually.
160
164
 
161
- The GitHub Actions workflow will authenticate with npm via OIDC and run `npm publish` without an npm token.
165
+ The GitHub Actions workflow authenticates with npm via OIDC and runs `npm publish` without an npm token.
package/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
2
 
3
- import { run } from "./src/cli";
3
+ import { runServiceCommand } from "./src/service";
4
4
 
5
- await run(process.argv.slice(2));
5
+ await runServiceCommand(process.argv.slice(2));
package/package.json CHANGED
@@ -1,19 +1,20 @@
1
1
  {
2
2
  "name": "create-svc",
3
- "version": "0.1.10",
4
- "description": "Local backend bootstrap CLI for Bun-first Cloud Run API services with Neon and Vault provisioning.",
3
+ "version": "0.1.12",
4
+ "description": "Local microservice bootstrap CLI for Cloud Run and Workers services with Neon-backed data.",
5
5
  "module": "index.ts",
6
6
  "type": "module",
7
7
  "license": "MIT",
8
8
  "bin": {
9
- "create-svc": "bin/create-svc.mjs",
10
- "create-service": "bin/create-svc.mjs"
9
+ "service": "bin/service.mjs"
11
10
  },
12
11
  "files": [
13
- "bin",
12
+ "bin/service.mjs",
14
13
  "index.ts",
15
14
  "src",
16
15
  "templates",
16
+ "!bin/generated",
17
+ "!templates/**/node_modules",
17
18
  "README.md"
18
19
  ],
19
20
  "scripts": {
@@ -45,12 +46,12 @@
45
46
  "@types/bun": "latest"
46
47
  },
47
48
  "peerDependencies": {
48
- "typescript": "^5"
49
+ "typescript": "^5.9.3"
49
50
  },
50
51
  "dependencies": {
51
- "@clack/prompts": "^1.2.0",
52
- "@google-cloud/billing": "^5.1.1",
53
- "@google-cloud/resource-manager": "^6.2.1",
52
+ "@clack/prompts": "^1.4.0",
53
+ "@google-cloud/billing": "^5.1.2",
54
+ "@google-cloud/resource-manager": "^6.2.2",
54
55
  "@neondatabase/api-client": "^2.7.1",
55
56
  "picocolors": "^1.1.1"
56
57
  }
package/src/cli.test.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  import { expect, test } from "bun:test";
2
2
  import { mkdir } from "node:fs/promises";
3
- import { assertDiscoveryReady, normalizeValidationResult, parseArgs, validateServiceNameInput } from "./cli";
3
+ import {
4
+ assertDiscoveryReady,
5
+ normalizeValidationResult,
6
+ parseArgs,
7
+ validateTargetRuntimeFramework,
8
+ validateServiceNameInput,
9
+ } from "./cli";
4
10
 
5
11
  test("normalizeValidationResult converts success to undefined", () => {
6
12
  expect(normalizeValidationResult(true)).toBeUndefined();
@@ -24,24 +30,36 @@ test("assertDiscoveryReady no longer blocks scaffold when remote discovery is un
24
30
  });
25
31
  });
26
32
 
27
- test("parseArgs defaults to the microservice profile and treats bootstrap as strict deploy", () => {
33
+ test("parseArgs defaults to microservice and cloudrun target", () => {
28
34
  expect(parseArgs(["launch-api", "--yes"])).toMatchObject({
29
35
  directory: "launch-api",
30
36
  profile: "microservice",
31
37
  yes: true,
32
38
  });
33
- expect(parseArgs(["launch-api", "--yes"]).autoDeploy).toBeUndefined();
34
-
35
- expect(parseArgs(["launch-api", "--profile", "microservice", "--bootstrap"])).toMatchObject({
39
+ expect(parseArgs(["launch-api", "--target", "workers", "--yes"])).toMatchObject({
36
40
  directory: "launch-api",
37
- profile: "microservice",
38
- autoDeploy: true,
41
+ target: "workers",
42
+ yes: true,
39
43
  });
44
+ expect(parseArgs(["launch-api", "--yes"]).autoDeploy).toBeUndefined();
45
+ expect(parseArgs(["launch-api", "--yes", "--no-git"]).noGit).toBeTrue();
46
+
47
+ expect(() => parseArgs(["launch-api", "--profile", "microservice", "--bootstrap"])).toThrow("Unknown argument");
48
+ });
49
+
50
+ test("parseArgs rejects the removed app profile", () => {
51
+ expect(() => parseArgs(["tracker", "--profile=app", "--yes"])).toThrow("app profile has moved");
40
52
  });
41
53
 
42
- test("parseArgs rejects the moved app profile with private template guidance", () => {
43
- expect(() => parseArgs(["tracker", "--profile=app", "--yes"])).toThrow("anmho/create-app-consumer");
44
- expect(() => parseArgs(["tracker", "--profile", "app", "--yes"])).toThrow("anmho/create-app-saas");
54
+ test("target/runtime/framework combinations are validated", () => {
55
+ expect(() => validateTargetRuntimeFramework("cloudrun", "go", "connectrpc")).not.toThrow();
56
+ expect(() => validateTargetRuntimeFramework("workers", "bun", "hono")).not.toThrow();
57
+ expect(() => validateTargetRuntimeFramework("workers", "bun", "connectrpc")).toThrow(
58
+ "Framework connectrpc is not valid for target workers and runtime bun"
59
+ );
60
+ expect(() => validateTargetRuntimeFramework("workers", "go", "connectrpc")).toThrow(
61
+ "Framework connectrpc is not valid for target workers and runtime go"
62
+ );
45
63
  });
46
64
 
47
65
  test("validateServiceNameInput rejects a taken target directory", async () => {