tegami 0.1.0 → 0.1.3
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/checks-Smwtq_Li.js +279 -0
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +212 -209
- package/dist/{error-DBK-9uBa.js → error-qpTCB2ld.js} +10 -6
- package/dist/generators/simple.d.ts +1 -1
- package/dist/generators/simple.js +1 -1
- package/dist/{graph-CUgwuRW5.js → graph-hBQUWKQA.js} +15 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +272 -294
- package/dist/plugins/git.d.ts +1 -1
- package/dist/plugins/git.js +4 -4
- package/dist/plugins/github.d.ts +7 -1
- package/dist/plugins/github.js +24 -23
- package/dist/providers/cargo.d.ts +1 -1
- package/dist/providers/cargo.js +32 -14
- package/dist/providers/npm.d.ts +1 -1
- package/dist/providers/npm.js +33 -18
- package/dist/{semver-mWK2Khi2.js → semver-cnZp9koa.js} +16 -5
- package/dist/{types-UjsZkz42.d.ts → types-Di--A9X1.d.ts} +68 -23
- package/package.json +1 -1
- package/dist/checks-BQISvt_o.js +0 -98
package/dist/plugins/git.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as execFailure } from "../error-qpTCB2ld.js";
|
|
2
2
|
import { t as isCI } from "../constants-B9qjNfvr.js";
|
|
3
3
|
import { x } from "tinyexec";
|
|
4
4
|
//#region src/plugins/git.ts
|
|
@@ -13,8 +13,7 @@ function git(options = {}) {
|
|
|
13
13
|
function resolveGitTag(context, result) {
|
|
14
14
|
const { graph } = context;
|
|
15
15
|
const pkg = graph.get(result.id);
|
|
16
|
-
|
|
17
|
-
const group = graph.getPackageGroup(pkg.id);
|
|
16
|
+
const group = pkg && graph.getPackageGroup(pkg.id);
|
|
18
17
|
if (group?.options.syncGitTag) return `${group.name}@${result.version}`;
|
|
19
18
|
return `${result.name}@${result.version}`;
|
|
20
19
|
}
|
|
@@ -39,9 +38,10 @@ function git(options = {}) {
|
|
|
39
38
|
} },
|
|
40
39
|
async afterPublishAll(result) {
|
|
41
40
|
const { cwd, publishOptions: { dryRun = false } } = this;
|
|
42
|
-
if (dryRun || !createTags || result.state
|
|
41
|
+
if (dryRun || !createTags || result.state === "skipped") return result;
|
|
43
42
|
const pendingTags = /* @__PURE__ */ new Set();
|
|
44
43
|
for (const pkg of result.packages) {
|
|
44
|
+
if (pkg.state !== "success") continue;
|
|
45
45
|
pkg.gitTag = resolveGitTag(this, pkg);
|
|
46
46
|
pendingTags.add(pkg.gitTag);
|
|
47
47
|
}
|
package/dist/plugins/github.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as PackagePublishResult, T as TegamiContext, c as TegamiPlugin, k as DraftPlan, t as Awaitable } from "../types-Di--A9X1.js";
|
|
2
2
|
import { GitPluginOptions } from "./git.js";
|
|
3
3
|
|
|
4
4
|
//#region src/plugins/github.d.ts
|
|
@@ -42,6 +42,12 @@ interface GitHubPluginOptions extends GitPluginOptions {
|
|
|
42
42
|
repo?: string;
|
|
43
43
|
/** Optional GitHub token for Git & GitHub operations. */
|
|
44
44
|
token?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Create GitHub release immediately after successful publish, without waiting for others.
|
|
47
|
+
*
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
eagerRelease?: boolean;
|
|
45
51
|
/** Override release details for a single package, return `false` to skip. */
|
|
46
52
|
onCreateRelease?: (this: TegamiContext, result: PackagePublishResult) => Awaitable<GithubRelease | false>;
|
|
47
53
|
/** Override release details when multiple packages share a git tag, return `false` to skip. */
|
package/dist/plugins/github.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
1
|
+
import { i as formatPackageVersion, r as formatNpmDistTag } from "../semver-cnZp9koa.js";
|
|
2
|
+
import { n as execFailure } from "../error-qpTCB2ld.js";
|
|
3
3
|
import { t as isCI } from "../constants-B9qjNfvr.js";
|
|
4
4
|
import { git } from "./git.js";
|
|
5
5
|
import { join, relative } from "node:path";
|
|
@@ -8,7 +8,8 @@ import { prerelease } from "semver";
|
|
|
8
8
|
//#region src/plugins/github.ts
|
|
9
9
|
/** Create GitHub releases for successfully published packages after the whole plan succeeds. */
|
|
10
10
|
function github(options = {}) {
|
|
11
|
-
|
|
11
|
+
const { eagerRelease = false, onCreateGroupedRelease, onCreateRelease, onCreateVersionPullRequest, cli: cliOptions = {} } = options;
|
|
12
|
+
async function runGithubRelease(gitTag, title, notes, prerelease, repo) {
|
|
12
13
|
const args = [
|
|
13
14
|
"release",
|
|
14
15
|
"create",
|
|
@@ -18,26 +19,27 @@ function github(options = {}) {
|
|
|
18
19
|
"--notes",
|
|
19
20
|
notes
|
|
20
21
|
];
|
|
21
|
-
if (
|
|
22
|
+
if (repo) args.push("--repo", repo);
|
|
22
23
|
if (prerelease) args.push("--prerelease");
|
|
23
24
|
const result = await x("gh", args);
|
|
24
25
|
if (result.exitCode !== 0) throw execFailure(`Failed to create GitHub release for ${gitTag}.`, result);
|
|
25
26
|
}
|
|
26
27
|
async function createRelease(context, pkg) {
|
|
27
|
-
if (!pkg.gitTag) return;
|
|
28
|
-
const release = await
|
|
28
|
+
if (!pkg.gitTag || pkg.state === "failed") return;
|
|
29
|
+
const release = await onCreateRelease?.call(context, pkg) ?? {};
|
|
29
30
|
if (release === false) return;
|
|
30
|
-
await runGithubRelease(pkg.gitTag, release.title ?? defaultTitle(pkg), release.notes ?? await defaultNotes(context, pkg), release.prerelease ?? prerelease(pkg.version) !== null);
|
|
31
|
+
await runGithubRelease(pkg.gitTag, release.title ?? defaultTitle(pkg), release.notes ?? await defaultNotes(context, pkg), release.prerelease ?? prerelease(pkg.version) !== null, context.github?.repo);
|
|
31
32
|
}
|
|
32
33
|
async function createGroupedRelease(context, packages) {
|
|
33
34
|
const primary = packages[0];
|
|
34
35
|
if (!primary?.gitTag) return;
|
|
35
|
-
|
|
36
|
+
if (packages.some((member) => member.state === "failed")) return;
|
|
37
|
+
const release = await onCreateGroupedRelease?.call(context, packages) ?? {};
|
|
36
38
|
if (release === false) return;
|
|
37
|
-
await runGithubRelease(primary.gitTag, release.title ?? defaultGroupedTitle(packages), release.notes ?? await defaultGroupedNotes(context, packages), release.prerelease ?? packages.some((pkg) => prerelease(pkg.version) !== null));
|
|
39
|
+
await runGithubRelease(primary.gitTag, release.title ?? defaultGroupedTitle(packages), release.notes ?? await defaultGroupedNotes(context, packages), release.prerelease ?? packages.some((pkg) => prerelease(pkg.version) !== null), context.github?.repo);
|
|
38
40
|
}
|
|
39
41
|
function resolvePROptions() {
|
|
40
|
-
const setting =
|
|
42
|
+
const setting = cliOptions.versionPr ?? isCI();
|
|
41
43
|
if (setting === false) return [false];
|
|
42
44
|
if (setting === true) return [true, {}];
|
|
43
45
|
if (setting.forceCreate || isCI()) return [true, setting];
|
|
@@ -77,24 +79,21 @@ function github(options = {}) {
|
|
|
77
79
|
return [git(options), {
|
|
78
80
|
name: "github",
|
|
79
81
|
init() {
|
|
80
|
-
const repository = options.repo ?? process.env.GITHUB_REPOSITORY;
|
|
81
|
-
const token = options.token ?? process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN;
|
|
82
82
|
this.github = {
|
|
83
|
-
repo:
|
|
84
|
-
token
|
|
83
|
+
repo: options.repo ?? process.env.GITHUB_REPOSITORY,
|
|
84
|
+
token: options.token ?? process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN
|
|
85
85
|
};
|
|
86
86
|
},
|
|
87
87
|
cli: {
|
|
88
88
|
async init() {
|
|
89
89
|
if (!isCI()) return;
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
if (!token || !repository) return;
|
|
90
|
+
const { repo, token } = this.github ?? {};
|
|
91
|
+
if (!token || !repo) return;
|
|
93
92
|
const result = await x("git", [
|
|
94
93
|
"remote",
|
|
95
94
|
"set-url",
|
|
96
95
|
"origin",
|
|
97
|
-
`https://x-access-token:${token}@github.com/${
|
|
96
|
+
`https://x-access-token:${token}@github.com/${repo}.git`
|
|
98
97
|
], { nodeOptions: { cwd: this.cwd } });
|
|
99
98
|
if (result.exitCode !== 0) throw execFailure("Failed to configure git remote for GitHub Actions.", result);
|
|
100
99
|
},
|
|
@@ -104,9 +103,10 @@ function github(options = {}) {
|
|
|
104
103
|
async publishPlanApplied(draft) {
|
|
105
104
|
const { cwd } = this;
|
|
106
105
|
const [enabled, config] = resolvePROptions();
|
|
106
|
+
const repo = this.github?.repo;
|
|
107
107
|
if (!enabled || !await hasGitChanges(cwd)) return;
|
|
108
108
|
const { branch = "tegami/version-packages", base = "main" } = config;
|
|
109
|
-
const basePR = await
|
|
109
|
+
const basePR = await onCreateVersionPullRequest?.call(this, draft);
|
|
110
110
|
if (basePR === false) return;
|
|
111
111
|
const pr = {
|
|
112
112
|
title: basePR?.title ?? "Version Packages",
|
|
@@ -135,7 +135,7 @@ function github(options = {}) {
|
|
|
135
135
|
branch
|
|
136
136
|
], gitOptions);
|
|
137
137
|
if (result.exitCode !== 0) throw execFailure("Failed to push the version branch to origin. Ensure `origin` is configured and you have push access.", result);
|
|
138
|
-
const openPr = await findOpenPullRequest(branch,
|
|
138
|
+
const openPr = await findOpenPullRequest(branch, repo);
|
|
139
139
|
if (openPr !== void 0) {
|
|
140
140
|
const editArgs = [
|
|
141
141
|
"pr",
|
|
@@ -146,7 +146,7 @@ function github(options = {}) {
|
|
|
146
146
|
"--body",
|
|
147
147
|
pr.body
|
|
148
148
|
];
|
|
149
|
-
if (
|
|
149
|
+
if (repo) editArgs.push("--repo", repo);
|
|
150
150
|
const editResult = await x("gh", editArgs);
|
|
151
151
|
if (editResult.exitCode !== 0) throw execFailure("Failed to update the version pull request.", editResult);
|
|
152
152
|
return;
|
|
@@ -163,13 +163,14 @@ function github(options = {}) {
|
|
|
163
163
|
"--base",
|
|
164
164
|
base
|
|
165
165
|
];
|
|
166
|
-
if (
|
|
166
|
+
if (repo) args.push("--repo", repo);
|
|
167
167
|
const prResult = await x("gh", args);
|
|
168
168
|
if (prResult.exitCode !== 0) throw execFailure("Failed to create the version pull request.", prResult);
|
|
169
169
|
}
|
|
170
170
|
},
|
|
171
171
|
async afterPublishAll(result) {
|
|
172
|
-
if (result.state
|
|
172
|
+
if (!eagerRelease && result.state === "failed") return;
|
|
173
|
+
if (result.state === "skipped") return;
|
|
173
174
|
for (const packages of groupPackagesByGitTag(result.packages).values()) if (packages.length > 1) await createGroupedRelease(this, packages);
|
|
174
175
|
else await createRelease(this, packages[0]);
|
|
175
176
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { d as
|
|
1
|
+
import { d as CargoPluginOptions, f as CargoRegistryClient, p as cargo, u as CargoPackage } from "../types-Di--A9X1.js";
|
|
2
2
|
export { CargoPackage, CargoPluginOptions, CargoRegistryClient, cargo };
|
package/dist/providers/cargo.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as WorkspacePackage } from "../graph-
|
|
1
|
+
import { i as isNodeError, n as execFailure } from "../error-qpTCB2ld.js";
|
|
2
|
+
import { n as WorkspacePackage } from "../graph-hBQUWKQA.js";
|
|
3
3
|
import { readFile, writeFile } from "node:fs/promises";
|
|
4
4
|
import { join, normalize } from "node:path";
|
|
5
5
|
import { x } from "tinyexec";
|
|
6
|
-
import initToml, { edit, parse } from "@rainbowatcher/toml-edit-js";
|
|
7
6
|
import * as semver from "semver";
|
|
7
|
+
import initToml, { edit, parse as parse$1 } from "@rainbowatcher/toml-edit-js";
|
|
8
8
|
import { glob } from "tinyglobby";
|
|
9
9
|
//#region src/providers/cargo.ts
|
|
10
10
|
const DEP_FIELDS = [
|
|
@@ -31,8 +31,8 @@ var CargoPackage = class extends WorkspacePackage {
|
|
|
31
31
|
get version() {
|
|
32
32
|
return stringValue(this.packageInfo.version) ?? this.workspaceVersion ?? "0.0.0";
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
const defaults = super.
|
|
34
|
+
initPlan() {
|
|
35
|
+
const defaults = super.initPlan();
|
|
36
36
|
defaults.publish ??= this.packageInfo.publish !== false;
|
|
37
37
|
return defaults;
|
|
38
38
|
}
|
|
@@ -55,9 +55,12 @@ var CargoPackage = class extends WorkspacePackage {
|
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
var CargoRegistryClient = class {
|
|
58
|
+
graph;
|
|
58
59
|
id = "cargo";
|
|
59
60
|
#versionMap = /* @__PURE__ */ new Map();
|
|
60
|
-
constructor(
|
|
61
|
+
constructor(graph) {
|
|
62
|
+
this.graph = graph;
|
|
63
|
+
}
|
|
61
64
|
supports(pkg) {
|
|
62
65
|
return pkg instanceof CargoPackage;
|
|
63
66
|
}
|
|
@@ -74,14 +77,24 @@ var CargoRegistryClient = class {
|
|
|
74
77
|
}
|
|
75
78
|
return info;
|
|
76
79
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
publishPreflight(pkg, { store }) {
|
|
81
|
+
const wait = [];
|
|
82
|
+
for (const { table } of dependencyTables(pkg.manifest, "")) for (const [rawName, rawSpec] of Object.entries(table)) {
|
|
83
|
+
if (!isTableValue(rawSpec) || typeof rawSpec.path !== "string") continue;
|
|
84
|
+
const id = `cargo:${stringValue(rawSpec.package) ?? rawName}`;
|
|
85
|
+
if (!store.packages[id]?.publish) continue;
|
|
86
|
+
const linked = this.graph.get(id);
|
|
87
|
+
if (!linked || !(linked instanceof CargoPackage)) continue;
|
|
88
|
+
wait.push(id);
|
|
89
|
+
}
|
|
90
|
+
return { wait };
|
|
91
|
+
}
|
|
92
|
+
async publish(pkg, _env) {
|
|
93
|
+
const result = await x("cargo", ["publish"], { nodeOptions: { cwd: pkg.path } });
|
|
94
|
+
if (result.exitCode !== 0) throw execFailure(`Failed to publish ${pkg.name}@${pkg.version}.`, result);
|
|
82
95
|
}
|
|
83
96
|
};
|
|
84
|
-
function cargo({ bumpDep: getBumpDepType = ({ kind }) => {
|
|
97
|
+
function cargo({ updateLockFile = false, bumpDep: getBumpDepType = ({ kind }) => {
|
|
85
98
|
switch (kind) {
|
|
86
99
|
case "dependencies": return "patch";
|
|
87
100
|
case "build-dependencies":
|
|
@@ -159,7 +172,12 @@ function cargo({ bumpDep: getBumpDepType = ({ kind }) => {
|
|
|
159
172
|
writes.push(pkg.write());
|
|
160
173
|
}
|
|
161
174
|
await Promise.all(writes);
|
|
162
|
-
}
|
|
175
|
+
},
|
|
176
|
+
cli: { async publishPlanApplied() {
|
|
177
|
+
if (!updateLockFile) return;
|
|
178
|
+
const result = await x("cargo", ["update", "--workspace"], { nodeOptions: { cwd: this.cwd } });
|
|
179
|
+
if (result.exitCode !== 0) throw execFailure("Failed to update Cargo lock file", result);
|
|
180
|
+
} }
|
|
163
181
|
};
|
|
164
182
|
}
|
|
165
183
|
async function discoverCargoPackages(cwd, add) {
|
|
@@ -249,7 +267,7 @@ function parseSpec(v) {
|
|
|
249
267
|
async function readCargoManifest(path) {
|
|
250
268
|
const content = await readFile(join(path, "Cargo.toml"), "utf8");
|
|
251
269
|
return {
|
|
252
|
-
manifest: parse(content),
|
|
270
|
+
manifest: parse$1(content),
|
|
253
271
|
content
|
|
254
272
|
};
|
|
255
273
|
}
|
package/dist/providers/npm.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as npm, g as NpmRegistryClient, h as NpmPluginOptions, m as NpmPackage } from "../types-Di--A9X1.js";
|
|
2
2
|
export { NpmPackage, NpmPluginOptions, NpmRegistryClient, npm };
|
package/dist/providers/npm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as WorkspacePackage } from "../graph-CUgwuRW5.js";
|
|
1
|
+
import { i as isNodeError, n as execFailure } from "../error-qpTCB2ld.js";
|
|
3
2
|
import { i as pnpmWorkspaceSchema, r as packageManifestSchema } from "../schemas-CurBAaW5.js";
|
|
3
|
+
import { n as WorkspacePackage } from "../graph-hBQUWKQA.js";
|
|
4
4
|
import { readFile, writeFile } from "node:fs/promises";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { x } from "tinyexec";
|
|
7
7
|
import * as semver from "semver";
|
|
8
|
-
import { glob } from "tinyglobby";
|
|
9
8
|
import { load } from "js-yaml";
|
|
9
|
+
import { glob } from "tinyglobby";
|
|
10
10
|
import { detect } from "package-manager-detector";
|
|
11
11
|
//#region src/providers/npm.ts
|
|
12
12
|
const DEP_FIELDS = [
|
|
@@ -33,8 +33,8 @@ var NpmPackage = class extends WorkspacePackage {
|
|
|
33
33
|
async write() {
|
|
34
34
|
await writeFile(path.join(this.path, "package.json"), `${JSON.stringify(this.manifest, null, 2)}\n`);
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
const defaults = super.
|
|
36
|
+
initPlan() {
|
|
37
|
+
const defaults = super.initPlan();
|
|
38
38
|
defaults.publish ??= this.manifest.private !== true;
|
|
39
39
|
if (this.manifest.publishConfig?.tag) {
|
|
40
40
|
defaults.npm ??= {};
|
|
@@ -70,9 +70,8 @@ var NpmRegistryClient = class {
|
|
|
70
70
|
if (registry) args.push("--registry", registry);
|
|
71
71
|
const result = await x(this.client === "pnpm" ? "pnpm" : "npm", args, { nodeOptions: { cwd: this.cwd } });
|
|
72
72
|
if (result.exitCode === 0) return true;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
throw new Error(`Unable to validate ${pkg.name}@${pkg.version} against the npm registry${registry ? ` "${registry}"` : ""}: ${output.trim() || `command exited with code ${result.exitCode}`}`);
|
|
73
|
+
if (isMissingRegistryEntry(result.stderr) || isMissingRegistryEntry(result.stdout)) return false;
|
|
74
|
+
throw execFailure(`Unable to validate ${pkg.name}@${pkg.version} against the npm registry${registry ? ` "${registry}"` : ""}.`, result);
|
|
76
75
|
};
|
|
77
76
|
info = run();
|
|
78
77
|
this.#versionMap.set(cacheKey, info);
|
|
@@ -80,18 +79,34 @@ var NpmRegistryClient = class {
|
|
|
80
79
|
return info;
|
|
81
80
|
}
|
|
82
81
|
async publish(pkg, { packageStore }) {
|
|
83
|
-
const args = ["publish"];
|
|
84
82
|
const distTag = packageStore.npm?.distTag;
|
|
83
|
+
if (this.client === "bun") {
|
|
84
|
+
const tarball = "pkg.tgz";
|
|
85
|
+
const packResult = await x("bun", [
|
|
86
|
+
"pm",
|
|
87
|
+
"pack",
|
|
88
|
+
"--filename",
|
|
89
|
+
tarball
|
|
90
|
+
], { nodeOptions: { cwd: pkg.path } });
|
|
91
|
+
if (packResult.exitCode !== 0) throw execFailure(`Failed to pack ${pkg.name}@${pkg.version}.`, packResult);
|
|
92
|
+
const publishArgs = ["publish", tarball];
|
|
93
|
+
if (distTag) publishArgs.push("--tag", distTag);
|
|
94
|
+
const publishResult = await x("npm", publishArgs, { nodeOptions: { cwd: pkg.path } });
|
|
95
|
+
if (publishResult.exitCode !== 0) throw execFailure(`Failed to publish ${pkg.name}@${pkg.version}${distTag ? ` with dist-tag "${distTag}"` : ""}.`, publishResult);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const args = ["publish"];
|
|
85
99
|
if (distTag) args.push("--tag", distTag);
|
|
86
|
-
|
|
87
|
-
if (client === "pnpm")
|
|
100
|
+
let client;
|
|
101
|
+
if (this.client === "pnpm") {
|
|
102
|
+
client = "pnpm";
|
|
103
|
+
args.push("--no-git-checks");
|
|
104
|
+
} else if (this.client === "yarn") client = "yarn";
|
|
105
|
+
else client = "npm";
|
|
88
106
|
const result = await x(client, args, { nodeOptions: { cwd: pkg.path } });
|
|
89
107
|
if (result.exitCode !== 0) throw execFailure(`Failed to publish ${pkg.name}@${pkg.version}${distTag ? ` with dist-tag "${distTag}"` : ""}.`, result);
|
|
90
108
|
}
|
|
91
109
|
};
|
|
92
|
-
function commandOutput(result) {
|
|
93
|
-
return [result.stdout, result.stderr].filter(Boolean).join("\n");
|
|
94
|
-
}
|
|
95
110
|
function isMissingRegistryEntry(output) {
|
|
96
111
|
const normalized = output.toLowerCase();
|
|
97
112
|
return normalized.includes("e404") || normalized.includes("404") || normalized.includes("no match") || normalized.includes("no matching version") || normalized.includes("not found");
|
|
@@ -200,8 +215,7 @@ function npm({ client: defaultClient, onBreakPeerDep = "set", updateLockFile = f
|
|
|
200
215
|
client = defaultClient;
|
|
201
216
|
return;
|
|
202
217
|
}
|
|
203
|
-
|
|
204
|
-
else client = "npm";
|
|
218
|
+
client = (await detect({ cwd: this.cwd }))?.name ?? "npm";
|
|
205
219
|
},
|
|
206
220
|
async resolve() {
|
|
207
221
|
await discoverNpmPackages(this.cwd, (pkg) => this.graph.add(pkg));
|
|
@@ -253,6 +267,7 @@ function npm({ client: defaultClient, onBreakPeerDep = "set", updateLockFile = f
|
|
|
253
267
|
let args;
|
|
254
268
|
if (client === "npm") args = ["ci"];
|
|
255
269
|
else if (client === "yarn") args = ["install", "--immutable"];
|
|
270
|
+
else if (client === "bun") args = ["install", "--frozen-lockfile"];
|
|
256
271
|
else args = ["install", "--frozen-lockfile"];
|
|
257
272
|
const result = await x(client, args, { nodeOptions: { cwd: this.cwd } });
|
|
258
273
|
if (result.exitCode !== 0) throw execFailure("Failed to update lockfile.", result);
|
|
@@ -273,9 +288,9 @@ async function discoverNpmPackages(cwd, add) {
|
|
|
273
288
|
path,
|
|
274
289
|
manifest
|
|
275
290
|
})).catch(() => void 0)));
|
|
276
|
-
if (rootManifest) add(new NpmPackage(cwd, rootManifest));
|
|
291
|
+
if (rootManifest?.version) add(new NpmPackage(cwd, rootManifest));
|
|
277
292
|
for (const entry of manifests) {
|
|
278
|
-
if (!entry?.manifest) continue;
|
|
293
|
+
if (!entry?.manifest.version) continue;
|
|
279
294
|
add(new NpmPackage(entry.path, entry.manifest));
|
|
280
295
|
}
|
|
281
296
|
}
|
|
@@ -11,6 +11,11 @@ const WEIGHTS = {
|
|
|
11
11
|
minor: 2,
|
|
12
12
|
patch: 1
|
|
13
13
|
};
|
|
14
|
+
const DEPTH = {
|
|
15
|
+
major: 1,
|
|
16
|
+
minor: 2,
|
|
17
|
+
patch: 3
|
|
18
|
+
};
|
|
14
19
|
const PRE = {
|
|
15
20
|
major: "premajor",
|
|
16
21
|
minor: "preminor",
|
|
@@ -20,14 +25,20 @@ function maxBump(a, b) {
|
|
|
20
25
|
if (WEIGHTS[a] > WEIGHTS[b]) return a;
|
|
21
26
|
return b;
|
|
22
27
|
}
|
|
28
|
+
function bumpDepth(type) {
|
|
29
|
+
return DEPTH[type];
|
|
30
|
+
}
|
|
23
31
|
function bumpVersion(version, type, prerelease) {
|
|
24
32
|
let next = version;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
const parsed = parse(version);
|
|
34
|
+
if (!parsed) next = null;
|
|
35
|
+
else if (prerelease) {
|
|
36
|
+
if (parsed.prerelease[0] === prerelease) next = inc(parsed, "prerelease", prerelease);
|
|
37
|
+
else if (type) next = inc(parsed, PRE[type], prerelease);
|
|
38
|
+
} else if (type) next = inc(parsed, type);
|
|
39
|
+
else if (parsed.prerelease.length > 0) next = inc(parsed, "release");
|
|
29
40
|
if (!next) throw new Error(`Invalid semver version: ${version}`);
|
|
30
41
|
return next;
|
|
31
42
|
}
|
|
32
43
|
//#endregion
|
|
33
|
-
export { maxBump as i,
|
|
44
|
+
export { maxBump as a, formatPackageVersion as i, bumpVersion as n, formatNpmDistTag as r, bumpDepth as t };
|
|
@@ -4,19 +4,31 @@ import { AgentName } from "package-manager-detector";
|
|
|
4
4
|
//#region src/utils/semver.d.ts
|
|
5
5
|
type BumpType = "major" | "minor" | "patch";
|
|
6
6
|
//#endregion
|
|
7
|
+
//#region src/changelog/shared.d.ts
|
|
8
|
+
declare const changelogPackageConfigSchema: z$1.ZodObject<{
|
|
9
|
+
type: z$1.ZodOptional<z$1.ZodEnum<{
|
|
10
|
+
major: "major";
|
|
11
|
+
minor: "minor";
|
|
12
|
+
patch: "patch";
|
|
13
|
+
}>>;
|
|
14
|
+
replay: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
|
|
15
|
+
}, z$1.core.$strip>;
|
|
16
|
+
type ChangelogPackageConfig = z$1.output<typeof changelogPackageConfigSchema>;
|
|
17
|
+
//#endregion
|
|
7
18
|
//#region src/changelog/parse.d.ts
|
|
8
19
|
interface ChangelogEntry {
|
|
9
20
|
id: string;
|
|
10
21
|
/** file name like `my-change.md` */
|
|
11
22
|
filename: string;
|
|
12
23
|
subject?: string;
|
|
13
|
-
packages: Map<string,
|
|
24
|
+
packages: Map<string, ChangelogPackageConfig>;
|
|
14
25
|
/** will not be empty */
|
|
15
26
|
sections: {
|
|
16
27
|
depth: number;
|
|
17
28
|
title: string;
|
|
18
29
|
content: string;
|
|
19
30
|
}[];
|
|
31
|
+
getRawContent: () => string;
|
|
20
32
|
}
|
|
21
33
|
//#endregion
|
|
22
34
|
//#region src/plans/draft.d.ts
|
|
@@ -48,17 +60,20 @@ declare class DraftPlan {
|
|
|
48
60
|
type: BumpType;
|
|
49
61
|
reason?: string;
|
|
50
62
|
}): PackagePlan;
|
|
63
|
+
dispatchPackage(pkg: WorkspacePackage, dispatch: (plan: PackagePlan) => void, onUpdate?: (plan: PackagePlan) => void): PackagePlan;
|
|
64
|
+
private getOrInitPackage;
|
|
51
65
|
hasPending(): boolean;
|
|
52
66
|
getChangelogs(): ChangelogEntry[];
|
|
53
67
|
getChangelog(id: string): ChangelogEntry | undefined;
|
|
54
68
|
addChangelog(entry: ChangelogEntry): void;
|
|
55
69
|
deleteChangelog(id: string): boolean;
|
|
56
|
-
private initPackagePlan;
|
|
57
70
|
/** Apply the publish plan: update package versions, write the plan file, and consume changelog files. */
|
|
58
71
|
applyPlan(): Promise<void>;
|
|
59
72
|
addPolicy(policy: PlanPolicy): void;
|
|
60
73
|
removePolicy(policy: PlanPolicy): void;
|
|
61
74
|
canApply(): boolean;
|
|
75
|
+
/** Attach replaying changelog entries to packages (already bumped), and return the updated changelog entries. */
|
|
76
|
+
private applyReplays;
|
|
62
77
|
private appendChangelog;
|
|
63
78
|
/** {@link applyPlan} but for `await using` syntax */
|
|
64
79
|
[Symbol.asyncDispose](): Promise<void>;
|
|
@@ -89,8 +104,10 @@ declare abstract class WorkspacePackage {
|
|
|
89
104
|
/** note: this will only be available after package graph is resolved */
|
|
90
105
|
getPackageOptions(): PackageOptions;
|
|
91
106
|
setPackageOptions(options: PackageOptions): void;
|
|
92
|
-
/** create
|
|
93
|
-
|
|
107
|
+
/** create the initial draft plan. */
|
|
108
|
+
initPlan(): PackagePlan;
|
|
109
|
+
/** configure an initial draft plan to match script-level configs. */
|
|
110
|
+
configurePlan(plan: PackagePlan): void;
|
|
94
111
|
}
|
|
95
112
|
interface PackageGroup {
|
|
96
113
|
name: string;
|
|
@@ -160,17 +177,7 @@ declare const planStoreSchema: z$1.ZodCodec<z$1.ZodString, z$1.ZodObject<{
|
|
|
160
177
|
version: z$1.ZodDefault<z$1.ZodLiteral<"0.0.0">>;
|
|
161
178
|
changelogs: z$1.ZodRecord<z$1.ZodString, z$1.ZodObject<{
|
|
162
179
|
filename: z$1.ZodString;
|
|
163
|
-
|
|
164
|
-
packages: z$1.ZodRecord<z$1.ZodString, z$1.ZodEnum<{
|
|
165
|
-
major: "major";
|
|
166
|
-
minor: "minor";
|
|
167
|
-
patch: "patch";
|
|
168
|
-
}>>;
|
|
169
|
-
sections: z$1.ZodArray<z$1.ZodObject<{
|
|
170
|
-
depth: z$1.ZodNumber;
|
|
171
|
-
title: z$1.ZodString;
|
|
172
|
-
content: z$1.ZodString;
|
|
173
|
-
}, z$1.core.$strip>>;
|
|
180
|
+
content: z$1.ZodString;
|
|
174
181
|
}, z$1.core.$strip>>;
|
|
175
182
|
packages: z$1.ZodRecord<z$1.ZodString, z$1.ZodObject<{
|
|
176
183
|
type: z$1.ZodOptional<z$1.ZodEnum<{
|
|
@@ -228,12 +235,26 @@ interface CreateChangelogOptions {
|
|
|
228
235
|
from?: string;
|
|
229
236
|
/** End revision. Defaults to HEAD. */
|
|
230
237
|
to?: string;
|
|
238
|
+
/**
|
|
239
|
+
* Write changelog files to disk.
|
|
240
|
+
*
|
|
241
|
+
* @default true
|
|
242
|
+
*/
|
|
243
|
+
write?: boolean;
|
|
231
244
|
}
|
|
232
245
|
interface CreatedChangelog {
|
|
233
246
|
filename: string;
|
|
234
|
-
|
|
247
|
+
content: string;
|
|
248
|
+
packages: Record<string, BumpType | ChangelogPackageConfig>;
|
|
249
|
+
changes: CommitChange[];
|
|
250
|
+
}
|
|
251
|
+
interface CommitChange {
|
|
252
|
+
hash: string;
|
|
253
|
+
subject: string;
|
|
254
|
+
body: string;
|
|
235
255
|
packages: string[];
|
|
236
|
-
|
|
256
|
+
type: BumpType;
|
|
257
|
+
title: string;
|
|
237
258
|
}
|
|
238
259
|
//#endregion
|
|
239
260
|
//#region src/index.d.ts
|
|
@@ -287,7 +308,7 @@ declare class NpmPackage extends WorkspacePackage {
|
|
|
287
308
|
get name(): string;
|
|
288
309
|
get version(): string;
|
|
289
310
|
write(): Promise<void>;
|
|
290
|
-
|
|
311
|
+
initPlan(): PackagePlan;
|
|
291
312
|
}
|
|
292
313
|
declare class NpmRegistryClient implements RegistryClient {
|
|
293
314
|
#private;
|
|
@@ -368,7 +389,7 @@ declare class CargoPackage extends WorkspacePackage {
|
|
|
368
389
|
constructor(path: string, manifest: TomlTable, content: string, workspaceManifest?: TomlTable | undefined);
|
|
369
390
|
get name(): string;
|
|
370
391
|
get version(): string;
|
|
371
|
-
|
|
392
|
+
initPlan(): PackagePlan;
|
|
372
393
|
setVersion(version: string): void;
|
|
373
394
|
write(): Promise<void>;
|
|
374
395
|
patch(path: string, value: unknown): void;
|
|
@@ -377,13 +398,28 @@ declare class CargoPackage extends WorkspacePackage {
|
|
|
377
398
|
}
|
|
378
399
|
declare class CargoRegistryClient implements RegistryClient {
|
|
379
400
|
#private;
|
|
401
|
+
private readonly graph;
|
|
380
402
|
readonly id = "cargo";
|
|
381
|
-
constructor(
|
|
403
|
+
constructor(graph: PackageGraph);
|
|
382
404
|
supports(pkg: WorkspacePackage): boolean;
|
|
383
405
|
isPackagePublished(pkg: CargoPackage): Promise<boolean>;
|
|
384
|
-
|
|
406
|
+
publishPreflight(pkg: CargoPackage, {
|
|
407
|
+
store
|
|
408
|
+
}: {
|
|
409
|
+
store: PlanStore;
|
|
410
|
+
}): PublishPreflight;
|
|
411
|
+
publish(pkg: CargoPackage, _env: {
|
|
412
|
+
store: PlanStore;
|
|
413
|
+
packageStore: PackagePlanStore;
|
|
414
|
+
}): Promise<void>;
|
|
385
415
|
}
|
|
386
416
|
interface CargoPluginOptions {
|
|
417
|
+
/**
|
|
418
|
+
* Update lock file after versioning.
|
|
419
|
+
*
|
|
420
|
+
* @default false
|
|
421
|
+
*/
|
|
422
|
+
updateLockFile?: boolean;
|
|
387
423
|
bumpDep?: (opts: {
|
|
388
424
|
kind: (typeof DEP_FIELDS)[number];
|
|
389
425
|
name: string;
|
|
@@ -391,6 +427,7 @@ interface CargoPluginOptions {
|
|
|
391
427
|
}) => BumpType | false;
|
|
392
428
|
}
|
|
393
429
|
declare function cargo({
|
|
430
|
+
updateLockFile,
|
|
394
431
|
bumpDep: getBumpDepType
|
|
395
432
|
}?: CargoPluginOptions): TegamiPlugin;
|
|
396
433
|
//#endregion
|
|
@@ -403,7 +440,7 @@ interface LogGenerator {
|
|
|
403
440
|
version: string;
|
|
404
441
|
changelogs: ChangelogEntry[];
|
|
405
442
|
plan: PackagePlan;
|
|
406
|
-
|
|
443
|
+
unstable_draft: DraftPlan;
|
|
407
444
|
}): string | Promise<string>;
|
|
408
445
|
}
|
|
409
446
|
interface TegamiOptions<Groups extends string = string> {
|
|
@@ -486,14 +523,22 @@ type Awaitable<T> = T | Promise<T>;
|
|
|
486
523
|
interface PublishPlanStatus {
|
|
487
524
|
state: "pending" | "success" | "missing";
|
|
488
525
|
}
|
|
526
|
+
interface PublishPreflight {
|
|
527
|
+
/** Package ids that must be published before this one, this will automatically disallow circular dependency. */
|
|
528
|
+
wait: string[];
|
|
529
|
+
}
|
|
489
530
|
interface RegistryClient {
|
|
490
531
|
id: string;
|
|
491
532
|
supports(pkg: WorkspacePackage): boolean;
|
|
492
533
|
isPackagePublished(pkg: WorkspacePackage): Promise<boolean>;
|
|
534
|
+
publishPreflight?(pkg: WorkspacePackage, env: {
|
|
535
|
+
store: PlanStore;
|
|
536
|
+
packageStore: PackagePlanStore;
|
|
537
|
+
}): Awaitable<PublishPreflight | void | undefined>;
|
|
493
538
|
publish(pkg: WorkspacePackage, env: {
|
|
494
539
|
store: PlanStore;
|
|
495
540
|
packageStore: PackagePlanStore;
|
|
496
541
|
}): Promise<void>;
|
|
497
542
|
}
|
|
498
543
|
//#endregion
|
|
499
|
-
export {
|
|
544
|
+
export { PackagePlan as A, PublishOptions as C, PackageGroup as D, PackageGraph as E, WorkspacePackage as O, PackagePublishResult as S, TegamiContext as T, npm as _, PublishPreflight as a, CreateChangelogOptions as b, TegamiPlugin as c, CargoPluginOptions as d, CargoRegistryClient as f, NpmRegistryClient as g, NpmPluginOptions as h, PackageOptions as i, DraftPlan as k, TegamiPluginOption as l, NpmPackage as m, GroupOptions as n, RegistryClient as o, cargo as p, LogGenerator as r, TegamiOptions as s, Awaitable as t, CargoPackage as u, Tegami as v, PublishResult as w, CreatedChangelog as x, tegami as y };
|