@d-zero/release-automation 0.0.0-stage → 0.0.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/LICENSE +21 -0
- package/README.md +58 -2
- package/dist/classify.js +406 -0
- package/dist/cli.js +126 -0
- package/dist/commands/approve-renovate.js +35 -0
- package/dist/commands/context.js +138 -0
- package/dist/commands/generate.js +97 -0
- package/dist/commands/local.js +125 -0
- package/dist/commands/nightly.js +125 -0
- package/dist/commands/publish.js +247 -0
- package/dist/commands/release-pr.js +297 -0
- package/dist/commands/runs.js +21 -0
- package/dist/commands/verify-release-pr.js +116 -0
- package/dist/conventional-commit.js +35 -0
- package/dist/dist-tag.js +32 -0
- package/dist/guard.js +58 -0
- package/dist/io/exec.js +33 -0
- package/dist/io/git.js +49 -0
- package/dist/io/github.js +87 -0
- package/dist/io/npm.js +25 -0
- package/dist/io/repo.js +163 -0
- package/dist/lines-check.js +147 -0
- package/dist/next-version.js +88 -0
- package/dist/nightly.js +56 -0
- package/dist/pr-checks.js +64 -0
- package/dist/release-content.js +231 -0
- package/dist/release-pr-decision.js +67 -0
- package/dist/retry.js +32 -0
- package/dist/rotation.js +133 -0
- package/dist/semver.js +87 -0
- package/dist/support-end.js +26 -0
- package/dist/types.js +14 -0
- package/package.json +81 -5
package/dist/semver.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { PRERELEASE_IDS } from './types.js';
|
|
2
|
+
const VERSION = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+)(?:\.(0|[1-9]\d*))?)?$/;
|
|
3
|
+
/**
|
|
4
|
+
* Parses a version. Anything outside the shape release lines use (build
|
|
5
|
+
* metadata, unknown prerelease identifiers, a prerelease without a number
|
|
6
|
+
* other than a bare identifier) is rejected, because the dist-tag and the
|
|
7
|
+
* next version cannot be decided for it.
|
|
8
|
+
* @param text - The version, without a leading `v`
|
|
9
|
+
* @returns The parsed version
|
|
10
|
+
* @throws {Error} When the text is not such a version
|
|
11
|
+
* @example
|
|
12
|
+
* parseVersion('2.0.1-alpha.3'); // { major: 2, minor: 0, patch: 1, pre: { id: 'alpha', n: 3 } }
|
|
13
|
+
*/
|
|
14
|
+
export function parseVersion(text) {
|
|
15
|
+
const match = VERSION.exec(text);
|
|
16
|
+
if (!match) {
|
|
17
|
+
throw new Error(`Not a valid version: ${text}`);
|
|
18
|
+
}
|
|
19
|
+
const [, major, minor, patch, id, n] = match;
|
|
20
|
+
if (id === undefined) {
|
|
21
|
+
return {
|
|
22
|
+
major: Number(major),
|
|
23
|
+
minor: Number(minor),
|
|
24
|
+
patch: Number(patch),
|
|
25
|
+
pre: null,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (!PRERELEASE_IDS.includes(id)) {
|
|
29
|
+
throw new Error(`Unknown prerelease identifier "${id}" in ${text}`);
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
major: Number(major),
|
|
33
|
+
minor: Number(minor),
|
|
34
|
+
patch: Number(patch),
|
|
35
|
+
pre: { id: id, n: n === undefined ? 0 : Number(n) },
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Formats a version.
|
|
40
|
+
* @param version - The version
|
|
41
|
+
* @returns `X.Y.Z` or `X.Y.Z-<id>.<n>`
|
|
42
|
+
* @example
|
|
43
|
+
* formatVersion({ major: 1, minor: 0, patch: 0, pre: null }); // '1.0.0'
|
|
44
|
+
*/
|
|
45
|
+
export function formatVersion(version) {
|
|
46
|
+
const core = `${version.major}.${version.minor}.${version.patch}`;
|
|
47
|
+
return version.pre ? `${core}-${version.pre.id}.${version.pre.n}` : core;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Compares two versions by SemVer precedence.
|
|
51
|
+
* @param a - A version
|
|
52
|
+
* @param b - Another version
|
|
53
|
+
* @returns Negative when `a` is lower, positive when higher, `0` when equal
|
|
54
|
+
* @example
|
|
55
|
+
* compareVersions(parseVersion('1.0.0-rc.1'), parseVersion('1.0.0')); // negative
|
|
56
|
+
*/
|
|
57
|
+
export function compareVersions(a, b) {
|
|
58
|
+
const core = a.major - b.major || a.minor - b.minor || a.patch - b.patch;
|
|
59
|
+
if (core !== 0) {
|
|
60
|
+
return core;
|
|
61
|
+
}
|
|
62
|
+
if (a.pre === null || b.pre === null) {
|
|
63
|
+
return (a.pre === null ? 1 : 0) - (b.pre === null ? 1 : 0);
|
|
64
|
+
}
|
|
65
|
+
return (PRERELEASE_IDS.indexOf(a.pre.id) - PRERELEASE_IDS.indexOf(b.pre.id) ||
|
|
66
|
+
a.pre.n - b.pre.n);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Parses a `v<version>` tag of a stable release.
|
|
70
|
+
* @param tag - A tag name
|
|
71
|
+
* @returns The version, or `null` when the tag is not `vX.Y.Z`
|
|
72
|
+
* @example
|
|
73
|
+
* stableTagVersion('v3.5.0'); // { major: 3, minor: 5, patch: 0, pre: null }
|
|
74
|
+
* stableTagVersion('v4.0.0-alpha.1'); // null
|
|
75
|
+
*/
|
|
76
|
+
export function stableTagVersion(tag) {
|
|
77
|
+
const match = /^v(\d+\.\d+\.\d+)$/.exec(tag);
|
|
78
|
+
if (!match?.[1]) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
return parseVersion(match[1]);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds whole months to a date in UTC, clamping to the last day of the target
|
|
3
|
+
* month (2026-01-31 plus one month is 2026-02-28).
|
|
4
|
+
* @param date - The start
|
|
5
|
+
* @param months - Months to add
|
|
6
|
+
* @returns The date `months` later
|
|
7
|
+
* @example
|
|
8
|
+
* addMonths(new Date('2026-01-31T00:00:00Z'), 1).toISOString(); // '2026-02-28T00:00:00.000Z'
|
|
9
|
+
*/
|
|
10
|
+
export function addMonths(date, months) {
|
|
11
|
+
const year = date.getUTCFullYear();
|
|
12
|
+
const month = date.getUTCMonth() + months;
|
|
13
|
+
const lastDay = new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
|
|
14
|
+
return new Date(Date.UTC(year, month, Math.min(date.getUTCDate(), lastDay), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds()));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Formats a date as `YYYY-MM-DD` in UTC, the form `SECURITY.md` states
|
|
18
|
+
* support end dates in.
|
|
19
|
+
* @param date - The date
|
|
20
|
+
* @returns The date part of its ISO string
|
|
21
|
+
* @example
|
|
22
|
+
* formatDate(new Date('2027-03-01T12:00:00Z')); // '2027-03-01'
|
|
23
|
+
*/
|
|
24
|
+
export function formatDate(date) {
|
|
25
|
+
return date.toISOString().slice(0, 10);
|
|
26
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The default of {@link LinesFile.supportMonths}. */
|
|
2
|
+
export const DEFAULT_SUPPORT_MONTHS = 12;
|
|
3
|
+
/** The default of {@link LinesFile.securityBatchMinutes}. */
|
|
4
|
+
export const DEFAULT_SECURITY_BATCH_MINUTES = 60;
|
|
5
|
+
/** The branch the `current` line is published from. */
|
|
6
|
+
export const CURRENT_PUBLISH_BRANCH = 'main';
|
|
7
|
+
/** The branch the `current` line is developed on. */
|
|
8
|
+
export const CURRENT_BRANCH = 'dev';
|
|
9
|
+
/**
|
|
10
|
+
* The prerelease identifiers a version may carry.
|
|
11
|
+
* @example
|
|
12
|
+
* PRERELEASE_IDS.includes('beta'); // true
|
|
13
|
+
*/
|
|
14
|
+
export const PRERELEASE_IDS = ['alpha', 'beta', 'rc'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,82 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@d-zero/release-automation",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Release lines, Release PRs, nightly gates and publishing for D-ZERO repositories",
|
|
5
|
+
"author": "D-ZERO",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/d-zero-dev/release-automation.git"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=24.11.0"
|
|
16
|
+
},
|
|
17
|
+
"type": "module",
|
|
18
|
+
"bin": "dist/cli.js",
|
|
19
|
+
"exports": {
|
|
20
|
+
"./classify": {
|
|
21
|
+
"import": "./dist/classify.js",
|
|
22
|
+
"types": "./dist/classify.d.ts"
|
|
23
|
+
},
|
|
24
|
+
"./dist-tag": {
|
|
25
|
+
"import": "./dist/dist-tag.js",
|
|
26
|
+
"types": "./dist/dist-tag.d.ts"
|
|
27
|
+
},
|
|
28
|
+
"./next-version": {
|
|
29
|
+
"import": "./dist/next-version.js",
|
|
30
|
+
"types": "./dist/next-version.d.ts"
|
|
31
|
+
},
|
|
32
|
+
"./release-pr-decision": {
|
|
33
|
+
"import": "./dist/release-pr-decision.js",
|
|
34
|
+
"types": "./dist/release-pr-decision.d.ts"
|
|
35
|
+
},
|
|
36
|
+
"./types": {
|
|
37
|
+
"import": "./dist/types.js",
|
|
38
|
+
"types": "./dist/types.d.ts"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsc",
|
|
46
|
+
"clean": "tsc --build --clean",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"lint": "run-s lint:oxlint lint:textlint:fix lint:oxfmt lint:textlint:check",
|
|
49
|
+
"lint:check": "run-s lint:oxlint:check lint:oxfmt:check lint:textlint:check",
|
|
50
|
+
"lint:oxlint": "oxlint --type-aware --fix .",
|
|
51
|
+
"lint:oxlint:check": "oxlint --type-aware --deny-warnings .",
|
|
52
|
+
"lint:oxfmt": "oxfmt --write \"{*,**/*}.{md,json,js,cjs,mjs,ts,mts,yml,yaml}\"",
|
|
53
|
+
"lint:oxfmt:check": "oxfmt --check \"{*,**/*}.{md,json,js,cjs,mjs,ts,mts,yml,yaml}\"",
|
|
54
|
+
"lint:textlint:fix": "textlint --fix \"{*,**/*}.md\"",
|
|
55
|
+
"lint:textlint:check": "textlint \"{*,**/*}.md\"",
|
|
56
|
+
"postinstall": "husky"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"yaml": "2.9.1"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@d-zero/commitlint-config": "6.0.0-alpha.3",
|
|
63
|
+
"@d-zero/lint-staged-config": "6.0.0-alpha.3",
|
|
64
|
+
"@d-zero/oxlint-config": "6.0.0-alpha.3",
|
|
65
|
+
"@d-zero/textlint-config": "6.0.0-alpha.3",
|
|
66
|
+
"@d-zero/tsconfig": "2.0.0",
|
|
67
|
+
"@types/node": "26.0.1",
|
|
68
|
+
"husky": "9.1.7",
|
|
69
|
+
"npm-run-all2": "9.0.3",
|
|
70
|
+
"oxfmt": "0.62.0",
|
|
71
|
+
"oxlint": "1.77.0",
|
|
72
|
+
"oxlint-tsgolint": "7.0.2005",
|
|
73
|
+
"textlint": "15.8.0",
|
|
74
|
+
"typescript": "6.0.3",
|
|
75
|
+
"vitest": "4.1.12"
|
|
76
|
+
},
|
|
77
|
+
"packageManager": "yarn@4.18.1",
|
|
78
|
+
"volta": {
|
|
79
|
+
"node": "26.7.0",
|
|
80
|
+
"yarn": "4.18.1"
|
|
81
|
+
}
|
|
82
|
+
}
|