@eclipse-docks/cli 0.7.137 → 0.7.140
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 +5 -0
- package/package.json +1 -1
- package/src/commands/release.js +40 -2
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ npx @eclipse-docks/cli release v1.2.3 # explicit version
|
|
|
12
12
|
npx @eclipse-docks/cli release --since v1.2.0 # notes from commits since that tag
|
|
13
13
|
npx @eclipse-docks/cli release --dry-run # print what would be tagged
|
|
14
14
|
npx @eclipse-docks/cli release --no-push # create the tag locally without pushing
|
|
15
|
+
npx @eclipse-docks/cli release --skip-tests # skip the project's release:checks script
|
|
15
16
|
```
|
|
16
17
|
|
|
17
18
|
## `release`
|
|
@@ -27,6 +28,10 @@ If CI fails after the tag was pushed, that workflow deletes the orphan remote ta
|
|
|
27
28
|
GitHub Release history has no gaps. Remove the local tag before retrying:
|
|
28
29
|
`git tag -d vX.Y.Z`.
|
|
29
30
|
|
|
31
|
+
If the project's `package.json` defines a `release:checks` script (e.g. type check and
|
|
32
|
+
tests), it runs before the version is tagged, and a failure aborts the release. Pass
|
|
33
|
+
`--skip-tests` to skip it, e.g. `npm run release -- --skip-tests`.
|
|
34
|
+
|
|
30
35
|
The last version is the most recent `vX.Y.Z` tag reachable from `HEAD` (via
|
|
31
36
|
`git describe`), not the highest semver tag in the repository. That drives the
|
|
32
37
|
default bump and changelog range.
|
package/package.json
CHANGED
package/src/commands/release.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
2
4
|
import { createInterface } from 'node:readline/promises';
|
|
3
5
|
|
|
4
6
|
/** CLI arg / release tag name: exact `vX.Y.Z`. */
|
|
5
7
|
const VERSION_RE = /^v\d+\.\d+\.\d+$/;
|
|
8
|
+
const CHECKS_SCRIPT = 'release:checks';
|
|
6
9
|
|
|
7
10
|
function git(args, cwd) {
|
|
8
11
|
const result = spawnSync('git', args, { cwd, encoding: 'utf8' });
|
|
@@ -18,11 +21,11 @@ function gitOrNull(args, cwd) {
|
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
function usage() {
|
|
21
|
-
return 'Usage: docks release [major|minor|patch|vX.Y.Z] [-m "release notes"] [--since vX.Y.Z] [--dry-run] [--no-push]';
|
|
24
|
+
return 'Usage: docks release [major|minor|patch|vX.Y.Z] [-m "release notes"] [--since vX.Y.Z] [--dry-run] [--no-push] [--skip-tests]';
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
function parseArgs(argv) {
|
|
25
|
-
const opts = { bump: 'patch', version: '', since: '', notes: '', dryRun: false, push: true };
|
|
28
|
+
const opts = { bump: 'patch', version: '', since: '', notes: '', dryRun: false, push: true, skipTests: false };
|
|
26
29
|
|
|
27
30
|
for (let i = 0; i < argv.length; i++) {
|
|
28
31
|
const arg = argv[i];
|
|
@@ -44,6 +47,8 @@ function parseArgs(argv) {
|
|
|
44
47
|
opts.push = true;
|
|
45
48
|
} else if (arg === '--no-push') {
|
|
46
49
|
opts.push = false;
|
|
50
|
+
} else if (arg === '--skip-tests') {
|
|
51
|
+
opts.skipTests = true;
|
|
47
52
|
} else {
|
|
48
53
|
throw new Error(`Unknown argument: ${arg}\n${usage()}`);
|
|
49
54
|
}
|
|
@@ -52,6 +57,37 @@ function parseArgs(argv) {
|
|
|
52
57
|
return opts;
|
|
53
58
|
}
|
|
54
59
|
|
|
60
|
+
function hasChecksScript(cwd) {
|
|
61
|
+
try {
|
|
62
|
+
const pkg = JSON.parse(readFileSync(join(cwd, 'package.json'), 'utf8'));
|
|
63
|
+
return Boolean(pkg.scripts?.[CHECKS_SCRIPT]);
|
|
64
|
+
} catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function runChecks(cwd, { skip, dryRun }) {
|
|
70
|
+
if (!hasChecksScript(cwd)) return;
|
|
71
|
+
if (skip) {
|
|
72
|
+
console.log(`Skipping npm run ${CHECKS_SCRIPT} (--skip-tests).`);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (dryRun) {
|
|
76
|
+
console.log(`[dry run] would run npm run ${CHECKS_SCRIPT}`);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
console.log(`Running npm run ${CHECKS_SCRIPT}...`);
|
|
81
|
+
const result = spawnSync('npm', ['run', CHECKS_SCRIPT], {
|
|
82
|
+
cwd,
|
|
83
|
+
stdio: 'inherit',
|
|
84
|
+
shell: process.platform === 'win32',
|
|
85
|
+
});
|
|
86
|
+
if (result.status !== 0) {
|
|
87
|
+
throw new Error(`npm run ${CHECKS_SCRIPT} failed; fix it or rerun with --skip-tests.`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
55
91
|
function findLastVersion(cwd) {
|
|
56
92
|
const tag = gitOrNull(['describe', '--tags', '--abbrev=0', '--match', 'v*', 'HEAD'], cwd);
|
|
57
93
|
if (!tag) return null;
|
|
@@ -178,6 +214,8 @@ export async function release(argv, cwd = process.cwd()) {
|
|
|
178
214
|
throw new Error('Working tree is not clean. Commit or stash your changes first.');
|
|
179
215
|
}
|
|
180
216
|
|
|
217
|
+
runChecks(cwd, { skip: opts.skipTests, dryRun: opts.dryRun });
|
|
218
|
+
|
|
181
219
|
const last = findLastVersion(cwd);
|
|
182
220
|
let version = opts.version;
|
|
183
221
|
if (!version) {
|