@freecodecamp/universe-cli 0.3.3 → 0.5.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 (4) hide show
  1. package/README.md +130 -45
  2. package/dist/index.cjs +16399 -47284
  3. package/dist/index.js +1844 -793
  4. package/package.json +8 -11
package/README.md CHANGED
@@ -17,73 +17,158 @@ universe <command>
17
17
 
18
18
  ### Binary
19
19
 
20
- Download the latest binary from [Releases](../../releases):
20
+ <details>
21
+ <summary>
22
+ Download the latest binary from [Releases](../../releases):
23
+ </summary>
24
+
25
+ ```sh
26
+ # macOS (Apple Silicon)
27
+ gh release download --repo freeCodeCamp-Universe/universe-cli --pattern "universe-darwin-arm64"
28
+ chmod +x universe-darwin-arm64
29
+ sudo mv universe-darwin-arm64 /usr/local/bin/universe
30
+
31
+ # macOS (Intel)
32
+ gh release download --repo freeCodeCamp-Universe/universe-cli --pattern "universe-darwin-amd64"
33
+ chmod +x universe-darwin-amd64
34
+ sudo mv universe-darwin-amd64 /usr/local/bin/universe
35
+
36
+ # Linux x64
37
+ gh release download --repo freeCodeCamp-Universe/universe-cli --pattern "universe-linux-amd64"
38
+ chmod +x universe-linux-amd64
39
+ sudo mv universe-linux-amd64 /usr/local/bin/universe
40
+
41
+ # Linux ARM64
42
+ gh release download --repo freeCodeCamp-Universe/universe-cli --pattern "universe-linux-arm64"
43
+ chmod +x universe-linux-arm64
44
+ sudo mv universe-linux-arm64 /usr/local/bin/universe
45
+ ```
46
+
47
+ </details>
48
+
49
+ Verify:
21
50
 
22
51
  ```sh
23
- # macOS (Apple Silicon)
24
- gh release download --repo freeCodeCamp-Universe/universe-cli --pattern "universe-darwin-arm64"
25
- chmod +x universe-darwin-arm64
26
- sudo mv universe-darwin-arm64 /usr/local/bin/universe
27
-
28
- # macOS (Intel)
29
- gh release download --repo freeCodeCamp-Universe/universe-cli --pattern "universe-darwin-amd64"
30
- chmod +x universe-darwin-amd64
31
- sudo mv universe-darwin-amd64 /usr/local/bin/universe
32
-
33
- # Linux x64
34
- gh release download --repo freeCodeCamp-Universe/universe-cli --pattern "universe-linux-amd64"
35
- chmod +x universe-linux-amd64
36
- sudo mv universe-linux-amd64 /usr/local/bin/universe
37
-
38
- # Linux ARM64
39
- gh release download --repo freeCodeCamp-Universe/universe-cli --pattern "universe-linux-arm64"
40
- chmod +x universe-linux-arm64
41
- sudo mv universe-linux-arm64 /usr/local/bin/universe
52
+ universe --version
42
53
  ```
43
54
 
44
- Verify:
55
+ ## CLI surface
56
+
57
+ Top-level (cross-cutting):
45
58
 
46
59
  ```sh
47
- universe --version
60
+ universe login # GitHub OAuth device flow → ~/.config/universe-cli/token
61
+ universe logout # delete stored token
62
+ universe whoami # echo current login + authorized-sites count
63
+ universe --version # CLI version
48
64
  ```
49
65
 
50
- ## Usage
66
+ Static-site verbs (namespaced under `static`):
51
67
 
52
68
  ```sh
53
- # Deploy a static site (from a directory with platform.yaml and a built dist/)
54
- universe static deploy
69
+ universe static deploy [--promote] [--dir <path>]
70
+ universe static promote [--from <deployId>]
71
+ universe static rollback --to <deployId>
72
+ universe static ls [--site <site>]
73
+ ```
55
74
 
56
- # Deploy without git metadata
57
- universe static deploy --force
75
+ Static-app registry (namespaced under `sites`, staff-gated writes):
58
76
 
59
- # Deploy a non-default build output directory
60
- universe static deploy --output-dir build
77
+ ```sh
78
+ universe sites ls [--mine] # list registered sites; `--mine` filters to your authorized set
79
+ universe sites register <slug> [--team=<name>...] # create new entry (staff; defaults --team to staff)
80
+ universe sites update <slug> --team=<name>... # replace teams list (staff)
81
+ universe sites rm <slug> # delete entry (staff; R2 deploy bytes untouched)
82
+ ```
61
83
 
