@groundfloorcloud/cli 0.1.2 → 0.1.3

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 (3) hide show
  1. package/README.md +30 -4
  2. package/dist/index.js +27 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -54,15 +54,28 @@ curl -H "Authorization: Bearer $(gf token)" \
54
54
  create if needed, upload a version, wait for the build, deploy, poll until
55
55
  complete, and print IDs and the URL.
56
56
 
57
- Do not create an App just to run a function, job, schedule, or service.
58
- Use `gf deploy`. Bind `--app-id` only when the coderunner should be a helper
59
- of an existing product App.
57
+ Do not create an App just to run a function, job, schedule, or service
58
+ (Deployment). Use `gf deploy`. Bind `--app-id` only when the coderunner should
59
+ be a helper of an existing product App.
60
+
61
+ **Before the first create:** enable workspace Authentication (Administer →
62
+ Authentication, mode `groundfloor` or `external`) until the realm is active.
63
+
64
+ ### Workload types
65
+
66
+ | `--workload-type` | Also called | Package notes |
67
+ |-------------------|-------------|---------------|
68
+ | `function` | Function | HTTP on `PORT`/8080. Node needs `scripts.start`. |
69
+ | `job` | Background job | Run-to-completion. Then `gf coderunner run`. |
70
+ | `schedule` | Scheduled job | Cron. No public URL. |
71
+ | `service` | **Deployment** | Long-running HTTP. **Root `Dockerfile` is required.** |
60
72
 
61
73
  ```bash
62
74
  gf deploy
63
75
  gf deploy --git https://github.com/me/my-fn.git --ref main
64
76
  gf deploy --name my-fn --runtime python --cpu 250m --memory 256Mi \
65
77
  -e API_KEY=secret
78
+ gf deploy --workload-type service
66
79
  gf deploy --app-id <app-uuid>
67
80
  ```
68
81
 
@@ -75,6 +88,19 @@ How the target is chosen:
75
88
 
76
89
  Runtime is auto-detected when omitted (`package.json` → node,
77
90
  `requirements.txt` / `pyproject.toml` → python), defaulting to python.
91
+ Node images run `npm start` — add `"scripts": { "start": "node index.js" }`.
92
+
93
+ ### Local with live data
94
+
95
+ ```bash
96
+ eval "$(gf env)"
97
+ export PORT=8080
98
+ npm start
99
+ curl -sS -H "Authorization: Bearer $(gf token)" \
100
+ "$CONTROLPLANE_URL/v1/workspaces/$GROUNDFLOOR_WORKSPACE_ID/vault/collections"
101
+ ```
102
+
103
+ Then `gf deploy` the same tree. Do not zip `.env` files.
78
104
 
79
105
  ### `groundfloor.json`
80
106
 
@@ -98,7 +124,7 @@ Runtime is auto-detected when omitted (`package.json` → node,
98
124
  | `--git <url>` / `--ref <ref>` | Clone and deploy a remote repo. |
99
125
  | `--subdir <dir>` | Package a subdirectory of the source. |
100
126
  | `--runtime <r>` | `python` \| `node` \| `dotnet-script`. |
101
- | `--workload-type <t>` | `function` \| `service` \| `job` \| `schedule`. |
127
+ | `--workload-type <t>` | `function` \| `service` (Deployment) \| `job` \| `schedule`. Service requires a Dockerfile. |
102
128
  | `--cpu` / `--memory` | Resource requests, e.g. `250m` / `256Mi`. |
103
129
  | `-e, --env KEY=VALUE` | Deployment env var (repeatable). |
104
130
  | `-m, --message <text>` | Version description. |
package/dist/index.js CHANGED
@@ -1239,6 +1239,33 @@ async function deployCommand(opts) {
1239
1239
  `Invalid workload type "${workloadType}" (expected: ${[...WORKLOAD_TYPES].join(", ")}).`
1240
1240
  );
1241
1241
  }
1242
+ if (workloadType === "service") {
1243
+ try {
1244
+ await fs3.access(path3.join(pkg.sourceDir, "Dockerfile"));
1245
+ } catch {
1246
+ throw new Error(
1247
+ 'workload type "service" (also called Deployment) requires a Dockerfile at the project root.'
1248
+ );
1249
+ }
1250
+ }
1251
+ if (runtime === "node") {
1252
+ try {
1253
+ const raw = await fs3.readFile(
1254
+ path3.join(pkg.sourceDir, "package.json"),
1255
+ "utf8"
1256
+ );
1257
+ const npm = JSON.parse(raw);
1258
+ if (!npm.scripts?.start?.trim()) {
1259
+ throw new Error(
1260
+ 'Node Coderunner packages require package.json "scripts.start" (runtime CMD is npm start).'
1261
+ );
1262
+ }
1263
+ } catch (err) {
1264
+ if (err instanceof Error && err.message.includes("scripts.start")) {
1265
+ throw err;
1266
+ }
1267
+ }
1268
+ }
1242
1269
  let coderunnerId = opts.coderunner;
1243
1270
  if (!coderunnerId) {
1244
1271
  const name = opts.name ?? manifest.name ?? (opts.git ? nameFromGitUrl(opts.git) : path3.basename(path3.resolve(opts.path ?? process.cwd())));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@groundfloorcloud/cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Groundfloor gf CLI — sign in, deploy coderunners, publish Shell apps, and manage secrets, files, and Dataplane.",
5
5
  "type": "module",
6
6
  "bin": {