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.
- package/README.md +51 -47
- package/index.ts +2 -2
- package/package.json +10 -9
- package/src/cli.test.ts +28 -10
- package/src/cli.ts +196 -33
- package/src/git-bootstrap.test.ts +40 -0
- package/src/git-bootstrap.ts +110 -0
- package/src/naming.test.ts +1 -0
- package/src/naming.ts +23 -0
- package/src/post-scaffold.test.ts +19 -0
- package/src/post-scaffold.ts +17 -4
- package/src/profiles.ts +2 -5
- package/src/scaffold.test.ts +232 -41
- package/src/scaffold.ts +81 -36
- package/src/service.test.ts +30 -0
- package/src/service.ts +65 -0
- package/src/vault.test.ts +61 -1
- package/src/vault.ts +77 -15
- package/templates/shared/.github/workflows/ci.yml +2 -1
- package/templates/shared/.github/workflows/deploy.yml +2 -0
- package/templates/shared/README.md +124 -47
- package/templates/shared/grafana/alerts.yaml +54 -0
- package/templates/shared/grafana/waitlist-dashboard.json +63 -0
- package/templates/shared/scripts/authctl.ts +231 -0
- package/templates/shared/scripts/cloudrun/bootstrap.ts +14 -5
- package/templates/shared/scripts/cloudrun/cleanup.ts +64 -4
- package/templates/shared/scripts/cloudrun/cli.ts +329 -7
- package/templates/shared/scripts/cloudrun/config.ts +11 -4
- package/templates/shared/scripts/cloudrun/deploy.ts +0 -4
- package/templates/shared/scripts/cloudrun/lib.ts +174 -41
- package/templates/shared/scripts/cloudrun/neon.ts +45 -0
- package/templates/shared/scripts/dev.ts +22 -0
- package/templates/shared/scripts/ensure-local-db.ts +3 -0
- package/templates/shared/scripts/local-docker.ts +63 -0
- package/templates/shared/scripts/local-env.ts +27 -0
- package/templates/shared/scripts/seed.ts +73 -0
- package/templates/shared/scripts/wait-for-db.ts +32 -0
- package/templates/shared/service.config.ts +59 -0
- package/templates/shared/service.yaml +24 -44
- package/templates/targets/workers/.github/workflows/ci.yml +19 -0
- package/templates/targets/workers/.github/workflows/deploy.yml +19 -0
- package/templates/targets/workers/Makefile +33 -0
- package/templates/targets/workers/README.md +75 -0
- package/templates/targets/workers/package.json +35 -0
- package/templates/targets/workers/scripts/workers/cli.ts +402 -0
- package/templates/targets/workers/src/auth.ts +178 -0
- package/templates/targets/workers/src/index.ts +198 -0
- package/templates/targets/workers/src/storage.ts +370 -0
- package/templates/targets/workers/test/app.test.ts +108 -0
- package/templates/targets/workers/tsconfig.json +11 -0
- package/templates/targets/workers/wrangler.toml +24 -0
- package/templates/variants/bun-connectrpc/Makefile +14 -8
- package/templates/variants/bun-connectrpc/gen/protos/waitlist/v1/waitlist_pb.ts +424 -0
- package/templates/variants/bun-connectrpc/migrations/0000_init.sql +12 -55
- package/templates/variants/bun-connectrpc/package.json +12 -5
- package/templates/variants/bun-connectrpc/protos/waitlist/v1/waitlist.proto +91 -0
- package/templates/variants/bun-connectrpc/scripts/codegen.ts +1 -1
- package/templates/variants/bun-connectrpc/scripts/migrate.ts +4 -1
- package/templates/variants/bun-connectrpc/src/auth.ts +200 -0
- package/templates/variants/bun-connectrpc/src/db/repository.ts +67 -420
- package/templates/variants/bun-connectrpc/src/db/schema.ts +15 -64
- package/templates/variants/bun-connectrpc/src/index.ts +76 -176
- package/templates/variants/bun-connectrpc/src/temporal/activities.ts +14 -0
- package/templates/variants/bun-connectrpc/src/temporal/worker.ts +38 -0
- package/templates/variants/bun-connectrpc/src/temporal/workflows.ts +10 -0
- package/templates/variants/bun-connectrpc/src/waitlist/service.ts +172 -0
- package/templates/variants/bun-connectrpc/src/waitlist/types.ts +45 -0
- package/templates/variants/bun-connectrpc/test/app.test.ts +4 -4
- package/templates/variants/bun-connectrpc/test/waitlist.integration.test.ts +71 -0
- package/templates/variants/bun-hono/Makefile +14 -8
- package/templates/variants/bun-hono/migrations/0000_init.sql +12 -55
- package/templates/variants/bun-hono/package.json +12 -5
- package/templates/variants/bun-hono/scripts/migrate.ts +4 -1
- package/templates/variants/bun-hono/src/auth.ts +181 -0
- package/templates/variants/bun-hono/src/db/repository.ts +68 -421
- package/templates/variants/bun-hono/src/db/schema.ts +15 -64
- package/templates/variants/bun-hono/src/index.ts +65 -180
- package/templates/variants/bun-hono/src/temporal/activities.ts +14 -0
- package/templates/variants/bun-hono/src/temporal/worker.ts +38 -0
- package/templates/variants/bun-hono/src/temporal/workflows.ts +10 -0
- package/templates/variants/bun-hono/src/waitlist/service.ts +166 -0
- package/templates/variants/bun-hono/src/waitlist/types.ts +50 -0
- package/templates/variants/bun-hono/test/app.test.ts +72 -41
- package/templates/variants/bun-hono/test/waitlist.integration.test.ts +102 -0
- package/templates/variants/go-chi/Makefile +27 -11
- package/templates/variants/go-chi/atlas.hcl +8 -0
- package/templates/variants/go-chi/cmd/server/main.go +21 -10
- package/templates/variants/go-chi/go.mod +1 -3
- package/templates/variants/go-chi/internal/app/service.go +202 -685
- package/templates/variants/go-chi/internal/auth/middleware.go +289 -0
- package/templates/variants/go-chi/internal/auth/middleware_test.go +38 -0
- package/templates/variants/go-chi/internal/config/config.go +27 -11
- package/templates/variants/go-chi/internal/httpapi/routes.go +78 -157
- package/templates/variants/go-chi/internal/httpapi/waitlist_integration_test.go +199 -0
- package/templates/variants/go-chi/internal/temporal/activities.go +27 -0
- package/templates/variants/go-chi/internal/temporal/worker.go +42 -0
- package/templates/variants/go-chi/internal/temporal/workflows.go +18 -0
- package/templates/variants/go-chi/migrations/0000_init.sql +12 -55
- package/templates/variants/go-chi/migrations/atlas.sum +2 -0
- package/templates/variants/go-chi/package.json +7 -1
- package/templates/variants/go-connectrpc/Makefile +26 -9
- package/templates/variants/go-connectrpc/atlas.hcl +8 -0
- package/templates/variants/go-connectrpc/buf.gen.yaml +2 -2
- package/templates/variants/go-connectrpc/cmd/server/main.go +23 -12
- package/templates/variants/go-connectrpc/gen/waitlist/v1/waitlist.pb.go +960 -0
- package/templates/variants/go-connectrpc/gen/waitlist/v1/waitlistv1connect/waitlist.connect.go +283 -0
- package/templates/variants/go-connectrpc/go.mod +1 -1
- package/templates/variants/go-connectrpc/internal/app/service.go +202 -685
- package/templates/variants/go-connectrpc/internal/auth/middleware.go +289 -0
- package/templates/variants/go-connectrpc/internal/auth/middleware_test.go +38 -0
- package/templates/variants/go-connectrpc/internal/config/config.go +27 -11
- package/templates/variants/go-connectrpc/internal/connectapi/handler.go +78 -201
- package/templates/variants/go-connectrpc/internal/connectapi/waitlist_integration_test.go +122 -0
- package/templates/variants/go-connectrpc/internal/httpapi/routes.go +147 -9
- package/templates/variants/go-connectrpc/internal/temporal/activities.go +27 -0
- package/templates/variants/go-connectrpc/internal/temporal/worker.go +42 -0
- package/templates/variants/go-connectrpc/internal/temporal/workflows.go +18 -0
- package/templates/variants/go-connectrpc/migrations/0000_init.sql +12 -55
- package/templates/variants/go-connectrpc/migrations/atlas.sum +2 -0
- package/templates/variants/go-connectrpc/package.json +7 -1
- package/templates/variants/go-connectrpc/protos/waitlist/v1/waitlist.proto +93 -0
- package/templates/root/.github/workflows/buf-publish.yml +0 -19
- package/templates/root/.github/workflows/ci.yml +0 -26
- package/templates/root/.github/workflows/deploy.yml +0 -22
- package/templates/root/Dockerfile +0 -23
- package/templates/root/README.md +0 -69
- package/templates/root/buf.gen.yaml +0 -10
- package/templates/root/buf.yaml +0 -9
- package/templates/root/cmd/server/main.go +0 -44
- package/templates/root/gen/dns/v1/dns.pb.go +0 -623
- package/templates/root/gen/dns/v1/dnsv1connect/dns.connect.go +0 -192
- package/templates/root/go.mod +0 -10
- package/templates/root/internal/app/service.go +0 -152
- package/templates/root/internal/app/token_source.go +0 -50
- package/templates/root/internal/cloudflare/client.go +0 -160
- package/templates/root/internal/config/config.go +0 -55
- package/templates/root/internal/connectapi/handler.go +0 -79
- package/templates/root/internal/httpapi/routes.go +0 -93
- package/templates/root/internal/vault/client.go +0 -148
- package/templates/root/package.json +0 -12
- package/templates/root/protos/dns/v1/dns.proto +0 -58
- package/templates/root/scripts/cloudrun/bootstrap.ts +0 -65
- package/templates/root/scripts/cloudrun/config.ts +0 -50
- package/templates/root/scripts/cloudrun/deploy.ts +0 -41
- package/templates/root/scripts/cloudrun/lib.ts +0 -244
- package/templates/root/service.yaml +0 -50
- package/templates/root/test/go.test.ts +0 -19
- package/templates/shared/scripts/cloudrun/integrations.ts +0 -111
- package/templates/variants/bun-connectrpc/gen/protos/chat/v1/chat_pb.ts +0 -1078
- package/templates/variants/bun-connectrpc/protos/chat/v1/chat.proto +0 -228
- package/templates/variants/bun-connectrpc/src/chat/service.ts +0 -384
- package/templates/variants/bun-connectrpc/src/chat/types.ts +0 -142
- package/templates/variants/bun-connectrpc/src/storage.ts +0 -72
- package/templates/variants/bun-connectrpc/src/webhooks.ts +0 -35
- package/templates/variants/bun-connectrpc/test/list-messages.integration.test.ts +0 -182
- package/templates/variants/bun-hono/src/chat/service.ts +0 -384
- package/templates/variants/bun-hono/src/chat/types.ts +0 -142
- package/templates/variants/bun-hono/src/storage.ts +0 -72
- package/templates/variants/bun-hono/src/webhooks.ts +0 -35
- package/templates/variants/bun-hono/test/list-messages.integration.test.ts +0 -256
- package/templates/variants/go-chi/buf.gen.yaml +0 -12
- package/templates/variants/go-chi/buf.yaml +0 -9
- package/templates/variants/go-chi/cmd/migrate/main.go +0 -101
- package/templates/variants/go-chi/internal/httpapi/list_messages_integration_test.go +0 -298
- package/templates/variants/go-chi/protos/chat/v1/chat.proto +0 -219
- package/templates/variants/go-connectrpc/cmd/migrate/main.go +0 -101
- package/templates/variants/go-connectrpc/gen/chat/v1/chat.pb.go +0 -2512
- package/templates/variants/go-connectrpc/gen/chat/v1/chatv1connect/chat.connect.go +0 -571
- package/templates/variants/go-connectrpc/internal/connectapi/list_messages_integration_test.go +0 -216
- package/templates/variants/go-connectrpc/protos/chat/v1/chat.proto +0 -232
- /package/bin/{create-svc.mjs → service.mjs} +0 -0
package/README.md
CHANGED
|
@@ -1,43 +1,56 @@
|
|
|
1
|
-
#
|
|
1
|
+
# service
|
|
2
2
|
|
|
3
|
-
`
|
|
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
|
-
-
|
|
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
|
-
-
|
|
9
|
-
-
|
|
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
|
|
13
|
-
-
|
|
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
|
|
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
|
-
|
|
23
|
+
service create my-service
|
|
26
24
|
```
|
|
27
25
|
|
|
28
|
-
|
|
26
|
+
Inside a generated service repo, the same command operates that repo:
|
|
29
27
|
|
|
30
28
|
```bash
|
|
31
|
-
|
|
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
|
-
|
|
43
|
+
service create my-service --yes
|
|
38
44
|
```
|
|
39
45
|
|
|
40
|
-
`--profile microservice` is accepted as a compatibility no-op.
|
|
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
|
-
|
|
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
|
-
|
|
66
|
-
|
|
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
|
|
86
|
+
## Generated Service Package
|
|
75
87
|
|
|
76
88
|
First local run:
|
|
77
89
|
|
|
78
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
|
|
113
|
+
service create
|
|
114
|
+
service deploy
|
|
115
|
+
service destroy
|
|
106
116
|
```
|
|
107
117
|
|
|
108
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
165
|
+
The GitHub Actions workflow authenticates with npm via OIDC and runs `npm publish` without an npm token.
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-svc",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Local
|
|
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
|
-
"
|
|
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.
|
|
52
|
-
"@google-cloud/billing": "^5.1.
|
|
53
|
-
"@google-cloud/resource-manager": "^6.2.
|
|
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 {
|
|
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
|
|
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"])
|
|
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
|
-
|
|
38
|
-
|
|
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("
|
|
43
|
-
expect(() =>
|
|
44
|
-
expect(() =>
|
|
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 () => {
|