@rexezuge/cli 1.14.0 → 1.15.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 +51 -27
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +5 -2
- package/dist/cli.js.map +3 -3
- package/dist/commands/backup.d.ts +22 -0
- package/dist/commands/backup.d.ts.map +1 -0
- package/dist/commands/backup.js +3 -0
- package/dist/commands/backup.js.map +7 -0
- package/dist/commands/manifest.d.ts +8 -0
- package/dist/commands/manifest.d.ts.map +1 -0
- package/dist/commands/manifest.js +1 -0
- package/dist/commands/manifest.js.map +7 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +1 -1
- package/dist/commands/sync.js.map +3 -3
- package/dist/doctor/checks/actions.d.ts +17 -0
- package/dist/doctor/checks/actions.d.ts.map +1 -0
- package/dist/doctor/checks/actions.js +1 -0
- package/dist/doctor/checks/actions.js.map +7 -0
- package/dist/doctor/checks/catalog.d.ts.map +1 -1
- package/dist/doctor/checks/catalog.js +1 -1
- package/dist/doctor/checks/catalog.js.map +3 -3
- package/dist/doctor/registry.d.ts.map +1 -1
- package/dist/doctor/registry.js +1 -1
- package/dist/doctor/registry.js.map +3 -3
- package/dist/manifest-plan.d.ts +58 -0
- package/dist/manifest-plan.d.ts.map +1 -0
- package/dist/manifest-plan.js +1 -0
- package/dist/manifest-plan.js.map +7 -0
- package/dist/repo.d.ts +10 -0
- package/dist/repo.d.ts.map +1 -1
- package/dist/repo.js +1 -1
- package/dist/repo.js.map +3 -3
- 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/plan.d.ts +6 -0
- package/dist/sync/plan.d.ts.map +1 -1
- package/dist/sync/plan.js +5 -3
- package/dist/sync/plan.js.map +3 -3
- package/dist/sync/run.d.ts +4 -0
- package/dist/sync/run.d.ts.map +1 -1
- package/dist/sync/run.js +1 -1
- package/dist/sync/run.js.map +2 -2
- package/dist/sync/tsconfig.d.ts +13 -0
- package/dist/sync/tsconfig.d.ts.map +1 -0
- package/dist/sync/tsconfig.js +5 -0
- package/dist/sync/tsconfig.js.map +7 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +3 -3
- package/dist/workflow-callers.d.ts +2 -1
- package/dist/workflow-callers.d.ts.map +1 -1
- package/dist/workflow-callers.js +15 -14
- package/dist/workflow-callers.js.map +3 -3
- package/package.json +5 -4
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { FamilyManifest } from '@rexezuge/tooling/manifest';
|
|
2
|
+
import type { Repo } from './repo.ts';
|
|
3
|
+
/**
|
|
4
|
+
* What the reusable workflows switch on, derived from the manifest and the repo's own files. Booleans and strings only,
|
|
5
|
+
* except `jobs`: the workflow's `plan` job publishes every non-array field as a step output.
|
|
6
|
+
*/
|
|
7
|
+
export interface ManifestPlan {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly scope: string;
|
|
10
|
+
readonly d1: boolean;
|
|
11
|
+
readonly d1Binding: string;
|
|
12
|
+
readonly d1Database: string;
|
|
13
|
+
readonly migrationsDir: string;
|
|
14
|
+
readonly web: boolean;
|
|
15
|
+
readonly pages: boolean;
|
|
16
|
+
readonly spaShell: boolean;
|
|
17
|
+
readonly background: boolean;
|
|
18
|
+
readonly backupD1: boolean;
|
|
19
|
+
readonly email: boolean;
|
|
20
|
+
/**
|
|
21
|
+
The repo has locale bundles (`apps/web/src/locales`).
|
|
22
|
+
*/
|
|
23
|
+
readonly locales: boolean;
|
|
24
|
+
/**
|
|
25
|
+
The root package.json defines `test:integration`.
|
|
26
|
+
*/
|
|
27
|
+
readonly integration: boolean;
|
|
28
|
+
/**
|
|
29
|
+
The root package.json defines `test:web`.
|
|
30
|
+
*/
|
|
31
|
+
readonly webTests: boolean;
|
|
32
|
+
/**
|
|
33
|
+
pnpm filter of the SPA package: `<scope>/web`.
|
|
34
|
+
*/
|
|
35
|
+
readonly webFilter: string;
|
|
36
|
+
/**
|
|
37
|
+
The Cloudflare Pages project the manifest names (`features.web.pagesProject`), or `''`.
|
|
38
|
+
*/
|
|
39
|
+
readonly pagesProject: string;
|
|
40
|
+
/**
|
|
41
|
+
The Pages project when neither the manifest nor the `CLOUDFLARE_PAGES_PROJECT_NAME` variable names one: `<name>-web`.
|
|
42
|
+
*/
|
|
43
|
+
readonly pagesProjectDefault: string;
|
|
44
|
+
/**
|
|
45
|
+
The root package.json script that builds the SPA (`features.web.buildScript`), or `''` for `pnpm --filter <web> run build`.
|
|
46
|
+
*/
|
|
47
|
+
readonly webBuildScript: string;
|
|
48
|
+
/**
|
|
49
|
+
The CI gates that will run, in order.
|
|
50
|
+
*/
|
|
51
|
+
readonly jobs: readonly string[];
|
|
52
|
+
}
|
|
53
|
+
export declare const LOCALES_DIR = "apps/web/src/locales";
|
|
54
|
+
/**
|
|
55
|
+
* The strict gates run for every repo; the others follow the manifest and the repo's scripts.
|
|
56
|
+
*/
|
|
57
|
+
export declare function planFor(manifest: FamilyManifest, repo: Repo): ManifestPlan;
|
|
58
|
+
//# sourceMappingURL=manifest-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-plan.d.ts","sourceRoot":"","sources":["../src/manifest-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB;;MAEE;IACF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B;;MAEE;IACF,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B;;MAEE;IACF,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B;;MAEE;IACF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;MAEE;IACF,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;MAEE;IACF,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC;;MAEE;IACF,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC;;MAEE;IACF,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AAED,eAAO,MAAM,WAAW,yBAAyB,CAAC;AAElD;;GAEG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,GAAG,YAAY,CA4C1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var u=Object.defineProperty;var d=(t,s)=>u(t,"name",{value:s,configurable:!0});import{rootScripts as g}from"./repo-json.js";const w="apps/web/src/locales";function D(t,s){const e=t.features,n=g(s),r=e?.d1!==void 0,o=e?.web!==void 0,a=e?.web?.spaShell===!0,i=o&&s.files.some(p=>p.startsWith(`${w}/`)),c=n["test:integration"]!==void 0,b=n["test:web"]!==void 0,l=["format","lint","typecheck","test",...c?["integration"]:[],...b?["web-tests"]:[],"god-files",...r?["migrations"]:[],...i?["locales"]:[],...o?[a?"spa-shell":"build-web"]:[],"doctor"];return{name:t.name,scope:t.scope,d1:r,d1Binding:e?.d1?.binding??"",d1Database:e?.d1?.database??"",migrationsDir:e?.d1?.migrationsDir??"migrations",web:o,pages:e?.web?.pages===!0,spaShell:a,background:e?.background===!0,backupD1:e?.backupD1===!0,email:e?.email===!0,locales:i,integration:c,webTests:b,webFilter:`${t.scope}/web`,pagesProject:e?.web?.pagesProject??"",pagesProjectDefault:`${t.name}-web`,webBuildScript:e?.web?.buildScript??"",jobs:l}}d(D,"planFor");export{w as LOCALES_DIR,D as planFor};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/manifest-plan.ts"],
|
|
4
|
+
"sourcesContent": ["import type { FamilyManifest } from '@rexezuge/tooling/manifest';\nimport { rootScripts } from './repo-json.ts';\nimport type { Repo } from './repo.ts';\n\n/**\n * What the reusable workflows switch on, derived from the manifest and the repo's own files. Booleans and strings only,\n * except `jobs`: the workflow's `plan` job publishes every non-array field as a step output.\n */\nexport interface ManifestPlan {\n readonly name: string;\n readonly scope: string;\n readonly d1: boolean;\n readonly d1Binding: string;\n readonly d1Database: string;\n readonly migrationsDir: string;\n readonly web: boolean;\n readonly pages: boolean;\n readonly spaShell: boolean;\n readonly background: boolean;\n readonly backupD1: boolean;\n readonly email: boolean;\n /**\n The repo has locale bundles (`apps/web/src/locales`).\n */\n readonly locales: boolean;\n /**\n The root package.json defines `test:integration`.\n */\n readonly integration: boolean;\n /**\n The root package.json defines `test:web`.\n */\n readonly webTests: boolean;\n /**\n pnpm filter of the SPA package: `<scope>/web`.\n */\n readonly webFilter: string;\n /**\n The Cloudflare Pages project the manifest names (`features.web.pagesProject`), or `''`.\n */\n readonly pagesProject: string;\n /**\n The Pages project when neither the manifest nor the `CLOUDFLARE_PAGES_PROJECT_NAME` variable names one: `<name>-web`.\n */\n readonly pagesProjectDefault: string;\n /**\n The root package.json script that builds the SPA (`features.web.buildScript`), or `''` for `pnpm --filter <web> run build`.\n */\n readonly webBuildScript: string;\n /**\n The CI gates that will run, in order.\n */\n readonly jobs: readonly string[];\n}\n\nexport const LOCALES_DIR = 'apps/web/src/locales';\n\n/**\n * The strict gates run for every repo; the others follow the manifest and the repo's scripts.\n */\nexport function planFor(manifest: FamilyManifest, repo: Repo): ManifestPlan {\n const features = manifest.features;\n const scripts = rootScripts(repo);\n const d1 = features?.d1 !== undefined;\n const web = features?.web !== undefined;\n const spaShell = features?.web?.spaShell === true;\n const locales = web && repo.files.some((file) => file.startsWith(`${LOCALES_DIR}/`));\n const integration = scripts['test:integration'] !== undefined;\n const webTests = scripts['test:web'] !== undefined;\n const jobs = [\n 'format',\n 'lint',\n 'typecheck',\n 'test',\n ...(integration ? ['integration'] : []),\n ...(webTests ? ['web-tests'] : []),\n 'god-files',\n ...(d1 ? ['migrations'] : []),\n ...(locales ? ['locales'] : []),\n ...(web ? [spaShell ? 'spa-shell' : 'build-web'] : []),\n 'doctor',\n ];\n return {\n name: manifest.name,\n scope: manifest.scope,\n d1,\n d1Binding: features?.d1?.binding ?? '',\n d1Database: features?.d1?.database ?? '',\n migrationsDir: features?.d1?.migrationsDir ?? 'migrations',\n web,\n pages: features?.web?.pages === true,\n spaShell,\n background: features?.background === true,\n backupD1: features?.backupD1 === true,\n email: features?.email === true,\n locales,\n integration,\n webTests,\n webFilter: `${manifest.scope}/web`,\n pagesProject: features?.web?.pagesProject ?? '',\n pagesProjectDefault: `${manifest.name}-web`,\n webBuildScript: features?.web?.buildScript ?? '',\n jobs,\n };\n}\n"],
|
|
5
|
+
"mappings": "+EACA,OAAS,eAAAA,MAAmB,iBAsDrB,MAAMC,EAAc,uBAKrB,SAAUC,EAAQC,EAA0BC,EAAU,CAC1D,MAAMC,EAAWF,EAAS,SACpBG,EAAUN,EAAYI,CAAI,EAC1BG,EAAKF,GAAU,KAAO,OACtBG,EAAMH,GAAU,MAAQ,OACxBI,EAAWJ,GAAU,KAAK,WAAa,GACvCK,EAAUF,GAAOJ,EAAK,MAAM,KAAMO,GAASA,EAAK,WAAW,GAAGV,CAAW,GAAG,CAAC,EAC7EW,EAAcN,EAAQ,kBAAkB,IAAM,OAC9CO,EAAWP,EAAQ,UAAU,IAAM,OACnCQ,EAAO,CACX,SACA,OACA,YACA,OACA,GAAIF,EAAc,CAAC,aAAa,EAAI,CAAA,EACpC,GAAIC,EAAW,CAAC,WAAW,EAAI,CAAA,EAC/B,YACA,GAAIN,EAAK,CAAC,YAAY,EAAI,CAAA,EAC1B,GAAIG,EAAU,CAAC,SAAS,EAAI,CAAA,EAC5B,GAAIF,EAAM,CAACC,EAAW,YAAc,WAAW,EAAI,CAAA,EACnD,UAEF,MAAO,CACL,KAAMN,EAAS,KACf,MAAOA,EAAS,MAChB,GAAAI,EACA,UAAWF,GAAU,IAAI,SAAW,GACpC,WAAYA,GAAU,IAAI,UAAY,GACtC,cAAeA,GAAU,IAAI,eAAiB,aAC9C,IAAAG,EACA,MAAOH,GAAU,KAAK,QAAU,GAChC,SAAAI,EACA,WAAYJ,GAAU,aAAe,GACrC,SAAUA,GAAU,WAAa,GACjC,MAAOA,GAAU,QAAU,GAC3B,QAAAK,EACA,YAAAE,EACA,SAAAC,EACA,UAAW,GAAGV,EAAS,KAAK,OAC5B,aAAcE,GAAU,KAAK,cAAgB,GAC7C,oBAAqB,GAAGF,EAAS,IAAI,OACrC,eAAgBE,GAAU,KAAK,aAAe,GAC9C,KAAAS,EAEJ,CA5CgBC,EAAAb,EAAA",
|
|
6
|
+
"names": ["rootScripts", "LOCALES_DIR", "planFor", "manifest", "repo", "features", "scripts", "d1", "web", "spaShell", "locales", "file", "integration", "webTests", "jobs", "__name"]
|
|
7
|
+
}
|
package/dist/repo.d.ts
CHANGED
|
@@ -34,4 +34,14 @@ export declare function loadRepo(root: string): Repo;
|
|
|
34
34
|
* The `@rexezuge/*` dependency specs in one package.json: name to spec, across the dependency fields.
|
|
35
35
|
*/
|
|
36
36
|
export declare function kitDependencies(json: Record<string, unknown> | null): Map<string, string>;
|
|
37
|
+
/**
|
|
38
|
+
* A specifier that points at local files rather than a registry version (`link:`, `file:`, `workspace:`).
|
|
39
|
+
* pnpm refuses these inside a catalog, and `sync` never rewrites them.
|
|
40
|
+
*/
|
|
41
|
+
export declare const isLocalSpec: (spec: string) => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The one local specifier doctor tolerates (as a warning): a `link:` to a local `@rexezuge/*` checkout in the
|
|
44
|
+
* root `package.json`, used while a fix is unreleased and swapped to `catalog:` after the release.
|
|
45
|
+
*/
|
|
46
|
+
export declare const isTempLink: (file: string, name: string, spec: string) => boolean;
|
|
37
47
|
//# sourceMappingURL=repo.d.ts.map
|
package/dist/repo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../src/repo.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKzD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC/C;AAED;;;GAGG;AACH,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;MAEE;IACF,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,CAAC;IACzC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,CAA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1C,QAAQ,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI,CAAC;IACzC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACjC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B;;MAEE;IACF,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CACxC;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAe/C;AAYD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAsC3C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAUzF;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,KAAG,OAAiD,CAAC;AAE7F;;;GAGG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,OACgB,CAAC"}
|
package/dist/repo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var u=Object.defineProperty;var s=(t,e)=>u(t,"name",{value:e,configurable:!0});import{existsSync as f,lstatSync as m,readdirSync as y,readFileSync as d,readlinkSync as k}from"node:fs";import a from"node:path";import{loadManifest as h,ManifestError as g}from"@rexezuge/tooling/manifest";import{parseWorkspaceYaml as j}from"./workspace-yaml.js";const S=new Set(["node_modules",".git","dist","coverage",".wrangler",".turbo",".next","build","out"]),x=2e4;function w(t){const e=[],i=s(o=>{for(const r of y(a.join(t,o),{withFileTypes:!0})){if(e.length>=x)return;const c=o===""?r.name:`${o}/${r.name}`;r.isDirectory()?S.has(r.name)||i(c):e.push(c)}},"visit");return i(""),e.sort((o,r)=>o.localeCompare(r))}s(w,"walkRepo");function b(t){if(t===null)return null;try{const e=JSON.parse(t);return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:null}catch{return null}}s(b,"parseJson");function T(t){const e=a.resolve(t),i=s(n=>{try{return d(a.join(e,n),"utf8")}catch{return null}},"read");let o=null,r=null;try{o=h(e)}catch(n){r=n instanceof g?n.errors.join("; "):String(n)}const c=w(e),p=c.filter(n=>n==="package.json"||n.endsWith("/package.json")).map(n=>({path:n,json:b(i(n))})),l=i("pnpm-workspace.yaml");return{root:e,files:c,manifest:o,manifestError:r,packages:p,workspace:l===null?null:j(l),read:i,exists:s(n=>f(a.join(e,n)),"exists"),linkTarget:s(n=>{try{return m(a.join(e,n)).isSymbolicLink()?k(a.join(e,n)):null}catch{return null}},"linkTarget")}}s(T,"loadRepo");function _(t){const e=new Map;for(const i of["dependencies","devDependencies","peerDependencies","optionalDependencies"]){const o=t?.[i];if(!(typeof o!="object"||o===null))for(const[r,c]of Object.entries(o))r.startsWith("@rexezuge/")&&typeof c=="string"&&e.set(r,c)}return e}s(_,"kitDependencies");const A=s(t=>/^(?:link|file|workspace):/.test(t),"isLocalSpec"),E=s((t,e,i)=>t==="package.json"&&e.startsWith("@rexezuge/")&&i.startsWith("link:"),"isTempLink");export{A as isLocalSpec,E as isTempLink,_ as kitDependencies,T as loadRepo,w as walkRepo};
|
package/dist/repo.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/repo.ts"],
|
|
4
|
-
"sourcesContent": ["import { existsSync, lstatSync, readdirSync, readFileSync, readlinkSync } from 'node:fs';\nimport path from 'node:path';\nimport { loadManifest, ManifestError } from '@rexezuge/tooling/manifest';\nimport type { FamilyManifest } from '@rexezuge/tooling/manifest';\nimport { parseWorkspaceYaml } from './workspace-yaml.ts';\nimport type { WorkspaceYaml } from './workspace-yaml.ts';\n\nconst SKIP_DIRS = new Set(['node_modules', '.git', 'dist', 'coverage', '.wrangler', '.turbo', '.next', 'build', 'out']);\nconst MAX_FILES = 20_000;\n\n/**\n * One `package.json` in the repo, parsed. `json` is `null` when the file is unreadable JSON.\n */\nexport interface PackageFile {\n readonly path: string;\n readonly json: Record<string, unknown> | null;\n}\n\n/**\n * A read-only view of the repository under inspection. Doctor checks and sync fixes see the repo\n * only through this, which is also what lets a test run them against a plain object.\n */\nexport interface Repo {\n readonly root: string;\n /**\n Repo-relative POSIX paths of every file, minus `node_modules`, `.git`, build output.\n */\n readonly files: readonly string[];\n readonly manifest: FamilyManifest | null;\n readonly manifestError: string | null;\n readonly packages: readonly PackageFile[];\n readonly workspace: WorkspaceYaml | null;\n read(rel: string): string | null;\n exists(rel: string): boolean;\n /**\n The symlink target of `rel`, or null when it is absent or not a symlink.\n */\n linkTarget(rel: string): string | null;\n}\n\nexport function walkRepo(root: string): string[] {\n const out: string[] = [];\n const visit = (dir: string): void => {\n for (const entry of readdirSync(path.join(root, dir), { withFileTypes: true })) {\n if (out.length >= MAX_FILES) return;\n const rel = dir === '' ? entry.name : `${dir}/${entry.name}`;\n if (entry.isDirectory()) {\n if (!SKIP_DIRS.has(entry.name)) visit(rel);\n } else {\n out.push(rel);\n }\n }\n };\n visit('');\n return out.sort((a, b) => a.localeCompare(b));\n}\n\nfunction parseJson(text: string | null): Record<string, unknown> | null {\n if (text === null) return null;\n try {\n const value: unknown = JSON.parse(text);\n return typeof value === 'object' && value !== null && !Array.isArray(value) ? (value as Record<string, unknown>) : null;\n } catch {\n return null;\n }\n}\n\nexport function loadRepo(root: string): Repo {\n const absolute = path.resolve(root);\n const read = (rel: string): string | null => {\n try {\n return readFileSync(path.join(absolute, rel), 'utf8');\n } catch {\n return null;\n }\n };\n let manifest: FamilyManifest | null = null;\n let manifestError: string | null = null;\n try {\n manifest = loadManifest(absolute);\n } catch (error: unknown) {\n manifestError = error instanceof ManifestError ? error.errors.join('; ') : String(error);\n }\n const files = walkRepo(absolute);\n const packages = files\n .filter((file) => file === 'package.json' || file.endsWith('/package.json'))\n .map((file) => ({ path: file, json: parseJson(read(file)) }));\n const workspaceText = read('pnpm-workspace.yaml');\n return {\n root: absolute,\n files,\n manifest,\n manifestError,\n packages,\n workspace: workspaceText === null ? null : parseWorkspaceYaml(workspaceText),\n read,\n exists: (rel) => existsSync(path.join(absolute, rel)),\n linkTarget: (rel) => {\n try {\n return lstatSync(path.join(absolute, rel)).isSymbolicLink() ? readlinkSync(path.join(absolute, rel)) : null;\n } catch {\n return null;\n }\n },\n };\n}\n\n/**\n * The `@rexezuge/*` dependency specs in one package.json: name to spec, across the dependency fields.\n */\nexport function kitDependencies(json: Record<string, unknown> | null): Map<string, string> {\n const out = new Map<string, string>();\n for (const field of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']) {\n const block = json?.[field];\n if (typeof block !== 'object' || block === null) continue;\n for (const [name, spec] of Object.entries(block as Record<string, unknown>)) {\n if (name.startsWith('@rexezuge/') && typeof spec === 'string') out.set(name, spec);\n }\n }\n return out;\n}\n"],
|
|
5
|
-
"mappings": "+EAAA,OAAS,cAAAA,EAAY,aAAAC,EAAW,eAAAC,EAAa,gBAAAC,EAAc,gBAAAC,MAAoB,UAC/E,OAAOC,MAAU,YACjB,OAAS,gBAAAC,EAAc,iBAAAC,MAAqB,6BAE5C,OAAS,sBAAAC,MAA0B,sBAGnC,MAAMC,EAAY,IAAI,IAAI,CAAC,eAAgB,OAAQ,OAAQ,WAAY,YAAa,SAAU,QAAS,QAAS,KAAK,CAAC,EAChHC,EAAY,IAgCZ,SAAUC,EAASC,EAAY,CACnC,MAAMC,EAAgB,CAAA,EAChBC,EAAQC,EAACC,GAAqB,CAClC,UAAWC,KAASf,EAAYG,EAAK,KAAKO,EAAMI,CAAG,EAAG,CAAE,cAAe,EAAI,CAAE,EAAG,CAC9E,GAAIH,EAAI,QAAUH,EAAW,OAC7B,MAAMQ,EAAMF,IAAQ,GAAKC,EAAM,KAAO,GAAGD,CAAG,IAAIC,EAAM,IAAI,GACtDA,EAAM,YAAW,EACd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lB,EAAWK,EAAK,KAAKoB,EAAUP,CAAG,CAAC,EAA5C,UACR,WAAYH,EAACG,GAAO,CAClB,GAAI,CACF,OAAOjB,EAAUI,EAAK,KAAKoB,EAAUP,CAAG,CAAC,EAAE,eAAc,EAAKd,EAAaC,EAAK,KAAKoB,EAAUP,CAAG,CAAC,EAAI,IACzG,MAAQ,CACN,OAAO,IACT,CACF,EANY,cAQhB,CAtCgBH,EAAAS,EAAA,YA2CV,SAAUU,EAAgBC,EAAoC,CAClE,MAAMtB,EAAM,IAAI,IAChB,UAAWuB,IAAS,CAAC,eAAgB,kBAAmB,mBAAoB,sBAAsB,EAAG,CACnG,MAAMC,EAAQF,IAAOC,CAAK,EAC1B,GAAI,SAAOC,GAAU,UAAYA,IAAU,MAC3C,SAAW,CAACC,EAAMC,CAAI,IAAK,OAAO,QAAQF,CAAgC,EACpEC,EAAK,WAAW,YAAY,GAAK,OAAOC,GAAS,UAAU1B,EAAI,IAAIyB,EAAMC,CAAI,CAErF,CACA,OAAO1B,CACT,CAVgBE,EAAAmB,EAAA",
|
|
6
|
-
"names": ["existsSync", "lstatSync", "readdirSync", "readFileSync", "readlinkSync", "path", "loadManifest", "ManifestError", "parseWorkspaceYaml", "SKIP_DIRS", "MAX_FILES", "walkRepo", "root", "out", "visit", "__name", "dir", "entry", "rel", "a", "b", "parseJson", "text", "value", "loadRepo", "absolute", "read", "manifest", "manifestError", "error", "files", "packages", "file", "workspaceText", "kitDependencies", "json", "field", "block", "name", "spec"]
|
|
4
|
+
"sourcesContent": ["import { existsSync, lstatSync, readdirSync, readFileSync, readlinkSync } from 'node:fs';\nimport path from 'node:path';\nimport { loadManifest, ManifestError } from '@rexezuge/tooling/manifest';\nimport type { FamilyManifest } from '@rexezuge/tooling/manifest';\nimport { parseWorkspaceYaml } from './workspace-yaml.ts';\nimport type { WorkspaceYaml } from './workspace-yaml.ts';\n\nconst SKIP_DIRS = new Set(['node_modules', '.git', 'dist', 'coverage', '.wrangler', '.turbo', '.next', 'build', 'out']);\nconst MAX_FILES = 20_000;\n\n/**\n * One `package.json` in the repo, parsed. `json` is `null` when the file is unreadable JSON.\n */\nexport interface PackageFile {\n readonly path: string;\n readonly json: Record<string, unknown> | null;\n}\n\n/**\n * A read-only view of the repository under inspection. Doctor checks and sync fixes see the repo\n * only through this, which is also what lets a test run them against a plain object.\n */\nexport interface Repo {\n readonly root: string;\n /**\n Repo-relative POSIX paths of every file, minus `node_modules`, `.git`, build output.\n */\n readonly files: readonly string[];\n readonly manifest: FamilyManifest | null;\n readonly manifestError: string | null;\n readonly packages: readonly PackageFile[];\n readonly workspace: WorkspaceYaml | null;\n read(rel: string): string | null;\n exists(rel: string): boolean;\n /**\n The symlink target of `rel`, or null when it is absent or not a symlink.\n */\n linkTarget(rel: string): string | null;\n}\n\nexport function walkRepo(root: string): string[] {\n const out: string[] = [];\n const visit = (dir: string): void => {\n for (const entry of readdirSync(path.join(root, dir), { withFileTypes: true })) {\n if (out.length >= MAX_FILES) return;\n const rel = dir === '' ? entry.name : `${dir}/${entry.name}`;\n if (entry.isDirectory()) {\n if (!SKIP_DIRS.has(entry.name)) visit(rel);\n } else {\n out.push(rel);\n }\n }\n };\n visit('');\n return out.sort((a, b) => a.localeCompare(b));\n}\n\nfunction parseJson(text: string | null): Record<string, unknown> | null {\n if (text === null) return null;\n try {\n const value: unknown = JSON.parse(text);\n return typeof value === 'object' && value !== null && !Array.isArray(value) ? (value as Record<string, unknown>) : null;\n } catch {\n return null;\n }\n}\n\nexport function loadRepo(root: string): Repo {\n const absolute = path.resolve(root);\n const read = (rel: string): string | null => {\n try {\n return readFileSync(path.join(absolute, rel), 'utf8');\n } catch {\n return null;\n }\n };\n let manifest: FamilyManifest | null = null;\n let manifestError: string | null = null;\n try {\n manifest = loadManifest(absolute);\n } catch (error: unknown) {\n manifestError = error instanceof ManifestError ? error.errors.join('; ') : String(error);\n }\n const files = walkRepo(absolute);\n const packages = files\n .filter((file) => file === 'package.json' || file.endsWith('/package.json'))\n .map((file) => ({ path: file, json: parseJson(read(file)) }));\n const workspaceText = read('pnpm-workspace.yaml');\n return {\n root: absolute,\n files,\n manifest,\n manifestError,\n packages,\n workspace: workspaceText === null ? null : parseWorkspaceYaml(workspaceText),\n read,\n exists: (rel) => existsSync(path.join(absolute, rel)),\n linkTarget: (rel) => {\n try {\n return lstatSync(path.join(absolute, rel)).isSymbolicLink() ? readlinkSync(path.join(absolute, rel)) : null;\n } catch {\n return null;\n }\n },\n };\n}\n\n/**\n * The `@rexezuge/*` dependency specs in one package.json: name to spec, across the dependency fields.\n */\nexport function kitDependencies(json: Record<string, unknown> | null): Map<string, string> {\n const out = new Map<string, string>();\n for (const field of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']) {\n const block = json?.[field];\n if (typeof block !== 'object' || block === null) continue;\n for (const [name, spec] of Object.entries(block as Record<string, unknown>)) {\n if (name.startsWith('@rexezuge/') && typeof spec === 'string') out.set(name, spec);\n }\n }\n return out;\n}\n\n/**\n * A specifier that points at local files rather than a registry version (`link:`, `file:`, `workspace:`).\n * pnpm refuses these inside a catalog, and `sync` never rewrites them.\n */\nexport const isLocalSpec = (spec: string): boolean => /^(?:link|file|workspace):/.test(spec);\n\n/**\n * The one local specifier doctor tolerates (as a warning): a `link:` to a local `@rexezuge/*` checkout in the\n * root `package.json`, used while a fix is unreleased and swapped to `catalog:` after the release.\n */\nexport const isTempLink = (file: string, name: string, spec: string): boolean =>\n file === 'package.json' && name.startsWith('@rexezuge/') && spec.startsWith('link:');\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAS,cAAAA,EAAY,aAAAC,EAAW,eAAAC,EAAa,gBAAAC,EAAc,gBAAAC,MAAoB,UAC/E,OAAOC,MAAU,YACjB,OAAS,gBAAAC,EAAc,iBAAAC,MAAqB,6BAE5C,OAAS,sBAAAC,MAA0B,sBAGnC,MAAMC,EAAY,IAAI,IAAI,CAAC,eAAgB,OAAQ,OAAQ,WAAY,YAAa,SAAU,QAAS,QAAS,KAAK,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", "loadManifest", "ManifestError", "parseWorkspaceYaml", "SKIP_DIRS", "MAX_FILES", "walkRepo", "root", "out", "visit", "__name", "dir", "entry", "rel", "a", "b", "parseJson", "text", "value", "loadRepo", "absolute", "read", "manifest", "manifestError", "error", "files", "packages", "file", "workspaceText", "kitDependencies", "json", "field", "block", "name", "spec", "isLocalSpec", "isTempLink"]
|
|
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;AASvC,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,CAa/C,CAAC"}
|
package/dist/sync/fixes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
`}}))}a(
|
|
3
|
-
`;if(
|
|
4
|
-
`,"Node 24"),"nodeVersion"),
|
|
5
|
-
`,"one-line pages-proxy re-export")},"pagesFunction"),
|
|
6
|
-
`,"re-export of @rexezuge/testing")},"workersMock"),
|
|
1
|
+
var k=Object.defineProperty;var a=(o,t)=>k(o,"name",{value:t,configurable:!0});import{applyEdits as w,modify as x}from"jsonc-parser";import{isLocalSpec as d,kitDependencies as y}from"../repo.js";import{removeOverrides as h,setCatalogEntries as v}from"../workspace-yaml.js";import{CLI_VERSION as E,KIT_PACKAGES as S}from"../version.js";import{CANONICAL_SCRIPTS as j}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 b}from"./tsconfig.js";import{staleActions as P}from"../doctor/checks/actions.js";import{workflowFixes as T}from"./workflows.js";const l=a(o=>o.startsWith("@rexezuge/"),"isKit");function p(o,t,n){return w(o,x(o,t,n,{formattingOptions:{insertSpaces:!0,tabSize:2,eol:`
|
|
2
|
+
`}}))}a(p,"editJson");const O=a((o,t)=>{const n=new Map;for(const s of o.packages)for(const[c,f]of y(s.json))d(f)||(S.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()),r=new Map([...n].filter(([s])=>!e.has(s)));if(r.size===0)return;const i=t.read("pnpm-workspace.yaml")??"";t.write("pnpm-workspace.yaml",v(i,r),`catalog: ${[...r.keys()].join(", ")}`)},"catalogPresent"),R=a((o,t)=>{const n=t.read("pnpm-workspace.yaml");n!==null&&o.workspace!==null&&t.write("pnpm-workspace.yaml",h(n,l),"remove @rexezuge/* overrides");for(const e of o.packages){const r=t.read(e.path),i=e.json?.pnpm?.overrides;if(r===null||i===void 0)continue;let s=r;const c=Object.keys(i).filter(l);for(const f of c)s=p(s,["pnpm","overrides",f],void 0);s!==r&&t.write(e.path,s,"remove @rexezuge/* pnpm.overrides")}},"noOverrides"),z=a((o,t)=>{for(const n of o.packages){let e=t.read(n.path);if(e===null)continue;const r=e;for(const i of["dependencies","devDependencies","peerDependencies","optionalDependencies"]){const s=n.json?.[i];for(const[c,f]of Object.entries(s??{}))l(c)&&typeof f=="string"&&!f.startsWith("catalog:")&&!d(f)&&(e=p(e,[i,c],"catalog:"))}e!==r&&t.write(n.path,e,"@rexezuge/* to catalog:")}},"catalogProtocol"),D=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 r=t.read(e)??`{}
|
|
3
|
+
`;if(A(r))continue;const i=e==="tsconfig.json"?"base":/apps\/web\//.test(e)?"web":"worker";t.write(e,b(r,i),`extends the ${i} preset`)}},"tsconfigPreset"),N={printWidth:140,singleQuote:!0,semi:!0,useTabs:!1},C=a((o,t)=>{const n=o.files.filter(s=>/^\.prettierrc(?:\.json)?$/.test(s)),e=a(s=>{try{const c=JSON.parse(s??"");return Object.entries(c).every(([f,g])=>N[f]===g)}catch{return!1}},"redundant");if(n.some(s=>!e(o.read(s))))return;for(const s of n)t.delete(s,"redundant with the preset");const i=t.read("package.json");i!==null&&t.write("package.json",p(i,["prettier"],"@rexezuge/tooling/prettier"),"prettier preset")},"prettierPreset"),I=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"),_=a((o,t)=>t.write(".nvmrc",`24
|
|
4
|
+
`,"Node 24"),"nodeVersion"),L={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"},$=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 r=e.scripts??{};let i=n;const s=[];for(const c of j)r[c]===void 0&&(i=p(i,["scripts",c],L[c]),s.push(c));s.length>0&&t.write("package.json",i,`scripts: ${s.join(", ")}`)},"canonicalScripts"),F=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"),G=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"),K=a((o,t)=>{for(const{name:n,files:e}of P(o))for(const r of e)t.delete(r,`unreferenced family action ${n}`)},"staleActionsFix"),Z={"catalog.present":O,"catalog.no-overrides":R,"catalog.protocol":z,"presets.tsconfig":D,"presets.prettier":C,"files.claude-symlink":I,"files.node-version":_,"scripts.canonical":$,"vendored.pages-function":F,"vendored.cloudflare-workers-mock":G,"workflows.callers":T,"workflows.stale-actions":K};export{Z 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 { kitDependencies } from '../repo.ts';\nimport type { Repo } from '../repo.ts';\nimport { removeOverrides, setCatalogEntries } from '../workspace-yaml.ts';\nimport { CLI_VERSION } 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 { 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)) if (
|
|
5
|
-
"mappings": "+EAAA,OAAS,cAAAA,EAAY,UAAAC,MAAc,eACnC,OAAS,mBAAAC,MAAuB,
|
|
6
|
-
"names": ["applyEdits", "modify", "kitDependencies", "removeOverrides", "setCatalogEntries", "CLI_VERSION", "CANONICAL_SCRIPTS", "extendsPreset", "vendoredFiles", "VENDORED_RULES", "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", "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 { 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,iBAS9B,MAAMC,EAAQC,EAACC,GAA0BA,EAAK,WAAW,YAAY,EAAvD,SAEd,SAASC,EAASC,EAAcC,EAA8BC,EAAc,CAC1E,OAAOrB,EAAWmB,EAAMlB,EAAOkB,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,IAAKxB,EAAgBuB,EAAI,IAAI,EAC7CxB,EAAYyB,CAAI,IAChBpB,EAAa,IAAIU,CAAI,EACvBQ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AAI,CAAC,EAC9DwC,EAAM,KAAKxC,CAAI,GAEbwC,EAAM,OAAS,GAAGjC,EAAK,MAAM,eAAgBS,EAAM,YAAYwB,EAAM,KAAK,IAAI,CAAC,EAAE,CACvF,EAb8B,oBAmBxBC,EAAqB1C,EAAA,CAACO,EAAMC,IAAQ,CACxC,MAAMmC,EAAOhD,EAAe,KAAMiD,GAAUA,EAAM,MAAQ,gBAAgB,EAC1E,GAAID,IAAS,OACb,UAAWjB,KAAQhC,EAAca,EAAMoC,CAAI,GACpCpC,EAAK,KAAKmB,CAAI,GAAK,IAAI,SAAS,YAAY,GAC/ClB,EAAK,MAAMkB,EAAM;EAAgE,gCAAgC,CAGvH,EAR2B,iBAcrBmB,EAAmB7C,EAAA,CAACO,EAAMC,IAAQ,CACtC,MAAMmC,EAAOhD,EAAe,KAAMiD,GAAUA,EAAM,MAAQ,yBAAyB,EACnF,GAAID,IAAS,OACb,UAAWjB,KAAQhC,EAAca,EAAMoC,CAAI,EACzCnC,EAAK,MAAMkB,EAAM;EAA2D,gCAAgC,CAEhH,EANyB,eAWnBoB,EAAuB9C,EAAA,CAACO,EAAMC,IAAQ,CAC1C,SAAW,CAAE,KAAAP,EAAM,MAAAwB,CAAK,IAAM5B,EAAaU,CAAI,EAC7C,UAAWmB,KAAQD,EAAOjB,EAAK,OAAOkB,EAAM,8BAA8BzB,CAAI,EAAE,CAEpF,EAJ6B,mBAShB8C,EAAuC,CAClD,kBAAmBzC,EACnB,uBAAwBQ,EACxB,mBAAoBM,EACpB,mBAAoBI,EACpB,mBAAoBK,EACpB,uBAAwBI,EACxB,qBAAsBE,EACtB,oBAAqBG,EACrB,0BAA2BI,EAC3B,mCAAoCG,EACpC,oBAAqB/C,EACrB,0BAA2BgD",
|
|
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"]
|
|
7
7
|
}
|
package/dist/sync/plan.d.ts
CHANGED
|
@@ -21,8 +21,14 @@ export type Change = {
|
|
|
21
21
|
export declare class Plan {
|
|
22
22
|
private readonly repo;
|
|
23
23
|
private readonly changes;
|
|
24
|
+
private readonly notes;
|
|
24
25
|
constructor(repo: Repo);
|
|
25
26
|
/**
|
|
27
|
+
Something a fix left alone on purpose and the report should say.
|
|
28
|
+
*/
|
|
29
|
+
note(message: string): void;
|
|
30
|
+
get reported(): readonly string[];
|
|
31
|
+
/**
|
|
26
32
|
The file as it will be after the plan, or null.
|
|
27
33
|
*/
|
|
28
34
|
read(rel: string): string | null;
|
package/dist/sync/plan.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/sync/plan.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,MAAM,MAAM,GACd;IAAE,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChG;IAAE,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,Q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,EAAE,CAEhC;IAED;;MAEE;IACF,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAMhC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAOvD,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAIxD,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAIvC,IAAI,IAAI,IAAI,SAAS,MAAM,EAAE,CAE5B;IAED;;MAEE;IACF,KAAK,IAAI,IAAI;CAkBd;AAyBD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAYlG"}
|
package/dist/sync/plan.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var p=Object.defineProperty;var s=(n,e)=>p(n,"name",{value:e,configurable:!0});import{lstatSync as u,mkdirSync as d,readdirSync as f,readlinkSync as g,rmdirSync as m,rmSync as l,symlinkSync as y,writeFileSync as w}from"node:fs";import c from"node:path";class D{static{s(this,"Plan")}repo;changes=new Map;notes=new Set;constructor(e){this.repo=e}note(e){this.notes.add(e)}get reported(){return[...this.notes]}read(e){const t=this.changes.get(e);return t===void 0?this.repo.read(e):t.op==="write"?t.content:null}write(e,t,i){let r=t.length;for(;r>0&&t[r-1]===`
|
|
2
|
+
`;)r-=1;this.changes.set(e,{op:"write",path:e,content:r===0?"":`${t.slice(0,r)}
|
|
3
|
+
`,note:i})}symlink(e,t,i){this.changes.set(e,{op:"symlink",path:e,target:t,note:i})}delete(e,t){this.changes.set(e,{op:"delete",path:e,note:t})}get list(){return[...this.changes.values()].sort((e,t)=>e.path.localeCompare(t.path))}apply(){for(const e of this.list){const t=c.join(this.repo.root,e.path);if(e.op==="delete"){l(t,{force:!0}),S(c.dirname(t),this.repo.root);continue}if(d(c.dirname(t),{recursive:!0}),e.op==="write"){w(t,e.content);continue}u(t,{throwIfNoEntry:!1})!==void 0&&h(t)!==e.target&&l(t,{force:!0}),h(t)!==e.target&&y(e.target,t)}}}function S(n,e){let t=n;try{for(;t!==e&&t.startsWith(e)&&f(t).length===0;)m(t),t=c.dirname(t)}catch{}}s(S,"pruneEmptyDirs");function h(n){try{return g(n)}catch{return null}}s(h,"readlinkSyncSafe");function E(n,e){const t=new Map;for(const o of(n??"").split(`
|
|
4
|
+
`))t.set(o,(t.get(o)??0)+1);let i=0;for(const o of e.split(`
|
|
5
|
+
`)){const a=t.get(o)??0;a>0?t.set(o,a-1):i+=1}let r=0;for(const o of t.values())r+=o;return{added:i,removed:n===null?0:r}}s(E,"lineDelta");export{D as Plan,E as lineDelta};
|
package/dist/sync/plan.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/sync/plan.ts"],
|
|
4
|
-
"sourcesContent": ["import { lstatSync, mkdirSync, readlinkSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';\nimport path from 'node:path';\nimport type { Repo } from '../repo.ts';\n\nexport type Change =\n | { readonly op: 'write'; readonly path: string; readonly content: string; readonly note: string }\n | { readonly op: 'symlink'; readonly path: string; readonly target: string; readonly note: string }\n | { readonly op: 'delete'; readonly path: string; readonly note: string };\n\n/**\n * The edits a sync would make, applied on top of the repo in memory so two fixes touching one file\n * (the catalog and the overrides both live in pnpm-workspace.yaml) compose instead of overwriting each other.\n */\nexport class Plan {\n private readonly changes = new Map<string, Change>();\n\n constructor(private readonly repo: Repo) {}\n\n /**\n The file as it will be after the plan, or null.\n */\n read(rel: string): string | null {\n const change = this.changes.get(rel);\n if (change === undefined) return this.repo.read(rel);\n return change.op === 'write' ? change.content : null;\n }\n\n write(rel: string, content: string, note: string): void {\n this.changes.set(rel, { op: 'write', path: rel, content, note });\n }\n\n symlink(rel: string, target: string, note: string): void {\n this.changes.set(rel, { op: 'symlink', path: rel, target, note });\n }\n\n delete(rel: string, note: string): void {\n this.changes.set(rel, { op: 'delete', path: rel, note });\n }\n\n get list(): readonly Change[] {\n return [...this.changes.values()].sort((a, b) => a.path.localeCompare(b.path));\n }\n\n /**\n Write the plan to disk. Idempotent: a file already holding the planned content is rewritten with it.\n */\n apply(): void {\n for (const change of this.list) {\n const full = path.join(this.repo.root, change.path);\n if (change.op === 'delete') {\n rmSync(full, { force: true });\n continue;\n }\n mkdirSync(path.dirname(full), { recursive: true });\n if (change.op === 'write') {\n writeFileSync(full, change.content);\n continue;\n }\n if (lstatSync(full, { throwIfNoEntry: false }) !== undefined && readlinkSyncSafe(full) !== change.target)\n rmSync(full, { force: true });\n if (readlinkSyncSafe(full) !== change.target) symlinkSync(change.target, full);\n }\n }\n}\n\nfunction readlinkSyncSafe(file: string): string | null {\n try {\n return readlinkSync(file);\n } catch {\n return null;\n }\n}\n\n/**\n * `+added -removed` line counts between two texts: a multiset comparison of lines, which is exact for\n * pure additions and removals and an approximation for reorderings. A summary, not a patch.\n */\nexport function lineDelta(before: string | null, after: string): { added: number; removed: number } {\n const counts = new Map<string, number>();\n for (const line of (before ?? '').split('\\n')) counts.set(line, (counts.get(line) ?? 0) + 1);\n let added = 0;\n for (const line of after.split('\\n')) {\n const have = counts.get(line) ?? 0;\n if (have > 0) counts.set(line, have - 1);\n else added += 1;\n }\n let removed = 0;\n for (const count of counts.values()) removed += count;\n return { added, removed: before === null ? 0 : removed };\n}\n"],
|
|
5
|
-
"mappings": "+EAAA,OAAS,aAAAA,EAAW,aAAAC,EAAW,gBAAAC,EAAc,UAAAC,EAAQ,eAAAC,EAAa,iBAAAC,MAAqB,
|
|
6
|
-
"names": ["lstatSync", "mkdirSync", "readlinkSync", "rmSync", "symlinkSync", "writeFileSync", "path", "Plan", "__name", "repo", "rel", "change", "content", "note", "target", "a", "b", "full", "readlinkSyncSafe", "file", "lineDelta", "before", "after", "counts", "line", "added", "have", "removed", "count"]
|
|
4
|
+
"sourcesContent": ["import { lstatSync, mkdirSync, readdirSync, readlinkSync, rmdirSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';\nimport path from 'node:path';\nimport type { Repo } from '../repo.ts';\n\nexport type Change =\n | { readonly op: 'write'; readonly path: string; readonly content: string; readonly note: string }\n | { readonly op: 'symlink'; readonly path: string; readonly target: string; readonly note: string }\n | { readonly op: 'delete'; readonly path: string; readonly note: string };\n\n/**\n * The edits a sync would make, applied on top of the repo in memory so two fixes touching one file\n * (the catalog and the overrides both live in pnpm-workspace.yaml) compose instead of overwriting each other.\n */\nexport class Plan {\n private readonly changes = new Map<string, Change>();\n\n private readonly notes = new Set<string>();\n\n constructor(private readonly repo: Repo) {}\n\n /**\n Something a fix left alone on purpose and the report should say.\n */\n note(message: string): void {\n this.notes.add(message);\n }\n\n get reported(): readonly string[] {\n return [...this.notes];\n }\n\n /**\n The file as it will be after the plan, or null.\n */\n read(rel: string): string | null {\n const change = this.changes.get(rel);\n if (change === undefined) return this.repo.read(rel);\n return change.op === 'write' ? change.content : null;\n }\n\n write(rel: string, content: string, note: string): void {\n // Every file sync writes ends with exactly one newline (an empty file stays empty).\n let end = content.length;\n while (end > 0 && content[end - 1] === '\\n') end -= 1;\n this.changes.set(rel, { op: 'write', path: rel, content: end === 0 ? '' : `${content.slice(0, end)}\\n`, note });\n }\n\n symlink(rel: string, target: string, note: string): void {\n this.changes.set(rel, { op: 'symlink', path: rel, target, note });\n }\n\n delete(rel: string, note: string): void {\n this.changes.set(rel, { op: 'delete', path: rel, note });\n }\n\n get list(): readonly Change[] {\n return [...this.changes.values()].sort((a, b) => a.path.localeCompare(b.path));\n }\n\n /**\n Write the plan to disk. Idempotent: a file already holding the planned content is rewritten with it.\n */\n apply(): void {\n for (const change of this.list) {\n const full = path.join(this.repo.root, change.path);\n if (change.op === 'delete') {\n rmSync(full, { force: true });\n pruneEmptyDirs(path.dirname(full), this.repo.root);\n continue;\n }\n mkdirSync(path.dirname(full), { recursive: true });\n if (change.op === 'write') {\n writeFileSync(full, change.content);\n continue;\n }\n if (lstatSync(full, { throwIfNoEntry: false }) !== undefined && readlinkSyncSafe(full) !== change.target)\n rmSync(full, { force: true });\n if (readlinkSyncSafe(full) !== change.target) symlinkSync(change.target, full);\n }\n }\n}\n\n/**\nRemove `dir` and its parents while they are empty, never `root` itself.\n*/\nfunction pruneEmptyDirs(dir: string, root: string): void {\n let current = dir;\n try {\n while (current !== root && current.startsWith(root) && readdirSync(current).length === 0) {\n rmdirSync(current);\n current = path.dirname(current);\n }\n } catch {\n // The directory is already gone or not ours to remove: nothing to prune.\n }\n}\n\nfunction readlinkSyncSafe(file: string): string | null {\n try {\n return readlinkSync(file);\n } catch {\n return null;\n }\n}\n\n/**\n * `+added -removed` line counts between two texts: a multiset comparison of lines, which is exact for\n * pure additions and removals and an approximation for reorderings. A summary, not a patch.\n */\nexport function lineDelta(before: string | null, after: string): { added: number; removed: number } {\n const counts = new Map<string, number>();\n for (const line of (before ?? '').split('\\n')) counts.set(line, (counts.get(line) ?? 0) + 1);\n let added = 0;\n for (const line of after.split('\\n')) {\n const have = counts.get(line) ?? 0;\n if (have > 0) counts.set(line, have - 1);\n else added += 1;\n }\n let removed = 0;\n for (const count of counts.values()) removed += count;\n return { added, removed: before === null ? 0 : removed };\n}\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAS,aAAAA,EAAW,aAAAC,EAAW,eAAAC,EAAa,gBAAAC,EAAc,aAAAC,EAAW,UAAAC,EAAQ,eAAAC,EAAa,iBAAAC,MAAqB,UAC/G,OAAOC,MAAU,YAYX,MAAOC,CAAI,CAbjB,MAaiB,CAAAC,EAAA,aAKc,KAJZ,QAAU,IAAI,IAEd,MAAQ,IAAI,IAE7B,YAA6BC,EAAU,CA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EAAAkB,EAAA",
|
|
6
|
+
"names": ["lstatSync", "mkdirSync", "readdirSync", "readlinkSync", "rmdirSync", "rmSync", "symlinkSync", "writeFileSync", "path", "Plan", "__name", "repo", "message", "rel", "change", "content", "note", "end", "target", "a", "b", "full", "pruneEmptyDirs", "readlinkSyncSafe", "dir", "root", "current", "file", "lineDelta", "before", "after", "counts", "line", "added", "have", "removed", "count"]
|
|
7
7
|
}
|
package/dist/sync/run.d.ts
CHANGED
|
@@ -16,6 +16,10 @@ export interface SyncResult {
|
|
|
16
16
|
Failing auto-fixable checks whose fix declined to act (a file that is the repo's own).
|
|
17
17
|
*/
|
|
18
18
|
readonly unfixed: readonly string[];
|
|
19
|
+
/**
|
|
20
|
+
What a fix deliberately left alone (an unpublished package, a `link:` specifier).
|
|
21
|
+
*/
|
|
22
|
+
readonly notes: readonly string[];
|
|
19
23
|
}
|
|
20
24
|
/**
|
|
21
25
|
* Compute the plan for every failing auto-fixable check and, with `write`, apply it. Dry run is the default.
|
package/dist/sync/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/sync/run.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B;;MAEE;IACF,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,GAAG;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/E;;MAEE;IACF,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/sync/run.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B;;MAEE;IACF,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,GAAG;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/E;;MAEE;IACF,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;MAEE;IACF,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED;;GAEG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAoB/E"}
|
package/dist/sync/run.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var m=Object.defineProperty;var
|
|
1
|
+
var m=Object.defineProperty;var p=(r,i)=>m(r,"name",{value:i,configurable:!0});import{loadRepo as a}from"../repo.js";import{diagnose as d}from"../doctor/run.js";import{FIXES as y}from"./fixes.js";import{lineDelta as g,Plan as S}from"./plan.js";async function O(r,i){const n=a(r),e=await d(n),t=new S(n),s=[];for(const o of e.findings){const l=y[o.id];if(o.status!=="fail"||l===void 0)continue;const u=t.list.length,c=JSON.stringify(t.list);l(n,t),t.list.length===u&&JSON.stringify(t.list)===c&&s.push(o.id)}const f=t.list.map(o=>o.op!=="write"?o:{...o,...g(n.read(o.path),o.content)});return i?(t.apply(),{root:n.root,write:i,before:e,after:await d(a(r)),changes:f,unfixed:s,notes:t.reported}):{root:n.root,write:i,before:e,after:null,changes:f,unfixed:s,notes:t.reported}}p(O,"runSync");export{O as runSync};
|
package/dist/sync/run.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/sync/run.ts"],
|
|
4
|
-
"sourcesContent": ["import { loadRepo } from '../repo.ts';\nimport { diagnose } from '../doctor/run.ts';\nimport type { DoctorReport } from '../doctor/types.ts';\nimport { FIXES } from './fixes.ts';\nimport { lineDelta, Plan } from './plan.ts';\nimport type { Change } from './plan.ts';\n\nexport interface SyncResult {\n readonly root: string;\n readonly write: boolean;\n readonly before: DoctorReport;\n /**\n Score after the plan is applied; null in a dry run, which changes nothing.\n */\n readonly after: DoctorReport | null;\n readonly changes: ReadonlyArray<Change & { added?: number; removed?: number }>;\n /**\n Failing auto-fixable checks whose fix declined to act (a file that is the repo's own).\n */\n readonly unfixed: readonly string[];\n}\n\n/**\n * Compute the plan for every failing auto-fixable check and, with `write`, apply it. Dry run is the default.\n */\nexport async function runSync(root: string, write: boolean): Promise<SyncResult> {\n const repo = loadRepo(root);\n const before = await diagnose(repo);\n const plan = new Plan(repo);\n const unfixed: string[] = [];\n for (const finding of before.findings) {\n const fix = FIXES[finding.id];\n if (finding.status !== 'fail' || fix === undefined) continue;\n const size = plan.list.length;\n const touched = JSON.stringify(plan.list);\n fix(repo, plan);\n if (plan.list.length === size && JSON.stringify(plan.list) === touched) unfixed.push(finding.id);\n }\n const changes = plan.list.map((change) => {\n if (change.op !== 'write') return change;\n return { ...change, ...lineDelta(repo.read(change.path), change.content) };\n });\n if (!write) return { root: repo.root, write, before, after: null, changes, unfixed };\n plan.apply();\n return { root: repo.root, write, before, after: await diagnose(loadRepo(root)), changes, unfixed };\n}\n"],
|
|
5
|
-
"mappings": "+EAAA,OAAS,YAAAA,MAAgB,aACzB,OAAS,YAAAC,MAAgB,mBAEzB,OAAS,SAAAC,MAAa,aACtB,OAAS,aAAAC,EAAW,QAAAC,MAAY,
|
|
4
|
+
"sourcesContent": ["import { loadRepo } from '../repo.ts';\nimport { diagnose } from '../doctor/run.ts';\nimport type { DoctorReport } from '../doctor/types.ts';\nimport { FIXES } from './fixes.ts';\nimport { lineDelta, Plan } from './plan.ts';\nimport type { Change } from './plan.ts';\n\nexport interface SyncResult {\n readonly root: string;\n readonly write: boolean;\n readonly before: DoctorReport;\n /**\n Score after the plan is applied; null in a dry run, which changes nothing.\n */\n readonly after: DoctorReport | null;\n readonly changes: ReadonlyArray<Change & { added?: number; removed?: number }>;\n /**\n Failing auto-fixable checks whose fix declined to act (a file that is the repo's own).\n */\n readonly unfixed: readonly string[];\n /**\n What a fix deliberately left alone (an unpublished package, a `link:` specifier).\n */\n readonly notes: readonly string[];\n}\n\n/**\n * Compute the plan for every failing auto-fixable check and, with `write`, apply it. Dry run is the default.\n */\nexport async function runSync(root: string, write: boolean): Promise<SyncResult> {\n const repo = loadRepo(root);\n const before = await diagnose(repo);\n const plan = new Plan(repo);\n const unfixed: string[] = [];\n for (const finding of before.findings) {\n const fix = FIXES[finding.id];\n if (finding.status !== 'fail' || fix === undefined) continue;\n const size = plan.list.length;\n const touched = JSON.stringify(plan.list);\n fix(repo, plan);\n if (plan.list.length === size && JSON.stringify(plan.list) === touched) unfixed.push(finding.id);\n }\n const changes = plan.list.map((change) => {\n if (change.op !== 'write') return change;\n return { ...change, ...lineDelta(repo.read(change.path), change.content) };\n });\n if (!write) return { root: repo.root, write, before, after: null, changes, unfixed, notes: plan.reported };\n plan.apply();\n return { root: repo.root, write, before, after: await diagnose(loadRepo(root)), changes, unfixed, notes: plan.reported };\n}\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAS,YAAAA,MAAgB,aACzB,OAAS,YAAAC,MAAgB,mBAEzB,OAAS,SAAAC,MAAa,aACtB,OAAS,aAAAC,EAAW,QAAAC,MAAY,YAyBhC,eAAsBC,EAAQC,EAAcC,EAAc,CACxD,MAAMC,EAAOR,EAASM,CAAI,EACpBG,EAAS,MAAMR,EAASO,CAAI,EAC5BE,EAAO,IAAIN,EAAKI,CAAI,EACpBG,EAAoB,CAAA,EAC1B,UAAWC,KAAWH,EAAO,SAAU,CACrC,MAAMI,EAAMX,EAAMU,EAAQ,EAAE,EAC5B,GAAIA,EAAQ,SAAW,QAAUC,IAAQ,OAAW,SACpD,MAAMC,EAAOJ,EAAK,KAAK,OACjBK,EAAU,KAAK,UAAUL,EAAK,IAAI,EACxCG,EAAIL,EAAME,CAAI,EACVA,EAAK,KAAK,SAAWI,GAAQ,KAAK,UAAUJ,EAAK,IAAI,IAAMK,GAASJ,EAAQ,KAAKC,EAAQ,EAAE,CACjG,CACA,MAAMI,EAAUN,EAAK,KAAK,IAAKO,GACzBA,EAAO,KAAO,QAAgBA,EAC3B,CAAE,GAAGA,EAAQ,GAAGd,EAAUK,EAAK,KAAKS,EAAO,IAAI,EAAGA,EAAO,OAAO,CAAC,CACzE,EACD,OAAKV,GACLG,EAAK,MAAK,EACH,CAAE,KAAMF,EAAK,KAAM,MAAAD,EAAO,OAAAE,EAAQ,MAAO,MAAMR,EAASD,EAASM,CAAI,CAAC,EAAG,QAAAU,EAAS,QAAAL,EAAS,MAAOD,EAAK,QAAQ,GAFnG,CAAE,KAAMF,EAAK,KAAM,MAAAD,EAAO,OAAAE,EAAQ,MAAO,KAAM,QAAAO,EAAS,QAAAL,EAAS,MAAOD,EAAK,QAAQ,CAG1G,CApBsBQ,EAAAb,EAAA",
|
|
6
6
|
"names": ["loadRepo", "diagnose", "FIXES", "lineDelta", "Plan", "runSync", "root", "write", "repo", "before", "plan", "unfixed", "finding", "fix", "size", "touched", "changes", "change", "__name"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type Options = Record<string, unknown>;
|
|
2
|
+
/**
|
|
3
|
+
* The `compilerOptions` a tooling preset sets, with its `extends` chain applied (`web` over `base`).
|
|
4
|
+
*/
|
|
5
|
+
export declare function presetCompilerOptions(preset: string): Options;
|
|
6
|
+
/**
|
|
7
|
+
* Point a tsconfig at a preset: `extends` becomes the first key, every other key keeps its formatting (text edits, not
|
|
8
|
+
* a re-serialisation), and a `compilerOptions` entry exactly equal to what the preset already sets is dropped.
|
|
9
|
+
* A differing value is never touched.
|
|
10
|
+
*/
|
|
11
|
+
export declare function applyPreset(text: string, preset: string): string;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=tsconfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsconfig.d.ts","sourceRoot":"","sources":["../../src/sync/tsconfig.ts"],"names":[],"mappings":"AAQA,KAAK,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEvC;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAO7D;AAwCD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAWhE"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var y=Object.defineProperty;var f=(e,t)=>y(e,"name",{value:t,configurable:!0});import{readFileSync as O}from"node:fs";import{createRequire as h}from"node:module";import u from"node:path";import{applyEdits as b,findNodeAtLocation as j,modify as S,parse as a,parseTree as g}from"jsonc-parser";const $={insertSpaces:!0,tabSize:2,eol:`
|
|
2
|
+
`},v=h(import.meta.url);function A(e){const t=f(n=>{const r=a(O(n,"utf8"));return{...typeof r.extends=="string"?t(u.resolve(u.dirname(n),r.extends)):{},...r.compilerOptions}},"read");return t(v.resolve(`@rexezuge/tooling/tsconfig/${e}.json`))}f(A,"presetCompilerOptions");const N=f((e,t)=>JSON.stringify(e)===JSON.stringify(t),"same");function d(e,t){const n=g(e),r=t.at(-1),o=t.length===1?n:n&&j(n,t.slice(0,-1)),i=o?.type==="object"?o.children??[]:[],c=i.findIndex(m=>m.children?.[0]?.value===r),s=i[c];if(o===void 0||s===void 0)return e;const l=i[c+1];if(l!==void 0)return e.slice(0,s.offset)+e.slice(l.offset);const p=i[c-1];return p!==void 0?e.slice(0,p.offset+p.length)+e.slice(s.offset+s.length):e.slice(0,o.offset+1)+e.slice(o.offset+o.length-1)}f(d,"removeProperty");function x(e,t){const n=g(e),r=n?.type==="object"?n.children?.[0]:void 0;if(n===void 0||r===void 0)return b(e,S(e,["extends"],t,{formattingOptions:$}));const o=n.offset+1,i=e.slice(o,r.offset),c=i.slice(i.lastIndexOf(`
|
|
3
|
+
`)+1),s=i.includes(`
|
|
4
|
+
`)?c.slice(0,c.length-c.trimStart().length):null,l=`"extends": ${JSON.stringify(t)},`;return e.slice(0,o)+(s===null?` ${l}`:`
|
|
5
|
+
${s}${l}`)+e.slice(o)}f(x,"insertExtendsFirst");function E(e,t){let n=d(e,["extends"]);n=x(n,`@rexezuge/tooling/tsconfig/${t}.json`);const r=a(n)?.compilerOptions;if(typeof r!="object"||r===null||Array.isArray(r))return n;const o=r,i=A(t),c=Object.keys(o).filter(s=>s in i&&N(o[s],i[s]));for(const s of c)n=d(n,["compilerOptions",s]);return c.length>0&&c.length===Object.keys(o).length&&(n=d(n,["compilerOptions"])),n}f(E,"applyPreset");export{E as applyPreset,A as presetCompilerOptions};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/sync/tsconfig.ts"],
|
|
4
|
+
"sourcesContent": ["import { readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\nimport { applyEdits, findNodeAtLocation, modify, parse, parseTree } from 'jsonc-parser';\n\nconst FORMAT = { insertSpaces: true, tabSize: 2, eol: '\\n' } as const;\nconst require = createRequire(import.meta.url);\n\ntype Options = Record<string, unknown>;\n\n/**\n * The `compilerOptions` a tooling preset sets, with its `extends` chain applied (`web` over `base`).\n */\nexport function presetCompilerOptions(preset: string): Options {\n const read = (file: string): Options => {\n const json = parse(readFileSync(file, 'utf8')) as { extends?: string; compilerOptions?: Options };\n const parent = typeof json.extends === 'string' ? read(path.resolve(path.dirname(file), json.extends)) : {};\n return { ...parent, ...json.compilerOptions };\n };\n return read(require.resolve(`@rexezuge/tooling/tsconfig/${preset}.json`));\n}\n\nconst same = (a: unknown, b: unknown): boolean => JSON.stringify(a) === JSON.stringify(b);\n\n/**\n * Delete one property of an object by text edit, taking the comma that separated it and nothing else, so the\n * rest of the file keeps its formatting (`modify` would re-indent the whole enclosing object).\n */\nfunction removeProperty(text: string, jsonPath: string[]): string {\n const root = parseTree(text);\n const key = jsonPath.at(-1);\n const object = jsonPath.length === 1 ? root : root && findNodeAtLocation(root, jsonPath.slice(0, -1));\n const props = object?.type === 'object' ? (object.children ?? []) : [];\n const index = props.findIndex((prop) => prop.children?.[0]?.value === key);\n const prop = props[index];\n if (object === undefined || prop === undefined) return text;\n const next = props[index + 1];\n if (next !== undefined) return text.slice(0, prop.offset) + text.slice(next.offset);\n const previous = props[index - 1];\n if (previous !== undefined) return text.slice(0, previous.offset + previous.length) + text.slice(prop.offset + prop.length);\n return text.slice(0, object.offset + 1) + text.slice(object.offset + object.length - 1);\n}\n\n/**\n * Insert `\"extends\"` as the first key, indented like the file's own first property.\n */\nfunction insertExtendsFirst(text: string, value: string): string {\n const root = parseTree(text);\n const first = root?.type === 'object' ? root.children?.[0] : undefined;\n if (root === undefined || first === undefined) {\n return applyEdits(text, modify(text, ['extends'], value, { formattingOptions: FORMAT }));\n }\n const open = root.offset + 1;\n const gap = text.slice(open, first.offset);\n const lastLine = gap.slice(gap.lastIndexOf('\\n') + 1);\n const indent = gap.includes('\\n') ? lastLine.slice(0, lastLine.length - lastLine.trimStart().length) : null;\n const entry = `\"extends\": ${JSON.stringify(value)},`;\n return text.slice(0, open) + (indent === null ? ` ${entry}` : `\\n${indent}${entry}`) + text.slice(open);\n}\n\n/**\n * Point a tsconfig at a preset: `extends` becomes the first key, every other key keeps its formatting (text edits, not\n * a re-serialisation), and a `compilerOptions` entry exactly equal to what the preset already sets is dropped.\n * A differing value is never touched.\n */\nexport function applyPreset(text: string, preset: string): string {\n let next = removeProperty(text, ['extends']);\n next = insertExtendsFirst(next, `@rexezuge/tooling/tsconfig/${preset}.json`);\n const own = (parse(next) as { compilerOptions?: unknown } | undefined)?.compilerOptions;\n if (typeof own !== 'object' || own === null || Array.isArray(own)) return next;\n const options = own as Options;\n const inherited = presetCompilerOptions(preset);\n const redundant = Object.keys(options).filter((key) => key in inherited && same(options[key], inherited[key]));\n for (const key of redundant) next = removeProperty(next, ['compilerOptions', key]);\n if (redundant.length > 0 && redundant.length === Object.keys(options).length) next = removeProperty(next, ['compilerOptions']);\n return next;\n}\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAS,gBAAAA,MAAoB,UAC7B,OAAS,iBAAAC,MAAqB,cAC9B,OAAOC,MAAU,YACjB,OAAS,cAAAC,EAAY,sBAAAC,EAAoB,UAAAC,EAAQ,SAAAC,EAAO,aAAAC,MAAiB,eAEzE,MAAMC,EAAS,CAAE,aAAc,GAAM,QAAS,EAAG,IAAK;CAAI,EACpDC,EAAUR,EAAc,YAAY,GAAG,EAOvC,SAAUS,EAAsBC,EAAc,CAClD,MAAMC,EAAOC,EAACC,GAAyB,CACrC,MAAMC,EAAOT,EAAMN,EAAac,EAAM,MAAM,CAAC,EAE7C,MAAO,CAAE,GADM,OAAOC,EAAK,SAAY,SAAWH,EAAKV,EAAK,QAAQA,EAAK,QAAQY,CAAI,EAAGC,EAAK,OAAO,CAAC,EAAI,CAAA,EACrF,GAAGA,EAAK,eAAe,CAC7C,EAJa,QAKb,OAAOH,EAAKH,EAAQ,QAAQ,8BAA8BE,CAAM,OAAO,CAAC,CAC1E,CAPgBE,EAAAH,EAAA,yBAShB,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Md,EAAK,MAAMa,EAAMD,EAAM,MAAM,EACnCG,EAAWD,EAAI,MAAMA,EAAI,YAAY;CAAI,EAAI,CAAC,EAC9CE,EAASF,EAAI,SAAS;CAAI,EAAIC,EAAS,MAAM,EAAGA,EAAS,OAASA,EAAS,UAAS,EAAG,MAAM,EAAI,KACjGE,EAAQ,cAAc,KAAK,UAAUN,CAAK,CAAC,IACjD,OAAOX,EAAK,MAAM,EAAGa,CAAI,GAAKG,IAAW,KAAO,IAAIC,CAAK,GAAK;EAAKD,CAAM,GAAGC,CAAK,IAAMjB,EAAK,MAAMa,CAAI,CACxG,CAZSpB,EAAAiB,EAAA,sBAmBH,SAAUQ,EAAYlB,EAAcT,EAAc,CACtD,IAAIiB,EAAOT,EAAeC,EAAM,CAAC,SAAS,CAAC,EAC3CQ,EAAOE,EAAmBF,EAAM,8BAA8BjB,CAAM,OAAO,EAC3E,MAAM4B,EAAOjC,EAAMsB,CAAI,GAAiD,gBACxE,GAAI,OAAOW,GAAQ,UAAYA,IAAQ,MAAQ,MAAM,QAAQA,CAAG,EAAG,OAAOX,EAC1E,MAAMY,EAAUD,EACVE,EAAY/B,EAAsBC,CAAM,EACxC+B,EAAY,OAAO,KAAKF,CAAO,EAAE,OAAQjB,GAAQA,KAAOkB,GAAazB,EAAKwB,EAAQjB,CAAG,EAAGkB,EAAUlB,CAAG,CAAC,CAAC,EAC7G,UAAWA,KAAOmB,EAAWd,EAAOT,EAAeS,EAAM,CAAC,kBAAmBL,CAAG,CAAC,EACjF,OAAImB,EAAU,OAAS,GAAKA,EAAU,SAAW,OAAO,KAAKF,CAAO,EAAE,SAAQZ,EAAOT,EAAeS,EAAM,CAAC,iBAAiB,CAAC,GACtHA,CACT,CAXgBf,EAAAyB,EAAA",
|
|
6
|
+
"names": ["readFileSync", "createRequire", "path", "applyEdits", "findNodeAtLocation", "modify", "parse", "parseTree", "FORMAT", "require", "presetCompilerOptions", "preset", "read", "__name", "file", "json", "same", "a", "b", "removeProperty", "text", "jsonPath", "root", "key", "object", "props", "index", "prop", "next", "previous", "insertExtendsFirst", "value", "first", "open", "gap", "lastLine", "indent", "entry", "applyPreset", "own", "options", "inherited", "redundant"]
|
|
7
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -11,4 +11,9 @@ export declare function parseVersion(spec: string): [number, number, number] | n
|
|
|
11
11
|
* Whether `a` is at least `b` on major.minor (patch releases never matter to "is the repo current").
|
|
12
12
|
*/
|
|
13
13
|
export declare function atLeastMinor(a: readonly number[], b: readonly number[]): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* The packages this SDK publishes, which is what `sync` may write a catalog entry for: it knows their version
|
|
16
|
+
* (the CLI's own, since they release in lockstep). Any other `@rexezuge/*` name is unknown here and left alone.
|
|
17
|
+
*/
|
|
18
|
+
export declare const KIT_PACKAGES: ReadonlySet<string>;
|
|
14
19
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,MAGtB,CAAC;AAEL;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAG1E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAEhF"}
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,MAGtB,CAAC;AAEL;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAG1E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAEhF;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,WAAW,CAAC,MAAM,CAI5C,CAAC"}
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var n=Object.defineProperty;var t=(e,r)=>n(e,"name",{value:r,configurable:!0});import{readFileSync as o}from"node:fs";const s=(()=>{const e=o(new URL("../package.json",import.meta.url),"utf8");return JSON.parse(e).version})();function u(e){const r=/(\d{1,9})\.(\d{1,9})\.(\d{1,9})/.exec(e);return r===null?null:[Number(r[1]),Number(r[2]),Number(r[3])]}t(u,"parseVersion");function a(e,r){return e[0]===r[0]?(e[1]??0)>=(r[1]??0):(e[0]??0)>(r[0]??0)}t(a,"atLeastMinor");const p=new Set(["errors","runtime","shared","i18n","d1","identity","web","http","contracts","tooling","testing","cli","create-worker"].map(e=>`@rexezuge/${e}`));export{s as CLI_VERSION,p as KIT_PACKAGES,a as atLeastMinor,u as parseVersion};
|
package/dist/version.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/version.ts"],
|
|
4
|
-
"sourcesContent": ["import { readFileSync } from 'node:fs';\n\n/**\n * This CLI's own version, which is the SDK version it knows (the packages release in lockstep).\n * Read from the package's `package.json` beside `dist/` (or `src/`), so it is offline and cannot drift.\n */\nexport const CLI_VERSION: string = (() => {\n const raw = readFileSync(new URL('../package.json', import.meta.url), 'utf8');\n return (JSON.parse(raw) as { version: string }).version;\n})();\n\n/**\n * `[major, minor, patch]` of the first semver in a range or version (`^1.12.0` is `[1, 12, 0]`), or null.\n */\nexport function parseVersion(spec: string): [number, number, number] | null {\n const match = /(\\d{1,9})\\.(\\d{1,9})\\.(\\d{1,9})/.exec(spec);\n return match === null ? null : [Number(match[1]), Number(match[2]), Number(match[3])];\n}\n\n/**\n * Whether `a` is at least `b` on major.minor (patch releases never matter to \"is the repo current\").\n */\nexport function atLeastMinor(a: readonly number[], b: readonly number[]): boolean {\n return a[0] === b[0] ? (a[1] ?? 0) >= (b[1] ?? 0) : (a[0] ?? 0) > (b[0] ?? 0);\n}\n"],
|
|
5
|
-
"mappings": "+EAAA,OAAS,gBAAAA,MAAoB,UAMtB,MAAMC,GAAuB,IAAK,CACvC,MAAMC,EAAMF,EAAa,IAAI,IAAI,kBAAmB,YAAY,GAAG,EAAG,MAAM,EAC5E,OAAQ,KAAK,MAAME,CAAG,EAA0B,OAClD,GAAE,EAKI,SAAUC,EAAaC,EAAY,CACvC,MAAMC,EAAQ,kCAAkC,KAAKD,CAAI,EACzD,OAAOC,IAAU,KAAO,KAAO,CAAC,OAAOA,EAAM,CAAC,CAAC,EAAG,OAAOA,EAAM,CAAC,CAAC,EAAG,OAAOA,EAAM,CAAC,CAAC,CAAC,CACtF,CAHgBC,EAAAH,EAAA,gBAQV,SAAUI,EAAaC,EAAsBC,EAAoB,CACrE,OAAOD,EAAE,CAAC,IAAMC,EAAE,CAAC,GAAKD,EAAE,CAAC,GAAK,KAAOC,EAAE,CAAC,GAAK,IAAMD,EAAE,CAAC,GAAK,IAAMC,EAAE,CAAC,GAAK,EAC7E,CAFgBH,EAAAC,EAAA",
|
|
6
|
-
"names": ["readFileSync", "CLI_VERSION", "raw", "parseVersion", "spec", "match", "__name", "atLeastMinor", "a", "b"]
|
|
4
|
+
"sourcesContent": ["import { readFileSync } from 'node:fs';\n\n/**\n * This CLI's own version, which is the SDK version it knows (the packages release in lockstep).\n * Read from the package's `package.json` beside `dist/` (or `src/`), so it is offline and cannot drift.\n */\nexport const CLI_VERSION: string = (() => {\n const raw = readFileSync(new URL('../package.json', import.meta.url), 'utf8');\n return (JSON.parse(raw) as { version: string }).version;\n})();\n\n/**\n * `[major, minor, patch]` of the first semver in a range or version (`^1.12.0` is `[1, 12, 0]`), or null.\n */\nexport function parseVersion(spec: string): [number, number, number] | null {\n const match = /(\\d{1,9})\\.(\\d{1,9})\\.(\\d{1,9})/.exec(spec);\n return match === null ? null : [Number(match[1]), Number(match[2]), Number(match[3])];\n}\n\n/**\n * Whether `a` is at least `b` on major.minor (patch releases never matter to \"is the repo current\").\n */\nexport function atLeastMinor(a: readonly number[], b: readonly number[]): boolean {\n return a[0] === b[0] ? (a[1] ?? 0) >= (b[1] ?? 0) : (a[0] ?? 0) > (b[0] ?? 0);\n}\n\n/**\n * The packages this SDK publishes, which is what `sync` may write a catalog entry for: it knows their version\n * (the CLI's own, since they release in lockstep). Any other `@rexezuge/*` name is unknown here and left alone.\n */\nexport const KIT_PACKAGES: ReadonlySet<string> = new Set(\n ['errors', 'runtime', 'shared', 'i18n', 'd1', 'identity', 'web', 'http', 'contracts', 'tooling', 'testing', 'cli', 'create-worker'].map(\n (name) => `@rexezuge/${name}`,\n ),\n);\n"],
|
|
5
|
+
"mappings": "+EAAA,OAAS,gBAAAA,MAAoB,UAMtB,MAAMC,GAAuB,IAAK,CACvC,MAAMC,EAAMF,EAAa,IAAI,IAAI,kBAAmB,YAAY,GAAG,EAAG,MAAM,EAC5E,OAAQ,KAAK,MAAME,CAAG,EAA0B,OAClD,GAAE,EAKI,SAAUC,EAAaC,EAAY,CACvC,MAAMC,EAAQ,kCAAkC,KAAKD,CAAI,EACzD,OAAOC,IAAU,KAAO,KAAO,CAAC,OAAOA,EAAM,CAAC,CAAC,EAAG,OAAOA,EAAM,CAAC,CAAC,EAAG,OAAOA,EAAM,CAAC,CAAC,CAAC,CACtF,CAHgBC,EAAAH,EAAA,gBAQV,SAAUI,EAAaC,EAAsBC,EAAoB,CACrE,OAAOD,EAAE,CAAC,IAAMC,EAAE,CAAC,GAAKD,EAAE,CAAC,GAAK,KAAOC,EAAE,CAAC,GAAK,IAAMD,EAAE,CAAC,GAAK,IAAMC,EAAE,CAAC,GAAK,EAC7E,CAFgBH,EAAAC,EAAA,gBAQT,MAAMG,EAAoC,IAAI,IACnD,CAAC,SAAU,UAAW,SAAU,OAAQ,KAAM,WAAY,MAAO,OAAQ,YAAa,UAAW,UAAW,MAAO,eAAe,EAAE,IACjIC,GAAS,aAAaA,CAAI,EAAE,CAC9B",
|
|
6
|
+
"names": ["readFileSync", "CLI_VERSION", "raw", "parseVersion", "spec", "match", "__name", "atLeastMinor", "a", "b", "KIT_PACKAGES", "name"]
|
|
7
7
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { FamilyManifest } from '@rexezuge/tooling/manifest';
|
|
2
2
|
/**
|
|
3
3
|
* The SDK's reusable workflows, which a consumer calls instead of copying (RFC 0001, "Repo workflows").
|
|
4
|
-
* They
|
|
4
|
+
* They live in the SDK's `.github/workflows` and the owner moves the `v1` tag after each release.
|
|
5
5
|
*/
|
|
6
6
|
export declare const WORKFLOW_REF = "Rexezuge-CloudflareWorkers/SDK/.github/workflows";
|
|
7
7
|
export declare const WORKFLOW_TAG = "v1";
|
|
8
8
|
export type CallerKind = 'ci' | 'cd' | 'version-update' | 'backup-d1' | 'backup-main' | 'upstream-sync';
|
|
9
9
|
/**
|
|
10
10
|
* A caller workflow: the whole file is one `uses:` of the SDK's reusable workflow with the repo's secrets.
|
|
11
|
+
* Inputs (`with:`) are the repo's to add; `rexezuge sync` replaces a workflow that is not a caller and leaves one that is.
|
|
11
12
|
*/
|
|
12
13
|
export declare function renderCaller(kind: CallerKind): string;
|
|
13
14
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-callers.d.ts","sourceRoot":"","sources":["../src/workflow-callers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,YAAY,qDAAqD,CAAC;AAC/E,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,gBAAgB,GAAG,WAAW,GAAG,aAAa,GAAG,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"workflow-callers.d.ts","sourceRoot":"","sources":["../src/workflow-callers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,YAAY,qDAAqD,CAAC;AAC/E,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,gBAAgB,GAAG,WAAW,GAAG,aAAa,GAAG,eAAe,CAAC;AA2DxG;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAerD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,GAAG,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAIpG;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAiBjE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAEnD"}
|