62
- # Promote preview to production
63
- universe static promote
84
+ All commands support `--json` for CI integration.
85
+
86
+ ## Identity (priority chain)
87
+
88
+ The CLI resolves a GitHub identity in this order — first match wins:
89
+
90
+ 1. `$GITHUB_TOKEN` / `$GH_TOKEN` env (CI explicit)
91
+ 2. GHA OIDC (`$ACTIONS_ID_TOKEN_REQUEST_URL` + `$ACTIONS_ID_TOKEN_REQUEST_TOKEN`)
92
+ 3. Woodpecker OIDC env (deferred — placeholder slot)
93
+ 4. `gh auth token` shell-out (laptop with `gh` installed)
94
+ 5. Device-flow stored token at `~/.config/universe-cli/token`
95
+
96
+ The proxy validates whatever it receives via GitHub `GET /user`, then
97
+ authorizes against the registry server-side (Valkey-backed; the
98
+ `sites_yaml` backend was retired in artemis `f115198`). Run
99
+ `universe whoami` to see which slot resolved; inspect the sites you
100
+ can deploy to with `universe sites ls --mine`.
101
+
102
+ ## Configuration (`platform.yaml`)
64
103
 
65
- # Promote a specific deploy
66
- universe static promote 20260413-120000-abc1234
104
+ Every site has a `platform.yaml` at its repo root. Minimal valid file:
67
105
 
68
- # Rollback production to previous deploy
69
- universe static rollback --confirm
106
+ ```yaml
107
+ site: my-site
70
108
  ```
71
109
 
72
- All commands support `--json` for CI integration. In JSON mode, `rollback` also requires `--confirm`.
110
+ Full schema reference (every field, defaults, validation rules):
111
+ [`docs/platform-yaml.md`](docs/platform-yaml.md).
73
112
 
74
- ## Credentials
113
+ No credential fields. The proxy holds the R2 admin key; the CLI never
114
+ reads or writes one.
75
115
 
76
- The CLI needs R2 credentials. See the [Staff Guide](docs/STAFF-GUIDE.md#2-credentials) for setup.
116
+ ## Common flows
77
117
 
78
- ## Development
118
+ Staff onboarding + deploy lifecycle:
79
119
 
80
120
  ```sh
81
- pnpm install
82
- pnpm vitest run # 180 tests
83
- pnpm tsup # build to dist/
84
- pnpm tsc --noEmit # typecheck
121
+ # 1. Authenticate (laptop, first time)
122
+ universe login
123
+
124
+ # 2. Identity + how many sites you can deploy to
125
+ universe whoami
126
+
127
+ # 3. List your authorized sites (intersects registry with your GH teams)
128
+ universe sites ls --mine
129
+
130
+ # 4. From your site repo: deploy to preview (reads ./platform.yaml)
131
+ universe static deploy
132
+
133
+ # 5. Inspect recent deploys for the current site
134
+ universe static ls
135
+
136
+ # 6. Promote preview to production
137
+ universe static promote
138
+
139
+ # 7. Roll production back to a past deploy
140
+ universe static rollback --to 20260427-141522-abc1234
85
141
  ```
86
142
 
87
- ## Releasing
143
+ Registry admin (staff team only — gated server-side by artemis's
144
+ `REGISTRY_AUTHZ_TEAM`, default `staff`):
145
+
146
+ ```sh
147
+ # Register a new site (defaults --team to staff)
148
+ universe sites register hello-universe --team bots,staff
149
+
150
+ # Add or replace the teams list on an existing site
151
+ universe sites update hello-universe --team bots,staff,curriculum
152
+
153
+ # Delete a site from the registry (R2 bytes age out via cleanup cron)
154
+ universe sites rm hello-universe
155
+ ```
156
+
157
+ CI (GitHub Actions) — set `permissions: id-token: write` and rely on
158
+ slot 2 (GHA OIDC) of the identity chain, or pass `$GITHUB_TOKEN`
159
+ explicitly. Full operator walkthrough:
160
+ [`docs/STAFF-GUIDE.md`](docs/STAFF-GUIDE.md).
161
+
162
+ ## Environment overrides
163
+
164
+ | Env | Default | Purpose |
165
+ | --------------------------- | -------------------------------- | --------------------------------------------------------- |
166
+ | `UNIVERSE_PROXY_URL` | `https://uploads.freecode.camp` | Override proxy host (staging etc.) |
167
+ | `UNIVERSE_GH_CLIENT_ID` | _baked-in freeCodeCamp OAuth id_ | Override GitHub OAuth App id (fork tenants, `login` only) |
168
+ | `GITHUB_TOKEN` / `GH_TOKEN` | — | Slot 1 of identity chain |
88
169
 
89
- See [RELEASING.md](docs/RELEASING.md).
170
+ The shipped binary embeds the `freeCodeCamp` GitHub OAuth App client id
171
+ (public; device flow uses no `client_secret`), so `universe login` works
172
+ out of the box for staff. Fork operators and self-hosted mirror tenants
173
+ set `UNIVERSE_GH_CLIENT_ID` to their own OAuth App's id — env value
174
+ wins when set.