tegami 1.1.3 → 1.2.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/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/generators/simple.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{npm-CaBYeOeV.js → npm-DaUHTtlV.js} +6 -172
- package/dist/plugins/cargo.d.ts +1 -1
- package/dist/plugins/git.d.ts +1 -1
- package/dist/plugins/github.d.ts +3 -47
- package/dist/plugins/github.js +12 -29
- package/dist/plugins/gitlab.d.ts +3 -47
- package/dist/plugins/gitlab.js +19 -32
- package/dist/plugins/go.d.ts +1 -1
- package/dist/providers/npm.d.ts +1 -1
- package/dist/providers/npm.js +1 -1
- package/dist/{draft-CzUiQasJ.js → publish-v30y8Lwq.js} +188 -6
- package/dist/{types-DEyZ2r-2.d.ts → types-BbwOrNZ2.d.ts} +8 -3
- package/dist/version-request-C24d9RIW.d.ts +39 -0
- package/dist/version-request-l6IJdFM6.js +419 -0
- package/package.json +1 -1
- package/dist/version-request-DlLpLLK3.js +0 -445
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import { r as formatNpmDistTag } from "./semver-EKJ8yK5U.js";
|
|
2
|
+
import { n as execFailure, o as isCI } from "./error-BhMYq9iW.js";
|
|
3
|
+
import { t as _accessExpressionAsString } from "./_accessExpressionAsString-QhbUZzwv.js";
|
|
4
|
+
import { n as _validateReport, t as _createStandardSchema } from "./_createStandardSchema-BGQyz-uA.js";
|
|
5
|
+
import { o as PublishLock, r as runPreflights, s as parsePublishLock, t as initPublishPlan } from "./publish-v30y8Lwq.js";
|
|
6
|
+
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
7
|
+
import { join, relative } from "node:path";
|
|
8
|
+
import { x } from "tinyexec";
|
|
9
|
+
import { tmpdir } from "node:os";
|
|
10
|
+
//#region src/utils/version-request.ts
|
|
11
|
+
const validatePublishGroupStore = (() => {
|
|
12
|
+
const _io0 = (input) => "object" === typeof input.groups && null !== input.groups && false === Array.isArray(input.groups) && _io1(input.groups);
|
|
13
|
+
const _io1 = (input) => Object.keys(input).every((key) => {
|
|
14
|
+
const value = input[key];
|
|
15
|
+
if (void 0 === value) return true;
|
|
16
|
+
return "pending" === value || "active" === value;
|
|
17
|
+
});
|
|
18
|
+
const _vo0 = (input, _path, _exceptionable = true) => [("object" === typeof input.groups && null !== input.groups && false === Array.isArray(input.groups) || _report(_exceptionable, {
|
|
19
|
+
path: _path + ".groups",
|
|
20
|
+
expected: "Record<string, \"pending\" | \"active\">",
|
|
21
|
+
value: input.groups
|
|
22
|
+
})) && _vo1(input.groups, _path + ".groups", _exceptionable) || _report(_exceptionable, {
|
|
23
|
+
path: _path + ".groups",
|
|
24
|
+
expected: "Record<string, \"pending\" | \"active\">",
|
|
25
|
+
value: input.groups
|
|
26
|
+
})].every((flag) => flag);
|
|
27
|
+
const _vo1 = (input, _path, _exceptionable = true) => [false === _exceptionable || Object.keys(input).map((key) => {
|
|
28
|
+
const value = input[key];
|
|
29
|
+
if (void 0 === value) return true;
|
|
30
|
+
return "pending" === value || "active" === value || _report(_exceptionable, {
|
|
31
|
+
path: _path + _accessExpressionAsString(key),
|
|
32
|
+
expected: "(\"active\" | \"pending\")",
|
|
33
|
+
value
|
|
34
|
+
});
|
|
35
|
+
}).every((flag) => flag)].every((flag) => flag);
|
|
36
|
+
const __is = (input) => "object" === typeof input && null !== input && _io0(input);
|
|
37
|
+
let errors;
|
|
38
|
+
let _report;
|
|
39
|
+
return _createStandardSchema((input) => {
|
|
40
|
+
if (false === __is(input)) {
|
|
41
|
+
errors = [];
|
|
42
|
+
_report = _validateReport(errors);
|
|
43
|
+
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
|
|
44
|
+
path: _path + "",
|
|
45
|
+
expected: "PublishGroupStore",
|
|
46
|
+
value: input
|
|
47
|
+
})) && _vo0(input, _path + "", true) || _report(true, {
|
|
48
|
+
path: _path + "",
|
|
49
|
+
expected: "PublishGroupStore",
|
|
50
|
+
value: input
|
|
51
|
+
}))(input, "$input", true);
|
|
52
|
+
const success = 0 === errors.length;
|
|
53
|
+
return success ? {
|
|
54
|
+
success,
|
|
55
|
+
data: input
|
|
56
|
+
} : {
|
|
57
|
+
success,
|
|
58
|
+
errors,
|
|
59
|
+
data: input
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
success: true,
|
|
64
|
+
data: input
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
})();
|
|
68
|
+
function onVersionRequest(provider) {
|
|
69
|
+
const namespace = `${provider.name}:publish-group`;
|
|
70
|
+
/** package id -> version before applying the CLI draft */
|
|
71
|
+
const snapshots = /* @__PURE__ */ new Map();
|
|
72
|
+
function resolveConfig(graph) {
|
|
73
|
+
if (provider.options === false) return;
|
|
74
|
+
const { forceCreate = false, branch = "tegami/version-packages", base = "main", groups, create } = provider.options ?? {};
|
|
75
|
+
const groupMap = /* @__PURE__ */ new Map();
|
|
76
|
+
if (groups?.length) {
|
|
77
|
+
const unlistedPackages = /* @__PURE__ */ new Set();
|
|
78
|
+
for (const pkg of graph.getPackages()) unlistedPackages.add(pkg.id);
|
|
79
|
+
for (let group of groups ?? []) {
|
|
80
|
+
if (!Array.isArray(group)) group = [group];
|
|
81
|
+
let id = publishGroupId(group);
|
|
82
|
+
if (id === "unlisted") id = "custom-unlisted";
|
|
83
|
+
groupMap.set(id, group);
|
|
84
|
+
for (const member of group) for (const pkg of graph.getByName(member)) unlistedPackages.delete(pkg.id);
|
|
85
|
+
}
|
|
86
|
+
if (unlistedPackages.size > 0) groupMap.set("unlisted", Array.from(unlistedPackages));
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
forceCreate,
|
|
90
|
+
branch,
|
|
91
|
+
base,
|
|
92
|
+
groupMap,
|
|
93
|
+
create
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Commit the group's lock state on top of `parent` and force-push its branch.
|
|
98
|
+
*
|
|
99
|
+
* Returns `true` and skips the push when the branch on `remote` already matches.
|
|
100
|
+
*/
|
|
101
|
+
async function syncGroupBranch(context, baseLock, opts) {
|
|
102
|
+
const lock = new PublishLock(baseLock);
|
|
103
|
+
while (lock.read(namespace));
|
|
104
|
+
lock.write(namespace, opts.store);
|
|
105
|
+
const commit = await createLockCommit(context, {
|
|
106
|
+
parent: opts.parent,
|
|
107
|
+
content: lock.serialize(),
|
|
108
|
+
message: "Update Lock"
|
|
109
|
+
});
|
|
110
|
+
if (opts.remote?.get(opts.branch) === commit) return true;
|
|
111
|
+
await run(context.cwd, [
|
|
112
|
+
"push",
|
|
113
|
+
"--force",
|
|
114
|
+
"origin",
|
|
115
|
+
`${commit}:refs/heads/${opts.branch}`
|
|
116
|
+
], "Failed to push the version branch to origin. Ensure `origin` is configured and you have push access.");
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
/** snapshot package versions, hook into `initCliDraft` */
|
|
121
|
+
initCliDraft() {
|
|
122
|
+
for (const pkg of this.graph.getPackages()) snapshots.set(pkg.id, pkg.version);
|
|
123
|
+
},
|
|
124
|
+
/** commit & push version branches, then upsert their requests, hook into `applyCliDraft` */
|
|
125
|
+
async applyCliDraft(draft) {
|
|
126
|
+
const config = resolveConfig(this.graph);
|
|
127
|
+
if (!config || !provider.canCreate(this)) return;
|
|
128
|
+
if (!(config.forceCreate || isCI()) || !await hasGitChanges(this.cwd)) return;
|
|
129
|
+
const requests = [];
|
|
130
|
+
const updatedPackages = /* @__PURE__ */ new Map();
|
|
131
|
+
for (const id of draft.getPackageDrafts().keys()) {
|
|
132
|
+
const snapshot = snapshots.get(id);
|
|
133
|
+
const pkg = this.graph.get(id);
|
|
134
|
+
if (pkg?.version && snapshot && pkg.version !== snapshot) updatedPackages.set(id, pkg);
|
|
135
|
+
}
|
|
136
|
+
for (const [id, members] of config.groupMap) {
|
|
137
|
+
const packages = [];
|
|
138
|
+
for (const member of members) for (const pkg of this.graph.getByName(member)) {
|
|
139
|
+
if (!updatedPackages.delete(pkg.id)) continue;
|
|
140
|
+
packages.push(pkg);
|
|
141
|
+
}
|
|
142
|
+
if (packages.length === 0) continue;
|
|
143
|
+
requests.push({
|
|
144
|
+
branch: `${config.branch}/${id}`,
|
|
145
|
+
packages,
|
|
146
|
+
publishGroup: id
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
if (updatedPackages.size > 0) requests.push({
|
|
150
|
+
branch: config.branch,
|
|
151
|
+
packages: Array.from(updatedPackages.values())
|
|
152
|
+
});
|
|
153
|
+
if (requests.length === 0) return;
|
|
154
|
+
await createVersionCommit(this.cwd, "Version Packages");
|
|
155
|
+
let baseLock;
|
|
156
|
+
let parent;
|
|
157
|
+
const tasks = [];
|
|
158
|
+
for (const { branch, packages, publishGroup } of requests) {
|
|
159
|
+
const plan = await initPublishPlan(this, { packages: publishGroup ? packages.map((pkg) => pkg.id) : void 0 });
|
|
160
|
+
if (plan) await runPreflights(this, plan);
|
|
161
|
+
const ctx = {
|
|
162
|
+
draft,
|
|
163
|
+
plan,
|
|
164
|
+
getPreviousVersion: (id) => snapshots.get(id)
|
|
165
|
+
};
|
|
166
|
+
const custom = await config.create?.call(this, ctx);
|
|
167
|
+
const title = custom?.title ?? (publishGroup ? `Release ${packages.map((pkg) => `${pkg.name} (${pkg.manager})`).join(", ")}` : "Version Packages");
|
|
168
|
+
if (publishGroup) {
|
|
169
|
+
parent ??= await resolveHead(this.cwd);
|
|
170
|
+
baseLock ??= await parsePublishLock(await readFile(this.lockPath, "utf8"));
|
|
171
|
+
const newGroups = {};
|
|
172
|
+
for (const req of requests) {
|
|
173
|
+
if (!req.publishGroup) continue;
|
|
174
|
+
newGroups[req.publishGroup] = req.publishGroup !== publishGroup ? "pending" : "active";
|
|
175
|
+
}
|
|
176
|
+
const inSync = await syncGroupBranch(this, baseLock, {
|
|
177
|
+
branch,
|
|
178
|
+
parent,
|
|
179
|
+
store: { groups: newGroups }
|
|
180
|
+
});
|
|
181
|
+
tasks.push(provider.upsert(this, {
|
|
182
|
+
title,
|
|
183
|
+
body: custom?.body ?? renderRequestBody(this, ctx),
|
|
184
|
+
head: branch,
|
|
185
|
+
base: config.base
|
|
186
|
+
}, !inSync));
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
await pushBranch(this.cwd, branch);
|
|
190
|
+
await provider.upsert(this, {
|
|
191
|
+
title,
|
|
192
|
+
body: custom?.body ?? renderRequestBody(this, ctx),
|
|
193
|
+
head: branch,
|
|
194
|
+
base: config.base
|
|
195
|
+
}, true);
|
|
196
|
+
}
|
|
197
|
+
await Promise.all(tasks);
|
|
198
|
+
},
|
|
199
|
+
/** restore publish groups from the lock into the plan, hook into `initPublishPlan` */
|
|
200
|
+
initPublishPlan({ lock, plan }) {
|
|
201
|
+
const config = resolveConfig(this.graph);
|
|
202
|
+
if (!config) return;
|
|
203
|
+
let data;
|
|
204
|
+
const publishGroups = /* @__PURE__ */ new Map();
|
|
205
|
+
plan.$versionRequest = { publishGroups };
|
|
206
|
+
while (data = lock.read(namespace)) {
|
|
207
|
+
const validated = validatePublishGroupStore(data);
|
|
208
|
+
if (!validated.success) continue;
|
|
209
|
+
const store = validated.data;
|
|
210
|
+
for (const [id, state] of Object.entries(store.groups)) {
|
|
211
|
+
if (!config.groupMap.has(id) || publishGroups.get(id) === "active") continue;
|
|
212
|
+
publishGroups.set(id, state);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (publishGroups.size === 0) return;
|
|
216
|
+
const packages = [];
|
|
217
|
+
if (plan.options.packages) packages.push(...plan.options.packages);
|
|
218
|
+
for (const [id, state] of publishGroups) {
|
|
219
|
+
if (state === "pending") continue;
|
|
220
|
+
for (const pkg of config.groupMap.get(id)) packages.push(pkg);
|
|
221
|
+
}
|
|
222
|
+
plan.options = {
|
|
223
|
+
...plan.options,
|
|
224
|
+
packages
|
|
225
|
+
};
|
|
226
|
+
},
|
|
227
|
+
/** report `pending` while publish groups are waiting for their request */
|
|
228
|
+
resolvePlanStatus({ plan }) {
|
|
229
|
+
const publishGroups = plan.$versionRequest?.publishGroups;
|
|
230
|
+
if (!publishGroups) return;
|
|
231
|
+
for (const s of publishGroups.values()) if (s === "pending") return "pending";
|
|
232
|
+
},
|
|
233
|
+
/** re-sync the version requests of pending publish groups, hook into `beforePublishAll` */
|
|
234
|
+
async beforePublishAll({ plan }) {
|
|
235
|
+
if (plan.options.dryRun || !provider.canCreate(this)) return;
|
|
236
|
+
const config = resolveConfig(this.graph);
|
|
237
|
+
if (!config) return;
|
|
238
|
+
const publishGroups = plan.$versionRequest?.publishGroups;
|
|
239
|
+
if (!publishGroups || publishGroups.size === 0) return;
|
|
240
|
+
const pending = [];
|
|
241
|
+
for (const [id, state] of publishGroups) if (state === "pending") pending.push(id);
|
|
242
|
+
if (pending.length === 0) return;
|
|
243
|
+
const parent = await resolveHead(this.cwd);
|
|
244
|
+
const baseLock = parsePublishLock(await readFile(this.lockPath, "utf8"));
|
|
245
|
+
const remote = await resolveRemoteBranches(this.cwd, pending.map((id) => `${config.branch}/${id}`));
|
|
246
|
+
for (const id of pending) {
|
|
247
|
+
const newGroups = Object.fromEntries(publishGroups.entries());
|
|
248
|
+
newGroups[id] = "active";
|
|
249
|
+
await syncGroupBranch(this, baseLock, {
|
|
250
|
+
branch: `${config.branch}/${id}`,
|
|
251
|
+
parent,
|
|
252
|
+
remote,
|
|
253
|
+
store: { groups: newGroups }
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function renderRequestBody(ctx, { draft, getPreviousVersion, plan }) {
|
|
260
|
+
const packageLines = [];
|
|
261
|
+
const changelogLines = [];
|
|
262
|
+
const publishLines = [];
|
|
263
|
+
const changesets = /* @__PURE__ */ new Map();
|
|
264
|
+
for (const [id, packageDraft] of draft.getPackageDrafts()) {
|
|
265
|
+
const pkg = ctx.graph.get(id);
|
|
266
|
+
if (!pkg) continue;
|
|
267
|
+
for (const changelog of packageDraft.changelogs ?? []) {
|
|
268
|
+
const list = changesets.get(changelog);
|
|
269
|
+
if (list) list.push(pkg);
|
|
270
|
+
else changesets.set(changelog, [pkg]);
|
|
271
|
+
}
|
|
272
|
+
const from = getPreviousVersion(id);
|
|
273
|
+
if (!from || from === pkg.version) continue;
|
|
274
|
+
packageLines.push(`| \`${pkg.name}\` | \`${from}\` | \`${pkg.version}\`${formatNpmDistTag(packageDraft.npm?.distTag)} |`);
|
|
275
|
+
}
|
|
276
|
+
for (const [entry, linkedPackages] of changesets) {
|
|
277
|
+
changelogLines.push(`### ${entry.subject ?? `\`${entry.filename}\``}`, "");
|
|
278
|
+
changelogLines.push("<details>", `<summary>Show Bumped Packages (${linkedPackages.length})</summary>`, "", ...linkedPackages.map((pkg) => `- \`${pkg.id}\``), "", "</details>", "");
|
|
279
|
+
for (const section of entry.sections) {
|
|
280
|
+
changelogLines.push(`#### ${section.title}`, "");
|
|
281
|
+
if (section.content) changelogLines.push(section.content);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (plan) {
|
|
285
|
+
for (const [id, { preflight }] of plan.packages) if (preflight.shouldPublish) publishLines.push(`- ${id}`);
|
|
286
|
+
}
|
|
287
|
+
const sections = [
|
|
288
|
+
"## Summary",
|
|
289
|
+
"",
|
|
290
|
+
"All bumped packages.",
|
|
291
|
+
""
|
|
292
|
+
];
|
|
293
|
+
if (packageLines.length > 0) sections.push("| Package | From | To |", "| --- | --- | --- |", ...packageLines);
|
|
294
|
+
if (changelogLines.length > 0) sections.push("", "## Changelogs", ...changelogLines);
|
|
295
|
+
if (publishLines.length > 0) sections.push("", "## Publish", "", "The following packages will be published if merged:", ...publishLines);
|
|
296
|
+
sections.push("");
|
|
297
|
+
return sections.join("\n");
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Commit a lock file change on top of `parent` via a detached index, without touching the
|
|
301
|
+
* working tree. Commit dates are pinned to the parent, so unchanged content always produces
|
|
302
|
+
* the exact same commit.
|
|
303
|
+
*/
|
|
304
|
+
async function createLockCommit(context, opts) {
|
|
305
|
+
const { cwd } = context;
|
|
306
|
+
const dir = await mkdtemp(join(tmpdir(), "tegami-"));
|
|
307
|
+
try {
|
|
308
|
+
const blobFile = join(dir, "lock");
|
|
309
|
+
await writeFile(blobFile, opts.content);
|
|
310
|
+
const blob = await run(cwd, [
|
|
311
|
+
"hash-object",
|
|
312
|
+
"-w",
|
|
313
|
+
blobFile
|
|
314
|
+
], "Failed to store the lock file update.");
|
|
315
|
+
const path = relative(cwd, context.lockPath).replaceAll("\\", "/");
|
|
316
|
+
const env = {
|
|
317
|
+
...process.env,
|
|
318
|
+
GIT_INDEX_FILE: join(dir, "index")
|
|
319
|
+
};
|
|
320
|
+
await run(cwd, ["read-tree", opts.parent.commit], "Failed to read the current git tree.", env);
|
|
321
|
+
await run(cwd, [
|
|
322
|
+
"update-index",
|
|
323
|
+
"--add",
|
|
324
|
+
"--cacheinfo",
|
|
325
|
+
`100644,${blob},${path}`
|
|
326
|
+
], "Failed to update the lock file entry.", env);
|
|
327
|
+
return await run(cwd, [
|
|
328
|
+
"commit-tree",
|
|
329
|
+
await run(cwd, ["write-tree"], "Failed to write the updated git tree.", env),
|
|
330
|
+
"-p",
|
|
331
|
+
opts.parent.commit,
|
|
332
|
+
"-m",
|
|
333
|
+
opts.message
|
|
334
|
+
], "Failed to commit the lock file update.", {
|
|
335
|
+
...env,
|
|
336
|
+
GIT_AUTHOR_DATE: opts.parent.date,
|
|
337
|
+
GIT_COMMITTER_DATE: opts.parent.date
|
|
338
|
+
});
|
|
339
|
+
} finally {
|
|
340
|
+
await rm(dir, {
|
|
341
|
+
recursive: true,
|
|
342
|
+
force: true
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
/** the checked out commit and its committer date */
|
|
347
|
+
async function resolveHead(cwd) {
|
|
348
|
+
const [commit = "", date = ""] = (await run(cwd, [
|
|
349
|
+
"show",
|
|
350
|
+
"-s",
|
|
351
|
+
"--format=%H%n%cI"
|
|
352
|
+
], "Failed to resolve the current commit.")).split("\n");
|
|
353
|
+
return {
|
|
354
|
+
commit,
|
|
355
|
+
date
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
/** branch -> commit on origin, `undefined` when the remote cannot be queried */
|
|
359
|
+
async function resolveRemoteBranches(cwd, branches) {
|
|
360
|
+
const result = await x("git", [
|
|
361
|
+
"ls-remote",
|
|
362
|
+
"origin",
|
|
363
|
+
...branches.map((branch) => `refs/heads/${branch}`)
|
|
364
|
+
], { nodeOptions: { cwd } });
|
|
365
|
+
if (result.exitCode !== 0) return;
|
|
366
|
+
const out = /* @__PURE__ */ new Map();
|
|
367
|
+
for (const line of result.stdout.split("\n")) {
|
|
368
|
+
const [commit, name] = line.split(" ");
|
|
369
|
+
const ref = name?.trim();
|
|
370
|
+
if (commit && ref?.startsWith("refs/heads/")) out.set(ref.slice(11), commit.trim());
|
|
371
|
+
}
|
|
372
|
+
return out;
|
|
373
|
+
}
|
|
374
|
+
async function hasGitChanges(cwd) {
|
|
375
|
+
return (await run(cwd, ["status", "--porcelain"], "Failed to check git status.")).length > 0;
|
|
376
|
+
}
|
|
377
|
+
/** commit the working tree changes onto a detached HEAD */
|
|
378
|
+
async function createVersionCommit(cwd, title) {
|
|
379
|
+
await run(cwd, ["checkout", "--detach"], "Failed to detach HEAD for version branches.");
|
|
380
|
+
await run(cwd, ["add", "-A"], "Failed to stage version changes.");
|
|
381
|
+
await run(cwd, [
|
|
382
|
+
"commit",
|
|
383
|
+
"-m",
|
|
384
|
+
title
|
|
385
|
+
], "Failed to commit version changes.");
|
|
386
|
+
}
|
|
387
|
+
async function pushBranch(cwd, branch) {
|
|
388
|
+
await run(cwd, [
|
|
389
|
+
"checkout",
|
|
390
|
+
"-B",
|
|
391
|
+
branch
|
|
392
|
+
], "Failed to create the version branch.");
|
|
393
|
+
await run(cwd, [
|
|
394
|
+
"push",
|
|
395
|
+
"--force",
|
|
396
|
+
"-u",
|
|
397
|
+
"origin",
|
|
398
|
+
branch
|
|
399
|
+
], "Failed to push the version branch to origin. Ensure `origin` is configured and you have push access.");
|
|
400
|
+
}
|
|
401
|
+
async function run(cwd, args, message, env) {
|
|
402
|
+
const result = await x("git", args, { nodeOptions: {
|
|
403
|
+
cwd,
|
|
404
|
+
env
|
|
405
|
+
} });
|
|
406
|
+
if (result.exitCode !== 0) throw execFailure(message, result);
|
|
407
|
+
return result.stdout.trim();
|
|
408
|
+
}
|
|
409
|
+
function publishGroupId(members) {
|
|
410
|
+
const slugs = [];
|
|
411
|
+
for (const name of members.toSorted()) {
|
|
412
|
+
const v = name.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
413
|
+
if (v.length > 0) slugs.push(v);
|
|
414
|
+
}
|
|
415
|
+
if (slugs.length === 0) slugs.push("group");
|
|
416
|
+
return slugs.join("-");
|
|
417
|
+
}
|
|
418
|
+
//#endregion
|
|
419
|
+
export { onVersionRequest as t };
|