@reddoorla/maintenance 0.2.0 → 0.3.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 +164 -5
- package/dist/cli/bin.js.map +1 -1
- package/dist/index.d.ts +14 -3
- package/dist/index.js +100 -1
- package/dist/index.js.map +1 -1
- package/dist/recipes/sync-configs.d.ts +1 -1
- package/dist/{sync-configs-7XIzzN_L.d.ts → sync-configs-D_Dm-68_.d.ts} +1 -1
- package/package.json +1 -1
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-D_Dm-68_.js';
|
|
2
|
+
export { C as ConfigName, c as SyncConfigsOptions, s as syncConfigs } from './sync-configs-D_Dm-68_.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
|
@@ -1358,12 +1358,110 @@ async function convertToPnpm(site, opts = {}) {
|
|
|
1358
1358
|
};
|
|
1359
1359
|
}
|
|
1360
1360
|
|
|
1361
|
+
// src/recipes/onboard.ts
|
|
1362
|
+
import { stat as stat2 } from "fs/promises";
|
|
1363
|
+
import { join as join13 } from "path";
|
|
1364
|
+
var PACKAGE_NAME = "@reddoorla/maintenance";
|
|
1365
|
+
var DEFAULT_PACKAGE_VERSION = "^0.2.0";
|
|
1366
|
+
var AUDIT_DEPS = {
|
|
1367
|
+
lighthouse: [{ name: "@lhci/cli", version: "^0.15.1" }],
|
|
1368
|
+
a11y: [
|
|
1369
|
+
{ name: "@playwright/test", version: "^1.59.1" },
|
|
1370
|
+
{ name: "@axe-core/playwright", version: "^4.11.3" }
|
|
1371
|
+
]
|
|
1372
|
+
};
|
|
1373
|
+
async function exists2(path) {
|
|
1374
|
+
try {
|
|
1375
|
+
await stat2(path);
|
|
1376
|
+
return true;
|
|
1377
|
+
} catch {
|
|
1378
|
+
return false;
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
function siteLabel10(site) {
|
|
1382
|
+
return site.name ?? site.path;
|
|
1383
|
+
}
|
|
1384
|
+
function isDeclared(pkg, name) {
|
|
1385
|
+
return Boolean(pkg.dependencies?.[name] ?? pkg.devDependencies?.[name]);
|
|
1386
|
+
}
|
|
1387
|
+
async function onboard(site, opts = {}) {
|
|
1388
|
+
const label = siteLabel10(site);
|
|
1389
|
+
const spawn2 = opts.spawn ?? defaultSpawn;
|
|
1390
|
+
const audits = opts.audits ?? ["lighthouse", "a11y"];
|
|
1391
|
+
const packageVersion = opts.packageVersion ?? DEFAULT_PACKAGE_VERSION;
|
|
1392
|
+
if (!await exists2(join13(site.path, "pnpm-lock.yaml"))) {
|
|
1393
|
+
return {
|
|
1394
|
+
recipe: "onboard",
|
|
1395
|
+
site: label,
|
|
1396
|
+
status: "failed",
|
|
1397
|
+
commits: [],
|
|
1398
|
+
notes: "no pnpm-lock.yaml at site root \u2014 run convert-to-pnpm first"
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1401
|
+
const pkgPath = join13(site.path, "package.json");
|
|
1402
|
+
const pkg = await readPackageJson(pkgPath);
|
|
1403
|
+
const toAdd = [];
|
|
1404
|
+
if (!isDeclared(pkg, PACKAGE_NAME)) {
|
|
1405
|
+
toAdd.push({ name: PACKAGE_NAME, version: packageVersion });
|
|
1406
|
+
}
|
|
1407
|
+
for (const audit of audits) {
|
|
1408
|
+
for (const dep of AUDIT_DEPS[audit]) {
|
|
1409
|
+
if (!isDeclared(pkg, dep.name)) toAdd.push(dep);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
if (toAdd.length === 0) {
|
|
1413
|
+
return {
|
|
1414
|
+
recipe: "onboard",
|
|
1415
|
+
site: label,
|
|
1416
|
+
status: "noop",
|
|
1417
|
+
commits: [],
|
|
1418
|
+
notes: `site already has ${PACKAGE_NAME} and audit deps (${audits.join("+")})`
|
|
1419
|
+
};
|
|
1420
|
+
}
|
|
1421
|
+
if (!await isWorkingTreeClean(site.path)) {
|
|
1422
|
+
throw new Error(`refusing to run: working tree is not clean at ${site.path}`);
|
|
1423
|
+
}
|
|
1424
|
+
const branch = branchName("onboard");
|
|
1425
|
+
await createBranch(site.path, branch);
|
|
1426
|
+
let next = pkg;
|
|
1427
|
+
for (const dep of toAdd) {
|
|
1428
|
+
next = bumpDep(next, dep.name, dep.version);
|
|
1429
|
+
}
|
|
1430
|
+
await writePackageJson(pkgPath, next);
|
|
1431
|
+
const installResult = await spawn2("pnpm", ["install"], {
|
|
1432
|
+
cwd: site.path,
|
|
1433
|
+
streaming: true
|
|
1434
|
+
});
|
|
1435
|
+
if (installResult.code !== 0) {
|
|
1436
|
+
return {
|
|
1437
|
+
recipe: "onboard",
|
|
1438
|
+
site: label,
|
|
1439
|
+
status: "failed",
|
|
1440
|
+
commits: [],
|
|
1441
|
+
notes: `pnpm install failed (exit ${installResult.code}). branch ${branch} left for inspection.`
|
|
1442
|
+
};
|
|
1443
|
+
}
|
|
1444
|
+
const sha = await commit(
|
|
1445
|
+
site.path,
|
|
1446
|
+
`chore(reddoor): onboard with ${PACKAGE_NAME} ${packageVersion}`
|
|
1447
|
+
);
|
|
1448
|
+
const shas = sha ? [sha] : [];
|
|
1449
|
+
return {
|
|
1450
|
+
recipe: "onboard",
|
|
1451
|
+
site: label,
|
|
1452
|
+
status: "applied",
|
|
1453
|
+
commits: shas,
|
|
1454
|
+
notes: `branch: ${branch}. Added ${toAdd.length} dep(s): ${toAdd.map((d) => d.name).join(", ")}`
|
|
1455
|
+
};
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1361
1458
|
// src/recipes/index.ts
|
|
1362
1459
|
var ALL_RECIPE_NAMES = [
|
|
1363
1460
|
"sync-configs",
|
|
1364
1461
|
"bump-deps",
|
|
1365
1462
|
"svelte-4-to-5",
|
|
1366
|
-
"convert-to-pnpm"
|
|
1463
|
+
"convert-to-pnpm",
|
|
1464
|
+
"onboard"
|
|
1367
1465
|
];
|
|
1368
1466
|
function isRecipeName(value) {
|
|
1369
1467
|
return ALL_RECIPE_NAMES.includes(value);
|
|
@@ -1423,6 +1521,7 @@ export {
|
|
|
1423
1521
|
lighthouseAudit,
|
|
1424
1522
|
lintAudit,
|
|
1425
1523
|
localPath,
|
|
1524
|
+
onboard,
|
|
1426
1525
|
runAudits,
|
|
1427
1526
|
runAuditsAcross,
|
|
1428
1527
|
securityAudit,
|