tegami 0.0.1 → 0.1.0-beta.1
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-CKBRRjgQ.js +100 -0
- package/dist/cli/{index.d.mts → index.d.ts} +2 -2
- package/dist/cli/{index.mjs → index.js} +78 -55
- package/dist/error-DBK-9uBa.js +23 -0
- package/dist/generators/{simple.d.mts → simple.d.ts} +1 -1
- package/dist/generators/{simple.mjs → simple.js} +3 -3
- package/dist/graph-CUgwuRW5.js +107 -0
- package/dist/index-Da6P6gSc.d.ts +467 -0
- package/dist/index.d.ts +2 -0
- package/dist/{index.mjs → index.js} +182 -194
- package/dist/plugins/{git.d.mts → git.d.ts} +1 -1
- package/dist/plugins/git.js +84 -0
- package/dist/plugins/{github.d.mts → github.d.ts} +23 -9
- package/dist/plugins/github.js +187 -0
- package/dist/providers/cargo.d.ts +2 -0
- package/dist/providers/{cargo.mjs → cargo.js} +110 -52
- package/dist/providers/npm.d.ts +2 -0
- package/dist/providers/npm.js +288 -0
- package/dist/schemas-Cc4h6bq5.js +41 -0
- package/dist/semver-mWK2Khi2.js +33 -0
- package/package.json +22 -22
- package/dist/context-CC36jtz1.d.mts +0 -297
- package/dist/exec-hOS852t5.mjs +0 -12
- package/dist/index-DJ7YxxdM.d.mts +0 -35
- package/dist/index.d.mts +0 -3
- package/dist/npm-BpFlXy8I.mjs +0 -281
- package/dist/plugins/git.mjs +0 -99
- package/dist/plugins/github.mjs +0 -146
- package/dist/providers/cargo.d.mts +0 -32
- package/dist/providers/npm.d.mts +0 -2
- package/dist/providers/npm.mjs +0 -2
- package/dist/semver-FSWx3_34.mjs +0 -35
- package/dist/workspace-B5_i21S0.mjs +0 -63
- /package/dist/{constants-B9qjNfvr.mjs → constants-B9qjNfvr.js} +0 -0
package/dist/plugins/git.mjs
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { t as execFailure } from "../exec-hOS852t5.mjs";
|
|
2
|
-
import { t as isCI } from "../constants-B9qjNfvr.mjs";
|
|
3
|
-
import { x } from "tinyexec";
|
|
4
|
-
//#region src/plugins/git.ts
|
|
5
|
-
/**
|
|
6
|
-
* Basic Git integrations:
|
|
7
|
-
* - auto tags.
|
|
8
|
-
*
|
|
9
|
-
* Note: you do not need this with `github` plugin enabled.
|
|
10
|
-
*/
|
|
11
|
-
function git(options = {}) {
|
|
12
|
-
const { createTags = true, pushTags = isCI() } = options;
|
|
13
|
-
return {
|
|
14
|
-
name: "git",
|
|
15
|
-
enforce: "pre",
|
|
16
|
-
cli: { async init() {
|
|
17
|
-
if (!isCI()) return;
|
|
18
|
-
const gitOptions = { nodeOptions: { cwd: this.cwd } };
|
|
19
|
-
for (const args of [[
|
|
20
|
-
"config",
|
|
21
|
-
"user.name",
|
|
22
|
-
"github-actions[bot]"
|
|
23
|
-
], [
|
|
24
|
-
"config",
|
|
25
|
-
"user.email",
|
|
26
|
-
"41898282+github-actions[bot]@users.noreply.github.com"
|
|
27
|
-
]]) {
|
|
28
|
-
const result = await x("git", [...args], gitOptions);
|
|
29
|
-
if (result.exitCode !== 0) throw new Error(execFailure("Failed to configure git user for GitHub Actions.", result));
|
|
30
|
-
}
|
|
31
|
-
} },
|
|
32
|
-
async afterPublish(result) {
|
|
33
|
-
const { cwd, graph, publishOptions: { dryRun = false } } = this;
|
|
34
|
-
if (dryRun || !createTags || result.state !== "created") return result;
|
|
35
|
-
const createdTags = [];
|
|
36
|
-
for (const pkg of result.packages) try {
|
|
37
|
-
const gitTag = `${pkg.name}@${pkg.version}`;
|
|
38
|
-
const packagePath = graph.get(pkg.id).path;
|
|
39
|
-
if (await createGitTag(packagePath, gitTag)) createdTags.push(gitTag);
|
|
40
|
-
pkg.gitTag = gitTag;
|
|
41
|
-
} catch (error) {
|
|
42
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
43
|
-
return {
|
|
44
|
-
...result,
|
|
45
|
-
state: "failed",
|
|
46
|
-
error: errorMessage,
|
|
47
|
-
packages: result.packages.map((pkgResult) => {
|
|
48
|
-
if (pkgResult.id === pkg.id) return {
|
|
49
|
-
...pkgResult,
|
|
50
|
-
state: "failed",
|
|
51
|
-
error: errorMessage
|
|
52
|
-
};
|
|
53
|
-
return pkgResult;
|
|
54
|
-
})
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
if (pushTags && createdTags.length > 0) try {
|
|
58
|
-
await pushGitTags(cwd, createdTags);
|
|
59
|
-
} catch (error) {
|
|
60
|
-
return {
|
|
61
|
-
...result,
|
|
62
|
-
state: "failed",
|
|
63
|
-
error: error instanceof Error ? error.message : String(error)
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
/** create a Git tag, ignored if already exists */
|
|
71
|
-
async function createGitTag(cwd, tag) {
|
|
72
|
-
if (await gitTagExists(cwd, tag)) return false;
|
|
73
|
-
await x("git", ["tag", tag], {
|
|
74
|
-
nodeOptions: { cwd },
|
|
75
|
-
throwOnError: true
|
|
76
|
-
});
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
async function gitTagExists(cwd, tag) {
|
|
80
|
-
return (await x("git", [
|
|
81
|
-
"rev-parse",
|
|
82
|
-
"-q",
|
|
83
|
-
"--verify",
|
|
84
|
-
`refs/tags/${tag}`
|
|
85
|
-
], { nodeOptions: { cwd } })).exitCode === 0;
|
|
86
|
-
}
|
|
87
|
-
async function pushGitTags(cwd, tags) {
|
|
88
|
-
if (tags.length === 0) return;
|
|
89
|
-
await x("git", [
|
|
90
|
-
"push",
|
|
91
|
-
"origin",
|
|
92
|
-
...tags
|
|
93
|
-
], {
|
|
94
|
-
nodeOptions: { cwd },
|
|
95
|
-
throwOnError: true
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
//#endregion
|
|
99
|
-
export { git };
|
package/dist/plugins/github.mjs
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { t as execFailure } from "../exec-hOS852t5.mjs";
|
|
2
|
-
import { a as previousVersion, r as formatVersionBump } from "../semver-FSWx3_34.mjs";
|
|
3
|
-
import { t as isCI } from "../constants-B9qjNfvr.mjs";
|
|
4
|
-
import { git } from "./git.mjs";
|
|
5
|
-
import { x } from "tinyexec";
|
|
6
|
-
//#region src/plugins/github.ts
|
|
7
|
-
/** Create GitHub releases for successfully published packages after the whole plan succeeds. */
|
|
8
|
-
function github(options = {}) {
|
|
9
|
-
async function createGithubRelease(pkg) {
|
|
10
|
-
if (!pkg.gitTag) return;
|
|
11
|
-
const release = await options.onCreateRelease?.(pkg) ?? {};
|
|
12
|
-
if (release === false) return;
|
|
13
|
-
const args = [
|
|
14
|
-
"release",
|
|
15
|
-
"create",
|
|
16
|
-
pkg.gitTag,
|
|
17
|
-
"--title",
|
|
18
|
-
release.title ?? `${pkg.name}@${pkg.version}`,
|
|
19
|
-
"--notes",
|
|
20
|
-
release.notes ?? defaultNotes(pkg)
|
|
21
|
-
];
|
|
22
|
-
if (options.repo) args.push("--repo", options.repo);
|
|
23
|
-
if (release.prerelease) args.push("--prerelease");
|
|
24
|
-
const result = await x("gh", args);
|
|
25
|
-
if (result.exitCode !== 0) throw new Error(execFailure(`Failed to create GitHub release for ${pkg.name}@${pkg.version}.`, result));
|
|
26
|
-
}
|
|
27
|
-
function resolvePROptions() {
|
|
28
|
-
const setting = options.cli?.createVersionPR ?? isCI();
|
|
29
|
-
if (setting === false) return [false];
|
|
30
|
-
return [true, typeof setting === "object" ? setting : {}];
|
|
31
|
-
}
|
|
32
|
-
return [git(options), {
|
|
33
|
-
name: "github",
|
|
34
|
-
cli: {
|
|
35
|
-
async init() {
|
|
36
|
-
if (!isCI()) return;
|
|
37
|
-
const token = process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN;
|
|
38
|
-
const repository = options.repo ?? process.env.GITHUB_REPOSITORY;
|
|
39
|
-
if (!token || !repository) return;
|
|
40
|
-
const result = await x("git", [
|
|
41
|
-
"remote",
|
|
42
|
-
"set-url",
|
|
43
|
-
"origin",
|
|
44
|
-
`https://x-access-token:${token}@github.com/${repository}.git`
|
|
45
|
-
], { nodeOptions: { cwd: this.cwd } });
|
|
46
|
-
if (result.exitCode !== 0) throw new Error(execFailure("Failed to configure git remote for GitHub Actions.", result));
|
|
47
|
-
},
|
|
48
|
-
async afterVersion(draft) {
|
|
49
|
-
const { cwd } = this;
|
|
50
|
-
const [enabled, config] = resolvePROptions();
|
|
51
|
-
if (!enabled || !await hasGitChanges(cwd)) return;
|
|
52
|
-
const { branch = "tegami/version-packages", base = "main", title = "Version Packages", body = defaultVersionPRBody(draft, this) } = config;
|
|
53
|
-
const gitOptions = { nodeOptions: { cwd } };
|
|
54
|
-
let result = await x("git", [
|
|
55
|
-
"checkout",
|
|
56
|
-
"-B",
|
|
57
|
-
branch
|
|
58
|
-
], gitOptions);
|
|
59
|
-
if (result.exitCode !== 0) throw new Error(execFailure("Failed to create the version pull request branch.", result));
|
|
60
|
-
result = await x("git", ["add", "-A"], gitOptions);
|
|
61
|
-
if (result.exitCode !== 0) throw new Error(execFailure("Failed to stage version changes.", result));
|
|
62
|
-
result = await x("git", [
|
|
63
|
-
"commit",
|
|
64
|
-
"-m",
|
|
65
|
-
title
|
|
66
|
-
], gitOptions);
|
|
67
|
-
if (result.exitCode !== 0) throw new Error(execFailure("Failed to commit version changes.", result));
|
|
68
|
-
result = await x("git", [
|
|
69
|
-
"push",
|
|
70
|
-
"--force",
|
|
71
|
-
"-u",
|
|
72
|
-
"origin",
|
|
73
|
-
branch
|
|
74
|
-
], gitOptions);
|
|
75
|
-
if (result.exitCode !== 0) throw new Error(execFailure("Failed to push the version branch to origin. Ensure `origin` is configured and you have push access.", result));
|
|
76
|
-
if (await hasOpenPullRequest(branch, options.repo)) return;
|
|
77
|
-
const args = [
|
|
78
|
-
"pr",
|
|
79
|
-
"create",
|
|
80
|
-
"--title",
|
|
81
|
-
title,
|
|
82
|
-
"--body",
|
|
83
|
-
body,
|
|
84
|
-
"--head",
|
|
85
|
-
branch,
|
|
86
|
-
"--base",
|
|
87
|
-
base
|
|
88
|
-
];
|
|
89
|
-
if (options.repo) args.push("--repo", options.repo);
|
|
90
|
-
const prResult = await x("gh", args);
|
|
91
|
-
if (prResult.exitCode !== 0) throw new Error(execFailure("Failed to create the version pull request.", prResult));
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
async afterPublish(result) {
|
|
95
|
-
if (result.state !== "created") return;
|
|
96
|
-
await Promise.all(result.packages.map(createGithubRelease));
|
|
97
|
-
}
|
|
98
|
-
}];
|
|
99
|
-
}
|
|
100
|
-
async function hasGitChanges(cwd) {
|
|
101
|
-
return (await x("git", ["status", "--porcelain"], { nodeOptions: { cwd } })).stdout.trim().length > 0;
|
|
102
|
-
}
|
|
103
|
-
async function hasOpenPullRequest(branch, repo) {
|
|
104
|
-
const args = [
|
|
105
|
-
"pr",
|
|
106
|
-
"list",
|
|
107
|
-
"--head",
|
|
108
|
-
branch,
|
|
109
|
-
"--state",
|
|
110
|
-
"open",
|
|
111
|
-
"--json",
|
|
112
|
-
"number"
|
|
113
|
-
];
|
|
114
|
-
if (repo) args.push("--repo", repo);
|
|
115
|
-
const result = await x("gh", args);
|
|
116
|
-
if (result.exitCode !== 0) throw new Error(execFailure("Failed to check for an existing version pull request.", result));
|
|
117
|
-
return result.stdout.trim() !== "[]";
|
|
118
|
-
}
|
|
119
|
-
function defaultVersionPRBody(draft, context) {
|
|
120
|
-
const packageLines = [];
|
|
121
|
-
for (const id of draft.getPackageIds()) {
|
|
122
|
-
const packagePlan = draft.getPackage(id);
|
|
123
|
-
if (!packagePlan) continue;
|
|
124
|
-
const pkg = context.graph.get(id);
|
|
125
|
-
if (!pkg) continue;
|
|
126
|
-
const publish = packagePlan.publish ? "" : " (no publish)";
|
|
127
|
-
const previous = previousVersion(pkg.version, packagePlan.type);
|
|
128
|
-
packageLines.push(`- ${formatVersionBump(pkg.name, previous, pkg.version, packagePlan.distTag)}${publish}`);
|
|
129
|
-
}
|
|
130
|
-
const changelogLines = draft.getChangelogIds().map((id) => draft.getChangelog(id)).filter((entry) => entry !== void 0).map((entry) => `- ${entry.title}`);
|
|
131
|
-
const sections = ["## Summary", ...packageLines];
|
|
132
|
-
if (changelogLines.length > 0) sections.push("", "## Changelogs", ...changelogLines);
|
|
133
|
-
sections.push("", "Merge this PR to publish the versioned packages.");
|
|
134
|
-
return sections.join("\n");
|
|
135
|
-
}
|
|
136
|
-
function defaultNotes(pkg) {
|
|
137
|
-
const entries = pkg.changelogs;
|
|
138
|
-
if (entries.length > 0) return entries.map((entry) => [`### ${entry.title}`, entry.content].filter(Boolean).join("\n\n")).join("\n\n");
|
|
139
|
-
return [
|
|
140
|
-
`Published ${pkg.name}@${pkg.version}.`,
|
|
141
|
-
"",
|
|
142
|
-
`npm dist-tag: ${pkg.distTag}`
|
|
143
|
-
].join("\n");
|
|
144
|
-
}
|
|
145
|
-
//#endregion
|
|
146
|
-
export { github };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { a as RegistryClient, i as PublishPlanStatus, m as WorkspacePackage, p as PackageGraph, s as TegamiPlugin, t as TegamiContext, v as PlanStore } from "../context-CC36jtz1.mjs";
|
|
2
|
-
import { TomlTable } from "smol-toml";
|
|
3
|
-
|
|
4
|
-
//#region src/providers/cargo.d.ts
|
|
5
|
-
declare class CargoPackage extends WorkspacePackage {
|
|
6
|
-
readonly path: string;
|
|
7
|
-
readonly manifest: TomlTable;
|
|
8
|
-
private readonly workspaceManifest?;
|
|
9
|
-
readonly manager = "cargo";
|
|
10
|
-
constructor(path: string, manifest: TomlTable, workspaceManifest?: TomlTable | undefined);
|
|
11
|
-
get name(): string;
|
|
12
|
-
get version(): string;
|
|
13
|
-
get publish(): boolean;
|
|
14
|
-
setVersion(version: string): void;
|
|
15
|
-
updateDependency(target: WorkspacePackage, version: string, context: TegamiContext): Promise<void>;
|
|
16
|
-
write(): Promise<void>;
|
|
17
|
-
private get packageInfo();
|
|
18
|
-
private get workspaceVersion();
|
|
19
|
-
}
|
|
20
|
-
declare class CargoRegistryClient implements RegistryClient {
|
|
21
|
-
#private;
|
|
22
|
-
private readonly graph;
|
|
23
|
-
readonly id = "cargo";
|
|
24
|
-
constructor(graph: PackageGraph);
|
|
25
|
-
supports(pkg: WorkspacePackage): boolean;
|
|
26
|
-
packageVersionExists(pkg: WorkspacePackage, version: string): Promise<boolean>;
|
|
27
|
-
publish(pkg: WorkspacePackage): Promise<void>;
|
|
28
|
-
publishPlanStatus(plan: PlanStore): Promise<PublishPlanStatus>;
|
|
29
|
-
}
|
|
30
|
-
declare function cargo(): TegamiPlugin;
|
|
31
|
-
//#endregion
|
|
32
|
-
export { CargoPackage, CargoRegistryClient, cargo };
|
package/dist/providers/npm.d.mts
DELETED
package/dist/providers/npm.mjs
DELETED
package/dist/semver-FSWx3_34.mjs
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { inc, parse } from "semver";
|
|
2
|
-
//#region src/utils/semver.ts
|
|
3
|
-
function formatPackageVersion(name, version, distTag) {
|
|
4
|
-
return `${name}@${version}${distTag ? ` (${distTag})` : ""}`;
|
|
5
|
-
}
|
|
6
|
-
function previousVersion(version, type) {
|
|
7
|
-
const parsed = parse(version);
|
|
8
|
-
if (!parsed) throw new Error(`Invalid semver version: ${version}`);
|
|
9
|
-
if (type === "major") {
|
|
10
|
-
parsed.major = Math.max(0, parsed.major - 1);
|
|
11
|
-
parsed.minor = 0;
|
|
12
|
-
parsed.patch = 0;
|
|
13
|
-
} else if (type === "minor") {
|
|
14
|
-
parsed.minor = Math.max(0, parsed.minor - 1);
|
|
15
|
-
parsed.patch = 0;
|
|
16
|
-
} else parsed.patch = Math.max(0, parsed.patch - 1);
|
|
17
|
-
parsed.prerelease = [];
|
|
18
|
-
parsed.build = [];
|
|
19
|
-
return parsed.format();
|
|
20
|
-
}
|
|
21
|
-
function formatVersionBump(name, from, to, distTag) {
|
|
22
|
-
return `${name}@${from} → ${name}@${to}${distTag ? ` (${distTag})` : ""}`;
|
|
23
|
-
}
|
|
24
|
-
function maxBump(a, b) {
|
|
25
|
-
if (a === "major" || b === "major") return "major";
|
|
26
|
-
if (a === "minor" || b === "minor") return "minor";
|
|
27
|
-
return "patch";
|
|
28
|
-
}
|
|
29
|
-
function bumpVersion(version, type) {
|
|
30
|
-
const next = inc(version, type);
|
|
31
|
-
if (!next) throw new Error(`Invalid semver version: ${version}`);
|
|
32
|
-
return next;
|
|
33
|
-
}
|
|
34
|
-
//#endregion
|
|
35
|
-
export { previousVersion as a, maxBump as i, formatPackageVersion as n, formatVersionBump as r, bumpVersion as t };
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import * as semver from "semver";
|
|
2
|
-
//#region src/utils/error.ts
|
|
3
|
-
function isNodeError(error) {
|
|
4
|
-
return error instanceof Error && "code" in error;
|
|
5
|
-
}
|
|
6
|
-
//#endregion
|
|
7
|
-
//#region src/workspace.ts
|
|
8
|
-
/** Package discovered in the workspace. */
|
|
9
|
-
var WorkspacePackage = class {
|
|
10
|
-
get distTag() {}
|
|
11
|
-
get id() {
|
|
12
|
-
return `${this.manager}:${this.name}`;
|
|
13
|
-
}
|
|
14
|
-
async updateRange(context, spec, next) {
|
|
15
|
-
for (const plugin of context.plugins) {
|
|
16
|
-
const result = await plugin.onUpdateRange?.call(context, this, spec, next);
|
|
17
|
-
if (result) return result;
|
|
18
|
-
}
|
|
19
|
-
if (!semver.validRange(spec.range)) return spec;
|
|
20
|
-
if (new semver.Range(spec.range).test(next)) return spec;
|
|
21
|
-
spec.range = next.format();
|
|
22
|
-
return spec;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
/** Dependency graph for discovered workspace packages. */
|
|
26
|
-
var PackageGraph = class {
|
|
27
|
-
byId = /* @__PURE__ */ new Map();
|
|
28
|
-
byName = /* @__PURE__ */ new Map();
|
|
29
|
-
constructor(packages = []) {
|
|
30
|
-
for (const pkg of packages) this.add(pkg);
|
|
31
|
-
}
|
|
32
|
-
getPackages() {
|
|
33
|
-
return Array.from(this.byId.values());
|
|
34
|
-
}
|
|
35
|
-
/** Get a package by exact id. */
|
|
36
|
-
get(id) {
|
|
37
|
-
return this.byId.get(id);
|
|
38
|
-
}
|
|
39
|
-
/** Get packages by id, or every package matching a name. */
|
|
40
|
-
getByName(nameOrId) {
|
|
41
|
-
const exact = this.byId.get(nameOrId);
|
|
42
|
-
if (exact) return [exact];
|
|
43
|
-
return this.byName.get(nameOrId) ?? [];
|
|
44
|
-
}
|
|
45
|
-
/** scan package into graph, if the package id already exists, replace the existing one in graph */
|
|
46
|
-
add(pkg) {
|
|
47
|
-
const existing = this.byId.get(pkg.id);
|
|
48
|
-
if (existing) this.delete(existing);
|
|
49
|
-
this.byId.set(pkg.id, pkg);
|
|
50
|
-
const named = this.byName.get(pkg.name);
|
|
51
|
-
if (named) named.push(pkg);
|
|
52
|
-
else this.byName.set(pkg.name, [pkg]);
|
|
53
|
-
}
|
|
54
|
-
delete(pkg) {
|
|
55
|
-
this.byId.delete(pkg.id);
|
|
56
|
-
const named = this.byName.get(pkg.name);
|
|
57
|
-
if (!named) return;
|
|
58
|
-
const index = named.findIndex((item) => item.id === pkg.id);
|
|
59
|
-
if (index !== -1) named.splice(index, 1);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
//#endregion
|
|
63
|
-
export { WorkspacePackage as n, isNodeError as r, PackageGraph as t };
|
|
File without changes
|