tegami 0.1.5 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,19 @@
1
- import z$1, { z } from "zod";
1
+ import z, { z as z$1 } from "zod";
2
2
  import { AgentName } from "package-manager-detector";
3
3
 
4
4
  //#region src/utils/semver.d.ts
5
5
  type BumpType = "major" | "minor" | "patch";
6
6
  //#endregion
7
7
  //#region src/changelog/shared.d.ts
8
- declare const changelogPackageConfigSchema: z$1.ZodObject<{
9
- type: z$1.ZodOptional<z$1.ZodEnum<{
8
+ declare const changelogPackageConfigSchema: z.ZodObject<{
9
+ type: z.ZodOptional<z.ZodEnum<{
10
10
  major: "major";
11
11
  minor: "minor";
12
12
  patch: "patch";
13
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>;
14
+ replay: z.ZodOptional<z.ZodArray<z.ZodString>>;
15
+ }, z.core.$strip>;
16
+ type ChangelogPackageConfig = z.output<typeof changelogPackageConfigSchema>;
17
17
  //#endregion
18
18
  //#region src/changelog/parse.d.ts
19
19
  interface ChangelogEntry {
@@ -28,69 +28,69 @@ interface ChangelogEntry {
28
28
  title: string;
29
29
  content: string;
30
30
  }[];
31
+ /** Generated in memory and not yet written to `changelogDir`. */
32
+ virtual?: boolean;
31
33
  getRawContent: () => string;
32
34
  }
33
35
  //#endregion
34
36
  //#region src/plans/draft.d.ts
35
- interface PackagePlan {
37
+ interface PackageDraft {
36
38
  type?: BumpType;
39
+ prerelease?: string;
37
40
  bumpReasons?: Set<string>;
38
41
  changelogs?: ChangelogEntry[];
39
- prerelease?: string;
40
- publish?: boolean;
41
42
  npm?: {
42
43
  /** npm dist-tag used when publishing. */distTag?: string;
43
44
  };
44
45
  /** get the bumped version of a package */
45
46
  bumpVersion: (pkg: WorkspacePackage) => string;
46
47
  }
47
- declare class DraftPlan {
48
+ /** a draft describes all operations to perform before the actual publishing, such as version bumps. */
49
+ declare class Draft {
48
50
  #private;
49
51
  private readonly context;
52
+ /** package id -> draft */
50
53
  private readonly packages;
54
+ /** id -> changelog */
51
55
  private readonly changelogs;
52
56
  private readonly policies;
53
57
  constructor(context: TegamiContext);
54
- getPackagePlans(): Map<string, PackagePlan>;
55
- getPackagePlan(id: string): PackagePlan | undefined;
58
+ getPackageDrafts(): Map<string, PackageDraft>;
59
+ getPackageDraft(id: string): PackageDraft | undefined;
56
60
  bumpPackage(pkg: WorkspacePackage, {
57
61
  type,
58
62
  reason
59
63
  }: {
60
64
  type: BumpType;
61
65
  reason?: string;
62
- }): PackagePlan;
63
- dispatchPackage(pkg: WorkspacePackage, dispatch: (plan: PackagePlan) => void, onUpdate?: (plan: PackagePlan) => void): PackagePlan;
64
- getOrInitPackage(pkg: WorkspacePackage): PackagePlan;
66
+ }): PackageDraft;
67
+ dispatchPackage(pkg: WorkspacePackage, dispatch: (draft: PackageDraft) => void, onUpdate?: (draft: PackageDraft) => void): PackageDraft;
68
+ getOrInitPackage(pkg: WorkspacePackage): PackageDraft;
65
69
  hasPending(): boolean;
66
70
  getChangelogs(): ChangelogEntry[];
67
71
  getChangelog(id: string): ChangelogEntry | undefined;
68
72
  addChangelog(entry: ChangelogEntry): void;
69
73
  deleteChangelog(id: string): boolean;
70
- /** Apply the publish plan: update package versions, write the plan file, and consume changelog files. */
71
- applyPlan(): Promise<void>;
72
- addPolicy(policy: PlanPolicy): void;
73
- removePolicy(policy: PlanPolicy): void;
74
+ /** Apply version bumps, lock file, and changelog files. */
75
+ apply(): Promise<void>;
76
+ /** write persistent data to publish lock */
77
+ private writeLockFile;
78
+ addPolicy(policy: DraftPolicy): void;
79
+ removePolicy(policy: DraftPolicy): void;
74
80
  canApply(): boolean;
75
81
  /** Attach replaying changelog entries to packages (already bumped), and return the updated changelog entries. */
76
82
  private applyReplays;
77
83
  private appendChangelog;
78
- /** {@link applyPlan} but for `await using` syntax */
84
+ /** {@link apply} but for `await using` syntax */
79
85
  [Symbol.asyncDispose](): Promise<void>;
80
86
  }
81
- interface PlanPolicy {
87
+ interface DraftPolicy {
82
88
  id: string;
83
- onUpdate?: (this: DraftPlan, opts: {
84
- plan: PackagePlan;
89
+ onUpdate?: (this: Draft, opts: {
90
+ packageDraft: PackageDraft;
85
91
  pkg: WorkspacePackage;
86
92
  }) => void;
87
93
  }
88
- type CleanupResult = {
89
- state: "removed";
90
- } | {
91
- state: "skipped";
92
- reason: "missing" | "pending";
93
- };
94
94
  //#endregion
95
95
  //#region src/graph.d.ts
96
96
  /** Package discovered in the workspace. */
@@ -104,10 +104,10 @@ declare abstract class WorkspacePackage {
104
104
  /** note: this will only be available after package graph is resolved */
105
105
  getPackageOptions(): PackageOptions;
106
106
  setPackageOptions(options: PackageOptions): void;
107
- /** create the initial draft plan. */
108
- initPlan(): PackagePlan;
109
- /** configure an initial draft plan to match script-level configs. */
110
- configurePlan(plan: PackagePlan, group?: PackageGroup): void;
107
+ /** create the initial draft. */
108
+ initDraft(): PackageDraft;
109
+ /** configure an initial draft to match script-level configs. */
110
+ configureDraft(draft: PackageDraft, group?: PackageGroup): void;
111
111
  }
112
112
  interface PackageGroup {
113
113
  name: string;
@@ -143,12 +143,10 @@ interface TegamiContext {
143
143
  /** absolute path */
144
144
  changelogDir: string;
145
145
  /** absolute path */
146
- planPath: string;
146
+ lockPath: string;
147
147
  options: TegamiOptions;
148
148
  plugins: TegamiPlugin[];
149
149
  graph: PackageGraph;
150
- /** error if doesn't exist */
151
- getRegistryClient(pkgOrId: WorkspacePackage | string): RegistryClient;
152
150
  /** additional context when GitHub plugin is configured */
153
151
  github?: {
154
152
  repo?: string;
@@ -160,93 +158,14 @@ interface TegamiContext {
160
158
  };
161
159
  }
162
160
  //#endregion
163
- //#region src/plans/store.d.ts
164
- declare const packagePlanStoreSchema: z$1.ZodObject<{
165
- type: z$1.ZodOptional<z$1.ZodEnum<{
166
- major: "major";
167
- minor: "minor";
168
- patch: "patch";
169
- }>>;
170
- changelogIds: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
171
- bumpReasons: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
172
- npm: z$1.ZodOptional<z$1.ZodObject<{
173
- distTag: z$1.ZodOptional<z$1.ZodString>;
174
- }, z$1.core.$strip>>;
175
- publish: z$1.ZodBoolean;
176
- }, z$1.core.$strip>;
177
- /** the persisted plan data for actual publishing */
178
- declare const planStoreSchema: z$1.ZodCodec<z$1.ZodString, z$1.ZodObject<{
179
- id: z$1.ZodString;
180
- createdAt: z$1.ZodISODateTime;
181
- version: z$1.ZodDefault<z$1.ZodLiteral<"0.0.0">>;
182
- changelogs: z$1.ZodRecord<z$1.ZodString, z$1.ZodObject<{
183
- filename: z$1.ZodString;
184
- content: z$1.ZodString;
185
- }, z$1.core.$strip>>;
186
- packages: z$1.ZodRecord<z$1.ZodString, z$1.ZodObject<{
187
- type: z$1.ZodOptional<z$1.ZodEnum<{
188
- major: "major";
189
- minor: "minor";
190
- patch: "patch";
191
- }>>;
192
- changelogIds: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
193
- bumpReasons: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
194
- npm: z$1.ZodOptional<z$1.ZodObject<{
195
- distTag: z$1.ZodOptional<z$1.ZodString>;
196
- }, z$1.core.$strip>>;
197
- publish: z$1.ZodBoolean;
198
- }, z$1.core.$strip>>;
199
- }, z$1.core.$strip>>;
200
- type PlanStore = z$1.output<typeof planStoreSchema>;
201
- type PackagePlanStore = z$1.output<typeof packagePlanStoreSchema>;
202
- //#endregion
203
- //#region src/publish.d.ts
204
- interface PublishOptions {
205
- /** Validate the publish plan without publishing packages, creating tags, or running release plugins. */
206
- dryRun?: boolean;
207
- }
208
- type PublishResult = {
209
- state: "created";
210
- packages: PackagePublishResult[]; /** the persisted plan object. This is not a public API, can be changed without notice */
211
- _rawPlan: PlanStore;
212
- } | {
213
- state: "failed";
214
- error?: string;
215
- packages: PackagePublishResult[]; /** the persisted plan object. This is not a public API, can be changed without notice */
216
- _rawPlan: PlanStore;
217
- } | {
218
- state: "skipped";
219
- };
220
- type PackagePublishResult = ({
221
- state: "failed";
222
- error?: string;
223
- } | {
224
- state: "success";
225
- }) & {
226
- id: string;
227
- name: string;
228
- version: string;
229
- npm?: {
230
- distTag?: string;
231
- }; /** added by the `git` plugin */
232
- gitTag?: string;
233
- changelogs: ChangelogEntry[];
234
- };
235
- //#endregion
236
161
  //#region src/changelog/generate.d.ts
237
- interface GenerateChangelogOptions {
162
+ interface GenerateFromCommitsOptions {
238
163
  /** Start revision. Defaults to the latest reachable git tag, or all history if none exists. */
239
164
  from?: string;
240
165
  /** End revision. Defaults to HEAD. */
241
166
  to?: string;
242
- /**
243
- * Write changelog files to disk.
244
- *
245
- * @default true
246
- */
247
- write?: boolean;
248
167
  }
249
- interface GeneratedChangelog {
168
+ interface CommitChangelog {
250
169
  filename: string;
251
170
  content: string;
252
171
  packages: Record<string, BumpType | ChangelogPackageConfig>;
@@ -261,16 +180,88 @@ interface CommitChange {
261
180
  title: string;
262
181
  }
263
182
  //#endregion
183
+ //#region src/plans/publish.d.ts
184
+ interface PublishPlan {
185
+ options: PublishOptions;
186
+ /** id -> entry */
187
+ changelogs: Map<string, ChangelogEntry>;
188
+ /** id -> package data. The package id will always exist in package graph, stale items will be pruned at init-time */
189
+ packages: Map<string, PackagePublishPlan>;
190
+ }
191
+ interface PackagePublishPlan {
192
+ changelogs: ChangelogEntry[];
193
+ /** whether this package was version-bumped when the lock was written */
194
+ updated: boolean;
195
+ /** generated by Git plugin */
196
+ git?: {
197
+ /** the associated Git tag of package */tag: string;
198
+ };
199
+ /** generated by npm plugin */
200
+ npm?: {
201
+ /** dist tag to use if published */distTag?: string;
202
+ };
203
+ /** publish result, generated for all packages in publish plan after publishing */
204
+ publishResult?: PackagePublishResult;
205
+ /** preflight result, generated for all packages in publish plan after preflights */
206
+ preflight?: PublishPreflight;
207
+ }
208
+ interface PublishOptions {
209
+ /** Validate the publish plan without publishing packages, creating tags, or running release plugins. */
210
+ dryRun?: boolean;
211
+ }
212
+ type PackagePublishResult = {
213
+ type: "published" | "skipped";
214
+ } | {
215
+ type: "failed";
216
+ error: string;
217
+ };
218
+ //#endregion
219
+ //#region src/plans/lock.d.ts
220
+ /**
221
+ * the data structure of `publish-lock.yaml` file.
222
+ */
223
+ declare class PublishLock {
224
+ /** namespace -> data array */
225
+ private readonly data;
226
+ constructor(/** namespace -> data array */
227
+
228
+ data?: Map<string, unknown[]>);
229
+ /** write data to namespace, note that the `data` must be serializable in yaml */
230
+ write(namespace: string, data: unknown): void;
231
+ read(namespace: string): unknown | undefined;
232
+ size(namespace: string): number;
233
+ serialize(): string;
234
+ }
235
+ //#endregion
264
236
  //#region src/index.d.ts
237
+ interface GenerateChangelogOptions extends GenerateFromCommitsOptions {
238
+ /**
239
+ * Write changelog files to disk.
240
+ *
241
+ * @default true
242
+ */
243
+ write?: boolean;
244
+ }
265
245
  interface Tegami {
266
246
  /** Create pending changelog files from git commit history. */
267
- generateChangelog(options?: GenerateChangelogOptions): Promise<GeneratedChangelog[]>;
247
+ generateChangelog(options?: GenerateChangelogOptions): Promise<CommitChangelog[]>;
268
248
  /** Build a draft from pending changelog files. */
269
- draft(): Promise<DraftPlan>;
270
- /** Publish the current publish plan. */
271
- publish(options?: PublishOptions): Promise<PublishResult>;
272
- /** Remove the publish plan file after it has finished successfully. */
273
- cleanup(): Promise<CleanupResult>;
249
+ draft(): Promise<Draft>;
250
+ /** Publish packages from the publish lock. */
251
+ publish(options?: PublishOptions): Promise<PublishPlan | "skipped">;
252
+ /**
253
+ * Check publish status.
254
+ *
255
+ * Prefer `publish()` over this if you are publishing packages, it will also check the publish status.
256
+ */
257
+ publishStatus(): Promise<"pending" | "success" | "idle">;
258
+ /** Remove the publish lock file after publishing has finished successfully. */
259
+ cleanup(): Promise<{
260
+ state: "removed";
261
+ } | {
262
+ state: "skipped";
263
+ reason: "no-plan" | "pending";
264
+ }>;
274
265
  /** Internal APIs, do not use it unless you know what you are doing */
275
266
  _internal: {
276
267
  context(): Promise<TegamiContext>;
@@ -282,25 +273,25 @@ interface Tegami {
282
273
  declare function tegami<const Groups extends string = string>(options?: TegamiOptions<Groups>): Tegami;
283
274
  //#endregion
284
275
  //#region src/schemas.d.ts
285
- declare const packageManifestSchema: z.ZodObject<{
286
- name: z.ZodString;
287
- version: z.ZodOptional<z.ZodString>;
288
- private: z.ZodOptional<z.ZodBoolean>;
289
- publishConfig: z.ZodOptional<z.ZodObject<{
290
- access: z.ZodOptional<z.ZodEnum<{
276
+ declare const packageManifestSchema: z$1.ZodObject<{
277
+ name: z$1.ZodString;
278
+ version: z$1.ZodOptional<z$1.ZodString>;
279
+ private: z$1.ZodOptional<z$1.ZodBoolean>;
280
+ publishConfig: z$1.ZodOptional<z$1.ZodObject<{
281
+ access: z$1.ZodOptional<z$1.ZodEnum<{
291
282
  public: "public";
292
283
  restricted: "restricted";
293
284
  }>>;
294
- registry: z.ZodOptional<z.ZodString>;
295
- tag: z.ZodOptional<z.ZodString>;
296
- }, z.core.$loose>>;
297
- workspaces: z.ZodOptional<z.ZodArray<z.ZodString>>;
298
- dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
299
- devDependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
300
- peerDependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
301
- optionalDependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
302
- }, z.core.$loose>;
303
- type PackageManifest = z.infer<typeof packageManifestSchema>;
285
+ registry: z$1.ZodOptional<z$1.ZodString>;
286
+ tag: z$1.ZodOptional<z$1.ZodString>;
287
+ }, z$1.core.$loose>>;
288
+ workspaces: z$1.ZodOptional<z$1.ZodArray<z$1.ZodString>>;
289
+ dependencies: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
290
+ devDependencies: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
291
+ peerDependencies: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
292
+ optionalDependencies: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
293
+ }, z$1.core.$loose>;
294
+ type PackageManifest = z$1.infer<typeof packageManifestSchema>;
304
295
  //#endregion
305
296
  //#region src/providers/npm.d.ts
306
297
  declare const DEP_FIELDS$1: readonly ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"];
@@ -312,22 +303,7 @@ declare class NpmPackage extends WorkspacePackage {
312
303
  get name(): string;
313
304
  get version(): string;
314
305
  write(): Promise<void>;
315
- initPlan(): PackagePlan;
316
- }
317
- declare class NpmRegistryClient implements RegistryClient {
318
- #private;
319
- private readonly cwd;
320
- private readonly client;
321
- readonly id = "npm";
322
- constructor(cwd: string, client: AgentName, _graph: PackageGraph);
323
- supports(pkg: WorkspacePackage): boolean;
324
- isPackagePublished(pkg: NpmPackage): Promise<boolean>;
325
- publish(pkg: NpmPackage, {
326
- packageStore
327
- }: {
328
- store: PlanStore;
329
- packageStore: PackagePlanStore;
330
- }): Promise<void>;
306
+ initDraft(): PackageDraft;
331
307
  }
332
308
  type DependencySpec = {
333
309
  protocol: "npm";
@@ -368,7 +344,7 @@ interface NpmPluginOptions {
368
344
  * Note: `workspace:` protocols are not included.
369
345
  */
370
346
  onBreakPeerDep?: "set" | "error" | "ignore";
371
- /** update lockfile after appling publish plan */
347
+ /** update lockfile after applying a draft @default true */
372
348
  updateLockFile?: boolean;
373
349
  }
374
350
  declare function npm({
@@ -393,35 +369,17 @@ declare class CargoPackage extends WorkspacePackage {
393
369
  constructor(path: string, manifest: TomlTable, content: string, workspaceManifest?: TomlTable | undefined);
394
370
  get name(): string;
395
371
  get version(): string;
396
- initPlan(): PackagePlan;
397
372
  setVersion(version: string): void;
398
373
  write(): Promise<void>;
399
374
  patch(path: string, value: unknown): void;
400
375
  get packageInfo(): TomlTable;
401
376
  private get workspaceVersion();
402
377
  }
403
- declare class CargoRegistryClient implements RegistryClient {
404
- #private;
405
- private readonly graph;
406
- readonly id = "cargo";
407
- constructor(graph: PackageGraph);
408
- supports(pkg: WorkspacePackage): boolean;
409
- isPackagePublished(pkg: CargoPackage): Promise<boolean>;
410
- publishPreflight(pkg: CargoPackage, {
411
- store
412
- }: {
413
- store: PlanStore;
414
- }): PublishPreflight;
415
- publish(pkg: CargoPackage, _env: {
416
- store: PlanStore;
417
- packageStore: PackagePlanStore;
418
- }): Promise<void>;
419
- }
420
378
  interface CargoPluginOptions {
421
379
  /**
422
380
  * Update lock file after versioning.
423
381
  *
424
- * @default false
382
+ * @default true
425
383
  */
426
384
  updateLockFile?: boolean;
427
385
  bumpDep?: (opts: {
@@ -439,12 +397,9 @@ declare function cargo({
439
397
  /** Generates changelog content for a package release. */
440
398
  interface LogGenerator {
441
399
  generate(this: TegamiContext, opts: {
442
- packageId: string;
443
- packageName: string;
444
- version: string;
445
- changelogs: ChangelogEntry[];
446
- plan: PackagePlan;
447
- unstable_draft: DraftPlan;
400
+ pkg: WorkspacePackage;
401
+ packageDraft: PackageDraft;
402
+ draft: Draft;
448
403
  }): string | Promise<string>;
449
404
  }
450
405
  interface TegamiOptions<Groups extends string = string> {
@@ -452,9 +407,9 @@ interface TegamiOptions<Groups extends string = string> {
452
407
  cwd?: string;
453
408
  /** Directory containing pending changelog markdown files. */
454
409
  changelogDir?: string;
455
- /** Path to the publish plan file. */
456
- planPath?: string;
457
- /** Changelog generator used when applying a publish plan. */
410
+ /** Path to the publish lock file. Defaults to `.tegami/publish-lock.yaml`. */
411
+ lockPath?: string;
412
+ /** Changelog generator used when applying a draft. */
458
413
  generator?: LogGenerator;
459
414
  /** Per-package release and publish options keyed by package name. */
460
415
  packages?: Record<string, PackageOptions<NoInfer<Groups>>>;
@@ -462,6 +417,14 @@ interface TegamiOptions<Groups extends string = string> {
462
417
  groups?: Record<Groups, GroupOptions>;
463
418
  /** Package names, ids, or regex patterns to exclude from the dependency graph. */
464
419
  ignore?: (string | RegExp)[];
420
+ /**
421
+ * When creating draft, automatically generate changelogs from conventional commits.
422
+ *
423
+ * When disabled (default), it requires you to run `generateChangelog()` to pre-generate changelogs before draft.
424
+ *
425
+ * @default false
426
+ */
427
+ conventionalCommits?: boolean;
465
428
  npm?: NpmPluginOptions;
466
429
  cargo?: CargoPluginOptions;
467
430
  }
@@ -480,8 +443,6 @@ interface GroupOptions {
480
443
  interface PackageOptions<Group extends string = string> {
481
444
  /** Prerelease identifier appended to bumped versions (e.g. `alpha` → `1.1.0-alpha.0`). */
482
445
  prerelease?: string;
483
- /** Set to false to keep this package out of npm publishing. */
484
- publish?: boolean;
485
446
  /** the group of this package, ignored if the group doesn't exist */
486
447
  group?: Group;
487
448
  /** npm-specific options. */
@@ -497,56 +458,68 @@ interface TegamiPlugin {
497
458
  init?(this: TegamiContext): Awaitable<void>;
498
459
  /** Resolve workspace packages and dependency metadata into the shared graph. */
499
460
  resolve?(this: TegamiContext): Awaitable<void>;
500
- /** Register registry clients used to handle packages for different package managers. */
501
- createRegistryClient?(this: TegamiContext): Awaitable<RegistryClient | RegistryClient[] | void | undefined>;
502
- /** Called when Tegami creates an empty draft plan. */
503
- initPlan?(this: TegamiContext, plan: DraftPlan): Awaitable<DraftPlan | void | undefined>;
504
- /** Called when Tegami applies the draft plan. */
505
- applyPlan?(this: TegamiContext, draft: DraftPlan): Awaitable<void>;
506
- /** resolve the plan status, crucial to check if the plan is finished successfully, or needs retries */
507
- resolvePlanStatus?(this: TegamiContext, status: PublishPlanStatus, env: {
508
- plan: PlanStore;
509
- }): Awaitable<PublishPlanStatus>;
461
+ /** Called when Tegami creates an empty draft. */
462
+ initDraft?(this: TegamiContext, draft: Draft): Awaitable<Draft | void | undefined>;
463
+ /** Called when Tegami applies the draft. */
464
+ applyDraft?(this: TegamiContext, draft: Draft): Awaitable<void>;
465
+ /** Called when Tegami creates publish lock. */
466
+ initPublishLock?(this: TegamiContext, opts: {
467
+ lock: PublishLock;
468
+ draft: Draft;
469
+ }): Awaitable<void>;
470
+ /** Called when Tegami creates publish plan. */
471
+ initPublishPlan?(this: TegamiContext, opts: {
472
+ lock: PublishLock;
473
+ plan: PublishPlan;
474
+ }): Awaitable<void>;
475
+ /** Collect data before publishing a package, will be merged if multiple plugins return preflight data for this package. */
476
+ publishPreflight?(this: TegamiContext, opts: {
477
+ pkg: WorkspacePackage;
478
+ plan: PublishPlan;
479
+ }): Awaitable<PublishPreflight | void | undefined>;
480
+ /** 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. */
481
+ publish?(this: TegamiContext, opts: {
482
+ pkg: WorkspacePackage;
483
+ plan: PublishPlan;
484
+ }): Promise<PackagePublishResult | undefined | void>;
485
+ /**
486
+ * Resolve publish plan status, used to check if the plan is finished successfully, or needs retries.
487
+ *
488
+ * Each plugin should only report the status of its own tasks, Tegami will summarize the results from all plugins.
489
+ */
490
+ resolvePlanStatus?(this: TegamiContext, opts: {
491
+ plan: PublishPlan;
492
+ }): Awaitable<"success" | "pending" | undefined | void>;
510
493
  /** Called before a package will be published, return `false` to prevent from publishing. */
511
494
  willPublish?(this: TegamiContext, opts: {
512
495
  pkg: WorkspacePackage;
513
- }): Awaitable<PackagePublishResult | false | void | undefined>;
514
- /** Called after a package is published. */
496
+ }): Awaitable<false | void | undefined>;
497
+ /** Called after a package is published, skipped, or failed. */
515
498
  afterPublish?(this: TegamiContext, opts: {
516
499
  pkg: WorkspacePackage;
517
- result: PackagePublishResult;
518
- }): Awaitable<PackagePublishResult | void | undefined>;
519
- /** Called after publishing finishes. */
520
- afterPublishAll?(this: TegamiContext & {
521
- publishOptions: PublishOptions;
522
- }, result: PublishResult): Awaitable<PublishResult | void | undefined>;
500
+ plan: PublishPlan;
501
+ }): Awaitable<void>;
502
+ /** Called after all publishing finishes. */
503
+ afterPublishAll?(this: TegamiContext, opts: {
504
+ plan: PublishPlan;
505
+ }): Awaitable<void>;
523
506
  /** CLI lifecycle hooks. */
524
507
  cli?: {
525
- /** Called once before a CLI command runs. */init?(this: TegamiContext): Awaitable<void>; /** Called after `tegami version` returns a draft plan. */
526
- publishPlanCreated?(this: TegamiContext, draft: DraftPlan): Awaitable<void>; /** Called after `tegami version` applies a publish plan. */
527
- publishPlanApplied?(this: TegamiContext, draft: DraftPlan): Awaitable<void>;
508
+ /** Called once before a CLI command runs. */init?(this: TegamiContext): Awaitable<void>; /** Called after `tegami version` returns a draft. */
509
+ draftCreated?(this: TegamiContext, draft: Draft): Awaitable<void>; /** Called after `tegami version` applies a draft. */
510
+ draftApplied?(this: TegamiContext, draft: Draft): Awaitable<void>;
528
511
  };
529
512
  }
530
513
  type Awaitable<T> = T | Promise<T>;
531
- interface PublishPlanStatus {
532
- state: "pending" | "success" | "missing";
533
- }
534
514
  interface PublishPreflight {
535
- /** Package ids that must be published before this one, this will automatically disallow circular dependency. */
536
- wait: string[];
537
- }
538
- interface RegistryClient {
539
- id: string;
540
- supports(pkg: WorkspacePackage): boolean;
541
- isPackagePublished(pkg: WorkspacePackage): Promise<boolean>;
542
- publishPreflight?(pkg: WorkspacePackage, env: {
543
- store: PlanStore;
544
- packageStore: PackagePlanStore;
545
- }): Awaitable<PublishPreflight | void | undefined>;
546
- publish(pkg: WorkspacePackage, env: {
547
- store: PlanStore;
548
- packageStore: PackagePlanStore;
549
- }): Promise<void>;
515
+ /** if the package should be published, default to `true`. */
516
+ publish?: boolean;
517
+ /**
518
+ * Package ids that must be published before this one, this will automatically disallow circular dependency.
519
+ *
520
+ * It is okay to add unpublished packages to `wait`, they will be ignored.
521
+ */
522
+ wait?: string[];
550
523
  }
551
524
  //#endregion
552
- 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, GenerateChangelogOptions 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, GeneratedChangelog as x, tegami as y };
525
+ export { PackageDraft as A, CommitChangelog as C, WorkspacePackage as D, PackageGroup as E, Draft as O, PublishPlan as S, PackageGraph as T, tegami as _, PublishPreflight as a, PackagePublishResult as b, TegamiPluginOption as c, cargo as d, NpmPackage as f, Tegami as g, GenerateChangelogOptions as h, PackageOptions as i, DraftPolicy as k, CargoPackage as l, npm as m, GroupOptions as n, TegamiOptions as o, NpmPluginOptions as p, LogGenerator as r, TegamiPlugin as s, Awaitable as t, CargoPluginOptions as u, PublishLock as v, TegamiContext as w, PublishOptions as x, PackagePublishPlan as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tegami",
3
- "version": "0.1.5",
3
+ "version": "0.2.0",
4
4
  "description": "Utility for package versioning & publish",
5
5
  "license": "MIT",
6
6
  "author": "Fuma Nama",
@@ -26,24 +26,23 @@
26
26
  "access": "public"
27
27
  },
28
28
  "dependencies": {
29
- "@clack/prompts": "^1.5.1",
29
+ "@clack/prompts": "^1.6.0",
30
30
  "@rainbowatcher/toml-edit-js": "^0.6.5",
31
31
  "commander": "^15.0.0",
32
- "js-yaml": "^4.2.0",
32
+ "js-yaml": "^5.1.0",
33
33
  "mdast-util-from-markdown": "^2.0.3",
34
34
  "mdast-util-to-markdown": "^2.1.2",
35
35
  "package-manager-detector": "^1.6.0",
36
- "semver": "^7.8.4",
36
+ "semver": "^7.8.5",
37
37
  "tinyexec": "^1.2.4",
38
38
  "tinyglobby": "^0.2.17",
39
39
  "zod": "^4.4.3"
40
40
  },
41
41
  "devDependencies": {
42
- "@types/js-yaml": "^4.0.9",
43
42
  "@types/mdast": "^4.0.4",
44
- "@types/node": "^25.5.0",
43
+ "@types/node": "^26.0.0",
45
44
  "@types/semver": "^7.7.1",
46
- "tsdown": "^0.22.2",
45
+ "tsdown": "^0.22.3",
47
46
  "typescript": "6.0.3",
48
47
  "@repo/typescript-config": "0.0.0"
49
48
  },