@runeditrun/rer 0.2.19 → 0.2.21
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 +7 -7
- package/cli/README.md +22 -21
- package/cli/adapter.mjs +5 -0
- package/cli/container.mjs +7 -2
- package/cli/contract.mjs +3 -4
- package/cli/delivery-declarations.mjs +36 -0
- package/cli/demo-host.mjs +6 -5
- package/cli/demo-removal-provider.mjs +24 -0
- package/cli/demo.mjs +16 -5
- package/cli/deploy-command.mjs +11 -5
- package/cli/deploy-hook.mjs +10 -14
- package/cli/deploy.mjs +4 -1
- package/cli/detached-server.mjs +2 -2
- package/cli/dev-identity.mjs +1 -1
- package/cli/export.mjs +1 -1
- package/cli/inspect.mjs +13 -13
- package/cli/lifecycle.mjs +16 -49
- package/cli/listen.mjs +31 -0
- package/cli/local.mjs +12 -18
- package/cli/main.mjs +5 -0
- package/cli/managed-server.mjs +26 -44
- package/cli/output.mjs +1 -1
- package/cli/parse.mjs +3 -3
- package/cli/port.mjs +20 -20
- package/cli/production-auth.mjs +38 -0
- package/cli/server-proxy.mjs +2 -6
- package/cli/server-registry.mjs +7 -2
- package/cli/setup-input.mjs +3 -0
- package/global/CHANGELOG.md +15 -0
- package/global/README.md +7 -7
- package/global/cli/install.mjs +4 -28
- package/global/cli/path-link.mjs +25 -21
- package/global/launch/dev.mjs +1 -1
- package/global/launch/facts.mjs +11 -14
- package/global/launch/failure.mjs +20 -0
- package/global/launch/render.mjs +2 -6
- package/global/launch/worker.mjs +3 -3
- package/global/main.mjs +1 -1
- package/modules/container/build.mjs +5 -3
- package/modules/container/demo-egress.mjs +35 -0
- package/modules/container/worker-engine.mjs +3 -3
- package/modules/d1-transport/index.d.mts +9 -0
- package/modules/d1-transport/index.mjs +124 -0
- package/modules/delivery-producer/bindings.mjs +140 -0
- package/modules/delivery-producer/declarations.mjs +49 -0
- package/modules/demo/README.md +34 -0
- package/modules/demo/effects.mjs +73 -0
- package/modules/demo/index.d.mts +15 -0
- package/modules/demo/index.mjs +63 -0
- package/modules/demo/label.d.mts +2 -0
- package/modules/demo/label.mjs +24 -0
- package/modules/demo/responses.mjs +26 -0
- package/modules/demo/sockets.mjs +13 -0
- package/modules/demo/vite.d.mts +2 -0
- package/modules/demo/vite.mjs +19 -0
- package/modules/demo-host/README.md +14 -1
- package/modules/demo-host/container.mjs +17 -11
- package/modules/demo-host/diagnostics.mjs +1 -0
- package/modules/demo-host/pages.mjs +1 -1
- package/modules/demo-host/placement.mjs +23 -0
- package/modules/demo-host/plan.mjs +1 -1
- package/modules/demo-host/startup.mjs +1 -1
- package/modules/demo-host/worker.mjs +2 -2
- package/modules/deploy-kit/README.md +12 -0
- package/modules/deploy-kit/health-request.mjs +7 -5
- package/modules/deploy-kit/owner.mjs +2 -2
- package/modules/deploy-kit/r2-objects.mjs +8 -5
- package/modules/job-queue/storage.mjs +4 -1
- package/modules/mail/README.md +19 -86
- package/modules/mail/src/core/validation.mjs +0 -1
- package/modules/mail/src/development/index.d.mts +1 -6
- package/modules/mail/src/development/index.mjs +3 -16
- package/modules/operator-auth/README.md +10 -9
- package/modules/operator-auth/csp.mjs +1 -2
- package/modules/operator-auth/dev/cli-session.mjs +32 -0
- package/modules/operator-auth/dev/index.mjs +18 -11
- package/modules/operator-auth/identity/email-link/index.mjs +3 -0
- package/modules/operator-auth/page.mjs +1 -1
- package/modules/operator-auth/signin/index.d.mts +1 -1
- package/modules/portability/README.md +6 -0
- package/modules/portability/catalogue.mjs +1 -1
- package/modules/portability/copies.mjs +17 -2
- package/modules/portability/index.mjs +2 -0
- package/modules/portability/storage.mjs +5 -1
- package/onboarding/README.md +8 -11
- package/onboarding/adapter-auth.mjs +6 -38
- package/onboarding/adapter-labels.mjs +1 -1
- package/onboarding/adapter.mjs +8 -11
- package/onboarding/app-fetch.mjs +1 -1
- package/onboarding/dependency-approval.mjs +5 -15
- package/onboarding/dev-identity.mjs +1 -1
- package/onboarding/operator-install.mjs +6 -7
- package/onboarding/operator-installer.mjs +5 -5
- package/onboarding/operator-prerequisites.mjs +4 -5
- package/onboarding/port-probe.mjs +38 -0
- package/onboarding/process-diagnostics.mjs +36 -20
- package/onboarding/server.mjs +1 -1
- package/onboarding/ui/app.js +1 -1
- package/operations/README.md +3 -0
- package/package.json +4 -2
- package/scripts/publish-check/public_hygiene.py +31 -10
- package/modules/mail/src/development/viewer-html.mjs +0 -42
- package/modules/mail/src/development/viewer.mjs +0 -72
- package/modules/operator-auth/dev/badge.mjs +0 -44
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ checkout always gets the behaviour it was built and tested with.
|
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Install `rer` with one of these commands:
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
12
|
npx -y @runeditrun/rer cli install # user install in ~/.local/share/rer, launcher ~/.local/bin/rer
|
|
@@ -23,9 +23,10 @@ the package's own `rer cli install`. A failed or refused download leaves the
|
|
|
23
23
|
version you had selected.
|
|
24
24
|
|
|
25
25
|
No installer edits shell profiles. The canonical launcher is `~/.local/bin/rer`.
|
|
26
|
-
|
|
27
|
-
existing
|
|
28
|
-
|
|
26
|
+
Installation creates that directory if needed and never writes into another
|
|
27
|
+
PATH directory. It names any existing `rer` elsewhere on PATH and leaves it
|
|
28
|
+
unchanged. If `~/.local/bin` is absent from PATH or another command shadows it,
|
|
29
|
+
it prints one activation line to run in the current shell:
|
|
29
30
|
`export PATH="$HOME/.local/bin:$PATH"` (with fish syntax for fish). The launcher runs `node` from
|
|
30
31
|
PATH, so a Node upgrade does not break it. A re-run with the same build changes
|
|
31
32
|
nothing; a different build is installed beside the current one, the previous one
|
|
@@ -99,7 +100,6 @@ RER_SIGNED_IN owner@cradle.test
|
|
|
99
100
|
RER_OPEN http://127.0.0.1:8787/__dev/key#...
|
|
100
101
|
```
|
|
101
102
|
|
|
102
|
-
or `RER_SIGN_IN <outbox>` for a seed that signs in through its development outbox.
|
|
103
103
|
A seed that declares a run site prints one more line after those,
|
|
104
104
|
`RER_SITE http://127.0.0.1:8788`: a local preview of its static run site (its
|
|
105
105
|
marketing homepage, `/run` and docs) on the first free port above the app's. It
|
|
@@ -262,7 +262,7 @@ line that still names it. A later refresh is a version bump:
|
|
|
262
262
|
| `@runeditrun/rer/modules/portability`, `/catalogue`, `/cli`, `/cli-options`, `/files`, `/format`, `/http`, `/import`, `/journal`, `/legacy-safety`, `/migration-history`, `/storage` | portability module | `scripts/base-cli/modules/portability/*.mjs` |
|
|
263
263
|
| `@runeditrun/rer/modules/release/export`, `/publication-scan`, `/source`, `/signature` | release export, publication scan and shared signature verifier | `scripts/base-cli/modules/release/*.mjs` |
|
|
264
264
|
| `@runeditrun/rer/modules/deploy-kit/owner`, `/owner-cli`, `/prepare`, `/provider` | deploy kit | `scripts/base-cli/modules/deploy-kit/*.mjs` |
|
|
265
|
-
| `@runeditrun/rer/modules/operator-auth`, `/dev`, `/dev
|
|
265
|
+
| `@runeditrun/rer/modules/operator-auth`, `/dev`, `/dev-admission`, `/accounts/native`, `/identity/email-link` | operator auth | `scripts/base-cli/modules/operator-auth/index.mjs`, `dev/index.mjs`, `dev-admission.mjs`, `accounts/native.mjs`, `identity/email-link/index.mjs` |
|
|
266
266
|
| `@runeditrun/rer/modules/erasure/fence` | erasure fence statements | `scripts/base-cli/modules/erasure/fence.mjs` |
|
|
267
267
|
| `@runeditrun/rer/modules/owner-claim`, `/modules/dependencies` | owner claim, dependency links | `scripts/base-cli/modules/owner-claim/index.mjs`, `dependencies/index.mjs` |
|
|
268
268
|
| `@runeditrun/rer/internal/PATH` | any other package file, for tests | `scripts/base-cli/PATH`, and `scripts/base-onboarding/PATH` with PATH under `onboarding/` |
|
|
@@ -273,7 +273,7 @@ In a checkout, every verb runs that checkout's own pinned `rer`; `rer VERB --hel
|
|
|
273
273
|
there lists its flags:
|
|
274
274
|
|
|
275
275
|
`install`, `setup`, `dev`, `preview`, `build`, `verify`, `reset --yes`, `deploy`,
|
|
276
|
-
`export`, `import`, `
|
|
276
|
+
`export`, `import`, `doctor`, `describe`, `check`, `release`,
|
|
277
277
|
`release sign`, `release receipt` and `release keygen`.
|
|
278
278
|
|
|
279
279
|
Anywhere: `rer list [DIR]`, `rer cli status|install|uninstall`, `rer update`,
|
package/cli/README.md
CHANGED
|
@@ -85,7 +85,7 @@ included authority generation, so archive hashes may differ even when retained
|
|
|
85
85
|
domain and identity rows are equal. The technical foundation currently has no
|
|
86
86
|
product domain or background jobs; default-seed retains its durable jobs and
|
|
87
87
|
schedule records while omitting transient queue delivery state, local runtime
|
|
88
|
-
caches and logs,
|
|
88
|
+
caches and logs, transfer bookkeeping, provider credentials,
|
|
89
89
|
provider link keys and transient provider sessions. People, external identity
|
|
90
90
|
bindings, the installation sector and the original owner claim are retained.
|
|
91
91
|
Retained dependency links are marked as needing re-link, and provider sign-in
|
|
@@ -101,7 +101,9 @@ secret generation. `--owner-email` maps to its owner-claim email field; private
|
|
|
101
101
|
`--answers` uses declared field names. Existing owner, settings and data are kept.
|
|
102
102
|
The owner name is prompted or defaulted only when the installer model declares
|
|
103
103
|
the adapter's name field (normally `displayName`). Nameless installers proceed
|
|
104
|
-
without it and refuse `--owner-name`.
|
|
104
|
+
without it and refuse `--owner-name`. A custom `input.names.name` uses its declared
|
|
105
|
+
manifest default and receives `--owner-name`; it replaces the generated
|
|
106
|
+
`displayName` input while keeping the adapter's owner bootstrap hook.
|
|
105
107
|
|
|
106
108
|
Run `node --test --test-concurrency=2 cli/*.test.mjs` from Base. Base's shared tests
|
|
107
109
|
stay in Base; exported seeds carry runtime source and their own adopting tests.
|
|
@@ -114,8 +116,8 @@ lockfiles, tool versions and output bytes in a nonsecret `.rer/local` receipt;
|
|
|
114
116
|
changed or incomplete output is rebuilt. Changes made while serving do not
|
|
115
117
|
rebuild preview. A build that regenerates its own files declares them as
|
|
116
118
|
`generatedOutputs` on the command adapter (see the seed command contract); those
|
|
117
|
-
paths are not inputs, while any other file touched during the build is refused by name. Both use the same `.wrangler/state
|
|
118
|
-
|
|
119
|
+
paths are not inputs, while any other file touched during the build is refused by name. Both use the same `.wrangler/state` and saved owner. Dev opens signed in through `RER_OPEN`, including with the legacy
|
|
120
|
+
`--login` flag. Stop before changing modes.
|
|
119
121
|
Stop dev or preview before build, verification or data transfer; use the
|
|
120
122
|
documented `--stop` flag or Ctrl-C.
|
|
121
123
|
|
|
@@ -135,7 +137,7 @@ Both are managed servers. `--detach` returns after readiness, leaving the server
|
|
|
135
137
|
running; `--foreground` keeps the invocation active while serving. Preview
|
|
136
138
|
refreshes changed built assets and their ETags; source edits need a restart and
|
|
137
139
|
rebuild. A compatible repeated invocation verifies the registered application,
|
|
138
|
-
prints its
|
|
140
|
+
prints its readiness and automatic sign-in URLs and exits without a new build or sign-in.
|
|
139
141
|
Explicit conflicting host, port or timeout, or the other mode, refuses with
|
|
140
142
|
exit 4 and the correct stop command. `--stop` is idempotent;
|
|
141
143
|
start-only flags cannot accompany it. It requires no setup or tool versions.
|
|
@@ -158,24 +160,23 @@ idle timeout, and they stop with `dev` (explicit stop, idle timeout, Ctrl-C or
|
|
|
158
160
|
an application exit). `preview` does not run schedules. A seed that does not
|
|
159
161
|
want this declares one adapter option: `commandAdapter(lifecycle, { scheduled: false, ... })`.
|
|
160
162
|
|
|
161
|
-
###
|
|
162
|
-
|
|
163
|
-
`setup`
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
(`
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
described above.
|
|
163
|
+
### Local and production sign-in
|
|
164
|
+
|
|
165
|
+
`setup` claims the local owner and stops its temporary runtime. `dev` prints
|
|
166
|
+
`RER_OPEN` to open automatically as that owner. It does not capture email or
|
|
167
|
+
request a sign-in message. Legacy `--login` uses this same automatic entry.
|
|
168
|
+
|
|
169
|
+
Production deployment requires outbound email configured in the actual declared
|
|
170
|
+
bindings (`MAIL_PROVIDER`, `MAIL_FROM`, `MAIL_API_KEY`, and `MAIL_ACCOUNT_ID` for
|
|
171
|
+
Cloudflare), or an Auth SSO dependency selected through the setup manifest and
|
|
172
|
+
approved through the existing link flow. A redeploy can retain existing mail
|
|
173
|
+
secrets after the provider verifies the owned deployment. Local setup and demo
|
|
174
|
+
do not require production mail credentials. Preview serves production output
|
|
175
|
+
and prints its ready address without a captured-mail sign-in flow.
|
|
175
176
|
|
|
176
177
|
Idle timeout is `--idle-timeout SECONDS`, then `RER_SERVER_IDLE_SECONDS`, then
|
|
177
178
|
43200 seconds (12 hours). Only positive integer seconds are accepted. HTTP requests,
|
|
178
|
-
including assets
|
|
179
|
+
including assets, reset inactivity; a live request/stream prevents idle
|
|
179
180
|
shutdown. Internal health probes and Vite HMR control traffic do not prolong
|
|
180
181
|
serving; application WebSocket data messages count. Explicit stop and idle
|
|
181
182
|
expiry clean up owned descendants before releasing state and capacity.
|
|
@@ -218,7 +219,7 @@ membership and actual process ancestry before sharing the admitted slot.
|
|
|
218
219
|
Direct documented browser/runtime entrypoints and indirect package scripts join
|
|
219
220
|
the same executor. Original-caller `CI=true` skips admission; `CI=false` and unset CI queue.
|
|
220
221
|
Heavy verbs alone accept `--no-queue`, only with `CI=true`. Synthesized install
|
|
221
|
-
child CI does not change the original decision. Inspection/help
|
|
222
|
+
child CI does not change the original decision. Inspection/help,
|
|
222
223
|
stop and reset inventory/removal do not start a heavy job or application.
|
|
223
224
|
|
|
224
225
|
After the seed's verification target, `verify` runs two checks on the production
|
package/cli/adapter.mjs
CHANGED
|
@@ -4,6 +4,11 @@ import { verbs, releaseFlags } from './contract.mjs';
|
|
|
4
4
|
// the existing onboarding kit. No adapter gets a second executor.
|
|
5
5
|
export function commandAdapter(lifecycle, options) {
|
|
6
6
|
const result = { version: 1, ...lifecycle, ...options, state: '.wrangler/state', settings: options.settings ?? ['.dev.vars', '.dev.vars.previous'] };
|
|
7
|
+
// ownerBootstrap adds the generic displayName input to the installer model.
|
|
8
|
+
// A declared custom name uses manifest validation instead; the lifecycle's
|
|
9
|
+
// owner hook still performs the bootstrap with that input.
|
|
10
|
+
const ownerName = result.input?.names?.name;
|
|
11
|
+
if (typeof ownerName === 'string' && ownerName.trim() && ownerName !== 'displayName') result.ownerBootstrap = false;
|
|
7
12
|
result.verbs = Object.fromEntries(Object.entries(verbs).filter(([verb]) => !['export', 'import'].includes(verb) || typeof result.portability?.[verb] === 'function').map(([verb, definition]) => [verb, { flags: [...definition.flags] }]));
|
|
8
13
|
result.verbs.release = { flags: [...releaseFlags] };
|
|
9
14
|
return result;
|
package/cli/container.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { requireProductionAuth } from './production-auth.mjs';
|
|
1
2
|
import { spawn, execFile } from 'node:child_process';
|
|
2
3
|
import { promisify } from 'node:util';
|
|
3
4
|
import { readFile, mkdir, writeFile } from 'node:fs/promises';
|
|
@@ -25,7 +26,7 @@ export async function imageFolder(project,operation,config,{output,engine}={}) {
|
|
|
25
26
|
const declared=Array.isArray(declaration.env)?declaration.env.map(item=>item.name):Object.keys(declaration.env??{});
|
|
26
27
|
await withoutLocalVariables(root,async()=>{
|
|
27
28
|
const builder=fileURLToPath(new URL('../modules/container/build.mjs',import.meta.url));
|
|
28
|
-
await run(process.execPath,[builder,root,JSON.stringify({output,engine})],{cwd:root,env:buildEnvironment([...declared,...(config.secrets??[]).flatMap(item=>[item.binding,item.environment])])});
|
|
29
|
+
await run(process.execPath,[builder,root,JSON.stringify({output,engine,declaration:config})],{cwd:root,env:buildEnvironment([...declared,...(config.secrets??[]).flatMap(item=>[item.binding,item.environment])])});
|
|
29
30
|
},{nested:operation.token,settings:[...(project.adapter?.settings??[]),...(project.privateInputs??[])]});
|
|
30
31
|
}
|
|
31
32
|
export async function containerCommand(project,options,out) {
|
|
@@ -36,13 +37,17 @@ export async function containerCommand(project,options,out) {
|
|
|
36
37
|
}
|
|
37
38
|
async function runContainer(project,options,out,operation) {
|
|
38
39
|
const {root}=project;
|
|
40
|
+
if(['build','deploy'].includes(options.verb)&&process.env.RER_DEMO)throw refuse('Production build and deploy refuse the local-only RER_DEMO environment binding. Unset it before retrying.');
|
|
39
41
|
if(options.verb==='deploy'){try{await refuseLocalModels(root);}catch{throw refuse('Deploy refuses the local-only key file .rer/local/models.json. Remove live-dev credentials before deployment.');}}
|
|
40
42
|
const config=JSON.parse(await readFile(join(root,'deploy.json'),'utf8'));
|
|
41
43
|
if(!(config.platforms??['workers']).includes('container'))throw refuse('This seed does not declare container support.');
|
|
42
44
|
const name='rer-local-'+createHash('sha256').update(root).digest('hex').slice(0,16),image=name+':candidate';
|
|
43
45
|
if(options.stop){await execute('docker',['stop','-t','10',name]);return{stopped:true};}
|
|
44
46
|
if(['build','deploy'].includes(options.verb)){
|
|
45
|
-
if(options.verb==='deploy'){if(!options.host)throw missing('Container deploy requires --host ssh://user@host.');sshTarget(options.host);await deployInputs({root,envFile:options.envFile,localOnlyKeys:project.adapter?.localOnlyKeys});
|
|
47
|
+
if(options.verb==='deploy'){if(!options.host)throw missing('Container deploy requires --host ssh://user@host.');sshTarget(options.host);const production=await deployInputs({root,envFile:options.envFile,localOnlyKeys:project.adapter?.localOnlyKeys});
|
|
48
|
+
const {loadInstallerSeed}=await shared('setup-manifest.mjs');
|
|
49
|
+
const setupSeed=project.adapter?.setup?await loadInstallerSeed(root,project.adapter):undefined;
|
|
50
|
+
await requireProductionAuth({root,declaration:config,env:production.settings,setupManifest:setupSeed?.manifest,setupSeed,adapter:project.adapter,options});}
|
|
46
51
|
const ingress={...(options.bindAddress?{address:options.bindAddress}:{}),...(options.httpPort?{httpPort:options.httpPort}:{}),...(options.httpsPort?{httpsPort:options.httpsPort}:{})};
|
|
47
52
|
ingressBindings({...config.container?.ingress,...ingress});
|
|
48
53
|
if(!options.image){await imageFolder(project,operation,config);await run('docker',['build','--tag',image,join(root,'.rer/container/image')],{cwd:root});}
|
package/cli/contract.mjs
CHANGED
|
@@ -6,15 +6,14 @@ export const commonFlags = ['--help', '--cwd', '--non-interactive', '--json'];
|
|
|
6
6
|
const definitions = {
|
|
7
7
|
install: [[], 'Frozen dependency installation; no setup or global tool changes.'],
|
|
8
8
|
setup: [['--owner-email', '--owner-name', '--port', '--host', '--answers', '--door'], 'Build, migrate, prepare private settings and first owner; stop the temporary app. --door sets a fresh checkout up at its front-door origin http://NAME.localhost:PORT (after rer door enable).'],
|
|
9
|
-
dev: [['--port', '--host', '--idle-timeout', '--stop', '--detach', '--foreground', '--as', '--login', '--models', '--models-service', '--door', '--direct', '--demo'], 'Development with assets, HMR and the declared scheduled triggers run locally on their schedule. --detach returns once ready; --foreground keeps this command serving. With devIdentity it opens signed in as the owner
|
|
9
|
+
dev: [['--port', '--host', '--idle-timeout', '--stop', '--detach', '--foreground', '--as', '--login', '--models', '--models-service', '--door', '--direct', '--demo'], 'Development with assets, HMR and the declared scheduled triggers run locally on their schedule. --detach returns once ready; --foreground keeps this command serving. With devIdentity it opens signed in as the owner; --as PERSONA picks another start. The legacy --login flag is accepted and uses the same automatic sign-in. --door moves this checkout to its front-door origin http://NAME.localhost:PORT, keeping its data; --direct moves it back; --port and --host serve directly. --demo (or rer demo) serves a throwaway demo: fresh data in .rer/demo/START (deleted when it stops: --stop, Ctrl-C or its end, one hour by default or --idle-timeout), the saved owner signed in, the seed\'s demo data, Demo in the app name and title, real public reads/checks and simulated external writes (RER_DEMO=1; the checkout\'s own data is never touched).'],
|
|
10
10
|
preview: [['--port', '--host', '--idle-timeout', '--stop', '--detach', '--foreground'], 'Production output; --detach returns once ready, --foreground keeps this command serving. Reuse intact build, refresh changed assets, preserve owner/state, idle timeout and explicit stop.'],
|
|
11
11
|
build: [['--site'], 'Production build with private local settings excluded and restored. --site instead writes the static run site (homepage, /run, docs) to its declared folder and prints that folder.'],
|
|
12
12
|
verify: [[], 'Run the complete internal verification target.'],
|
|
13
13
|
reset: [['--yes'], 'Confirmed removal of the declared local inventory only.'],
|
|
14
|
-
deploy: [['--environment', '--dry-run', '--site', '--demo', '--host', '--env-file', '--image', '--bind-address', '--http-port', '--https-port', '--remove', '--yes', '--set-secret', '--unset-secret'], 'Owner-account deployment and health; dry run performs local validation/build only. Declared secrets come from the environment or --env-file (an owned 0600 KEY=VALUE file); a new Worker gets the local setup owner and fresh generated secrets when they are not given. After a healthy deploy rer claims the setup owner on the hosted app with the one-time setup token, then removes the token. --set-secret NAME (value from the environment or --env-file) and --unset-secret NAME change one secret of the deployed Worker without a build and record its new version. --remove --yes deletes what this environment\'s deploy record says rer created (Worker, D1, R2, KV, queues), reads back that each is gone, and touches nothing else. --site deploys the run site instead: an assets-only Worker on its custom domain with www redirected; with --dry-run it builds the site and prints the plan with no provider request. --demo deploys the hosted demo instead (deploy-demo.json): a front Worker on demo.<domain> giving each visitor their own signed-in, throwaway container of this seed
|
|
14
|
+
deploy: [['--environment', '--dry-run', '--site', '--demo', '--host', '--env-file', '--image', '--bind-address', '--http-port', '--https-port', '--remove', '--yes', '--set-secret', '--unset-secret'], 'Owner-account deployment and health; dry run performs local validation/build only. Declared secrets come from the environment or --env-file (an owned 0600 KEY=VALUE file); a new Worker gets the local setup owner and fresh generated secrets when they are not given. After a healthy deploy rer claims the setup owner on the hosted app with the one-time setup token, then removes the token. --set-secret NAME (value from the environment or --env-file) and --unset-secret NAME change one secret of the deployed Worker without a build and record its new version. --remove --yes deletes what this environment\'s deploy record says rer created (Worker, D1, R2, KV, queues), reads back that each is gone, and touches nothing else. --site deploys the run site instead: an assets-only Worker on its custom domain with www redirected; with --dry-run it builds the site and prints the plan with no provider request. --demo deploys the hosted demo instead (deploy-demo.json): a front Worker on demo.<domain> giving each visitor their own signed-in, throwaway container of this seed with real public reads/checks and simulated external writes; --dry-run writes it to .rer/demo-host with no provider request; --demo --remove --yes deletes that demo (its Worker, demo.<domain> Custom Domain and Container application, each only while the record its deploy left proves it the demo\'s), reads back that each is gone, and is a no-op once it is.'],
|
|
15
15
|
export: [['--target', '--output', '--origin', '--session-file'], 'Complete supported installation archive with integrity and exclusions.'],
|
|
16
16
|
import: [['--target', '--input', '--journal', '--origin', '--session-file', '--yes', '--legacy-v1', '--acknowledge-unverified-metadata', '--output'], 'Confirmed atomic restore into an empty destination; --journal LATER_ARCHIVE also fences rows that installation erased since. Backup-only local v1 recovery requires --legacy-v1 --acknowledge-unverified-metadata and a new --output v2 archive; --journal requires normal v2 import.'],
|
|
17
|
-
outbox: [['--port', '--host', '--owner-email', '--open'], 'Credential-free local outbox URL; optional ordinary sign-in request and explicit browser opening.'],
|
|
18
17
|
doctor: [[], 'Read-only installed tool, configuration and state diagnostics.'],
|
|
19
18
|
describe: [[], 'Read-only description of actual command capabilities.'],
|
|
20
19
|
check: [['--profile'], 'Read-only structural command contract and operations validation.'],
|
|
@@ -22,7 +21,7 @@ const definitions = {
|
|
|
22
21
|
export const verbs = Object.fromEntries(Object.entries(definitions).map(([name, [flags, effects]]) => [name, { flags: [...commonFlags, ...flags, ...(['build','deploy','dev','preview','export','import'].includes(name)?['--platform']:[]), ...(['install','setup','dev','preview','build','verify','deploy','export','import'].includes(name)?['--no-queue']:[])], effects }]));
|
|
23
22
|
// `rer demo` is `rer dev --demo`; describe lists it as a verb with the dev
|
|
24
23
|
// flags a demo takes whenever the seed's dev takes --demo.
|
|
25
|
-
export const demoVerb = Object.freeze({ flags: [...commonFlags, '--port', '--host', '--idle-timeout', '--stop', '--detach', '--foreground', '--no-queue'], effects: 'A throwaway demo of this seed (rer dev --demo): fresh data in .rer/demo/START (deleted when it stops: --stop, Ctrl-C or its end, one hour by default or --idle-timeout), the saved owner signed in, the seed\'s demo data,
|
|
24
|
+
export const demoVerb = Object.freeze({ flags: [...commonFlags, '--port', '--host', '--idle-timeout', '--stop', '--detach', '--foreground', '--no-queue'], effects: 'A throwaway demo of this seed (rer dev --demo): fresh data in .rer/demo/START (deleted when it stops: --stop, Ctrl-C or its end, one hour by default or --idle-timeout), the saved owner signed in, the seed\'s demo data, Demo in the app name and title, real public reads/checks and simulated external writes (RER_DEMO=1; the checkout\'s own data is never touched).' });
|
|
26
25
|
// `rer signin` is rer's own, not a seed operation: any seed rer deploys, it can
|
|
27
26
|
// sign the owner in to, so no seed declares it and check does not ask for it.
|
|
28
27
|
export const signinVerb = Object.freeze({ flags: [...commonFlags, '--environment', '--env-file'], effects: 'A one-time sign-in link for the hosted owner, without mail. Uses the Cloudflare credentials that deployed --environment (default production; from the environment or --env-file) to write a single-use grant for the recorded owner into that deployment\'s auth database, then prints the link once to this terminal; it is never saved. The link works once, only for that owner, expires within 15 minutes, and its use is recorded in the owner\'s audit log. Signed in this way, the owner can correct a wrong email in settings.' });
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { validateDeclarations } from '../modules/delivery-producer/declarations.mjs';
|
|
3
|
+
import { contained } from './project.mjs';
|
|
4
|
+
|
|
5
|
+
// Source policy and its committed integration projection. Inspect declarations
|
|
6
|
+
// without requiring a build or executing the seed's packaging code.
|
|
7
|
+
const sources = [
|
|
8
|
+
['rer-packaging.json', value => value?.artifact?.specInputs],
|
|
9
|
+
['packaging.json', value => value?.artifact?.specInputs],
|
|
10
|
+
['scripts/delivery/base/packaging.json', value => value?.artifact?.specInputs],
|
|
11
|
+
['management/integration/deployment-spec.json', value => value],
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
export async function deliveryDeclarationClauses(root) {
|
|
15
|
+
const clauses = [];
|
|
16
|
+
for (const [path, select] of sources) {
|
|
17
|
+
let text;
|
|
18
|
+
try { text = await readFile(await contained(root, path, { optional: true }), 'utf8'); }
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error.code === 'ENOENT') continue;
|
|
21
|
+
clauses.push({ id: `delivery.declarations.${path}`, ok: false, message: `Restore a readable contained declaration at ${path}.` });
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const clause = { id: `delivery.declarations.${path}`, ok: true };
|
|
25
|
+
let value;
|
|
26
|
+
try { value = JSON.parse(text); }
|
|
27
|
+
catch { clause.ok = false; clause.message = `${path}: invalid JSON declaration.`; }
|
|
28
|
+
if (clause.ok) {
|
|
29
|
+
const spec = select(value);
|
|
30
|
+
if (spec !== undefined) try { validateDeclarations(spec); }
|
|
31
|
+
catch (error) { clause.ok = false; clause.message = `${path}: ${error.message}`; }
|
|
32
|
+
}
|
|
33
|
+
clauses.push(clause);
|
|
34
|
+
}
|
|
35
|
+
return clauses;
|
|
36
|
+
}
|
package/cli/demo-host.mjs
CHANGED
|
@@ -21,7 +21,7 @@ export async function demoHostCommand(project, options, store, signal, out, oper
|
|
|
21
21
|
let plan;
|
|
22
22
|
try { plan = demoPlan({ project: app.project, environment: options.environment ?? 'production', compatibilityDate: app.compatibilityDate, originVar: app.originVar, declaration, turnstileSiteKey: process.env.TURNSTILE_SITE_KEY?.trim() }); }
|
|
23
23
|
catch (error) { throw invalid(`The demo deploy declaration is invalid (${error.message}). deploy-demo.json holds {"version": 1, "domain": "<run site apex>", "name": "<product name>"}, optionally "maxInstances", "instanceType" (${INSTANCE_TYPES.join(', ')}; default basic) and plain "settings".`); }
|
|
24
|
-
if (options.remove) return removeDemo(plan, store);
|
|
24
|
+
if (options.remove) return removeDemo(plan, store, signal);
|
|
25
25
|
if (process.env.RER_DEMO_OPERATOR_TOKEN && (process.env.RER_DEMO_OPERATOR_TOKEN.length < 32 || process.env.RER_DEMO_OPERATOR_TOKEN.length > 512)) throw invalid('RER_DEMO_OPERATOR_TOKEN must contain 32 to 512 characters.');
|
|
26
26
|
const folder = join(project.root, '.rer', 'demo-host');
|
|
27
27
|
await rm(folder, { recursive: true, force: true });
|
|
@@ -31,9 +31,9 @@ export async function demoHostCommand(project, options, store, signal, out, oper
|
|
|
31
31
|
await prepareDemoImage(join(folder, 'image'));
|
|
32
32
|
for (const file of DEMO_FILES) await cp(new URL(`../modules/demo-host/${file}`, import.meta.url), join(folder, file));
|
|
33
33
|
await writeFile(join(folder, 'wrangler.json'), JSON.stringify(plan.wrangler, null, 2) + '\n');
|
|
34
|
-
const summary = { worker: plan.worker, origin: plan.origin, hostname: plan.hostname, folder: '.rer/demo-host', maxInstances: plan.maxInstances, settings: plan.settings, instanceType: plan.instanceType, startsPerIpPerMinute: 3, minutes: 60, idleMinutes: 15, enableInternet:
|
|
34
|
+
const summary = { worker: plan.worker, origin: plan.origin, hostname: plan.hostname, folder: '.rer/demo-host', maxInstances: plan.maxInstances, settings: plan.settings, instanceType: plan.instanceType, startsPerIpPerMinute: 3, minutes: 60, idleMinutes: 15, enableInternet: true };
|
|
35
35
|
const human = [`Demo plan: Worker ${summary.worker} on ${summary.hostname} (custom domain; workers.dev off), written to ${summary.folder}`,
|
|
36
|
-
` one container per visitor (${summary.instanceType}, at most ${summary.maxInstances} at once,
|
|
36
|
+
` one container per visitor (${summary.instanceType}, at most ${summary.maxInstances} at once, public internet, RER_DEMO=1), 3 starts per IP per minute behind Turnstile`,
|
|
37
37
|
` each demo ends after 60 minutes or 15 idle minutes; its container is destroyed and its state deleted`];
|
|
38
38
|
if (options.dryRun) {
|
|
39
39
|
if (options.json) out.event('demo', summary); else for (const line of human) out.human(line);
|
|
@@ -54,15 +54,16 @@ export async function demoHostCommand(project, options, store, signal, out, oper
|
|
|
54
54
|
return { dryRun: false, deployed: true, origin: plan.origin, demo: summary };
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
async function removeDemo(plan, store) {
|
|
57
|
+
async function removeDemo(plan, store, signal) {
|
|
58
58
|
const names = ['CLOUDFLARE_ACCOUNT_ID', 'CLOUDFLARE_API_TOKEN'];
|
|
59
59
|
if (names.some(name => !process.env[name]?.trim())) throw missing(`${names.join(' and ')} are required to remove the demo; see DEMO.md "Removing a hosted demo".`);
|
|
60
60
|
const { cloudflare } = await import('../modules/deploy-kit/provider.mjs');
|
|
61
61
|
const { providerRefusal } = await import('../modules/deploy-kit/diagnostics.mjs');
|
|
62
62
|
const { demoRemove } = await import('../modules/demo-host/remove.mjs');
|
|
63
|
+
const { demoRemovalFetch } = await import('./demo-removal-provider.mjs');
|
|
63
64
|
await store.step(`Removing the demo Worker ${plan.worker} on ${plan.hostname}`);
|
|
64
65
|
let result;
|
|
65
|
-
try { result = await demoRemove({ api: cloudflare({ accountId: process.env.CLOUDFLARE_ACCOUNT_ID, token: process.env.CLOUDFLARE_API_TOKEN }), plan }); }
|
|
66
|
+
try { result = await demoRemove({ api: cloudflare({ accountId: process.env.CLOUDFLARE_ACCOUNT_ID, token: process.env.CLOUDFLARE_API_TOKEN, fetch: demoRemovalFetch(signal) }), plan }); }
|
|
66
67
|
catch (error) {
|
|
67
68
|
if (error instanceof RerError) throw error;
|
|
68
69
|
const code = /^[a-z0-9-]{1,80}$/.test(error.message) ? error.message : 'demo-remove-failed';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { setTimeout as pause } from 'node:timers/promises';
|
|
2
|
+
|
|
3
|
+
// Only demo removal uses these retries. The provider's original request signal
|
|
4
|
+
// bounds every attempt and backoff together; no retry gets a fresh deadline.
|
|
5
|
+
export function demoRemovalFetch(signal, request = globalThis.fetch) {
|
|
6
|
+
return async (input, init = {}) => {
|
|
7
|
+
const signals = [init.signal, signal].filter(Boolean);
|
|
8
|
+
const bounded = signals.length ? AbortSignal.any(signals) : undefined;
|
|
9
|
+
const method = init.method ?? 'GET';
|
|
10
|
+
for (let attempt = 0; ; attempt++) {
|
|
11
|
+
bounded?.throwIfAborted();
|
|
12
|
+
const response = await request(input, { ...init, signal: bounded });
|
|
13
|
+
// A DELETE can have succeeded before the provider lost its answer. Its
|
|
14
|
+
// retry then sees 404; the remover still performs its full absence readback.
|
|
15
|
+
if (method === 'DELETE' && response.status === 404) {
|
|
16
|
+
void response.body?.cancel().catch(() => {});
|
|
17
|
+
return new Response(null, { status: 204 });
|
|
18
|
+
}
|
|
19
|
+
if (!['GET', 'DELETE'].includes(method) || response.status < 500 || response.status > 599 || attempt === 2) return response;
|
|
20
|
+
void response.body?.cancel().catch(() => {});
|
|
21
|
+
await pause(250 * 2 ** attempt, undefined, { signal: bounded });
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
package/cli/demo.mjs
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import { readdir, readFile, rm } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { DatabaseSync } from 'node:sqlite';
|
|
4
|
-
import { refuse } from './errors.mjs';
|
|
4
|
+
import { missing, refuse } from './errors.mjs';
|
|
5
5
|
import { shared } from './shared.mjs';
|
|
6
|
+
import { requiredLocalSettings } from './settings.mjs';
|
|
6
7
|
|
|
7
8
|
// `rer demo` (dev --demo) state and its two adoption checks (export/DEMO.md).
|
|
8
9
|
const adopt = 'See DEMO.md: a seed adopts demo mode with src/demo.ts, withDemo as the first import of its Worker entry, and three vite.config changes.';
|
|
9
10
|
|
|
11
|
+
// Owner-data prerequisites belong to dev/preview. Older adapters ignore a demo
|
|
12
|
+
// flag and open the owner's SQLite even for a refused start (rewriting -shm).
|
|
13
|
+
// Check only saved configuration here; migrations and owner bootstrap are
|
|
14
|
+
// verified by starting the application against its fresh demo state.
|
|
15
|
+
export async function demoPreflight(project, vars, seconds) {
|
|
16
|
+
if (requiredLocalSettings(project, vars).length) throw missing('Private owner settings are missing. Run rer setup first.');
|
|
17
|
+
await demoAdopted(project.root);
|
|
18
|
+
return demoState(project.root, seconds);
|
|
19
|
+
}
|
|
20
|
+
|
|
10
21
|
// Before anything starts: the seed's Vite persists where rer says, so the
|
|
11
22
|
// checkout's own .wrangler/state is never opened by a demo, and hands the
|
|
12
23
|
// Worker's cloudflare:sockets imports demo mode's guarded connect.
|
|
@@ -16,12 +27,12 @@ export async function demoAdopted(root) {
|
|
|
16
27
|
try { text = await readFile(join(root, name), 'utf8'); break; } catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
17
28
|
}
|
|
18
29
|
if (!text.includes('RER_STATE_DIR')) throw refuse(`This seed's vite.config does not persist to RER_STATE_DIR, so a demo would run on this checkout's own data. ${adopt}`);
|
|
19
|
-
if (!text.includes('demoSockets(')) throw refuse(`This seed's vite.config does not list demoSockets(), so
|
|
30
|
+
if (!text.includes('demoSockets(')) throw refuse(`This seed's vite.config does not list demoSockets(), so direct mail transports would not pass through the demo effect guard. ${adopt}`);
|
|
20
31
|
}
|
|
21
32
|
|
|
22
33
|
// A demo's data lives in .rer/demo/START. Only one server runs per checkout, so
|
|
23
34
|
// any other demo folder is a stopped demo's leftover (a hard kill) and goes now.
|
|
24
|
-
// The end is local ISO time with its offset
|
|
35
|
+
// The end is local ISO time with its offset, also returned in readiness metadata.
|
|
25
36
|
export async function demoState(root, seconds) {
|
|
26
37
|
const { privateDirectory } = await shared('private-files.mjs');
|
|
27
38
|
const started = new Date(), stamp = started.toISOString().replace(/[-:]|\.\d+/g, '');
|
|
@@ -34,7 +45,7 @@ export async function demoState(root, seconds) {
|
|
|
34
45
|
}
|
|
35
46
|
|
|
36
47
|
// After start: a request has passed withDemo, which creates rer_demo in the
|
|
37
|
-
// demo's own database. Without it
|
|
48
|
+
// demo's own database. Without it effect simulation is unproved, so the demo stops.
|
|
38
49
|
export async function demoGuarded(url, state, signal) {
|
|
39
50
|
const { appFetch } = await shared('app-fetch.mjs');
|
|
40
51
|
await (await appFetch(url + '/health', { signal })).body?.cancel();
|
|
@@ -43,5 +54,5 @@ export async function demoGuarded(url, state, signal) {
|
|
|
43
54
|
const db = new DatabaseSync(join(directory, file), { readOnly: true });
|
|
44
55
|
try { if (db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'rer_demo'").get()) return; } finally { db.close(); }
|
|
45
56
|
}
|
|
46
|
-
throw refuse(`The app did not start in demo mode (no withDemo guard answered), so
|
|
57
|
+
throw refuse(`The app did not start in demo mode (no withDemo guard answered), so external writes might run for real. The demo was stopped and its data deleted. ${adopt}`);
|
|
47
58
|
}
|
package/cli/deploy-command.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { requireProductionAuth } from './production-auth.mjs';
|
|
1
2
|
import { observedReadiness } from '../modules/deploy-kit/readiness-window.mjs';
|
|
2
3
|
import { readFile, readdir } from 'node:fs/promises';
|
|
3
4
|
import { contained } from './project.mjs';
|
|
@@ -62,6 +63,8 @@ export async function deployCommand(context) {
|
|
|
62
63
|
// may perform them; neither a build nor a custom upload runs here.
|
|
63
64
|
if (options.remove || options.setSecret || options.unsetSecret) return ownerDeploy(path, adapter)(context);
|
|
64
65
|
if (adapter.deploy.managesHostedOwner) return adapter.deploy(context);
|
|
66
|
+
const production = await deployEnvironment({ root, options, declaration, setupManifest, settings: adapter.settings, localOnlyKeys });
|
|
67
|
+
await requireProductionAuth({ root, declaration, env: production.env, setupManifest, setupSeed: context.setupSeed, adapter, declarationPath: path, options });
|
|
65
68
|
const sourceSha = options.dryRun ? undefined : committedSource(root, options);
|
|
66
69
|
const { env, supplied } = await deployEnvironment({ root, options, declaration, setupManifest, settings: adapter.settings, localOnlyKeys });
|
|
67
70
|
const { createRedaction, credentialValues } = await shared('redaction.mjs');
|
|
@@ -75,9 +78,9 @@ export async function deployCommand(context) {
|
|
|
75
78
|
const command = (verb, extra = [], values = env, more = {}) => owner([verb, '--declaration', path, '--environment', environment, ...(hookRecord ? ['--state', hookRecord] : []), ...extra], values, { cwd: root, localOnlyKeys, ...more });
|
|
76
79
|
// A hook that deployed through the kit's standard record lets rer issue and
|
|
77
80
|
// retire the setup token; a hook keeping an unnamed record of its own keeps its token.
|
|
78
|
-
let recorded;
|
|
81
|
+
let recorded, hookReturned = false;
|
|
79
82
|
const inspect = async (origin = deployed?.origin) => {
|
|
80
|
-
try { return recorded = await command('inspect', [], env, {propagation:observedReadiness(origin)?.propagation}); }
|
|
83
|
+
try { return recorded = await command('inspect', [], env, hookReturned ? {} : {propagation:observedReadiness(origin)?.propagation}); }
|
|
81
84
|
catch (error) { if (error.message !== 'missing-owner-receipt') throw error; }
|
|
82
85
|
};
|
|
83
86
|
let observedClaims = [];
|
|
@@ -94,18 +97,21 @@ export async function deployCommand(context) {
|
|
|
94
97
|
for (const key of Object.keys(process.env)) if (!Object.hasOwn(saved, key)) delete process.env[key];
|
|
95
98
|
Object.assign(process.env, saved);
|
|
96
99
|
}
|
|
100
|
+
hookReturned = true;
|
|
97
101
|
if (options.dryRun) return deployed;
|
|
98
102
|
await rememberHookState(root, environment, deployed?.state);
|
|
99
103
|
hookRecord = await hookState(root, environment);
|
|
100
104
|
const origin = hookOrigin(deployed, deployAgain(options));
|
|
101
105
|
const uploaded = observedReadiness(origin);
|
|
102
|
-
step = 'wait for the deployed source';
|
|
103
|
-
await waitForSource({ origin, sourceSha, uploaded, again: deployAgain(options) });
|
|
104
106
|
step = 'verify recorded deployment';
|
|
105
|
-
|
|
107
|
+
// A hook may already have claimed the owner and retired its token. Read the
|
|
108
|
+
// current version independently of the original upload's spent deadline.
|
|
109
|
+
const state = await inspect(origin);
|
|
106
110
|
if ((state?.origin ?? origin) !== origin || claims.some(item => item.origin !== origin)) throw new Error('owner-claim-origin-mismatch');
|
|
107
111
|
if (claims.some(item => !item.outcome)) throw new Error('owner-claim-failed');
|
|
108
112
|
claimed = claims.at(-1)?.outcome;
|
|
113
|
+
step = 'wait for the deployed source';
|
|
114
|
+
await waitForSource({ origin, sourceSha, versionId: state?.versionId ?? (!claims.length && !deployed.owner ? uploaded?.versionId : undefined), again: deployAgain(options) });
|
|
109
115
|
step = 'claim owner';
|
|
110
116
|
if (typeof deployed.setupToken === 'string' && deployed.setupToken) addSecret(deployed.setupToken);
|
|
111
117
|
const sentSecrets = (uploaded?.sentSecrets ?? []).filter(binding => uploaded.propagation.matchesToken(binding, env[declaration.secrets.find(item => item.binding === binding)?.environment]));
|
package/cli/deploy-hook.mjs
CHANGED
|
@@ -12,25 +12,21 @@ export function hookOrigin(deployed, again) {
|
|
|
12
12
|
throw hookFailure(`The deploy hook finished without reporting a live deployment, so rer claimed no owner. A deploy hook returns { deployed: true, origin } once its upload is live. Check the hook's output above, fix the hook, then run ${again} again.`);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export async function waitForSource({ origin, sourceSha,
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
try { await waitHealth({ origin, expected: { sourceSha, ...(uploaded?.versionId ? { versionId: uploaded.versionId } : {}) },
|
|
22
|
-
request: (url, init) => globalThis.fetch(url, init),
|
|
23
|
-
...(window ? { window, clock: window.clock, sleep: window.sleep, freshUpload: true } : {}) }); }
|
|
15
|
+
export async function waitForSource({ origin, sourceSha, versionId, again }) {
|
|
16
|
+
// Finalization gets its own 90 seconds after the hook returns: upload, owner
|
|
17
|
+
// claim and token retirement may have consumed the upload readiness window.
|
|
18
|
+
// Retirement also creates a new version; use the current recorded identity.
|
|
19
|
+
try { await waitHealth({ origin, expected: { sourceSha, ...(versionId ? { versionId } : {}) }, retryIdentityMismatch: true,
|
|
20
|
+
request: (url, init) => globalThis.fetch(url, init) }); }
|
|
24
21
|
catch (error) {
|
|
25
22
|
const last = error.attempts?.at(-1);
|
|
26
|
-
let named;
|
|
27
|
-
try {
|
|
23
|
+
let named, version;
|
|
24
|
+
try { const identity = JSON.parse(last.body).deployment; named = identity?.sourceSha; version = identity?.versionId; } catch {}
|
|
28
25
|
const seen = !last || last.status === null ? 'it did not answer'
|
|
29
26
|
: last.status !== 200 ? `its last answer was HTTP ${last.status}`
|
|
30
|
-
: typeof named === 'string' && /^[0-9a-f]{7,64}$/.test(named) ? `it still answers for commit ${named.slice(0, 12)}`
|
|
27
|
+
: typeof named === 'string' && /^[0-9a-f]{7,64}$/.test(named) ? `it still answers for commit ${named.slice(0, 12)}${typeof version === 'string' && /^[a-zA-Z0-9_-]{1,64}$/.test(version) ? `, Worker version ${version}` : ''}`
|
|
31
28
|
: 'it answers without a deploy identity';
|
|
32
|
-
|
|
33
|
-
throw hookFailure(`The deploy hook reported a deployment at ${origin}, but its /health never named this checkout's commit ${sourceSha.slice(0, 12)}${uploaded?.versionId ? ' and the uploaded Worker version' : ''}${deadline} (${seen}), so rer stopped before owner finalization. Check that the hook uploaded this build and that /health answers deploymentHealth(env), then run ${again} again.`);
|
|
29
|
+
throw hookFailure(`The deploy hook reported a deployment at ${origin}, but its /health did not confirm this checkout's commit ${sourceSha.slice(0, 12)}${versionId ? ' and the current recorded Worker version' : ''} within the 90-second finalization wait (${seen}; ${last?.errorClass ?? 'health-timeout'}), so rer stopped before owner finalization. Check that the hook uploaded this build and that /health answers deploymentHealth(env), then run ${again} again.`);
|
|
34
30
|
}
|
|
35
31
|
}
|
|
36
32
|
|
package/cli/deploy.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { requireProductionAuth } from './production-auth.mjs';
|
|
1
2
|
import { readFile } from 'node:fs/promises';
|
|
2
3
|
import { deployDiagnostic } from '../modules/deploy-kit/diagnostics.mjs';
|
|
3
4
|
import { shared } from './shared.mjs';
|
|
@@ -15,7 +16,7 @@ import { hookState, forgetHookState } from './deploy-hook-record.mjs';
|
|
|
15
16
|
|
|
16
17
|
export function ownerDeploy(declarationPath, lifecycle) {
|
|
17
18
|
// rer verify serves the build with this declaration's vars and secrets.
|
|
18
|
-
return Object.assign(async ({ root, options, store, signal, operationToken, localOnlyKeys = [], checkBuild = async () => {}, setupManifest, linkDependencies }) => {
|
|
19
|
+
return Object.assign(async ({ root, options, store, signal, operationToken, localOnlyKeys = [], checkBuild = async () => {}, setupManifest, setupSeed, linkDependencies }) => {
|
|
19
20
|
try { await refuseLocalModels(root); } catch { throw refuse('Deploy refuses the local-only key file .rer/local/models.json. Remove live-dev credentials before deployment.'); }
|
|
20
21
|
const path = await contained(root, declarationPath);
|
|
21
22
|
let declaration; try { declaration = JSON.parse(await readFile(path, 'utf8')); } catch { throw invalid('Malformed owner-account deploy declaration.'); }
|
|
@@ -31,6 +32,8 @@ export function ownerDeploy(declarationPath, lifecycle) {
|
|
|
31
32
|
// A dry run reads the settings file too, so a refused key fails here and not only on the real deploy.
|
|
32
33
|
if (options.dryRun && options.envFile) await deployEnvironment({ root, options, declaration, localOnlyKeys });
|
|
33
34
|
if (!change.length) {
|
|
35
|
+
const production = await deployEnvironment({ root, options, declaration, setupManifest, settings: lifecycle.settings, localOnlyKeys });
|
|
36
|
+
await requireProductionAuth({ root, declaration, env: production.env, setupManifest, setupSeed, adapter: lifecycle, declarationPath, options });
|
|
34
37
|
if (!options.dryRun) committedSource(root, options);
|
|
35
38
|
await lifecycle.run(root, {}, store, () => {}, signal, { verb: 'build', operationToken });
|
|
36
39
|
await checkBuild();
|
package/cli/detached-server.mjs
CHANGED
|
@@ -34,8 +34,8 @@ export async function detachedServer(options, argv, out) {
|
|
|
34
34
|
if (event.event==='error') failure=event;
|
|
35
35
|
if (event.event==='ready') {
|
|
36
36
|
keep=true;child.unref();
|
|
37
|
-
const dev = event.openUrl ? {openUrl:event.openUrl,identity:options.verb === 'dev'
|
|
38
|
-
ready(out,event.url,dev,options.json,
|
|
37
|
+
const dev = event.openUrl ? {openUrl:event.openUrl,identity:options.verb === 'dev',signedInAs:event.signedInAs,ownerLeft:options.verb === 'dev' && event.signedInAs === null} : undefined;
|
|
38
|
+
ready(out,event.url,dev,options.json,event.siteUrl,event.demo);
|
|
39
39
|
return 0;
|
|
40
40
|
}
|
|
41
41
|
if (event.event==='waiting' || event.event==='warning') out.event(event.event,event);
|
package/cli/dev-identity.mjs
CHANGED
|
@@ -52,7 +52,7 @@ export function refuseManagedInstallation(...sources) {
|
|
|
52
52
|
for (const vars of sources) {
|
|
53
53
|
if (!vars?.RER_INSTALLATION_ID || !vars.RER_MANAGEMENT_ORIGIN) continue;
|
|
54
54
|
let host; try { host = new URL(vars.RER_MANAGEMENT_ORIGIN).hostname.replace(/^\[|\]$/g, ''); } catch {}
|
|
55
|
-
if (!loopback(host)) throw refuse('Dev identity refuses to start beside RER_INSTALLATION_ID with a non-loopback RER_MANAGEMENT_ORIGIN. Remove them from local settings
|
|
55
|
+
if (!loopback(host)) throw refuse('Dev identity refuses to start beside RER_INSTALLATION_ID with a non-loopback RER_MANAGEMENT_ORIGIN. Remove them from local settings before starting local dev identity.');
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
package/cli/export.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { cliVersion } from './version.mjs';
|
|
|
6
6
|
|
|
7
7
|
// Copy whole maintained source/tooling directories. Python publication scans
|
|
8
8
|
// load sibling modules and data dynamically; they belong in the inventory too.
|
|
9
|
-
export const sourceRoots = ['bin/rer.mjs', 'cli', 'modules/job-queue', 'modules/release', 'modules/deploy-kit', 'modules/container', 'modules/demo-host', 'modules/integrations/core', 'modules/mail', 'modules/ai', 'modules/portability', 'modules/erasure', 'modules/dependencies', 'modules/operator-auth', 'modules/owner-claim', 'operations', 'scripts/publish-check', 'scripts/publish-check.mjs', 'composition/git-source.mjs', 'edition-authoring/manifest.mjs', 'edition-authoring/files.mjs'];
|
|
9
|
+
export const sourceRoots = ['bin/rer.mjs', 'cli', 'modules/delivery-producer/declarations.mjs', 'modules/delivery-producer/bindings.mjs', 'modules/job-queue', 'modules/release', 'modules/deploy-kit', 'modules/container', 'modules/demo-host', 'modules/demo', 'modules/integrations/core', 'modules/mail', 'modules/ai', 'modules/portability', 'modules/d1-transport', 'modules/erasure', 'modules/dependencies', 'modules/operator-auth', 'modules/owner-claim', 'operations', 'scripts/publish-check', 'scripts/publish-check.mjs', 'composition/git-source.mjs', 'edition-authoring/manifest.mjs', 'edition-authoring/files.mjs'];
|
|
10
10
|
export async function inventory(base, roots = sourceRoots) {
|
|
11
11
|
const files = [];
|
|
12
12
|
async function walk(path) {
|