wawesome 0.10.0 → 0.11.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.
- package/README.md +122 -110
- package/dist/index.mjs +141 -43
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# wawesome
|
|
2
2
|
|
|
3
|
-
> Official CLI for
|
|
4
|
-
>
|
|
3
|
+
> Official CLI for bundling and deploying serverless WebAssembly functions on the
|
|
4
|
+
> [wawesome.io](https://wawesome.io) platform.
|
|
5
5
|
|
|
6
6
|
[](https://www.npmjs.com/package/wawesome)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Write a TypeScript function, deploy it from your terminal, and get back the address it answers on.
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## Quick start
|
|
13
13
|
|
|
14
14
|
### 1. Create an account
|
|
15
15
|
|
|
16
16
|
Sign up for free at **[https://wawesome.io](https://wawesome.io)** to set up your workspace.
|
|
17
17
|
|
|
18
|
-
### 2. Authenticate CLI
|
|
18
|
+
### 2. Authenticate the CLI
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
Log in through your browser:
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
23
|
npx wawesome login
|
|
@@ -32,14 +32,14 @@ mkdir my-wasm-app && cd my-wasm-app
|
|
|
32
32
|
npx wawesome init
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
`init` asks for the function name and for the **App slug
|
|
35
|
+
`init` asks for the function name and for the **App slug**. An App groups the Functions of one
|
|
36
36
|
project, and its slug is part of the public URL your client sees. Both default to the directory
|
|
37
37
|
name, so naming is usually a matter of pressing enter.
|
|
38
38
|
|
|
39
39
|
An App slug must be a legal hostname label: lowercase letters, numbers, and single hyphens between
|
|
40
|
-
them (no leading or trailing hyphen, 63 characters at most). Type something else
|
|
41
|
-
and the CLI shows you the slug it would become (`my-client`) and asks again, rather
|
|
42
|
-
your answer behind your back.
|
|
40
|
+
them (no leading or trailing hyphen, 63 characters at most). Type something else, such as
|
|
41
|
+
`My Client`, and the CLI shows you the slug it would become (`my-client`) and asks again, rather
|
|
42
|
+
than rewriting your answer behind your back.
|
|
43
43
|
|
|
44
44
|
#### Starting from a template
|
|
45
45
|
|
|
@@ -51,39 +51,40 @@ npx wawesome init --template stripe-webhook
|
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
This goes from nothing to a deployed Function in one command. The template is downloaded over
|
|
54
|
-
plain HTTP and unpacked
|
|
55
|
-
they are published. Only the `name` in `package.json`, the App and
|
|
56
|
-
`wawesome-function.json`, and the `wawesome` dependency
|
|
57
|
-
get depends on the CLI that scaffolded it rather than the one the template was released
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
plain HTTP and unpacked, so **git is not required** on any platform, and its files land exactly as
|
|
55
|
+
they are published. Only three things are touched: the `name` in `package.json`, the App and
|
|
56
|
+
Function names in `wawesome-function.json`, and the `wawesome` dependency. That last one is so the
|
|
57
|
+
project you get depends on the CLI that scaffolded it rather than the one the template was released
|
|
58
|
+
against.
|
|
59
|
+
|
|
60
|
+
Templates declare what they need rather than shipping placeholders. The CLI asks for each
|
|
61
|
+
environment variable the template requires, showing where in the provider's own dashboard to find
|
|
62
|
+
the value. It stores them (secrets write-only), enables any outbound providers the template calls,
|
|
62
63
|
and deploys. If a value does not exist yet, leave it blank; the CLI tells you the `env set` command
|
|
63
64
|
to run once it does.
|
|
64
65
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
template's imports. Pass `--no-install` to do it yourself. A failed install never stops the flow
|
|
68
|
-
the command to re-run
|
|
66
|
+
The CLI installs your dependencies with whatever package manager launched it (`npx`, `pnpm dlx`,
|
|
67
|
+
`bun x`), so the types are there when you open the project and the bundler can resolve the
|
|
68
|
+
template's imports. Pass `--no-install` to do it yourself. A failed install never stops the flow,
|
|
69
|
+
and the CLI prints the command to re-run.
|
|
69
70
|
|
|
70
71
|
Before any of that is sent anywhere, the CLI shows you the **public URL your Function will have**
|
|
71
|
-
and offers to change your workspace address
|
|
72
|
-
project's, and the same one `wawesome workspace show` prints.
|
|
73
|
-
stays changeable until your first deploy, at which point it locks for good, because
|
|
74
|
-
it. Press enter to keep it. If it is already locked, the
|
|
75
|
-
|
|
72
|
+
and offers to change your workspace address. That is the part of the URL which is yours rather
|
|
73
|
+
than this project's, and it is the same one `wawesome workspace show` prints. Signup mints it at
|
|
74
|
+
random and it stays changeable until your first deploy, at which point it locks for good, because
|
|
75
|
+
live URLs carry it. Press enter to keep it. If it is already locked, the CLI does not make the
|
|
76
|
+
offer and says why.
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
offers you a login there and then, and declining still leaves you the project plus
|
|
79
|
-
that finish it.
|
|
78
|
+
The CLI checks you are logged in **before** the first question rather than at the deploy. An
|
|
79
|
+
expired session offers you a login there and then, and declining still leaves you the project plus
|
|
80
|
+
the two commands that finish it.
|
|
80
81
|
|
|
81
|
-
Run it in an empty directory
|
|
82
|
-
|
|
82
|
+
Run it in an empty directory. If any file would be overwritten, nothing is written at all and the
|
|
83
|
+
CLI names the collision.
|
|
83
84
|
|
|
84
|
-
### 4. Build
|
|
85
|
+
### 4. Build and deploy
|
|
85
86
|
|
|
86
|
-
Deploy your serverless function to
|
|
87
|
+
Deploy your serverless function to the platform:
|
|
87
88
|
|
|
88
89
|
```bash
|
|
89
90
|
npx wawesome deploy
|
|
@@ -91,7 +92,7 @@ npx wawesome deploy
|
|
|
91
92
|
|
|
92
93
|
---
|
|
93
94
|
|
|
94
|
-
##
|
|
95
|
+
## Command reference
|
|
95
96
|
|
|
96
97
|
| Command | Description |
|
|
97
98
|
|:----------------------------------------|:--------------------------------------------------------------------|
|
|
@@ -116,37 +117,37 @@ npx wawesome deploy
|
|
|
116
117
|
| `npx wawesome env list` | View environment variables for the current app |
|
|
117
118
|
| `npx wawesome env set <key> <val>` | Set an environment variable (add `--secret` for write-only) |
|
|
118
119
|
| `npx wawesome env rm <key>` | Delete an environment variable |
|
|
119
|
-
| `npx wawesome credentials` | List deploy credentials
|
|
120
|
+
| `npx wawesome credentials` | List deploy credentials: name, prefix, capabilities, Apps, last use |
|
|
120
121
|
| `npx wawesome credentials mint <name>` | Mint a deploy credential and print its secret, once |
|
|
121
122
|
| `npx wawesome credentials revoke <name>`| Revoke a deploy credential by name or prefix |
|
|
122
123
|
|
|
123
124
|
---
|
|
124
125
|
|
|
125
|
-
##
|
|
126
|
+
## Unsupported globals
|
|
126
127
|
|
|
127
128
|
Every build scans the bundle it just produced against the platform's declared guest surface, and says
|
|
128
129
|
nothing unless it finds something.
|
|
129
130
|
|
|
130
|
-
- **`Intl` is not provided.** Where the bundle reaches it as it loads
|
|
131
|
-
dependency's
|
|
132
|
-
evaluate on the platform. Where the reference sits inside a function that may never be called,
|
|
131
|
+
- **`Intl` is not provided.** Where the bundle reaches it as it loads, in your own module scope or
|
|
132
|
+
a dependency's, the build is refused before a deploy uploads anything, because that bundle would
|
|
133
|
+
not evaluate on the platform. Where the reference sits inside a function that may never be called,
|
|
133
134
|
behind a `typeof` check, or inside a `try`, you get a warning and the deploy proceeds.
|
|
134
135
|
- **`toLocaleString`, `toLocaleDateString`, `toLocaleTimeString`, `toLocaleLowerCase` and
|
|
135
136
|
`toLocaleUpperCase` ignore their locale argument.** They run and return an unlocalised answer, so
|
|
136
137
|
these warn.
|
|
137
138
|
|
|
138
139
|
Each message names the global, the file and line in *your* source, and what to do about it. Declaring
|
|
139
|
-
an `Intl` polyfill in your `package.json
|
|
140
|
-
reads](#testing-against-the-guests-javascript-surface)
|
|
140
|
+
an `Intl` polyfill in your `package.json`, the same declaration [local parity
|
|
141
|
+
reads](#testing-against-the-guests-javascript-surface), silences the report, as does installing one
|
|
141
142
|
on `globalThis` in the bundle itself. The scan reads static references only: a global reached through
|
|
142
143
|
`globalThis['Intl']` is invisible to it, so it never refuses a deploy on a guess. `deploy
|
|
143
144
|
--skip-build` scans the bundle it found on disk before uploading it.
|
|
144
145
|
|
|
145
|
-
##
|
|
146
|
+
## Invocation logs
|
|
146
147
|
|
|
147
148
|
Inspect past function runs or view raw `stdout` / `stderr` log outputs directly in your terminal.
|
|
148
149
|
|
|
149
|
-
### 1. List
|
|
150
|
+
### 1. List recent invocations
|
|
150
151
|
|
|
151
152
|
List past executions (including status, trigger type, timestamp, and duration) for the function in the
|
|
152
153
|
current directory:
|
|
@@ -161,7 +162,7 @@ Or list invocations for a specific function by name:
|
|
|
161
162
|
npx wawesome logs my-function
|
|
162
163
|
```
|
|
163
164
|
|
|
164
|
-
Filter by invocation status
|
|
165
|
+
Filter by invocation status, to show only errors or timeouts:
|
|
165
166
|
|
|
166
167
|
```bash
|
|
167
168
|
npx wawesome logs my-function --error
|
|
@@ -169,7 +170,7 @@ npx wawesome logs my-function --status timeout
|
|
|
169
170
|
npx wawesome logs my-function --running
|
|
170
171
|
```
|
|
171
172
|
|
|
172
|
-
### 2. View
|
|
173
|
+
### 2. View the invocation log body (`stdout`/`stderr`)
|
|
173
174
|
|
|
174
175
|
Fetch and print the captured `console.log` / `console.error` text for a specific invocation:
|
|
175
176
|
|
|
@@ -183,9 +184,9 @@ Or pass the UUID directly as the target:
|
|
|
183
184
|
npx wawesome logs 019fb344-ea0c-78f2-8a9b-d04e188b9823
|
|
184
185
|
```
|
|
185
186
|
|
|
186
|
-
### 3. Follow
|
|
187
|
+
### 3. Follow live output (`--follow`)
|
|
187
188
|
|
|
188
|
-
Stream an invocation's output as it runs
|
|
189
|
+
Stream an invocation's output as it runs, like `tail -f` for your serverless function.
|
|
189
190
|
|
|
190
191
|
#### Follow by function name (recommended)
|
|
191
192
|
|
|
@@ -205,13 +206,13 @@ npx wawesome logs 019fb344-ea0c-78f2-8a9b-d04e188b9823 --follow
|
|
|
205
206
|
|
|
206
207
|
#### Reconnection
|
|
207
208
|
|
|
208
|
-
On transient network
|
|
209
|
-
|
|
210
|
-
|
|
209
|
+
On a transient network error or a 5xx, the CLI reconnects with exponential back-off, up to three
|
|
210
|
+
retries. It does not retry an authentication failure (401) or an unknown invocation (404). Those
|
|
211
|
+
exit at once, naming what happened.
|
|
211
212
|
|
|
212
213
|
---
|
|
213
214
|
|
|
214
|
-
##
|
|
215
|
+
## Manual invocation
|
|
215
216
|
|
|
216
217
|
Fire a background run of a Function immediately without waiting for a schedule tick or deploying code:
|
|
217
218
|
|
|
@@ -231,11 +232,11 @@ npx wawesome invoke --no-follow
|
|
|
231
232
|
|
|
232
233
|
---
|
|
233
234
|
|
|
234
|
-
##
|
|
235
|
+
## Schedules and cron management
|
|
235
236
|
|
|
236
237
|
Manage recurring Schedules and inspect background run history directly from your terminal.
|
|
237
238
|
|
|
238
|
-
### 1. List
|
|
239
|
+
### 1. List schedules
|
|
239
240
|
|
|
240
241
|
List a Function's Schedules with expression, state, and next run in UTC:
|
|
241
242
|
|
|
@@ -250,12 +251,12 @@ npx wawesome cron list my-function
|
|
|
250
251
|
npx wawesome cron list --app my-app
|
|
251
252
|
```
|
|
252
253
|
|
|
253
|
-
The output
|
|
254
|
+
The output tells the three off-states apart:
|
|
254
255
|
- `paused`: stopped by a user, resumable with `wawesome cron resume <name>`
|
|
255
256
|
- `not in this config file`: disabled because it was removed from configuration, resumable only by declaring it again in code
|
|
256
257
|
- `suspended`: suspended by the non-payment ladder, resumable only after settling workspace balance
|
|
257
258
|
|
|
258
|
-
### 2. Pause and
|
|
259
|
+
### 2. Pause and resume schedules
|
|
259
260
|
|
|
260
261
|
```bash
|
|
261
262
|
# Pause a schedule by name (stops queued ticks and survives future deploys)
|
|
@@ -268,7 +269,7 @@ npx wawesome cron pause nightly-reconcile --reason "database maintenance"
|
|
|
268
269
|
npx wawesome cron resume nightly-reconcile
|
|
269
270
|
```
|
|
270
271
|
|
|
271
|
-
### 3. Read
|
|
272
|
+
### 3. Read run history
|
|
272
273
|
|
|
273
274
|
Inspect past scheduled and manual runs, showing when each run was due, when it started, pool delay, and how it ended:
|
|
274
275
|
|
|
@@ -282,15 +283,15 @@ npx wawesome cron history my-function --state failed
|
|
|
282
283
|
|
|
283
284
|
---
|
|
284
285
|
|
|
285
|
-
##
|
|
286
|
+
## Deploy credentials
|
|
286
287
|
|
|
287
288
|
A deploy credential is what a CI pipeline or an agent authenticates with, where there is nobody at a
|
|
288
289
|
keyboard to log in. It belongs to the workspace rather than to you: it keeps working after you leave,
|
|
289
|
-
and revoking it does not end your own session. Once you have one, [Deploying from CI](
|
|
290
|
+
and revoking it does not end your own session. Once you have one, [Deploying from CI](#deploying-from-ci)
|
|
290
291
|
is what to do with it.
|
|
291
292
|
|
|
292
|
-
Minting, listing and revoking
|
|
293
|
-
themselves whatever
|
|
293
|
+
Minting, listing and revoking belong to the workspace owner. They are closed to deploy credentials
|
|
294
|
+
themselves, whatever those carry, so a leaked credential cannot mint another. All three run on your
|
|
294
295
|
ordinary `npx wawesome login` session.
|
|
295
296
|
|
|
296
297
|
### Mint one
|
|
@@ -299,8 +300,8 @@ ordinary `npx wawesome login` session.
|
|
|
299
300
|
npx wawesome credentials mint ci-pipeline
|
|
300
301
|
```
|
|
301
302
|
|
|
302
|
-
The secret is printed once and never again
|
|
303
|
-
rebuild it. It goes to stdout on a line of its own and everything else the command prints goes to
|
|
303
|
+
The secret is printed once and never again. The platform stores a digest of it, so no later read
|
|
304
|
+
can rebuild it. It goes to stdout on a line of its own and everything else the command prints goes to
|
|
304
305
|
stderr, so a redirect catches the secret and not one character besides:
|
|
305
306
|
|
|
306
307
|
```bash
|
|
@@ -321,9 +322,9 @@ npx wawesome credentials mint agent -c logs:read -a prod --expires never
|
|
|
321
322
|
| `-a, --app` | Restrict to these Apps, by slug. Repeatable. Default: every App in the workspace |
|
|
322
323
|
| `--expires` | Days, or `never`. Default: 90 |
|
|
323
324
|
|
|
324
|
-
An App named in a restriction does not have to exist yet
|
|
325
|
+
An App named in a restriction does not have to exist yet. A pipeline whose first deploy creates the
|
|
325
326
|
App it was minted for is the ordinary case. A restriction bounds what a credential can disturb, not
|
|
326
|
-
what it can read
|
|
327
|
+
what it can read. A Function deployed into one App still reads the whole workspace's environment at
|
|
327
328
|
runtime.
|
|
328
329
|
|
|
329
330
|
### List them
|
|
@@ -332,7 +333,7 @@ runtime.
|
|
|
332
333
|
npx wawesome credentials
|
|
333
334
|
```
|
|
334
335
|
|
|
335
|
-
Name, displayable prefix, capabilities, Apps, last use and expiry
|
|
336
|
+
Name, displayable prefix, capabilities, Apps, last use and expiry. Never the secret, which the
|
|
336
337
|
platform no longer holds. `LAST USED` lags by a few minutes and reads `never` for a credential
|
|
337
338
|
nothing has ever presented, which is a better reason to revoke one than any calendar date.
|
|
338
339
|
|
|
@@ -350,7 +351,7 @@ it.
|
|
|
350
351
|
|
|
351
352
|
---
|
|
352
353
|
|
|
353
|
-
##
|
|
354
|
+
## Configuration and a custom gateway
|
|
354
355
|
|
|
355
356
|
### `wawesome-function.json`
|
|
356
357
|
|
|
@@ -364,7 +365,7 @@ Every project directory includes a `wawesome-function.json` file generated durin
|
|
|
364
365
|
}
|
|
365
366
|
```
|
|
366
367
|
|
|
367
|
-
`app` is the App this Function is deployed into, and it is client-facing
|
|
368
|
+
`app` is the App this Function is deployed into, and it is client-facing. Every deploy from this
|
|
368
369
|
directory is scoped to it.
|
|
369
370
|
|
|
370
371
|
`function` is the address. Changing it does not rename anything: your Function's URL is built from
|
|
@@ -385,40 +386,40 @@ Add `"assets"` to deploy static files beside your code:
|
|
|
385
386
|
```
|
|
386
387
|
|
|
387
388
|
Everything under that directory is deployed with the version and served at its path beneath your
|
|
388
|
-
Function's URL
|
|
389
|
+
Function's URL, so `dist/client/assets/index-a1.js` answers at `https://<app-host>/<function>/assets/index-a1.js`.
|
|
389
390
|
The CLI hashes each file and asks the platform which of them it does not already hold, so a redeploy
|
|
390
|
-
that changed one chunk uploads one chunk
|
|
391
|
-
|
|
391
|
+
that changed one chunk uploads one chunk. A deploy that changed nothing at all is refused before a
|
|
392
|
+
byte moves.
|
|
392
393
|
|
|
393
394
|
Files are served straight from object storage; your Function is never invoked for one, and no
|
|
394
|
-
invocation is recorded. They answer on your App's own hostname and nowhere else
|
|
395
|
+
invocation is recorded. They answer on your App's own hostname and nowhere else. On the
|
|
395
396
|
development path form (`/x/<tenant>/<app>/<function>/...`) the same address reaches your handler
|
|
396
397
|
as it always has, because a file on an origin every workspace shares would be same-origin with
|
|
397
398
|
all of them. Each carries `Cache-Control: public, max-age=31536000, immutable` and an
|
|
398
|
-
`ETag`, so name your build output by content hash
|
|
399
|
+
`ETag`, so name your build output by content hash. A file's bytes must never change under a name a
|
|
399
400
|
browser has already cached for a year. The content type comes from the extension against a fixed
|
|
400
401
|
allowlist and is never sniffed; anything off it is served as a download.
|
|
401
402
|
|
|
402
403
|
Two rules to know about:
|
|
403
404
|
|
|
404
405
|
- **Everything beneath `assets/` is static**, whatever the deploy carries. A request there never
|
|
405
|
-
reaches your handler
|
|
406
|
+
reaches your handler, and an unknown path under it is a 404 rather than a route for you to answer.
|
|
406
407
|
- **At most 100 files may sit outside `assets/`.** Those paths travel on the version record so a
|
|
407
408
|
request can be routed without a lookup per file. Put bulk output under `assets/`, where a file
|
|
408
409
|
costs nothing; `favicon.ico`, `robots.txt` and a `.well-known/` directory are what the rest is
|
|
409
410
|
for.
|
|
410
411
|
|
|
411
412
|
**HTML is refused at deploy time.** Your Function renders its own markup, and a document served from
|
|
412
|
-
your App's own origin is the sharpest same-origin
|
|
413
|
+
your App's own origin is the sharpest same-origin risk a static file carries.
|
|
413
414
|
|
|
414
415
|
**An SVG is served inert.** The rule behind the refusal above is that nothing you deploy as a file
|
|
415
|
-
becomes a page on your App's own origin, and an SVG opened directly in a browser would
|
|
416
|
-
script, and it renders whatever HTML a `<foreignObject>` holds. It is served rather than
|
|
417
|
-
because making it inert costs the file nothing
|
|
418
|
-
is never checked against the policy, so your drawings render as they always did. Every
|
|
419
|
-
file carries `Content-Security-Policy: script-src 'none'; sandbox`, and only navigating
|
|
420
|
-
one loses anything
|
|
421
|
-
navigate and a page embedding it through `<object>` or `<iframe>` cannot reach into its DOM.
|
|
416
|
+
becomes a page on your App's own origin, and an SVG opened directly in a browser would become one.
|
|
417
|
+
It runs script, and it renders whatever HTML a `<foreignObject>` holds. It is served rather than
|
|
418
|
+
refused because making it inert costs the file nothing. An `<img src="logo.svg">` never ran that
|
|
419
|
+
script and is never checked against the policy, so your drawings render as they always did. Every
|
|
420
|
+
SVG and XML file carries `Content-Security-Policy: script-src 'none'; sandbox`, and only navigating
|
|
421
|
+
straight to one loses anything. Such a file is sandboxed onto an origin of its own, so its links no
|
|
422
|
+
longer navigate and a page embedding it through `<object>` or `<iframe>` cannot reach into its DOM.
|
|
422
423
|
|
|
423
424
|
### Schedules
|
|
424
425
|
|
|
@@ -433,12 +434,12 @@ Add `"schedules"` to run a Function on a recurring timer, with no caller:
|
|
|
433
434
|
}
|
|
434
435
|
```
|
|
435
436
|
|
|
436
|
-
An expression is **five fields, read in UTC
|
|
437
|
-
is no seconds field
|
|
437
|
+
An expression is **five fields, read in UTC**: minute, hour, day of month, month, day of week. There
|
|
438
|
+
is no seconds field and no timezone. A local zone would make one night a year fire a job twice and
|
|
438
439
|
another night not at all.
|
|
439
440
|
|
|
440
441
|
The name is yours to choose and is what the platform keys the schedule by, so editing an expression
|
|
441
|
-
is a change to the same schedule rather than the deletion of one and the creation of another
|
|
442
|
+
is a change to the same schedule rather than the deletion of one and the creation of another. Its
|
|
442
443
|
history and its paused state stay attached to it.
|
|
443
444
|
|
|
444
445
|
Your deploy applies them and prints each one with the time it will next run. It is refused, before
|
|
@@ -448,7 +449,7 @@ five minutes, or if one Function declares more than five schedules.
|
|
|
448
449
|
Two rules worth knowing before you edit the file:
|
|
449
450
|
|
|
450
451
|
- **A schedule you delete from the file is disabled, not deleted.** Its history stays, and declaring
|
|
451
|
-
it again is what turns it back on
|
|
452
|
+
it again is what turns it back on, so a typo costs you a deploy rather than a job's record.
|
|
452
453
|
- **A deploy never resumes a schedule a person paused.** When it runs is code; whether it is running
|
|
453
454
|
is not, and an unrelated commit the next morning must not restart what you stopped at 3am.
|
|
454
455
|
|
|
@@ -469,7 +470,7 @@ A job on a timer should not also be sitting at a guessable URL where a stranger
|
|
|
469
470
|
}
|
|
470
471
|
```
|
|
471
472
|
|
|
472
|
-
A private Function has **no public address at all** in production
|
|
473
|
+
A private Function has **no public address at all** in production, not a hidden one and not one
|
|
473
474
|
behind a credential. A request for it against your App's own hostname is answered with the same 404
|
|
474
475
|
as a Function that was never deployed. This is how you deploy a job with side effects without leaving
|
|
475
476
|
it where a stranger who guesses the slug can fire it.
|
|
@@ -497,7 +498,7 @@ the line is refused, and the deploy tells you so having written nothing.
|
|
|
497
498
|
npx wawesome deploy --publish
|
|
498
499
|
```
|
|
499
500
|
|
|
500
|
-
That is deliberate
|
|
501
|
+
That is deliberate. The line that keeps a job off the internet is one line, and a deploy that
|
|
501
502
|
quietly honoured its deletion would put the job back on the open internet with nothing said. Every
|
|
502
503
|
deploy prints the visibility it landed, beside the URL or in place of it.
|
|
503
504
|
|
|
@@ -529,19 +530,30 @@ deploy prints the refusal and lands everything else it was doing.
|
|
|
529
530
|
The address derived from your workspace slug keeps serving after you attach a domain. Both names
|
|
530
531
|
answer, so webhooks and integrations already pointed at the old one keep working.
|
|
531
532
|
|
|
532
|
-
An apex domain
|
|
533
|
+
An apex domain, `client.com` with no `www`, attaches like any other name. Whether a CNAME may sit at
|
|
533
534
|
your zone root is your DNS provider's rule, and where it cannot, attach `www.client.com` and configure
|
|
534
535
|
the redirect at the provider.
|
|
535
536
|
|
|
536
|
-
Deleting the line detaches nothing. Detaching takes a live site dark, which is not something a
|
|
537
|
-
should infer from a deleted line.
|
|
537
|
+
Deleting the line detaches nothing. Detaching takes a live site dark, which is not something a
|
|
538
|
+
deploy should infer from a deleted line. So the deploy reports the domain it found and left serving,
|
|
539
|
+
and names the one command that takes it off:
|
|
540
|
+
|
|
541
|
+
```bash
|
|
542
|
+
npx wawesome domains detach shop.client.com
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
The hostname is typed because an App carries exactly one domain, and the command that removes it
|
|
546
|
+
should not be one you can run by reflex. It says what it is about to do first: the domain stops
|
|
547
|
+
resolving here, this App's own address keeps serving, and the certificate is given back. Afterwards
|
|
548
|
+
the name is free to attach again by declaring it and deploying, which is also what the next deploy
|
|
549
|
+
does if you leave the line in the file.
|
|
538
550
|
|
|
539
551
|
### Reserved headers
|
|
540
552
|
|
|
541
553
|
`x-wawesome-*` belongs to the platform in both directions. It is stripped off the request before your
|
|
542
|
-
handler sees it, and off your response before the caller does
|
|
543
|
-
on that prefix
|
|
544
|
-
you why it vanished.
|
|
554
|
+
handler sees it, and off your response before the caller does. So **do not name a header of your
|
|
555
|
+
own on that prefix**. It is dropped silently rather than rejected, and you will not get an error
|
|
556
|
+
telling you why it vanished.
|
|
545
557
|
|
|
546
558
|
Four headers arrive or leave on it, and the stripping is what makes them worth trusting:
|
|
547
559
|
|
|
@@ -549,13 +561,13 @@ Four headers arrive or leave on it, and the stripping is what makes them worth t
|
|
|
549
561
|
| --- | --- | --- |
|
|
550
562
|
| `x-wawesome-forwarded-prefix` | inbound | The mount that was stripped from the path. Join it to the path you observe to rebuild the caller's URL. |
|
|
551
563
|
| `x-wawesome-trigger` | inbound | How this run started: `caller` when someone called your address, `schedule` when fired by a Schedule. A caller cannot forge it in production (stripped inbound). On the local development surface, pass `x-wawesome-trigger: schedule` to exercise a background run by hand with the collapsed budget. |
|
|
552
|
-
| `x-wawesome-invocation-id` | outbound | The id of this run
|
|
553
|
-
| `x-wawesome-error` | outbound | Present only when the platform failed, never when your Function did. Its *absence* means the status on the wire is yours
|
|
564
|
+
| `x-wawesome-invocation-id` | outbound | The id of this run, the key to fetch its logs with `npx wawesome logs --invocation <id>`. |
|
|
565
|
+
| `x-wawesome-error` | outbound | Present only when the platform failed, never when your Function did. Its *absence* means the status on the wire is yours, up to the moment your response is committed and no further. |
|
|
554
566
|
|
|
555
567
|
### Testing against the guest's JavaScript surface
|
|
556
568
|
|
|
557
569
|
Your Function does not run on Node. The engine has no `Intl`, and its `toLocaleString` ignores the
|
|
558
|
-
locale you pass
|
|
570
|
+
locale you pass. `(1234.5).toLocaleString('en-US')` comes back as `"1234.5"`, not `"1,234.50"`. On
|
|
559
571
|
Node both work, which is how a green suite ships a Function that throws in production, or renders
|
|
560
572
|
markup the browser then refuses to hydrate.
|
|
561
573
|
|
|
@@ -572,19 +584,19 @@ export default defineConfig({
|
|
|
572
584
|
|
|
573
585
|
Templates scaffolded with `wawesome init --template` ship this already. With it in place `Intl` is
|
|
574
586
|
gone, `MessageChannel` is the platform's own implementation rather than Node's, and the
|
|
575
|
-
locale-sensitive methods throw with a message naming the remedy
|
|
587
|
+
locale-sensitive methods throw with a message naming the remedy. They throw rather than return the
|
|
576
588
|
engine's unlocalised answer because the platform declares them unsupported, and a wrong string that
|
|
577
589
|
fails nowhere is the thing this is here to stop you shipping.
|
|
578
590
|
|
|
579
|
-
If you bundle an `Intl` polyfill, declare it in your `package.json` as you normally would
|
|
591
|
+
If you bundle an `Intl` polyfill, declare it in your `package.json` as you normally would. A
|
|
580
592
|
dependency that provides `Intl` is left in place rather than stripped out from under you.
|
|
581
593
|
|
|
582
|
-
### Local
|
|
594
|
+
### Local development and gateway overrides
|
|
583
595
|
|
|
584
596
|
If you are running a local gateway or self-hosted instance, you can configure your CLI Gateway URL using any of the
|
|
585
597
|
following:
|
|
586
598
|
|
|
587
|
-
#### 1. Custom
|
|
599
|
+
#### 1. Custom settings (`~/.wawesome/settings.json`)
|
|
588
600
|
|
|
589
601
|
Create `~/.wawesome/settings.json`:
|
|
590
602
|
|
|
@@ -594,13 +606,13 @@ Create `~/.wawesome/settings.json`:
|
|
|
594
606
|
}
|
|
595
607
|
```
|
|
596
608
|
|
|
597
|
-
#### 2. Environment
|
|
609
|
+
#### 2. Environment variables
|
|
598
610
|
|
|
599
611
|
```bash
|
|
600
612
|
export WAWESOME_GATEWAY_URL="http://localhost:3000"
|
|
601
613
|
```
|
|
602
614
|
|
|
603
|
-
#### 3. CLI
|
|
615
|
+
#### 3. CLI flag
|
|
604
616
|
|
|
605
617
|
```bash
|
|
606
618
|
npx wawesome login --gateway http://localhost:3000
|
|
@@ -613,10 +625,10 @@ gateway along with the credentials.
|
|
|
613
625
|
|
|
614
626
|
---
|
|
615
627
|
|
|
616
|
-
##
|
|
628
|
+
## Deploying from CI
|
|
617
629
|
|
|
618
630
|
A **deploy credential** is what deploys without a person at a keyboard. Your workspace mints one, and the CLI reads it
|
|
619
|
-
from a single environment variable
|
|
631
|
+
from a single environment variable. There is no login, and no credentials file is involved at any point:
|
|
620
632
|
|
|
621
633
|
```bash
|
|
622
634
|
export WAWESOME_DEPLOY_CREDENTIAL="wawe_..."
|
|
@@ -633,8 +645,8 @@ While it is set:
|
|
|
633
645
|
- it wins over any `~/.wawesome/credentials.json` on the machine, so a runner with a stale cached home directory still
|
|
634
646
|
deploys as the credential rather than as whoever last logged in there;
|
|
635
647
|
- nothing is written to disk, and the secret stays in the environment where you put it;
|
|
636
|
-
- a refusal
|
|
637
|
-
command needs
|
|
648
|
+
- a refusal names which of four things happened: the credential is unknown, revoked, expired, or does not carry what
|
|
649
|
+
the command needs. It does not ask you to sign in again, which a pipeline cannot do;
|
|
638
650
|
- `login` and `logout` refuse, because neither would change what the next command authenticates as;
|
|
639
651
|
- `credentials` is refused by the platform, because minting, listing and revoking are closed to
|
|
640
652
|
credentials whatever they carry;
|
|
@@ -642,7 +654,7 @@ While it is set:
|
|
|
642
654
|
|
|
643
655
|
---
|
|
644
656
|
|
|
645
|
-
##
|
|
657
|
+
## Security and secrets
|
|
646
658
|
|
|
647
659
|
Wawesome encrypts environment variables at rest using two-tier envelope encryption (AES-256-GCM with per-app data keys
|
|
648
660
|
and AAD context binding). Use `--secret` when setting sensitive keys:
|
|
@@ -653,7 +665,7 @@ npx wawesome env set STRIPE_SECRET_KEY sk_live_xxx --secret
|
|
|
653
665
|
|
|
654
666
|
---
|
|
655
667
|
|
|
656
|
-
##
|
|
668
|
+
## Resources and support
|
|
657
669
|
|
|
658
670
|
- **Platform Homepage**: [https://wawesome.io](https://wawesome.io)
|
|
659
671
|
- **Documentation**: [https://docs.wawesome.io](https://docs.wawesome.io)
|
package/dist/index.mjs
CHANGED
|
@@ -331,10 +331,10 @@ function decodeVlq(encoded) {
|
|
|
331
331
|
//#endregion
|
|
332
332
|
//#region src/guest-surface-scan.ts
|
|
333
333
|
const MAX_LOCATIONS = 3;
|
|
334
|
-
const ABSENT_PROBLEM = "
|
|
335
|
-
const METHOD_PROBLEM = "
|
|
336
|
-
const GUARDED_PROBLEM = "
|
|
337
|
-
const DEFERRED_PROBLEM = "
|
|
334
|
+
const ABSENT_PROBLEM = "The guest does not define it, so evaluating this reference throws a ReferenceError.";
|
|
335
|
+
const METHOD_PROBLEM = "The guest carries no ICU, so it ignores the locale argument.";
|
|
336
|
+
const GUARDED_PROBLEM = "The guest does not define it. This bundle guards the reference, so what runs is the path it takes when the global is missing.";
|
|
337
|
+
const DEFERRED_PROBLEM = "The guest does not define it. The code holding this reference throws a ReferenceError if it ever runs.";
|
|
338
338
|
const GLOBAL_OBJECTS = /* @__PURE__ */ new Set([
|
|
339
339
|
"globalThis",
|
|
340
340
|
"window",
|
|
@@ -472,7 +472,7 @@ function surfaceReportLines(findings) {
|
|
|
472
472
|
const lines = [];
|
|
473
473
|
for (const finding of findings) {
|
|
474
474
|
const headline = finding.severity === "refuse" ? "Refusing to deploy" : "Warning";
|
|
475
|
-
lines.push(`[wawesome] ${headline}: \`${finding.name}
|
|
475
|
+
lines.push(`[wawesome] ${headline}: \`${finding.name}\`. ${finding.problem}`);
|
|
476
476
|
for (const location of finding.locations) lines.push(`[wawesome] at ${location.file}:${location.line}:${location.column}`);
|
|
477
477
|
if (finding.undisplayedLocations > 0) lines.push(`[wawesome] and ${finding.undisplayedLocations} more reference${finding.undisplayedLocations === 1 ? "" : "s"}`);
|
|
478
478
|
lines.push(`[wawesome] Remedy: ${finding.remedy}`);
|
|
@@ -883,7 +883,7 @@ async function buildJs(entryInput, options) {
|
|
|
883
883
|
* that has to name this version — `--version`, the dependency a scaffolded
|
|
884
884
|
* project pins — reads it here, so a release bumps one file.
|
|
885
885
|
*/
|
|
886
|
-
const CLI_VERSION = "0.
|
|
886
|
+
const CLI_VERSION = "0.11.0";
|
|
887
887
|
//#endregion
|
|
888
888
|
//#region src/prompt.ts
|
|
889
889
|
/**
|
|
@@ -1158,7 +1158,7 @@ async function promptForWorkspaceName(options) {
|
|
|
1158
1158
|
const supplied = options.workspace?.trim();
|
|
1159
1159
|
if (supplied) return supplied;
|
|
1160
1160
|
if (!isInteractive()) throw new Error("No workspace found, and no name to create one with. Re-run with --workspace <name>.");
|
|
1161
|
-
console.log("\n[wawesome] You don't have a workspace yet
|
|
1161
|
+
console.log("\n[wawesome] You don't have a workspace yet. Let's create one.");
|
|
1162
1162
|
console.log(" (this is the name you'll see in the dashboard; its public address is set separately)");
|
|
1163
1163
|
const session = openPromptSession();
|
|
1164
1164
|
try {
|
|
@@ -1454,11 +1454,11 @@ async function reportCredential(creds) {
|
|
|
1454
1454
|
function whenItRuns(schedule) {
|
|
1455
1455
|
const undeclared = schedule.declared === false;
|
|
1456
1456
|
if (schedule.state === "suspended") {
|
|
1457
|
-
const why = "
|
|
1458
|
-
return undeclared ? `suspended, and not in this config file
|
|
1457
|
+
const why = "The workspace owes payment, its subscription ended, or it has spent past its plan's allowance";
|
|
1458
|
+
return undeclared ? `suspended, and not in this config file. ${why}; declare it again too` : `suspended. ${why}`;
|
|
1459
1459
|
}
|
|
1460
|
-
if (schedule.state === "paused") return undeclared ? "paused, and not in this config file
|
|
1461
|
-
if (undeclared) return "not in this config file
|
|
1460
|
+
if (schedule.state === "paused") return undeclared ? "paused, and not in this config file. Declare it again, then resume" : "paused. Resume it to run again";
|
|
1461
|
+
if (undeclared) return "not in this config file, so it is disabled. Its history is kept";
|
|
1462
1462
|
if (schedule.state !== "active") return schedule.state;
|
|
1463
1463
|
return schedule.next_fire_at ? `next run ${asUtc$1(schedule.next_fire_at)}` : "next run unknown";
|
|
1464
1464
|
}
|
|
@@ -1553,11 +1553,33 @@ async function applyDeclaredDomain(creds, app, hostname) {
|
|
|
1553
1553
|
kind: "refused",
|
|
1554
1554
|
hostname,
|
|
1555
1555
|
said: whatWentWrong(err),
|
|
1556
|
-
advice: planLimitAdvice(refusal?.reason)
|
|
1556
|
+
advice: planLimitAdvice(refusal?.reason),
|
|
1557
|
+
held: held.find((domain) => !domain.detaching)?.hostname
|
|
1557
1558
|
};
|
|
1558
1559
|
}
|
|
1559
1560
|
}
|
|
1560
1561
|
/**
|
|
1562
|
+
* What the App carries that its configuration does not, for a deploy that
|
|
1563
|
+
* declares no domain at all.
|
|
1564
|
+
*
|
|
1565
|
+
* Reports and never acts. A read that fails says nothing rather than guessing:
|
|
1566
|
+
* a project with no domain in its file has nothing to be told about one, and a
|
|
1567
|
+
* false alarm here is one about a client's site that is up.
|
|
1568
|
+
*/
|
|
1569
|
+
async function findUndeclaredDomain(creds, app) {
|
|
1570
|
+
let held;
|
|
1571
|
+
try {
|
|
1572
|
+
held = await listDomains(creds, app);
|
|
1573
|
+
} catch {
|
|
1574
|
+
return null;
|
|
1575
|
+
}
|
|
1576
|
+
const domain = held.find((candidate) => !candidate.detaching);
|
|
1577
|
+
return domain ? {
|
|
1578
|
+
kind: "undeclared",
|
|
1579
|
+
domain
|
|
1580
|
+
} : null;
|
|
1581
|
+
}
|
|
1582
|
+
/**
|
|
1561
1583
|
* The platform's own words where it has any. A credential refusal is read
|
|
1562
1584
|
* through the same reading every other command gives one, so a CI runner is
|
|
1563
1585
|
* told what its credential lacks rather than to sign in again.
|
|
@@ -1597,6 +1619,62 @@ async function attachDomain(creds, app, hostname) {
|
|
|
1597
1619
|
const { domain } = await res.json();
|
|
1598
1620
|
return domain;
|
|
1599
1621
|
}
|
|
1622
|
+
/**
|
|
1623
|
+
* Take a domain off the App, naming it. The name is the route's requirement and
|
|
1624
|
+
* ADR-0025's argument, not this function's.
|
|
1625
|
+
*/
|
|
1626
|
+
async function detachDomain(creds, app, hostname) {
|
|
1627
|
+
const res = await authorizedFetch(`${domainsUrl(creds, app)}/${encodeURIComponent(hostname)}`, {
|
|
1628
|
+
method: "DELETE",
|
|
1629
|
+
headers: { Authorization: `Bearer ${creds.tenant_jwt}` }
|
|
1630
|
+
});
|
|
1631
|
+
if (!res.ok) throw await asGatewayError(res, `'${hostname}' could not be detached (HTTP ${res.status}).`);
|
|
1632
|
+
}
|
|
1633
|
+
/** A missing name is refused here rather than sent, so the reason reads at the keyboard. */
|
|
1634
|
+
async function detachDomainCommand(hostname, options = {}) {
|
|
1635
|
+
if (!hostname || !hostname.trim()) {
|
|
1636
|
+
console.error("[wawesome] Error: Missing domain. Usage: wawesome domains detach <hostname>");
|
|
1637
|
+
console.error("[wawesome] The domain is typed out because detaching one takes it dark.");
|
|
1638
|
+
process.exit(1);
|
|
1639
|
+
}
|
|
1640
|
+
const creds = readCredentials();
|
|
1641
|
+
if (!creds) {
|
|
1642
|
+
console.error("[wawesome] Error: Not logged in. Run 'wawesome login' first.");
|
|
1643
|
+
process.exit(1);
|
|
1644
|
+
}
|
|
1645
|
+
const app = options.app?.trim() || readFunctionConfig()?.app?.trim();
|
|
1646
|
+
if (!app) {
|
|
1647
|
+
console.error("[wawesome] Error: No wawesome-function.json found in the current directory.");
|
|
1648
|
+
console.error("[wawesome] Run this from your project, or name the app with --app <slug>.");
|
|
1649
|
+
process.exit(1);
|
|
1650
|
+
}
|
|
1651
|
+
const name = hostname.trim();
|
|
1652
|
+
console.log(`[wawesome] Detaching '${name}' from app '${app}':`);
|
|
1653
|
+
console.log("[wawesome] • the domain stops resolving here, so anything pointed at it stops");
|
|
1654
|
+
console.log("[wawesome] reaching this app");
|
|
1655
|
+
console.log("[wawesome] • this app's own address is unaffected and keeps serving");
|
|
1656
|
+
console.log("[wawesome] • the certificate is given back, and none is held for the name");
|
|
1657
|
+
try {
|
|
1658
|
+
await detachDomain(creds, app, name);
|
|
1659
|
+
} catch (err) {
|
|
1660
|
+
console.error(`[wawesome] Error: ${whatWentWrong(err)}`);
|
|
1661
|
+
process.exit(1);
|
|
1662
|
+
}
|
|
1663
|
+
console.log(`[wawesome] ✅ Detached '${name}' from app '${app}'.`);
|
|
1664
|
+
console.log("[wawesome] The domain is free to attach again by declaring it and deploying.");
|
|
1665
|
+
const declared = readFunctionConfig()?.domain;
|
|
1666
|
+
if (typeof declared === "string" && isSameHostname(declared, name)) {
|
|
1667
|
+
console.log(`[wawesome] wawesome-function.json still declares '${declared}'. Remove the line,`);
|
|
1668
|
+
console.log("[wawesome] or the next deploy attaches the domain again.");
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
async function domainsCommand(action, target, options = {}) {
|
|
1672
|
+
if ((action || "").toLowerCase().trim() === "detach") return detachDomainCommand(target, options);
|
|
1673
|
+
console.error(`[wawesome] Error: Unknown command '${["domains", action].filter(Boolean).join(" ")}'.`);
|
|
1674
|
+
console.error("[wawesome] Usage: wawesome domains detach <hostname>");
|
|
1675
|
+
console.error("[wawesome] A domain is attached by declaring it in wawesome-function.json.");
|
|
1676
|
+
process.exit(1);
|
|
1677
|
+
}
|
|
1600
1678
|
function domainsUrl(creds, app) {
|
|
1601
1679
|
return `${creds.gateway_url}/v1/apps/${encodeURIComponent(app)}/domains`;
|
|
1602
1680
|
}
|
|
@@ -1625,19 +1703,37 @@ const VALUE_COLUMN = " ".repeat(14);
|
|
|
1625
1703
|
function domainLines(outcome) {
|
|
1626
1704
|
if (outcome.kind === "unread") return [
|
|
1627
1705
|
"",
|
|
1628
|
-
` Domain: \x1b[33m${outcome.hostname}
|
|
1706
|
+
` Domain: \x1b[33m${outcome.hostname}: where it got to is unknown\x1b[0m`,
|
|
1629
1707
|
...wrapped(outcome.said).map((line) => `${VALUE_COLUMN}${line}`),
|
|
1630
1708
|
`${VALUE_COLUMN}Nothing about the domain changed, and the deploy landed.`
|
|
1631
1709
|
];
|
|
1710
|
+
if (outcome.kind === "undeclared") {
|
|
1711
|
+
const { hostname, state } = outcome.domain;
|
|
1712
|
+
const left = state.serving ? "it is still serving" : "nothing changed";
|
|
1713
|
+
return [
|
|
1714
|
+
"",
|
|
1715
|
+
` Domain: \x1b[33m${hostname}: attached, and this project declares no domain\x1b[0m`,
|
|
1716
|
+
...wrapped(`Nothing was detached and ${left}. A domain comes off an App when somebody names it, never because a line was deleted. Declare it again in wawesome-function.json, or take it off with`).map((line) => `${VALUE_COLUMN}${line}`),
|
|
1717
|
+
`${VALUE_COLUMN} \x1b[36mwawesome domains detach ${hostname}\x1b[0m`
|
|
1718
|
+
];
|
|
1719
|
+
}
|
|
1632
1720
|
if (outcome.kind === "refused") return [
|
|
1633
1721
|
"",
|
|
1634
|
-
` Domain: \x1b[33m${outcome.hostname}
|
|
1722
|
+
` Domain: \x1b[33m${outcome.hostname}: not attached\x1b[0m`,
|
|
1635
1723
|
...wrapped(outcome.said).map((line) => `${VALUE_COLUMN}${line}`),
|
|
1636
1724
|
...outcome.advice ? [`${VALUE_COLUMN}${outcome.advice}`] : [],
|
|
1725
|
+
...outcome.held ? [`${VALUE_COLUMN}Nothing was detached. Take '${outcome.held}' off first with`, `${VALUE_COLUMN} \x1b[36mwawesome domains detach ${outcome.held}\x1b[0m`] : [],
|
|
1637
1726
|
`${VALUE_COLUMN}The deploy landed, and this App's other address still answers.`
|
|
1638
1727
|
];
|
|
1639
|
-
const { hostname, records, state, last_checked_at } = outcome.domain;
|
|
1640
|
-
|
|
1728
|
+
const { hostname, records, state, last_checked_at, detaching } = outcome.domain;
|
|
1729
|
+
if (detaching) return [
|
|
1730
|
+
"",
|
|
1731
|
+
` Domain: \x1b[33m${hostname}: being detached\x1b[0m`,
|
|
1732
|
+
`${VALUE_COLUMN}It has stopped answering, and the certificate is being given back.`,
|
|
1733
|
+
`${VALUE_COLUMN}Remove 'domain' from wawesome-function.json, or deploy again`,
|
|
1734
|
+
`${VALUE_COLUMN}once it is gone to attach it afresh.`
|
|
1735
|
+
];
|
|
1736
|
+
const lines = ["", ` Domain: \x1b[36m${hostname}\x1b[0m: ${whereItGotTo(state)}`];
|
|
1641
1737
|
if (state.serving) {
|
|
1642
1738
|
lines.push(`${VALUE_COLUMN}The address above answers too, so nothing pointed at it breaks.`);
|
|
1643
1739
|
return lines;
|
|
@@ -1738,7 +1834,7 @@ const MONTHS = [
|
|
|
1738
1834
|
];
|
|
1739
1835
|
/** Indented to sit inside the receipt the deploy already prints. */
|
|
1740
1836
|
function headroomLines(usage) {
|
|
1741
|
-
const lines = [` Plan: ${usage.plan.name}
|
|
1837
|
+
const lines = [` Plan: ${usage.plan.name}. This deploy does not change your bill.`, ` Apps: ${usage.occupied_app_slots} / ${usage.plan.limits.app_slots} slots`];
|
|
1742
1838
|
const stored = storedLine(usage);
|
|
1743
1839
|
if (stored !== null) lines.push(stored);
|
|
1744
1840
|
lines.push(` Usage: ${periodLabel(usage.period.start, usage.period.end)}`);
|
|
@@ -2020,8 +2116,8 @@ function divergenceLines(previous, target, addresses) {
|
|
|
2020
2116
|
`[wawesome] wawesome-function.json now says ${qualifiedName(target)}.`,
|
|
2021
2117
|
"",
|
|
2022
2118
|
"[wawesome] Deploying will not rename it. A Function's address is built from its",
|
|
2023
|
-
"[wawesome] name, so this deploy lands on a Function of its own
|
|
2024
|
-
"[wawesome]
|
|
2119
|
+
"[wawesome] name, so this deploy lands on a Function of its own. The old one stays",
|
|
2120
|
+
"[wawesome] promoted, and still answers the code on it:",
|
|
2025
2121
|
"",
|
|
2026
2122
|
`[wawesome] stays live: ${addresses.previous ?? qualifiedName(previous)}`,
|
|
2027
2123
|
`[wawesome] gets this deploy: ${addresses.next ?? qualifiedName(target)}`,
|
|
@@ -2075,7 +2171,7 @@ function declaredVisibility(value) {
|
|
|
2075
2171
|
function reportPublishRefusal(message) {
|
|
2076
2172
|
console.error(`\n[wawesome] \x1b[31mError: ${message}\x1b[0m`);
|
|
2077
2173
|
console.error("[wawesome] Nothing was deployed. This Function is private, so its address");
|
|
2078
|
-
console.error("[wawesome] resolves for nobody
|
|
2174
|
+
console.error("[wawesome] resolves for nobody. Publishing it puts it back on the open");
|
|
2079
2175
|
console.error("[wawesome] internet.");
|
|
2080
2176
|
console.error("[wawesome] Re-run with \x1B[36mwawesome deploy --publish\x1B[0m to publish it, or put");
|
|
2081
2177
|
console.error("[wawesome] \x1B[36m\"visibility\": \"private\"\x1B[0m back in wawesome-function.json.\n");
|
|
@@ -2236,7 +2332,7 @@ async function deploy(entryInput, options) {
|
|
|
2236
2332
|
} catch (err) {
|
|
2237
2333
|
if (isVerbose) console.log(`[wawesome:verbose] Could not resolve the workspace address: ${err instanceof Error ? err.message : err}`);
|
|
2238
2334
|
}
|
|
2239
|
-
const domain = domainName ? await applyDeclaredDomain(creds, app, domainName) :
|
|
2335
|
+
const domain = domainName ? await applyDeclaredDomain(creds, app, domainName) : await findUndeclaredDomain(creds, app);
|
|
2240
2336
|
let headroom = null;
|
|
2241
2337
|
try {
|
|
2242
2338
|
headroom = headroomLines(await fetchTenantUsage(creds));
|
|
@@ -2256,13 +2352,13 @@ async function deploy(entryInput, options) {
|
|
|
2256
2352
|
for (const line of scheduleLines(schedules)) console.log(line);
|
|
2257
2353
|
}
|
|
2258
2354
|
if (visibility === "private") {
|
|
2259
|
-
console.log("\n URL: none
|
|
2355
|
+
console.log("\n URL: none. This Function is private, so it is not reachable");
|
|
2260
2356
|
console.log(" from the web at all.");
|
|
2261
2357
|
} else if (address) {
|
|
2262
2358
|
console.log(`\n URL: \x1b[36m${address}\x1b[0m`);
|
|
2263
2359
|
console.log(` ${SUBTREE_NOTE}`);
|
|
2264
2360
|
} else if (surface) {
|
|
2265
|
-
console.log("\n URL: none
|
|
2361
|
+
console.log("\n URL: none. This gateway serves no public address form.");
|
|
2266
2362
|
console.log(" Set CONTENT_ORIGIN on it, or ALLOW_PATH_INVOCATION_FORM");
|
|
2267
2363
|
console.log(" for local development.");
|
|
2268
2364
|
}
|
|
@@ -2358,8 +2454,8 @@ async function uploadAssets(creds, app, funcName, bundle, assets, declared, isVe
|
|
|
2358
2454
|
//#region src/env.ts
|
|
2359
2455
|
const STANDARD_SECRET_MESSAGES = [
|
|
2360
2456
|
"Encrypted at rest using AES-256",
|
|
2361
|
-
"This value can't be viewed again after you save it
|
|
2362
|
-
"Only decrypted at the moment your function runs
|
|
2457
|
+
"This value can't be viewed again after you save it, only updated or deleted",
|
|
2458
|
+
"Only decrypted at the moment your function runs, and never returned by the CLI, dashboard, or API after creation."
|
|
2363
2459
|
];
|
|
2364
2460
|
/**
|
|
2365
2461
|
* Load credentials and validate project config.
|
|
@@ -3048,7 +3144,7 @@ async function listTemplates(options) {
|
|
|
3048
3144
|
}
|
|
3049
3145
|
console.log("\n📦 \x1B[1mTemplates\x1B[0m\n");
|
|
3050
3146
|
for (const template of templates) {
|
|
3051
|
-
console.log(` \x1b[36m${template.name}\x1b[0m
|
|
3147
|
+
console.log(` \x1b[36m${template.name}\x1b[0m: ${template.title}`);
|
|
3052
3148
|
console.log(` ${template.description}`);
|
|
3053
3149
|
if (template.tags.length > 0) console.log(` \x1b[90m${template.tags.join(", ")}\x1b[0m`);
|
|
3054
3150
|
console.log(` \x1b[90m${template.source_url}\x1b[0m`);
|
|
@@ -3170,7 +3266,7 @@ async function ensureSession(options) {
|
|
|
3170
3266
|
const probed = await probeSession(stored);
|
|
3171
3267
|
if (probed) return probed;
|
|
3172
3268
|
}
|
|
3173
|
-
console.log(stored ? "\n[wawesome] Your session has expired." : "\n[wawesome] You're not logged in yet
|
|
3269
|
+
console.log(stored ? "\n[wawesome] Your session has expired." : "\n[wawesome] You're not logged in yet, which is what a deploy needs.");
|
|
3174
3270
|
if (!isInteractive()) {
|
|
3175
3271
|
console.log("[wawesome] Run 'wawesome login', then 'wawesome deploy'.");
|
|
3176
3272
|
return null;
|
|
@@ -3234,12 +3330,12 @@ async function offerWorkspaceAddress(session, creds, tenant, appSlug, functionNa
|
|
|
3234
3330
|
return;
|
|
3235
3331
|
}
|
|
3236
3332
|
if (tenant.slug_locked) {
|
|
3237
|
-
console.log(` 🔒 '${current}' is fixed
|
|
3333
|
+
console.log(` 🔒 '${current}' is fixed. A Function version has been promoted, and live URLs already carry it.\n`);
|
|
3238
3334
|
return;
|
|
3239
3335
|
}
|
|
3240
|
-
console.log(` '${current}' is your workspace address
|
|
3241
|
-
console.log(" rather than this project's
|
|
3242
|
-
console.log(" for good the first time you deploy, because live URLs carry it.");
|
|
3336
|
+
console.log(` '${current}' is your workspace address, the part of that URL that is`);
|
|
3337
|
+
console.log(" yours rather than this project's. Now is the moment to change it. It");
|
|
3338
|
+
console.log(" locks for good the first time you deploy, because live URLs carry it.");
|
|
3243
3339
|
console.log(" Press enter to keep it.\n");
|
|
3244
3340
|
let refusal;
|
|
3245
3341
|
for (let attempt = 0; attempt < MAX_RENAME_ATTEMPTS; attempt++) {
|
|
@@ -3271,7 +3367,7 @@ async function offerWorkspaceAddress(session, creds, tenant, appSlug, functionNa
|
|
|
3271
3367
|
* template from needing a CLI release.
|
|
3272
3368
|
*/
|
|
3273
3369
|
async function wireUp(creds, appSlug, manifest, answers) {
|
|
3274
|
-
const scaffolded = "Your project is scaffolded
|
|
3370
|
+
const scaffolded = "Your project is scaffolded. Fix this, then run 'wawesome deploy'.";
|
|
3275
3371
|
try {
|
|
3276
3372
|
await ensureApp(creds, appSlug);
|
|
3277
3373
|
} catch (err) {
|
|
@@ -3354,7 +3450,7 @@ async function initFromTemplate(templateName, options) {
|
|
|
3354
3450
|
const session = openPromptSession();
|
|
3355
3451
|
try {
|
|
3356
3452
|
functionName = await promptForSlug(session, "Function name", readFunctionConfig(staging)?.function || dirName);
|
|
3357
|
-
console.log(" (an App groups the Functions of one project
|
|
3453
|
+
console.log(" (an App groups the Functions of one project, and its slug is part of the public URL)");
|
|
3358
3454
|
appSlug = await promptForSlug(session, "App slug", dirName);
|
|
3359
3455
|
let repinned = null;
|
|
3360
3456
|
try {
|
|
@@ -3368,7 +3464,7 @@ async function initFromTemplate(templateName, options) {
|
|
|
3368
3464
|
fail$1(errorText(err), `Some of '${template.name}' may have been written to ${cwd}.`);
|
|
3369
3465
|
}
|
|
3370
3466
|
console.log(`\n[wawesome] ✅ Scaffolded ${files.length} files from '${template.name}'.`);
|
|
3371
|
-
if (repinned) console.log(`[wawesome] Using wawesome ${repinned.to}
|
|
3467
|
+
if (repinned) console.log(`[wawesome] Using wawesome ${repinned.to}. The template pinned ${repinned.from}.`);
|
|
3372
3468
|
if (tenantSession) await offerWorkspaceAddress(session, tenantSession.creds, tenantSession.tenant, appSlug, functionName);
|
|
3373
3469
|
answers = tenantSession ? await promptForDeclaredEnv(session, manifest.env) : [];
|
|
3374
3470
|
} finally {
|
|
@@ -3417,7 +3513,7 @@ async function init(options) {
|
|
|
3417
3513
|
functionName = "root";
|
|
3418
3514
|
console.log(" Function name? root (locked by --root)");
|
|
3419
3515
|
} else functionName = await promptForSlug(session, "Function name", dirName);
|
|
3420
|
-
console.log(" (an App groups the Functions of one project
|
|
3516
|
+
console.log(" (an App groups the Functions of one project, and its slug is part of the public URL)");
|
|
3421
3517
|
appSlug = await promptForSlug(session, "App slug", dirName);
|
|
3422
3518
|
} finally {
|
|
3423
3519
|
session.close();
|
|
@@ -4424,7 +4520,7 @@ async function showWorkspace(options) {
|
|
|
4424
4520
|
console.log(` ${SUBTREE_NOTE}`);
|
|
4425
4521
|
}
|
|
4426
4522
|
}
|
|
4427
|
-
if (tenant.slug_locked) console.log("\n 🔒 The address is fixed
|
|
4523
|
+
if (tenant.slug_locked) console.log("\n 🔒 The address is fixed. A Function version has been promoted, and live URLs carry it.");
|
|
4428
4524
|
else {
|
|
4429
4525
|
console.log("\n The address can still be changed: \x1B[36mwawesome workspace rename <name>\x1B[0m");
|
|
4430
4526
|
console.log(" It locks for good the first time you deploy.");
|
|
@@ -5196,6 +5292,8 @@ cli.command("env [action] [key] [value]", "Manage environment variables (set, li
|
|
|
5196
5292
|
cli.command("env set <key> <value>", "Set or overwrite an environment variable on the current app").option("-s, --secret", "Flag variable as secret (write-only)").option("-v, --verbose", "Enable verbose debug output").action((key, value, options) => setEnvVar(key, value, options));
|
|
5197
5293
|
cli.command("env list", "List environment variables for the current app").alias("env ls").option("-v, --verbose", "Enable verbose debug output").action((options) => listEnvVars(options));
|
|
5198
5294
|
cli.command("env rm <key>", "Delete an environment variable from the current app").alias("env remove").alias("env delete").alias("env unset").option("-v, --verbose", "Enable verbose debug output").action((key, options) => removeEnvVar(key, options));
|
|
5295
|
+
cli.command("domains [action] [hostname]", "Manage the custom domain on the current app (detach)").usage("domains <action> [hostname]\n\nActions:\n detach <hostname> Stop serving the app at a domain you attached\n\nA domain is attached by declaring it in wawesome-function.json and deploying.").example("wawesome domains detach shop.client.com").option("-a, --app <slug>", "App to act on (default: the app in wawesome-function.json)").action((action, hostname, options) => domainsCommand(action, hostname, options));
|
|
5296
|
+
cli.command("domains detach <hostname>", "Stop serving the current app at a domain you attached").option("-a, --app <slug>", "App to act on (default: the app in wawesome-function.json)").action((hostname, options) => detachDomainCommand(hostname, options));
|
|
5199
5297
|
cli.command("login", "Authenticate with the wawesome.io platform").option("--api <url>", "API URL (default: https://api.wawesome.io)").option("--gateway <url>", "Alias for --api <url>").option("--dashboard <url>", "Dashboard URL (default: https://dashboard.wawesome.io)").option("--provider <name>", "OAuth provider (default: github)").option("--workspace <name>", "Name for the workspace, when signing up without a terminal to prompt").option("--accept-terms", "Accept the terms of service and privacy policy, when signing up without a terminal to prompt").option("-v, --verbose", "Enable verbose debug output").action((options) => login(options));
|
|
5200
5298
|
cli.command("logout", "Clear stored authentication credentials").action(() => logout());
|
|
5201
5299
|
cli.command("whoami", "Show current login session info").action(() => whoami());
|
|
@@ -5221,30 +5319,30 @@ cli.command("credentials [action] [target]", "Mint, list and revoke deploy crede
|
|
|
5221
5319
|
wawesome credentials revoke ci-pipeline
|
|
5222
5320
|
wawesome credentials revoke wawe_ab3k9x --yes`).option("-c, --capability <capability>", "Capability to grant: deploy, logs:read (repeatable or comma-separated, default: deploy)").option("-a, --app <app>", "Restrict the credential to this App (repeatable or comma-separated, default: every App)").option("--expires <days|never>", "Days until the credential expires, or 'never' (default: 90)").option("-y, --yes", "Skip the revoke confirmation").option("-v, --verbose", "Enable verbose debug output").action((action, target, options) => credentialsCommand(action, target, options));
|
|
5223
5321
|
cli.command("credentials mint <name>", "Mint a deploy credential, printing its secret exactly once").option("-c, --capability <capability>", "Capability to grant: deploy, logs:read (repeatable or comma-separated)").option("-a, --app <app>", "Restrict the credential to this App (repeatable or comma-separated)").option("--expires <days|never>", "Days until the credential expires, or 'never' (default: 90)").option("-v, --verbose", "Enable verbose debug output").action((name, options) => mintCredentialCommand(name, options));
|
|
5224
|
-
cli.command("credentials list", "List deploy credentials
|
|
5322
|
+
cli.command("credentials list", "List deploy credentials, never their secrets").alias("credentials ls").option("-v, --verbose", "Enable verbose debug output").action((options) => listCredentialsCommand(options));
|
|
5225
5323
|
cli.command("credentials revoke <name-or-prefix>", "Revoke a deploy credential, immediately and for good").option("-y, --yes", "Revoke without being asked to confirm").option("-v, --verbose", "Enable verbose debug output").action((target, options) => revokeCredentialCommand(target, options));
|
|
5226
5324
|
cli.command("init", "Scaffold a new function project in the current directory").usage("init [options]\n\nWith --template, the project is fetched from the template catalog, wired up\nfrom what the template declares it needs, and deployed. Run 'wawesome templates'\nto see what is available.").example("wawesome init").example("wawesome init --template stripe-webhook").option("-t, --template <name>", "Scaffold from a catalog template and deploy it").option("--api <url>", "API URL (default: https://api.wawesome.io)").option("--dashboard <url>", "Dashboard URL (default: https://dashboard.wawesome.io)").option("--no-install", "Skip installing dependencies after scaffolding").option("--root", "Generate a root function router template").option("-v, --verbose", "Enable verbose debug output").action((options) => init(options));
|
|
5227
5325
|
cli.command("logs [function-name-or-invocation-id]", "View invocation history, fetch log output, or follow live").usage(`logs [target] [options]
|
|
5228
5326
|
|
|
5229
5327
|
The target argument determines what the command does:
|
|
5230
5328
|
|
|
5231
|
-
MODE 1
|
|
5329
|
+
MODE 1: list invocations (no UUID target)
|
|
5232
5330
|
wawesome logs # list invocations for the function in the current directory
|
|
5233
5331
|
wawesome logs my-function # list invocations for 'my-function'
|
|
5234
5332
|
wawesome logs my-function --error # only show failed invocations
|
|
5235
5333
|
wawesome logs my-function --running # only show currently running invocations
|
|
5236
5334
|
|
|
5237
|
-
MODE 2
|
|
5335
|
+
MODE 2: fetch the captured log body (UUID target or --invocation)
|
|
5238
5336
|
wawesome logs <invocation-id> # print stdout/stderr for a specific invocation
|
|
5239
5337
|
wawesome logs my-function --invocation <id> # same, explicit flag form
|
|
5240
5338
|
|
|
5241
|
-
MODE 3
|
|
5339
|
+
MODE 3: follow live output (--follow / -f)
|
|
5242
5340
|
wawesome logs my-function --follow # follow the function: stream output from every invocation as it runs
|
|
5243
5341
|
wawesome logs <invocation-id> --follow # follow one specific in-flight invocation by ID
|
|
5244
5342
|
|
|
5245
|
-
With a function name, --follow streams the function's output
|
|
5246
|
-
|
|
5247
|
-
specific
|
|
5343
|
+
With a function name, --follow streams the function's output across invocations.
|
|
5344
|
+
New output appears each time the function runs, so you never have to catch a
|
|
5345
|
+
specific one. Press Ctrl-C to stop at any time.`).option("-f, --follow", "Stream live output (tail -f style). Follows a running invocation or waits for the next one. Ctrl-C to stop").option("-i, --invocation <id>", "Fetch stdout/stderr log body for a specific invocation ID").option("-a, --app <app>", "App slug override (defaults to wawesome-function.json)").option("-s, --status <status>", "Filter invocations by status (success, error, timeout, running)").option("--success", "Shorthand for --status success").option("--error", "Shorthand for --status error").option("--timeout", "Shorthand for --status timeout").option("--running", "Shorthand for --status running").option("-v, --verbose", "Enable verbose debug output").action((target, options) => logsCommand(target, options));
|
|
5248
5346
|
cli.command("invoke [function]", "Fire a background run of a serverless function").usage(`invoke [function] [options]
|
|
5249
5347
|
|
|
5250
5348
|
Fire a Function run now through the authenticated API, without deploying anything
|