tegami 1.0.1 → 1.0.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.
@@ -1,4 +1,4 @@
1
- import { T as Draft, p as Tegami, t as Awaitable, y as PublishPlan } from "../types-DItu_YCc.js";
1
+ import { k as Draft, p as Tegami, t as Awaitable, y as PublishPlan } from "../types-DHddSAez.js";
2
2
 
3
3
  //#region src/cli/index.d.ts
4
4
  interface TegamiCLIOptions {
package/dist/cli/index.js CHANGED
@@ -124,14 +124,11 @@ async function promptPackageSelection(graph, cwd) {
124
124
  groups.push([group, changed]);
125
125
  }
126
126
  groups.sort((a, b) => (a[1] ? 0 : 1) - (b[1] ? 0 : 1));
127
- for (const [group, changed] of groups) {
128
- if (changed) initialValues.add(`group:${group.name}`);
129
- selectOptions.push({
130
- label: `(Group) ${group.name}` + (changed ? "*" : ""),
131
- value: `group:${group.name}`,
132
- hint: group.packages.map(getPackageLabel).join(", ")
133
- });
134
- }
127
+ for (const [group, changed] of groups) selectOptions.push({
128
+ label: `(Group) ${group.name}` + (changed ? "*" : ""),
129
+ value: `group:${group.name}`,
130
+ hint: group.packages.map(getPackageLabel).join(", ")
131
+ });
135
132
  const packages = graph.getPackages().toSorted((a, b) => (changedPackages.has(a) ? 0 : 1) - (changedPackages.has(b) ? 0 : 1));
136
133
  for (const pkg of packages) {
137
134
  const changed = changedPackages.has(pkg);
@@ -1,4 +1,4 @@
1
- import { r as LogGenerator } from "../types-DItu_YCc.js";
1
+ import { r as LogGenerator } from "../types-DHddSAez.js";
2
2
 
3
3
  //#region src/generators/simple.d.ts
4
4
  declare function simpleGenerator(): LogGenerator;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { C as PackageGroup, D as PackageDraft, E as DraftPolicy, O as BumpType, S as PackageGraph, T as Draft, _ as PackagePublishResult, a as PublishPreflight, b as CommitChangelog, c as TegamiPluginOption, f as GenerateChangelogOptions, g as PackagePublishPlan, h as PublishLock, i as PackageOptions, m as tegami, n as GroupOptions, o as TegamiOptions, p as Tegami, r as LogGenerator, s as TegamiPlugin, v as PublishOptions, w as WorkspacePackage, x as TegamiContext, y as PublishPlan } from "./types-DItu_YCc.js";
1
+ import { A as DraftPolicy, D as PackageGroup, E as PackageGraph, M as BumpType, O as WorkspacePackage, _ as PackagePublishResult, a as PublishPreflight, b as CommitChangelog, c as TegamiPluginOption, f as GenerateChangelogOptions, g as PackagePublishPlan, h as PublishLock, i as PackageOptions, j as PackageDraft, k as Draft, m as tegami, n as GroupOptions, o as TegamiOptions, p as Tegami, r as LogGenerator, s as TegamiPlugin, v as PublishOptions, x as TegamiContext, y as PublishPlan } from "./types-DHddSAez.js";
2
2
  export { type BumpType, type CommitChangelog, type Draft, type DraftPolicy, GenerateChangelogOptions, type GroupOptions, type LogGenerator, type PackageDraft, PackageGraph, type PackageGroup, type PackageOptions, type PackagePublishPlan, type PackagePublishResult, type PublishLock, type PublishOptions, type PublishPlan, type PublishPreflight, Tegami, type TegamiContext, type TegamiOptions, type TegamiPlugin, type TegamiPluginOption, WorkspacePackage, tegami };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as generateFromCommits } from "./generate-Rvz4Lu98.js";
2
2
  import { r as handlePluginError } from "./error-BhMYq9iW.js";
3
- import { a as runPreflights, i as publishPlanStatus, n as npm, o as runPublishPlan, r as initPublishPlan } from "./npm-1iEegfHg.js";
3
+ import { a as runPreflights, i as publishPlanStatus, n as npm, o as runPublishPlan, r as initPublishPlan } from "./npm-5cG02krT.js";
4
4
  import { n as WorkspacePackage, t as PackageGraph } from "./graph-gThXu8Cz.js";
5
5
  import { a as parseChangelogFile, n as createDraft, o as readChangelogEntries } from "./draft-BqHcSCeX.js";
6
6
  import { mkdir, rm, writeFile } from "node:fs/promises";
@@ -133,27 +133,25 @@ async function runPublishPlan(context, plan) {
133
133
  }
134
134
  async function runPreflights(context, plan) {
135
135
  const promises = [];
136
- const runPreflight = async (pkg) => {
137
- for (const plugin of context.plugins) {
138
- const res = await handlePluginError(plugin, "publishPreflight", () => plugin.publishPreflight?.call(context, {
139
- pkg,
140
- plan
141
- }));
142
- if (res) return res;
143
- }
144
- return { shouldPublish: false };
145
- };
146
136
  for (const [id, packagePlan] of plan.packages) {
147
137
  const pkg = context.graph.get(id);
148
- if (!packagePlan.updated) {
149
- packagePlan.preflight = { shouldPublish: false };
150
- continue;
151
- }
152
- promises.push(runPreflight(pkg).then((preflight) => {
153
- packagePlan.preflight = preflight;
154
- }));
138
+ packagePlan.preflight = { shouldPublish: false };
139
+ if (!packagePlan.updated) continue;
140
+ promises.push((async () => {
141
+ for (const plugin of context.plugins) {
142
+ const res = await handlePluginError(plugin, "publishPreflight", () => plugin.publishPreflight?.call(context, {
143
+ pkg,
144
+ plan
145
+ }));
146
+ if (res) {
147
+ packagePlan.preflight = res;
148
+ break;
149
+ }
150
+ }
151
+ })());
155
152
  }
156
153
  await Promise.all(promises);
154
+ for (const plugin of context.plugins) await handlePluginError(plugin, "afterPreflight", () => plugin.afterPreflight?.call(context, { plan }));
157
155
  }
158
156
  async function publishPlanStatus(plan, context) {
159
157
  for (const plugin of context.plugins) {
@@ -1,97 +1,2 @@
1
- import { O as BumpType, s as TegamiPlugin, w as WorkspacePackage } from "../types-DItu_YCc.js";
2
- import z from "zod";
3
-
4
- //#region src/plugins/cargo/schema.d.ts
5
- declare const cargoManifestSchema: z.ZodObject<{
6
- package: z.ZodObject<{
7
- name: z.ZodString;
8
- version: z.ZodOptional<z.ZodString>;
9
- publish: z.ZodOptional<z.ZodBoolean>;
10
- }, z.core.$strip>;
11
- workspace: z.ZodOptional<z.ZodObject<{
12
- members: z.ZodOptional<z.ZodArray<z.ZodString>>;
13
- exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
14
- package: z.ZodOptional<z.ZodObject<{
15
- version: z.ZodOptional<z.ZodString>;
16
- }, z.core.$strip>>;
17
- }, z.core.$strip>>;
18
- dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
19
- version: z.ZodString;
20
- package: z.ZodOptional<z.ZodString>;
21
- path: z.ZodOptional<z.ZodString>;
22
- }, z.core.$strip>]>>>;
23
- "dev-dependencies": z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
24
- version: z.ZodString;
25
- package: z.ZodOptional<z.ZodString>;
26
- path: z.ZodOptional<z.ZodString>;
27
- }, z.core.$strip>]>>>;
28
- "build-dependencies": z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
29
- version: z.ZodString;
30
- package: z.ZodOptional<z.ZodString>;
31
- path: z.ZodOptional<z.ZodString>;
32
- }, z.core.$strip>]>>>;
33
- target: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
34
- dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
35
- version: z.ZodString;
36
- package: z.ZodOptional<z.ZodString>;
37
- path: z.ZodOptional<z.ZodString>;
38
- }, z.core.$strip>]>>>;
39
- "dev-dependencies": z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
40
- version: z.ZodString;
41
- package: z.ZodOptional<z.ZodString>;
42
- path: z.ZodOptional<z.ZodString>;
43
- }, z.core.$strip>]>>>;
44
- "build-dependencies": z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
45
- version: z.ZodString;
46
- package: z.ZodOptional<z.ZodString>;
47
- path: z.ZodOptional<z.ZodString>;
48
- }, z.core.$strip>]>>>;
49
- }, z.core.$strip>>>;
50
- }, z.core.$strip>;
51
- type CargoManifest = z.infer<typeof cargoManifestSchema>;
52
- //#endregion
53
- //#region src/plugins/cargo.d.ts
54
- declare const DEP_FIELDS: readonly ["dependencies", "dev-dependencies", "build-dependencies"];
55
- declare class CargoPackage extends WorkspacePackage {
56
- readonly path: string;
57
- readonly manifest: CargoManifest;
58
- private content;
59
- private readonly workspaceManifest?;
60
- readonly manager = "cargo";
61
- constructor(path: string, manifest: CargoManifest, content: string, workspaceManifest?: CargoManifest | undefined);
62
- get name(): string;
63
- get version(): string | undefined;
64
- setVersion(version: string): void;
65
- write(): Promise<void>;
66
- patch(path: string, value: unknown): void;
67
- get packageInfo(): {
68
- name: string;
69
- version?: string | undefined;
70
- publish?: boolean | undefined;
71
- };
72
- private get workspaceVersion();
73
- }
74
- interface DependentRef {
75
- dependent: CargoPackage;
76
- kind: (typeof DEP_FIELDS)[number];
77
- name: string;
78
- version: string;
79
- }
80
- interface CargoPluginOptions {
81
- /**
82
- * Update lock file after versioning.
83
- *
84
- * @default true
85
- */
86
- updateLockFile?: boolean;
87
- /**
88
- * Decide how to bump the dependents of a bumped package.
89
- */
90
- bumpDep?: (opts: DependentRef) => BumpType | false;
91
- }
92
- declare function cargo({
93
- updateLockFile,
94
- bumpDep: getBumpDepType
95
- }?: CargoPluginOptions): TegamiPlugin;
96
- //#endregion
97
- export { CargoPackage, CargoPluginOptions, cargo };
1
+ import { C as CargoPackage, S as CargoGraph, T as cargo, w as CargoPluginOptions } from "../types-DHddSAez.js";
2
+ export { CargoGraph, CargoPackage, CargoPluginOptions, cargo };
@@ -1,40 +1,76 @@
1
1
  import { n as execFailure } from "../error-BhMYq9iW.js";
