create-svc 0.1.13 → 0.1.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 +19 -6
- package/package.json +1 -3
- package/src/cli.test.ts +31 -2
- package/src/cli.ts +498 -159
- package/src/gcp.ts +35 -44
- package/src/git-bootstrap.ts +14 -11
- package/src/naming.test.ts +1 -1
- package/src/naming.ts +1 -1
- package/src/post-scaffold.test.ts +17 -1
- package/src/post-scaffold.ts +24 -3
- package/src/scaffold.test.ts +12 -5
- package/src/service.test.ts +12 -1
- package/src/service.ts +26 -0
- package/templates/shared/scripts/authctl.ts +17 -1
- package/templates/shared/scripts/cloudrun/cli.ts +21 -2
- package/templates/targets/workers/scripts/workers/cli.ts +20 -2
- package/templates/variants/go-chi/package.json +9 -1
- package/templates/variants/go-connectrpc/package.json +9 -1
package/README.md
CHANGED
|
@@ -23,6 +23,13 @@ npm: <https://www.npmjs.com/package/create-svc>
|
|
|
23
23
|
service create my-service
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
That creates `./my-service` by default. To write somewhere else while keeping
|
|
27
|
+
the service id as `my-service`, pass `--dir`:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
service create my-service --dir /Users/andrewho/repos/projects/my-service
|
|
31
|
+
```
|
|
32
|
+
|
|
26
33
|
Inside a generated service repo, the same command operates that repo:
|
|
27
34
|
|
|
28
35
|
```bash
|
|
@@ -34,7 +41,7 @@ service deploy
|
|
|
34
41
|
To install from npm:
|
|
35
42
|
|
|
36
43
|
```bash
|
|
37
|
-
|
|
44
|
+
npm install -g create-svc
|
|
38
45
|
```
|
|
39
46
|
|
|
40
47
|
For the strict one-command production path:
|
|
@@ -43,14 +50,19 @@ For the strict one-command production path:
|
|
|
43
50
|
service create my-service --yes
|
|
44
51
|
```
|
|
45
52
|
|
|
53
|
+
By default, that scaffolds the repo, installs dependencies, runs the generated
|
|
54
|
+
repo's `service create`, and then runs `service deploy`. Pass
|
|
55
|
+
`--no-auto-deploy` for scaffold-only generation.
|
|
56
|
+
|
|
46
57
|
`--profile microservice` is accepted as a compatibility no-op. App workspaces live outside this package in private app template repositories.
|
|
47
58
|
|
|
48
59
|
By default, a standalone generated service is initialized as a git repository,
|
|
49
60
|
committed with `Initial commit`, created as a private GitHub repository at
|
|
50
|
-
`anmho/<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
61
|
+
`https://github.com/anmho/<service_id>`, and pushed to `origin/main`. Go
|
|
62
|
+
services also default their module path to `github.com/anmho/<service_id>`.
|
|
63
|
+
If the target directory is inside an existing git worktree, `service` skips git
|
|
64
|
+
and GitHub setup so the parent repository remains in control. Pass `--no-git`
|
|
65
|
+
to skip all git and GitHub side effects.
|
|
54
66
|
|
|
55
67
|
## Local Testing
|
|
56
68
|
|
|
@@ -59,7 +71,8 @@ Without publishing to npm:
|
|
|
59
71
|
```bash
|
|
60
72
|
bun install
|
|
61
73
|
npm pack
|
|
62
|
-
|
|
74
|
+
npm install -g ./create-svc-*.tgz
|
|
75
|
+
service create my-service
|
|
63
76
|
```
|
|
64
77
|
|
|
65
78
|
For faster iteration against your working tree:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-svc",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
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",
|
|
@@ -50,8 +50,6 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@clack/prompts": "^1.4.0",
|
|
53
|
-
"@google-cloud/billing": "^5.1.2",
|
|
54
|
-
"@google-cloud/resource-manager": "^6.2.2",
|
|
55
53
|
"@neondatabase/api-client": "^2.7.1",
|
|
56
54
|
"picocolors": "^1.1.1"
|
|
57
55
|
}
|
package/src/cli.test.ts
CHANGED
|
@@ -2,8 +2,10 @@ import { expect, test } from "bun:test";
|
|
|
2
2
|
import { mkdir } from "node:fs/promises";
|
|
3
3
|
import {
|
|
4
4
|
assertDiscoveryReady,
|
|
5
|
+
formatScaffoldHelp,
|
|
5
6
|
normalizeValidationResult,
|
|
6
7
|
parseArgs,
|
|
8
|
+
resolveAutoDeploy,
|
|
7
9
|
validateTargetRuntimeFramework,
|
|
8
10
|
validateServiceNameInput,
|
|
9
11
|
} from "./cli";
|
|
@@ -32,12 +34,12 @@ test("assertDiscoveryReady no longer blocks scaffold when remote discovery is un
|
|
|
32
34
|
|
|
33
35
|
test("parseArgs defaults to microservice and cloudrun target", () => {
|
|
34
36
|
expect(parseArgs(["launch-api", "--yes"])).toMatchObject({
|
|
35
|
-
|
|
37
|
+
serviceName: "launch-api",
|
|
36
38
|
profile: "microservice",
|
|
37
39
|
yes: true,
|
|
38
40
|
});
|
|
39
41
|
expect(parseArgs(["launch-api", "--target", "workers", "--yes"])).toMatchObject({
|
|
40
|
-
|
|
42
|
+
serviceName: "launch-api",
|
|
41
43
|
target: "workers",
|
|
42
44
|
yes: true,
|
|
43
45
|
});
|
|
@@ -47,6 +49,33 @@ test("parseArgs defaults to microservice and cloudrun target", () => {
|
|
|
47
49
|
expect(() => parseArgs(["launch-api", "--profile", "microservice", "--bootstrap"])).toThrow("Unknown argument");
|
|
48
50
|
});
|
|
49
51
|
|
|
52
|
+
test("resolveAutoDeploy defaults to one-shot create and deploy", () => {
|
|
53
|
+
expect(resolveAutoDeploy(undefined)).toBeTrue();
|
|
54
|
+
expect(resolveAutoDeploy(true)).toBeTrue();
|
|
55
|
+
expect(resolveAutoDeploy(false)).toBeFalse();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("parseArgs supports an explicit output directory", () => {
|
|
59
|
+
expect(parseArgs(["launch-api", "--dir", "/tmp/generated-launch-api", "--yes"])).toMatchObject({
|
|
60
|
+
serviceName: "launch-api",
|
|
61
|
+
directory: "/tmp/generated-launch-api",
|
|
62
|
+
yes: true,
|
|
63
|
+
});
|
|
64
|
+
expect(parseArgs(["--dir=/tmp/generated-launch-api", "--yes"])).toMatchObject({
|
|
65
|
+
directory: "/tmp/generated-launch-api",
|
|
66
|
+
yes: true,
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test("formatScaffoldHelp is compact and starts at usage", () => {
|
|
71
|
+
const help = formatScaffoldHelp();
|
|
72
|
+
expect(help.startsWith("Usage:\n")).toBeTrue();
|
|
73
|
+
expect(help).not.toContain("\n\n\n");
|
|
74
|
+
expect(help).not.toContain("│");
|
|
75
|
+
expect(help).toContain("service create <service_id> [options]");
|
|
76
|
+
expect(help).toContain("--dir <path>");
|
|
77
|
+
});
|
|
78
|
+
|
|
50
79
|
test("parseArgs rejects the removed app profile", () => {
|
|
51
80
|
expect(() => parseArgs(["tracker", "--profile=app", "--yes"])).toThrow("app profile has moved");
|
|
52
81
|
});
|