td-ai-tools 1.5.2 → 1.6.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/package.json +1 -1
- package/skills/README.md +2 -7
- package/skills/barrage/scripts/__pycache__/build_queue.cpython-312.pyc +0 -0
- package/skills/barrage/scripts/__pycache__/manage_queue.cpython-312.pyc +0 -0
- package/skills/barrage/scripts/__pycache__/queue_paths.cpython-312.pyc +0 -0
- package/skills/cloudflare/SKILL.md +11 -3
- package/skills/cloudflare/assets/wrangler.jsonc +11 -9
- package/skills/cloudflare/references/auth-and-accounts.md +6 -4
- package/skills/cloudflare/references/ci-cd.md +11 -6
- package/skills/cloudflare/references/data-d1-kv-r2.md +4 -4
- package/skills/cloudflare/references/deploy-and-release.md +2 -2
- package/skills/cloudflare/references/domains-and-dns.md +1 -1
- package/skills/cloudflare/references/forms-email-turnstile.md +1 -1
- package/skills/cloudflare/references/launch-new-site.md +30 -49
- package/skills/cloudflare/references/observability-and-incidents.md +1 -1
- package/skills/cloudflare/scripts/cf-api.sh +4 -3
- package/skills/cloudflare/scripts/preflight.sh +1 -0
- package/skills/cloudflare-init/SKILL.md +101 -0
- package/skills/cloudflare-init/agents/openai.yaml +4 -0
- package/skills/cloudflare-init/assets/placeholder-worker.js +15 -0
- package/skills/cloudflare-init/assets/worker.emdash.ts +10 -0
- package/skills/cloudflare-init/assets/wrangler.jsonc +65 -0
- package/skills/cloudflare-init/scripts/cloudflare-init.mjs +598 -0
- package/skills/shopify-lint/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/skills/shopify-lint/scripts/__pycache__/shopify_lint.cpython-312.pyc +0 -0
- package/skills/shopify-lint/tests/__pycache__/test_shopify_lint.cpython-312.pyc +0 -0
- package/skills/shopify-pre-pr/scripts/__pycache__/test_vendor_change_audit.cpython-312.pyc +0 -0
- package/skills/shopify-pre-pr/scripts/__pycache__/vendor_change_audit.cpython-312.pyc +0 -0
- package/skills/visual-regression/scripts/__pycache__/visual_regression.cpython-312.pyc +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Generated by cloudflare-init ({{VARIANT}} site). Names follow the cloudflare-init naming standard:
|
|
2
|
+
// the Worker is the project slug, and each resource is `<slug>-<binding>`. Don't rename them by hand.
|
|
3
|
+
{
|
|
4
|
+
"$schema": "node_modules/wrangler/config-schema.json",
|
|
5
|
+
"name": "{{SLUG}}",
|
|
6
|
+
// {{ACCOUNT_NAME}}. Pins every wrangler command in this repo to it.
|
|
7
|
+
"account_id": "{{ACCOUNT_ID}}",
|
|
8
|
+
"compatibility_date": "{{COMPAT_DATE}}",
|
|
9
|
+
//#if emdash
|
|
10
|
+
"compatibility_flags": ["nodejs_compat"],
|
|
11
|
+
// EmDash's Worker entry: the adapter's handler plus the scheduled handler (scheduled publishing, cleanup).
|
|
12
|
+
"main": "./src/worker.ts",
|
|
13
|
+
"triggers": { "crons": ["* * * * *"] },
|
|
14
|
+
//#endif
|
|
15
|
+
|
|
16
|
+
// Launch: once the zone is active on Cloudflare, attach the domain here (cloudflare skill,
|
|
17
|
+
// references/launch-new-site.md, phase 9) and switch the Leyline workflow's production-url.
|
|
18
|
+
// "routes": [
|
|
19
|
+
// { "pattern": "<domain>", "custom_domain": true },
|
|
20
|
+
// { "pattern": "www.<domain>", "custom_domain": true },
|
|
21
|
+
// ],
|
|
22
|
+
// Until launch the site is served (noindex) at https://{{WORKERS_DEV_HOST}}.
|
|
23
|
+
"workers_dev": true,
|
|
24
|
+
// Per-version preview URLs: the Leyline update pipeline tests each PR on one.
|
|
25
|
+
"preview_urls": true,
|
|
26
|
+
|
|
27
|
+
"observability": { "enabled": true, "head_sampling_rate": 1 },
|
|
28
|
+
//#if turnstile
|
|
29
|
+
|
|
30
|
+
// Turnstile widget "{{SLUG}}" (managed). TURNSTILE_SECRET_KEY is a Worker secret.
|
|
31
|
+
"vars": { "PUBLIC_TURNSTILE_SITE_KEY": "{{TURNSTILE_SITEKEY}}" },
|
|
32
|
+
//#endif
|
|
33
|
+
|
|
34
|
+
// Secrets (never in this file): FORM_SIGNING_SECRET{{SECRETS_EXTRA}}
|
|
35
|
+
// local: .dev.vars production: set by cloudflare-init (npx wrangler secret put NAME to rotate)
|
|
36
|
+
|
|
37
|
+
"d1_databases": [
|
|
38
|
+
{
|
|
39
|
+
"binding": "DB",
|
|
40
|
+
//#if emdash
|
|
41
|
+
// EmDash content and Leyline form submissions.
|
|
42
|
+
//#endif
|
|
43
|
+
"database_name": "{{SLUG}}-db",
|
|
44
|
+
"database_id": "{{D1_ID}}",
|
|
45
|
+
"migrations_dir": "migrations",
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
// Astro sessions (the adapter binds SESSION). Declared so wrangler doesn't auto-provision another one.
|
|
49
|
+
"kv_namespaces": [{ "binding": "SESSION", "id": "{{KV_ID}}" }],
|
|
50
|
+
//#if emdash
|
|
51
|
+
// EmDash media library.
|
|
52
|
+
"r2_buckets": [{ "binding": "MEDIA", "bucket_name": "{{SLUG}}-media" }],
|
|
53
|
+
//#endif
|
|
54
|
+
|
|
55
|
+
// Cloudflare Email Sending for form notifications and visitor confirmations.
|
|
56
|
+
// Launch: `npx wrangler email sending enable <domain>`, then lock the sender:
|
|
57
|
+
// "allowed_sender_addresses": ["web@<domain>"]
|
|
58
|
+
"send_email": [{ "name": "EMAIL" }],
|
|
59
|
+
|
|
60
|
+
// Form rate limiting. namespace_id is allocated by cloudflare-init and unique in the account:
|
|
61
|
+
// never copy it from another site, or the sites share counters.
|
|
62
|
+
"ratelimits": [
|
|
63
|
+
{ "name": "FORM_RATE_LIMITER", "namespace_id": "{{RATELIMIT_ID}}", "simple": { "limit": 5, "period": 60 } },
|
|
64
|
+
],
|
|
65
|
+
}
|
|
@@ -0,0 +1,598 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// cloudflare-init: provisions the Cloudflare side of a new Leyline site before its domain exists,
|
|
3
|
+
// with standard names. Read-only plan by default; --apply makes the changes. Idempotent: anything
|
|
4
|
+
// that already exists under its standard name is reused, so re-running finishes a partial run.
|
|
5
|
+
//
|
|
6
|
+
// Usage: cloudflare-init.mjs <slug> [options]
|
|
7
|
+
// --emdash EmDash site (default: static). Adds R2 media, nodejs_compat, the cron entry.
|
|
8
|
+
// --apply Make the changes. Without it, print the plan and change nothing.
|
|
9
|
+
// --dir <path> Site repo to write wrangler.jsonc, .dev.vars (and src/worker.ts) into. Default: .
|
|
10
|
+
// --repo <owner/name> GitHub repo for Workers Builds. Default: Theory-Digital/<slug>
|
|
11
|
+
// --location <hint> D1/R2 location hint (wnam, enam, weur, eeur, apac, oc). Default: wnam
|
|
12
|
+
// --no-turnstile Skip the Turnstile widget, var and secret.
|
|
13
|
+
// --account <id> Cloudflare account. Default: Theory Digital (Kyle@theorydigital.ca's Account)
|
|
14
|
+
// --only <steps> Comma list of: resources,config,worker,secrets,builds. Default: all.
|
|
15
|
+
// --build-token <uuid> Workers Builds build token, when the account has more than one.
|
|
16
|
+
// --allow-similar Proceed despite near-miss names (e.g. accessmatting vs access-matting).
|
|
17
|
+
// --write-config Overwrite an existing wrangler.jsonc that differs from the standard one.
|
|
18
|
+
//
|
|
19
|
+
// Auth: CLOUDFLARE_API_TOKEN, else CLOUDFLARE_TOKEN (never printed). Needs Workers Scripts, D1,
|
|
20
|
+
// Workers KV, Workers R2, Turnstile and Workers Builds Configuration edit on the account (user-owned
|
|
21
|
+
// token: the Builds API rejects account-owned ones). NPM_TOKEN (npm read token) is set on the build
|
|
22
|
+
// triggers when exported. `gh` must be logged in for the builds step.
|
|
23
|
+
// Exit codes: 0 ok, 1 error, 2 usage, 3 plan has clashes.
|
|
24
|
+
|
|
25
|
+
import { execFileSync } from 'node:child_process';
|
|
26
|
+
import { randomBytes } from 'node:crypto';
|
|
27
|
+
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
28
|
+
import { tmpdir } from 'node:os';
|
|
29
|
+
import { dirname, join, resolve } from 'node:path';
|
|
30
|
+
import { fileURLToPath } from 'node:url';
|
|
31
|
+
|
|
32
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
33
|
+
const ASSETS = join(HERE, '..', 'assets');
|
|
34
|
+
const API = 'https://api.cloudflare.com/client/v4';
|
|
35
|
+
const DEFAULT_ACCOUNT = 'cfb16515b630dbcddca02b1f6a2585ca';
|
|
36
|
+
const GH_ORG = 'Theory-Digital';
|
|
37
|
+
const SLUG_RE = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
|
|
38
|
+
const LOCATIONS = ['wnam', 'enam', 'weur', 'eeur', 'apac', 'oc'];
|
|
39
|
+
const STEPS = ['resources', 'config', 'worker', 'secrets', 'builds'];
|
|
40
|
+
const RATELIMIT_BASE = 1000; // first allocated ID is 1001
|
|
41
|
+
const TURNSTILE_TEST = { site: '1x00000000000000000000AA', secret: '1x0000000000000000000000000000000AA' };
|
|
42
|
+
const TRIGGERS = {
|
|
43
|
+
production: {
|
|
44
|
+
trigger_name: 'Deploy production',
|
|
45
|
+
branch_includes: ['main'],
|
|
46
|
+
branch_excludes: [],
|
|
47
|
+
build_command: 'npm run build',
|
|
48
|
+
deploy_command: 'npx wrangler d1 migrations apply DB --remote && npx wrangler deploy',
|
|
49
|
+
},
|
|
50
|
+
preview: {
|
|
51
|
+
trigger_name: 'Preview other branches',
|
|
52
|
+
branch_includes: ['*'],
|
|
53
|
+
branch_excludes: ['main'],
|
|
54
|
+
build_command: 'npm run build',
|
|
55
|
+
deploy_command: 'npx wrangler versions upload',
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// --- args -----------------------------------------------------------------------------------
|
|
60
|
+
|
|
61
|
+
function usage(code = 2) {
|
|
62
|
+
const text = readFileSync(fileURLToPath(import.meta.url), 'utf8').split('\n');
|
|
63
|
+
console.error(text.slice(1, 23).map((l) => l.replace(/^\/\/ ?/, '')).join('\n'));
|
|
64
|
+
process.exit(code);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const opts = { emdash: false, apply: false, dir: '.', location: 'wnam', turnstile: true, account: DEFAULT_ACCOUNT, only: STEPS, allowSimilar: false, writeConfig: false };
|
|
68
|
+
{
|
|
69
|
+
const argv = process.argv.slice(2);
|
|
70
|
+
const take = (i, flag) => {
|
|
71
|
+
if (argv[i + 1] === undefined || argv[i + 1].startsWith('--')) die(`${flag} needs a value`, 2);
|
|
72
|
+
return argv[i + 1];
|
|
73
|
+
};
|
|
74
|
+
for (let i = 0; i < argv.length; i++) {
|
|
75
|
+
const a = argv[i];
|
|
76
|
+
switch (a) {
|
|
77
|
+
case '-h': case '--help': usage(0); break;
|
|
78
|
+
case '--emdash': opts.emdash = true; break;
|
|
79
|
+
case '--apply': opts.apply = true; break;
|
|
80
|
+
case '--no-turnstile': opts.turnstile = false; break;
|
|
81
|
+
case '--allow-similar': opts.allowSimilar = true; break;
|
|
82
|
+
case '--write-config': opts.writeConfig = true; break;
|
|
83
|
+
case '--dir': opts.dir = take(i++, a); break;
|
|
84
|
+
case '--repo': opts.repo = take(i++, a); break;
|
|
85
|
+
case '--location': opts.location = take(i++, a); break;
|
|
86
|
+
case '--account': opts.account = take(i++, a); break;
|
|
87
|
+
case '--build-token': opts.buildToken = take(i++, a); break;
|
|
88
|
+
case '--only': opts.only = take(i++, a).split(',').map((s) => s.trim()).filter(Boolean); break;
|
|
89
|
+
default:
|
|
90
|
+
if (a.startsWith('-')) die(`unknown option ${a}`, 2);
|
|
91
|
+
if (opts.slug) die('one slug only', 2);
|
|
92
|
+
opts.slug = a;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (!opts.slug) usage();
|
|
96
|
+
if (!SLUG_RE.test(opts.slug) || opts.slug.length > 40)
|
|
97
|
+
die(`slug "${opts.slug}" must be kebab-case brand words (a-z, 0-9, single hyphens), at most 40 characters`, 2);
|
|
98
|
+
if (!LOCATIONS.includes(opts.location)) die(`--location must be one of ${LOCATIONS.join(', ')}`, 2);
|
|
99
|
+
for (const s of opts.only) if (!STEPS.includes(s)) die(`--only takes ${STEPS.join(',')}`, 2);
|
|
100
|
+
opts.repo ??= `${GH_ORG}/${opts.slug}`;
|
|
101
|
+
opts.dir = resolve(opts.dir);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const S = opts.slug;
|
|
105
|
+
const NAMES = {
|
|
106
|
+
worker: S,
|
|
107
|
+
d1: `${S}-db`,
|
|
108
|
+
kv: `${S}-session`,
|
|
109
|
+
r2: `${S}-media`,
|
|
110
|
+
turnstile: S,
|
|
111
|
+
};
|
|
112
|
+
const wants = (step) => opts.only.includes(step);
|
|
113
|
+
const TOKEN = process.env.CLOUDFLARE_API_TOKEN || process.env.CLOUDFLARE_TOKEN;
|
|
114
|
+
if (!TOKEN) die('set CLOUDFLARE_TOKEN (or CLOUDFLARE_API_TOKEN); see the cloudflare skill, references/auth-and-accounts.md');
|
|
115
|
+
|
|
116
|
+
// --- helpers --------------------------------------------------------------------------------
|
|
117
|
+
|
|
118
|
+
function die(msg, code = 1) {
|
|
119
|
+
console.error(`cloudflare-init: ${msg}`);
|
|
120
|
+
process.exit(code);
|
|
121
|
+
}
|
|
122
|
+
const norm = (s) => s.toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
123
|
+
const ACC = `/accounts/${opts.account}`;
|
|
124
|
+
|
|
125
|
+
class ApiError extends Error {
|
|
126
|
+
constructor(method, path, errors) {
|
|
127
|
+
super(`${method} ${path}: ${errors.map((e) => `${e.code} ${e.message}`).join('; ') || 'request failed'}`);
|
|
128
|
+
this.codes = errors.map((e) => e.code);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function api(method, path, body, { raw = false } = {}) {
|
|
133
|
+
const init = { method, headers: { Authorization: `Bearer ${TOKEN}` } };
|
|
134
|
+
if (body instanceof FormData) init.body = body;
|
|
135
|
+
else if (body !== undefined) {
|
|
136
|
+
init.headers['Content-Type'] = 'application/json';
|
|
137
|
+
init.body = JSON.stringify(body);
|
|
138
|
+
}
|
|
139
|
+
const res = await fetch(API + path, init);
|
|
140
|
+
const json = await res.json().catch(() => ({ success: false, errors: [{ code: res.status, message: res.statusText }] }));
|
|
141
|
+
if (!json.success) throw new ApiError(method, path, json.errors ?? []);
|
|
142
|
+
return raw ? json : json.result;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async function listAll(path, pick = (r) => r) {
|
|
146
|
+
const out = [];
|
|
147
|
+
for (let page = 1; ; page++) {
|
|
148
|
+
const sep = path.includes('?') ? '&' : '?';
|
|
149
|
+
const json = await api('GET', `${path}${sep}page=${page}&per_page=100`, undefined, { raw: true });
|
|
150
|
+
const items = pick(json.result) ?? [];
|
|
151
|
+
out.push(...items);
|
|
152
|
+
const info = json.result_info;
|
|
153
|
+
if (!info || items.length < 100 || (info.total_pages && page >= info.total_pages)) break;
|
|
154
|
+
}
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function gh(args, json = true) {
|
|
159
|
+
try {
|
|
160
|
+
const out = execFileSync('gh', args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: 64 * 1024 * 1024 });
|
|
161
|
+
return json ? JSON.parse(out) : out;
|
|
162
|
+
} catch {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Strips comments and trailing commas from JSONC, leaving strings alone. */
|
|
168
|
+
function parseJsonc(text) {
|
|
169
|
+
let out = '';
|
|
170
|
+
for (let i = 0; i < text.length; i++) {
|
|
171
|
+
const c = text[i];
|
|
172
|
+
if (c === '"') {
|
|
173
|
+
let j = i + 1;
|
|
174
|
+
while (j < text.length && text[j] !== '"') j += text[j] === '\\' ? 2 : 1;
|
|
175
|
+
out += text.slice(i, j + 1);
|
|
176
|
+
i = j;
|
|
177
|
+
} else if (c === '/' && text[i + 1] === '/') {
|
|
178
|
+
while (i < text.length && text[i] !== '\n') i++;
|
|
179
|
+
out += '\n';
|
|
180
|
+
} else if (c === '/' && text[i + 1] === '*') {
|
|
181
|
+
i = text.indexOf('*/', i + 2) + 1;
|
|
182
|
+
} else out += c;
|
|
183
|
+
}
|
|
184
|
+
return JSON.parse(out.replace(/,(\s*[}\]])/g, '$1'));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const rows = [];
|
|
188
|
+
let clashes = 0;
|
|
189
|
+
function row(kind, name, status, detail = '') {
|
|
190
|
+
rows.push({ kind, name, status, detail });
|
|
191
|
+
if (status === 'CLASH') clashes++;
|
|
192
|
+
}
|
|
193
|
+
function printRows() {
|
|
194
|
+
const w = [0, 0, 0].map((_, i) => Math.max(...rows.map((r) => [r.kind, r.name, r.status][i].length)));
|
|
195
|
+
for (const r of rows) console.log(` ${r.kind.padEnd(w[0])} ${r.name.padEnd(w[1])} ${r.status.padEnd(w[2])} ${r.detail}`);
|
|
196
|
+
rows.length = 0;
|
|
197
|
+
}
|
|
198
|
+
const step = (t) => console.log(`\n▶ ${t}`);
|
|
199
|
+
const verb = (created) => (opts.apply ? (created ? 'created' : 'exists') : created ? 'create' : 'exists');
|
|
200
|
+
|
|
201
|
+
// --- 1. preflight ---------------------------------------------------------------------------
|
|
202
|
+
|
|
203
|
+
step(`Preflight: ${S} (${opts.emdash ? 'EmDash' : 'static'}), ${opts.apply ? 'APPLY' : 'plan only'}`);
|
|
204
|
+
let account;
|
|
205
|
+
try {
|
|
206
|
+
await api('GET', '/user/tokens/verify');
|
|
207
|
+
account = await api('GET', ACC);
|
|
208
|
+
} catch (e) {
|
|
209
|
+
die(`token check failed (${e.message}). The token must be user-owned and see account ${opts.account}.`);
|
|
210
|
+
}
|
|
211
|
+
const subdomain = (await api('GET', `${ACC}/workers/subdomain`)).subdomain;
|
|
212
|
+
const host = `${S}.${subdomain}.workers.dev`;
|
|
213
|
+
console.log(` account ${account.name} (${account.id})`);
|
|
214
|
+
console.log(` host https://${host}`);
|
|
215
|
+
|
|
216
|
+
const [workers, d1s, kvs, r2s, widgets] = await Promise.all([
|
|
217
|
+
api('GET', `${ACC}/workers/scripts`),
|
|
218
|
+
listAll(`${ACC}/d1/database`),
|
|
219
|
+
listAll(`${ACC}/storage/kv/namespaces`),
|
|
220
|
+
api('GET', `${ACC}/r2/buckets?per_page=1000`).then((r) => r.buckets ?? []),
|
|
221
|
+
listAll(`${ACC}/challenges/widgets`),
|
|
222
|
+
]);
|
|
223
|
+
const existing = {
|
|
224
|
+
worker: workers.map((w) => ({ name: w.id, id: w.tag })),
|
|
225
|
+
d1: d1s.map((d) => ({ name: d.name, id: d.uuid })),
|
|
226
|
+
kv: kvs.map((k) => ({ name: k.title, id: k.id })),
|
|
227
|
+
r2: r2s.map((b) => ({ name: b.name, id: b.name })),
|
|
228
|
+
turnstile: widgets.map((w) => ({ name: w.name, id: w.sitekey })),
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// Near-miss guard: anything whose normalized name matches one of this project's standard names
|
|
232
|
+
// (or the bare slug) but isn't the exact standard name for its kind.
|
|
233
|
+
const targets = new Set([S, ...Object.values(NAMES)].map(norm));
|
|
234
|
+
for (const [kind, list] of Object.entries(existing)) {
|
|
235
|
+
for (const r of list) {
|
|
236
|
+
if (r.name === NAMES[kind]) continue;
|
|
237
|
+
if (targets.has(norm(r.name))) row(kind, r.name, 'CLASH', `near-miss of ${NAMES[kind]}: rename, reuse it deliberately, or pick another slug`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
const orgRepos = gh(['api', '--paginate', `orgs/${GH_ORG}/repos?per_page=100`, '--jq', '.[].name'], false)?.split('\n').filter(Boolean) ?? [];
|
|
241
|
+
if (!orgRepos.length) console.log(` ! couldn't list ${GH_ORG} repos (gh auth status?): repo near-miss check skipped`);
|
|
242
|
+
const repoName = opts.repo.split('/')[1];
|
|
243
|
+
for (const r of orgRepos) {
|
|
244
|
+
if (r !== repoName && norm(r) === norm(S)) row('repo', `${GH_ORG}/${r}`, 'CLASH', `near-miss of ${opts.repo}; pass --repo ${GH_ORG}/${r} if this is the site`);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const pkgPath = join(opts.dir, 'package.json');
|
|
248
|
+
const pkg = existsSync(pkgPath) ? JSON.parse(readFileSync(pkgPath, 'utf8')) : null;
|
|
249
|
+
if (pkg) {
|
|
250
|
+
const hasEmdash = Boolean(pkg.dependencies?.emdash ?? pkg.devDependencies?.emdash);
|
|
251
|
+
if (hasEmdash !== opts.emdash)
|
|
252
|
+
console.log(` ! ${pkgPath} ${hasEmdash ? 'depends on emdash but --emdash is off' : 'has no emdash dependency but --emdash is on'}`);
|
|
253
|
+
} else {
|
|
254
|
+
console.log(` ! no package.json in ${opts.dir}: local files (wrangler.jsonc, .dev.vars) are skipped`);
|
|
255
|
+
}
|
|
256
|
+
if (rows.length) printRows();
|
|
257
|
+
if (clashes && !opts.allowSimilar) {
|
|
258
|
+
console.log(`\n${clashes} near-miss name(s). Nothing was changed. Resolve them or re-run with --allow-similar.`);
|
|
259
|
+
process.exit(3);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// --- 2. resources ---------------------------------------------------------------------------
|
|
263
|
+
|
|
264
|
+
step('Resources');
|
|
265
|
+
const find = (kind) => existing[kind].find((r) => r.name === NAMES[kind]);
|
|
266
|
+
const ids = {};
|
|
267
|
+
const pending = '<created on apply>';
|
|
268
|
+
const canCreate = opts.apply && wants('resources');
|
|
269
|
+
|
|
270
|
+
async function ensure(kind, label, create) {
|
|
271
|
+
const hit = find(kind);
|
|
272
|
+
if (hit) {
|
|
273
|
+
ids[kind] = hit.id;
|
|
274
|
+
row(label, NAMES[kind], verb(false), hit.id);
|
|
275
|
+
} else if (canCreate) {
|
|
276
|
+
ids[kind] = await create();
|
|
277
|
+
row(label, NAMES[kind], verb(true), ids[kind]);
|
|
278
|
+
} else {
|
|
279
|
+
ids[kind] = pending;
|
|
280
|
+
row(label, NAMES[kind], wants('resources') ? 'create' : 'MISSING', wants('resources') ? '' : '(not in --only)');
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
await ensure('d1', 'D1 DB', async () =>
|
|
285
|
+
(await api('POST', `${ACC}/d1/database`, { name: NAMES.d1, primary_location_hint: opts.location })).uuid,
|
|
286
|
+
);
|
|
287
|
+
await ensure('kv', 'KV SESSION', async () =>
|
|
288
|
+
(await api('POST', `${ACC}/storage/kv/namespaces`, { title: NAMES.kv })).id,
|
|
289
|
+
);
|
|
290
|
+
if (opts.emdash) {
|
|
291
|
+
await ensure('r2', 'R2 MEDIA', async () => {
|
|
292
|
+
await api('POST', `${ACC}/r2/buckets`, { name: NAMES.r2, locationHint: opts.location });
|
|
293
|
+
return NAMES.r2;
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
let turnstileSecret;
|
|
297
|
+
if (opts.turnstile) {
|
|
298
|
+
const domains = [host, `${subdomain}.workers.dev`];
|
|
299
|
+
await ensure('turnstile', 'Turnstile', async () => {
|
|
300
|
+
const w = await api('POST', `${ACC}/challenges/widgets`, { name: NAMES.turnstile, domains, mode: 'managed' });
|
|
301
|
+
turnstileSecret = w.secret;
|
|
302
|
+
return w.sitekey;
|
|
303
|
+
});
|
|
304
|
+
const w = widgets.find((x) => x.name === NAMES.turnstile);
|
|
305
|
+
const missing = w ? domains.filter((d) => !w.domains.includes(d)) : [];
|
|
306
|
+
if (missing.length) console.log(` ! widget ${w.sitekey} lacks ${missing.join(', ')}; add them (cloudflare skill, forms-email-turnstile.md)`);
|
|
307
|
+
}
|
|
308
|
+
if (!opts.apply && wants('resources')) {
|
|
309
|
+
const loc = opts.location.toUpperCase();
|
|
310
|
+
console.log(` D1 location ${loc}${opts.emdash ? `, R2 location ${loc}` : ''}${opts.turnstile ? `, Turnstile domains ${host}, ${subdomain}.workers.dev` : ''}`);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Rate-limit namespace: reuse this Worker's, else one above the highest bound in the account.
|
|
314
|
+
const settings = {};
|
|
315
|
+
await Promise.all(
|
|
316
|
+
workers.map(async (w) => {
|
|
317
|
+
settings[w.id] = await api('GET', `${ACC}/workers/scripts/${w.id}/settings`).catch(() => ({ bindings: [] }));
|
|
318
|
+
}),
|
|
319
|
+
);
|
|
320
|
+
const own = settings[S]?.bindings?.find((b) => b.type === 'ratelimit' && b.name === 'FORM_RATE_LIMITER');
|
|
321
|
+
const used = Object.values(settings).flatMap((s) => s.bindings.filter((b) => b.type === 'ratelimit').map((b) => Number(b.namespace_id)));
|
|
322
|
+
ids.ratelimit = own ? String(own.namespace_id) : String(Math.max(RATELIMIT_BASE, ...used.filter(Number.isFinite)) + 1);
|
|
323
|
+
row('Rate limit', 'FORM_RATE_LIMITER', own ? 'exists' : 'allocate', `namespace_id ${ids.ratelimit}`);
|
|
324
|
+
printRows();
|
|
325
|
+
|
|
326
|
+
// --- 3. config ------------------------------------------------------------------------------
|
|
327
|
+
|
|
328
|
+
const configPath = join(opts.dir, 'wrangler.jsonc');
|
|
329
|
+
let current = null;
|
|
330
|
+
if (existsSync(configPath)) {
|
|
331
|
+
try {
|
|
332
|
+
current = parseJsonc(readFileSync(configPath, 'utf8'));
|
|
333
|
+
} catch (e) {
|
|
334
|
+
console.log(` ! could not parse ${configPath}: ${e.message}`);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
const compatDate = current?.compatibility_date ?? new Date().toISOString().slice(0, 10);
|
|
338
|
+
|
|
339
|
+
function render() {
|
|
340
|
+
const flags = { emdash: opts.emdash, turnstile: opts.turnstile };
|
|
341
|
+
const vals = {
|
|
342
|
+
VARIANT: opts.emdash ? 'EmDash' : 'static',
|
|
343
|
+
SLUG: S,
|
|
344
|
+
ACCOUNT_NAME: account.name,
|
|
345
|
+
ACCOUNT_ID: account.id,
|
|
346
|
+
COMPAT_DATE: compatDate,
|
|
347
|
+
WORKERS_DEV_HOST: host,
|
|
348
|
+
TURNSTILE_SITEKEY: ids.turnstile,
|
|
349
|
+
SECRETS_EXTRA: opts.turnstile ? ', TURNSTILE_SECRET_KEY' : '',
|
|
350
|
+
D1_ID: ids.d1,
|
|
351
|
+
KV_ID: ids.kv,
|
|
352
|
+
RATELIMIT_ID: ids.ratelimit,
|
|
353
|
+
};
|
|
354
|
+
const out = [];
|
|
355
|
+
const stack = [];
|
|
356
|
+
for (const line of readFileSync(join(ASSETS, 'wrangler.jsonc'), 'utf8').split('\n')) {
|
|
357
|
+
const m = line.match(/^\/\/#if (\w+)$/);
|
|
358
|
+
if (m) stack.push(Boolean(flags[m[1]]));
|
|
359
|
+
else if (line === '//#endif') stack.pop();
|
|
360
|
+
else if (stack.every(Boolean)) out.push(line.replace(/\{\{(\w+)\}\}/g, (_, k) => vals[k]));
|
|
361
|
+
}
|
|
362
|
+
return out.join('\n');
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (wants('config')) {
|
|
366
|
+
step('Local files');
|
|
367
|
+
if (!pkg) {
|
|
368
|
+
console.log(' skipped (no package.json in --dir)');
|
|
369
|
+
} else {
|
|
370
|
+
const text = render();
|
|
371
|
+
if (current && current.name !== S) console.log(` ! existing wrangler.jsonc names the Worker "${current.name}", not "${S}"`);
|
|
372
|
+
const prev = existsSync(configPath) ? readFileSync(configPath, 'utf8') : null;
|
|
373
|
+
if (prev === text) row('file', 'wrangler.jsonc', 'up to date');
|
|
374
|
+
else if (prev === null || opts.writeConfig) {
|
|
375
|
+
const ready = !text.includes(pending);
|
|
376
|
+
if (opts.apply && ready) writeFileSync(configPath, text);
|
|
377
|
+
row('file', 'wrangler.jsonc', opts.apply ? (ready ? 'written' : 'NOT written (resources missing)') : prev === null ? 'write' : 'overwrite');
|
|
378
|
+
} else {
|
|
379
|
+
row('file', 'wrangler.jsonc', 'differs', 'kept; diff below, --write-config replaces it');
|
|
380
|
+
const tmp = mkdtempSync(join(tmpdir(), 'cf-init-'));
|
|
381
|
+
writeFileSync(join(tmp, 'wrangler.jsonc'), text);
|
|
382
|
+
try {
|
|
383
|
+
execFileSync('git', ['diff', '--no-index', '--no-color', configPath, join(tmp, 'wrangler.jsonc')], { stdio: 'inherit' });
|
|
384
|
+
} catch {
|
|
385
|
+
/* diff exits 1 when files differ */
|
|
386
|
+
}
|
|
387
|
+
rmSync(tmp, { recursive: true });
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const devVars = join(opts.dir, '.dev.vars');
|
|
391
|
+
if (existsSync(devVars)) row('file', '.dev.vars', 'exists');
|
|
392
|
+
else {
|
|
393
|
+
if (opts.apply) {
|
|
394
|
+
const lines = [
|
|
395
|
+
'# Local secrets for wrangler dev (gitignored). Production values are Worker secrets.',
|
|
396
|
+
`FORM_SIGNING_SECRET=${randomBytes(36).toString('base64')}`,
|
|
397
|
+
];
|
|
398
|
+
if (opts.turnstile) lines.push('# Cloudflare test keys: always pass. Leyline allows them through the action check.', `TURNSTILE_SECRET_KEY=${TURNSTILE_TEST.secret}`);
|
|
399
|
+
writeFileSync(devVars, lines.join('\n') + '\n', { mode: 0o600 });
|
|
400
|
+
}
|
|
401
|
+
row('file', '.dev.vars', opts.apply ? 'written' : 'write', 'dev-only signing secret' + (opts.turnstile ? ', Turnstile test secret' : ''));
|
|
402
|
+
}
|
|
403
|
+
const gi = join(opts.dir, '.gitignore');
|
|
404
|
+
const ignored = existsSync(gi) && /^\.dev\.vars\*?$/m.test(readFileSync(gi, 'utf8'));
|
|
405
|
+
if (!ignored) console.log(' ! .gitignore does not list .dev.vars: add `.dev.vars*` before committing');
|
|
406
|
+
|
|
407
|
+
if (opts.emdash) {
|
|
408
|
+
const entry = join(opts.dir, 'src', 'worker.ts');
|
|
409
|
+
if (existsSync(entry)) row('file', 'src/worker.ts', 'exists');
|
|
410
|
+
else {
|
|
411
|
+
if (opts.apply) {
|
|
412
|
+
mkdirSync(dirname(entry), { recursive: true });
|
|
413
|
+
writeFileSync(entry, readFileSync(join(ASSETS, 'worker.emdash.ts'), 'utf8'));
|
|
414
|
+
}
|
|
415
|
+
row('file', 'src/worker.ts', opts.apply ? 'written' : 'write', 'EmDash entry with the scheduled handler');
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
printRows();
|
|
419
|
+
if (opts.turnstile) console.log(` local dev Turnstile sitekey: set PUBLIC_TURNSTILE_SITE_KEY=${TURNSTILE_TEST.site} in .dev.vars to override the real one`);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// --- 4. worker ------------------------------------------------------------------------------
|
|
424
|
+
|
|
425
|
+
let worker = workers.find((w) => w.id === S);
|
|
426
|
+
if (wants('worker')) {
|
|
427
|
+
step('Worker');
|
|
428
|
+
if (worker) row('Worker', S, 'exists', `tag ${worker.tag}`);
|
|
429
|
+
else if (!opts.apply) row('Worker', S, 'create', 'placeholder (503, noindex) with the site bindings; the first build replaces it');
|
|
430
|
+
else if (Object.values(ids).includes(pending)) row('Worker', S, 'NOT created', 'resources are missing; run with --only resources first');
|
|
431
|
+
else {
|
|
432
|
+
const bindings = [
|
|
433
|
+
{ type: 'd1', name: 'DB', id: ids.d1 },
|
|
434
|
+
{ type: 'kv_namespace', name: 'SESSION', namespace_id: ids.kv },
|
|
435
|
+
{ type: 'send_email', name: 'EMAIL' },
|
|
436
|
+
{ type: 'ratelimit', name: 'FORM_RATE_LIMITER', namespace_id: ids.ratelimit, simple: { limit: 5, period: 60 } },
|
|
437
|
+
];
|
|
438
|
+
if (opts.emdash) bindings.push({ type: 'r2_bucket', name: 'MEDIA', bucket_name: NAMES.r2 });
|
|
439
|
+
if (opts.turnstile) bindings.push({ type: 'plain_text', name: 'PUBLIC_TURNSTILE_SITE_KEY', text: ids.turnstile });
|
|
440
|
+
const metadata = {
|
|
441
|
+
main_module: 'index.js',
|
|
442
|
+
compatibility_date: compatDate,
|
|
443
|
+
compatibility_flags: opts.emdash ? ['nodejs_compat'] : [],
|
|
444
|
+
bindings,
|
|
445
|
+
observability: { enabled: true, head_sampling_rate: 1 },
|
|
446
|
+
};
|
|
447
|
+
const form = new FormData();
|
|
448
|
+
form.append('metadata', new Blob([JSON.stringify(metadata)], { type: 'application/json' }));
|
|
449
|
+
form.append('index.js', new Blob([readFileSync(join(ASSETS, 'placeholder-worker.js'))], { type: 'application/javascript+module' }), 'index.js');
|
|
450
|
+
await api('PUT', `${ACC}/workers/scripts/${S}`, form);
|
|
451
|
+
await api('POST', `${ACC}/workers/scripts/${S}/subdomain`, { enabled: true, previews_enabled: true });
|
|
452
|
+
worker = (await api('GET', `${ACC}/workers/scripts`)).find((w) => w.id === S);
|
|
453
|
+
row('Worker', S, 'created', `tag ${worker.tag}, https://${host}`);
|
|
454
|
+
}
|
|
455
|
+
printRows();
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// --- 5. secrets -----------------------------------------------------------------------------
|
|
459
|
+
|
|
460
|
+
if (wants('secrets')) {
|
|
461
|
+
step('Worker secrets');
|
|
462
|
+
const have = worker ? (await api('GET', `${ACC}/workers/scripts/${S}/secrets`)).map((s) => s.name) : [];
|
|
463
|
+
const wanted = ['FORM_SIGNING_SECRET', ...(opts.turnstile ? ['TURNSTILE_SECRET_KEY'] : [])];
|
|
464
|
+
for (const name of wanted) {
|
|
465
|
+
if (have.includes(name)) row('secret', name, 'exists');
|
|
466
|
+
else if (!opts.apply) row('secret', name, 'set', name === 'FORM_SIGNING_SECRET' ? 'random 48 bytes' : 'from the Turnstile widget');
|
|
467
|
+
else if (!worker) row('secret', name, 'NOT set', 'the Worker does not exist yet');
|
|
468
|
+
else {
|
|
469
|
+
let text;
|
|
470
|
+
if (name === 'FORM_SIGNING_SECRET') text = randomBytes(48).toString('base64');
|
|
471
|
+
else text = turnstileSecret ?? (ids.turnstile !== pending ? (await api('GET', `${ACC}/challenges/widgets/${ids.turnstile}`)).secret : undefined);
|
|
472
|
+
if (!text) row('secret', name, 'NOT set', 'Turnstile widget missing');
|
|
473
|
+
else {
|
|
474
|
+
await api('PUT', `${ACC}/workers/scripts/${S}/secrets`, { name, text, type: 'secret_text' });
|
|
475
|
+
row('secret', name, 'set');
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
printRows();
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// --- 6. Workers Builds ----------------------------------------------------------------------
|
|
483
|
+
|
|
484
|
+
let buildsNote = '';
|
|
485
|
+
if (wants('builds')) {
|
|
486
|
+
step(`Workers Builds (${opts.repo})`);
|
|
487
|
+
const repo = gh(['api', `repos/${opts.repo}`]);
|
|
488
|
+
let tokens = [];
|
|
489
|
+
try {
|
|
490
|
+
tokens = await api('GET', `${ACC}/builds/tokens`);
|
|
491
|
+
} catch (e) {
|
|
492
|
+
buildsNote = `token can't reach the Builds API (${e.message}); it needs Workers Builds Configuration Edit and must be user-owned`;
|
|
493
|
+
}
|
|
494
|
+
const buildToken = opts.buildToken ?? (tokens.length === 1 ? tokens[0].build_token_uuid : undefined);
|
|
495
|
+
if (!buildsNote && !repo) buildsNote = `GitHub repo ${opts.repo} not found (create it, or check \`gh auth status\`), then re-run with --only builds`;
|
|
496
|
+
if (!buildsNote && !buildToken)
|
|
497
|
+
buildsNote = tokens.length ? `the account has ${tokens.length} build tokens; pass --build-token (${tokens.map((t) => `${t.build_token_uuid} "${t.build_token_name}"`).join(', ')})` : 'the account has no build token; create one in the dashboard (Worker → Settings → Builds → API token)';
|
|
498
|
+
if (!buildsNote && !worker) buildsNote = opts.apply ? 'the Worker does not exist yet' : '';
|
|
499
|
+
|
|
500
|
+
if (buildsNote) console.log(` skipped: ${buildsNote}`);
|
|
501
|
+
else if (!worker) {
|
|
502
|
+
for (const t of Object.values(TRIGGERS)) row('trigger', t.trigger_name, 'create', `${t.build_command} / ${t.deploy_command}`);
|
|
503
|
+
row('setting', 'previews_enabled', 'set false');
|
|
504
|
+
row('env', 'NPM_TOKEN', process.env.NPM_TOKEN ? 'set' : 'SKIP', process.env.NPM_TOKEN ? 'secret, both triggers' : 'export NPM_TOKEN (npm read token) first');
|
|
505
|
+
} else {
|
|
506
|
+
const tag = worker.tag;
|
|
507
|
+
const listTriggers = () => api('GET', `${ACC}/builds/workers/${tag}/triggers`).catch((e) => (e.codes.includes(12000) ? [] : Promise.reject(e)));
|
|
508
|
+
const role = (t) => (t.branch_includes?.includes('main') && !t.branch_excludes?.length ? 'production' : t.branch_excludes?.includes('main') ? 'preview' : null);
|
|
509
|
+
let triggers = await listTriggers();
|
|
510
|
+
let connection = triggers[0]?.repo_connection?.repo_connection_uuid;
|
|
511
|
+
if (!connection && opts.apply) {
|
|
512
|
+
connection = (
|
|
513
|
+
await api('PUT', `${ACC}/builds/repos/connections`, {
|
|
514
|
+
provider_type: 'github',
|
|
515
|
+
provider_account_id: String(repo.owner.id),
|
|
516
|
+
provider_account_name: repo.owner.login,
|
|
517
|
+
repo_id: String(repo.id),
|
|
518
|
+
repo_name: repo.name,
|
|
519
|
+
})
|
|
520
|
+
).repo_connection_uuid;
|
|
521
|
+
}
|
|
522
|
+
const create = async (key) => {
|
|
523
|
+
const t = TRIGGERS[key];
|
|
524
|
+
const existingT = triggers.find((x) => role(x) === key);
|
|
525
|
+
if (existingT) {
|
|
526
|
+
const same = existingT.trigger_name === t.trigger_name && existingT.build_command === t.build_command && existingT.deploy_command === t.deploy_command;
|
|
527
|
+
row('trigger', existingT.trigger_name, 'exists', same ? '' : `differs from the standard "${t.trigger_name}": ${t.build_command} / ${t.deploy_command}`);
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
if (!opts.apply) return row('trigger', t.trigger_name, 'create', `${t.build_command} / ${t.deploy_command}`);
|
|
531
|
+
await api('POST', `${ACC}/builds/triggers`, {
|
|
532
|
+
...t,
|
|
533
|
+
external_script_id: tag,
|
|
534
|
+
repo_connection_uuid: connection,
|
|
535
|
+
build_token_uuid: buildToken,
|
|
536
|
+
root_directory: '/',
|
|
537
|
+
path_includes: ['*'],
|
|
538
|
+
path_excludes: [],
|
|
539
|
+
build_caching_enabled: true,
|
|
540
|
+
});
|
|
541
|
+
row('trigger', t.trigger_name, 'created', `${t.build_command} / ${t.deploy_command}`);
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
await create('production');
|
|
545
|
+
// Previews beta off before the preview trigger: turning it off deletes non-production triggers.
|
|
546
|
+
const cfg = await api('GET', `${ACC}/builds/workers/${tag}`).catch(() => null);
|
|
547
|
+
if (cfg?.previews_enabled === false) row('setting', 'previews_enabled', 'false');
|
|
548
|
+
else if (opts.apply) {
|
|
549
|
+
await api('PATCH', `${ACC}/builds/workers/${tag}`, { previews_enabled: false });
|
|
550
|
+
row('setting', 'previews_enabled', 'set false');
|
|
551
|
+
} else row('setting', 'previews_enabled', 'set false');
|
|
552
|
+
triggers = await listTriggers();
|
|
553
|
+
await create('preview');
|
|
554
|
+
|
|
555
|
+
triggers = opts.apply ? await listTriggers() : triggers;
|
|
556
|
+
for (const t of triggers.filter((x) => role(x))) {
|
|
557
|
+
const vars = await api('GET', `${ACC}/builds/triggers/${t.trigger_uuid}/environment_variables`).catch(() => ({}));
|
|
558
|
+
if (vars?.NPM_TOKEN) row('env', `NPM_TOKEN (${t.trigger_name})`, 'exists');
|
|
559
|
+
else if (!process.env.NPM_TOKEN) row('env', `NPM_TOKEN (${t.trigger_name})`, 'SKIP', 'export NPM_TOKEN (npm read token), then re-run --only builds');
|
|
560
|
+
else if (!opts.apply) row('env', `NPM_TOKEN (${t.trigger_name})`, 'set', 'secret');
|
|
561
|
+
else {
|
|
562
|
+
await api('PATCH', `${ACC}/builds/triggers/${t.trigger_uuid}/environment_variables`, { NPM_TOKEN: { value: process.env.NPM_TOKEN, is_secret: true } });
|
|
563
|
+
row('env', `NPM_TOKEN (${t.trigger_name})`, 'set', 'secret');
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
if (!opts.apply && !triggers.length) row('env', 'NPM_TOKEN', process.env.NPM_TOKEN ? 'set' : 'SKIP', process.env.NPM_TOKEN ? 'secret, both triggers' : 'export NPM_TOKEN first');
|
|
567
|
+
}
|
|
568
|
+
printRows();
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
// --- 7. summary -----------------------------------------------------------------------------
|
|
572
|
+
|
|
573
|
+
if (!opts.apply) {
|
|
574
|
+
console.log('\nPlan only: nothing was changed. Re-run with --apply to make these changes.');
|
|
575
|
+
process.exit(clashes ? 3 : 0);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
const repoUrl = `https://github.com/${opts.repo}`;
|
|
579
|
+
console.log(`
|
|
580
|
+
▶ Done. Entry for docs/sites.md (fill in the dates and anything marked TODO):
|
|
581
|
+
|
|
582
|
+
### ${repoName}
|
|
583
|
+
|
|
584
|
+
- Worker \`${S}\` (tag \`${worker?.tag ?? 'TODO'}\`). Compatibility date ${compatDate}${opts.emdash ? ', `nodejs_compat`' : ', no flags'}, observability on.${opts.emdash ? ' Custom entry `src/worker.ts`, with a cron trigger every minute (`* * * * *`).' : ''}
|
|
585
|
+
- Domains: none yet. Pre-launch on https://${host}, which is also the workflow's \`production-url\`.
|
|
586
|
+
- Builds: production "Deploy production" and preview "Preview other branches", \`NPM_TOKEN\` a secret on both.${buildsNote ? ` TODO: ${buildsNote}.` : ''}
|
|
587
|
+
- Bindings:
|
|
588
|
+
- D1 \`DB\` → \`${NAMES.d1}\` (\`${ids.d1}\`, ${opts.location.toUpperCase()})
|
|
589
|
+
- KV \`SESSION\` → \`${NAMES.kv}\`${opts.emdash ? `\n - R2 \`MEDIA\` → \`${NAMES.r2}\`` : ''}
|
|
590
|
+
- Email Sending \`EMAIL\` (no sender allow-list until launch)
|
|
591
|
+
- rate limit \`FORM_RATE_LIMITER\` (5/60s, namespace ${ids.ratelimit})${opts.turnstile ? `\n - var \`PUBLIC_TURNSTILE_SITE_KEY\` (widget \`${NAMES.turnstile}\`, \`${ids.turnstile}\`)` : ''}
|
|
592
|
+
- Worker secrets: \`FORM_SIGNING_SECRET\`${opts.turnstile ? ', `TURNSTILE_SECRET_KEY`' : ''}.
|
|
593
|
+
|
|
594
|
+
Next:
|
|
595
|
+
1. Copy Leyline's form migrations: cp node_modules/@theory-digital/leyline/src/forms/migrations/*.sql migrations/
|
|
596
|
+
2. Commit wrangler.jsonc${opts.emdash ? ', src/worker.ts' : ''} and migrations/, and push to main (${repoUrl}). The first build applies migrations and replaces the placeholder.
|
|
597
|
+
3. Enrol in Leyline updates: docs/sites.md, "Enrolling a site" (workflow file, then the leyline-site topic).
|
|
598
|
+
4. At launch, with the cloudflare skill: zone, routes, Turnstile hostname, email sending enable + allowed_sender_addresses, production-url.`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"4.1.10","results":[[":eslint-plugin-theory/src/rules/guarded-custom-element-define.test.ts",{"duration":0,"failed":true}],[":stylelint-config-theory/src/liquid/mask.test.ts",{"duration":21.486761,"failed":false}],[":theme-check-theory/src/checks/hardcoded-text.test.ts",{"duration":79.642067,"failed":false}],[":stylelint-config-theory/src/integration.test.ts",{"duration":322.234405,"failed":false}],[":theme-check-theory/src/checks/unguarded-nullable-setting.test.ts",{"duration":126.54217099999994,"failed":false}],[":eslint-plugin-theory/src/rules/disconnected-callback-cleanup.test.ts",{"duration":0,"failed":true}],[":eslint-plugin-theory/src/integration.test.ts",{"duration":207.055841,"failed":false}],[":eslint-plugin-theory/src/liquid/mask.test.ts",{"duration":31.769655,"failed":false}],[":stylelint-config-theory/src/config.test.ts",{"duration":13.856021999999996,"failed":false}],[":theme-check-theory/src/checks/unused-section-settings.test.ts",{"duration":63.80623400000002,"failed":false}],[":theme-check-theory/src/checks/unguarded-metaobject.test.ts",{"duration":34.325909000000024,"failed":false}],[":eslint-plugin-theory/src/index.test.ts",{"duration":6.773288999999977,"failed":false}],[":theme-check-theory/src/checks/disallowed-script-or-style-tag.test.ts",{"duration":32.848730000000046,"failed":false}],[":theme-check-theory/src/checks/unguarded-metafield.test.ts",{"duration":37.897699999999986,"failed":false}],[":eslint-plugin-theory/src/rules/no-class-selectors.test.ts",{"duration":0,"failed":true}],[":eslint-plugin-theory/src/rules/no-unapproved-imports.test.ts",{"duration":0,"failed":true}],[":eslint-plugin-theory/src/rules/require-jsdoc.test.ts",{"duration":87.66796799999997,"failed":false}],[":eslint-plugin-theory/src/rules/centralize-selectors.test.ts",{"duration":0,"failed":true}],[":stylelint-config-theory/src/build.test.ts",{"duration":903.9329710000001,"failed":false}],[":theme-check-theory/src/index.test.ts",{"duration":2.380390000000034,"failed":false}],[":eslint-plugin-theory/src/processors/liquid.test.ts",{"duration":6.720345000000009,"failed":false}],[":eslint-plugin-theory/src/build.test.ts",{"duration":965.007413,"failed":false}]]}
|