@reddoorla/maintenance 0.2.0 → 0.4.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/dist/cli/bin.js +183 -6
- package/dist/cli/bin.js.map +1 -1
- package/dist/configs/svelte.d.ts +39 -0
- package/dist/configs/svelte.js +30 -0
- package/dist/configs/svelte.js.map +1 -0
- package/dist/index.d.ts +14 -3
- package/dist/index.js +119 -2
- package/dist/index.js.map +1 -1
- package/dist/recipes/sync-configs.d.ts +1 -1
- package/dist/recipes/sync-configs.js +19 -1
- package/dist/recipes/sync-configs.js.map +1 -1
- package/dist/{sync-configs-7XIzzN_L.d.ts → sync-configs-C56tK7Go.d.ts} +2 -2
- package/package.json +5 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal shape we touch — the full type lives in @sveltejs/kit's `Config`.
|
|
3
|
+
* We don't import it directly to avoid a peer dependency for what amounts
|
|
4
|
+
* to a small config helper. Sites get full type-checking from their own
|
|
5
|
+
* `@sveltejs/kit` install when they invoke createSvelteConfig.
|
|
6
|
+
*/
|
|
7
|
+
type WarningFilter = (warning: {
|
|
8
|
+
code?: string;
|
|
9
|
+
message?: string;
|
|
10
|
+
}) => boolean;
|
|
11
|
+
type SvelteConfigLike = {
|
|
12
|
+
kit?: unknown;
|
|
13
|
+
preprocess?: unknown;
|
|
14
|
+
compilerOptions?: {
|
|
15
|
+
warningFilter?: WarningFilter;
|
|
16
|
+
[k: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
[k: string]: unknown;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Compose a Svelte/Kit config with reddoor's canonical compilerOptions
|
|
22
|
+
* layered in. Sites pass their site-specific bits (`kit.adapter`,
|
|
23
|
+
* `preprocess`, etc.) and get back a complete config with the canonical
|
|
24
|
+
* warning filter applied.
|
|
25
|
+
*
|
|
26
|
+
* If the site supplies its own `compilerOptions.warningFilter`, the filters
|
|
27
|
+
* compose: a warning is shown only when both filters allow it.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* import { createSvelteConfig } from "@reddoorla/maintenance/configs/svelte";
|
|
31
|
+
* import adapter from "@sveltejs/adapter-auto";
|
|
32
|
+
*
|
|
33
|
+
* export default createSvelteConfig({ kit: { adapter: adapter() } });
|
|
34
|
+
*/
|
|
35
|
+
declare function createSvelteConfig(siteConfig?: SvelteConfigLike): SvelteConfigLike & {
|
|
36
|
+
compilerOptions: NonNullable<SvelteConfigLike["compilerOptions"]>;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { type SvelteConfigLike, createSvelteConfig, createSvelteConfig as default };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/configs/svelte.ts
|
|
2
|
+
var SILENCED_WARNING_CODES = /* @__PURE__ */ new Set([
|
|
3
|
+
// `<div ... />` shorthand is widely used across reddoor codebases; the
|
|
4
|
+
// Svelte 5 strictness change for non-void self-closing tags would flood
|
|
5
|
+
// dev logs with no actionable signal.
|
|
6
|
+
"element_invalid_self_closing_tag"
|
|
7
|
+
]);
|
|
8
|
+
function isSilenced(warning) {
|
|
9
|
+
return warning.code !== void 0 && SILENCED_WARNING_CODES.has(warning.code);
|
|
10
|
+
}
|
|
11
|
+
function createSvelteConfig(siteConfig = {}) {
|
|
12
|
+
const siteCompiler = siteConfig.compilerOptions ?? {};
|
|
13
|
+
const siteFilter = siteCompiler.warningFilter;
|
|
14
|
+
return {
|
|
15
|
+
...siteConfig,
|
|
16
|
+
compilerOptions: {
|
|
17
|
+
...siteCompiler,
|
|
18
|
+
warningFilter: (warning) => {
|
|
19
|
+
if (isSilenced(warning)) return false;
|
|
20
|
+
return siteFilter ? siteFilter(warning) : true;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
var svelte_default = createSvelteConfig;
|
|
26
|
+
export {
|
|
27
|
+
createSvelteConfig,
|
|
28
|
+
svelte_default as default
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=svelte.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/configs/svelte.ts"],"sourcesContent":["/**\n * Minimal shape we touch — the full type lives in @sveltejs/kit's `Config`.\n * We don't import it directly to avoid a peer dependency for what amounts\n * to a small config helper. Sites get full type-checking from their own\n * `@sveltejs/kit` install when they invoke createSvelteConfig.\n */\ntype WarningFilter = (warning: { code?: string; message?: string }) => boolean;\n\nexport type SvelteConfigLike = {\n kit?: unknown;\n preprocess?: unknown;\n compilerOptions?: {\n warningFilter?: WarningFilter;\n [k: string]: unknown;\n };\n [k: string]: unknown;\n};\n\n/** Compiler-level warnings the canonical reddoor stack treats as noise. */\nconst SILENCED_WARNING_CODES = new Set<string>([\n // `<div ... />` shorthand is widely used across reddoor codebases; the\n // Svelte 5 strictness change for non-void self-closing tags would flood\n // dev logs with no actionable signal.\n \"element_invalid_self_closing_tag\",\n]);\n\nfunction isSilenced(warning: { code?: string }): boolean {\n return warning.code !== undefined && SILENCED_WARNING_CODES.has(warning.code);\n}\n\n/**\n * Compose a Svelte/Kit config with reddoor's canonical compilerOptions\n * layered in. Sites pass their site-specific bits (`kit.adapter`,\n * `preprocess`, etc.) and get back a complete config with the canonical\n * warning filter applied.\n *\n * If the site supplies its own `compilerOptions.warningFilter`, the filters\n * compose: a warning is shown only when both filters allow it.\n *\n * @example\n * import { createSvelteConfig } from \"@reddoorla/maintenance/configs/svelte\";\n * import adapter from \"@sveltejs/adapter-auto\";\n *\n * export default createSvelteConfig({ kit: { adapter: adapter() } });\n */\nexport function createSvelteConfig(siteConfig: SvelteConfigLike = {}): SvelteConfigLike & {\n compilerOptions: NonNullable<SvelteConfigLike[\"compilerOptions\"]>;\n} {\n const siteCompiler = siteConfig.compilerOptions ?? {};\n const siteFilter = siteCompiler.warningFilter;\n\n return {\n ...siteConfig,\n compilerOptions: {\n ...siteCompiler,\n warningFilter: (warning) => {\n if (isSilenced(warning)) return false;\n return siteFilter ? siteFilter(warning) : true;\n },\n },\n };\n}\n\nexport default createSvelteConfig;\n"],"mappings":";AAmBA,IAAM,yBAAyB,oBAAI,IAAY;AAAA;AAAA;AAAA;AAAA,EAI7C;AACF,CAAC;AAED,SAAS,WAAW,SAAqC;AACvD,SAAO,QAAQ,SAAS,UAAa,uBAAuB,IAAI,QAAQ,IAAI;AAC9E;AAiBO,SAAS,mBAAmB,aAA+B,CAAC,GAEjE;AACA,QAAM,eAAe,WAAW,mBAAmB,CAAC;AACpD,QAAM,aAAa,aAAa;AAEhC,SAAO;AAAA,IACL,GAAG;AAAA,IACH,iBAAiB;AAAA,MACf,GAAG;AAAA,MACH,eAAe,CAAC,YAAY;AAC1B,YAAI,WAAW,OAAO,EAAG,QAAO;AAChC,eAAO,aAAa,WAAW,OAAO,IAAI;AAAA,MAC5C;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,iBAAQ;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as Site, a as AuditResult, A as AuditName, b as RecipeResult, R as RecipeName, I as InventoryProvider } from './sync-configs-
|
|
2
|
-
export { C as ConfigName, c as SyncConfigsOptions, s as syncConfigs } from './sync-configs-
|
|
1
|
+
import { S as Site, a as AuditResult, A as AuditName, b as RecipeResult, R as RecipeName, I as InventoryProvider } from './sync-configs-C56tK7Go.js';
|
|
2
|
+
export { C as ConfigName, c as SyncConfigsOptions, s as syncConfigs } from './sync-configs-C56tK7Go.js';
|
|
3
3
|
|
|
4
4
|
type SpawnResult = {
|
|
5
5
|
code: number;
|
|
@@ -56,6 +56,17 @@ type ConvertToPnpmOptions = {
|
|
|
56
56
|
};
|
|
57
57
|
declare function convertToPnpm(site: Site, opts?: ConvertToPnpmOptions): Promise<RecipeResult>;
|
|
58
58
|
|
|
59
|
+
type OnboardAudit = "lighthouse" | "a11y";
|
|
60
|
+
type OnboardOptions = {
|
|
61
|
+
spawn?: SpawnFn;
|
|
62
|
+
/** Which audit-related deps to ensure. Defaults to all known audits. */
|
|
63
|
+
audits?: OnboardAudit[];
|
|
64
|
+
/** Version range to pin for @reddoorla/maintenance. Defaults to the
|
|
65
|
+
* current minor range. Update on each minor bump. */
|
|
66
|
+
packageVersion?: string;
|
|
67
|
+
};
|
|
68
|
+
declare function onboard(site: Site, opts?: OnboardOptions): Promise<RecipeResult>;
|
|
69
|
+
|
|
59
70
|
declare const ALL_RECIPE_NAMES: RecipeName[];
|
|
60
71
|
declare function isRecipeName(value: string): value is RecipeName;
|
|
61
72
|
|
|
@@ -66,4 +77,4 @@ declare function localPath(path: string, opts?: LocalPathOptions): InventoryProv
|
|
|
66
77
|
|
|
67
78
|
declare function fromJsonFile(path: string): InventoryProvider;
|
|
68
79
|
|
|
69
|
-
export { ALL_AUDIT_NAMES, ALL_RECIPE_NAMES, AuditName, AuditResult, type BumpDepsOptions, type ConvertToPnpmOptions, InventoryProvider, type LocalPathOptions, RecipeName, RecipeResult, Site, type UpgradeSvelte4to5Options, a11yAudit, bumpDeps, convertToPnpm, depsAudit, fromJsonFile, isRecipeName, lighthouseAudit, lintAudit, localPath, runAudits, runAuditsAcross, securityAudit, upgradeSvelte4to5 };
|
|
80
|
+
export { ALL_AUDIT_NAMES, ALL_RECIPE_NAMES, AuditName, AuditResult, type BumpDepsOptions, type ConvertToPnpmOptions, InventoryProvider, type LocalPathOptions, type OnboardAudit, type OnboardOptions, RecipeName, RecipeResult, Site, type UpgradeSvelte4to5Options, a11yAudit, bumpDeps, convertToPnpm, depsAudit, fromJsonFile, isRecipeName, lighthouseAudit, lintAudit, localPath, onboard, runAudits, runAuditsAcross, securityAudit, upgradeSvelte4to5 };
|
package/dist/index.js
CHANGED
|
@@ -702,7 +702,25 @@ var playwrightA11y = {
|
|
|
702
702
|
contents: `export { default } from "@reddoorla/maintenance/configs/playwright-a11y";
|
|
703
703
|
`
|
|
704
704
|
};
|
|
705
|
-
var
|
|
705
|
+
var svelte = {
|
|
706
|
+
config: "svelte",
|
|
707
|
+
path: "svelte.config.js",
|
|
708
|
+
contents: `import { createSvelteConfig } from "@reddoorla/maintenance/configs/svelte";
|
|
709
|
+
import adapter from "@sveltejs/adapter-auto";
|
|
710
|
+
|
|
711
|
+
/** @type {import('@sveltejs/kit').Config} */
|
|
712
|
+
export default createSvelteConfig({
|
|
713
|
+
kit: { adapter: adapter() },
|
|
714
|
+
});
|
|
715
|
+
`
|
|
716
|
+
};
|
|
717
|
+
var ALL_TEMPLATES = [
|
|
718
|
+
eslint,
|
|
719
|
+
prettier,
|
|
720
|
+
lighthouse,
|
|
721
|
+
playwrightA11y,
|
|
722
|
+
svelte
|
|
723
|
+
];
|
|
706
724
|
function templatesByName(which) {
|
|
707
725
|
return ALL_TEMPLATES.filter((t) => which.includes(t.config));
|
|
708
726
|
}
|
|
@@ -1358,12 +1376,110 @@ async function convertToPnpm(site, opts = {}) {
|
|
|
1358
1376
|
};
|
|
1359
1377
|
}
|
|
1360
1378
|
|
|
1379
|
+
// src/recipes/onboard.ts
|
|
1380
|
+
import { stat as stat2 } from "fs/promises";
|
|
1381
|
+
import { join as join13 } from "path";
|
|
1382
|
+
var PACKAGE_NAME = "@reddoorla/maintenance";
|
|
1383
|
+
var DEFAULT_PACKAGE_VERSION = "^0.2.0";
|
|
1384
|
+
var AUDIT_DEPS = {
|
|
1385
|
+
lighthouse: [{ name: "@lhci/cli", version: "^0.15.1" }],
|
|
1386
|
+
a11y: [
|
|
1387
|
+
{ name: "@playwright/test", version: "^1.59.1" },
|
|
1388
|
+
{ name: "@axe-core/playwright", version: "^4.11.3" }
|
|
1389
|
+
]
|
|
1390
|
+
};
|
|
1391
|
+
async function exists2(path) {
|
|
1392
|
+
try {
|
|
1393
|
+
await stat2(path);
|
|
1394
|
+
return true;
|
|
1395
|
+
} catch {
|
|
1396
|
+
return false;
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
function siteLabel10(site) {
|
|
1400
|
+
return site.name ?? site.path;
|
|
1401
|
+
}
|
|
1402
|
+
function isDeclared(pkg, name) {
|
|
1403
|
+
return Boolean(pkg.dependencies?.[name] ?? pkg.devDependencies?.[name]);
|
|
1404
|
+
}
|
|
1405
|
+
async function onboard(site, opts = {}) {
|
|
1406
|
+
const label = siteLabel10(site);
|
|
1407
|
+
const spawn2 = opts.spawn ?? defaultSpawn;
|
|
1408
|
+
const audits = opts.audits ?? ["lighthouse", "a11y"];
|
|
1409
|
+
const packageVersion = opts.packageVersion ?? DEFAULT_PACKAGE_VERSION;
|
|
1410
|
+
if (!await exists2(join13(site.path, "pnpm-lock.yaml"))) {
|
|
1411
|
+
return {
|
|
1412
|
+
recipe: "onboard",
|
|
1413
|
+
site: label,
|
|
1414
|
+
status: "failed",
|
|
1415
|
+
commits: [],
|
|
1416
|
+
notes: "no pnpm-lock.yaml at site root \u2014 run convert-to-pnpm first"
|
|
1417
|
+
};
|
|
1418
|
+
}
|
|
1419
|
+
const pkgPath = join13(site.path, "package.json");
|
|
1420
|
+
const pkg = await readPackageJson(pkgPath);
|
|
1421
|
+
const toAdd = [];
|
|
1422
|
+
if (!isDeclared(pkg, PACKAGE_NAME)) {
|
|
1423
|
+
toAdd.push({ name: PACKAGE_NAME, version: packageVersion });
|
|
1424
|
+
}
|
|
1425
|
+
for (const audit of audits) {
|
|
1426
|
+
for (const dep of AUDIT_DEPS[audit]) {
|
|
1427
|
+
if (!isDeclared(pkg, dep.name)) toAdd.push(dep);
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
if (toAdd.length === 0) {
|
|
1431
|
+
return {
|
|
1432
|
+
recipe: "onboard",
|
|
1433
|
+
site: label,
|
|
1434
|
+
status: "noop",
|
|
1435
|
+
commits: [],
|
|
1436
|
+
notes: `site already has ${PACKAGE_NAME} and audit deps (${audits.join("+")})`
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
if (!await isWorkingTreeClean(site.path)) {
|
|
1440
|
+
throw new Error(`refusing to run: working tree is not clean at ${site.path}`);
|
|
1441
|
+
}
|
|
1442
|
+
const branch = branchName("onboard");
|
|
1443
|
+
await createBranch(site.path, branch);
|
|
1444
|
+
let next = pkg;
|
|
1445
|
+
for (const dep of toAdd) {
|
|
1446
|
+
next = bumpDep(next, dep.name, dep.version);
|
|
1447
|
+
}
|
|
1448
|
+
await writePackageJson(pkgPath, next);
|
|
1449
|
+
const installResult = await spawn2("pnpm", ["install"], {
|
|
1450
|
+
cwd: site.path,
|
|
1451
|
+
streaming: true
|
|
1452
|
+
});
|
|
1453
|
+
if (installResult.code !== 0) {
|
|
1454
|
+
return {
|
|
1455
|
+
recipe: "onboard",
|
|
1456
|
+
site: label,
|
|
1457
|
+
status: "failed",
|
|
1458
|
+
commits: [],
|
|
1459
|
+
notes: `pnpm install failed (exit ${installResult.code}). branch ${branch} left for inspection.`
|
|
1460
|
+
};
|
|
1461
|
+
}
|
|
1462
|
+
const sha = await commit(
|
|
1463
|
+
site.path,
|
|
1464
|
+
`chore(reddoor): onboard with ${PACKAGE_NAME} ${packageVersion}`
|
|
1465
|
+
);
|
|
1466
|
+
const shas = sha ? [sha] : [];
|
|
1467
|
+
return {
|
|
1468
|
+
recipe: "onboard",
|
|
1469
|
+
site: label,
|
|
1470
|
+
status: "applied",
|
|
1471
|
+
commits: shas,
|
|
1472
|
+
notes: `branch: ${branch}. Added ${toAdd.length} dep(s): ${toAdd.map((d) => d.name).join(", ")}`
|
|
1473
|
+
};
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1361
1476
|
// src/recipes/index.ts
|
|
1362
1477
|
var ALL_RECIPE_NAMES = [
|
|
1363
1478
|
"sync-configs",
|
|
1364
1479
|
"bump-deps",
|
|
1365
1480
|
"svelte-4-to-5",
|
|
1366
|
-
"convert-to-pnpm"
|
|
1481
|
+
"convert-to-pnpm",
|
|
1482
|
+
"onboard"
|
|
1367
1483
|
];
|
|
1368
1484
|
function isRecipeName(value) {
|
|
1369
1485
|
return ALL_RECIPE_NAMES.includes(value);
|
|
@@ -1423,6 +1539,7 @@ export {
|
|
|
1423
1539
|
lighthouseAudit,
|
|
1424
1540
|
lintAudit,
|
|
1425
1541
|
localPath,
|
|
1542
|
+
onboard,
|
|
1426
1543
|
runAudits,
|
|
1427
1544
|
runAuditsAcross,
|
|
1428
1545
|
securityAudit,
|