@rexezuge/cli 1.15.0 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -14
- package/dist/doctor/checks/files.d.ts.map +1 -1
- package/dist/doctor/checks/files.js +1 -1
- package/dist/doctor/checks/files.js.map +3 -3
- package/dist/doctor/checks/vendored.js +1 -1
- package/dist/doctor/checks/vendored.js.map +1 -1
- package/dist/sync/fixes.d.ts.map +1 -1
- package/dist/sync/fixes.js +6 -6
- package/dist/sync/fixes.js.map +3 -3
- package/dist/sync/scripts.d.ts +8 -0
- package/dist/sync/scripts.d.ts.map +1 -0
- package/dist/sync/scripts.js +2 -0
- package/dist/sync/scripts.js.map +7 -0
- package/dist/sync/workflows.d.ts +5 -0
- package/dist/sync/workflows.d.ts.map +1 -1
- package/dist/sync/workflows.js +1 -1
- package/dist/sync/workflows.js.map +3 -3
- package/dist/workflow-callers.d.ts +1 -1
- package/dist/workflow-callers.js +1 -1
- package/dist/workflow-callers.js.map +2 -2
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -13,20 +13,20 @@ Every command takes `--cwd <dir>` (the repo; default `.`) and `--help`, exits **
|
|
|
13
13
|
|
|
14
14
|
## Commands
|
|
15
15
|
|
|
16
|
-
| Command | What it does
|
|
17
|
-
| ------------------------------------------------------------------------------------------------------------- |
|
|
18
|
-
| `rexezuge doctor [--json] [--strict]` | Family conformance report with a score. Exit 1 when an ERROR check fails (`--strict`: a WARN too).
|
|
19
|
-
| `rexezuge manifest [--json]` | The validated manifest and the CI/CD plan derived from it (what the reusable workflows switch on).
|
|
20
|
-
| `rexezuge sync [--write] [--json]` | Repairs what doctor found. A dry run unless `--write`.
|
|
21
|
-
| `rexezuge prepare-wrangler` | Materialize `wrangler.jsonc` from the template and provision the resources it names (env-driven, see tooling). KV bindings come from the manifest's `features.kv`: none declared, none added. |
|
|
22
|
-
| `rexezuge init-secrets` | Create the Secrets Store entries `wrangler.jsonc` declares, generate-if-absent.
|
|
23
|
-
| `rexezuge backup d1 check\|resolve-target\|encrypt\|upload s3\|upload webdav` | The steps of the reusable `backup-d1` workflow: preflight, target, compress and encrypt, upload and prune.
|
|
24
|
-
| `rexezuge migrations verify [--dir <d>] [--json]` | Names, numbering and digests against `migrations.lock.json`. Read-only: the CI gate.
|
|
25
|
-
| `rexezuge migrations lock [--dir <d>] [--json]` | Add-only lock write, then a re-check from disk, so an edited applied migration still exits 1.
|
|
26
|
-
| `rexezuge migrations add-identity [--dir <d>] [--dry-run] [--json]` | Write the next numbered `NNNN_user_identity.sql` from `@rexezuge/identity`.
|
|
27
|
-
| `rexezuge spa-shell ensure\|verify [--json]` | Write the empty stub when absent, or reject a missing, stubbed or half-refreshed SPA shell.
|
|
28
|
-
| `rexezuge god-files [--allowlist <f>] [--fail-on-hard] [--json]` | The 300 / 400 line guard; the manifest's `quality.godFiles` may only lower the limits.
|
|
29
|
-
| `rexezuge locales validate [--dir <d>] [--base <tag>] [--shape <s>] [--call-sites <d>] [--tags <f>] [--json]` | Key parity, empty values and `{{placeholder}}` parity across locale bundles; optionally call sites and tags.
|
|
16
|
+
| Command | What it does |
|
|
17
|
+
| ------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
18
|
+
| `rexezuge doctor [--json] [--strict]` | Family conformance report with a score. Exit 1 when an ERROR check fails (`--strict`: a WARN too). |
|
|
19
|
+
| `rexezuge manifest [--json]` | The validated manifest and the CI/CD plan derived from it (what the reusable workflows switch on). |
|
|
20
|
+
| `rexezuge sync [--write] [--json]` | Repairs what doctor found. A dry run unless `--write`. |
|
|
21
|
+
| `rexezuge prepare-wrangler` | Materialize `wrangler.jsonc` from the template (manifest `features.workers`, default `apps/api/wrangler.template.jsonc`) and provision the resources it names (env-driven, see tooling). KV bindings come from the manifest's `features.kv`: none declared, none added. |
|
|
22
|
+
| `rexezuge init-secrets` | Create the Secrets Store entries `wrangler.jsonc` declares, generate-if-absent. |
|
|
23
|
+
| `rexezuge backup d1 check\|resolve-target\|encrypt\|upload s3\|upload webdav` | The steps of the reusable `backup-d1` workflow: preflight, target, compress and encrypt, upload and prune. |
|
|
24
|
+
| `rexezuge migrations verify [--dir <d>] [--json]` | Names, numbering and digests against `migrations.lock.json`. Read-only: the CI gate. |
|
|
25
|
+
| `rexezuge migrations lock [--dir <d>] [--json]` | Add-only lock write, then a re-check from disk, so an edited applied migration still exits 1. |
|
|
26
|
+
| `rexezuge migrations add-identity [--dir <d>] [--dry-run] [--json]` | Write the next numbered `NNNN_user_identity.sql` from `@rexezuge/identity`. |
|
|
27
|
+
| `rexezuge spa-shell ensure\|verify [--json]` | Write the empty stub when absent, or reject a missing, stubbed or half-refreshed SPA shell. |
|
|
28
|
+
| `rexezuge god-files [--allowlist <f>] [--fail-on-hard] [--json]` | The 300 / 400 line guard; the manifest's `quality.godFiles` may only lower the limits. |
|
|
29
|
+
| `rexezuge locales validate [--dir <d>] [--base <tag>] [--shape <s>] [--call-sites <d>] [--tags <f>] [--json]` | Key parity, empty values and `{{placeholder}}` parity across locale bundles; optionally call sites and tags. |
|
|
30
30
|
|
|
31
31
|
`--dir` defaults to the manifest's `features.d1.migrationsDir` (then `migrations`) for `migrations`, and to `apps/web/src/locales` for `locales`.
|
|
32
32
|
|
|
@@ -115,6 +115,8 @@ before and after. **Dry run by default**; `--write` applies it. Fixes compose in
|
|
|
115
115
|
| `functions/[[path]].ts` | Becomes `export { onRequest } from '@rexezuge/tooling/pages-proxy';`, only when the file is the proxy (it names `API_WORKER`) |
|
|
116
116
|
| `test/mocks/cloudflare-workers.ts` | Becomes `export * from '@rexezuge/testing/cloudflare-workers';` (rewritten, not deleted: suites import it by path) |
|
|
117
117
|
| `.github/workflows/*.yml` | Replaced with the thin caller for the workflow's family name (`continuous-integration` to `worker-ci`, and so on) |
|
|
118
|
+
| `.github/workflows/backup-main.yml` | Created when no workflow calls the reusable `backup-main` (a warning-level check, `workflows.backup-main`). The caller is secrets-gated: with none of the `BACKUP_REPO_*` secrets set it skips |
|
|
119
|
+
| `scripts/*` prepare / init copies | The vendored `prepare-wrangler-config` and `init-secrets` are deleted; then `scripts/tsconfig.json` and the `typecheck:scripts` script too, only when no TypeScript file is left under `scripts/` |
|
|
118
120
|
| `.github/actions/{setup-env,retry-step}` | Deleted when no remaining workflow references them (a workflow sync replaces does not count); no other action is ever touched |
|
|
119
121
|
|
|
120
122
|
Every file `sync` writes ends with exactly one newline. `sync` never deletes domain code. A vendored file is rewritten only when the replacement is a pure re-export; every other vendored copy is reported by doctor and left to you,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/doctor/checks/files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGzC;;GAEG;AACH,eAAO,MAAM,iBAAiB,sHAUpB,CAAC;AAEX,eAAO,MAAM,eAAe,sDAAsD,CAAC;AAEnF,eAAO,MAAM,UAAU,EAAE,SAAS,KAAK,
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/doctor/checks/files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGzC;;GAEG;AACH,eAAO,MAAM,iBAAiB,sHAUpB,CAAC;AAEX,eAAO,MAAM,eAAe,sDAAsD,CAAC;AAEnF,eAAO,MAAM,UAAU,EAAE,SAAS,KAAK,EAqHtC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var n=Object.defineProperty;var r=(e,s)=>n(e,"name",{value:s,configurable:!0});import{rootScripts as a}from"../../repo-json.js";const l=["checks","typecheck","lint","lint:check","format","format:check","test","test:coverage","typegen"],o="Rexezuge-CloudflareWorkers/SDK/.github/workflows/",
|
|
1
|
+
var n=Object.defineProperty;var r=(e,s)=>n(e,"name",{value:s,configurable:!0});import{rootScripts as a}from"../../repo-json.js";const l=["checks","typecheck","lint","lint:check","format","format:check","test","test:coverage","typegen"],o="Rexezuge-CloudflareWorkers/SDK/.github/workflows/",d=[{id:"workflows.callers",severity:"error",title:".github/workflows/*.yml are thin callers of the SDK reusable workflows",message:"A workflow is a full pipeline instead of a caller.",fix:`Replace it with a caller: \`uses: ${o}<name>.yml@v1\` (rexezuge sync --write).`,autoFixable:!0,run:r(e=>{const s=e.files.filter(t=>/^\.github\/workflows\/[^/]+\.ya?ml$/.test(t));if(s.length===0)return{ok:!1,details:[".github/workflows has no workflow"]};const i=s.filter(t=>!new RegExp(String.raw`uses:\s*${o.replaceAll(".",String.raw`\.`)}`).test(e.read(t)??""));return i.length===0?{ok:!0}:{ok:!1,details:i.map(t=>`${t} does not call ${o}*`)}},"run")},{id:"workflows.backup-main",severity:"warn",title:"A workflow calls the backup-main reusable workflow",message:"The repo does not mirror main: there is no caller of backup-main.yml.",fix:`Add a caller of \`${o}backup-main.yml@v1\` (rexezuge sync --write). It is secrets-gated: with none of the BACKUP_REPO_* secrets set it skips.`,autoFixable:!0,run:r(e=>{const s=new RegExp(String.raw`uses:\s*${o.replaceAll(".",String.raw`\.`)}backup-main\.yml`);return e.files.filter(t=>/^\.github\/workflows\/[^/]+\.ya?ml$/.test(t)).some(t=>s.test(e.read(t)??""))?{ok:!0}:{ok:!1,details:["no workflow calls backup-main.yml"]}},"run")},{id:"files.license",severity:"error",title:"LICENSE exists",message:"The repo has no LICENSE file.",fix:"Add the family LICENSE (MIT).",autoFixable:!1,run:r(e=>e.exists("LICENSE")||e.exists("LICENSE.md")?{ok:!0}:{ok:!1,details:["LICENSE"]},"run")},{id:"files.editorconfig",severity:"warn",title:".editorconfig exists",message:"The repo has no .editorconfig.",fix:"Copy the family .editorconfig.",autoFixable:!1,run:r(e=>e.exists(".editorconfig")?{ok:!0}:{ok:!1,details:[".editorconfig"]},"run")},{id:"files.agents",severity:"error",title:"AGENTS.md exists",message:"The repo has no AGENTS.md.",fix:"Add AGENTS.md linking the SDK conventions (docs/conventions.md).",autoFixable:!1,run:r(e=>e.exists("AGENTS.md")?{ok:!0}:{ok:!1,details:["AGENTS.md"]},"run")},{id:"files.claude-symlink",severity:"error",title:"CLAUDE.md is a symlink to AGENTS.md",message:"CLAUDE.md is missing or is not a symlink to AGENTS.md.",fix:"ln -sf AGENTS.md CLAUDE.md (rexezuge sync --write).",autoFixable:!0,run:r(e=>{const s=e.linkTarget("CLAUDE.md");return s==="AGENTS.md"||s==="./AGENTS.md"?{ok:!0}:{ok:!1,details:[s===null?"CLAUDE.md is absent or a regular file":`CLAUDE.md points at ${s}`]}},"run")},{id:"files.node-version",severity:"warn",title:".nvmrc is 24 or package.json engines.node is set",message:"The Node version is not pinned.",fix:"Write 24 to .nvmrc (rexezuge sync --write).",autoFixable:!0,run:r(e=>{const s=e.read(".nvmrc")?.trim();if(s!==void 0&&/^v?24(?:\.|$)/.test(s))return{ok:!0};const i=e.packages.find(t=>t.path==="package.json")?.json?.engines?.node;return typeof i=="string"&&i!==""?{ok:!0}:{ok:!1,details:[s===void 0?".nvmrc not found":`.nvmrc is ${s}, expected 24`]}},"run")},{id:"files.migrations-lock",severity:"error",title:"migrations.lock.json exists when the repo uses D1",message:"The D1 migrations have no lock.",fix:"Run `rexezuge migrations lock`.",autoFixable:!1,run:r(e=>{const s=e.manifest?.features?.d1;if(s===void 0)return{skipped:"feature d1 is off"};const i=`${s.migrationsDir??"migrations"}/migrations.lock.json`;return e.exists(i)?{ok:!0}:{ok:!1,details:[i]}},"run")},{id:"scripts.canonical",severity:"warn",title:"package.json defines the canonical scripts",message:"Some canonical scripts are missing from the root package.json.",fix:"Add the missing scripts (rexezuge sync --write).",autoFixable:!0,run:r(e=>{const s=a(e),i=l.filter(t=>s[t]===void 0);return i.length===0?{ok:!0}:{ok:!1,details:i.map(t=>`scripts.${t}`)}},"run")}];export{l as CANONICAL_SCRIPTS,o as WORKFLOW_PREFIX,d as fileChecks};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/doctor/checks/files.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Check } from '../types.ts';\nimport { rootScripts } from '../../repo-json.ts';\n\n/**\n * The script names every family repo defines, so `pnpm run checks` means the same thing everywhere.\n */\nexport const CANONICAL_SCRIPTS = [\n 'checks',\n 'typecheck',\n 'lint',\n 'lint:check',\n 'format',\n 'format:check',\n 'test',\n 'test:coverage',\n 'typegen',\n] as const;\n\nexport const WORKFLOW_PREFIX = 'Rexezuge-CloudflareWorkers/SDK/.github/workflows/';\n\nexport const fileChecks: readonly Check[] = [\n {\n id: 'workflows.callers',\n severity: 'error',\n title: '.github/workflows/*.yml are thin callers of the SDK reusable workflows',\n message: 'A workflow is a full pipeline instead of a caller.',\n fix: `Replace it with a caller: \\`uses: ${WORKFLOW_PREFIX}<name>.yml@v1\\` (rexezuge sync --write).`,\n autoFixable: true,\n run: (repo) => {\n const files = repo.files.filter((file) => /^\\.github\\/workflows\\/[^/]+\\.ya?ml$/.test(file));\n if (files.length === 0) return { ok: false, details: ['.github/workflows has no workflow'] };\n const bad = files.filter(\n (file) => !new RegExp(String.raw`uses:\\s*${WORKFLOW_PREFIX.replaceAll('.', String.raw`\\.`)}`).test(repo.read(file) ?? ''),\n );\n return bad.length === 0 ? { ok: true } : { ok: false, details: bad.map((file) => `${file} does not call ${WORKFLOW_PREFIX}*`) };\n },\n },\n {\n id: 'files.license',\n severity: 'error',\n title: 'LICENSE exists',\n message: 'The repo has no LICENSE file.',\n fix: 'Add the family LICENSE (MIT).',\n autoFixable: false,\n run: (repo) => (repo.exists('LICENSE') || repo.exists('LICENSE.md') ? { ok: true } : { ok: false, details: ['LICENSE'] }),\n },\n {\n id: 'files.editorconfig',\n severity: 'warn',\n title: '.editorconfig exists',\n message: 'The repo has no .editorconfig.',\n fix: 'Copy the family .editorconfig.',\n autoFixable: false,\n run: (repo) => (repo.exists('.editorconfig') ? { ok: true } : { ok: false, details: ['.editorconfig'] }),\n },\n {\n id: 'files.agents',\n severity: 'error',\n title: 'AGENTS.md exists',\n message: 'The repo has no AGENTS.md.',\n fix: 'Add AGENTS.md linking the SDK conventions (docs/conventions.md).',\n autoFixable: false,\n run: (repo) => (repo.exists('AGENTS.md') ? { ok: true } : { ok: false, details: ['AGENTS.md'] }),\n },\n {\n id: 'files.claude-symlink',\n severity: 'error',\n title: 'CLAUDE.md is a symlink to AGENTS.md',\n message: 'CLAUDE.md is missing or is not a symlink to AGENTS.md.',\n fix: 'ln -sf AGENTS.md CLAUDE.md (rexezuge sync --write).',\n autoFixable: true,\n run: (repo) => {\n const target = repo.linkTarget('CLAUDE.md');\n return target === 'AGENTS.md' || target === './AGENTS.md'\n ? { ok: true }\n : { ok: false, details: [target === null ? 'CLAUDE.md is absent or a regular file' : `CLAUDE.md points at ${target}`] };\n },\n },\n {\n id: 'files.node-version',\n severity: 'warn',\n title: '.nvmrc is 24 or package.json engines.node is set',\n message: 'The Node version is not pinned.',\n fix: 'Write 24 to .nvmrc (rexezuge sync --write).',\n autoFixable: true,\n run: (repo) => {\n const nvmrc = repo.read('.nvmrc')?.trim();\n if (nvmrc !== undefined && /^v?24(?:\\.|$)/.test(nvmrc)) return { ok: true };\n const engines = (\n repo.packages.find((pkg) => pkg.path === 'package.json')?.json as { engines?: { node?: unknown } } | null | undefined\n )?.engines?.node;\n if (typeof engines === 'string' && engines !== '') return { ok: true };\n return { ok: false, details: [nvmrc === undefined ? '.nvmrc not found' : `.nvmrc is ${nvmrc}, expected 24`] };\n },\n },\n {\n id: 'files.migrations-lock',\n severity: 'error',\n title: 'migrations.lock.json exists when the repo uses D1',\n message: 'The D1 migrations have no lock.',\n fix: 'Run `rexezuge migrations lock`.',\n autoFixable: false,\n run: (repo) => {\n const d1 = repo.manifest?.features?.d1;\n if (d1 === undefined) return { skipped: 'feature d1 is off' };\n const lock = `${d1.migrationsDir ?? 'migrations'}/migrations.lock.json`;\n return repo.exists(lock) ? { ok: true } : { ok: false, details: [lock] };\n },\n },\n {\n id: 'scripts.canonical',\n severity: 'warn',\n title: 'package.json defines the canonical scripts',\n message: 'Some canonical scripts are missing from the root package.json.',\n fix: 'Add the missing scripts (rexezuge sync --write).',\n autoFixable: true,\n run: (repo) => {\n const scripts = rootScripts(repo);\n const missing = CANONICAL_SCRIPTS.filter((name) => scripts[name] === undefined);\n return missing.length === 0 ? { ok: true } : { ok: false, details: missing.map((name) => `scripts.${name}`) };\n },\n },\n];\n"],
|
|
5
|
-
"mappings": "+EACA,OAAS,eAAAA,MAAmB,qBAKrB,MAAMC,EAAoB,CAC/B,SACA,YACA,OACA,aACA,SACA,eACA,OACA,gBACA,WAGWC,EAAkB,oDAElBC,EAA+B,CAC1C,CACE,GAAI,oBACJ,SAAU,QACV,MAAO,yEACP,QAAS,qDACT,IAAK,qCAAqCD,CAAe,2CACzD,YAAa,GACb,IAAKE,EAACC,GAAQ,CACZ,MAAMC,EAAQD,EAAK,MAAM,OAAQE,GAAS,sCAAsC,KAAKA,CAAI,CAAC,EAC1F,GAAID,EAAM,SAAW,EAAG,MAAO,CAAE,GAAI,GAAO,QAAS,CAAC,mCAAmC,CAAC,EAC1F,MAAME,EAAMF,EAAM,OACfC,GAAS,CAAC,IAAI,OAAO,OAAO,cAAcL,EAAgB,WAAW,IAAK,OAAO,OAAO,CAAC,EAAE,EAAE,KAAKG,EAAK,KAAKE,CAAI,GAAK,EAAE,CAAC,EAE3H,OAAOC,EAAI,SAAW,EAAI,CAAE,GAAI,EAAI,EAAK,CAAE,GAAI,GAAO,QAASA,EAAI,IAAKD,GAAS,GAAGA,CAAI,kBAAkBL,CAAe,GAAG,CAAC,CAC/H,EAPK,QASP,CACE,GAAI,gBACJ,SAAU,QACV,MAAO,iBACP,QAAS,gCACT,IAAK,gCACL,YAAa,GACb,
|
|
6
|
-
"names": ["rootScripts", "CANONICAL_SCRIPTS", "WORKFLOW_PREFIX", "fileChecks", "__name", "repo", "files", "file", "bad", "target", "nvmrc", "engines", "pkg", "d1", "lock", "scripts", "missing", "name"]
|
|
4
|
+
"sourcesContent": ["import type { Check } from '../types.ts';\nimport { rootScripts } from '../../repo-json.ts';\n\n/**\n * The script names every family repo defines, so `pnpm run checks` means the same thing everywhere.\n */\nexport const CANONICAL_SCRIPTS = [\n 'checks',\n 'typecheck',\n 'lint',\n 'lint:check',\n 'format',\n 'format:check',\n 'test',\n 'test:coverage',\n 'typegen',\n] as const;\n\nexport const WORKFLOW_PREFIX = 'Rexezuge-CloudflareWorkers/SDK/.github/workflows/';\n\nexport const fileChecks: readonly Check[] = [\n {\n id: 'workflows.callers',\n severity: 'error',\n title: '.github/workflows/*.yml are thin callers of the SDK reusable workflows',\n message: 'A workflow is a full pipeline instead of a caller.',\n fix: `Replace it with a caller: \\`uses: ${WORKFLOW_PREFIX}<name>.yml@v1\\` (rexezuge sync --write).`,\n autoFixable: true,\n run: (repo) => {\n const files = repo.files.filter((file) => /^\\.github\\/workflows\\/[^/]+\\.ya?ml$/.test(file));\n if (files.length === 0) return { ok: false, details: ['.github/workflows has no workflow'] };\n const bad = files.filter(\n (file) => !new RegExp(String.raw`uses:\\s*${WORKFLOW_PREFIX.replaceAll('.', String.raw`\\.`)}`).test(repo.read(file) ?? ''),\n );\n return bad.length === 0 ? { ok: true } : { ok: false, details: bad.map((file) => `${file} does not call ${WORKFLOW_PREFIX}*`) };\n },\n },\n {\n id: 'workflows.backup-main',\n severity: 'warn',\n title: 'A workflow calls the backup-main reusable workflow',\n message: 'The repo does not mirror main: there is no caller of backup-main.yml.',\n fix: `Add a caller of \\`${WORKFLOW_PREFIX}backup-main.yml@v1\\` (rexezuge sync --write). It is secrets-gated: with none of the BACKUP_REPO_* secrets set it skips.`,\n autoFixable: true,\n run: (repo) => {\n const calls = new RegExp(String.raw`uses:\\s*${WORKFLOW_PREFIX.replaceAll('.', String.raw`\\.`)}backup-main\\.yml`);\n const files = repo.files.filter((file) => /^\\.github\\/workflows\\/[^/]+\\.ya?ml$/.test(file));\n return files.some((file) => calls.test(repo.read(file) ?? ''))\n ? { ok: true }\n : { ok: false, details: ['no workflow calls backup-main.yml'] };\n },\n },\n {\n id: 'files.license',\n severity: 'error',\n title: 'LICENSE exists',\n message: 'The repo has no LICENSE file.',\n fix: 'Add the family LICENSE (MIT).',\n autoFixable: false,\n run: (repo) => (repo.exists('LICENSE') || repo.exists('LICENSE.md') ? { ok: true } : { ok: false, details: ['LICENSE'] }),\n },\n {\n id: 'files.editorconfig',\n severity: 'warn',\n title: '.editorconfig exists',\n message: 'The repo has no .editorconfig.',\n fix: 'Copy the family .editorconfig.',\n autoFixable: false,\n run: (repo) => (repo.exists('.editorconfig') ? { ok: true } : { ok: false, details: ['.editorconfig'] }),\n },\n {\n id: 'files.agents',\n severity: 'error',\n title: 'AGENTS.md exists',\n message: 'The repo has no AGENTS.md.',\n fix: 'Add AGENTS.md linking the SDK conventions (docs/conventions.md).',\n autoFixable: false,\n run: (repo) => (repo.exists('AGENTS.md') ? { ok: true } : { ok: false, details: ['AGENTS.md'] }),\n },\n {\n id: 'files.claude-symlink',\n severity: 'error',\n title: 'CLAUDE.md is a symlink to AGENTS.md',\n message: 'CLAUDE.md is missing or is not a symlink to AGENTS.md.',\n fix: 'ln -sf AGENTS.md CLAUDE.md (rexezuge sync --write).',\n autoFixable: true,\n run: (repo) => {\n const target = repo.linkTarget('CLAUDE.md');\n return target === 'AGENTS.md' || target === './AGENTS.md'\n ? { ok: true }\n : { ok: false, details: [target === null ? 'CLAUDE.md is absent or a regular file' : `CLAUDE.md points at ${target}`] };\n },\n },\n {\n id: 'files.node-version',\n severity: 'warn',\n title: '.nvmrc is 24 or package.json engines.node is set',\n message: 'The Node version is not pinned.',\n fix: 'Write 24 to .nvmrc (rexezuge sync --write).',\n autoFixable: true,\n run: (repo) => {\n const nvmrc = repo.read('.nvmrc')?.trim();\n if (nvmrc !== undefined && /^v?24(?:\\.|$)/.test(nvmrc)) return { ok: true };\n const engines = (\n repo.packages.find((pkg) => pkg.path === 'package.json')?.json as { engines?: { node?: unknown } } | null | undefined\n )?.engines?.node;\n if (typeof engines === 'string' && engines !== '') return { ok: true };\n return { ok: false, details: [nvmrc === undefined ? '.nvmrc not found' : `.nvmrc is ${nvmrc}, expected 24`] };\n },\n },\n {\n id: 'files.migrations-lock',\n severity: 'error',\n title: 'migrations.lock.json exists when the repo uses D1',\n message: 'The D1 migrations have no lock.',\n fix: 'Run `rexezuge migrations lock`.',\n autoFixable: false,\n run: (repo) => {\n const d1 = repo.manifest?.features?.d1;\n if (d1 === undefined) return { skipped: 'feature d1 is off' };\n const lock = `${d1.migrationsDir ?? 'migrations'}/migrations.lock.json`;\n return repo.exists(lock) ? { ok: true } : { ok: false, details: [lock] };\n },\n },\n {\n id: 'scripts.canonical',\n severity: 'warn',\n title: 'package.json defines the canonical scripts',\n message: 'Some canonical scripts are missing from the root package.json.',\n fix: 'Add the missing scripts (rexezuge sync --write).',\n autoFixable: true,\n run: (repo) => {\n const scripts = rootScripts(repo);\n const missing = CANONICAL_SCRIPTS.filter((name) => scripts[name] === undefined);\n return missing.length === 0 ? { ok: true } : { ok: false, details: missing.map((name) => `scripts.${name}`) };\n },\n },\n];\n"],
|
|
5
|
+
"mappings": "+EACA,OAAS,eAAAA,MAAmB,qBAKrB,MAAMC,EAAoB,CAC/B,SACA,YACA,OACA,aACA,SACA,eACA,OACA,gBACA,WAGWC,EAAkB,oDAElBC,EAA+B,CAC1C,CACE,GAAI,oBACJ,SAAU,QACV,MAAO,yEACP,QAAS,qDACT,IAAK,qCAAqCD,CAAe,2CACzD,YAAa,GACb,IAAKE,EAACC,GAAQ,CACZ,MAAMC,EAAQD,EAAK,MAAM,OAAQE,GAAS,sCAAsC,KAAKA,CAAI,CAAC,EAC1F,GAAID,EAAM,SAAW,EAAG,MAAO,CAAE,GAAI,GAAO,QAAS,CAAC,mCAAmC,CAAC,EAC1F,MAAME,EAAMF,EAAM,OACfC,GAAS,CAAC,IAAI,OAAO,OAAO,cAAcL,EAAgB,WAAW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EACT,IAAK,mDACL,YAAa,GACb,IAAKX,EAACC,GAAQ,CACZ,MAAMW,EAAUhB,EAAYK,CAAI,EAC1BY,EAAUhB,EAAkB,OAAQiB,GAASF,EAAQE,CAAI,IAAM,MAAS,EAC9E,OAAOD,EAAQ,SAAW,EAAI,CAAE,GAAI,EAAI,EAAK,CAAE,GAAI,GAAO,QAASA,EAAQ,IAAKC,GAAS,WAAWA,CAAI,EAAE,CAAC,CAC7G,EAJK",
|
|
6
|
+
"names": ["rootScripts", "CANONICAL_SCRIPTS", "WORKFLOW_PREFIX", "fileChecks", "__name", "repo", "files", "file", "bad", "calls", "target", "nvmrc", "engines", "pkg", "d1", "lock", "scripts", "missing", "name"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var s=Object.defineProperty;var t=(e,r)=>s(e,"name",{value:r,configurable:!0});const i=t(e=>e.includes("@rexezuge/"),"mentionsKit"),o=[{key:"wrangler-config",title:"No vendored scripts/lib/wrangler-config",hint:"Delete it and call `rexezuge prepare-wrangler` / `rexezuge init-secrets`.",autoFixable:!1,path:/(^|\/)scripts\/(?:.+\/)?wrangler-config\/[^/]+\.(?:ts|mts|mjs|js)$/},{key:"backup",title:"No vendored scripts/backup helpers",hint:"Import d1-target, destination-config, naming and encrypt-backup from @rexezuge/tooling.",autoFixable:!1,path:/(^|\/)scripts\/(?:.+\/)?backup\/(?:d1-target|destination-config|naming|encrypt-backup)\.(?:ts|mts|mjs|js)$/},{key:"verify-migrations",title:"No vendored migrations verifier",hint:"Delete it and run `rexezuge migrations verify|lock`.",autoFixable:!1,path:/(^|\/)scripts\/(?:.+\/)?(?:verify-migrations|migrations-lock)\.(?:ts|mts|mjs|js)$/},{key:"god-files",title:"No vendored check-god-files",hint:"Delete it and run `rexezuge god-files`.",autoFixable:!1,path:/(^|\/)check-god-files\.[a-z]+$/},{key:"init-secrets",title:"No vendored init-secrets",hint:"Delete it and run `rexezuge init-secrets`.",autoFixable:!
|
|
1
|
+
var s=Object.defineProperty;var t=(e,r)=>s(e,"name",{value:r,configurable:!0});const i=t(e=>e.includes("@rexezuge/"),"mentionsKit"),o=[{key:"wrangler-config",title:"No vendored scripts/lib/wrangler-config",hint:"Delete it and call `rexezuge prepare-wrangler` / `rexezuge init-secrets`.",autoFixable:!1,path:/(^|\/)scripts\/(?:.+\/)?wrangler-config\/[^/]+\.(?:ts|mts|mjs|js)$/},{key:"backup",title:"No vendored scripts/backup helpers",hint:"Import d1-target, destination-config, naming and encrypt-backup from @rexezuge/tooling.",autoFixable:!1,path:/(^|\/)scripts\/(?:.+\/)?backup\/(?:d1-target|destination-config|naming|encrypt-backup)\.(?:ts|mts|mjs|js)$/},{key:"verify-migrations",title:"No vendored migrations verifier",hint:"Delete it and run `rexezuge migrations verify|lock`.",autoFixable:!1,path:/(^|\/)scripts\/(?:.+\/)?(?:verify-migrations|migrations-lock)\.(?:ts|mts|mjs|js)$/},{key:"god-files",title:"No vendored check-god-files",hint:"Delete it and run `rexezuge god-files`.",autoFixable:!1,path:/(^|\/)check-god-files\.[a-z]+$/},{key:"init-secrets",title:"No vendored init-secrets",hint:"Delete it and run `rexezuge init-secrets`.",autoFixable:!0,path:/(^|\/)scripts\/(?:.+\/)?init-secrets\.(?:ts|mts|mjs|js)$/},{key:"prepare-wrangler",title:"No vendored prepare-wrangler-config",hint:"Delete it and run `rexezuge prepare-wrangler`.",autoFixable:!0,path:/(^|\/)prepare-wrangler-config\.(?:ts|mts|mjs|js)$/},{key:"cloudflare-workers-mock",title:"test/mocks/cloudflare-workers.ts is not a vendored copy",hint:"Replace it with `export * from '@rexezuge/testing/cloudflare-workers';` or delete it.",autoFixable:!0,path:/(^|\/)test\/mocks\/cloudflare-workers\.ts$/},{key:"pages-function",title:"functions/[[path]].ts delegates to the tooling pages proxy",hint:"Make it `export { onRequest } from '@rexezuge/tooling/pages-proxy';`.",autoFixable:!0,path:/(^|\/)functions\/\[\[path\]\]\.ts$/,delegates:t(e=>/@rexezuge\/tooling\/(?:functions\/)?pages-proxy/.test(e),"delegates")},{key:"use-current-user",title:"No local useCurrentUser hook",hint:"Use `useCurrentUser` from '@rexezuge/web'.",autoFixable:!1,path:/(^|\/)apps\/web\/src\/hooks\/useCurrentUser\.tsx?$/},{key:"use-spa-language",title:"No local useSpaLanguage hook",hint:"Use `useSpaLanguage` from '@rexezuge/web'.",autoFixable:!1,path:/(^|\/)apps\/web\/src\/hooks\/useSpaLanguage\.tsx?$/},{key:"spa-i18n",title:"apps/web/src/i18n.ts is built on createSpaI18n",hint:"Build it with `createSpaI18n` from '@rexezuge/web/i18n'.",autoFixable:!1,path:/(^|\/)apps\/web\/src\/i18n\.tsx?$/,delegates:t(e=>e.includes("@rexezuge/web/i18n"),"delegates")},{key:"base-route",title:"No local IBaseRoute",hint:"Extend `FamilyRoute` from @rexezuge/http/hono.",autoFixable:!1,path:/(^|\/)IBaseRoute\.ts$/},{key:"cron-worker",title:"CronTasksWorker extends CronTasksDurableObject",hint:"Extend `CronTasksDurableObject` from @rexezuge/runtime and keep only createRegistry.",autoFixable:!1,path:/(^|\/)CronTasksWorker\.ts$/,delegates:t(e=>/extends\s+CronTasksDurableObject\b/.test(e),"delegates")},{key:"pruning-task",title:"No local AbstractPruningTask",hint:"Extend `AbstractPruningTask` from '@rexezuge/runtime'.",autoFixable:!1,path:/(^|\/)AbstractPruningTask\.ts$/},{key:"logger",title:"No local Logger",hint:"Use `createLogger` from '@rexezuge/runtime'.",autoFixable:!1,path:/(^|\/)Logger\.ts$/},{key:"http-hardening",title:"No local HttpHardening",hint:"Use `createApiApp({ hardening })` from '@rexezuge/http/hono'.",autoFixable:!1,path:/(^|\/)HttpHardening\.ts$/}];function n(e,r){return e.files.filter(a=>r.path.test(a)?!(r.delegates??i)(e.read(a)??""):!1)}t(n,"vendoredFiles");const u=o.map(e=>({id:`vendored.${e.key}`,severity:"error",title:e.title,message:"A copy of kit code lives in the repo instead of an import.",fix:e.hint,autoFixable:e.autoFixable,run:t(r=>{const a=n(r,e);return a.length===0?{ok:!0}:{ok:!1,details:a}},"run")}));export{o as VENDORED_RULES,u as vendoredChecks,n as vendoredFiles};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/doctor/checks/vendored.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Repo } from '../../repo.ts';\nimport type { Check } from '../types.ts';\n\n/**\n * A known vendored copy: which files to look at, and when a file is the repo's own domain code instead.\n * Heuristics rather than hashes (a copy drifts the moment it is vendored): a path pattern, plus a content test.\n */\ninterface VendoredRule {\n readonly key: string;\n readonly title: string;\n readonly hint: string;\n readonly autoFixable: boolean;\n readonly path: RegExp;\n /**\n True when the file at a matching path already delegates to the kit. Default: it mentions `@rexezuge/`.\n */\n readonly delegates?: (content: string) => boolean;\n}\n\nconst mentionsKit = (content: string): boolean => content.includes('@rexezuge/');\n\nexport const VENDORED_RULES: readonly VendoredRule[] = [\n {\n key: 'wrangler-config',\n title: 'No vendored scripts/lib/wrangler-config',\n hint: 'Delete it and call `rexezuge prepare-wrangler` / `rexezuge init-secrets`.',\n autoFixable: false,\n path: /(^|\\/)scripts\\/(?:.+\\/)?wrangler-config\\/[^/]+\\.(?:ts|mts|mjs|js)$/,\n },\n {\n key: 'backup',\n title: 'No vendored scripts/backup helpers',\n hint: 'Import d1-target, destination-config, naming and encrypt-backup from @rexezuge/tooling.',\n autoFixable: false,\n path: /(^|\\/)scripts\\/(?:.+\\/)?backup\\/(?:d1-target|destination-config|naming|encrypt-backup)\\.(?:ts|mts|mjs|js)$/,\n },\n {\n key: 'verify-migrations',\n title: 'No vendored migrations verifier',\n hint: 'Delete it and run `rexezuge migrations verify|lock`.',\n autoFixable: false,\n path: /(^|\\/)scripts\\/(?:.+\\/)?(?:verify-migrations|migrations-lock)\\.(?:ts|mts|mjs|js)$/,\n },\n {\n key: 'god-files',\n title: 'No vendored check-god-files',\n hint: 'Delete it and run `rexezuge god-files`.',\n autoFixable: false,\n path: /(^|\\/)check-god-files\\.[a-z]+$/,\n },\n {\n key: 'init-secrets',\n title: 'No vendored init-secrets',\n hint: 'Delete it and run `rexezuge init-secrets`.',\n autoFixable:
|
|
4
|
+
"sourcesContent": ["import type { Repo } from '../../repo.ts';\nimport type { Check } from '../types.ts';\n\n/**\n * A known vendored copy: which files to look at, and when a file is the repo's own domain code instead.\n * Heuristics rather than hashes (a copy drifts the moment it is vendored): a path pattern, plus a content test.\n */\ninterface VendoredRule {\n readonly key: string;\n readonly title: string;\n readonly hint: string;\n readonly autoFixable: boolean;\n readonly path: RegExp;\n /**\n True when the file at a matching path already delegates to the kit. Default: it mentions `@rexezuge/`.\n */\n readonly delegates?: (content: string) => boolean;\n}\n\nconst mentionsKit = (content: string): boolean => content.includes('@rexezuge/');\n\nexport const VENDORED_RULES: readonly VendoredRule[] = [\n {\n key: 'wrangler-config',\n title: 'No vendored scripts/lib/wrangler-config',\n hint: 'Delete it and call `rexezuge prepare-wrangler` / `rexezuge init-secrets`.',\n autoFixable: false,\n path: /(^|\\/)scripts\\/(?:.+\\/)?wrangler-config\\/[^/]+\\.(?:ts|mts|mjs|js)$/,\n },\n {\n key: 'backup',\n title: 'No vendored scripts/backup helpers',\n hint: 'Import d1-target, destination-config, naming and encrypt-backup from @rexezuge/tooling.',\n autoFixable: false,\n path: /(^|\\/)scripts\\/(?:.+\\/)?backup\\/(?:d1-target|destination-config|naming|encrypt-backup)\\.(?:ts|mts|mjs|js)$/,\n },\n {\n key: 'verify-migrations',\n title: 'No vendored migrations verifier',\n hint: 'Delete it and run `rexezuge migrations verify|lock`.',\n autoFixable: false,\n path: /(^|\\/)scripts\\/(?:.+\\/)?(?:verify-migrations|migrations-lock)\\.(?:ts|mts|mjs|js)$/,\n },\n {\n key: 'god-files',\n title: 'No vendored check-god-files',\n hint: 'Delete it and run `rexezuge god-files`.',\n autoFixable: false,\n path: /(^|\\/)check-god-files\\.[a-z]+$/,\n },\n {\n key: 'init-secrets',\n title: 'No vendored init-secrets',\n hint: 'Delete it and run `rexezuge init-secrets`.',\n autoFixable: true,\n path: /(^|\\/)scripts\\/(?:.+\\/)?init-secrets\\.(?:ts|mts|mjs|js)$/,\n },\n {\n key: 'prepare-wrangler',\n title: 'No vendored prepare-wrangler-config',\n hint: 'Delete it and run `rexezuge prepare-wrangler`.',\n autoFixable: true,\n path: /(^|\\/)prepare-wrangler-config\\.(?:ts|mts|mjs|js)$/,\n },\n {\n key: 'cloudflare-workers-mock',\n title: 'test/mocks/cloudflare-workers.ts is not a vendored copy',\n hint: \"Replace it with `export * from '@rexezuge/testing/cloudflare-workers';` or delete it.\",\n autoFixable: true,\n path: /(^|\\/)test\\/mocks\\/cloudflare-workers\\.ts$/,\n },\n {\n key: 'pages-function',\n title: 'functions/[[path]].ts delegates to the tooling pages proxy',\n hint: \"Make it `export { onRequest } from '@rexezuge/tooling/pages-proxy';`.\",\n autoFixable: true,\n path: /(^|\\/)functions\\/\\[\\[path\\]\\]\\.ts$/,\n delegates: (content) => /@rexezuge\\/tooling\\/(?:functions\\/)?pages-proxy/.test(content),\n },\n {\n key: 'use-current-user',\n title: 'No local useCurrentUser hook',\n hint: \"Use `useCurrentUser` from '@rexezuge/web'.\",\n autoFixable: false,\n path: /(^|\\/)apps\\/web\\/src\\/hooks\\/useCurrentUser\\.tsx?$/,\n },\n {\n key: 'use-spa-language',\n title: 'No local useSpaLanguage hook',\n hint: \"Use `useSpaLanguage` from '@rexezuge/web'.\",\n autoFixable: false,\n path: /(^|\\/)apps\\/web\\/src\\/hooks\\/useSpaLanguage\\.tsx?$/,\n },\n {\n key: 'spa-i18n',\n title: 'apps/web/src/i18n.ts is built on createSpaI18n',\n hint: \"Build it with `createSpaI18n` from '@rexezuge/web/i18n'.\",\n autoFixable: false,\n path: /(^|\\/)apps\\/web\\/src\\/i18n\\.tsx?$/,\n delegates: (content) => content.includes('@rexezuge/web/i18n'),\n },\n {\n key: 'base-route',\n title: 'No local IBaseRoute',\n hint: 'Extend `FamilyRoute` from @rexezuge/http/hono.',\n autoFixable: false,\n path: /(^|\\/)IBaseRoute\\.ts$/,\n },\n {\n key: 'cron-worker',\n title: 'CronTasksWorker extends CronTasksDurableObject',\n hint: 'Extend `CronTasksDurableObject` from @rexezuge/runtime and keep only createRegistry.',\n autoFixable: false,\n path: /(^|\\/)CronTasksWorker\\.ts$/,\n delegates: (content) => /extends\\s+CronTasksDurableObject\\b/.test(content),\n },\n {\n key: 'pruning-task',\n title: 'No local AbstractPruningTask',\n hint: \"Extend `AbstractPruningTask` from '@rexezuge/runtime'.\",\n autoFixable: false,\n path: /(^|\\/)AbstractPruningTask\\.ts$/,\n },\n {\n key: 'logger',\n title: 'No local Logger',\n hint: \"Use `createLogger` from '@rexezuge/runtime'.\",\n autoFixable: false,\n path: /(^|\\/)Logger\\.ts$/,\n },\n {\n key: 'http-hardening',\n title: 'No local HttpHardening',\n hint: \"Use `createApiApp({ hardening })` from '@rexezuge/http/hono'.\",\n autoFixable: false,\n path: /(^|\\/)HttpHardening\\.ts$/,\n },\n];\n\n/**\n * The repo-relative paths a rule flags: files at a matching path that do not delegate to the kit.\n */\nexport function vendoredFiles(repo: Repo, rule: VendoredRule): string[] {\n return repo.files.filter((file) => {\n if (!rule.path.test(file)) return false;\n return !(rule.delegates ?? mentionsKit)(repo.read(file) ?? '');\n });\n}\n\nexport const vendoredChecks: readonly Check[] = VENDORED_RULES.map((rule) => ({\n id: `vendored.${rule.key}`,\n severity: 'error' as const,\n title: rule.title,\n message: 'A copy of kit code lives in the repo instead of an import.',\n fix: rule.hint,\n autoFixable: rule.autoFixable,\n run: (repo: Repo) => {\n const files = vendoredFiles(repo, rule);\n return files.length === 0 ? { ok: true as const } : { ok: false as const, details: files };\n },\n}));\n"],
|
|
5
5
|
"mappings": "+EAmBA,MAAMA,EAAcC,EAACC,GAA6BA,EAAQ,SAAS,YAAY,EAA3D,eAEPC,EAA0C,CACrD,CACE,IAAK,kBACL,MAAO,0CACP,KAAM,4EACN,YAAa,GACb,KAAM,s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AAaN,GAAaK,EAAK,KAAKE,CAAI,GAAK,EAAE,EAD3B,EAEnC,CACH,CALgBN,EAAAG,EAAA,iBAOT,MAAMI,EAAmCL,EAAe,IAAKG,IAAU,CAC5E,GAAI,YAAYA,EAAK,GAAG,GACxB,SAAU,QACV,MAAOA,EAAK,MACZ,QAAS,6DACT,IAAKA,EAAK,KACV,YAAaA,EAAK,YAClB,IAAKL,EAACI,GAAc,CAClB,MAAMI,EAAQL,EAAcC,EAAMC,CAAI,EACtC,OAAOG,EAAM,SAAW,EAAI,CAAE,GAAI,EAAa,EAAK,CAAE,GAAI,GAAgB,QAASA,CAAK,CAC1F,EAHK,QAIL",
|
|
6
6
|
"names": ["mentionsKit", "__name", "content", "VENDORED_RULES", "vendoredFiles", "repo", "rule", "file", "vendoredChecks", "files"]
|
|
7
7
|
}
|
package/dist/sync/fixes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixes.d.ts","sourceRoot":"","sources":["../../src/sync/fixes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"fixes.d.ts","sourceRoot":"","sources":["../../src/sync/fixes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAUvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC;;;GAGG;AACH,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;AA8JnD;;GAEG;AACH,eAAO,MAAM,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAgB/C,CAAC"}
|
package/dist/sync/fixes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
`}}))}a(
|
|
3
|
-
`;if(A(
|
|
4
|
-
`,"Node 24"),"nodeVersion")
|
|
5
|
-
`,"one-line pages-proxy re-export")},"pagesFunction"),
|
|
6
|
-
`,"re-export of @rexezuge/testing")},"workersMock"),
|
|
1
|
+
var w=Object.defineProperty;var a=(o,t)=>w(o,"name",{value:t,configurable:!0});import{applyEdits as x,modify as y}from"jsonc-parser";import{isLocalSpec as d,kitDependencies as h}from"../repo.js";import{removeOverrides as v,setCatalogEntries as S}from"../workspace-yaml.js";import{CLI_VERSION as E,KIT_PACKAGES as j}from"../version.js";import{CANONICAL_SCRIPTS as b}from"../doctor/checks/files.js";import{extendsPreset as A}from"../doctor/checks/presets.js";import{vendoredFiles as m,VENDORED_RULES as u}from"../doctor/checks/vendored.js";import{applyPreset as P}from"./tsconfig.js";import{staleActions as T}from"../doctor/checks/actions.js";import{backupMainFix as O,workflowFixes as R}from"./workflows.js";import{vendoredScriptFixes as g}from"./scripts.js";const l=a(o=>o.startsWith("@rexezuge/"),"isKit");function f(o,t,n){return x(o,y(o,t,n,{formattingOptions:{insertSpaces:!0,tabSize:2,eol:`
|
|
2
|
+
`}}))}a(f,"editJson");const z=a((o,t)=>{const n=new Map;for(const r of o.packages)for(const[c,p]of h(r.json))d(p)||(j.has(c)?n.set(c,E):t.note(`${c}: not a package this SDK publishes, so no catalog entry was written for it`));const e=new Set(o.workspace?.catalog.keys()),s=new Map([...n].filter(([r])=>!e.has(r)));if(s.size===0)return;const i=t.read("pnpm-workspace.yaml")??"";t.write("pnpm-workspace.yaml",S(i,s),`catalog: ${[...s.keys()].join(", ")}`)},"catalogPresent"),D=a((o,t)=>{const n=t.read("pnpm-workspace.yaml");n!==null&&o.workspace!==null&&t.write("pnpm-workspace.yaml",v(n,l),"remove @rexezuge/* overrides");for(const e of o.packages){const s=t.read(e.path),i=e.json?.pnpm?.overrides;if(s===null||i===void 0)continue;let r=s;const c=Object.keys(i).filter(l);for(const p of c)r=f(r,["pnpm","overrides",p],void 0);r!==s&&t.write(e.path,r,"remove @rexezuge/* pnpm.overrides")}},"noOverrides"),N=a((o,t)=>{for(const n of o.packages){let e=t.read(n.path);if(e===null)continue;const s=e;for(const i of["dependencies","devDependencies","peerDependencies","optionalDependencies"]){const r=n.json?.[i];for(const[c,p]of Object.entries(r??{}))l(c)&&typeof p=="string"&&!p.startsWith("catalog:")&&!d(p)&&(e=f(e,[i,c],"catalog:"))}e!==s&&t.write(n.path,e,"@rexezuge/* to catalog:")}},"catalogProtocol"),C=a((o,t)=>{const n=o.files.filter(e=>e==="tsconfig.json"||/^apps\/[^/]+\/tsconfig\.json$/.test(e));for(const e of n.length===0?["tsconfig.json"]:n){const s=t.read(e)??`{}
|
|
3
|
+
`;if(A(s))continue;const i=e==="tsconfig.json"?"base":/apps\/web\//.test(e)?"web":"worker";t.write(e,P(s,i),`extends the ${i} preset`)}},"tsconfigPreset"),I={printWidth:140,singleQuote:!0,semi:!0,useTabs:!1},F=a((o,t)=>{const n=o.files.filter(r=>/^\.prettierrc(?:\.json)?$/.test(r)),e=a(r=>{try{const c=JSON.parse(r??"");return Object.entries(c).every(([p,k])=>I[p]===k)}catch{return!1}},"redundant");if(n.some(r=>!e(o.read(r))))return;for(const r of n)t.delete(r,"redundant with the preset");const i=t.read("package.json");i!==null&&t.write("package.json",f(i,["prettier"],"@rexezuge/tooling/prettier"),"prettier preset")},"prettierPreset"),_=a((o,t)=>{if(!o.exists("AGENTS.md"))return;const n=o.read("CLAUDE.md");n!==null&&n!==o.read("AGENTS.md")||t.symlink("CLAUDE.md","AGENTS.md","symlink to AGENTS.md")},"claudeSymlink"),L=a((o,t)=>t.write(".nvmrc",`24
|
|
4
|
+
`,"Node 24"),"nodeVersion"),$={checks:"pnpm run typecheck && pnpm run lint:check && pnpm run test && pnpm run format:check",typecheck:"tsc --noEmit",lint:"eslint --fix --quiet .","lint:check":"eslint --quiet .",format:"prettier --write .","format:check":"prettier --check .",test:"vitest run","test:coverage":"vitest run --coverage",typegen:"wrangler types"},G=a((o,t)=>{const n=t.read("package.json"),e=o.packages.find(c=>c.path==="package.json")?.json;if(n===null||e===null||e===void 0)return;const s=e.scripts??{};let i=n;const r=[];for(const c of b)s[c]===void 0&&(i=f(i,["scripts",c],$[c]),r.push(c));r.length>0&&t.write("package.json",i,`scripts: ${r.join(", ")}`)},"canonicalScripts"),K=a((o,t)=>{const n=u.find(e=>e.key==="pages-function");if(n!==void 0)for(const e of m(o,n))(o.read(e)??"").includes("API_WORKER")&&t.write(e,`export { onRequest } from '@rexezuge/tooling/pages-proxy';
|
|
5
|
+
`,"one-line pages-proxy re-export")},"pagesFunction"),M=a((o,t)=>{const n=u.find(e=>e.key==="cloudflare-workers-mock");if(n!==void 0)for(const e of m(o,n))t.write(e,`export * from '@rexezuge/testing/cloudflare-workers';
|
|
6
|
+
`,"re-export of @rexezuge/testing")},"workersMock"),U=a((o,t)=>{for(const{name:n,files:e}of T(o))for(const s of e)t.delete(s,`unreferenced family action ${n}`)},"staleActionsFix"),oe={"catalog.present":z,"catalog.no-overrides":D,"catalog.protocol":N,"presets.tsconfig":C,"presets.prettier":F,"files.claude-symlink":_,"files.node-version":L,"scripts.canonical":G,"vendored.pages-function":K,"vendored.cloudflare-workers-mock":M,"vendored.prepare-wrangler":g(["prepare-wrangler"]),"vendored.init-secrets":g(["init-secrets"]),"workflows.callers":R,"workflows.backup-main":O,"workflows.stale-actions":U};export{oe as FIXES};
|
package/dist/sync/fixes.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/sync/fixes.ts"],
|
|
4
|
-
"sourcesContent": ["import { applyEdits, modify } from 'jsonc-parser';\nimport { isLocalSpec, kitDependencies } from '../repo.ts';\nimport type { Repo } from '../repo.ts';\nimport { removeOverrides, setCatalogEntries } from '../workspace-yaml.ts';\nimport { CLI_VERSION, KIT_PACKAGES } from '../version.ts';\nimport { CANONICAL_SCRIPTS } from '../doctor/checks/files.ts';\nimport { extendsPreset } from '../doctor/checks/presets.ts';\nimport { vendoredFiles, VENDORED_RULES } from '../doctor/checks/vendored.ts';\nimport { applyPreset } from './tsconfig.ts';\nimport { staleActions } from '../doctor/checks/actions.ts';\nimport { workflowFixes } from './workflows.ts';\nimport type { Plan } from './plan.ts';\n\n/**\n * A repair for one failing, auto-fixable check. It edits the plan, never the disk; whatever it cannot do\n * safely it leaves alone, and the check keeps failing in the report that follows.\n */\nexport type Fix = (repo: Repo, plan: Plan) => void;\n\nconst isKit = (name: string): boolean => name.startsWith('@rexezuge/');\n\nfunction editJson(text: string, path: Array<string | number>, value: unknown): string {\n return applyEdits(text, modify(text, path, value, { formattingOptions: { insertSpaces: true, tabSize: 2, eol: '\\n' } }));\n}\n\nconst catalogPresent: Fix = (repo, plan) => {\n const wanted = new Map<string, string>();\n for (const pkg of repo.packages) {\n for (const [name, spec] of kitDependencies(pkg.json)) {\n if (isLocalSpec(spec)) continue; // a link/file/workspace specifier never goes through the catalog\n if (KIT_PACKAGES.has(name))\n wanted.set(name, CLI_VERSION); // exact, not a range: the packages release in lockstep\n else plan.note(`${name}: not a package this SDK publishes, so no catalog entry was written for it`);\n }\n }\n const have = new Set(repo.workspace?.catalog.keys());\n const missing = new Map([...wanted].filter(([name]) => !have.has(name)));\n if (missing.size === 0) return;\n const text = plan.read('pnpm-workspace.yaml') ?? '';\n plan.write('pnpm-workspace.yaml', setCatalogEntries(text, missing), `catalog: ${[...missing.keys()].join(', ')}`);\n};\n\nconst noOverrides: Fix = (repo, plan) => {\n const yaml = plan.read('pnpm-workspace.yaml');\n if (yaml !== null && repo.workspace !== null)\n plan.write('pnpm-workspace.yaml', removeOverrides(yaml, isKit), 'remove @rexezuge/* overrides');\n for (const pkg of repo.packages) {\n const text = plan.read(pkg.path);\n const nested = (pkg.json?.['pnpm'] as { overrides?: Record<string, unknown> } | undefined)?.overrides;\n if (text === null || nested === undefined) continue;\n let next = text;\n const pinned = Object.keys(nested).filter(isKit);\n for (const key of pinned) next = editJson(next, ['pnpm', 'overrides', key], undefined);\n if (next !== text) plan.write(pkg.path, next, 'remove @rexezuge/* pnpm.overrides');\n }\n};\n\nconst catalogProtocol: Fix = (repo, plan) => {\n for (const pkg of repo.packages) {\n let text = plan.read(pkg.path);\n if (text === null) continue;\n const before = text;\n for (const field of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']) {\n const block = pkg.json?.[field] as Record<string, unknown> | undefined;\n for (const [name, spec] of Object.entries(block ?? {})) {\n if (isKit(name) && typeof spec === 'string' && !spec.startsWith('catalog:') && !isLocalSpec(spec)) {\n text = editJson(text, [field, name], 'catalog:');\n }\n }\n }\n if (text !== before) plan.write(pkg.path, text, '@rexezuge/* to catalog:');\n }\n};\n\nconst tsconfigPreset: Fix = (repo, plan) => {\n const files = repo.files.filter((file) => file === 'tsconfig.json' || /^apps\\/[^/]+\\/tsconfig\\.json$/.test(file));\n for (const file of files.length === 0 ? ['tsconfig.json'] : files) {\n const text = plan.read(file) ?? '{}\\n';\n if (extendsPreset(text)) continue;\n const preset = file === 'tsconfig.json' ? 'base' : /apps\\/web\\//.test(file) ? 'web' : 'worker';\n plan.write(file, applyPreset(text, preset), `extends the ${preset} preset`);\n }\n};\n\nconst PRETTIER_PRESET = { printWidth: 140, singleQuote: true, semi: true, useTabs: false } as const;\n\nconst prettierPreset: Fix = (repo, plan) => {\n const rc = repo.files.filter((file) => /^\\.prettierrc(?:\\.json)?$/.test(file));\n // Delete a hand-written rc only when it says nothing the preset does not (a custom option would be lost).\n const redundant = (text: string | null): boolean => {\n try {\n const parsed = JSON.parse(text ?? '') as Record<string, unknown>;\n return Object.entries(parsed).every(([key, value]) => (PRETTIER_PRESET as Record<string, unknown>)[key] === value);\n } catch {\n return false;\n }\n };\n const blocking = rc.some((file) => !redundant(repo.read(file)));\n if (blocking) return;\n for (const file of rc) plan.delete(file, 'redundant with the preset');\n const text = plan.read('package.json');\n if (text !== null) plan.write('package.json', editJson(text, ['prettier'], '@rexezuge/tooling/prettier'), 'prettier preset');\n};\n\nconst claudeSymlink: Fix = (repo, plan) => {\n if (!repo.exists('AGENTS.md')) return;\n const existing = repo.read('CLAUDE.md');\n if (existing !== null && existing !== repo.read('AGENTS.md')) return; // a distinct regular file is the repo's own text\n plan.symlink('CLAUDE.md', 'AGENTS.md', 'symlink to AGENTS.md');\n};\n\nconst nodeVersion: Fix = (_repo, plan) => plan.write('.nvmrc', '24\\n', 'Node 24');\n\nconst DEFAULT_SCRIPTS: Record<(typeof CANONICAL_SCRIPTS)[number], string> = {\n checks: 'pnpm run typecheck && pnpm run lint:check && pnpm run test && pnpm run format:check',\n typecheck: 'tsc --noEmit',\n lint: 'eslint --fix --quiet .',\n 'lint:check': 'eslint --quiet .',\n format: 'prettier --write .',\n 'format:check': 'prettier --check .',\n test: 'vitest run',\n 'test:coverage': 'vitest run --coverage',\n typegen: 'wrangler types',\n};\n\nconst canonicalScripts: Fix = (repo, plan) => {\n const text = plan.read('package.json');\n const json = repo.packages.find((pkg) => pkg.path === 'package.json')?.json;\n if (text === null || json === null || json === undefined) return;\n const scripts = (json['scripts'] ?? {}) as Record<string, unknown>;\n let next = text;\n const added: string[] = [];\n for (const name of CANONICAL_SCRIPTS) {\n if (scripts[name] !== undefined) continue;\n next = editJson(next, ['scripts', name], DEFAULT_SCRIPTS[name]);\n added.push(name);\n }\n if (added.length > 0) plan.write('package.json', next, `scripts: ${added.join(', ')}`);\n};\n\n/**\n * `functions/[[path]].ts` becomes the one-line re-export, but only for a file that is the proxy\n * (it names `API_WORKER`); any other function in that path is the repo's code and stays.\n */\nconst pagesFunction: Fix = (repo, plan) => {\n const rule = VENDORED_RULES.find((entry) => entry.key === 'pages-function');\n if (rule === undefined) return;\n for (const file of vendoredFiles(repo, rule)) {\n if ((repo.read(file) ?? '').includes('API_WORKER')) {\n plan.write(file, \"export { onRequest } from '@rexezuge/tooling/pages-proxy';\\n\", 'one-line pages-proxy re-export');\n }\n }\n};\n\n/**\n * The `cloudflare:workers` mock becomes a pure re-export of the kit's superset. Rewritten, not deleted:\n * suites import it by path.\n */\nconst workersMock: Fix = (repo, plan) => {\n const rule = VENDORED_RULES.find((entry) => entry.key === 'cloudflare-workers-mock');\n if (rule === undefined) return;\n for (const file of vendoredFiles(repo, rule)) {\n plan.write(file, \"export * from '@rexezuge/testing/cloudflare-workers';\\n\", 're-export of @rexezuge/testing');\n }\n};\n\n/**\n * Removes the family's deleted composite actions (`setup-env`, `retry-step`) when nothing references them; no other action.\n */\nconst staleActionsFix: Fix = (repo, plan) => {\n for (const { name, files } of staleActions(repo)) {\n for (const file of files) plan.delete(file, `unreferenced family action ${name}`);\n }\n};\n\n/**\n * Auto-fixes by check id. Ids absent here are reported by doctor and left to a human.\n */\nexport const FIXES: Readonly<Record<string, Fix>> = {\n 'catalog.present': catalogPresent,\n 'catalog.no-overrides': noOverrides,\n 'catalog.protocol': catalogProtocol,\n 'presets.tsconfig': tsconfigPreset,\n 'presets.prettier': prettierPreset,\n 'files.claude-symlink': claudeSymlink,\n 'files.node-version': nodeVersion,\n 'scripts.canonical': canonicalScripts,\n 'vendored.pages-function': pagesFunction,\n 'vendored.cloudflare-workers-mock': workersMock,\n 'workflows.callers': workflowFixes,\n 'workflows.stale-actions': staleActionsFix,\n};\n"],
|
|
5
|
-
"mappings": "+EAAA,OAAS,cAAAA,EAAY,UAAAC,MAAc,eACnC,OAAS,eAAAC,EAAa,mBAAAC,MAAuB,aAE7C,OAAS,mBAAAC,EAAiB,qBAAAC,MAAyB,uBACnD,OAAS,eAAAC,EAAa,gBAAAC,MAAoB,gBAC1C,OAAS,qBAAAC,MAAyB,4BAClC,OAAS,iBAAAC,MAAqB,8BAC9B,OAAS,iBAAAC,EAAe,kBAAAC,MAAsB,+BAC9C,OAAS,eAAAC,MAAmB,gBAC5B,OAAS,gBAAAC,MAAoB,8BAC7B,OAAS,iBAAAC,MAAqB,
|
|
6
|
-
"names": ["applyEdits", "modify", "isLocalSpec", "kitDependencies", "removeOverrides", "setCatalogEntries", "CLI_VERSION", "KIT_PACKAGES", "CANONICAL_SCRIPTS", "extendsPreset", "vendoredFiles", "VENDORED_RULES", "applyPreset", "staleActions", "workflowFixes", "isKit", "__name", "name", "editJson", "text", "path", "value", "catalogPresent", "repo", "plan", "wanted", "pkg", "spec", "have", "missing", "noOverrides", "yaml", "nested", "next", "pinned", "key", "catalogProtocol", "before", "field", "block", "tsconfigPreset", "files", "file", "preset", "PRETTIER_PRESET", "prettierPreset", "rc", "redundant", "parsed", "claudeSymlink", "existing", "nodeVersion", "_repo", "DEFAULT_SCRIPTS", "canonicalScripts", "json", "scripts", "added", "pagesFunction", "rule", "entry", "workersMock", "staleActionsFix", "FIXES"]
|
|
4
|
+
"sourcesContent": ["import { applyEdits, modify } from 'jsonc-parser';\nimport { isLocalSpec, kitDependencies } from '../repo.ts';\nimport type { Repo } from '../repo.ts';\nimport { removeOverrides, setCatalogEntries } from '../workspace-yaml.ts';\nimport { CLI_VERSION, KIT_PACKAGES } from '../version.ts';\nimport { CANONICAL_SCRIPTS } from '../doctor/checks/files.ts';\nimport { extendsPreset } from '../doctor/checks/presets.ts';\nimport { vendoredFiles, VENDORED_RULES } from '../doctor/checks/vendored.ts';\nimport { applyPreset } from './tsconfig.ts';\nimport { staleActions } from '../doctor/checks/actions.ts';\nimport { backupMainFix, workflowFixes } from './workflows.ts';\nimport { vendoredScriptFixes } from './scripts.ts';\nimport type { Plan } from './plan.ts';\n\n/**\n * A repair for one failing, auto-fixable check. It edits the plan, never the disk; whatever it cannot do\n * safely it leaves alone, and the check keeps failing in the report that follows.\n */\nexport type Fix = (repo: Repo, plan: Plan) => void;\n\nconst isKit = (name: string): boolean => name.startsWith('@rexezuge/');\n\nfunction editJson(text: string, path: Array<string | number>, value: unknown): string {\n return applyEdits(text, modify(text, path, value, { formattingOptions: { insertSpaces: true, tabSize: 2, eol: '\\n' } }));\n}\n\nconst catalogPresent: Fix = (repo, plan) => {\n const wanted = new Map<string, string>();\n for (const pkg of repo.packages) {\n for (const [name, spec] of kitDependencies(pkg.json)) {\n if (isLocalSpec(spec)) continue; // a link/file/workspace specifier never goes through the catalog\n if (KIT_PACKAGES.has(name))\n wanted.set(name, CLI_VERSION); // exact, not a range: the packages release in lockstep\n else plan.note(`${name}: not a package this SDK publishes, so no catalog entry was written for it`);\n }\n }\n const have = new Set(repo.workspace?.catalog.keys());\n const missing = new Map([...wanted].filter(([name]) => !have.has(name)));\n if (missing.size === 0) return;\n const text = plan.read('pnpm-workspace.yaml') ?? '';\n plan.write('pnpm-workspace.yaml', setCatalogEntries(text, missing), `catalog: ${[...missing.keys()].join(', ')}`);\n};\n\nconst noOverrides: Fix = (repo, plan) => {\n const yaml = plan.read('pnpm-workspace.yaml');\n if (yaml !== null && repo.workspace !== null)\n plan.write('pnpm-workspace.yaml', removeOverrides(yaml, isKit), 'remove @rexezuge/* overrides');\n for (const pkg of repo.packages) {\n const text = plan.read(pkg.path);\n const nested = (pkg.json?.['pnpm'] as { overrides?: Record<string, unknown> } | undefined)?.overrides;\n if (text === null || nested === undefined) continue;\n let next = text;\n const pinned = Object.keys(nested).filter(isKit);\n for (const key of pinned) next = editJson(next, ['pnpm', 'overrides', key], undefined);\n if (next !== text) plan.write(pkg.path, next, 'remove @rexezuge/* pnpm.overrides');\n }\n};\n\nconst catalogProtocol: Fix = (repo, plan) => {\n for (const pkg of repo.packages) {\n let text = plan.read(pkg.path);\n if (text === null) continue;\n const before = text;\n for (const field of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']) {\n const block = pkg.json?.[field] as Record<string, unknown> | undefined;\n for (const [name, spec] of Object.entries(block ?? {})) {\n if (isKit(name) && typeof spec === 'string' && !spec.startsWith('catalog:') && !isLocalSpec(spec)) {\n text = editJson(text, [field, name], 'catalog:');\n }\n }\n }\n if (text !== before) plan.write(pkg.path, text, '@rexezuge/* to catalog:');\n }\n};\n\nconst tsconfigPreset: Fix = (repo, plan) => {\n const files = repo.files.filter((file) => file === 'tsconfig.json' || /^apps\\/[^/]+\\/tsconfig\\.json$/.test(file));\n for (const file of files.length === 0 ? ['tsconfig.json'] : files) {\n const text = plan.read(file) ?? '{}\\n';\n if (extendsPreset(text)) continue;\n const preset = file === 'tsconfig.json' ? 'base' : /apps\\/web\\//.test(file) ? 'web' : 'worker';\n plan.write(file, applyPreset(text, preset), `extends the ${preset} preset`);\n }\n};\n\nconst PRETTIER_PRESET = { printWidth: 140, singleQuote: true, semi: true, useTabs: false } as const;\n\nconst prettierPreset: Fix = (repo, plan) => {\n const rc = repo.files.filter((file) => /^\\.prettierrc(?:\\.json)?$/.test(file));\n // Delete a hand-written rc only when it says nothing the preset does not (a custom option would be lost).\n const redundant = (text: string | null): boolean => {\n try {\n const parsed = JSON.parse(text ?? '') as Record<string, unknown>;\n return Object.entries(parsed).every(([key, value]) => (PRETTIER_PRESET as Record<string, unknown>)[key] === value);\n } catch {\n return false;\n }\n };\n const blocking = rc.some((file) => !redundant(repo.read(file)));\n if (blocking) return;\n for (const file of rc) plan.delete(file, 'redundant with the preset');\n const text = plan.read('package.json');\n if (text !== null) plan.write('package.json', editJson(text, ['prettier'], '@rexezuge/tooling/prettier'), 'prettier preset');\n};\n\nconst claudeSymlink: Fix = (repo, plan) => {\n if (!repo.exists('AGENTS.md')) return;\n const existing = repo.read('CLAUDE.md');\n if (existing !== null && existing !== repo.read('AGENTS.md')) return; // a distinct regular file is the repo's own text\n plan.symlink('CLAUDE.md', 'AGENTS.md', 'symlink to AGENTS.md');\n};\n\nconst nodeVersion: Fix = (_repo, plan) => plan.write('.nvmrc', '24\\n', 'Node 24');\n\nconst DEFAULT_SCRIPTS: Record<(typeof CANONICAL_SCRIPTS)[number], string> = {\n checks: 'pnpm run typecheck && pnpm run lint:check && pnpm run test && pnpm run format:check',\n typecheck: 'tsc --noEmit',\n lint: 'eslint --fix --quiet .',\n 'lint:check': 'eslint --quiet .',\n format: 'prettier --write .',\n 'format:check': 'prettier --check .',\n test: 'vitest run',\n 'test:coverage': 'vitest run --coverage',\n typegen: 'wrangler types',\n};\n\nconst canonicalScripts: Fix = (repo, plan) => {\n const text = plan.read('package.json');\n const json = repo.packages.find((pkg) => pkg.path === 'package.json')?.json;\n if (text === null || json === null || json === undefined) return;\n const scripts = (json['scripts'] ?? {}) as Record<string, unknown>;\n let next = text;\n const added: string[] = [];\n for (const name of CANONICAL_SCRIPTS) {\n if (scripts[name] !== undefined) continue;\n next = editJson(next, ['scripts', name], DEFAULT_SCRIPTS[name]);\n added.push(name);\n }\n if (added.length > 0) plan.write('package.json', next, `scripts: ${added.join(', ')}`);\n};\n\n/**\n * `functions/[[path]].ts` becomes the one-line re-export, but only for a file that is the proxy\n * (it names `API_WORKER`); any other function in that path is the repo's code and stays.\n */\nconst pagesFunction: Fix = (repo, plan) => {\n const rule = VENDORED_RULES.find((entry) => entry.key === 'pages-function');\n if (rule === undefined) return;\n for (const file of vendoredFiles(repo, rule)) {\n if ((repo.read(file) ?? '').includes('API_WORKER')) {\n plan.write(file, \"export { onRequest } from '@rexezuge/tooling/pages-proxy';\\n\", 'one-line pages-proxy re-export');\n }\n }\n};\n\n/**\n * The `cloudflare:workers` mock becomes a pure re-export of the kit's superset. Rewritten, not deleted:\n * suites import it by path.\n */\nconst workersMock: Fix = (repo, plan) => {\n const rule = VENDORED_RULES.find((entry) => entry.key === 'cloudflare-workers-mock');\n if (rule === undefined) return;\n for (const file of vendoredFiles(repo, rule)) {\n plan.write(file, \"export * from '@rexezuge/testing/cloudflare-workers';\\n\", 're-export of @rexezuge/testing');\n }\n};\n\n/**\n * Removes the family's deleted composite actions (`setup-env`, `retry-step`) when nothing references them; no other action.\n */\nconst staleActionsFix: Fix = (repo, plan) => {\n for (const { name, files } of staleActions(repo)) {\n for (const file of files) plan.delete(file, `unreferenced family action ${name}`);\n }\n};\n\n/**\n * Auto-fixes by check id. Ids absent here are reported by doctor and left to a human.\n */\nexport const FIXES: Readonly<Record<string, Fix>> = {\n 'catalog.present': catalogPresent,\n 'catalog.no-overrides': noOverrides,\n 'catalog.protocol': catalogProtocol,\n 'presets.tsconfig': tsconfigPreset,\n 'presets.prettier': prettierPreset,\n 'files.claude-symlink': claudeSymlink,\n 'files.node-version': nodeVersion,\n 'scripts.canonical': canonicalScripts,\n 'vendored.pages-function': pagesFunction,\n 'vendored.cloudflare-workers-mock': workersMock,\n 'vendored.prepare-wrangler': vendoredScriptFixes(['prepare-wrangler']),\n 'vendored.init-secrets': vendoredScriptFixes(['init-secrets']),\n 'workflows.callers': workflowFixes,\n 'workflows.backup-main': backupMainFix,\n 'workflows.stale-actions': staleActionsFix,\n};\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAS,cAAAA,EAAY,UAAAC,MAAc,eACnC,OAAS,eAAAC,EAAa,mBAAAC,MAAuB,aAE7C,OAAS,mBAAAC,EAAiB,qBAAAC,MAAyB,uBACnD,OAAS,eAAAC,EAAa,gBAAAC,MAAoB,gBAC1C,OAAS,qBAAAC,MAAyB,4BAClC,OAAS,iBAAAC,MAAqB,8BAC9B,OAAS,iBAAAC,EAAe,kBAAAC,MAAsB,+BAC9C,OAAS,eAAAC,MAAmB,gBAC5B,OAAS,gBAAAC,MAAoB,8BAC7B,OAAS,iBAAAC,EAAe,iBAAAC,MAAqB,iBAC7C,OAAS,uBAAAC,MAA2B,eASpC,MAAMC,EAAQC,EAACC,GAA0BA,EAAK,WAAW,YAAY,EAAvD,SAEd,SAASC,EAASC,EAAcC,EAA8BC,EAAc,CAC1E,OAAOvB,EAAWqB,EAAMpB,EAAOoB,EAAMC,EAAMC,EAAO,CAAE,kBAAmB,CAAE,aAAc,GAAM,QAAS,EAAG,IAAK;CAAI,CAAE,CAAE,CAAC,CACzH,CAFSL,EAAAE,EAAA,YAIT,MAAMI,EAAsBN,EAAA,CAACO,EAAMC,IAAQ,CACzC,MAAMC,EAAS,IAAI,IACnB,UAAWC,KAAOH,EAAK,SACrB,SAAW,CAACN,EAAMU,CAAI,IAAK1B,EAAgByB,EAAI,IAAI,EAC7C1B,EAAY2B,CAAI,IAChBtB,EAAa,IAAIY,CAAI,EACvBQ,EAAO,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verrides", "setCatalogEntries", "CLI_VERSION", "KIT_PACKAGES", "CANONICAL_SCRIPTS", "extendsPreset", "vendoredFiles", "VENDORED_RULES", "applyPreset", "staleActions", "backupMainFix", "workflowFixes", "vendoredScriptFixes", "isKit", "__name", "name", "editJson", "text", "path", "value", "catalogPresent", "repo", "plan", "wanted", "pkg", "spec", "have", "missing", "noOverrides", "yaml", "nested", "next", "pinned", "key", "catalogProtocol", "before", "field", "block", "tsconfigPreset", "files", "file", "preset", "PRETTIER_PRESET", "prettierPreset", "rc", "redundant", "parsed", "claudeSymlink", "existing", "nodeVersion", "_repo", "DEFAULT_SCRIPTS", "canonicalScripts", "json", "scripts", "added", "pagesFunction", "rule", "entry", "workersMock", "staleActionsFix", "FIXES"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Repo } from '../repo.ts';
|
|
2
|
+
import type { Plan } from './plan.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Delete the vendored copies of `prepare-wrangler-config` / `init-secrets` (the kit's `rexezuge prepare-wrangler` /
|
|
5
|
+
* `init-secrets` replace them), then the tooling they leave orphaned.
|
|
6
|
+
*/
|
|
7
|
+
export declare function vendoredScriptFixes(keys: readonly string[]): (repo: Repo, plan: Plan) => void;
|
|
8
|
+
//# sourceMappingURL=scripts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripts.d.ts","sourceRoot":"","sources":["../../src/sync/scripts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AA0BtC;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,KAAK,IAAI,CAQ7F"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var f=Object.defineProperty;var n=(c,e)=>f(c,"name",{value:e,configurable:!0});import{applyEdits as a,modify as l}from"jsonc-parser";import{vendoredFiles as u,VENDORED_RULES as h}from"../doctor/checks/vendored.js";const m=/\.(?:[cm]?ts|tsx)$/;function g(c,e){if(c.files.filter(t=>t.startsWith("scripts/")&&m.test(t)&&e.read(t)!==null).length>0)return;e.read("scripts/tsconfig.json")!==null&&e.delete("scripts/tsconfig.json","orphaned: scripts/ has no TypeScript left");const s=e.read("package.json"),i=c.packages.find(t=>t.path==="package.json")?.json?.scripts;if(s===null||i?.["typecheck:scripts"]===void 0)return;const o=l(s,["scripts","typecheck:scripts"],void 0,{formattingOptions:{insertSpaces:!0,tabSize:2,eol:`
|
|
2
|
+
`}});e.write("package.json",a(s,o),"remove the typecheck:scripts script (scripts/ is empty of TypeScript)");const p=Object.entries(i).filter(([t,d])=>t!=="typecheck:scripts"&&String(d).includes("typecheck:scripts"));for(const[t]of p)e.note(`package.json script "${t}" still runs typecheck:scripts; remove that call`)}n(g,"pruneScriptsTooling");function j(c){return(e,r)=>{for(const s of h)if(c.includes(s.key))for(const i of u(e,s))r.delete(i,`vendored ${s.key}: replaced by the rexezuge command`);g(e,r)}}n(j,"vendoredScriptFixes");export{j as vendoredScriptFixes};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/sync/scripts.ts"],
|
|
4
|
+
"sourcesContent": ["import { applyEdits, modify } from 'jsonc-parser';\nimport { vendoredFiles, VENDORED_RULES } from '../doctor/checks/vendored.ts';\nimport type { Repo } from '../repo.ts';\nimport type { Plan } from './plan.ts';\n\nconst SCRIPT_SOURCE = /\\.(?:[cm]?ts|tsx)$/;\n\n/**\n * Remove the orphaned script tooling a vendored-script removal leaves behind: `scripts/tsconfig.json` and the\n * `typecheck:scripts` script. Only when no TypeScript file remains under `scripts/` once the plan is applied; a\n * repo that still has its own script keeps the tsconfig that typechecks it.\n */\nfunction pruneScriptsTooling(repo: Repo, plan: Plan): void {\n const remaining = repo.files.filter((file) => file.startsWith('scripts/') && SCRIPT_SOURCE.test(file) && plan.read(file) !== null);\n if (remaining.length > 0) return;\n if (plan.read('scripts/tsconfig.json') !== null) plan.delete('scripts/tsconfig.json', 'orphaned: scripts/ has no TypeScript left');\n const text = plan.read('package.json');\n const scripts = repo.packages.find((pkg) => pkg.path === 'package.json')?.json?.['scripts'] as Record<string, unknown> | undefined;\n if (text === null || scripts?.['typecheck:scripts'] === undefined) return;\n const edits = modify(text, ['scripts', 'typecheck:scripts'], undefined, {\n formattingOptions: { insertSpaces: true, tabSize: 2, eol: '\\n' },\n });\n plan.write('package.json', applyEdits(text, edits), 'remove the typecheck:scripts script (scripts/ is empty of TypeScript)');\n const chained = Object.entries(scripts).filter(\n ([name, value]) => name !== 'typecheck:scripts' && String(value).includes('typecheck:scripts'),\n );\n for (const [name] of chained) plan.note(`package.json script \"${name}\" still runs typecheck:scripts; remove that call`);\n}\n\n/**\n * Delete the vendored copies of `prepare-wrangler-config` / `init-secrets` (the kit's `rexezuge prepare-wrangler` /\n * `init-secrets` replace them), then the tooling they leave orphaned.\n */\nexport function vendoredScriptFixes(keys: readonly string[]): (repo: Repo, plan: Plan) => void {\n return (repo, plan) => {\n for (const rule of VENDORED_RULES) {\n if (!keys.includes(rule.key)) continue;\n for (const file of vendoredFiles(repo, rule)) plan.delete(file, `vendored ${rule.key}: replaced by the rexezuge command`);\n }\n pruneScriptsTooling(repo, plan);\n };\n}\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAS,cAAAA,EAAY,UAAAC,MAAc,eACnC,OAAS,iBAAAC,EAAe,kBAAAC,MAAsB,+BAI9C,MAAMC,EAAgB,qBAOtB,SAASC,EAAoBC,EAAYC,EAAU,CAEjD,GADkBD,EAAK,MAAM,OAAQE,GAASA,EAAK,WAAW,UAAU,GAAKJ,EAAc,KAAKI,CAAI,GAAKD,EAAK,KAAKC,CAAI,IAAM,IAAI,EACnH,OAAS,EAAG,OACtBD,EAAK,KAAK,uBAAuB,IAAM,MAAMA,EAAK,OAAO,wBAAyB,2CAA2C,EACjI,MAAME,EAAOF,EAAK,KAAK,cAAc,EAC/BG,EAAUJ,EAAK,SAAS,KAAMK,GAAQA,EAAI,OAAS,cAAc,GAAG,MAAO,QACjF,GAAIF,IAAS,MAAQC,IAAU,mBAAmB,IAAM,OAAW,OACnE,MAAME,EAAQX,EAAOQ,EAAM,CAAC,UAAW,mBAAmB,EAAG,OAAW,CACtE,kBAAmB,CAAE,aAAc,GAAM,QAAS,EAAG,IAAK;CAAI,EAC/D,EACDF,EAAK,MAAM,eAAgBP,EAAWS,EAAMG,CAAK,EAAG,uEAAuE,EAC3H,MAAMC,EAAU,OAAO,QAAQH,CAAO,EAAE,OACtC,CAAC,CAACI,EAAMC,CAAK,IAAMD,IAAS,qBAAuB,OAAOC,CAAK,EAAE,SAAS,mBAAmB,CAAC,EAEhG,SAAW,CAACD,CAAI,IAAKD,EAASN,EAAK,KAAK,wBAAwBO,CAAI,kDAAkD,CACxH,CAfSE,EAAAX,EAAA,uBAqBH,SAAUY,EAAoBC,EAAuB,CACzD,MAAO,CAACZ,EAAMC,IAAQ,CACpB,UAAWY,KAAQhB,EACjB,GAAKe,EAAK,SAASC,EAAK,GAAG,EAC3B,UAAWX,KAAQN,EAAcI,EAAMa,CAAI,EAAGZ,EAAK,OAAOC,EAAM,YAAYW,EAAK,GAAG,oCAAoC,EAE1Hd,EAAoBC,EAAMC,CAAI,CAChC,CACF,CARgBS,EAAAC,EAAA",
|
|
6
|
+
"names": ["applyEdits", "modify", "vendoredFiles", "VENDORED_RULES", "SCRIPT_SOURCE", "pruneScriptsTooling", "repo", "plan", "file", "text", "scripts", "pkg", "edits", "chained", "name", "value", "__name", "vendoredScriptFixes", "keys", "rule"]
|
|
7
|
+
}
|
package/dist/sync/workflows.d.ts
CHANGED
|
@@ -5,4 +5,9 @@ import type { Plan } from './plan.ts';
|
|
|
5
5
|
* name when it already has the family's, and is renamed to it otherwise (one caller per kind).
|
|
6
6
|
*/
|
|
7
7
|
export declare function workflowFixes(repo: Repo, plan: Plan): void;
|
|
8
|
+
/**
|
|
9
|
+
* Create the `backup-main.yml` caller when no workflow calls the reusable one. Never replaces a file: an existing
|
|
10
|
+
* `backup-main.yml` that is not a caller is converted by {@link workflowFixes}, and one that already is stays.
|
|
11
|
+
*/
|
|
12
|
+
export declare function backupMainFix(_repo: Repo, plan: Plan): void;
|
|
8
13
|
//# sourceMappingURL=workflows.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/sync/workflows.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAItC;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAY1D"}
|
|
1
|
+
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../../src/sync/workflows.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAItC;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAY1D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAI3D"}
|
package/dist/sync/workflows.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var f=Object.defineProperty;var l=(e,o)=>f(e,"name",{value:o,configurable:!0});import{WORKFLOW_REF as u}from"../workflow-callers.js";import{callerFile as n,callerKindForFile as w,renderCaller as a}from"../workflow-callers.js";const d=l(e=>e.includes(`uses: ${u}/`),"isCaller");function p(e,o){const i=new Set,s=e.files.filter(t=>/^\.github\/workflows\/[^/]+\.ya?ml$/.test(t));for(const t of s){if(d(e.read(t)??""))continue;const r=w(t);if(r===null||i.has(r))continue;i.add(r);const c=`.github/workflows/${n(r)}`;c!==t&&o.delete(t,`replaced by ${n(r)}`),o.write(c,a(r),`caller of ${r}`)}}l(p,"workflowFixes");function F(e,o){const i=`.github/workflows/${n("backup-main")}`;o.read(i)===null&&o.write(i,a("backup-main"),"caller of backup-main (secrets-gated)")}l(F,"backupMainFix");export{F as backupMainFix,p as workflowFixes};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/sync/workflows.ts"],
|
|
4
|
-
"sourcesContent": ["import { WORKFLOW_REF } from '../workflow-callers.ts';\nimport { callerFile, callerKindForFile, renderCaller } from '../workflow-callers.ts';\nimport type { Repo } from '../repo.ts';\nimport type { Plan } from './plan.ts';\n\nconst isCaller = (content: string): boolean => content.includes(`uses: ${WORKFLOW_REF}/`);\n\n/**\n * Replace every non-caller workflow whose name the family knows with its caller. The file keeps its\n * name when it already has the family's, and is renamed to it otherwise (one caller per kind).\n */\nexport function workflowFixes(repo: Repo, plan: Plan): void {\n const claimed = new Set<string>();\n const workflows = repo.files.filter((entry) => /^\\.github\\/workflows\\/[^/]+\\.ya?ml$/.test(entry));\n for (const file of workflows) {\n if (isCaller(repo.read(file) ?? '')) continue;\n const kind = callerKindForFile(file);\n if (kind === null || claimed.has(kind)) continue;\n claimed.add(kind);\n const target = `.github/workflows/${callerFile(kind)}`;\n if (target !== file) plan.delete(file, `replaced by ${callerFile(kind)}`);\n plan.write(target, renderCaller(kind), `caller of ${kind}`);\n }\n}\n"],
|
|
5
|
-
"mappings": "+EAAA,OAAS,gBAAAA,MAAoB,yBAC7B,OAAS,cAAAC,EAAY,qBAAAC,EAAmB,gBAAAC,MAAoB,yBAI5D,MAAMC,EAAWC,EAACC,GAA6BA,EAAQ,SAAS,SAASN,CAAY,GAAG,EAAvE,YAMX,SAAUO,EAAcC,EAAYC,EAAU,CAClD,MAAMC,EAAU,IAAI,IACdC,EAAYH,EAAK,MAAM,OAAQI,GAAU,sCAAsC,KAAKA,CAAK,CAAC,EAChG,UAAWC,KAAQF,EAAW,CAC5B,GAAIP,EAASI,EAAK,KAAKK,CAAI,GAAK,EAAE,EAAG,SACrC,MAAMC,EAAOZ,EAAkBW,CAAI,EACnC,GAAIC,IAAS,MAAQJ,EAAQ,IAAII,CAAI,EAAG,SACxCJ,EAAQ,IAAII,CAAI,EAChB,MAAMC,EAAS,qBAAqBd,EAAWa,CAAI,CAAC,GAChDC,IAAWF,GAAMJ,EAAK,OAAOI,EAAM,eAAeZ,EAAWa,CAAI,CAAC,EAAE,EACxEL,EAAK,MAAMM,EAAQZ,EAAaW,CAAI,EAAG,aAAaA,CAAI,EAAE,CAC5D,CACF,CAZgBT,EAAAE,EAAA",
|
|
6
|
-
"names": ["WORKFLOW_REF", "callerFile", "callerKindForFile", "renderCaller", "isCaller", "__name", "content", "workflowFixes", "repo", "plan", "claimed", "workflows", "entry", "file", "kind", "target"]
|
|
4
|
+
"sourcesContent": ["import { WORKFLOW_REF } from '../workflow-callers.ts';\nimport { callerFile, callerKindForFile, renderCaller } from '../workflow-callers.ts';\nimport type { Repo } from '../repo.ts';\nimport type { Plan } from './plan.ts';\n\nconst isCaller = (content: string): boolean => content.includes(`uses: ${WORKFLOW_REF}/`);\n\n/**\n * Replace every non-caller workflow whose name the family knows with its caller. The file keeps its\n * name when it already has the family's, and is renamed to it otherwise (one caller per kind).\n */\nexport function workflowFixes(repo: Repo, plan: Plan): void {\n const claimed = new Set<string>();\n const workflows = repo.files.filter((entry) => /^\\.github\\/workflows\\/[^/]+\\.ya?ml$/.test(entry));\n for (const file of workflows) {\n if (isCaller(repo.read(file) ?? '')) continue;\n const kind = callerKindForFile(file);\n if (kind === null || claimed.has(kind)) continue;\n claimed.add(kind);\n const target = `.github/workflows/${callerFile(kind)}`;\n if (target !== file) plan.delete(file, `replaced by ${callerFile(kind)}`);\n plan.write(target, renderCaller(kind), `caller of ${kind}`);\n }\n}\n\n/**\n * Create the `backup-main.yml` caller when no workflow calls the reusable one. Never replaces a file: an existing\n * `backup-main.yml` that is not a caller is converted by {@link workflowFixes}, and one that already is stays.\n */\nexport function backupMainFix(_repo: Repo, plan: Plan): void {\n const target = `.github/workflows/${callerFile('backup-main')}`;\n if (plan.read(target) !== null) return;\n plan.write(target, renderCaller('backup-main'), 'caller of backup-main (secrets-gated)');\n}\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAS,gBAAAA,MAAoB,yBAC7B,OAAS,cAAAC,EAAY,qBAAAC,EAAmB,gBAAAC,MAAoB,yBAI5D,MAAMC,EAAWC,EAACC,GAA6BA,EAAQ,SAAS,SAASN,CAAY,GAAG,EAAvE,YAMX,SAAUO,EAAcC,EAAYC,EAAU,CAClD,MAAMC,EAAU,IAAI,IACdC,EAAYH,EAAK,MAAM,OAAQI,GAAU,sCAAsC,KAAKA,CAAK,CAAC,EAChG,UAAWC,KAAQF,EAAW,CAC5B,GAAIP,EAASI,EAAK,KAAKK,CAAI,GAAK,EAAE,EAAG,SACrC,MAAMC,EAAOZ,EAAkBW,CAAI,EACnC,GAAIC,IAAS,MAAQJ,EAAQ,IAAII,CAAI,EAAG,SACxCJ,EAAQ,IAAII,CAAI,EAChB,MAAMC,EAAS,qBAAqBd,EAAWa,CAAI,CAAC,GAChDC,IAAWF,GAAMJ,EAAK,OAAOI,EAAM,eAAeZ,EAAWa,CAAI,CAAC,EAAE,EACxEL,EAAK,MAAMM,EAAQZ,EAAaW,CAAI,EAAG,aAAaA,CAAI,EAAE,CAC5D,CACF,CAZgBT,EAAAE,EAAA,iBAkBV,SAAUS,EAAcC,EAAaR,EAAU,CACnD,MAAMM,EAAS,qBAAqBd,EAAW,aAAa,CAAC,GACzDQ,EAAK,KAAKM,CAAM,IAAM,MAC1BN,EAAK,MAAMM,EAAQZ,EAAa,aAAa,EAAG,uCAAuC,CACzF,CAJgBE,EAAAW,EAAA",
|
|
6
|
+
"names": ["WORKFLOW_REF", "callerFile", "callerKindForFile", "renderCaller", "isCaller", "__name", "content", "workflowFixes", "repo", "plan", "claimed", "workflows", "entry", "file", "kind", "target", "backupMainFix", "_repo"]
|
|
7
7
|
}
|
|
@@ -12,7 +12,7 @@ export type CallerKind = 'ci' | 'cd' | 'version-update' | 'backup-d1' | 'backup-
|
|
|
12
12
|
*/
|
|
13
13
|
export declare function renderCaller(kind: CallerKind): string;
|
|
14
14
|
/**
|
|
15
|
-
* The callers a repo with these features carries: CI, CD
|
|
15
|
+
* The callers a repo with these features carries: CI, CD, the version bump and the `main` mirror (secrets-gated: it skips with no `BACKUP_REPO_*` secret) always; the nightly D1 backup with `backupD1`.
|
|
16
16
|
*/
|
|
17
17
|
export declare function callersFor(manifest: FamilyManifest | null): Array<{
|
|
18
18
|
path: string;
|
package/dist/workflow-callers.js
CHANGED
|
@@ -32,4 +32,4 @@ var i=Object.defineProperty;var r=(e,n)=>i(e,"name",{value:n,configurable:!0});c
|
|
|
32
32
|
workflow_dispatch:
|
|
33
33
|
`,permissions:["contents: write"]}};function c(e){const n=s[e];return[`# A thin caller: the pipeline lives in ${t}/${n.workflow}.yml (tag v1).`,"# Jobs switch on .rexezuge.jsonc features; change behaviour there or in the SDK, not here.",`name: ${n.name}
|
|
34
34
|
`,n.on,"jobs:",` ${n.workflow}:`," permissions:",...n.permissions.map(o=>` ${o}`),` uses: ${t}/${n.workflow}.yml@v1`," secrets: inherit",""].join(`
|
|
35
|
-
`)}r(c,"renderCaller");function p(e){const n=["ci","cd","version-update"];return e?.features?.backupD1===!0&&n.push("backup-d1"),n.map(o=>({path:`.github/workflows/${s[o].file}`,content:c(o)}))}r(p,"callersFor");function l(e){const n=e.replace(/^.*\//,"").replace(/\.ya?ml$/,"");return{"continuous-integration":"ci",ci:"ci","worker-ci":"ci","continuous-deployment":"cd",cd:"cd",deploy:"cd","worker-cd":"cd","scheduled-version-update":"version-update","version-update":"version-update","backup-d1":"backup-d1","backup-main":"backup-main","upstream-sync":"upstream-sync"}[n]??null}r(l,"callerKindForFile");function d(e){return s[e].file}r(d,"callerFile");export{t as WORKFLOW_REF,u as WORKFLOW_TAG,d as callerFile,l as callerKindForFile,p as callersFor,c as renderCaller};
|
|
35
|
+
`)}r(c,"renderCaller");function p(e){const n=["ci","cd","version-update","backup-main"];return e?.features?.backupD1===!0&&n.push("backup-d1"),n.map(o=>({path:`.github/workflows/${s[o].file}`,content:c(o)}))}r(p,"callersFor");function l(e){const n=e.replace(/^.*\//,"").replace(/\.ya?ml$/,"");return{"continuous-integration":"ci",ci:"ci","worker-ci":"ci","continuous-deployment":"cd",cd:"cd",deploy:"cd","worker-cd":"cd","scheduled-version-update":"version-update","version-update":"version-update","backup-d1":"backup-d1","backup-main":"backup-main","upstream-sync":"upstream-sync"}[n]??null}r(l,"callerKindForFile");function d(e){return s[e].file}r(d,"callerFile");export{t as WORKFLOW_REF,u as WORKFLOW_TAG,d as callerFile,l as callerKindForFile,p as callersFor,c as renderCaller};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/workflow-callers.ts"],
|
|
4
|
-
"sourcesContent": ["import type { FamilyManifest } from '@rexezuge/tooling/manifest';\n\n/**\n * The SDK's reusable workflows, which a consumer calls instead of copying (RFC 0001, \"Repo workflows\").\n * They live in the SDK's `.github/workflows` and the owner moves the `v1` tag after each release.\n */\nexport const WORKFLOW_REF = 'Rexezuge-CloudflareWorkers/SDK/.github/workflows';\nexport const WORKFLOW_TAG = 'v1';\n\nexport type CallerKind = 'ci' | 'cd' | 'version-update' | 'backup-d1' | 'backup-main' | 'upstream-sync';\n\ninterface CallerSpec {\n readonly file: string;\n readonly workflow: string;\n readonly name: string;\n readonly on: string;\n /**\n What the called workflow's jobs need. A reusable workflow can only narrow the caller's token, never widen it.\n */\n readonly permissions: readonly string[];\n}\n\nconst SPECS: Record<CallerKind, CallerSpec> = {\n ci: {\n file: 'continuous-integration.yml',\n workflow: 'worker-ci',\n name: 'Continuous Integration',\n on: 'on:\\n push:\\n branches: [main]\\n pull_request:\\n repository_dispatch:\\n types: [upstream-sync]\\n workflow_dispatch:\\n',\n // contents + pull-requests write: the Dependabot auto-merge job; contents write: the upstream-sync deploy dispatch.\n permissions: ['contents: write', 'pull-requests: write'],\n },\n cd: {\n file: 'continuous-deployment.yml',\n workflow: 'worker-cd',\n name: 'Continuous Deployment',\n on: \"on:\\n workflow_run:\\n workflows: ['Continuous Integration']\\n types: [completed]\\n branches: [main]\\n repository_dispatch:\\n types: [upstream-sync]\\n workflow_dispatch:\\n\",\n permissions: ['contents: read'],\n },\n 'version-update': {\n file: 'scheduled-version-update.yml',\n workflow: 'version-update',\n name: 'Scheduled Version Update',\n on: \"on:\\n schedule:\\n - cron: '0 0 1,15 * *'\\n workflow_dispatch:\\n\",\n permissions: ['contents: write'],\n },\n 'backup-d1': {\n file: 'backup-d1.yml',\n workflow: 'backup-d1',\n name: 'Backup D1',\n on: \"on:\\n schedule:\\n - cron: '15 4 * * *'\\n workflow_dispatch:\\n\",\n permissions: ['contents: read'],\n },\n 'backup-main': {\n file: 'backup-main.yml',\n workflow: 'backup-main',\n name: 'Backup Main',\n on: \"on:\\n push:\\n branches: [main]\\n schedule:\\n - cron: '0 0 5 * *'\\n\",\n permissions: ['contents: read'],\n },\n 'upstream-sync': {\n file: 'upstream-sync.yml',\n workflow: 'upstream-sync',\n name: 'Upstream Sync',\n on: \"on:\\n schedule:\\n - cron: '17 2 * * 1'\\n workflow_dispatch:\\n\",\n permissions: ['contents: write'],\n },\n};\n\n/**\n * A caller workflow: the whole file is one `uses:` of the SDK's reusable workflow with the repo's secrets.\n * Inputs (`with:`) are the repo's to add; `rexezuge sync` replaces a workflow that is not a caller and leaves one that is.\n */\nexport function renderCaller(kind: CallerKind): string {\n const spec = SPECS[kind];\n return [\n `# A thin caller: the pipeline lives in ${WORKFLOW_REF}/${spec.workflow}.yml (tag ${WORKFLOW_TAG}).`,\n `# Jobs switch on .rexezuge.jsonc features; change behaviour there or in the SDK, not here.`,\n `name: ${spec.name}\\n`,\n spec.on,\n 'jobs:',\n ` ${spec.workflow}:`,\n ' permissions:',\n ...spec.permissions.map((permission) => ` ${permission}`),\n ` uses: ${WORKFLOW_REF}/${spec.workflow}.yml@${WORKFLOW_TAG}`,\n ' secrets: inherit',\n '',\n ].join('\\n');\n}\n\n/**\n * The callers a repo with these features carries: CI, CD
|
|
5
|
-
"mappings": "+EAMO,MAAMA,EAAe,mDACfC,EAAe,KAetBC,EAAwC,CAC5C,GAAI,CACF,KAAM,6BACN,SAAU,YACV,KAAM,yBACN,GAAI;;;;;;;EAEJ,YAAa,CAAC,kBAAmB,sBAAsB,GAEzD,GAAI,CACF,KAAM,4BACN,SAAU,YACV,KAAM,wBACN,GAAI;;;;;;;;EACJ,YAAa,CAAC,gBAAgB,GAEhC,iBAAkB,CAChB,KAAM,+BACN,SAAU,iBACV,KAAM,2BACN,GAAI;;;;EACJ,YAAa,CAAC,iBAAiB,GAEjC,YAAa,CACX,KAAM,gBACN,SAAU,YACV,KAAM,YACN,GAAI;;;;EACJ,YAAa,CAAC,gBAAgB,GAEhC,cAAe,CACb,KAAM,kBACN,SAAU,cACV,KAAM,cACN,GAAI;;;;;EACJ,YAAa,CAAC,gBAAgB,GAEhC,gBAAiB,CACf,KAAM,oBACN,SAAU,gBACV,KAAM,gBACN,GAAI;;;;EACJ,YAAa,CAAC,iBAAiB,IAQ7B,SAAUC,EAAaC,EAAgB,CAC3C,MAAMC,EAAOH,EAAME,CAAI,EACvB,MAAO,CACL,0CAA0CJ,CAAY,IAAIK,EAAK,QAAQ,iBACvE,6FACA,SAASA,EAAK,IAAI;EAClBA,EAAK,GACL,QACA,KAAKA,EAAK,QAAQ,IAClB,mBACA,GAAGA,EAAK,YAAY,IAAKC,GAAe,SAASA,CAAU,EAAE,EAC7D,aAAaN,CAAY,IAAIK,EAAK,QAAQ,UAC1C,uBACA,IACA,KAAK;CAAI,CACb,CAfgBE,EAAAJ,EAAA,gBAoBV,SAAUK,EAAWC,EAA+B,CACxD,MAAMC,EAAsB,CAAC,KAAM,KAAM,
|
|
4
|
+
"sourcesContent": ["import type { FamilyManifest } from '@rexezuge/tooling/manifest';\n\n/**\n * The SDK's reusable workflows, which a consumer calls instead of copying (RFC 0001, \"Repo workflows\").\n * They live in the SDK's `.github/workflows` and the owner moves the `v1` tag after each release.\n */\nexport const WORKFLOW_REF = 'Rexezuge-CloudflareWorkers/SDK/.github/workflows';\nexport const WORKFLOW_TAG = 'v1';\n\nexport type CallerKind = 'ci' | 'cd' | 'version-update' | 'backup-d1' | 'backup-main' | 'upstream-sync';\n\ninterface CallerSpec {\n readonly file: string;\n readonly workflow: string;\n readonly name: string;\n readonly on: string;\n /**\n What the called workflow's jobs need. A reusable workflow can only narrow the caller's token, never widen it.\n */\n readonly permissions: readonly string[];\n}\n\nconst SPECS: Record<CallerKind, CallerSpec> = {\n ci: {\n file: 'continuous-integration.yml',\n workflow: 'worker-ci',\n name: 'Continuous Integration',\n on: 'on:\\n push:\\n branches: [main]\\n pull_request:\\n repository_dispatch:\\n types: [upstream-sync]\\n workflow_dispatch:\\n',\n // contents + pull-requests write: the Dependabot auto-merge job; contents write: the upstream-sync deploy dispatch.\n permissions: ['contents: write', 'pull-requests: write'],\n },\n cd: {\n file: 'continuous-deployment.yml',\n workflow: 'worker-cd',\n name: 'Continuous Deployment',\n on: \"on:\\n workflow_run:\\n workflows: ['Continuous Integration']\\n types: [completed]\\n branches: [main]\\n repository_dispatch:\\n types: [upstream-sync]\\n workflow_dispatch:\\n\",\n permissions: ['contents: read'],\n },\n 'version-update': {\n file: 'scheduled-version-update.yml',\n workflow: 'version-update',\n name: 'Scheduled Version Update',\n on: \"on:\\n schedule:\\n - cron: '0 0 1,15 * *'\\n workflow_dispatch:\\n\",\n permissions: ['contents: write'],\n },\n 'backup-d1': {\n file: 'backup-d1.yml',\n workflow: 'backup-d1',\n name: 'Backup D1',\n on: \"on:\\n schedule:\\n - cron: '15 4 * * *'\\n workflow_dispatch:\\n\",\n permissions: ['contents: read'],\n },\n 'backup-main': {\n file: 'backup-main.yml',\n workflow: 'backup-main',\n name: 'Backup Main',\n on: \"on:\\n push:\\n branches: [main]\\n schedule:\\n - cron: '0 0 5 * *'\\n\",\n permissions: ['contents: read'],\n },\n 'upstream-sync': {\n file: 'upstream-sync.yml',\n workflow: 'upstream-sync',\n name: 'Upstream Sync',\n on: \"on:\\n schedule:\\n - cron: '17 2 * * 1'\\n workflow_dispatch:\\n\",\n permissions: ['contents: write'],\n },\n};\n\n/**\n * A caller workflow: the whole file is one `uses:` of the SDK's reusable workflow with the repo's secrets.\n * Inputs (`with:`) are the repo's to add; `rexezuge sync` replaces a workflow that is not a caller and leaves one that is.\n */\nexport function renderCaller(kind: CallerKind): string {\n const spec = SPECS[kind];\n return [\n `# A thin caller: the pipeline lives in ${WORKFLOW_REF}/${spec.workflow}.yml (tag ${WORKFLOW_TAG}).`,\n `# Jobs switch on .rexezuge.jsonc features; change behaviour there or in the SDK, not here.`,\n `name: ${spec.name}\\n`,\n spec.on,\n 'jobs:',\n ` ${spec.workflow}:`,\n ' permissions:',\n ...spec.permissions.map((permission) => ` ${permission}`),\n ` uses: ${WORKFLOW_REF}/${spec.workflow}.yml@${WORKFLOW_TAG}`,\n ' secrets: inherit',\n '',\n ].join('\\n');\n}\n\n/**\n * The callers a repo with these features carries: CI, CD, the version bump and the `main` mirror (secrets-gated: it skips with no `BACKUP_REPO_*` secret) always; the nightly D1 backup with `backupD1`.\n */\nexport function callersFor(manifest: FamilyManifest | null): Array<{ path: string; content: string }> {\n const kinds: CallerKind[] = ['ci', 'cd', 'version-update', 'backup-main'];\n if (manifest?.features?.backupD1 === true) kinds.push('backup-d1');\n return kinds.map((kind) => ({ path: `.github/workflows/${SPECS[kind].file}`, content: renderCaller(kind) }));\n}\n\n/**\n * Which caller replaces a workflow file, by the file name a consumer repo uses. Unknown names return null:\n * a workflow the family has no equivalent for is the repo's own and is never replaced.\n */\nexport function callerKindForFile(file: string): CallerKind | null {\n const base = file.replace(/^.*\\//, '').replace(/\\.ya?ml$/, '');\n const table: Record<string, CallerKind> = {\n 'continuous-integration': 'ci',\n ci: 'ci',\n 'worker-ci': 'ci',\n 'continuous-deployment': 'cd',\n cd: 'cd',\n deploy: 'cd',\n 'worker-cd': 'cd',\n 'scheduled-version-update': 'version-update',\n 'version-update': 'version-update',\n 'backup-d1': 'backup-d1',\n 'backup-main': 'backup-main',\n 'upstream-sync': 'upstream-sync',\n };\n return table[base] ?? null;\n}\n\nexport function callerFile(kind: CallerKind): string {\n return SPECS[kind].file;\n}\n"],
|
|
5
|
+
"mappings": "+EAMO,MAAMA,EAAe,mDACfC,EAAe,KAetBC,EAAwC,CAC5C,GAAI,CACF,KAAM,6BACN,SAAU,YACV,KAAM,yBACN,GAAI;;;;;;;EAEJ,YAAa,CAAC,kBAAmB,sBAAsB,GAEzD,GAAI,CACF,KAAM,4BACN,SAAU,YACV,KAAM,wBACN,GAAI;;;;;;;;EACJ,YAAa,CAAC,gBAAgB,GAEhC,iBAAkB,CAChB,KAAM,+BACN,SAAU,iBACV,KAAM,2BACN,GAAI;;;;EACJ,YAAa,CAAC,iBAAiB,GAEjC,YAAa,CACX,KAAM,gBACN,SAAU,YACV,KAAM,YACN,GAAI;;;;EACJ,YAAa,CAAC,gBAAgB,GAEhC,cAAe,CACb,KAAM,kBACN,SAAU,cACV,KAAM,cACN,GAAI;;;;;EACJ,YAAa,CAAC,gBAAgB,GAEhC,gBAAiB,CACf,KAAM,oBACN,SAAU,gBACV,KAAM,gBACN,GAAI;;;;EACJ,YAAa,CAAC,iBAAiB,IAQ7B,SAAUC,EAAaC,EAAgB,CAC3C,MAAMC,EAAOH,EAAME,CAAI,EACvB,MAAO,CACL,0CAA0CJ,CAAY,IAAIK,EAAK,QAAQ,iBACvE,6FACA,SAASA,EAAK,IAAI;EAClBA,EAAK,GACL,QACA,KAAKA,EAAK,QAAQ,IAClB,mBACA,GAAGA,EAAK,YAAY,IAAKC,GAAe,SAASA,CAAU,EAAE,EAC7D,aAAaN,CAAY,IAAIK,EAAK,QAAQ,UAC1C,uBACA,IACA,KAAK;CAAI,CACb,CAfgBE,EAAAJ,EAAA,gBAoBV,SAAUK,EAAWC,EAA+B,CACxD,MAAMC,EAAsB,CAAC,KAAM,KAAM,iBAAkB,aAAa,EACxE,OAAID,GAAU,UAAU,WAAa,IAAMC,EAAM,KAAK,WAAW,EAC1DA,EAAM,IAAKN,IAAU,CAAE,KAAM,qBAAqBF,EAAME,CAAI,EAAE,IAAI,GAAI,QAASD,EAAaC,CAAI,CAAC,EAAG,CAC7G,CAJgBG,EAAAC,EAAA,cAUV,SAAUG,EAAkBC,EAAY,CAC5C,MAAMC,EAAOD,EAAK,QAAQ,QAAS,EAAE,EAAE,QAAQ,WAAY,EAAE,EAe7D,MAd0C,CACxC,yBAA0B,KAC1B,GAAI,KACJ,YAAa,KACb,wBAAyB,KACzB,GAAI,KACJ,OAAQ,KACR,YAAa,KACb,2BAA4B,iBAC5B,iBAAkB,iBAClB,YAAa,YACb,cAAe,cACf,gBAAiB,iBAENC,CAAI,GAAK,IACxB,CAjBgBN,EAAAI,EAAA,qBAmBV,SAAUG,EAAWV,EAAgB,CACzC,OAAOF,EAAME,CAAI,EAAE,IACrB,CAFgBG,EAAAO,EAAA",
|
|
6
6
|
"names": ["WORKFLOW_REF", "WORKFLOW_TAG", "SPECS", "renderCaller", "kind", "spec", "permission", "__name", "callersFor", "manifest", "kinds", "callerKindForFile", "file", "base", "callerFile"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexezuge/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"jsonc-parser": "3.3.1",
|
|
35
|
-
"@rexezuge/
|
|
36
|
-
"@rexezuge/
|
|
35
|
+
"@rexezuge/tooling": "1.17.0",
|
|
36
|
+
"@rexezuge/identity": "1.17.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "26.6.4",
|