versionary 0.28.0 → 0.28.2
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/action/index.js +7 -9
- package/dist/cli/index.js +32 -34
- package/dist/config/load-config.js +16 -23
- package/dist/config/schema.js +45 -48
- package/dist/git/commits.js +23 -42
- package/dist/git/identity.js +7 -11
- package/dist/git/repo-url.js +3 -6
- package/dist/index.js +6 -16
- package/dist/release/artifact-rules.js +15 -21
- package/dist/release/changelog.js +23 -34
- package/dist/release/plan.js +34 -43
- package/dist/release/pr.js +75 -92
- package/dist/release/recovery.js +9 -12
- package/dist/release/release.js +37 -50
- package/dist/release/semver.js +5 -12
- package/dist/release/state.js +22 -31
- package/dist/release/verify-project.js +14 -20
- package/dist/scm/capabilities.js +2 -6
- package/dist/scm/client.js +3 -6
- package/dist/scm/github-plugin.js +6 -9
- package/dist/scm/types.js +1 -2
- package/dist/strategy/composite.js +1 -4
- package/dist/strategy/latex.js +18 -24
- package/dist/strategy/node.js +13 -19
- package/dist/strategy/package-context.js +8 -15
- package/dist/strategy/python.js +35 -41
- package/dist/strategy/r.js +16 -22
- package/dist/strategy/resolve.js +16 -20
- package/dist/strategy/rust.js +80 -89
- package/dist/strategy/simple.js +8 -14
- package/dist/strategy/types.js +1 -2
- package/dist/types/config.js +1 -2
- package/dist/types/plugins.js +1 -2
- package/package.json +3 -3
package/dist/release/release.js
CHANGED
|
@@ -1,40 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.runSimpleRelease = runSimpleRelease;
|
|
13
|
-
exports.runSimpleReleaseDetailed = runSimpleReleaseDetailed;
|
|
14
|
-
const node_child_process_1 = require("node:child_process");
|
|
15
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
16
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
17
|
-
const load_config_js_1 = require("../config/load-config.js");
|
|
18
|
-
const client_js_1 = require("../scm/client.js");
|
|
19
|
-
const package_context_js_1 = require("../strategy/package-context.js");
|
|
20
|
-
const resolve_js_1 = require("../strategy/resolve.js");
|
|
21
|
-
const plan_js_1 = require("./plan.js");
|
|
22
|
-
const pr_js_1 = require("./pr.js");
|
|
23
|
-
const recovery_js_1 = require("./recovery.js");
|
|
24
|
-
const state_js_1 = require("./state.js");
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { loadConfig } from "../config/load-config.js";
|
|
5
|
+
import { getScmClient } from "../scm/client.js";
|
|
6
|
+
import { resolvePackageStrategyContext, resolveReleaseName, } from "../strategy/package-context.js";
|
|
7
|
+
import { resolveVersionStrategy } from "../strategy/resolve.js";
|
|
8
|
+
import { getChangelogDefaults } from "./plan.js";
|
|
9
|
+
import { isReleaseCommitMessage } from "./pr.js";
|
|
10
|
+
import { executeIdempotentReleaseTarget } from "./recovery.js";
|
|
11
|
+
import { readReleaseTargets } from "./state.js";
|
|
25
12
|
function escapeRegExp(input) {
|
|
26
13
|
return input.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
27
14
|
}
|
|
28
|
-
function resolveTargetPackageName(cwd, config, targetPath) {
|
|
15
|
+
export function resolveTargetPackageName(cwd, config, targetPath) {
|
|
29
16
|
const packageConfig = config.packages?.[targetPath] ?? {};
|
|
30
|
-
const { strategy, config: strategyConfig } =
|
|
31
|
-
const resolved =
|
|
17
|
+
const { strategy, config: strategyConfig } = resolvePackageStrategyContext(config, targetPath, packageConfig);
|
|
18
|
+
const resolved = resolveReleaseName(cwd, targetPath, packageConfig, strategy, strategyConfig);
|
|
32
19
|
if (!resolved || resolved === targetPath) {
|
|
33
20
|
return undefined;
|
|
34
21
|
}
|
|
35
22
|
return resolved;
|
|
36
23
|
}
|
|
37
|
-
function extractReleaseNotes(content, version, changelogFormat) {
|
|
24
|
+
export function extractReleaseNotes(content, version, changelogFormat) {
|
|
38
25
|
const lines = content.split("\n");
|
|
39
26
|
const shortVersion = version.replace(/\.\d+$/u, "");
|
|
40
27
|
const start = changelogFormat === "r-news"
|
|
@@ -72,22 +59,22 @@ function extractReleaseNotes(content, version, changelogFormat) {
|
|
|
72
59
|
.trim();
|
|
73
60
|
}
|
|
74
61
|
function getHeadCommitMessage(cwd) {
|
|
75
|
-
return
|
|
62
|
+
return execFileSync("git", ["log", "-1", "--pretty=%B"], {
|
|
76
63
|
cwd,
|
|
77
64
|
encoding: "utf8",
|
|
78
65
|
stdio: ["ignore", "pipe", "ignore"],
|
|
79
66
|
}).trim();
|
|
80
67
|
}
|
|
81
68
|
function readReleaseNotes(cwd, version, changelogFile, changelogFormat) {
|
|
82
|
-
const changelogPath =
|
|
83
|
-
if (!
|
|
69
|
+
const changelogPath = path.join(cwd, changelogFile);
|
|
70
|
+
if (!fs.existsSync(changelogPath)) {
|
|
84
71
|
return `Automated release for v${version}`;
|
|
85
72
|
}
|
|
86
|
-
const content =
|
|
73
|
+
const content = fs.readFileSync(changelogPath, "utf8");
|
|
87
74
|
const notes = extractReleaseNotes(content, version, changelogFormat);
|
|
88
75
|
return notes.length > 0 ? notes : `Automated release for v${version}`;
|
|
89
76
|
}
|
|
90
|
-
function extractClosingReferencesFromNotes(notes) {
|
|
77
|
+
export function extractClosingReferencesFromNotes(notes) {
|
|
91
78
|
const refs = new Set();
|
|
92
79
|
const linkedPattern = /\b(close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\b\s+\[#(\d+)\]\([^)]+\)/giu;
|
|
93
80
|
for (const match of notes.matchAll(linkedPattern)) {
|
|
@@ -105,30 +92,30 @@ function extractClosingReferencesFromNotes(notes) {
|
|
|
105
92
|
}
|
|
106
93
|
return [...refs].sort((a, b) => a - b);
|
|
107
94
|
}
|
|
108
|
-
function resolveTargetChangelogFile(config, rootChangelogFile, targetPath) {
|
|
95
|
+
export function resolveTargetChangelogFile(config, rootChangelogFile, targetPath) {
|
|
109
96
|
if (targetPath === ".") {
|
|
110
97
|
return rootChangelogFile;
|
|
111
98
|
}
|
|
112
99
|
const packageConfig = config.packages?.[targetPath];
|
|
113
|
-
const packageStrategy =
|
|
100
|
+
const packageStrategy = resolveVersionStrategy({
|
|
114
101
|
...config,
|
|
115
102
|
"release-type": packageConfig?.["release-type"] ?? config["release-type"],
|
|
116
103
|
});
|
|
117
|
-
const { changelogFile: packageChangelogFile } =
|
|
104
|
+
const { changelogFile: packageChangelogFile } = getChangelogDefaults({
|
|
118
105
|
"release-type": packageConfig?.["release-type"] ?? config["release-type"],
|
|
119
106
|
"changelog-file": packageConfig?.["changelog-file"] ?? config["changelog-file"],
|
|
120
107
|
"changelog-format": packageConfig?.["changelog-format"] ?? config["changelog-format"],
|
|
121
108
|
defaultChangelogFormat: packageStrategy.getDefaultChangelogFormat?.(),
|
|
122
109
|
});
|
|
123
|
-
return
|
|
110
|
+
return path.posix.join(targetPath, packageChangelogFile);
|
|
124
111
|
}
|
|
125
112
|
function resolveTargetChangelogFormat(config, targetPath) {
|
|
126
113
|
const packageConfig = config.packages?.[targetPath];
|
|
127
|
-
const packageStrategy =
|
|
114
|
+
const packageStrategy = resolveVersionStrategy({
|
|
128
115
|
...config,
|
|
129
116
|
"release-type": packageConfig?.["release-type"] ?? config["release-type"],
|
|
130
117
|
});
|
|
131
|
-
const { changelogFormat } =
|
|
118
|
+
const { changelogFormat } = getChangelogDefaults({
|
|
132
119
|
"release-type": packageConfig?.["release-type"] ?? config["release-type"],
|
|
133
120
|
"changelog-file": packageConfig?.["changelog-file"] ?? config["changelog-file"],
|
|
134
121
|
"changelog-format": packageConfig?.["changelog-format"] ?? config["changelog-format"],
|
|
@@ -136,31 +123,31 @@ function resolveTargetChangelogFormat(config, targetPath) {
|
|
|
136
123
|
});
|
|
137
124
|
return changelogFormat;
|
|
138
125
|
}
|
|
139
|
-
async function runRelease(cwd = process.cwd()) {
|
|
126
|
+
export async function runRelease(cwd = process.cwd()) {
|
|
140
127
|
const result = await runReleaseDetailed(cwd, { logger: console });
|
|
141
128
|
if (result.action === "release-skipped") {
|
|
142
129
|
return result.reason;
|
|
143
130
|
}
|
|
144
131
|
return result.message;
|
|
145
132
|
}
|
|
146
|
-
async function runReleaseDetailed(cwd = process.cwd(), options = {}) {
|
|
133
|
+
export async function runReleaseDetailed(cwd = process.cwd(), options = {}) {
|
|
147
134
|
const commitMessage = getHeadCommitMessage(cwd);
|
|
148
|
-
if (!
|
|
135
|
+
if (!isReleaseCommitMessage(commitMessage)) {
|
|
149
136
|
return {
|
|
150
137
|
action: "release-skipped",
|
|
151
138
|
reason: "No release commit context detected; skipping release stage.",
|
|
152
139
|
};
|
|
153
140
|
}
|
|
154
|
-
const loaded =
|
|
155
|
-
const strategy =
|
|
156
|
-
const { changelogFile } =
|
|
141
|
+
const loaded = loadConfig(cwd);
|
|
142
|
+
const strategy = resolveVersionStrategy(loaded.config);
|
|
143
|
+
const { changelogFile } = getChangelogDefaults({
|
|
157
144
|
...loaded.config,
|
|
158
145
|
defaultChangelogFormat: strategy.getDefaultChangelogFormat?.(),
|
|
159
146
|
});
|
|
160
147
|
const referenceCommentMode = loaded.config["release-reference-comments"] ?? "off";
|
|
161
148
|
const version = strategy.readVersion(cwd, loaded.config);
|
|
162
149
|
const defaultTag = `v${version}`;
|
|
163
|
-
const releaseTargets =
|
|
150
|
+
const releaseTargets = readReleaseTargets(cwd);
|
|
164
151
|
const targets = releaseTargets.length > 0
|
|
165
152
|
? releaseTargets
|
|
166
153
|
: [
|
|
@@ -181,7 +168,7 @@ async function runReleaseDetailed(cwd = process.cwd(), options = {}) {
|
|
|
181
168
|
message: `Dry run: would publish releases ${targetList.join(", ")}`,
|
|
182
169
|
};
|
|
183
170
|
}
|
|
184
|
-
const scmClient =
|
|
171
|
+
const scmClient = getScmClient();
|
|
185
172
|
const releases = [];
|
|
186
173
|
const referenceReleases = [];
|
|
187
174
|
for (const target of targets) {
|
|
@@ -189,7 +176,7 @@ async function runReleaseDetailed(cwd = process.cwd(), options = {}) {
|
|
|
189
176
|
const targetChangelogFormat = resolveTargetChangelogFormat(loaded.config, target.path);
|
|
190
177
|
const releaseNotes = readReleaseNotes(cwd, target.version, targetChangelogFile, targetChangelogFormat);
|
|
191
178
|
const references = extractClosingReferencesFromNotes(releaseNotes);
|
|
192
|
-
const outcome = await
|
|
179
|
+
const outcome = await executeIdempotentReleaseTarget(cwd, {
|
|
193
180
|
tag: target.tag,
|
|
194
181
|
version: target.version,
|
|
195
182
|
notes: releaseNotes,
|
|
@@ -237,10 +224,10 @@ async function runReleaseDetailed(cwd = process.cwd(), options = {}) {
|
|
|
237
224
|
};
|
|
238
225
|
}
|
|
239
226
|
/** @deprecated Use runRelease. */
|
|
240
|
-
async function runSimpleRelease(cwd = process.cwd()) {
|
|
227
|
+
export async function runSimpleRelease(cwd = process.cwd()) {
|
|
241
228
|
return runRelease(cwd);
|
|
242
229
|
}
|
|
243
230
|
/** @deprecated Use runReleaseDetailed. */
|
|
244
|
-
async function runSimpleReleaseDetailed(cwd = process.cwd(), options = {}) {
|
|
231
|
+
export async function runSimpleReleaseDetailed(cwd = process.cwd(), options = {}) {
|
|
245
232
|
return runReleaseDetailed(cwd, options);
|
|
246
233
|
}
|
package/dist/release/semver.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.maxReleaseType = maxReleaseType;
|
|
4
|
-
exports.parseVersion = parseVersion;
|
|
5
|
-
exports.isValidVersion = isValidVersion;
|
|
6
|
-
exports.compareVersions = compareVersions;
|
|
7
|
-
exports.bumpVersion = bumpVersion;
|
|
8
|
-
function maxReleaseType(types) {
|
|
1
|
+
export function maxReleaseType(types) {
|
|
9
2
|
if (types.includes("major")) {
|
|
10
3
|
return "major";
|
|
11
4
|
}
|
|
@@ -28,7 +21,7 @@ function normalizeVersionInput(version) {
|
|
|
28
21
|
const [, major, minor, patch, prerelease] = compatMatch;
|
|
29
22
|
return `${major}.${minor}.${patch}-${prerelease}`;
|
|
30
23
|
}
|
|
31
|
-
function parseVersion(version) {
|
|
24
|
+
export function parseVersion(version) {
|
|
32
25
|
const normalized = normalizeVersionInput(version);
|
|
33
26
|
const match = normalized.match(SEMVER_PATTERN);
|
|
34
27
|
if (!match) {
|
|
@@ -42,7 +35,7 @@ function parseVersion(version) {
|
|
|
42
35
|
build: match[5] ? match[5].split(".") : [],
|
|
43
36
|
};
|
|
44
37
|
}
|
|
45
|
-
function isValidVersion(version) {
|
|
38
|
+
export function isValidVersion(version) {
|
|
46
39
|
return SEMVER_PATTERN.test(normalizeVersionInput(version));
|
|
47
40
|
}
|
|
48
41
|
function isNumericIdentifier(identifier) {
|
|
@@ -76,7 +69,7 @@ function comparePreReleaseIdentifiers(left, right) {
|
|
|
76
69
|
}
|
|
77
70
|
return 0;
|
|
78
71
|
}
|
|
79
|
-
function compareVersions(leftRaw, rightRaw) {
|
|
72
|
+
export function compareVersions(leftRaw, rightRaw) {
|
|
80
73
|
const left = parseVersion(leftRaw);
|
|
81
74
|
const right = parseVersion(rightRaw);
|
|
82
75
|
if (left.major !== right.major) {
|
|
@@ -116,7 +109,7 @@ function compareVersions(leftRaw, rightRaw) {
|
|
|
116
109
|
}
|
|
117
110
|
return 0;
|
|
118
111
|
}
|
|
119
|
-
function bumpVersion(current, releaseType, options = {}) {
|
|
112
|
+
export function bumpVersion(current, releaseType, options = {}) {
|
|
120
113
|
const parsed = parseVersion(current);
|
|
121
114
|
const allowStableMajor = options.allowStableMajor ?? false;
|
|
122
115
|
if (releaseType === "major") {
|
package/dist/release/state.js
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getBaselineStatePath = getBaselineStatePath;
|
|
7
|
-
exports.readBaselineSha = readBaselineSha;
|
|
8
|
-
exports.readReleaseTargets = readReleaseTargets;
|
|
9
|
-
exports.writeBaselineSha = writeBaselineSha;
|
|
10
|
-
const node_child_process_1 = require("node:child_process");
|
|
11
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
12
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
-
const load_config_js_1 = require("../config/load-config.js");
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { loadConfig } from "../config/load-config.js";
|
|
14
5
|
const MANIFEST_VERSION_KEY = "manifest-version";
|
|
15
6
|
const BASELINE_SHA_KEY = "baseline-sha";
|
|
16
7
|
const RELEASE_TARGETS_KEY = "release-targets";
|
|
@@ -47,48 +38,48 @@ function parseStateFile(raw, filePath) {
|
|
|
47
38
|
}
|
|
48
39
|
return manifest;
|
|
49
40
|
}
|
|
50
|
-
function getBaselineStatePath(cwd) {
|
|
51
|
-
const loaded =
|
|
41
|
+
export function getBaselineStatePath(cwd) {
|
|
42
|
+
const loaded = loadConfig(cwd);
|
|
52
43
|
const configured = loaded.config["baseline-file"];
|
|
53
44
|
if (configured) {
|
|
54
|
-
return
|
|
45
|
+
return path.join(cwd, configured);
|
|
55
46
|
}
|
|
56
|
-
const preferred =
|
|
57
|
-
if (
|
|
47
|
+
const preferred = path.join(cwd, ".versionary-manifest.json");
|
|
48
|
+
if (fs.existsSync(preferred)) {
|
|
58
49
|
return preferred;
|
|
59
50
|
}
|
|
60
|
-
const legacy =
|
|
61
|
-
if (
|
|
51
|
+
const legacy = path.join(cwd, "versionary.versions.json");
|
|
52
|
+
if (fs.existsSync(legacy)) {
|
|
62
53
|
return legacy;
|
|
63
54
|
}
|
|
64
55
|
return preferred;
|
|
65
56
|
}
|
|
66
|
-
function readBaselineSha(cwd = process.cwd()) {
|
|
57
|
+
export function readBaselineSha(cwd = process.cwd()) {
|
|
67
58
|
const filePath = getBaselineStatePath(cwd);
|
|
68
|
-
if (!
|
|
59
|
+
if (!fs.existsSync(filePath)) {
|
|
69
60
|
return null;
|
|
70
61
|
}
|
|
71
|
-
const parsed = parseStateFile(
|
|
62
|
+
const parsed = parseStateFile(fs.readFileSync(filePath, "utf8"), filePath);
|
|
72
63
|
return parsed[BASELINE_SHA_KEY] ?? null;
|
|
73
64
|
}
|
|
74
|
-
function readReleaseTargets(cwd = process.cwd()) {
|
|
65
|
+
export function readReleaseTargets(cwd = process.cwd()) {
|
|
75
66
|
const filePath = getBaselineStatePath(cwd);
|
|
76
|
-
if (!
|
|
67
|
+
if (!fs.existsSync(filePath)) {
|
|
77
68
|
return [];
|
|
78
69
|
}
|
|
79
|
-
const parsed = parseStateFile(
|
|
70
|
+
const parsed = parseStateFile(fs.readFileSync(filePath, "utf8"), filePath);
|
|
80
71
|
return parsed[RELEASE_TARGETS_KEY] ?? [];
|
|
81
72
|
}
|
|
82
|
-
function writeBaselineSha(cwd = process.cwd(), sha, releaseTargets) {
|
|
73
|
+
export function writeBaselineSha(cwd = process.cwd(), sha, releaseTargets) {
|
|
83
74
|
const baselineShaValue = sha ??
|
|
84
|
-
|
|
75
|
+
execFileSync("git", ["rev-parse", "HEAD"], {
|
|
85
76
|
cwd,
|
|
86
77
|
encoding: "utf8",
|
|
87
78
|
stdio: ["ignore", "pipe", "ignore"],
|
|
88
79
|
}).trim();
|
|
89
80
|
const filePath = getBaselineStatePath(cwd);
|
|
90
|
-
const existing =
|
|
91
|
-
? parseStateFile(
|
|
81
|
+
const existing = fs.existsSync(filePath)
|
|
82
|
+
? parseStateFile(fs.readFileSync(filePath, "utf8"), filePath)
|
|
92
83
|
: {};
|
|
93
84
|
const existingTargets = existing[RELEASE_TARGETS_KEY] ?? [];
|
|
94
85
|
const nextTargets = releaseTargets === undefined
|
|
@@ -104,5 +95,5 @@ function writeBaselineSha(cwd = process.cwd(), sha, releaseTargets) {
|
|
|
104
95
|
[BASELINE_SHA_KEY]: baselineShaValue,
|
|
105
96
|
[RELEASE_TARGETS_KEY]: nextTargets,
|
|
106
97
|
};
|
|
107
|
-
|
|
98
|
+
fs.writeFileSync(filePath, `${JSON.stringify(next, null, 2)}\n`, "utf8");
|
|
108
99
|
}
|
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
const load_config_js_1 = require("../config/load-config.js");
|
|
10
|
-
const package_context_js_1 = require("../strategy/package-context.js");
|
|
11
|
-
const resolve_js_1 = require("../strategy/resolve.js");
|
|
12
|
-
function verifyProject(cwd = process.cwd()) {
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { loadConfig } from "../config/load-config.js";
|
|
4
|
+
import { resolvePackageStrategyContext } from "../strategy/package-context.js";
|
|
5
|
+
import { resolveVersionStrategy } from "../strategy/resolve.js";
|
|
6
|
+
export function verifyProject(cwd = process.cwd()) {
|
|
13
7
|
const checks = [];
|
|
14
|
-
const config =
|
|
8
|
+
const config = loadConfig(cwd);
|
|
15
9
|
checks.push({
|
|
16
10
|
name: "config-load",
|
|
17
11
|
ok: true,
|
|
18
|
-
details: `Loaded ${
|
|
12
|
+
details: `Loaded ${path.basename(config.path)} (${config.format})`,
|
|
19
13
|
category: "config",
|
|
20
14
|
});
|
|
21
|
-
const strategy =
|
|
15
|
+
const strategy = resolveVersionStrategy(config.config);
|
|
22
16
|
const versionFile = strategy.getVersionFile(config.config);
|
|
23
|
-
const exists =
|
|
17
|
+
const exists = fs.existsSync(path.join(cwd, versionFile));
|
|
24
18
|
checks.push({
|
|
25
19
|
name: `version-file:${versionFile}`,
|
|
26
20
|
ok: exists,
|
|
@@ -44,8 +38,8 @@ function verifyProject(cwd = process.cwd()) {
|
|
|
44
38
|
}
|
|
45
39
|
if (config.config.packages) {
|
|
46
40
|
for (const [pkgPathRaw, packageConfig] of Object.entries(config.config.packages)) {
|
|
47
|
-
const pkgPath =
|
|
48
|
-
const exists =
|
|
41
|
+
const pkgPath = path.join(cwd, pkgPathRaw);
|
|
42
|
+
const exists = fs.existsSync(pkgPath);
|
|
49
43
|
checks.push({
|
|
50
44
|
name: `package-path:${pkgPathRaw}`,
|
|
51
45
|
ok: exists,
|
|
@@ -56,9 +50,9 @@ function verifyProject(cwd = process.cwd()) {
|
|
|
56
50
|
: `Create ${pkgPathRaw} or remove/rename this entry under "packages" in versionary config.`,
|
|
57
51
|
});
|
|
58
52
|
if (exists) {
|
|
59
|
-
const packageContext =
|
|
53
|
+
const packageContext = resolvePackageStrategyContext(config.config, pkgPathRaw, packageConfig);
|
|
60
54
|
const packageVersionFile = packageContext.versionFile;
|
|
61
|
-
const packageVersionExists =
|
|
55
|
+
const packageVersionExists = fs.existsSync(path.join(cwd, packageVersionFile));
|
|
62
56
|
checks.push({
|
|
63
57
|
name: `version-file:${packageVersionFile}`,
|
|
64
58
|
ok: packageVersionExists,
|
package/dist/scm/capabilities.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pluginHasCapability = pluginHasCapability;
|
|
4
|
-
exports.findPluginsByCapability = findPluginsByCapability;
|
|
5
|
-
function pluginHasCapability(plugin, capability) {
|
|
1
|
+
export function pluginHasCapability(plugin, capability) {
|
|
6
2
|
return plugin.capabilities.includes(capability);
|
|
7
3
|
}
|
|
8
|
-
function findPluginsByCapability(plugins, capability) {
|
|
4
|
+
export function findPluginsByCapability(plugins, capability) {
|
|
9
5
|
return plugins.filter((plugin) => pluginHasCapability(plugin, capability));
|
|
10
6
|
}
|
package/dist/scm/client.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const github_plugin_js_1 = require("./github-plugin.js");
|
|
5
|
-
function getScmClient() {
|
|
6
|
-
return (0, github_plugin_js_1.createGitHubPlugin)();
|
|
1
|
+
import { createGitHubPlugin } from "./github-plugin.js";
|
|
2
|
+
export function getScmClient() {
|
|
3
|
+
return createGitHubPlugin();
|
|
7
4
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createGitHubPlugin = createGitHubPlugin;
|
|
4
|
-
const rest_1 = require("@octokit/rest");
|
|
1
|
+
import { Octokit } from "@octokit/rest";
|
|
5
2
|
function parseRepoSlug(input) {
|
|
6
3
|
const [owner, repo] = input.split("/");
|
|
7
4
|
if (!owner || !repo) {
|
|
@@ -122,7 +119,7 @@ function renderReleaseReferenceCommentBody(releases) {
|
|
|
122
119
|
.join("\n");
|
|
123
120
|
return `This is included in the following releases: :tada:\n\n${bullets}\n\n${footer}`;
|
|
124
121
|
}
|
|
125
|
-
function createGitHubPlugin() {
|
|
122
|
+
export function createGitHubPlugin() {
|
|
126
123
|
return {
|
|
127
124
|
name: "github",
|
|
128
125
|
capabilities: [
|
|
@@ -133,7 +130,7 @@ function createGitHubPlugin() {
|
|
|
133
130
|
provider: "github",
|
|
134
131
|
async createOrUpdateReviewRequest(input, _context) {
|
|
135
132
|
const repo = getRepoFromEnv();
|
|
136
|
-
const octokit = new
|
|
133
|
+
const octokit = new Octokit({ auth: getGitHubToken() });
|
|
137
134
|
const listHead = resolveHeadForList(repo, input.headBranch);
|
|
138
135
|
let existing;
|
|
139
136
|
try {
|
|
@@ -212,7 +209,7 @@ function createGitHubPlugin() {
|
|
|
212
209
|
},
|
|
213
210
|
async closeReviewRequestIfExists(input, _context) {
|
|
214
211
|
const repo = getRepoFromEnv();
|
|
215
|
-
const octokit = new
|
|
212
|
+
const octokit = new Octokit({ auth: getGitHubToken() });
|
|
216
213
|
const listHead = resolveHeadForList(repo, input.headBranch);
|
|
217
214
|
let existing;
|
|
218
215
|
try {
|
|
@@ -274,7 +271,7 @@ function createGitHubPlugin() {
|
|
|
274
271
|
},
|
|
275
272
|
async createReleaseMetadata(input, _context) {
|
|
276
273
|
const repo = getRepoFromEnv();
|
|
277
|
-
const octokit = new
|
|
274
|
+
const octokit = new Octokit({ auth: getGitHubToken() });
|
|
278
275
|
try {
|
|
279
276
|
const existing = await octokit.repos.getReleaseByTag({
|
|
280
277
|
owner: repo.owner,
|
|
@@ -310,7 +307,7 @@ function createGitHubPlugin() {
|
|
|
310
307
|
},
|
|
311
308
|
async createReleaseReferenceComments(input, context) {
|
|
312
309
|
const repo = getRepoFromEnv();
|
|
313
|
-
const octokit = new
|
|
310
|
+
const octokit = new Octokit({ auth: getGitHubToken() });
|
|
314
311
|
const mode = input.mode ?? "best-effort";
|
|
315
312
|
const releasesByIssue = groupReleasesByIssue(input.releases);
|
|
316
313
|
const commented = [];
|
package/dist/scm/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.compositeVersionStrategy = compositeVersionStrategy;
|
|
4
1
|
function configForSecondary(config) {
|
|
5
2
|
if (config["version-file"] === undefined) {
|
|
6
3
|
return config;
|
|
@@ -11,7 +8,7 @@ function configForSecondary(config) {
|
|
|
11
8
|
function dedupedSorted(values) {
|
|
12
9
|
return [...new Set(values)].sort((a, b) => a.localeCompare(b));
|
|
13
10
|
}
|
|
14
|
-
function compositeVersionStrategy(strategies) {
|
|
11
|
+
export function compositeVersionStrategy(strategies) {
|
|
15
12
|
if (strategies.length === 0) {
|
|
16
13
|
throw new Error("compositeVersionStrategy requires at least one strategy.");
|
|
17
14
|
}
|
package/dist/strategy/latex.js
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.latexVersionStrategy = void 0;
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
9
3
|
const BUILD_LUA_VERSION_PATTERN = /^(\s*version\s*=\s*")([^"]+)(")/mu;
|
|
10
4
|
const PROVIDES_PACKAGE_PATTERN = /\\ProvidesPackage\{([^}]+)\}\[\d{4}-\d{2}-\d{2} v([0-9]+\.[0-9]+\.[0-9]+) ([^\]]+)\]/gu;
|
|
11
5
|
const PROVIDES_EXPL_PACKAGE_PATTERN = /\\ProvidesExplPackage\{([^}]+)\}\{\d{4}-\d{2}-\d{2}\}\{[^}]+\}\{([^}]*)\}/gu;
|
|
12
6
|
function normalizeRelative(base, target) {
|
|
13
|
-
return
|
|
7
|
+
return path.relative(base, target).replaceAll("\\", "/");
|
|
14
8
|
}
|
|
15
9
|
function collectDtxFiles(dir) {
|
|
16
|
-
if (!
|
|
10
|
+
if (!fs.existsSync(dir)) {
|
|
17
11
|
return [];
|
|
18
12
|
}
|
|
19
|
-
const entries =
|
|
13
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
20
14
|
const files = [];
|
|
21
15
|
for (const entry of entries) {
|
|
22
|
-
const target =
|
|
16
|
+
const target = path.join(dir, entry.name);
|
|
23
17
|
if (entry.isDirectory()) {
|
|
24
18
|
files.push(...collectDtxFiles(target));
|
|
25
19
|
continue;
|
|
@@ -51,18 +45,18 @@ function replaceProvidesPackageMetadata(content, version, releaseDate, relativeP
|
|
|
51
45
|
}
|
|
52
46
|
return content.replace(PROVIDES_PACKAGE_PATTERN, (_full, pkg, _prevVersion, desc) => `\\ProvidesPackage{${pkg}}[${releaseDate} v${version} ${desc}]`);
|
|
53
47
|
}
|
|
54
|
-
|
|
48
|
+
export const latexVersionStrategy = {
|
|
55
49
|
name: "latex",
|
|
56
50
|
getVersionFile(config) {
|
|
57
51
|
return config["version-file"] ?? "build.lua";
|
|
58
52
|
},
|
|
59
53
|
readVersion(cwd, config) {
|
|
60
54
|
const versionFile = this.getVersionFile(config);
|
|
61
|
-
const versionPath =
|
|
62
|
-
if (!
|
|
55
|
+
const versionPath = path.join(cwd, versionFile);
|
|
56
|
+
if (!fs.existsSync(versionPath)) {
|
|
63
57
|
throw new Error(`Versionary requires ${versionFile} to exist.`);
|
|
64
58
|
}
|
|
65
|
-
const content =
|
|
59
|
+
const content = fs.readFileSync(versionPath, "utf8");
|
|
66
60
|
const match = content.match(BUILD_LUA_VERSION_PATTERN);
|
|
67
61
|
if (!match?.[2]) {
|
|
68
62
|
throw new Error(`${versionFile} is missing a valid version field required by release-type "latex".`);
|
|
@@ -71,31 +65,31 @@ exports.latexVersionStrategy = {
|
|
|
71
65
|
},
|
|
72
66
|
writeVersion(cwd, config, version) {
|
|
73
67
|
const versionFile = this.getVersionFile(config);
|
|
74
|
-
const versionPath =
|
|
75
|
-
if (!
|
|
68
|
+
const versionPath = path.join(cwd, versionFile);
|
|
69
|
+
if (!fs.existsSync(versionPath)) {
|
|
76
70
|
throw new Error(`Versionary requires ${versionFile} to exist.`);
|
|
77
71
|
}
|
|
78
|
-
const next = replaceBuildLuaVersion(
|
|
79
|
-
|
|
72
|
+
const next = replaceBuildLuaVersion(fs.readFileSync(versionPath, "utf8"), version, versionFile);
|
|
73
|
+
fs.writeFileSync(versionPath, next, "utf8");
|
|
80
74
|
return [versionFile];
|
|
81
75
|
},
|
|
82
76
|
finalizeVersionWrites(cwd, writes, context) {
|
|
83
77
|
const updated = new Set();
|
|
84
78
|
for (const write of writes) {
|
|
85
|
-
const packageRoot = write.packagePath === "." ? cwd :
|
|
86
|
-
const srcDir =
|
|
79
|
+
const packageRoot = write.packagePath === "." ? cwd : path.join(cwd, write.packagePath);
|
|
80
|
+
const srcDir = path.join(packageRoot, "src");
|
|
87
81
|
const dtxFiles = collectDtxFiles(srcDir);
|
|
88
82
|
if (dtxFiles.length === 0) {
|
|
89
83
|
throw new Error(`release-type "latex" requires at least one .dtx file under ${normalizeRelative(cwd, srcDir)}.`);
|
|
90
84
|
}
|
|
91
85
|
for (const dtxPath of dtxFiles) {
|
|
92
86
|
const relativePath = normalizeRelative(cwd, dtxPath);
|
|
93
|
-
const existing =
|
|
87
|
+
const existing = fs.readFileSync(dtxPath, "utf8");
|
|
94
88
|
const next = replaceProvidesPackageMetadata(existing, write.version, context.releaseDate, relativePath);
|
|
95
89
|
if (next === existing) {
|
|
96
90
|
continue;
|
|
97
91
|
}
|
|
98
|
-
|
|
92
|
+
fs.writeFileSync(dtxPath, next, "utf8");
|
|
99
93
|
updated.add(relativePath);
|
|
100
94
|
}
|
|
101
95
|
}
|