@bensandee/tooling 0.53.0 → 0.53.1
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/bin.mjs +49 -10
- package/package.json +1 -1
package/dist/bin.mjs
CHANGED
|
@@ -1188,6 +1188,45 @@ function preserveDevBinaryPath(generated, existing) {
|
|
|
1188
1188
|
if (!match) return generated;
|
|
1189
1189
|
return generated.replaceAll("pnpm exec bst", match[0]).replaceAll("pnpm dlx @bensandee/tooling", match[0]);
|
|
1190
1190
|
}
|
|
1191
|
+
function escapeRegex(value) {
|
|
1192
|
+
return value.replaceAll(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1193
|
+
}
|
|
1194
|
+
/** Match a `uses: <name>@<ref>` line, capturing indentation, action name, ref, and trailing comment. */
|
|
1195
|
+
const USES_LINE_PATTERN = /^(?<indent>\s*(?:-\s+)?uses:\s*)(?<name>[^\s@#]+)@(?<ref>\S+)(?<comment>[ \t]+#[^\n]*)?$/gm;
|
|
1196
|
+
/**
|
|
1197
|
+
* Extract a map of action-name → full verbatim tail (`<ref>` + optional inline comment)
|
|
1198
|
+
* from an existing workflow's `uses:` lines. Local actions (starting with `./` or
|
|
1199
|
+
* `docker://`) are skipped. First occurrence wins.
|
|
1200
|
+
*/
|
|
1201
|
+
function extractPinnedActions(existing) {
|
|
1202
|
+
const map = /* @__PURE__ */ new Map();
|
|
1203
|
+
for (const match of existing.matchAll(USES_LINE_PATTERN)) {
|
|
1204
|
+
const { name, ref, comment } = match.groups ?? {};
|
|
1205
|
+
if (!name || !ref) continue;
|
|
1206
|
+
if (name.startsWith("./") || name.startsWith("docker://")) continue;
|
|
1207
|
+
if (!map.has(name)) map.set(name, `${ref}${comment ?? ""}`);
|
|
1208
|
+
}
|
|
1209
|
+
return map;
|
|
1210
|
+
}
|
|
1211
|
+
/**
|
|
1212
|
+
* Preserve existing Renovate-managed action pins when rewriting a workflow.
|
|
1213
|
+
*
|
|
1214
|
+
* For each `uses: <name>@<ref>` in the existing file, if the generated file references the
|
|
1215
|
+
* same action name, substitute the existing ref (including any inline comment like `# v6`)
|
|
1216
|
+
* into the generated output. This keeps SHA pins and their version annotations stable when
|
|
1217
|
+
* unrelated workflow changes force a rewrite.
|
|
1218
|
+
*/
|
|
1219
|
+
function preservePinnedActions(generated, existing) {
|
|
1220
|
+
if (!existing) return generated;
|
|
1221
|
+
const pins = extractPinnedActions(existing);
|
|
1222
|
+
if (pins.size === 0) return generated;
|
|
1223
|
+
let result = generated;
|
|
1224
|
+
for (const [name, tail] of pins) {
|
|
1225
|
+
const pattern = new RegExp(String.raw`^(\s*(?:-\s+)?uses:\s*)${escapeRegex(name)}@\S+(?:[ \t]+#[^\n]*)?$`, "gm");
|
|
1226
|
+
result = result.replace(pattern, `$1${name}@${tail}`);
|
|
1227
|
+
}
|
|
1228
|
+
return result;
|
|
1229
|
+
}
|
|
1191
1230
|
/** Build a complete workflow YAML string from structured options. Single source of truth for workflow files. */
|
|
1192
1231
|
function buildWorkflowYaml(options) {
|
|
1193
1232
|
const doc = { name: options.name };
|
|
@@ -1350,8 +1389,8 @@ async function generateDeployCi(ctx) {
|
|
|
1350
1389
|
description: "Publish workflow already up to date"
|
|
1351
1390
|
};
|
|
1352
1391
|
}
|
|
1353
|
-
const
|
|
1354
|
-
const final = existing ? insertCustomBlocks(
|
|
1392
|
+
const withPinnedActions = preservePinnedActions(preserveDevBinaryPath(content, existing), existing);
|
|
1393
|
+
const final = existing ? insertCustomBlocks(withPinnedActions, extractCustomBlocks(existing)) : withPinnedActions;
|
|
1355
1394
|
ctx.write(workflowPath, final);
|
|
1356
1395
|
return {
|
|
1357
1396
|
filePath: workflowPath,
|
|
@@ -1635,7 +1674,7 @@ async function generatePackageJson(ctx) {
|
|
|
1635
1674
|
const devDeps = { ...ROOT_DEV_DEPS };
|
|
1636
1675
|
if (!isMonorepo) Object.assign(devDeps, PER_PACKAGE_DEV_DEPS);
|
|
1637
1676
|
devDeps["@bensandee/config"] = isWorkspacePackage(ctx, "@bensandee/config") ? "workspace:*" : "0.10.2";
|
|
1638
|
-
devDeps["@bensandee/tooling"] = isWorkspacePackage(ctx, "@bensandee/tooling") ? "workspace:*" : "0.53.
|
|
1677
|
+
devDeps["@bensandee/tooling"] = isWorkspacePackage(ctx, "@bensandee/tooling") ? "workspace:*" : "0.53.1";
|
|
1639
1678
|
if (ctx.config.useEslintPlugin) devDeps["@bensandee/eslint-plugin"] = isWorkspacePackage(ctx, "@bensandee/eslint-plugin") ? "workspace:*" : "0.12.0";
|
|
1640
1679
|
if (ctx.config.formatter === "oxfmt") devDeps["oxfmt"] = {
|
|
1641
1680
|
"@changesets/cli": "2.30.0",
|
|
@@ -2427,8 +2466,8 @@ async function generateReleaseCi(ctx) {
|
|
|
2427
2466
|
description: "Release workflow already up to date"
|
|
2428
2467
|
};
|
|
2429
2468
|
}
|
|
2430
|
-
const
|
|
2431
|
-
const final = existing ? insertCustomBlocks(
|
|
2469
|
+
const withPinnedActions = preservePinnedActions(preserveDevBinaryPath(content, existing), existing);
|
|
2470
|
+
const final = existing ? insertCustomBlocks(withPinnedActions, extractCustomBlocks(existing)) : withPinnedActions;
|
|
2432
2471
|
ctx.write(workflowPath, final);
|
|
2433
2472
|
return {
|
|
2434
2473
|
filePath: workflowPath,
|
|
@@ -2557,8 +2596,8 @@ async function generateCi(ctx) {
|
|
|
2557
2596
|
description: "CI workflow already up to date"
|
|
2558
2597
|
};
|
|
2559
2598
|
}
|
|
2560
|
-
const
|
|
2561
|
-
const final = existing ? insertCustomBlocks(
|
|
2599
|
+
const withPinnedActions = preservePinnedActions(preserveDevBinaryPath(content, existing), existing);
|
|
2600
|
+
const final = existing ? insertCustomBlocks(withPinnedActions, extractCustomBlocks(existing)) : withPinnedActions;
|
|
2562
2601
|
ctx.write(filePath, final);
|
|
2563
2602
|
return {
|
|
2564
2603
|
filePath,
|
|
@@ -3411,7 +3450,7 @@ async function runGenerators(ctx) {
|
|
|
3411
3450
|
function generateMigratePrompt(results, config, detected) {
|
|
3412
3451
|
const sections = [];
|
|
3413
3452
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
3414
|
-
sections.push(`# Migration Prompt\n\n_Generated by \`@bensandee/tooling@0.53.
|
|
3453
|
+
sections.push(`# Migration Prompt\n\n_Generated by \`@bensandee/tooling@0.53.1 repo:sync\` on ${timestamp}_\n`);
|
|
3415
3454
|
const changed = results.filter((r) => r.action === "created" || r.action === "updated" || r.action === "archived");
|
|
3416
3455
|
if (changed.length > 0) {
|
|
3417
3456
|
const items = changed.map((r) => {
|
|
@@ -6714,7 +6753,7 @@ async function sendWebhookWithLogging(url, secret, payload) {
|
|
|
6714
6753
|
const main = defineCommand({
|
|
6715
6754
|
meta: {
|
|
6716
6755
|
name: "bst",
|
|
6717
|
-
version: "0.53.
|
|
6756
|
+
version: "0.53.1",
|
|
6718
6757
|
description: "Bootstrap and maintain standardized TypeScript project tooling"
|
|
6719
6758
|
},
|
|
6720
6759
|
subCommands: {
|
|
@@ -6782,7 +6821,7 @@ const main = defineCommand({
|
|
|
6782
6821
|
})
|
|
6783
6822
|
}
|
|
6784
6823
|
});
|
|
6785
|
-
console.log(`@bensandee/tooling v0.53.
|
|
6824
|
+
console.log(`@bensandee/tooling v0.53.1`);
|
|
6786
6825
|
async function run() {
|
|
6787
6826
|
await runMain(main);
|
|
6788
6827
|
process.exit(process.exitCode ?? 0);
|