2
2
  import { n as WorkspacePackage } from "../graph-gThXu8Cz.js";
3
3
  import { readFile, writeFile } from "node:fs/promises";
4
- import { join, normalize } from "node:path";
4
+ import path from "node:path";
5
5
  import { x } from "tinyexec";
6
6
  import * as semver$1 from "semver";
7
7
  import z from "zod";
8
8
  import { glob } from "tinyglobby";
9
9
  import initToml, { edit, parse as parse$1 } from "@rainbowatcher/toml-edit-js";
10
10
  //#region src/plugins/cargo/schema.ts
11
- const cargoDependencySchema = z.union([z.string(), z.object({
12
- version: z.string(),
11
+ const baseDepSchema = z.object({
13
12
  package: z.string().optional(),
14
- path: z.string().optional()
15
- })]);
16
- const cargoTargetConfigSchema = z.object({
17
- dependencies: z.record(z.string(), cargoDependencySchema).optional(),
18
- "dev-dependencies": z.record(z.string(), cargoDependencySchema).optional(),
19
- "build-dependencies": z.record(z.string(), cargoDependencySchema).optional()
13
+ features: z.array(z.string()).optional(),
14
+ optional: z.boolean().optional(),
15
+ "default-features": z.boolean().optional()
16
+ });
17
+ /** `{ workspace = true }` — inherit from `[workspace.dependencies]` */
18
+ const workspaceDependencySchema = baseDepSchema.extend({ workspace: z.literal(true) });
19
+ /** `{ path = "../lib" }` — optional `version` for publishing */
20
+ const pathDependencySchema = baseDepSchema.extend({
21
+ path: z.string(),
22
+ version: z.string().optional()
23
+ });
24
+ /** `{ git = "…" }` — exactly one of `branch`, `tag`, or `rev` in practice */
25
+ const gitDependencySchema = baseDepSchema.extend({
26
+ git: z.string(),
27
+ branch: z.string().optional(),
28
+ tag: z.string().optional(),
29
+ rev: z.string().optional(),
30
+ version: z.string().optional()
20
31
  });
21
- const cargoPackageSchema = z.object({
22
- name: z.string(),
23
- version: z.string().optional(),
24
- publish: z.boolean().optional()
32
+ /** `{ version = "1.0" }` — crates.io or `[registries]` */
33
+ const registryDependencySchema = baseDepSchema.extend({
34
+ version: z.string(),
35
+ registry: z.string().optional()
25
36
  });
26
- const cargoWorkspaceSchema = z.object({
37
+ /**
38
+ * @see https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html
39
+ */
40
+ const cargoDependencySchema = z.union([
41
+ z.string(),
42
+ workspaceDependencySchema,
43
+ pathDependencySchema,
44
+ gitDependencySchema,
45
+ registryDependencySchema
46
+ ]);
47
+ const cargoInheritSchema = z.looseObject({ workspace: z.literal(true) });
48
+ const cargoWorkspaceSchema = z.looseObject({
27
49
  members: z.array(z.string()).optional(),
28
50
  exclude: z.array(z.string()).optional(),
29
- package: z.object({ version: z.string().optional() }).optional()
51
+ package: z.looseObject({
52
+ version: z.string().optional(),
53
+ publish: z.boolean().optional()
54
+ }).optional(),
55
+ dependencies: z.record(z.string(), cargoDependencySchema).optional(),
56
+ "dev-dependencies": z.record(z.string(), cargoDependencySchema).optional(),
57
+ "build-dependencies": z.record(z.string(), cargoDependencySchema).optional()
30
58
  });
31
- const cargoManifestSchema = z.object({
32
- package: cargoPackageSchema,
59
+ const cargoManifestSchema = z.looseObject({
60
+ package: z.looseObject({
61
+ name: z.string(),
62
+ version: z.string().or(cargoInheritSchema),
63
+ publish: z.boolean().or(cargoInheritSchema).optional()
64
+ }).optional(),
33
65
  workspace: cargoWorkspaceSchema.optional(),
34
66
  dependencies: z.record(z.string(), cargoDependencySchema).optional(),
35
67
  "dev-dependencies": z.record(z.string(), cargoDependencySchema).optional(),
36
68
  "build-dependencies": z.record(z.string(), cargoDependencySchema).optional(),
37
- target: z.record(z.string(), cargoTargetConfigSchema).optional()
69
+ target: z.record(z.string(), z.looseObject({
70
+ dependencies: z.record(z.string(), cargoDependencySchema).optional(),
71
+ "dev-dependencies": z.record(z.string(), cargoDependencySchema).optional(),
72
+ "build-dependencies": z.record(z.string(), cargoDependencySchema).optional()
73
+ })).optional()
38
74
  });
39
75
  //#endregion
40
76
  //#region src/plugins/cargo.ts
@@ -45,42 +81,46 @@ const DEP_FIELDS = [
45
81
  ];
46
82
  var CargoPackage = class extends WorkspacePackage {
47
83
  path;
48
- manifest;
49
- content;
50
- workspaceManifest;
84
+ file;
85
+ workspaceFile;
51
86
  manager = "cargo";
52
- constructor(path, manifest, content, workspaceManifest) {
87
+ manifest;
88
+ constructor(path, file, workspaceFile) {
53
89
  super();
54
90
  this.path = path;
55
- this.manifest = manifest;
56
- this.content = content;
57
- this.workspaceManifest = workspaceManifest;
91
+ this.file = file;
92
+ this.workspaceFile = workspaceFile;
93
+ this.manifest = file.data;
58
94
  }
59
95
  get name() {
60
- return this.packageInfo.name;
96
+ return this.manifest.package.name;
61
97
  }
62
98
  get version() {
63
- return this.packageInfo.version ?? this.workspaceVersion;
99
+ const packageVersion = this.manifest.package.version;
100
+ if (typeof packageVersion === "string") return packageVersion;
101
+ const inherited = this.workspaceFile?.data.workspace.package;
102
+ if (packageVersion.workspace && inherited?.version) return inherited.version;
103
+ throw new Error(`Invalid Cargo.toml in "${this.path}".`);
64
104
  }
65
105
  setVersion(version) {
66
- this.packageInfo.version = version;
67
- this.patch("package.version", version);
68
- }
69
- async write() {
70
- await writeFile(join(this.path, "Cargo.toml"), this.content + "\n");
71
- }
72
- patch(path, value) {
73
- this.content = edit(this.content, path, value);
74
- }
75
- get packageInfo() {
76
- return this.manifest.package;
77
- }
78
- get workspaceVersion() {
79
- return this.workspaceManifest?.workspace?.package?.version;
106
+ const packageInfo = this.manifest.package;
107
+ if (typeof packageInfo.version === "string") {
108
+ packageInfo.version = version;
109
+ patchFile(this.file, "package.version", version);
110
+ return;
111
+ }
112
+ if (packageInfo.version.workspace && this.workspaceFile?.data.workspace.package) {
113
+ this.workspaceFile.data.workspace.package.version = version;
114
+ patchFile(this.workspaceFile, "workspace.package.version", version);
115
+ return;
116
+ }
117
+ throw new Error(`Invalid Cargo.toml in "${this.path}".`);
80
118
  }
81
119
  };
120
+ function patchFile(file, path, value) {
121
+ file.content = edit(file.content, path, value);
122
+ }
82
123
  function cargo({ updateLockFile = true, bumpDep: getBumpDepType } = {}) {
83
- let active = false;
84
124
  return {
85
125
  name: "cargo",
86
126
  enforce: "pre",
@@ -88,34 +128,37 @@ function cargo({ updateLockFile = true, bumpDep: getBumpDepType } = {}) {
88
128
  await initToml();
89
129
  },
90
130
  async resolve() {
91
- await discoverCargoPackages(this.cwd, (pkg) => this.graph.add(pkg));
92
- active = this.graph.getPackages().some((pkg) => pkg instanceof CargoPackage);
131
+ const graph = await resolveCargoGraph(this.cwd);
132
+ if (graph.packages.size === 0) return;
133
+ this.cargo = { graph };
134
+ for (const pkg of graph.packages.values()) this.graph.add(pkg);
93
135
  },
94
136
  initDraft(plan) {
95
- if (!active) return;
137
+ if (!this.cargo) return;
96
138
  plan.addPolicy(depsPolicy(this, getBumpDepType));
97
139
  },
98
140
  async publishPreflight({ pkg }) {
99
- if (!(pkg instanceof CargoPackage)) return;
141
+ if (!(pkg instanceof CargoPackage) || !this.cargo) return;
142
+ let shouldPublish = true;
143
+ if (typeof pkg.manifest.package.publish === "boolean") shouldPublish = pkg.manifest.package.publish;
144
+ else if (pkg.manifest.package.publish?.workspace) shouldPublish = pkg.workspaceFile?.data.workspace?.package?.publish ?? shouldPublish;
100
145
  const wait = [];
101
- for (const { table } of dependencyTables(pkg.manifest, "")) for (const [rawName, dep] of Object.entries(table)) {
102
- if (!dep || typeof dep === "string" || !dep.path) continue;
103
- const id = `cargo:${dep.package ?? rawName}`;
104
- const linked = this.graph.get(id);
105
- if (!linked || !(linked instanceof CargoPackage)) continue;
106
- wait.push(id);
146
+ for (const { table, tablePath } of dependencyTables(pkg.manifest)) for (const [rawName, spec] of Object.entries(table)) {
147
+ const resolved = resolveLinkedDep(pkg.workspaceFile, pkg.file, this.cargo.graph, tablePath, rawName, spec);
148
+ if (!resolved) continue;
149
+ wait.push(resolved.linked.id);
107
150
  }
108
151
  return {
109
- shouldPublish: pkg.version !== void 0 && pkg.packageInfo.publish !== false,
152
+ shouldPublish,
110
153
  wait
111
154
  };
112
155
  },
113
156
  resolvePlanStatus({ plan }) {
114
- if (!active) return;
157
+ if (!this.cargo) return;
115
158
  return Array.from(plan.packages, async ([id, { preflight }]) => {
116
159
  if (!preflight.shouldPublish) return;
117
160
  const pkg = this.graph.get(id);
118
- if (!(pkg instanceof CargoPackage) || !pkg.version) return;
161
+ if (!(pkg instanceof CargoPackage)) return;
119
162
  if (!await isPackagePublished(pkg.name, pkg.version)) return "pending";
120
163
  });
121
164
  },
@@ -132,70 +175,59 @@ function cargo({ updateLockFile = true, bumpDep: getBumpDepType } = {}) {
132
175
  return { type: "published" };
133
176
  },
134
177
  async applyDraft(draft) {
135
- if (!active) return;
136
- const { graph } = this;
137
- const writes = [];
138
- for (const pkg of graph.getPackages()) {
139
- if (!(pkg instanceof CargoPackage)) continue;
178
+ if (!this.cargo) return;
179
+ const graph = this.cargo.graph;
180
+ for (const pkg of graph.packages.values()) {
140
181
  const bumped = draft.getPackageDraft(pkg.id)?.bumpVersion(pkg);
141
182
  if (bumped) pkg.setVersion(bumped);
142
183
  }
143
- for (const pkg of graph.getPackages()) {
144
- if (!(pkg instanceof CargoPackage)) continue;
145
- for (const { table, path: tablePath } of dependencyTables(pkg.manifest, "")) for (const [rawName, rawSpec] of Object.entries(table)) {
146
- const spec = parseSpec(rawSpec);
147
- if (!spec || !semver$1.validRange(spec.version)) continue;
148
- const packageName = spec.package ?? rawName;
149
- const linked = graph.get(`cargo:${packageName}`);
150
- if (!linked || !(linked instanceof CargoPackage)) continue;
151
- if (!linked.version || semver$1.satisfies(linked.version, spec.version)) continue;
152
- let updatedRange;
153
- if (spec.version.startsWith("^")) updatedRange = `^${linked.version}`;
154
- else if (spec.version.startsWith("~")) updatedRange = `~${linked.version}`;
155
- else updatedRange = linked.version;
156
- table[rawName] = spec.setVersion(updatedRange);
157
- pkg.patch(typeof rawSpec === "string" ? `${tablePath}.${rawName}` : `${tablePath}.${rawName}.version`, updatedRange);
158
- }
159
- writes.push(pkg.write());
184
+ for (const pkg of graph.packages.values()) for (const { table, tablePath } of dependencyTables(pkg.manifest)) for (const [rawName, spec] of Object.entries(table)) {
185
+ const resolved = resolveLinkedDep(pkg.workspaceFile, pkg.file, graph, tablePath, rawName, spec);
186
+ if (!resolved || !resolved.range || !resolved.setRange || semver$1.satisfies(resolved.linked.version, resolved.range)) continue;
187
+ let updatedRange;
188
+ if (resolved.range.startsWith("^")) updatedRange = `^${resolved.linked.version}`;
189
+ else if (resolved.range.startsWith("~")) updatedRange = `~${resolved.linked.version}`;
190
+ else updatedRange = resolved.linked.version;
191
+ table[rawName] = resolved.setRange(updatedRange);
160
192
  }
161
- await Promise.all(writes);
193
+ await Promise.all(Array.from(graph.files.values(), (file) => writeFile(file.path, file.content + "\n")));
162
194
  },
163
195
  async applyCliDraft() {
164
- if (!active || !updateLockFile) return;
196
+ if (!this.cargo || !updateLockFile) return;
165
197
  const result = await x("cargo", ["update", "--workspace"], { nodeOptions: { cwd: this.cwd } });
166
198
  if (result.exitCode !== 0) throw execFailure("Failed to update Cargo lock file", result);
167
199
  }
168
200
  };
169
201
  }
170
- function depsPolicy({ graph }, getBumpDepType = ({ kind }) => {
202
+ function depsPolicy({ graph, cargo }, getBumpDepType = ({ kind }) => {
171
203
  switch (kind) {
172
204
  case "dependencies": return "patch";
173
205
  case "build-dependencies":
174
206
  case "dev-dependencies": return false;
175
207
  }
176
208
  }) {
209
+ const cargoGraph = cargo.graph;
177
210
  const dependentMap = /* @__PURE__ */ new Map();
178
- for (const pkg of graph.getPackages()) {
179
- if (!(pkg instanceof CargoPackage)) continue;
180
- for (const { table, kind } of dependencyTables(pkg.manifest, "")) for (const [rawName, rawSpec] of Object.entries(table)) {
181
- const spec = parseSpec(rawSpec);
182
- if (!spec || !semver$1.validRange(spec.version)) continue;
183
- const name = spec.package ?? rawName;
184
- const id = `cargo:${name}`;
185
- const refs = dependentMap.get(id);
186
- if (refs) refs.push({
187
- dependent: pkg,
188
- kind,
189
- name,
190
- version: spec.version
191
- });
192
- else dependentMap.set(id, [{
193
- dependent: pkg,
194
- kind,
195
- name,
196
- version: spec.version
197
- }]);
198
- }
211
+ for (const pkg of cargoGraph.packages.values()) for (const { table, tablePath } of dependencyTables(pkg.manifest)) for (const [name, spec] of Object.entries(table)) {
212
+ const resolved = resolveLinkedDep(pkg.workspaceFile, pkg.file, cargoGraph, tablePath, name, spec);
213
+ if (!resolved) continue;
214
+ const id = resolved.linked.id;
215
+ const refs = dependentMap.get(id);
216
+ const kind = tablePath.at(-1);
217
+ if (refs) refs.push({
218
+ dependent: pkg,
219
+ kind,
220
+ name,
221
+ spec,
222
+ version: resolved.range
223
+ });
224
+ else dependentMap.set(id, [{
225
+ dependent: pkg,
226
+ kind,
227
+ name,
228
+ spec,
229
+ version: resolved.range
230
+ }]);
199
231
  }
200
232
  return {
201
233
  id: "cargo:deps",
@@ -208,12 +240,12 @@ function depsPolicy({ graph }, getBumpDepType = ({ kind }) => {
208
240
  if (!bumped) return;
209
241
  for (const dep of deps) {
210
242
  if (group?.options.syncBump && graph.getPackageGroup(dep.dependent.id) === group) continue;
211
- if (semver$1.satisfies(bumped, dep.version)) continue;
243
+ if (dep.version && semver$1.satisfies(bumped, dep.version)) continue;
212
244
  const bumpType = getBumpDepType(dep);
213
245
  if (bumpType === false) continue;
214
246
  this.bumpPackage(dep.dependent, {
215
247
  type: bumpType,
216
- reason: `update dependency "${dep.name}"`
248
+ reason: `update dependency "${pkg.name}"`
217
249
  });
218
250
  }
219
251
  }
@@ -225,81 +257,146 @@ async function isPackagePublished(name, version) {
225
257
  if (response.status === 404) return false;
226
258
  throw new Error(`Unable to validate ${name}@${version} against crates.io: ${await response.text()}`);
227
259
  }
228
- async function buildEntry(path) {
260
+ async function buildEntry(dir) {
229
261
  try {
230
- const content = await readFile(join(path, "Cargo.toml"), "utf8");
262
+ const filePath = path.join(dir, "Cargo.toml");
263
+ const content = await readFile(filePath, "utf8");
231
264
  return {
232
- manifest: cargoManifestSchema.parse(parse$1(content)),
233
- content,
234
- path
265
+ path: filePath,
266
+ data: cargoManifestSchema.parse(parse$1(content)),
267
+ content
235
268
  };
236
269
  } catch {
237
270
  return;
238
271
  }
239
272
  }
240
- async function discoverCargoPackages(cwd, add) {
273
+ async function resolveCargoGraph(cwd) {
274
+ const out = {
275
+ packages: /* @__PURE__ */ new Map(),
276
+ files: /* @__PURE__ */ new Map()
277
+ };
241
278
  const root = await buildEntry(cwd);
242
- if (!root) return;
243
- if (root.manifest.package?.name) add(new CargoPackage(cwd, root.manifest, root.content, root.manifest));
244
- const workspace = root.manifest.workspace;
245
- if (!workspace?.members) return;
246
- const paths = await expandWorkspaceMembers(cwd, workspace.members, workspace.exclude);
247
- const manifests = await Promise.all(paths.map(buildEntry));
248
- for (const entry of manifests) if (entry?.manifest.package?.name) add(new CargoPackage(entry.path, entry.manifest, entry.content, root.manifest));
279
+ if (!root) return out;
280
+ const rootWorkspace = root.data.workspace;
281
+ out.files.set(root.path, root);
282
+ if (root.data.package) {
283
+ const pkg = new CargoPackage(cwd, root, rootWorkspace ? root : void 0);
284
+ out.packages.set(pkg.name, pkg);
285
+ }
286
+ if (!rootWorkspace || !rootWorkspace.members) return out;
287
+ const dirs = await expandWorkspaceMembers(cwd, rootWorkspace.members, rootWorkspace.exclude);
288
+ await Promise.all(dirs.map(async (dir) => {
289
+ const entry = await buildEntry(dir);
290
+ if (!entry || !entry.data.package) return;
291
+ const pkg = new CargoPackage(dir, entry, root);
292
+ out.files.set(entry.path, entry);
293
+ out.packages.set(pkg.name, pkg);
294
+ }));
295
+ return out;
249
296
  }
250
297
  async function expandWorkspaceMembers(cwd, members, exclude = []) {
251
- const paths = members.includes(".") ? [cwd] : [];
252
298
  const patterns = members.filter((member) => member !== ".");
253
- if (patterns.length > 0) paths.push(...await glob(patterns, {
299
+ if (patterns.length === 0) return [];
300
+ return (await glob(patterns, {
254
301
  absolute: true,
255
302
  cwd,
256
303
  ignore: ["**/target/**", ...exclude],
257
304
  onlyDirectories: true,
258
305
  onlyFiles: false
259
- }));
260
- return paths.map(normalize);
306
+ })).map((item) => {
307
+ return item.endsWith(path.sep) ? item.slice(0, -1) : item;
308
+ });
261
309
  }
262
- function dependencyTables(manifest, prefix) {
310
+ function dependencyTables(manifest, prefix = []) {
263
311
  const tables = [];
264
312
  for (const field of DEP_FIELDS) {
265
313
  const table = manifest[field];
266
- if (table) {
267
- const path = prefix ? `${prefix}.${field}` : field;
268
- tables.push({
269
- kind: field,
270
- table,
271
- path
272
- });
273
- }
314
+ if (!table) continue;
315
+ tables.push({
316
+ table,
317
+ tablePath: [...prefix, field]
318
+ });
274
319
  }
275
320
  const target = manifest.target;
276
- if (target) for (const [targetKey, targetConfig] of Object.entries(target)) {
277
- const targetPath = prefix ? `${prefix}.target.${targetKey}` : `target.${targetKey}`;
278
- for (const field of DEP_FIELDS) {
279
- const table = targetConfig[field];
280
- if (table) tables.push({
281
- kind: field,
282
- table,
283
- path: `${targetPath}.${field}`
284
- });
285
- }
321
+ if (target) for (const [targetKey, targetConfig] of Object.entries(target)) for (const field of DEP_FIELDS) {
322
+ const table = targetConfig[field];
323
+ if (!table) continue;
324
+ tables.push({
325
+ table,
326
+ tablePath: [
327
+ ...prefix,
328
+ "target",
329
+ targetKey,
330
+ field
331
+ ]
332
+ });
286
333
  }
287
334
  return tables;
288
335
  }
289
- function parseSpec(v) {
290
- if (typeof v === "string") return {
291
- version: v,
292
- setVersion(version) {
293
- return version;
336
+ function resolveLinkedDep(workspaceFile, file, graph, tablePath, rawName, spec) {
337
+ if (typeof spec === "string") {
338
+ const linked = graph.packages.get(rawName);
339
+ if (!linked) return;
340
+ return {
341
+ linked,
342
+ range: spec,
343
+ setRange(v) {
344
+ patchFile(file, [...tablePath, rawName].join("."), v);
345
+ return v;
346
+ }
347
+ };
348
+ }
349
+ if ("git" in spec) return;
350
+ if ("workspace" in spec) {
351
+ const kind = tablePath[tablePath.length - 1];
352
+ const entry = workspaceFile?.data.workspace?.[kind]?.[rawName];
353
+ if (!entry) return;
354
+ const resolved = resolveLinkedDep(void 0, workspaceFile, graph, ["workspace", kind], rawName, entry);
355
+ if (!resolved || !resolved.setRange) return resolved;
356
+ return {
357
+ ...resolved,
358
+ setRange(v) {
359
+ workspaceFile.data.workspace[kind][rawName] = resolved.setRange(v);
360
+ return spec;
361
+ }
362
+ };
363
+ }
364
+ if ("path" in spec) {
365
+ const pkgPath = path.resolve(path.dirname(file.path), spec.path);
366
+ for (const pkg of graph.packages.values()) {
367
+ if (pkg.path !== pkgPath) continue;
368
+ return {
369
+ linked: pkg,
370
+ range: spec.version,
371
+ setRange(v) {
372
+ patchFile(file, [
373
+ ...tablePath,
374
+ rawName,
375
+ "version"
376
+ ].join("."), v);
377
+ return {
378
+ ...spec,
379
+ version: v
380
+ };
381
+ }
382
+ };
294
383
  }
295
- };
384
+ return;
385
+ }
386
+ const linked = graph.packages.get(spec.package ?? rawName);
387
+ if (!linked) return;
296
388
  return {
297
- package: v.package,
298
- version: v.version,
299
- setVersion(version) {
389
+ linked,
390
+ range: spec.version,
391
+ setRange(v) {
392
+ patchFile(file, [
393
+ ...tablePath,
394
+ rawName,
395
+ "version"
396
+ ].join("."), v);
300
397
  return {
301
- ...v,
302
- version
398
+ ...spec,
399
+ version: v
303
400
  };
304
401
  }
305
402
  };
@@ -1,4 +1,4 @@
1
- import { s as TegamiPlugin } from "../types-DItu_YCc.js";
1
+ import { s as TegamiPlugin } from "../types-DHddSAez.js";
2
2
 
3
3
  //#region src/plugins/git.d.ts
4
4
  interface GitPluginOptions {
@@ -1,4 +1,4 @@
1
- import { T as Draft, s as TegamiPlugin, t as Awaitable, w as WorkspacePackage, x as TegamiContext, y as PublishPlan } from "../types-DItu_YCc.js";
1
+ import { O as WorkspacePackage, k as Draft, s as TegamiPlugin, t as Awaitable, x as TegamiContext, y as PublishPlan } from "../types-DHddSAez.js";
2
2
  import { GitPluginOptions } from "./git.js";
3
3
 
4
4
  //#region src/plugins/github.d.ts
@@ -1,4 +1,4 @@
1
- import { T as Draft, s as TegamiPlugin, t as Awaitable, w as WorkspacePackage, x as TegamiContext, y as PublishPlan } from "../types-DItu_YCc.js";
1
+ import { O as WorkspacePackage, k as Draft, s as TegamiPlugin, t as Awaitable, x as TegamiContext, y as PublishPlan } from "../types-DHddSAez.js";
2
2
  import { GitPluginOptions } from "./git.js";
3
3
 
4
4
  //#region src/plugins/gitlab.d.ts
@@ -1,4 +1,4 @@
1
- import { O as BumpType, s as TegamiPlugin, w as WorkspacePackage } from "../types-DItu_YCc.js";
1
+ import { M as BumpType, O as WorkspacePackage, s as TegamiPlugin } from "../types-DHddSAez.js";
2
2
 
3
3
  //#region src/plugins/go.d.ts
4
4
  interface GoModFile {
@@ -1,2 +1,2 @@
1
- import { d as npm, l as NpmPackage, u as NpmPluginOptions } from "../types-DItu_YCc.js";
1
+ import { d as npm, l as NpmPackage, u as NpmPluginOptions } from "../types-DHddSAez.js";
2
2
  export { NpmPackage, NpmPluginOptions, npm };
@@ -1,2 +1,2 @@
1
- import { n as npm, t as NpmPackage } from "../npm-1iEegfHg.js";
1
+ import { n as npm, t as NpmPackage } from "../npm-5cG02krT.js";
2
2
  export { NpmPackage, npm };
@@ -144,6 +144,395 @@ interface GitLabToken {
144
144
  type: "private-token" | "job-token";
145
145
  }
146
146
  //#endregion
147
+ //#region src/plugins/cargo/schema.d.ts
148
+ /**
149
+ * @see https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html
150
+ */
151
+ declare const cargoDependencySchema: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
152
+ package: z.ZodOptional<z.ZodString>;
153
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
154
+ optional: z.ZodOptional<z.ZodBoolean>;
155
+ "default-features": z.ZodOptional<z.ZodBoolean>;
156
+ workspace: z.ZodLiteral<true>;
157
+ }, z.core.$strip>, z.ZodObject<{
158
+ package: z.ZodOptional<z.ZodString>;
159
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
160
+ optional: z.ZodOptional<z.ZodBoolean>;
161
+ "default-features": z.ZodOptional<z.ZodBoolean>;
162
+ path: z.ZodString;
163
+ version: z.ZodOptional<z.ZodString>;
164
+ }, z.core.$strip>, z.ZodObject<{
165
+ package: z.ZodOptional<z.ZodString>;
166
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
167
+ optional: z.ZodOptional<z.ZodBoolean>;
168
+ "default-features": z.ZodOptional<z.ZodBoolean>;
169
+ git: z.ZodString;
170
+ branch: z.ZodOptional<z.ZodString>;
171
+ tag: z.ZodOptional<z.ZodString>;
172
+ rev: z.ZodOptional<z.ZodString>;
173
+ version: z.ZodOptional<z.ZodString>;
174
+ }, z.core.$strip>, z.ZodObject<{
175
+ package: z.ZodOptional<z.ZodString>;
176
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
177
+ optional: z.ZodOptional<z.ZodBoolean>;
178
+ "default-features": z.ZodOptional<z.ZodBoolean>;
179
+ version: z.ZodString;
180
+ registry: z.ZodOptional<z.ZodString>;
181
+ }, z.core.$strip>]>;
182
+ declare const cargoManifestSchema: z.ZodObject<{
183
+ package: z.ZodOptional<z.ZodObject<{
184
+ name: z.ZodString;
185
+ version: z.ZodUnion<[z.ZodString, z.ZodObject<{
186
+ workspace: z.ZodLiteral<true>;
187
+ }, z.core.$loose>]>;
188
+ publish: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
189
+ workspace: z.ZodLiteral<true>;
190
+ }, z.core.$loose>]>>;
191
+ }, z.core.$loose>>;
192
+ workspace: z.ZodOptional<z.ZodObject<{
193
+ members: z.ZodOptional<z.ZodArray<z.ZodString>>;
194
+ exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
195
+ package: z.ZodOptional<z.ZodObject<{
196
+ version: z.ZodOptional<z.ZodString>;
197
+ publish: z.ZodOptional<z.ZodBoolean>;
198
+ }, z.core.$loose>>;
199
+ dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
200
+ package: z.ZodOptional<z.ZodString>;
201
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
202
+ optional: z.ZodOptional<z.ZodBoolean>;
203
+ "default-features": z.ZodOptional<z.ZodBoolean>;
204
+ workspace: z.ZodLiteral<true>;
205
+ }, z.core.$strip>, z.ZodObject<{
206
+ package: z.ZodOptional<z.ZodString>;
207
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
208
+ optional: z.ZodOptional<z.ZodBoolean>;
209
+ "default-features": z.ZodOptional<z.ZodBoolean>;
210
+ path: z.ZodString;
211
+ version: z.ZodOptional<z.ZodString>;
212
+ }, z.core.$strip>, z.ZodObject<{
213
+ package: z.ZodOptional<z.ZodString>;
214
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
215
+ optional: z.ZodOptional<z.ZodBoolean>;
216
+ "default-features": z.ZodOptional<z.ZodBoolean>;
217
+ git: z.ZodString;
218
+ branch: z.ZodOptional<z.ZodString>;
219
+ tag: z.ZodOptional<z.ZodString>;
220
+ rev: z.ZodOptional<z.ZodString>;
221
+ version: z.ZodOptional<z.ZodString>;
222
+ }, z.core.$strip>, z.ZodObject<{
223
+ package: z.ZodOptional<z.ZodString>;
224
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
225
+ optional: z.ZodOptional<z.ZodBoolean>;
226
+ "default-features": z.ZodOptional<z.ZodBoolean>;
227
+ version: z.ZodString;
228
+ registry: z.ZodOptional<z.ZodString>;
229
+ }, z.core.$strip>]>>>;
230
+ "dev-dependencies": z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
231
+ package: z.ZodOptional<z.ZodString>;
232
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
233
+ optional: z.ZodOptional<z.ZodBoolean>;
234
+ "default-features": z.ZodOptional<z.ZodBoolean>;
235
+ workspace: z.ZodLiteral<true>;
236
+ }, z.core.$strip>, z.ZodObject<{
237
+ package: z.ZodOptional<z.ZodString>;
238
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
239
+ optional: z.ZodOptional<z.ZodBoolean>;
240
+ "default-features": z.ZodOptional<z.ZodBoolean>;
241
+ path: z.ZodString;
242
+ version: z.ZodOptional<z.ZodString>;
243
+ }, z.core.$strip>, z.ZodObject<{
244
+ package: z.ZodOptional<z.ZodString>;
245
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
246
+ optional: z.ZodOptional<z.ZodBoolean>;
247
+ "default-features": z.ZodOptional<z.ZodBoolean>;
248
+ git: z.ZodString;
249
+ branch: z.ZodOptional<z.ZodString>;
250
+ tag: z.ZodOptional<z.ZodString>;
251
+ rev: z.ZodOptional<z.ZodString>;
252
+ version: z.ZodOptional<z.ZodString>;
253
+ }, z.core.$strip>, z.ZodObject<{
254
+ package: z.ZodOptional<z.ZodString>;
255
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
256
+ optional: z.ZodOptional<z.ZodBoolean>;
257
+ "default-features": z.ZodOptional<z.ZodBoolean>;
258
+ version: z.ZodString;
259
+ registry: z.ZodOptional<z.ZodString>;
260
+ }, z.core.$strip>]>>>;
261
+ "build-dependencies": z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
262
+ package: z.ZodOptional<z.ZodString>;
263
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
264
+ optional: z.ZodOptional<z.ZodBoolean>;
265
+ "default-features": z.ZodOptional<z.ZodBoolean>;
266
+ workspace: z.ZodLiteral<true>;
267
+ }, z.core.$strip>, z.ZodObject<{
268
+ package: z.ZodOptional<z.ZodString>;
269
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
270
+ optional: z.ZodOptional<z.ZodBoolean>;
271
+ "default-features": z.ZodOptional<z.ZodBoolean>;
272
+ path: z.ZodString;
273
+ version: z.ZodOptional<z.ZodString>;
274
+ }, z.core.$strip>, z.ZodObject<{
275
+ package: z.ZodOptional<z.ZodString>;
276
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
277
+ optional: z.ZodOptional<z.ZodBoolean>;
278
+ "default-features": z.ZodOptional<z.ZodBoolean>;
279
+ git: z.ZodString;
280
+ branch: z.ZodOptional<z.ZodString>;
281
+ tag: z.ZodOptional<z.ZodString>;
282
+ rev: z.ZodOptional<z.ZodString>;
283
+ version: z.ZodOptional<z.ZodString>;
284
+ }, z.core.$strip>, z.ZodObject<{
285
+ package: z.ZodOptional<z.ZodString>;
286
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
287
+ optional: z.ZodOptional<z.ZodBoolean>;
288
+ "default-features": z.ZodOptional<z.ZodBoolean>;
289
+ version: z.ZodString;
290
+ registry: z.ZodOptional<z.ZodString>;
291
+ }, z.core.$strip>]>>>;
292
+ }, z.core.$loose>>;
293
+ dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
294
+ package: z.ZodOptional<z.ZodString>;
295
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
296
+ optional: z.ZodOptional<z.ZodBoolean>;
297
+ "default-features": z.ZodOptional<z.ZodBoolean>;
298
+ workspace: z.ZodLiteral<true>;
299
+ }, z.core.$strip>, z.ZodObject<{
300
+ package: z.ZodOptional<z.ZodString>;
301
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
302
+ optional: z.ZodOptional<z.ZodBoolean>;
303
+ "default-features": z.ZodOptional<z.ZodBoolean>;
304
+ path: z.ZodString;
305
+ version: z.ZodOptional<z.ZodString>;
306
+ }, z.core.$strip>, z.ZodObject<{
307
+ package: z.ZodOptional<z.ZodString>;
308
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
309
+ optional: z.ZodOptional<z.ZodBoolean>;
310
+ "default-features": z.ZodOptional<z.ZodBoolean>;
311
+ git: z.ZodString;
312
+ branch: z.ZodOptional<z.ZodString>;
313
+ tag: z.ZodOptional<z.ZodString>;
314
+ rev: z.ZodOptional<z.ZodString>;
315
+ version: z.ZodOptional<z.ZodString>;
316
+ }, z.core.$strip>, z.ZodObject<{
317
+ package: z.ZodOptional<z.ZodString>;
318
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
319
+ optional: z.ZodOptional<z.ZodBoolean>;
320
+ "default-features": z.ZodOptional<z.ZodBoolean>;
321
+ version: z.ZodString;
322
+ registry: z.ZodOptional<z.ZodString>;
323
+ }, z.core.$strip>]>>>;
324
+ "dev-dependencies": z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
325
+ package: z.ZodOptional<z.ZodString>;
326
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
327
+ optional: z.ZodOptional<z.ZodBoolean>;
328
+ "default-features": z.ZodOptional<z.ZodBoolean>;
329
+ workspace: z.ZodLiteral<true>;
330
+ }, z.core.$strip>, z.ZodObject<{
331
+ package: z.ZodOptional<z.ZodString>;
332
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
333
+ optional: z.ZodOptional<z.ZodBoolean>;
334
+ "default-features": z.ZodOptional<z.ZodBoolean>;
335
+ path: z.ZodString;
336
+ version: z.ZodOptional<z.ZodString>;
337
+ }, z.core.$strip>, z.ZodObject<{
338
+ package: z.ZodOptional<z.ZodString>;
339
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
340
+ optional: z.ZodOptional<z.ZodBoolean>;
341
+ "default-features": z.ZodOptional<z.ZodBoolean>;
342
+ git: z.ZodString;
343
+ branch: z.ZodOptional<z.ZodString>;
344
+ tag: z.ZodOptional<z.ZodString>;
345
+ rev: z.ZodOptional<z.ZodString>;
346
+ version: z.ZodOptional<z.ZodString>;
347
+ }, z.core.$strip>, z.ZodObject<{
348
+ package: z.ZodOptional<z.ZodString>;
349
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
350
+ optional: z.ZodOptional<z.ZodBoolean>;
351
+ "default-features": z.ZodOptional<z.ZodBoolean>;
352
+ version: z.ZodString;
353
+ registry: z.ZodOptional<z.ZodString>;
354
+ }, z.core.$strip>]>>>;
355
+ "build-dependencies": z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
356
+ package: z.ZodOptional<z.ZodString>;
357
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
358
+ optional: z.ZodOptional<z.ZodBoolean>;
359
+ "default-features": z.ZodOptional<z.ZodBoolean>;
360
+ workspace: z.ZodLiteral<true>;
361
+ }, z.core.$strip>, z.ZodObject<{
362
+ package: z.ZodOptional<z.ZodString>;
363
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
364
+ optional: z.ZodOptional<z.ZodBoolean>;
365
+ "default-features": z.ZodOptional<z.ZodBoolean>;
366
+ path: z.ZodString;
367
+ version: z.ZodOptional<z.ZodString>;
368
+ }, z.core.$strip>, z.ZodObject<{
369
+ package: z.ZodOptional<z.ZodString>;
370
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
371
+ optional: z.ZodOptional<z.ZodBoolean>;
372
+ "default-features": z.ZodOptional<z.ZodBoolean>;
373
+ git: z.ZodString;
374
+ branch: z.ZodOptional<z.ZodString>;
375
+ tag: z.ZodOptional<z.ZodString>;
376
+ rev: z.ZodOptional<z.ZodString>;
377
+ version: z.ZodOptional<z.ZodString>;
378
+ }, z.core.$strip>, z.ZodObject<{
379
+ package: z.ZodOptional<z.ZodString>;
380
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
381
+ optional: z.ZodOptional<z.ZodBoolean>;
382
+ "default-features": z.ZodOptional<z.ZodBoolean>;
383
+ version: z.ZodString;
384
+ registry: z.ZodOptional<z.ZodString>;
385
+ }, z.core.$strip>]>>>;
386
+ target: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
387
+ dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
388
+ package: z.ZodOptional<z.ZodString>;
389
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
390
+ optional: z.ZodOptional<z.ZodBoolean>;
391
+ "default-features": z.ZodOptional<z.ZodBoolean>;
392
+ workspace: z.ZodLiteral<true>;
393
+ }, z.core.$strip>, z.ZodObject<{
394
+ package: z.ZodOptional<z.ZodString>;
395
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
396
+ optional: z.ZodOptional<z.ZodBoolean>;
397
+ "default-features": z.ZodOptional<z.ZodBoolean>;
398
+ path: z.ZodString;
399
+ version: z.ZodOptional<z.ZodString>;
400
+ }, z.core.$strip>, z.ZodObject<{
401
+ package: z.ZodOptional<z.ZodString>;
402
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
403
+ optional: z.ZodOptional<z.ZodBoolean>;
404
+ "default-features": z.ZodOptional<z.ZodBoolean>;
405
+ git: z.ZodString;
406
+ branch: z.ZodOptional<z.ZodString>;
407
+ tag: z.ZodOptional<z.ZodString>;
408
+ rev: z.ZodOptional<z.ZodString>;
409
+ version: z.ZodOptional<z.ZodString>;
410
+ }, z.core.$strip>, z.ZodObject<{
411
+ package: z.ZodOptional<z.ZodString>;
412
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
413
+ optional: z.ZodOptional<z.ZodBoolean>;
414
+ "default-features": z.ZodOptional<z.ZodBoolean>;
415
+ version: z.ZodString;
416
+ registry: z.ZodOptional<z.ZodString>;
417
+ }, z.core.$strip>]>>>;
418
+ "dev-dependencies": z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
419
+ package: z.ZodOptional<z.ZodString>;
420
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
421
+ optional: z.ZodOptional<z.ZodBoolean>;
422
+ "default-features": z.ZodOptional<z.ZodBoolean>;
423
+ workspace: z.ZodLiteral<true>;
424
+ }, z.core.$strip>, z.ZodObject<{
425
+ package: z.ZodOptional<z.ZodString>;
426
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
427
+ optional: z.ZodOptional<z.ZodBoolean>;
428
+ "default-features": z.ZodOptional<z.ZodBoolean>;
429
+ path: z.ZodString;
430
+ version: z.ZodOptional<z.ZodString>;
431
+ }, z.core.$strip>, z.ZodObject<{
432
+ package: z.ZodOptional<z.ZodString>;
433
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
434
+ optional: z.ZodOptional<z.ZodBoolean>;
435
+ "default-features": z.ZodOptional<z.ZodBoolean>;
436
+ git: z.ZodString;
437
+ branch: z.ZodOptional<z.ZodString>;
438
+ tag: z.ZodOptional<z.ZodString>;
439
+ rev: z.ZodOptional<z.ZodString>;
440
+ version: z.ZodOptional<z.ZodString>;
441
+ }, z.core.$strip>, z.ZodObject<{
442
+ package: z.ZodOptional<z.ZodString>;
443
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
444
+ optional: z.ZodOptional<z.ZodBoolean>;
445
+ "default-features": z.ZodOptional<z.ZodBoolean>;
446
+ version: z.ZodString;
447
+ registry: z.ZodOptional<z.ZodString>;
448
+ }, z.core.$strip>]>>>;
449
+ "build-dependencies": z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
450
+ package: z.ZodOptional<z.ZodString>;
451
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
452
+ optional: z.ZodOptional<z.ZodBoolean>;
453
+ "default-features": z.ZodOptional<z.ZodBoolean>;
454
+ workspace: z.ZodLiteral<true>;
455
+ }, z.core.$strip>, z.ZodObject<{
456
+ package: z.ZodOptional<z.ZodString>;
457
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
458
+ optional: z.ZodOptional<z.ZodBoolean>;
459
+ "default-features": z.ZodOptional<z.ZodBoolean>;
460
+ path: z.ZodString;
461
+ version: z.ZodOptional<z.ZodString>;
462
+ }, z.core.$strip>, z.ZodObject<{
463
+ package: z.ZodOptional<z.ZodString>;
464
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
465
+ optional: z.ZodOptional<z.ZodBoolean>;
466
+ "default-features": z.ZodOptional<z.ZodBoolean>;
467
+ git: z.ZodString;
468
+ branch: z.ZodOptional<z.ZodString>;
469
+ tag: z.ZodOptional<z.ZodString>;
470
+ rev: z.ZodOptional<z.ZodString>;
471
+ version: z.ZodOptional<z.ZodString>;
472
+ }, z.core.$strip>, z.ZodObject<{
473
+ package: z.ZodOptional<z.ZodString>;
474
+ features: z.ZodOptional<z.ZodArray<z.ZodString>>;
475
+ optional: z.ZodOptional<z.ZodBoolean>;
476
+ "default-features": z.ZodOptional<z.ZodBoolean>;
477
+ version: z.ZodString;
478
+ registry: z.ZodOptional<z.ZodString>;
479
+ }, z.core.$strip>]>>>;
480
+ }, z.core.$loose>>>;
481
+ }, z.core.$loose>;
482
+ type CargoDependency = z.infer<typeof cargoDependencySchema>;
483
+ type CargoManifest = z.infer<typeof cargoManifestSchema>;
484
+ //#endregion
485
+ //#region src/plugins/cargo.d.ts
486
+ declare const DEP_FIELDS$1: readonly ["dependencies", "dev-dependencies", "build-dependencies"];
487
+ interface CargoToml<Data extends CargoManifest = CargoManifest> {
488
+ path: string;
489
+ content: string;
490
+ data: Data;
491
+ }
492
+ declare class CargoPackage extends WorkspacePackage {
493
+ readonly path: string;
494
+ /** a crate must have `package` field defined, otherwise it is merely a virutal workspace file, and Tegami should not include it. */
495
+ readonly file: CargoToml<RequireFields<CargoManifest, "package">>;
496
+ readonly workspaceFile?: CargoToml<RequireFields<CargoManifest, "workspace">> | undefined;
497
+ readonly manager = "cargo";
498
+ readonly manifest: RequireFields<CargoManifest, "package">;
499
+ constructor(path: string, /** a crate must have `package` field defined, otherwise it is merely a virutal workspace file, and Tegami should not include it. */
500
+
501
+ file: CargoToml<RequireFields<CargoManifest, "package">>, workspaceFile?: CargoToml<RequireFields<CargoManifest, "workspace">> | undefined);
502
+ get name(): string;
503
+ get version(): string;
504
+ setVersion(version: string): void;
505
+ }
506
+ interface DependentRef$1 {
507
+ dependent: CargoPackage;
508
+ kind: (typeof DEP_FIELDS$1)[number];
509
+ name: string;
510
+ spec: CargoDependency;
511
+ version?: string;
512
+ }
513
+ interface CargoPluginOptions {
514
+ /**
515
+ * Update lock file after versioning.
516
+ *
517
+ * @default true
518
+ */
519
+ updateLockFile?: boolean;
520
+ /**
521
+ * Decide how to bump the dependents of a bumped package.
522
+ */
523
+ bumpDep?: (opts: DependentRef$1) => BumpType | false;
524
+ }
525
+ declare function cargo({
526
+ updateLockFile,
527
+ bumpDep: getBumpDepType
528
+ }?: CargoPluginOptions): TegamiPlugin;
529
+ interface CargoGraph {
530
+ /** path -> Cargo.toml */
531
+ files: Map<string, CargoToml>;
532
+ /** name -> package */
533
+ packages: Map<string, CargoPackage>;
534
+ }
535
+ //#endregion
147
536
  //#region src/context.d.ts
148
537
  interface TegamiContext {
149
538
  /** absolute path */
@@ -171,6 +560,9 @@ interface TegamiContext {
171
560
  npm?: {
172
561
  client: AgentName;
173
562
  };
563
+ cargo?: {
564
+ graph: CargoGraph;
565
+ };
174
566
  }
175
567
  //#endregion
176
568
  //#region src/providers/npm/schema.d.ts
@@ -516,6 +908,10 @@ interface TegamiPlugin {
516
908
  pkg: WorkspacePackage;
517
909
  plan: PublishPlan;
518
910
  }): Awaitable<PublishPreflight | void | undefined>;
911
+ /** Called when all preflights finished */
912
+ afterPreflight?(this: TegamiContext, opts: {
913
+ plan: PublishPlan;
914
+ }): Awaitable<void>;
519
915
  /** Publish package, return a result object indicating if the package is published, skipped, or failed. Return `undefined` if the package is not handled by this plugin. */
520
916
  publish?(this: TegamiContext, opts: {
521
917
  pkg: WorkspacePackage;
@@ -548,6 +944,7 @@ interface TegamiPlugin {
548
944
  applyCliDraft?(this: TegamiContext, draft: Draft): Awaitable<void>;
549
945
  }
550
946
  type Awaitable<T> = T | Promise<T>;
947
+ type RequireFields<Obj, K extends keyof Obj> = Obj & { [R in K]-?: NonNullable<Obj[R]> };
551
948
  interface PublishPreflight {
552
949
  /**
553
950
  * Whether the package should be published, the state **must not** be changed across different runs.
@@ -563,4 +960,4 @@ interface PublishPreflight {
563
960
  wait?: string[];
564
961
  }
565
962
  //#endregion
566
- export { PackageGroup as C, PackageDraft as D, DraftPolicy as E, BumpType as O, PackageGraph as S, Draft as T, PackagePublishResult as _, PublishPreflight as a, CommitChangelog as b, TegamiPluginOption as c, npm as d, GenerateChangelogOptions as f, PackagePublishPlan as g, PublishLock as h, PackageOptions as i, NpmPackage as l, tegami as m, GroupOptions as n, TegamiOptions as o, Tegami as p, LogGenerator as r, TegamiPlugin as s, Awaitable as t, NpmPluginOptions as u, PublishOptions as v, WorkspacePackage as w, TegamiContext as x, PublishPlan as y };
963
+ export { DraftPolicy as A, CargoPackage as C, PackageGroup as D, PackageGraph as E, BumpType as M, WorkspacePackage as O, CargoGraph as S, cargo as T, PackagePublishResult as _, PublishPreflight as a, CommitChangelog as b, TegamiPluginOption as c, npm as d, GenerateChangelogOptions as f, PackagePublishPlan as g, PublishLock as h, PackageOptions as i, PackageDraft as j, Draft as k, NpmPackage as l, tegami as m, GroupOptions as n, TegamiOptions as o, Tegami as p, LogGenerator as r, TegamiPlugin as s, Awaitable as t, NpmPluginOptions as u, PublishOptions as v, CargoPluginOptions as w, TegamiContext as x, PublishPlan as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tegami",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Utility for package versioning & publish",
5
5
  "license": "MIT",
6
6
  "author": "Fuma Nama",