@afokapu/atdd-bun 0.10.60 → 0.10.61

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 CHANGED
@@ -25,6 +25,13 @@ without `--replace`, and adding the dependency changes nothing until you run `in
25
25
 
26
26
  Then require the workflow's job in the GitHub branch ruleset, so it gates merges.
27
27
 
28
+ For a declared GitHub Packages scope in `.npmrc` (for example,
29
+ `@forgeonehundred:registry=https://npm.pkg.github.com`), run
30
+ `bun run atdd-bun ci init --replace`. The generator preserves that scope and adds
31
+ only `//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}`; the generated workflow
32
+ supplies the ephemeral Actions token to its frozen install step. It refuses an
33
+ existing stored token rather than reading, copying, or replacing it.
34
+
28
35
  ## Commands
29
36
 
30
37
  | Command | What it does |
package/integrity.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
- "version": "0.10.60",
2
+ "version": "0.10.61",
3
3
  "files": {
4
4
  "HOOK_AUDIT.md": "5329d840db37671b1918f688ead26865473b87db73dbc75f7c8b2a8bbe8d6d43",
5
5
  "PLANNER_PORT.md": "fb5935bac8b7ac18994de21e43ace3a5ef8cd55f85b0e3349fca261280054f11",
6
- "README.md": "ab10b690a87a3a654e7b16ad2528acdfc682e0b2eca31dddf1fae9dd69ef44c5",
6
+ "README.md": "97715ea62760048752774c5c6f9a34046e5a019595590fc71d5b007551385c7e",
7
7
  "bunfig.toml": "b9fc65eca9014c5179380259d70e76385a6a80788fa9a2df5fb3eaa5554fd2fe",
8
8
  "conventions/_profiles/architecture.yaml": "f1808768b720a4e476047e4a0912002ca673946562cea9aeef5d0c214828d93a",
9
9
  "conventions/_profiles/coder.yaml": "3fb191556a64c9ebcf249516afa189afca24da9b22fd40b2fc66908196cdfb78",
@@ -1257,7 +1257,7 @@
1257
1257
  "planner-schemas/wmbt.schema.json": "7a3a5693bfcf01340667c2be4a3c48e74f34b1af7e8dc13372c0de06b7f4fe12",
1258
1258
  "relationships.yaml": "5860a308ebc3ee7fa8172fc2c6633984000ab3003f0ae4b6fa28db48879eda22",
1259
1259
  "src/agent.ts": "6d6c6e75908af8fbab13432f0001b0374bb25cf3dee46ba218dfd67e0090cb56",
1260
- "src/ci.ts": "67e54d2cbfc44a9e42837d5e750af526d6255c539d3c452a4d5fca3226c0d9ac",
1260
+ "src/ci.ts": "646e72ff576d3921d85ecdd1d8c7821693832735be8949f5da254f3c345be032",
1261
1261
  "src/cli.ts": "90e59edbb8a7ea116ad9e7b4ba56b5c612ac18ada05824e8e941048be4dc72c8",
1262
1262
  "src/docs-capability.ts": "bdeeb414649049b1cd4fa8008cada3a576318be51c43bec91bfa46a8e250c270",
1263
1263
  "src/enforce.ts": "7e6b3a1fc7c90f8e1836ab3e4655778fb569a63be5e7c199de44024fc003e6be",
@@ -1279,6 +1279,6 @@
1279
1279
  "templates/agents/atdd-bun.integrity.test.ts": "dec6f6e5f65a08d9512fc703b367c163f8c9da1f6aa7fd466835c1ec30348a41",
1280
1280
  "templates/docs/site.css": "482b3427e3a3cb02a85dc85cfbeac80592dfd53abf42fc92d6ea7071f22afc95",
1281
1281
  "templates/github/atdd-bun-release.yml": "d9547e9e6ef3ae010d53d55314f6a54567f88bd900f7e50d994cd308601d2684",
1282
- "templates/github/atdd-bun.yml": "404dc06b6ff4faf5eab909f9f77bac0ae58163d810c3928c4353b1f4b3529048"
1282
+ "templates/github/atdd-bun.yml": "c267f47505eb7df2b73b279185f46912aac0f17dcd2c5a1c6c8e1a5834bdcb30"
1283
1283
  }
