@runeditrun/rer 0.2.12 → 0.2.13
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/cli/deploy-command.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { invalid, refuse, RerError } from './errors.mjs';
|
|
|
4
4
|
import { ownerDeploy } from './deploy.mjs';
|
|
5
5
|
import { deployEnvironment, deployAgain } from './deploy-inputs.mjs';
|
|
6
6
|
import { claimHostedOwner } from './deploy-owner.mjs';
|
|
7
|
+
import { checkHostedSetup, hostedSetupFailure } from './deploy-setup.mjs';
|
|
7
8
|
import { mutationReadinessFailure } from './deploy-readiness.mjs';
|
|
8
9
|
import { observeOwner } from './deploy-observation.mjs';
|
|
9
10
|
import { committedSource } from './deploy-source.mjs';
|
|
@@ -97,6 +98,8 @@ export async function deployCommand(context) {
|
|
|
97
98
|
const kit = state ? { secret: (extra, values) => command('secret', extra, values), recordClaim: outcome => command('record-owner', ['--outcome', outcome]) } : { token: deployed.setupToken || undefined };
|
|
98
99
|
claimed = await claimHostedOwner({ hook: adapter.hooks?.owner, setupManifest, declaration, deployed: { ...state, origin, owner: claimed, observedOwner: () => claims.at(-1)?.outcome }, env, supplied, ...kit, addSecret, beforeClaim: token => link(token, origin), store, signal: context.signal });
|
|
99
100
|
if (!linked) await linkDependencies?.(origin);
|
|
101
|
+
step = 'verify hosted setup';
|
|
102
|
+
await checkHostedSetup({ origin, claimed: claimed ?? state?.ownerClaim?.outcome ?? claims.at(-1)?.outcome, signal: context.signal });
|
|
100
103
|
if (claimed) store.report(`${claimed === 'claimed' ? 'Claimed the hosted owner' : 'The hosted owner was already claimed and was kept'}${state ? '; the one-time setup token was removed' : ''}. Sign in by email at ${origin}.`);
|
|
101
104
|
const { setupToken: _, ...result } = deployed;
|
|
102
105
|
return { ...result, ...(claimed ? { owner: claimed } : {}), dependenciesLinked: true };
|
|
@@ -109,6 +112,8 @@ export async function deployCommand(context) {
|
|
|
109
112
|
const outcome = error.owner ?? claimed ?? observedClaims.at(-1)?.outcome;
|
|
110
113
|
const state = deployed?.deployed || recorded ? `The application is deployed at ${deployed?.origin ?? recorded.origin}; ${outcome ? `owner ${outcome}` : 'owner claim is not confirmed'}${recorded ? '; setup token retirement is not confirmed' : ''}.` : 'The custom deploy did not finish; inspect its deployment record before recovery.';
|
|
111
114
|
const redact = value => store.redact?.(redaction.redact(value)) ?? redaction.redact(value);
|
|
115
|
+
const setup = hostedSetupFailure(error, { origin: deployed?.origin ?? recorded?.origin, again });
|
|
116
|
+
if (setup) throw commandFailure(redact(setup));
|
|
112
117
|
const readiness = mutationReadinessFailure(error, { again, redact });
|
|
113
118
|
if (readiness) throw commandFailure(readiness);
|
|
114
119
|
const refused = providerRefusal(error);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Some native apps expose setup status without registering a shared owner step.
|
|
2
|
+
// An explicit unfinished setup must not become deploy success just because
|
|
3
|
+
// /health is healthy. An absent or unsupported endpoint proves nothing either
|
|
4
|
+
// way and remains compatible with apps that do not implement this optional API.
|
|
5
|
+
export async function checkHostedSetup({ origin, claimed, signal }) {
|
|
6
|
+
if (['claimed', 'kept'].includes(claimed)) return;
|
|
7
|
+
let required = false;
|
|
8
|
+
try {
|
|
9
|
+
const response = await globalThis.fetch(new URL('/api/identity/setup-status', origin), {
|
|
10
|
+
method: 'GET', credentials: 'omit', redirect: 'manual',
|
|
11
|
+
headers: { Accept: 'application/json', 'Cache-Control': 'no-cache' },
|
|
12
|
+
signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(10000)]) : AbortSignal.timeout(10000),
|
|
13
|
+
});
|
|
14
|
+
// Never follow a redirect or interpret an error page as a setup contract.
|
|
15
|
+
if (!response.redirected && (response.ok || response.status === 409)) required = (await response.json())?.setupRequired === true;
|
|
16
|
+
else await response.body?.cancel();
|
|
17
|
+
} catch { /* Only an explicit setup-required response establishes this gap. */ }
|
|
18
|
+
signal?.throwIfAborted();
|
|
19
|
+
if (required) throw new Error('hosted-setup-required');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function hostedSetupFailure(error, { origin, again }) {
|
|
23
|
+
if (error.message !== 'hosted-setup-required') return undefined;
|
|
24
|
+
return `Deploy is incomplete. The application is deployed at ${origin}, but /api/identity/setup-status reports that setup is required and the owner claim is not confirmed. The deployed resources are retained for recovery. Fix or register the application's actual native owner-claim integration in its adapter and setup manifest, then rerun ${again} using the same environment credentials.`;
|
|
25
|
+
}
|
package/cli/deploy.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { packageBuild } from '../modules/deploy-kit/prepare.mjs';
|
|
|
8
8
|
import { refuseLocalModels } from '../modules/deploy-kit/local-only.mjs';
|
|
9
9
|
import { deployEnvironment, deployAgain } from './deploy-inputs.mjs';
|
|
10
10
|
import { claimHostedOwner } from './deploy-owner.mjs';
|
|
11
|
+
import { checkHostedSetup, hostedSetupFailure } from './deploy-setup.mjs';
|
|
11
12
|
import { mutationReadinessFailure } from './deploy-readiness.mjs';
|
|
12
13
|
import { committedSource } from './deploy-source.mjs';
|
|
13
14
|
import { hookState, forgetHookState } from './deploy-hook-record.mjs';
|
|
@@ -79,7 +80,6 @@ export function ownerDeploy(declarationPath, lifecycle) {
|
|
|
79
80
|
if (sent.length) store.report(`rer supplied ${sent.join(', ')} from the local setup owner and fresh generated values.`);
|
|
80
81
|
step = 'health';
|
|
81
82
|
await owner('health');
|
|
82
|
-
store.report(`Your application is live on your Cloudflare account at ${deployed.origin}.`);
|
|
83
83
|
step = 'claim owner';
|
|
84
84
|
const { liveSecrets, retiredSecrets, ownerClaim } = await owner('inspect');
|
|
85
85
|
const linked = token => linkDependencies?.(deployed.origin, token);
|
|
@@ -87,6 +87,9 @@ export function ownerDeploy(declarationPath, lifecycle) {
|
|
|
87
87
|
secret: (extra, values) => owner('secret', extra, values), beforeClaim: linked, recordClaim: outcome => owner('record-owner', ['--outcome', outcome]), inspect: () => owner('inspect'), store, signal });
|
|
88
88
|
// A seed that claims its owner its own way links with the token it was given.
|
|
89
89
|
if (claimed === undefined) await linked(env[declared(claim?.tokenField ?? 'SETUP_TOKEN')?.environment]);
|
|
90
|
+
step = 'verify hosted setup';
|
|
91
|
+
await checkHostedSetup({ origin: deployed.origin, claimed: claimed ?? ownerClaim?.outcome, signal });
|
|
92
|
+
store.report(`Your application is live on your Cloudflare account at ${deployed.origin}.`);
|
|
90
93
|
// The app claims the OWNER_EMAIL the Worker holds: the local one only when this run uploaded it.
|
|
91
94
|
const email = declared(claim?.emailField);
|
|
92
95
|
const named = !email ? '' : deployed.sentSecrets.includes(email.binding) && env[email.environment] ? ` (${env[email.environment]})` : ` (the ${email.binding} already set on the Worker)`;
|
|
@@ -102,6 +105,8 @@ export function ownerDeploy(declarationPath, lifecycle) {
|
|
|
102
105
|
|
|
103
106
|
// The failing step, its redacted cause, what this run created and the command that continues.
|
|
104
107
|
function failureText({ error, step, created, again, retry, secretChange, deployed, redact }) {
|
|
108
|
+
const setup = hostedSetupFailure(error, { origin: deployed?.origin, again });
|
|
109
|
+
if (setup) return redact(setup);
|
|
105
110
|
const readiness = mutationReadinessFailure(error, { again, redact });
|
|
106
111
|
if (readiness) return readiness;
|
|
107
112
|
const diagnostic = deployDiagnostic(error, redact);
|
package/global/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.13
|
|
4
|
+
|
|
5
|
+
- `rer deploy --remove` accepts empty owned R2 object listings without pagination metadata, fixing the 0.2.9 regression. Populated or malformed listings still require complete pagination proof before deletion.
|
|
6
|
+
- Workerd container images may use `HTMLRewriter`, including hosted demo images. Engines without that API still refuse it.
|
|
7
|
+
- A deploy whose hosted app explicitly reports setup required without a confirmed owner claim exits 1 with the recovery step. The live announcement follows owner handling and the setup check.
|
|
8
|
+
|
|
9
|
+
### Upgrade notes
|
|
10
|
+
|
|
11
|
+
- Update the rer package to receive these deploy fixes. An app with an unregistered native owner claim still needs that integration repaired; rer now reports the incomplete deployment and retains its resources for recovery.
|
|
12
|
+
|
|
3
13
|
## 0.2.12
|
|
4
14
|
|
|
5
15
|
- Import-kit resumable field redaction finishes however large one import job is. A step takes as many jobs as fit the request (at most 25); a job that does not fit alone is redacted in pages of its entries, and a step that would not fit writes nothing and is retried smaller, so every committed step stays inside D1's per-request limit and the erasure reaches its final batch. Receipts and match counts are unchanged.
|
|
@@ -25,7 +25,7 @@ export async function checkBoundary(root, { engine='node', cacheContract }={}) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
if(ts.isCallExpression(node)&&node.arguments.some(arg=>ts.isStringLiteral(arg)&&arg.text.startsWith('cloudflare:')))fail('Dynamic Cloudflare import');
|
|
28
|
-
if(ts.isIdentifier(node)&&['WebSocketPair','
|
|
28
|
+
if(ts.isIdentifier(node)&&(['WebSocketPair','passThroughOnException','timingSafeEqual'].includes(node.text)||(node.text==='HTMLRewriter'&&engine!=='workerd')))fail(node.text);
|
|
29
29
|
if(ts.isCallExpression(node)&&ts.isIdentifier(node.expression)&&node.expression.text==='email'&&!localNames.has('email'))fail('email()');
|
|
30
30
|
if(ts.isPropertyAccessExpression(node)&&((node.expression.getText(tree)==='caches'&&node.name.text==='default')||(node.expression.getText(tree)==='request'&&node.name.text==='cf')))fail(node.getText(tree));
|
|
31
31
|
if(ts.isElementAccessExpression(node)&&ts.isStringLiteral(node.argumentExpression)&&((node.expression.getText(tree)==='caches'&&node.argumentExpression.text==='default')||(node.expression.getText(tree)==='request'&&node.argumentExpression.text==='cf')))fail(node.getText(tree));
|
|
@@ -22,6 +22,9 @@ export async function* r2ObjectPages(api, bucket) {
|
|
|
22
22
|
const data = await api.envelope(`/r2/buckets/${bucket}/objects?per_page=1000${cursor ? `&cursor=${encodeURIComponent(cursor)}` : ''}`);
|
|
23
23
|
const rows = data.result, info = data.result_info;
|
|
24
24
|
assert(Array.isArray(rows) && rows.length <= 1000 && rows.every(row => typeof row?.key === 'string' && row.key.length), 'invalid-r2-object-list');
|
|
25
|
+
// Empty object listings may omit pagination or return null. Only that
|
|
26
|
+
// shape proves completion without explicit pagination evidence.
|
|
27
|
+
if (rows.length === 0 && info == null) { yield rows; return; }
|
|
25
28
|
assert(info && typeof info.is_truncated === 'boolean' && (!info.delimited || Array.isArray(info.delimited) && !info.delimited.length), 'provider-incomplete-pagination');
|
|
26
29
|
assert(new Set(rows.map(row => row.key)).size === rows.length, 'invalid-r2-object-list');
|
|
27
30
|
if (info.is_truncated) {
|