@jakobm/peacekeeper 0.18.0 → 0.19.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 +16 -9
- package/bin/peacekeeper.js +51 -49
- package/bin/peacekeeper.yaml +101 -0
- package/package.json +2 -1
- package/scripts/check-test-receipt.js +2 -2
- package/scripts/create-project-core.js +31 -4
- package/scripts/project-config-defaults.json +3 -1
- package/scripts/run-tests.js +2 -2
package/README.md
CHANGED
|
@@ -40,9 +40,15 @@ verified local commit. Inspect or remove the directory before retrying.
|
|
|
40
40
|
|
|
41
41
|
The generated executable `setup-github-config.sh` is deliberately not run by the
|
|
42
42
|
generator. Run it afterwards and complete the manual checklist at its top. It
|
|
43
|
-
configures applicable GitHub policy through `gh
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
configures applicable GitHub policy through `gh`, including automatic head-branch
|
|
44
|
+
deletion, repository-level **Allow auto-merge**, and merge commits as the only
|
|
45
|
+
permitted pull-request merge method, and uses
|
|
46
|
+
`groundskeeper secrets sync --new-repo` to add the repository when synchronizing
|
|
47
|
+
`RELEASE_POLICY_TOKEN`. Published projects also document the required initial manual
|
|
48
|
+
publication with `npm login` and `npm publish`, followed by npm trusted publishing
|
|
49
|
+
setup. The authenticated `gh` token needs repository **Administration: write**
|
|
50
|
+
permission to configure repository settings and branch protection. The generator
|
|
51
|
+
never registers a publisher or publishes a package.
|
|
46
52
|
|
|
47
53
|
When moving an existing project to Peacekeeper, update its dependency and lockfile,
|
|
48
54
|
package scripts, and configuration filename together. Replace previous lifecycle
|
|
@@ -129,7 +135,7 @@ Complete example:
|
|
|
129
135
|
}
|
|
130
136
|
```
|
|
131
137
|
|
|
132
|
-
`git.remote` and `git.defaultBranch` identify the branch used for checkpointing and cleanup. `git.branchPrefix` names new task branches. `run-tests` always runs the local `check-project` validation first, even when reusing a test receipt. Explicit `check-project` invocations in `tests.commands` are rejected as redundant. The configured commands are complete shell commands, run in order from the caller's Git root; install any executables they use. The test runner stops on the first failure and records a receipt only after every command succeeds. `receiptMaxAgeMinutes` controls how long a receipt can be reused. Set `npmTestUsesRunner` to `true` only when the caller's `npm test` script invokes `peacekeeper run-tests`; this makes the rerun hint `npm test --
|
|
138
|
+
`git.remote` and `git.defaultBranch` identify the branch used for checkpointing and cleanup. `git.branchPrefix` names new task branches. `run-tests` always runs the local `check-project` validation first, even when reusing a test receipt. Explicit `check-project` invocations in `tests.commands` are rejected as redundant. The configured commands are complete shell commands, run in order from the caller's Git root; install any executables they use. The test runner stops on the first failure and records a receipt only after every command succeeds. `receiptMaxAgeMinutes` controls how long a receipt can be reused. Set `npmTestUsesRunner` to `true` only when the caller's `npm test` script invokes `peacekeeper run-tests`; this makes the rerun hint `npm test -- --force`. Otherwise the hint uses the explicit package path. `loggingDirectory` stores hook invocation logs relative to the primary Git worktree's root.
|
|
133
139
|
|
|
134
140
|
`loggingEnabled` has the bundled default `true`; set it to `false` to disable invocation logs and the background cleanup worker's log file. Existing logs are kept. The setting is read from the primary checkout's configuration, including for linked worktrees. SessionStart and Stop logs include the process and event working directories, event type, primary-checkout classification, and hook response or error. Only selected event fields are logged, never the full incoming payload. These logs require the Peacekeeper script to start; a missing Node.js executable or package must be diagnosed in Codex's own logs.
|
|
135
141
|
|
|
@@ -147,7 +153,7 @@ To publish checkpoint branches automatically, set `git.checkpointPushRemotes` (f
|
|
|
147
153
|
```
|
|
148
154
|
|
|
149
155
|
Each name must identify a Git remote configured in the calling repository. Checkpoints push to exactly those remotes, creating the task branch if
|
|
150
|
-
needed.
|
|
156
|
+
needed. The bundled default is `["origin"]`; set an empty list to disable checkpoint pushes.
|
|
151
157
|
The field must be present; there is no implicit push fallback. Pushes never use force. Only a push to `git.remote` sets the
|
|
152
158
|
branch's upstream. If a push fails, earlier pushes are kept and the checkpoint
|
|
153
159
|
records a failure; fix the cause and rerun the checkpoint command to retry without
|
|
@@ -254,7 +260,7 @@ them. The shared policy then follows the installed package version.
|
|
|
254
260
|
|
|
255
261
|
## Check the setup
|
|
256
262
|
|
|
257
|
-
From the caller's Git worktree, run `npm test` for the configured commands, `npm test --
|
|
263
|
+
From the caller's Git worktree, run `npm test` for the configured commands, `npm test -- --force` to bypass a reusable receipt, `npm run cleanup:branches` to preview merged branch cleanup, and `npm run cleanup:empty-directories` to preview removal of empty directories and directories containing only ignored files. The latter command protects the root `.git`, `node_modules`, and `tmp` directories; other selected directories are removed recursively, including their ignored contents. Add `-- --execute` to either cleanup package script to apply it. Run `npm exec --no -- peacekeeper --help` for the complete command list. To create a manual checkpoint, use `npm exec --no -- peacekeeper checkpoint-codex-changes --subject "<subject>" --body "<body paragraph>"`.
|
|
258
264
|
|
|
259
265
|
Directory cleanup also preserves nested Git repositories and linked worktrees,
|
|
260
266
|
including their parent directories when those parents are ignored. It does not
|
|
@@ -270,7 +276,7 @@ the root package's own bin, including the checkpoint command requested by the
|
|
|
270
276
|
Stop hook. Install dependencies with `npm ci` to run the full test suite.
|
|
271
277
|
|
|
272
278
|
Run `npm test` in this repository to verify the shared package itself, or
|
|
273
|
-
`npm test --
|
|
279
|
+
`npm test -- --force` to force a fresh run. Its configured test command runs Node's
|
|
274
280
|
test runner directly, avoiding recursion through `npm test`. The cleanup package
|
|
275
281
|
scripts work the same way as in calling projects.
|
|
276
282
|
|
|
@@ -597,8 +603,9 @@ Explicit alternative job conditions are not supported. Workspaces are not suppor
|
|
|
597
603
|
|
|
598
604
|
Configuration migration: previously optional fields must now be declared. Run
|
|
599
605
|
`peacekeeper update-config`, review the inserted defaults, and commit the result.
|
|
600
|
-
|
|
601
|
-
|
|
606
|
+
The default `git.checkpointPushRemotes` value publishes to `origin`; use an
|
|
607
|
+
explicit empty array to keep checkpoint branches local. Empty
|
|
608
|
+
`git.releaseRequiredChecks` is valid configuration but blocks release
|
|
602
609
|
policy verification; empty `tests.commands` blocks test execution and receipts.
|
|
603
610
|
`projectChecks` always explicitly selects the workflow and jobs. This change does
|
|
604
611
|
not add online GitHub verification to `check-project`.
|
package/bin/peacekeeper.js
CHANGED
|
@@ -1,54 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { spawnSync } = require('node:child_process');
|
|
4
|
+
const fs = require('node:fs');
|
|
4
5
|
const path = require('node:path');
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
-
['update-config', 'Create or complete project configuration using bundled defaults.'],
|
|
8
|
-
['create-project', 'Create and verify a compliant TypeScript library in an empty GitHub repository.'],
|
|
9
|
-
['check-project', 'Validate local toolchain, hooks, CI and publication conventions.'],
|
|
10
|
-
['install-hooks', 'Install or update project Codex hooks while preserving other hooks.'],
|
|
11
|
-
['verify-release', 'Verify release versions, required CI and strict branch protection.'],
|
|
12
|
-
['verify-release-protection', 'Require strict mandatory release checks without bypass.'],
|
|
13
|
-
['verify-release-version', 'Check a release tag against package and lockfile versions.'],
|
|
14
|
-
['release', 'Publish a version through a GitHub Actions npm workflow.'],
|
|
15
|
-
['assess-release', 'Assess unpublished changes with Codex and return a JSON recommendation.'],
|
|
16
|
-
['run-tests', 'Run configured tests, reusing a valid test receipt.'],
|
|
17
|
-
['check-test-receipt', 'Check whether a valid test receipt exists.'],
|
|
18
|
-
['record-test-receipt', 'Record a test receipt without running tests.'],
|
|
19
|
-
['checkpoint-codex-changes', 'Commit a linked worktree and push according to project configuration.'],
|
|
20
|
-
['checkpoint-codex-session-start', 'Load checkpoint instructions for a linked Codex worktree.'],
|
|
21
|
-
['checkpoint-codex-stop', 'Handle the Codex Stop hook and request a checkpoint if needed.'],
|
|
22
|
-
['cleanup-ended-session', 'Queue cleanup for a merged Codex session worktree.'],
|
|
23
|
-
['queue-merged-worktree-cleanup', 'Queue cleanup for the current merged worktree.'],
|
|
24
|
-
['cleanup-merged-branches', 'Preview or delete merged worktrees and branches.'],
|
|
25
|
-
['remove-empty-directories', 'Preview or remove directories containing only ignored files.'],
|
|
26
|
-
]);
|
|
7
|
+
const CONFIG_PATH = path.join(__dirname, 'peacekeeper.yaml');
|
|
27
8
|
|
|
28
|
-
function
|
|
29
|
-
const width = Math.max(...[...COMMANDS.keys()].map((command) => command.length));
|
|
30
|
-
const commands = [...COMMANDS]
|
|
31
|
-
.map(([command, description]) => ` ${command.padEnd(width)} ${description}`)
|
|
32
|
-
.join('\n');
|
|
33
|
-
return `Usage: peacekeeper <command> [arguments]\n\nCommands:\n${commands}\n\nOptions:\n -h, --help Show this help.\n`;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function main() {
|
|
37
|
-
const [command, ...args] = process.argv.slice(2);
|
|
38
|
-
if (command === '--help' || command === '-h') {
|
|
39
|
-
process.stdout.write(helpText());
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (!COMMANDS.has(command)) {
|
|
43
|
-
const detail = command ? `Unknown command: ${command}` : 'A command is required.';
|
|
44
|
-
process.stderr.write(`${detail}\n\n${helpText()}`);
|
|
45
|
-
process.exitCode = 2;
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const informational = (args.length === 1 && ['--help', '-h'].includes(args[0]))
|
|
49
|
-
|| (command === 'check-project' && args.length === 1 && args[0] === '--explain');
|
|
50
|
-
const checkpointHook = ['checkpoint-codex-session-start', 'checkpoint-codex-stop'].includes(command);
|
|
51
|
-
if (!['update-config', 'assess-release', 'create-project'].includes(command) && !checkpointHook && !informational) require('../scripts/project-config').projectConfig();
|
|
9
|
+
function runScript(command, args) {
|
|
52
10
|
const script = path.resolve(__dirname, '..', 'scripts', `${command}.js`);
|
|
53
11
|
const result = spawnSync(process.execPath, [script, ...args], {
|
|
54
12
|
cwd: process.cwd(),
|
|
@@ -58,9 +16,53 @@ function main() {
|
|
|
58
16
|
process.exitCode = result.status ?? 1;
|
|
59
17
|
}
|
|
60
18
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
19
|
+
async function main() {
|
|
20
|
+
const rawArgs = process.argv.slice(2);
|
|
21
|
+
const [command, ...args] = rawArgs;
|
|
22
|
+
const script = path.resolve(__dirname, '..', 'scripts', `${command}.js`);
|
|
23
|
+
const informational = args.length === 1 && (
|
|
24
|
+
['--help', '-h'].includes(args[0])
|
|
25
|
+
|| (command === 'check-project' && args[0] === '--explain')
|
|
26
|
+
);
|
|
27
|
+
const checkpointHook = ['checkpoint-codex-session-start', 'checkpoint-codex-stop'].includes(command);
|
|
28
|
+
if (
|
|
29
|
+
fs.existsSync(script)
|
|
30
|
+
&& !['update-config', 'assess-release', 'create-project'].includes(command)
|
|
31
|
+
&& !checkpointHook
|
|
32
|
+
&& !informational
|
|
33
|
+
) require('../scripts/project-config').projectConfig();
|
|
34
|
+
|
|
35
|
+
// assess-release guarantees machine-readable JSON even for invalid arguments.
|
|
36
|
+
// Preserve that application-level error contract instead of letting the CLI parser format it.
|
|
37
|
+
if (command === 'assess-release' && args.length > 0) {
|
|
38
|
+
runScript(command, args);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const dependencyFreeHooks = new Set([
|
|
42
|
+
'checkpoint-codex-session-start',
|
|
43
|
+
'checkpoint-codex-stop',
|
|
44
|
+
'checkpoint-codex-changes',
|
|
45
|
+
'cleanup-ended-session',
|
|
46
|
+
]);
|
|
47
|
+
if (dependencyFreeHooks.has(command) && !informational) {
|
|
48
|
+
runScript(command, args);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const { runCli } = await import('@jakobm/cmdabra');
|
|
53
|
+
const implementation = new Proxy({}, {
|
|
54
|
+
get: (_target, name) => () => runScript(name, args),
|
|
55
|
+
});
|
|
56
|
+
await runCli(CONFIG_PATH, implementation, rawArgs);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
main().catch(async (error) => {
|
|
60
|
+
const { CmdabraUsageError } = await import('@jakobm/cmdabra');
|
|
61
|
+
if (error instanceof CmdabraUsageError) {
|
|
62
|
+
process.stderr.write(`${error.message}\n\n${error.help}`);
|
|
63
|
+
process.exitCode = error.exitCode;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
64
66
|
console.error(`Error: ${error.message}`);
|
|
65
67
|
process.exitCode = 1;
|
|
66
|
-
}
|
|
68
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
name: peacekeeper
|
|
2
|
+
description: Shared repository test, Git worktree, and Codex hook commands
|
|
3
|
+
commands:
|
|
4
|
+
update-config:
|
|
5
|
+
description: Create or complete project configuration using bundled defaults.
|
|
6
|
+
create-project:
|
|
7
|
+
description: Create and verify a compliant TypeScript library in an empty GitHub repository.
|
|
8
|
+
named-options:
|
|
9
|
+
repository:
|
|
10
|
+
description: GitHub HTTPS repository URL.
|
|
11
|
+
required: true
|
|
12
|
+
directory:
|
|
13
|
+
description: Directory in which to create the project.
|
|
14
|
+
required: true
|
|
15
|
+
package-name:
|
|
16
|
+
description: npm package name.
|
|
17
|
+
required: true
|
|
18
|
+
author-name:
|
|
19
|
+
description: Package author name.
|
|
20
|
+
required: true
|
|
21
|
+
author-email:
|
|
22
|
+
description: Package author email address.
|
|
23
|
+
required: true
|
|
24
|
+
publish-to-npm:
|
|
25
|
+
description: Whether the package will be published to npm.
|
|
26
|
+
type: enum
|
|
27
|
+
choices: ["true", "false"]
|
|
28
|
+
required: true
|
|
29
|
+
check-project:
|
|
30
|
+
description: Validate local toolchain, hooks, CI and publication conventions.
|
|
31
|
+
named-options:
|
|
32
|
+
explain:
|
|
33
|
+
description: Print the complete expected project architecture.
|
|
34
|
+
type: boolean
|
|
35
|
+
install-hooks:
|
|
36
|
+
description: Install or update project Codex hooks while preserving other hooks.
|
|
37
|
+
named-options:
|
|
38
|
+
dry-run:
|
|
39
|
+
description: Preview changes without writing hooks.
|
|
40
|
+
type: boolean
|
|
41
|
+
verify-release:
|
|
42
|
+
description: Verify release versions, required CI and strict branch protection.
|
|
43
|
+
verify-release-protection:
|
|
44
|
+
description: Require strict mandatory release checks without bypass.
|
|
45
|
+
verify-release-version:
|
|
46
|
+
description: Check a release tag against package and lockfile versions.
|
|
47
|
+
release:
|
|
48
|
+
description: Publish a version through a GitHub Actions npm workflow.
|
|
49
|
+
positional-arguments:
|
|
50
|
+
bump:
|
|
51
|
+
description: Version increment to publish.
|
|
52
|
+
type: enum
|
|
53
|
+
choices: [major, minor, patch]
|
|
54
|
+
assess-release:
|
|
55
|
+
description: Assess unpublished changes with Codex and return a JSON recommendation.
|
|
56
|
+
run-tests:
|
|
57
|
+
description: Run configured tests, reusing a valid test receipt.
|
|
58
|
+
named-options:
|
|
59
|
+
force:
|
|
60
|
+
description: Run tests even when a valid receipt exists.
|
|
61
|
+
type: boolean
|
|
62
|
+
check-test-receipt:
|
|
63
|
+
description: Check whether a valid test receipt exists.
|
|
64
|
+
record-test-receipt:
|
|
65
|
+
description: Record a test receipt without running tests.
|
|
66
|
+
checkpoint-codex-changes:
|
|
67
|
+
description: Commit a linked worktree and push according to project configuration.
|
|
68
|
+
named-options:
|
|
69
|
+
subject:
|
|
70
|
+
description: Commit subject.
|
|
71
|
+
required: true
|
|
72
|
+
body:
|
|
73
|
+
description: Commit body paragraph; may be repeated.
|
|
74
|
+
required: true
|
|
75
|
+
repeatable: true
|
|
76
|
+
checkpoint-codex-session-start:
|
|
77
|
+
description: Load checkpoint instructions for a linked Codex worktree.
|
|
78
|
+
checkpoint-codex-stop:
|
|
79
|
+
description: Handle the Codex Stop hook and request a checkpoint if needed.
|
|
80
|
+
cleanup-ended-session:
|
|
81
|
+
description: Queue cleanup for a merged Codex session worktree.
|
|
82
|
+
queue-merged-worktree-cleanup:
|
|
83
|
+
description: Queue cleanup for the current merged worktree.
|
|
84
|
+
cleanup-merged-branches:
|
|
85
|
+
description: Preview or delete merged worktrees and branches.
|
|
86
|
+
named-options:
|
|
87
|
+
dry-run:
|
|
88
|
+
description: Preview cleanup without deleting anything.
|
|
89
|
+
type: boolean
|
|
90
|
+
execute:
|
|
91
|
+
description: Delete the displayed worktrees and branches.
|
|
92
|
+
type: boolean
|
|
93
|
+
remove-empty-directories:
|
|
94
|
+
description: Preview or remove directories containing only ignored files.
|
|
95
|
+
named-options:
|
|
96
|
+
dry-run:
|
|
97
|
+
description: Preview cleanup without deleting anything.
|
|
98
|
+
type: boolean
|
|
99
|
+
execute:
|
|
100
|
+
description: Remove the displayed directories.
|
|
101
|
+
type: boolean
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jakobm/peacekeeper",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Shared repository test, Git worktree, and Codex hook commands",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Jakob Mattsson",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@iarna/toml": "^2.2.5",
|
|
33
|
+
"@jakobm/cmdabra": "^0.2.1",
|
|
33
34
|
"semver": "^7.8.5",
|
|
34
35
|
"yaml": "^2.9.1"
|
|
35
36
|
},
|
|
@@ -5,8 +5,8 @@ const { ROOT, environmentFingerprint, receiptPath, snapshot } = require('./recei
|
|
|
5
5
|
const { projectConfig, requireTestCommands } = require('./project-config');
|
|
6
6
|
function successMessage(root = ROOT()) {
|
|
7
7
|
const command = projectConfig(root).tests.npmTestUsesRunner
|
|
8
|
-
? 'npm test --
|
|
9
|
-
: 'node node_modules/@jakobm/peacekeeper/bin/peacekeeper.js run-tests
|
|
8
|
+
? 'npm test -- --force'
|
|
9
|
+
: 'node node_modules/@jakobm/peacekeeper/bin/peacekeeper.js run-tests --force';
|
|
10
10
|
return `Tests already passed for this change set. In order to rerun tests anyway, use: ${command}`;
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -79,16 +79,43 @@ function write(root, name, contents, mode = 0o644) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
function workflow(published) {
|
|
82
|
-
return `name: Test\n\non:\n pull_request:\n branches: [main]\n\npermissions:\n contents: read\n\njobs:\n test:\n runs-on: ubuntu-24.04\n steps:\n - uses: actions/checkout@v7\n - uses: volta-cli/action@v5\n - run: npm ci\n - name: Verify strict release policy\n env:\n GH_TOKEN: \${{ secrets.RELEASE_POLICY_TOKEN }}\n run: peacekeeper verify-release-protection\n - run: npm test\n${published ? `\n package:\n name: Test package\n runs-on: ubuntu-24.04\n steps:\n - uses: actions/checkout@v7\n - uses: volta-cli/action@v5\n - run: npm ci\n - run: npm run test:package\n` : ''}`;
|
|
82
|
+
return `name: Test\n\non:\n pull_request:\n branches: [main]\n\npermissions:\n contents: read\n\njobs:\n test:\n runs-on: ubuntu-24.04\n steps:\n - uses: actions/checkout@v7\n - uses: volta-cli/action@v5\n - run: npm ci\n - name: Verify strict release policy\n env:\n GH_TOKEN: \${{ secrets.RELEASE_POLICY_TOKEN }}\n run: npm exec --no -- peacekeeper verify-release-protection\n - run: npm test\n${published ? `\n package:\n name: Test package\n runs-on: ubuntu-24.04\n steps:\n - uses: actions/checkout@v7\n - uses: volta-cli/action@v5\n - run: npm ci\n - run: npm run test:package\n` : ''}`;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
function publishWorkflow() {
|
|
86
|
-
return `name: Publish\n\non:\n push:\n tags: ['v*']\n\npermissions:\n contents: read\n\njobs:\n publish:\n name: Publish to npm\n runs-on: ubuntu-24.04\n permissions:\n contents: read\n actions: read\n pull-requests: read\n id-token: write\n steps:\n - uses: actions/checkout@v7\n - uses: volta-cli/action@v5\n with:\n registry-url: https://registry.npmjs.org\n - run: npm ci\n - name: Verify release\n env:\n GH_TOKEN: \${{ secrets.RELEASE_POLICY_TOKEN }}\n RELEASE_TAG: \${{ github.ref_name }}\n run: peacekeeper verify-release\n - run: npm publish\n`;
|
|
86
|
+
return `name: Publish\n\non:\n push:\n tags: ['v*']\n\npermissions:\n contents: read\n\njobs:\n publish:\n name: Publish to npm\n runs-on: ubuntu-24.04\n permissions:\n contents: read\n actions: read\n pull-requests: read\n id-token: write\n steps:\n - uses: actions/checkout@v7\n - uses: volta-cli/action@v5\n with:\n registry-url: https://registry.npmjs.org\n - run: npm ci\n - name: Verify release\n env:\n GH_TOKEN: \${{ secrets.RELEASE_POLICY_TOKEN }}\n RELEASE_TAG: \${{ github.ref_name }}\n run: npm exec --no -- peacekeeper verify-release\n - run: npm publish\n`;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
function githubSetup({ owner, repositoryName, published }) {
|
|
90
|
-
const npm = published ? `# -
|
|
91
|
-
|
|
90
|
+
const npm = published ? `# - Publish the package manually once from this directory before configuring npm trusted publishing:
|
|
91
|
+
# npm login
|
|
92
|
+
# npm publish
|
|
93
|
+
# - Configure npm trusted publishing for GitHub repository ${owner}/${repositoryName} and workflow publish.yml.
|
|
94
|
+
` : '';
|
|
95
|
+
return `#!/usr/bin/env bash
|
|
96
|
+
# Manual checklist:
|
|
97
|
+
# - Run this script yourself after the initial project has been pushed.
|
|
98
|
+
# - Authenticate gh with Administration: write access to this repository.
|
|
99
|
+
${npm}set -euo pipefail
|
|
100
|
+
|
|
101
|
+
repo=${owner}/${repositoryName}
|
|
102
|
+
gh auth status
|
|
103
|
+
gh repo view "$repo" >/dev/null
|
|
104
|
+
gh api --method PATCH "repos/$repo" \\
|
|
105
|
+
-F delete_branch_on_merge=true \\
|
|
106
|
+
-F allow_auto_merge=true \\
|
|
107
|
+
-F allow_merge_commit=true \\
|
|
108
|
+
-F allow_squash_merge=false \\
|
|
109
|
+
-F allow_rebase_merge=false >/dev/null
|
|
110
|
+
gh api --method PUT "repos/$repo/branches/main/protection" \\
|
|
111
|
+
-F 'required_status_checks[strict]=true' \\
|
|
112
|
+
-f 'required_status_checks[contexts][]=test' \\
|
|
113
|
+
-F enforce_admins=true \\
|
|
114
|
+
-F 'required_pull_request_reviews[required_approving_review_count]=0' \\
|
|
115
|
+
-F restrictions=null >/dev/null
|
|
116
|
+
groundskeeper secrets sync --name RELEASE_POLICY_TOKEN --new-repo "$repo"
|
|
117
|
+
printf 'GitHub configuration completed for %s.\\n' "$repo"
|
|
118
|
+
`;
|
|
92
119
|
}
|
|
93
120
|
|
|
94
121
|
function packageTest() {
|
package/scripts/run-tests.js
CHANGED
|
@@ -25,9 +25,9 @@ function hasReusableReceipt() {
|
|
|
25
25
|
function main() {
|
|
26
26
|
requireTestCommands();
|
|
27
27
|
const config = projectConfig();
|
|
28
|
-
const force = process.argv.length === 3 && [
|
|
28
|
+
const force = process.argv.length === 3 && process.argv[2] === '--force';
|
|
29
29
|
if (process.argv.length !== 2 && !force) {
|
|
30
|
-
console.error('Usage: node scripts/run-tests.js [
|
|
30
|
+
console.error('Usage: node scripts/run-tests.js [--force]');
|
|
31
31
|
process.exitCode = 2;
|
|
32
32
|
return;
|
|
33
33
|
}
|