1284
1284
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afokapu/atdd-bun",
3
- "version": "0.10.60",
3
+ "version": "0.10.61",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/afokapu/atdd-bun.git"
package/src/ci.ts CHANGED
@@ -12,5 +12,36 @@ const version = (await Bun.file(join(root, "package.json")).json() as { version:
12
12
  export async function renderWorkflow(repo = process.cwd()) {
13
13
  return (await readFile(template, "utf8")).replace("{{VERSION}}", version).replace("{{PROTECTED_BRANCHES}}", (await policy(repo)).protected_branches.map(branch => JSON.stringify(branch)).join(", "));
14
14
  }
15
- export async function ciInit(repo = process.cwd(), replace = false) { const output = join(repo, ".github/workflows/atdd-bun.yml"); if (existsSync(output) && !replace) return { ok: false, message: `${output} exists; use --replace` }; let rendered: string; try { rendered = await renderWorkflow(repo); } catch (error) { return { ok: false, message: `atdd-bun.yaml could not be parsed, so the workflow's push branches are unknown; fix the file first: ${String(error)}` }; } await mkdir(join(repo, ".github/workflows"), { recursive: true }); await writeFile(output, rendered); return { ok: true, message: output }; }
15
+ const githubPackagesRegistry = /^\s*@[\w.-]+:registry\s*=\s*https:\/\/npm\.pkg\.github\.com\/?\s*$/im;
16
+ const githubPackagesAuth = /^\s*\/\/npm\.pkg\.github\.com\/:_authToken\s*=\s*(.*?)\s*$/gim;
17
+ const githubPackagesTokenInterpolation = "${NODE_AUTH_TOKEN}";
18
+
19
+ /** Add only the npm-compatible environment interpolation required by an already-declared GitHub Packages scope.
20
+ * Registry ownership remains with the consumer: absent or other registry scopes are never invented or changed. */
21
+ async function githubPackagesNpmrc(repo: string) {
22
+ const path = join(repo, ".npmrc");
23
+ if (!existsSync(path)) return { ok: true, path, content: undefined as string | undefined };
24
+ const content = await readFile(path, "utf8");
25
+ // Authentication is sensitive even when no scope currently routes to GitHub Packages: validate every present
26
+ // assignment before deciding whether the generator should add a missing interpolation for a declared scope.
27
+ const assignments = [...content.matchAll(githubPackagesAuth)].map(match => match[1]);
28
+ if (assignments.length > 1) return { ok: false, path, message: ".npmrc must declare exactly one npm.pkg.github.com _authToken assignment to avoid ambiguous authentication" };
29
+ const current = assignments[0];
30
+ if (current !== undefined && current !== githubPackagesTokenInterpolation) return { ok: false, path, message: ".npmrc already configures npm.pkg.github.com authentication; replace it with the standard ${NODE_AUTH_TOKEN} interpolation instead of storing a credential" };
31
+ if (!githubPackagesRegistry.test(content) || current !== undefined) return { ok: true, path, content: undefined as string | undefined };
32
+ return { ok: true, path, content: `${content}${content.endsWith("\n") ? "" : "\n"}//npm.pkg.github.com/:_authToken=${githubPackagesTokenInterpolation}\n` };
33
+ }
34
+
35
+ export async function ciInit(repo = process.cwd(), replace = false) {
36
+ const output = join(repo, ".github/workflows/atdd-bun.yml");
37
+ if (existsSync(output) && !replace) return { ok: false, message: `${output} exists; use --replace` };
38
+ let rendered: string;
39
+ try { rendered = await renderWorkflow(repo); } catch (error) { return { ok: false, message: `atdd-bun.yaml could not be parsed, so the workflow's push branches are unknown; fix the file first: ${String(error)}` }; }
40
+ const npmrc = await githubPackagesNpmrc(repo);
41
+ if (!npmrc.ok) return { ok: false, message: `${npmrc.path}: ${npmrc.message}` };
42
+ await mkdir(join(repo, ".github/workflows"), { recursive: true });
43
+ if (npmrc.content !== undefined) await writeFile(npmrc.path, npmrc.content);
44
+ await writeFile(output, rendered);
45
+ return { ok: true, message: npmrc.content === undefined ? output : `${output}\n${npmrc.path}` };
46
+ }
16
47
  export async function ciStatus(repo = process.cwd()) { const output = join(repo, ".github/workflows/atdd-bun.yml"); return { ok: existsSync(output), message: output }; }
@@ -1,5 +1,10 @@
1
1
  # Generated by @afokapu/atdd-bun {{VERSION}}. Do not edit; run `atdd-bun ci init --replace`.
2
2
  name: ATdd-Bun
3
+ # The generated gate only needs checkout and package-download access. All other
4
+ # token capabilities are explicitly disabled.
5
+ permissions:
6
+ contents: read
7
+ packages: read
3
8
  on:
4
9
  pull_request:
5
10
  merge_group:
@@ -16,9 +21,15 @@ jobs:
16
21
  ATDD_BASE_REF: ${{ github.event_name == 'push' && github.event.before || github.event_name == 'merge_group' && github.event.merge_group.base_sha || '' }}
17
22
  steps:
18
23
  - uses: actions/checkout@v4
19
- with: { fetch-depth: 0 }
24
+ with:
25
+ fetch-depth: 0
26
+ persist-credentials: false
20
27
  - uses: oven-sh/setup-bun@v2
28
+ # A consumer-owned .npmrc keeps registry scope. The Actions token exists
29
+ # only for this install step; it is neither written nor echoed.
21
30
  - run: bun install --frozen-lockfile
31
+ env:
32
+ NODE_AUTH_TOKEN: ${{ github.token }}
22
33
  - run: bun run atdd-bun integrity
23
34
  - run: bun run atdd-bun all
24
35
  - run: bun test