tegami 1.0.0-beta.4 → 1.0.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.
@@ -1,4 +1,4 @@
1
- import { i as isNodeError, n as execFailure } from "../error-We7chQVJ.js";
1
+ import { i as isNodeError, n as execFailure } from "../error-BhMYq9iW.js";
2
2
  import { n as WorkspacePackage } from "../graph-gThXu8Cz.js";
3
3
  import { relative, resolve } from "node:path";
4
4
  import { x } from "tinyexec";
@@ -66,7 +66,7 @@ const packageLockSchema = z.object({
66
66
  version: z.string()
67
67
  });
68
68
  /**
69
- * Experimental plugin for Golang, the release flow of Golang is pretty special, there's some exceptions for it:
69
+ * Plugin for Golang, the release flow of Golang is pretty special, there's some exceptions for it:
70
70
  *
71
71
  * - Version is stored in lock file, normally, it should prefer to store versions in a file like `package.json` & `Cargo.toml`, but for Golang, there is no such file.
72
72
  * - Publishing is handed to Git plugin, because Golang uses Git tag for publishing.
@@ -153,6 +153,7 @@ function go({ updateLockFile = true, bumpDep: getBumpDepType } = {}) {
153
153
  };
154
154
  },
155
155
  resolvePlanStatus({ plan }) {
156
+ if (!active) return;
156
157
  return Array.from(plan.packages, async ([id, { preflight }]) => {
157
158
  if (!preflight.shouldPublish) return;
158
159
  const pkg = this.graph.get(id);
@@ -180,29 +181,42 @@ function go({ updateLockFile = true, bumpDep: getBumpDepType } = {}) {
180
181
  };
181
182
  }
182
183
  function depsPolicy({ graph }, getBumpDepType = () => "patch") {
184
+ const dependentMap = /* @__PURE__ */ new Map();
185
+ for (const pkg of graph.getPackages()) {
186
+ if (!(pkg instanceof GoPackage)) continue;
187
+ for (const [name, version] of pkg.mod.requires) {
188
+ const id = `go:${name}`;
189
+ const refs = dependentMap.get(id);
190
+ if (refs) refs.push({
191
+ dependent: pkg,
192
+ name,
193
+ version
194
+ });
195
+ else dependentMap.set(id, [{
196
+ dependent: pkg,
197
+ name,
198
+ version
199
+ }]);
200
+ }
201
+ }
183
202
  return {
184
203
  id: "go:deps",
185
204
  onUpdate({ pkg, packageDraft: plan }) {
186
205
  if (!(pkg instanceof GoPackage)) return;
206
+ const deps = dependentMap.get(pkg.id);
207
+ if (!deps) return;
187
208
  const group = graph.getPackageGroup(pkg.id);
188
- for (const dependent of graph.getPackages()) {
189
- if (!(dependent instanceof GoPackage)) continue;
190
- for (const [moduleName, requireVersion] of dependent.mod.requires) {
191
- if (pkg.id !== `go:${moduleName}`) continue;
192
- if (group?.options.syncBump && graph.getPackageGroup(dependent.id) === group) continue;
193
- const bumped = plan.bumpVersion(pkg);
194
- if (!bumped || semver$1.satisfies(bumped, stripGoVersion(requireVersion))) continue;
195
- const bumpType = getBumpDepType?.({
196
- name: pkg.name,
197
- dependent,
198
- version: requireVersion
199
- });
200
- if (bumpType === false) continue;
201
- this.bumpPackage(dependent, {
202
- type: bumpType,
203
- reason: `update require "${moduleName}"`
204
- });
205
- }
209
+ const bumped = plan.bumpVersion(pkg);
210
+ if (!bumped) return;
211
+ for (const dep of deps) {
212
+ if (group?.options.syncBump && graph.getPackageGroup(dep.dependent.id) === group) continue;
213
+ if (semver$1.satisfies(bumped, stripGoVersion(dep.version))) continue;
214
+ const bumpType = getBumpDepType?.(dep);
215
+ if (bumpType === false) continue;
216
+ this.bumpPackage(dep.dependent, {
217
+ type: bumpType,
218
+ reason: `update require "${dep.name}"`
219
+ });
206
220
  }
207
221
  }
208
222
  };
@@ -1,2 +1,2 @@
1
- import { C as npm, S as NpmPluginOptions, x as NpmPackage } from "../types-DKZsadC8.js";
1
+ import { d as npm, l as NpmPackage, u as NpmPluginOptions } from "../types-DItu_YCc.js";
2
2
  export { NpmPackage, NpmPluginOptions, npm };
@@ -1,2 +1,2 @@
1
- import { n as npm, t as NpmPackage } from "../npm-CMOyacwf.js";
1
+ import { n as npm, t as NpmPackage } from "../npm-1iEegfHg.js";
2
2
  export { NpmPackage, npm };
@@ -0,0 +1,32 @@
1
+ import z from "zod";
2
+ import { dump } from "js-yaml";
3
+ //#region src/changelog/shared.ts
4
+ const bumpTypeSchema = z.enum([
5
+ "major",
6
+ "minor",
7
+ "patch"
8
+ ]);
9
+ const changelogPackageConfigSchema = z.object({
10
+ type: bumpTypeSchema.optional(),
11
+ replay: z.array(z.string().min(1)).optional()
12
+ });
13
+ const changelogFrontmatterSchema = z.object({
14
+ subject: z.string().optional(),
15
+ packages: z.union([z.array(z.string()), z.record(z.string(), z.union([
16
+ bumpTypeSchema,
17
+ z.null(),
18
+ changelogPackageConfigSchema
19
+ ]))]).optional()
20
+ });
21
+ function renderChangelog(frontmatter, body) {
22
+ return [
23
+ "---",
24
+ dump(frontmatter).trim(),
25
+ "---",
26
+ "",
27
+ body.trim(),
28
+ ""
29
+ ].join("\n");
30
+ }
31
+ //#endregion
32
+ export { renderChangelog as n, changelogFrontmatterSchema as t };
@@ -164,8 +164,8 @@ interface TegamiContext {
164
164
  gitlab?: {
165
165
  repo?: string;
166
166
  token?: GitLabToken;
167
- apiUrl?: string;
168
- webUrl?: string;
167
+ apiUrl: string;
168
+ webUrl: string;
169
169
  };
170
170
  /** additional context when npm plugin is configured */
171
171
  npm?: {
@@ -195,111 +195,27 @@ declare const packageManifestSchema: z.ZodObject<{
195
195
  }, z.core.$loose>;
196
196
  type PackageManifest = z.infer<typeof packageManifestSchema>;
197
197
  //#endregion
198
- //#region src/providers/npm.d.ts
199
- declare const DEP_FIELDS$1: readonly ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
200
- declare class NpmPackage extends WorkspacePackage {
201
- readonly path: string;
202
- readonly manifest: PackageManifest;
203
- readonly manager = "npm";
204
- constructor(path: string, manifest: PackageManifest);
205
- get name(): string;
206
- get version(): string | undefined;
207
- write(): Promise<void>;
208
- initDraft(): PackageDraft;
209
- configureDraft(draft: PackageDraft, group?: PackageGroup): void;
210
- }
211
- type DependencySpec = {
212
- protocol: "npm";
213
- alias: string;
214
- range: string;
215
- linked?: WorkspacePackage;
216
- } | {
217
- protocol: "workspace";
218
- range: string;
219
- linked?: WorkspacePackage;
220
- } | {
221
- protocol: "file";
222
- raw: string;
223
- linked?: WorkspacePackage;
224
- } | {
225
- range: string;
226
- linked?: WorkspacePackage;
227
- protocol?: undefined;
228
- };
229
- interface NpmPluginOptions {
230
- /** Package manager command used for npm registry operations. */
231
- client?: AgentName;
232
- /**
233
- * Decide how to bump the dependents of a bumped package.
234
- */
235
- bumpDep?: (opts: {
236
- dependent: NpmPackage;
237
- kind: (typeof DEP_FIELDS$1)[number];
238
- name: string;
239
- spec: DependencySpec;
240
- }) => BumpType | false;
241
- /**
242
- * What to do when a workspace dependency's version has gone beyond peer dependency constraints:
243
- *
244
- * - `set` (default): set to the current version (won't preserve prefix).
245
- * - `error`: throw error.
246
- * - `ignore`: do nothing.
247
- *
248
- * Note: `workspace:` protocols are not included.
249
- */
250
- onBreakPeerDep?: "set" | "error" | "ignore";
251
- /** update lockfile after applying a draft @default true */
252
- updateLockFile?: boolean;
253
- }
254
- declare function npm({
255
- client: defaultClient,
256
- onBreakPeerDep,
257
- updateLockFile,
258
- bumpDep: getBumpDepType
259
- }?: NpmPluginOptions): TegamiPlugin;
260
- //#endregion
261
- //#region src/providers/cargo.d.ts
262
- interface TomlTable {
263
- [key: string]: TomlValue;
198
+ //#region src/changelog/generate.d.ts
199
+ interface GenerateFromCommitsOptions {
200
+ /** Start revision. Defaults to the latest reachable git tag, or all history if none exists. */
201
+ from?: string;
202
+ /** End revision. Defaults to HEAD. */
203
+ to?: string;
264
204
  }
265
- type TomlValue = string | number | boolean | TomlTable | TomlValue[];
266
- declare const DEP_FIELDS: readonly ["dependencies", "dev-dependencies", "build-dependencies"];
267
- declare class CargoPackage extends WorkspacePackage {
268
- readonly path: string;
269
- readonly manifest: TomlTable;
270
- private content;
271
- private readonly workspaceManifest?;
272
- readonly manager = "cargo";
273
- constructor(path: string, manifest: TomlTable, content: string, workspaceManifest?: TomlTable | undefined);
274
- get name(): string;
275
- get version(): string | undefined;
276
- setVersion(version: string): void;
277
- write(): Promise<void>;
278
- patch(path: string, value: unknown): void;
279
- get packageInfo(): TomlTable;
280
- private get workspaceVersion();
205
+ interface CommitChangelog {
206
+ filename: string;
207
+ content: string;
208
+ packages: Record<string, BumpType | ChangelogPackageConfig>;
209
+ changes: CommitChange[];
281
210
  }
282
- interface CargoPluginOptions {
283
- /**
284
- * Update lock file after versioning.
285
- *
286
- * @default true
287
- */
288
- updateLockFile?: boolean;
289
- /**
290
- * Decide how to bump the dependents of a bumped package.
291
- */
292
- bumpDep?: (opts: {
293
- dependent: CargoPackage;
294
- kind: (typeof DEP_FIELDS)[number];
295
- name: string;
296
- version: string;
297
- }) => BumpType | false;
211
+ interface CommitChange {
212
+ hash: string;
213
+ subject: string;
214
+ body: string;
215
+ packages: string[];
216
+ type: BumpType;
217
+ title: string;
298
218
  }
299
- declare function cargo({
300
- updateLockFile,
301
- bumpDep: getBumpDepType
302
- }?: CargoPluginOptions): TegamiPlugin;
303
219
  //#endregion
304
220
  //#region src/plans/publish.d.ts
305
221
  interface PublishPlan {
@@ -319,7 +235,8 @@ interface PackagePublishPlan {
319
235
  };
320
236
  /** generated by npm plugin */
321
237
  npm?: {
322
- /** dist tag to use if published */distTag?: string;
238
+ /** dist tag to use if published */distTag?: string; /** point latest tag to it if published */
239
+ markLatest?: boolean;
323
240
  };
324
241
  /** publish result, generated for all packages in publish plan after publishing */
325
242
  publishResult?: PackagePublishResult;
@@ -354,28 +271,6 @@ declare class PublishLock {
354
271
  serialize(): string;
355
272
  }
356
273
  //#endregion
357
- //#region src/changelog/generate.d.ts
358
- interface GenerateFromCommitsOptions {
359
- /** Start revision. Defaults to the latest reachable git tag, or all history if none exists. */
360
- from?: string;
361
- /** End revision. Defaults to HEAD. */
362
- to?: string;
363
- }
364
- interface CommitChangelog {
365
- filename: string;
366
- content: string;
367
- packages: Record<string, BumpType | ChangelogPackageConfig>;
368
- changes: CommitChange[];
369
- }
370
- interface CommitChange {
371
- hash: string;
372
- subject: string;
373
- body: string;
374
- packages: string[];
375
- type: BumpType;
376
- title: string;
377
- }
378
- //#endregion
379
274
  //#region src/index.d.ts
380
275
  interface GenerateChangelogOptions extends GenerateFromCommitsOptions {
381
276
  /**
@@ -443,6 +338,83 @@ interface TegamiCliRegistry {
443
338
  parse(argv: string[]): Promise<void>;
444
339
  }
445
340
  //#endregion
341
+ //#region src/providers/npm/cli.d.ts
342
+ type TrustedPublishOptions = {
343
+ provider: "github"; /** CI workflow filename for publishing. */
344
+ workflow: string;
345
+ } | {
346
+ provider: "gitlab"; /** CI pipeline filename for publishing. */
347
+ workflow: string;
348
+ };
349
+ //#endregion
350
+ //#region src/providers/npm.d.ts
351
+ declare const DEP_FIELDS: readonly ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
352
+ declare class NpmPackage extends WorkspacePackage {
353
+ readonly path: string;
354
+ readonly manifest: PackageManifest;
355
+ readonly manager = "npm";
356
+ constructor(path: string, manifest: PackageManifest);
357
+ get name(): string;
358
+ get version(): string | undefined;
359
+ write(): Promise<void>;
360
+ initDraft(): PackageDraft;
361
+ getRegistry(): string;
362
+ configureDraft(draft: PackageDraft, group?: PackageGroup): void;
363
+ }
364
+ type DependencySpec = {
365
+ protocol: "npm";
366
+ alias: string;
367
+ range: string;
368
+ linked?: WorkspacePackage;
369
+ } | {
370
+ protocol: "workspace";
371
+ range: string;
372
+ linked?: WorkspacePackage;
373
+ } | {
374
+ protocol: "file";
375
+ raw: string;
376
+ linked?: WorkspacePackage;
377
+ } | {
378
+ range: string;
379
+ linked?: WorkspacePackage;
380
+ protocol?: undefined;
381
+ };
382
+ interface DependentRef {
383
+ dependent: NpmPackage;
384
+ kind: (typeof DEP_FIELDS)[number];
385
+ name: string;
386
+ spec: DependencySpec;
387
+ }
388
+ interface NpmPluginOptions {
389
+ /** Package manager command used for npm registry operations. */
390
+ client?: AgentName;
391
+ /**
392
+ * Decide how to bump the dependents of a bumped package.
393
+ */
394
+ bumpDep?: (opts: DependentRef) => BumpType | false;
395
+ /**
396
+ * What to do when a workspace dependency's version has gone beyond peer dependency constraints:
397
+ *
398
+ * - `set` (default): set to the current version (won't preserve prefix).
399
+ * - `error`: throw error.
400
+ * - `ignore`: do nothing.
401
+ *
402
+ * Note: `workspace:` protocols are not included.
403
+ */
404
+ onBreakPeerDep?: "set" | "error" | "ignore";
405
+ /** update lockfile after applying a draft @default true */
406
+ updateLockFile?: boolean;
407
+ /** Configure `tegami npm pretrust`, disabled by default. */
408
+ trustedPublish?: TrustedPublishOptions;
409
+ }
410
+ declare function npm({
411
+ client: defaultClient,
412
+ onBreakPeerDep,
413
+ updateLockFile,
414
+ trustedPublish,
415
+ bumpDep: getBumpDepType
416
+ }?: NpmPluginOptions): TegamiPlugin;
417
+ //#endregion
446
418
  //#region src/types.d.ts
447
419
  /** Generates changelog content for a package release. */
448
420
  interface LogGenerator {
@@ -476,7 +448,6 @@ interface TegamiOptions<Groups extends string = string> {
476
448
  */
477
449
  conventionalCommits?: boolean;
478
450
  npm?: NpmPluginOptions;
479
- cargo?: CargoPluginOptions;
480
451
  }
481
452
  interface SharedGoOptions {
482
453
  /**
@@ -592,4 +563,4 @@ interface PublishPreflight {
592
563
  wait?: string[];
593
564
  }
594
565
  //#endregion
595
- export { PackageDraft as A, npm as C, WorkspacePackage as D, PackageGroup as E, Draft as O, NpmPluginOptions as S, PackageGraph as T, PublishPlan as _, PublishPreflight as a, cargo as b, TegamiPluginOption as c, tegami as d, CommitChangelog as f, PublishOptions as g, PackagePublishResult as h, PackageOptions as i, BumpType as j, DraftPolicy as k, GenerateChangelogOptions as l, PackagePublishPlan as m, GroupOptions as n, TegamiOptions as o, PublishLock as p, LogGenerator as r, TegamiPlugin as s, Awaitable as t, Tegami as u, CargoPackage as v, TegamiContext as w, NpmPackage as x, CargoPluginOptions as y };
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 };
@@ -0,0 +1,6 @@
1
+ import { Result } from "tinyexec";
2
+
3
+ //#region src/utils/error.d.ts
4
+ declare function execFailure(context: string, result: Awaited<Result>): Error;
5
+ //#endregion
6
+ export { execFailure };
@@ -0,0 +1,2 @@
1
+ import { n as execFailure } from "../error-BhMYq9iW.js";
2
+ export { execFailure };
@@ -1,9 +1,11 @@
1
1
  import { r as formatNpmDistTag } from "./semver-EKJ8yK5U.js";
2
- import { n as execFailure } from "./error-We7chQVJ.js";
2
+ import { n as execFailure } from "./error-BhMYq9iW.js";
3
3
  import { x } from "tinyexec";
4
4
  //#region src/utils/version-request.ts
5
5
  async function hasGitChanges(cwd) {
6
- return (await x("git", ["status", "--porcelain"], { nodeOptions: { cwd } })).stdout.trim().length > 0;
6
+ const result = await x("git", ["status", "--porcelain"], { nodeOptions: { cwd } });
7
+ if (result.exitCode !== 0) throw execFailure("Failed to check git status.", result);
8
+ return result.stdout.trim().length > 0;
7
9
  }
8
10
  async function commitVersionBranchChanges(cwd, branch, title) {
9
11
  const gitOptions = { nodeOptions: { cwd } };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tegami",
3
- "version": "1.0.0-beta.4",
3
+ "version": "1.0.1",
4
4
  "description": "Utility for package versioning & publish",
5
5
  "license": "MIT",
6
6
  "author": "Fuma Nama",
@@ -16,12 +16,13 @@
16
16
  ".": "./dist/index.js",
17
17
  "./cli": "./dist/cli/index.js",
18
18
  "./generators/simple": "./dist/generators/simple.js",
19
+ "./plugins/cargo": "./dist/plugins/cargo.js",
19
20
  "./plugins/git": "./dist/plugins/git.js",
20
21
  "./plugins/github": "./dist/plugins/github.js",
21
22
  "./plugins/gitlab": "./dist/plugins/gitlab.js",
22
23
  "./plugins/go": "./dist/plugins/go.js",
23
- "./providers/cargo": "./dist/providers/cargo.js",
24
24
  "./providers/npm": "./dist/providers/npm.js",
25
+ "./utils": "./dist/utils/index.js",
25
26
  "./package.json": "./package.json"
26
27
  },
27
28
  "publishConfig": {
@@ -30,7 +31,7 @@
30
31
  "dependencies": {
31
32
  "@clack/prompts": "^1.6.0",
32
33
  "@rainbowatcher/toml-edit-js": "^0.6.5",
33
- "js-yaml": "^5.1.0",
34
+ "js-yaml": "^5.2.0",
34
35
  "package-manager-detector": "^1.6.0",
35
36
  "semver": "^7.8.5",
36
37
  "tinyexec": "^1.2.4",
@@ -38,7 +39,7 @@
38
39
  "zod": "^4.4.3"
39
40
  },
40
41
  "devDependencies": {
41
- "@types/node": "^26.0.0",
42
+ "@types/node": "^26.0.1",
42
43
  "@types/semver": "^7.7.1",
43
44
  "tsdown": "^0.22.3",
44
45
  "typescript": "6.0.3",