tegami 1.1.1 → 1.1.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,203 +1,18 @@
1
1
  import { c as somePromise, i as isNodeError, n as execFailure, r as handlePluginError, s as joinPath } from "./error-BhMYq9iW.js";
2
2
  import { t as _accessExpressionAsString } from "./_accessExpressionAsString-QhbUZzwv.js";
3
3
  import { n as _validateReport, t as _createStandardSchema } from "./_createStandardSchema-BGQyz-uA.js";
4
+ import { a as parseChangelogFile, i as parsePublishLock, n as validateChangelogStore, r as validatePackageStore } from "./draft-CzUiQasJ.js";
4
5
  import { t as _assertGuard } from "./_assertGuard-BBn2NbSz.js";
5
6
  import { n as WorkspacePackage } from "./graph-BmXTJZxx.js";
6
- import { a as parseChangelogFile, i as parsePublishLock, n as validateChangelogStore, r as validatePackageStore } from "./draft-DsxZOCOb.js";
7
7
  import fs, { readFile, writeFile } from "node:fs/promises";
8
8
  import path, { join } from "node:path";
9
9
  import { x } from "tinyexec";
10
10
  import * as semver$1 from "semver";
11
- import { parse as parse$1 } from "yaml";
12
- import { glob } from "tinyglobby";
11
+ import { parse as parse$1, parseDocument, stringify } from "yaml";
13
12
  import { detect } from "package-manager-detector";
14
13
  import { tmpdir } from "node:os";
15
14
  import { intro, note, outro } from "@clack/prompts";
16
- //#region src/providers/npm/schema.ts
17
- const assertPnpmWorkspace = (() => {
18
- const _io0 = (input) => void 0 === input.packages || Array.isArray(input.packages) && input.packages.every((elem) => "string" === typeof elem);
19
- const _ao0 = (input, _path, _exceptionable = true) => void 0 === input.packages || (Array.isArray(input.packages) || _assertGuard(_exceptionable, {
20
- method: "typia.createAssert",
21
- path: _path + ".packages",
22
- expected: "(Array<string> | undefined)",
23
- value: input.packages
24
- }, _errorFactory)) && input.packages.every((elem, _index2) => "string" === typeof elem || _assertGuard(_exceptionable, {
25
- method: "typia.createAssert",
26
- path: _path + ".packages[" + _index2 + "]",
27
- expected: "string",
28
- value: elem
29
- }, _errorFactory)) || _assertGuard(_exceptionable, {
30
- method: "typia.createAssert",
31
- path: _path + ".packages",
32
- expected: "(Array<string> | undefined)",
33
- value: input.packages
34
- }, _errorFactory);
35
- const __is = (input) => "object" === typeof input && null !== input && false === Array.isArray(input) && _io0(input);
36
- let _errorFactory;
37
- return (input, errorFactory) => {
38
- if (false === __is(input)) {
39
- _errorFactory = errorFactory;
40
- ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input && false === Array.isArray(input) || _assertGuard(true, {
41
- method: "typia.createAssert",
42
- path: _path + "",
43
- expected: "PnpmWorkspace",
44
- value: input
45
- }, _errorFactory)) && _ao0(input, _path + "", true) || _assertGuard(true, {
46
- method: "typia.createAssert",
47
- path: _path + "",
48
- expected: "PnpmWorkspace",
49
- value: input
50
- }, _errorFactory))(input, "$input", true);
51
- }
52
- return input;
53
- };
54
- })();
55
- const assertPackageManifest = (() => {
56
- const _io0 = (input) => "string" === typeof input.name && (void 0 === input.version || "string" === typeof input.version) && (void 0 === input["private"] || "boolean" === typeof input["private"]) && (void 0 === input.publishConfig || "object" === typeof input.publishConfig && null !== input.publishConfig && false === Array.isArray(input.publishConfig) && _io1(input.publishConfig)) && (void 0 === input.scripts || "object" === typeof input.scripts && null !== input.scripts && false === Array.isArray(input.scripts) && _io2(input.scripts)) && (void 0 === input.workspaces || Array.isArray(input.workspaces) && input.workspaces.every((elem) => "string" === typeof elem)) && (void 0 === input.dependencies || "object" === typeof input.dependencies && null !== input.dependencies && false === Array.isArray(input.dependencies) && _io2(input.dependencies)) && (void 0 === input.devDependencies || "object" === typeof input.devDependencies && null !== input.devDependencies && false === Array.isArray(input.devDependencies) && _io2(input.devDependencies)) && (void 0 === input.peerDependencies || "object" === typeof input.peerDependencies && null !== input.peerDependencies && false === Array.isArray(input.peerDependencies) && _io2(input.peerDependencies)) && (void 0 === input.optionalDependencies || "object" === typeof input.optionalDependencies && null !== input.optionalDependencies && false === Array.isArray(input.optionalDependencies) && _io2(input.optionalDependencies));
57
- const _io1 = (input) => (void 0 === input.access || "public" === input.access || "restricted" === input.access) && (void 0 === input.registry || "string" === typeof input.registry) && (void 0 === input.tag || "string" === typeof input.tag);
58
- const _io2 = (input) => Object.keys(input).every((key) => {
59
- const value = input[key];
60
- if (void 0 === value) return true;
61
- return "string" === typeof value;
62
- });
63
- const _ao0 = (input, _path, _exceptionable = true) => ("string" === typeof input.name || _assertGuard(_exceptionable, {
64
- method: "typia.createAssert",
65
- path: _path + ".name",
66
- expected: "string",
67
- value: input.name
68
- }, _errorFactory)) && (void 0 === input.version || "string" === typeof input.version || _assertGuard(_exceptionable, {
69
- method: "typia.createAssert",
70
- path: _path + ".version",
71
- expected: "(string | undefined)",
72
- value: input.version
73
- }, _errorFactory)) && (void 0 === input["private"] || "boolean" === typeof input["private"] || _assertGuard(_exceptionable, {
74
- method: "typia.createAssert",
75
- path: _path + "[\"private\"]",
76
- expected: "(boolean | undefined)",
77
- value: input["private"]
78
- }, _errorFactory)) && (void 0 === input.publishConfig || ("object" === typeof input.publishConfig && null !== input.publishConfig && false === Array.isArray(input.publishConfig) || _assertGuard(_exceptionable, {
79
- method: "typia.createAssert",
80
- path: _path + ".publishConfig",
81
- expected: "(__type | undefined)",
82
- value: input.publishConfig
83
- }, _errorFactory)) && _ao1(input.publishConfig, _path + ".publishConfig", _exceptionable) || _assertGuard(_exceptionable, {
84
- method: "typia.createAssert",
85
- path: _path + ".publishConfig",
86
- expected: "(__type | undefined)",
87
- value: input.publishConfig
88
- }, _errorFactory)) && (void 0 === input.scripts || ("object" === typeof input.scripts && null !== input.scripts && false === Array.isArray(input.scripts) || _assertGuard(_exceptionable, {
89
- method: "typia.createAssert",
90
- path: _path + ".scripts",
91
- expected: "(Record<string, string> | undefined)",
92
- value: input.scripts
93
- }, _errorFactory)) && _ao2(input.scripts, _path + ".scripts", _exceptionable) || _assertGuard(_exceptionable, {
94
- method: "typia.createAssert",
95
- path: _path + ".scripts",
96
- expected: "(Record<string, string> | undefined)",
97
- value: input.scripts
98
- }, _errorFactory)) && (void 0 === input.workspaces || (Array.isArray(input.workspaces) || _assertGuard(_exceptionable, {
99
- method: "typia.createAssert",
100
- path: _path + ".workspaces",
101
- expected: "(Array<string> | undefined)",
102
- value: input.workspaces
103
- }, _errorFactory)) && input.workspaces.every((elem, _index2) => "string" === typeof elem || _assertGuard(_exceptionable, {
104
- method: "typia.createAssert",
105
- path: _path + ".workspaces[" + _index2 + "]",
106
- expected: "string",
107
- value: elem
108
- }, _errorFactory)) || _assertGuard(_exceptionable, {
109
- method: "typia.createAssert",
110
- path: _path + ".workspaces",
111
- expected: "(Array<string> | undefined)",
112
- value: input.workspaces
113
- }, _errorFactory)) && (void 0 === input.dependencies || ("object" === typeof input.dependencies && null !== input.dependencies && false === Array.isArray(input.dependencies) || _assertGuard(_exceptionable, {
114
- method: "typia.createAssert",
115
- path: _path + ".dependencies",
116
- expected: "(Record<string, string> | undefined)",
117
- value: input.dependencies
118
- }, _errorFactory)) && _ao2(input.dependencies, _path + ".dependencies", _exceptionable) || _assertGuard(_exceptionable, {
119
- method: "typia.createAssert",
120
- path: _path + ".dependencies",
121
- expected: "(Record<string, string> | undefined)",
122
- value: input.dependencies
123
- }, _errorFactory)) && (void 0 === input.devDependencies || ("object" === typeof input.devDependencies && null !== input.devDependencies && false === Array.isArray(input.devDependencies) || _assertGuard(_exceptionable, {
124
- method: "typia.createAssert",
125
- path: _path + ".devDependencies",
126
- expected: "(Record<string, string> | undefined)",
127
- value: input.devDependencies
128
- }, _errorFactory)) && _ao2(input.devDependencies, _path + ".devDependencies", _exceptionable) || _assertGuard(_exceptionable, {
129
- method: "typia.createAssert",
130
- path: _path + ".devDependencies",
131
- expected: "(Record<string, string> | undefined)",
132
- value: input.devDependencies
133
- }, _errorFactory)) && (void 0 === input.peerDependencies || ("object" === typeof input.peerDependencies && null !== input.peerDependencies && false === Array.isArray(input.peerDependencies) || _assertGuard(_exceptionable, {
134
- method: "typia.createAssert",
135
- path: _path + ".peerDependencies",
136
- expected: "(Record<string, string> | undefined)",
137
- value: input.peerDependencies
138
- }, _errorFactory)) && _ao2(input.peerDependencies, _path + ".peerDependencies", _exceptionable) || _assertGuard(_exceptionable, {
139
- method: "typia.createAssert",
140
- path: _path + ".peerDependencies",
141
- expected: "(Record<string, string> | undefined)",
142
- value: input.peerDependencies
143
- }, _errorFactory)) && (void 0 === input.optionalDependencies || ("object" === typeof input.optionalDependencies && null !== input.optionalDependencies && false === Array.isArray(input.optionalDependencies) || _assertGuard(_exceptionable, {
144
- method: "typia.createAssert",
145
- path: _path + ".optionalDependencies",
146
- expected: "(Record<string, string> | undefined)",
147
- value: input.optionalDependencies
148
- }, _errorFactory)) && _ao2(input.optionalDependencies, _path + ".optionalDependencies", _exceptionable) || _assertGuard(_exceptionable, {
149
- method: "typia.createAssert",
150
- path: _path + ".optionalDependencies",
151
- expected: "(Record<string, string> | undefined)",
152
- value: input.optionalDependencies
153
- }, _errorFactory));
154
- const _ao1 = (input, _path, _exceptionable = true) => (void 0 === input.access || "public" === input.access || "restricted" === input.access || _assertGuard(_exceptionable, {
155
- method: "typia.createAssert",
156
- path: _path + ".access",
157
- expected: "(\"public\" | \"restricted\" | undefined)",
158
- value: input.access
159
- }, _errorFactory)) && (void 0 === input.registry || "string" === typeof input.registry || _assertGuard(_exceptionable, {
160
- method: "typia.createAssert",
161
- path: _path + ".registry",
162
- expected: "(string | undefined)",
163
- value: input.registry
164
- }, _errorFactory)) && (void 0 === input.tag || "string" === typeof input.tag || _assertGuard(_exceptionable, {
165
- method: "typia.createAssert",
166
- path: _path + ".tag",
167
- expected: "(string | undefined)",
168
- value: input.tag
169
- }, _errorFactory));
170
- const _ao2 = (input, _path, _exceptionable = true) => false === _exceptionable || Object.keys(input).every((key) => {
171
- const value = input[key];
172
- if (void 0 === value) return true;
173
- return "string" === typeof value || _assertGuard(_exceptionable, {
174
- method: "typia.createAssert",
175
- path: _path + _accessExpressionAsString(key),
176
- expected: "string",
177
- value
178
- }, _errorFactory);
179
- });
180
- const __is = (input) => "object" === typeof input && null !== input && _io0(input);
181
- let _errorFactory;
182
- return (input, errorFactory) => {
183
- if (false === __is(input)) {
184
- _errorFactory = errorFactory;
185
- ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _assertGuard(true, {
186
- method: "typia.createAssert",
187
- path: _path + "",
188
- expected: "PackageManifest",
189
- value: input
190
- }, _errorFactory)) && _ao0(input, _path + "", true) || _assertGuard(true, {
191
- method: "typia.createAssert",
192
- path: _path + "",
193
- expected: "PackageManifest",
194
- value: input
195
- }, _errorFactory))(input, "$input", true);
196
- }
197
- return input;
198
- };
199
- })();
200
- //#endregion
15
+ import { glob } from "tinyglobby";
201
16
  //#region src/plans/publish.ts
202
17
  async function initPublishPlan(context, options) {
203
18
  let lock;
@@ -463,17 +278,12 @@ async function npmTrust(context, pkg, options, repo) {
463
278
  }
464
279
  }
465
280
  //#endregion
466
- //#region src/providers/npm.ts
467
- const DEP_FIELDS = [
468
- "dependencies",
469
- "devDependencies",
470
- "peerDependencies",
471
- "optionalDependencies"
472
- ];
281
+ //#region src/providers/npm/graph.ts
473
282
  var NpmPackage = class extends WorkspacePackage {
474
283
  path;
475
284
  manifest;
476
285
  manager = "npm";
286
+ dependencies;
477
287
  constructor(path, manifest) {
478
288
  super();
479
289
  this.path = path;
@@ -507,100 +317,667 @@ var NpmPackage = class extends WorkspacePackage {
507
317
  draft.npm.distTag ??= draft.prerelease;
508
318
  }
509
319
  }
510
- };
511
- function parseDependencySpec(context, dependent, name, range) {
512
- const { graph } = context;
513
- if (range.startsWith("workspace:")) return {
514
- range: range.slice(10),
515
- linked: graph.get(`npm:${name}`),
516
- protocol: "workspace"
517
- };
518
- if (range.startsWith("file:")) {
519
- let target = path.resolve(dependent.path, range.slice(5));
520
- if (path.basename(target) === "package.json") target = path.dirname(target);
521
- return {
522
- protocol: "file",
523
- raw: range,
524
- linked: graph.getPackages().find((pkg) => pkg instanceof NpmPackage && pkg.path === target)
525
- };
526
- }
527
- if (range.startsWith("npm:")) {
528
- const spec = range.slice(4);
529
- const separator = spec.lastIndexOf("@");
530
- if (separator <= 0) return;
531
- const alias = spec.slice(0, separator);
532
- return {
533
- alias,
534
- linked: graph.get(`npm:${alias}`),
535
- range: spec.slice(separator + 1),
536
- protocol: "npm"
537
- };
320
+ listDependencies(graph) {
321
+ return this.dependencies ??= listDependencies(graph, this);
538
322
  }
539
- return {
540
- linked: graph.get(`npm:${name}`),
541
- range
542
- };
543
- }
544
- function formatDependencySpec(spec) {
545
- if (spec.protocol === "workspace") return `workspace:${spec.range}`;
546
- if (spec.protocol === "file") return spec.raw;
547
- if (spec.protocol === "npm") return `npm:${spec.alias}@${spec.range}`;
548
- return spec.range;
549
- }
550
- const validateNpmPackageLock = (() => {
551
- const _io0 = (input) => "string" === typeof input.id && (void 0 === input.distTag || "string" === typeof input.distTag);
552
- const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.id || _report(_exceptionable, {
553
- path: _path + ".id",
554
- expected: "string",
555
- value: input.id
556
- }), void 0 === input.distTag || "string" === typeof input.distTag || _report(_exceptionable, {
557
- path: _path + ".distTag",
558
- expected: "(string | undefined)",
559
- value: input.distTag
560
- })].every((flag) => flag);
561
- const __is = (input) => "object" === typeof input && null !== input && _io0(input);
562
- let errors;
563
- let _report;
564
- return _createStandardSchema((input) => {
565
- if (false === __is(input)) {
566
- errors = [];
567
- _report = _validateReport(errors);
568
- ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
569
- path: _path + "",
570
- expected: "NpmPackageLock",
571
- value: input
572
- })) && _vo0(input, _path + "", true) || _report(true, {
573
- path: _path + "",
574
- expected: "NpmPackageLock",
575
- value: input
576
- }))(input, "$input", true);
577
- const success = 0 === errors.length;
578
- return success ? {
579
- success,
580
- data: input
581
- } : {
582
- success,
583
- errors,
584
- data: input
585
- };
586
- }
587
- return {
588
- success: true,
589
- data: input
590
- };
323
+ };
324
+ const assertPnpmWorkspace = (() => {
325
+ const _io0 = (input) => (void 0 === input.packages || Array.isArray(input.packages) && input.packages.every((elem) => "string" === typeof elem)) && (void 0 === input.catalog || "object" === typeof input.catalog && null !== input.catalog && false === Array.isArray(input.catalog) && _io1(input.catalog)) && (void 0 === input.catalogs || "object" === typeof input.catalogs && null !== input.catalogs && false === Array.isArray(input.catalogs) && _io2(input.catalogs));
326
+ const _io1 = (input) => Object.keys(input).every((key) => {
327
+ const value = input[key];
328
+ if (void 0 === value) return true;
329
+ return "string" === typeof value;
591
330
  });
592
- })();
593
- const validateNpmMarkLatestLock = (() => {
594
- const _io0 = (input) => "string" === typeof input.id;
595
- const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.id || _report(_exceptionable, {
596
- path: _path + ".id",
597
- expected: "string",
598
- value: input.id
599
- })].every((flag) => flag);
600
- const __is = (input) => "object" === typeof input && null !== input && _io0(input);
601
- let errors;
602
- let _report;
603
- return _createStandardSchema((input) => {
331
+ const _io2 = (input) => Object.keys(input).every((key) => {
332
+ const value = input[key];
333
+ if (void 0 === value) return true;
334
+ return "object" === typeof value && null !== value && false === Array.isArray(value) && _io1(value);
335
+ });
336
+ const _ao0 = (input, _path, _exceptionable = true) => (void 0 === input.packages || (Array.isArray(input.packages) || _assertGuard(_exceptionable, {
337
+ method: "typia.createAssert",
338
+ path: _path + ".packages",
339
+ expected: "(Array<string> | undefined)",
340
+ value: input.packages
341
+ }, _errorFactory)) && input.packages.every((elem, _index2) => "string" === typeof elem || _assertGuard(_exceptionable, {
342
+ method: "typia.createAssert",
343
+ path: _path + ".packages[" + _index2 + "]",
344
+ expected: "string",
345
+ value: elem
346
+ }, _errorFactory)) || _assertGuard(_exceptionable, {
347
+ method: "typia.createAssert",
348
+ path: _path + ".packages",
349
+ expected: "(Array<string> | undefined)",
350
+ value: input.packages
351
+ }, _errorFactory)) && (void 0 === input.catalog || ("object" === typeof input.catalog && null !== input.catalog && false === Array.isArray(input.catalog) || _assertGuard(_exceptionable, {
352
+ method: "typia.createAssert",
353
+ path: _path + ".catalog",
354
+ expected: "(Record<string, string> | undefined)",
355
+ value: input.catalog
356
+ }, _errorFactory)) && _ao1(input.catalog, _path + ".catalog", _exceptionable) || _assertGuard(_exceptionable, {
357
+ method: "typia.createAssert",
358
+ path: _path + ".catalog",
359
+ expected: "(Record<string, string> | undefined)",
360
+ value: input.catalog
361
+ }, _errorFactory)) && (void 0 === input.catalogs || ("object" === typeof input.catalogs && null !== input.catalogs && false === Array.isArray(input.catalogs) || _assertGuard(_exceptionable, {
362
+ method: "typia.createAssert",
363
+ path: _path + ".catalogs",
364
+ expected: "(Record<string, Record<string, string>> | undefined)",
365
+ value: input.catalogs
366
+ }, _errorFactory)) && _ao2(input.catalogs, _path + ".catalogs", _exceptionable) || _assertGuard(_exceptionable, {
367
+ method: "typia.createAssert",
368
+ path: _path + ".catalogs",
369
+ expected: "(Record<string, Record<string, string>> | undefined)",
370
+ value: input.catalogs
371
+ }, _errorFactory));
372
+ const _ao1 = (input, _path, _exceptionable = true) => false === _exceptionable || Object.keys(input).every((key) => {
373
+ const value = input[key];
374
+ if (void 0 === value) return true;
375
+ return "string" === typeof value || _assertGuard(_exceptionable, {
376
+ method: "typia.createAssert",
377
+ path: _path + _accessExpressionAsString(key),
378
+ expected: "string",
379
+ value
380
+ }, _errorFactory);
381
+ });
382
+ const _ao2 = (input, _path, _exceptionable = true) => false === _exceptionable || Object.keys(input).every((key) => {
383
+ const value = input[key];
384
+ if (void 0 === value) return true;
385
+ return ("object" === typeof value && null !== value && false === Array.isArray(value) || _assertGuard(_exceptionable, {
386
+ method: "typia.createAssert",
387
+ path: _path + _accessExpressionAsString(key),
388
+ expected: "Record<string, string>",
389
+ value
390
+ }, _errorFactory)) && _ao1(value, _path + _accessExpressionAsString(key), _exceptionable) || _assertGuard(_exceptionable, {
391
+ method: "typia.createAssert",
392
+ path: _path + _accessExpressionAsString(key),
393
+ expected: "Record<string, string>",
394
+ value
395
+ }, _errorFactory);
396
+ });
397
+ const __is = (input) => "object" === typeof input && null !== input && false === Array.isArray(input) && _io0(input);
398
+ let _errorFactory;
399
+ return (input, errorFactory) => {
400
+ if (false === __is(input)) {
401
+ _errorFactory = errorFactory;
402
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input && false === Array.isArray(input) || _assertGuard(true, {
403
+ method: "typia.createAssert",
404
+ path: _path + "",
405
+ expected: "PnpmWorkspace",
406
+ value: input
407
+ }, _errorFactory)) && _ao0(input, _path + "", true) || _assertGuard(true, {
408
+ method: "typia.createAssert",
409
+ path: _path + "",
410
+ expected: "PnpmWorkspace",
411
+ value: input
412
+ }, _errorFactory))(input, "$input", true);
413
+ }
414
+ return input;
415
+ };
416
+ })();
417
+ const assertPackageManifest = (() => {
418
+ const _io0 = (input) => "string" === typeof input.name && (void 0 === input.version || "string" === typeof input.version) && (void 0 === input["private"] || "boolean" === typeof input["private"]) && (void 0 === input.publishConfig || "object" === typeof input.publishConfig && null !== input.publishConfig && false === Array.isArray(input.publishConfig) && _io1(input.publishConfig)) && (void 0 === input.scripts || "object" === typeof input.scripts && null !== input.scripts && false === Array.isArray(input.scripts) && _io2(input.scripts)) && null !== input.workspaces && (void 0 === input.workspaces || Array.isArray(input.workspaces) && input.workspaces.every((elem) => "string" === typeof elem) || "object" === typeof input.workspaces && null !== input.workspaces && false === Array.isArray(input.workspaces) && _io3(input.workspaces)) && (void 0 === input.catalog || "object" === typeof input.catalog && null !== input.catalog && false === Array.isArray(input.catalog) && _io2(input.catalog)) && (void 0 === input.catalogs || "object" === typeof input.catalogs && null !== input.catalogs && false === Array.isArray(input.catalogs) && _io4(input.catalogs)) && (void 0 === input.dependencies || "object" === typeof input.dependencies && null !== input.dependencies && false === Array.isArray(input.dependencies) && _io2(input.dependencies)) && (void 0 === input.devDependencies || "object" === typeof input.devDependencies && null !== input.devDependencies && false === Array.isArray(input.devDependencies) && _io2(input.devDependencies)) && (void 0 === input.peerDependencies || "object" === typeof input.peerDependencies && null !== input.peerDependencies && false === Array.isArray(input.peerDependencies) && _io2(input.peerDependencies)) && (void 0 === input.optionalDependencies || "object" === typeof input.optionalDependencies && null !== input.optionalDependencies && false === Array.isArray(input.optionalDependencies) && _io2(input.optionalDependencies));
419
+ const _io1 = (input) => (void 0 === input.access || "public" === input.access || "restricted" === input.access) && (void 0 === input.registry || "string" === typeof input.registry) && (void 0 === input.tag || "string" === typeof input.tag);
420
+ const _io2 = (input) => Object.keys(input).every((key) => {
421
+ const value = input[key];
422
+ if (void 0 === value) return true;
423
+ return "string" === typeof value;
424
+ });
425
+ const _io3 = (input) => (void 0 === input.packages || Array.isArray(input.packages) && input.packages.every((elem) => "string" === typeof elem)) && (void 0 === input.catalog || "object" === typeof input.catalog && null !== input.catalog && false === Array.isArray(input.catalog) && _io2(input.catalog)) && (void 0 === input.catalogs || "object" === typeof input.catalogs && null !== input.catalogs && false === Array.isArray(input.catalogs) && _io4(input.catalogs));
426
+ const _io4 = (input) => Object.keys(input).every((key) => {
427
+ const value = input[key];
428
+ if (void 0 === value) return true;
429
+ return "object" === typeof value && null !== value && false === Array.isArray(value) && _io2(value);
430
+ });
431
+ const _ao0 = (input, _path, _exceptionable = true) => ("string" === typeof input.name || _assertGuard(_exceptionable, {
432
+ method: "typia.createAssert",
433
+ path: _path + ".name",
434
+ expected: "string",
435
+ value: input.name
436
+ }, _errorFactory)) && (void 0 === input.version || "string" === typeof input.version || _assertGuard(_exceptionable, {
437
+ method: "typia.createAssert",
438
+ path: _path + ".version",
439
+ expected: "(string | undefined)",
440
+ value: input.version
441
+ }, _errorFactory)) && (void 0 === input["private"] || "boolean" === typeof input["private"] || _assertGuard(_exceptionable, {
442
+ method: "typia.createAssert",
443
+ path: _path + "[\"private\"]",
444
+ expected: "(boolean | undefined)",
445
+ value: input["private"]
446
+ }, _errorFactory)) && (void 0 === input.publishConfig || ("object" === typeof input.publishConfig && null !== input.publishConfig && false === Array.isArray(input.publishConfig) || _assertGuard(_exceptionable, {
447
+ method: "typia.createAssert",
448
+ path: _path + ".publishConfig",
449
+ expected: "(__type | undefined)",
450
+ value: input.publishConfig
451
+ }, _errorFactory)) && _ao1(input.publishConfig, _path + ".publishConfig", _exceptionable) || _assertGuard(_exceptionable, {
452
+ method: "typia.createAssert",
453
+ path: _path + ".publishConfig",
454
+ expected: "(__type | undefined)",
455
+ value: input.publishConfig
456
+ }, _errorFactory)) && (void 0 === input.scripts || ("object" === typeof input.scripts && null !== input.scripts && false === Array.isArray(input.scripts) || _assertGuard(_exceptionable, {
457
+ method: "typia.createAssert",
458
+ path: _path + ".scripts",
459
+ expected: "(Record<string, string> | undefined)",
460
+ value: input.scripts
461
+ }, _errorFactory)) && _ao2(input.scripts, _path + ".scripts", _exceptionable) || _assertGuard(_exceptionable, {
462
+ method: "typia.createAssert",
463
+ path: _path + ".scripts",
464
+ expected: "(Record<string, string> | undefined)",
465
+ value: input.scripts
466
+ }, _errorFactory)) && (null !== input.workspaces || _assertGuard(_exceptionable, {
467
+ method: "typia.createAssert",
468
+ path: _path + ".workspaces",
469
+ expected: "(Array<string> | BunWorkspaces | undefined)",
470
+ value: input.workspaces
471
+ }, _errorFactory)) && (void 0 === input.workspaces || Array.isArray(input.workspaces) && input.workspaces.every((elem, _index3) => "string" === typeof elem || _assertGuard(_exceptionable, {
472
+ method: "typia.createAssert",
473
+ path: _path + ".workspaces[" + _index3 + "]",
474
+ expected: "string",
475
+ value: elem
476
+ }, _errorFactory)) || "object" === typeof input.workspaces && null !== input.workspaces && false === Array.isArray(input.workspaces) && _ao3(input.workspaces, _path + ".workspaces", _exceptionable) || _assertGuard(_exceptionable, {
477
+ method: "typia.createAssert",
478
+ path: _path + ".workspaces",
479
+ expected: "(Array<string> | BunWorkspaces | undefined)",
480
+ value: input.workspaces
481
+ }, _errorFactory) || _assertGuard(_exceptionable, {
482
+ method: "typia.createAssert",
483
+ path: _path + ".workspaces",
484
+ expected: "(Array<string> | BunWorkspaces | undefined)",
485
+ value: input.workspaces
486
+ }, _errorFactory)) && (void 0 === input.catalog || ("object" === typeof input.catalog && null !== input.catalog && false === Array.isArray(input.catalog) || _assertGuard(_exceptionable, {
487
+ method: "typia.createAssert",
488
+ path: _path + ".catalog",
489
+ expected: "(Record<string, string> | undefined)",
490
+ value: input.catalog
491
+ }, _errorFactory)) && _ao2(input.catalog, _path + ".catalog", _exceptionable) || _assertGuard(_exceptionable, {
492
+ method: "typia.createAssert",
493
+ path: _path + ".catalog",
494
+ expected: "(Record<string, string> | undefined)",
495
+ value: input.catalog
496
+ }, _errorFactory)) && (void 0 === input.catalogs || ("object" === typeof input.catalogs && null !== input.catalogs && false === Array.isArray(input.catalogs) || _assertGuard(_exceptionable, {
497
+ method: "typia.createAssert",
498
+ path: _path + ".catalogs",
499
+ expected: "(Record<string, Record<string, string>> | undefined)",
500
+ value: input.catalogs
501
+ }, _errorFactory)) && _ao4(input.catalogs, _path + ".catalogs", _exceptionable) || _assertGuard(_exceptionable, {
502
+ method: "typia.createAssert",
503
+ path: _path + ".catalogs",
504
+ expected: "(Record<string, Record<string, string>> | undefined)",
505
+ value: input.catalogs
506
+ }, _errorFactory)) && (void 0 === input.dependencies || ("object" === typeof input.dependencies && null !== input.dependencies && false === Array.isArray(input.dependencies) || _assertGuard(_exceptionable, {
507
+ method: "typia.createAssert",
508
+ path: _path + ".dependencies",
509
+ expected: "(Record<string, string> | undefined)",
510
+ value: input.dependencies
511
+ }, _errorFactory)) && _ao2(input.dependencies, _path + ".dependencies", _exceptionable) || _assertGuard(_exceptionable, {
512
+ method: "typia.createAssert",
513
+ path: _path + ".dependencies",
514
+ expected: "(Record<string, string> | undefined)",
515
+ value: input.dependencies
516
+ }, _errorFactory)) && (void 0 === input.devDependencies || ("object" === typeof input.devDependencies && null !== input.devDependencies && false === Array.isArray(input.devDependencies) || _assertGuard(_exceptionable, {
517
+ method: "typia.createAssert",
518
+ path: _path + ".devDependencies",
519
+ expected: "(Record<string, string> | undefined)",
520
+ value: input.devDependencies
521
+ }, _errorFactory)) && _ao2(input.devDependencies, _path + ".devDependencies", _exceptionable) || _assertGuard(_exceptionable, {
522
+ method: "typia.createAssert",
523
+ path: _path + ".devDependencies",
524
+ expected: "(Record<string, string> | undefined)",
525
+ value: input.devDependencies
526
+ }, _errorFactory)) && (void 0 === input.peerDependencies || ("object" === typeof input.peerDependencies && null !== input.peerDependencies && false === Array.isArray(input.peerDependencies) || _assertGuard(_exceptionable, {
527
+ method: "typia.createAssert",
528
+ path: _path + ".peerDependencies",
529
+ expected: "(Record<string, string> | undefined)",
530
+ value: input.peerDependencies
531
+ }, _errorFactory)) && _ao2(input.peerDependencies, _path + ".peerDependencies", _exceptionable) || _assertGuard(_exceptionable, {
532
+ method: "typia.createAssert",
533
+ path: _path + ".peerDependencies",
534
+ expected: "(Record<string, string> | undefined)",
535
+ value: input.peerDependencies
536
+ }, _errorFactory)) && (void 0 === input.optionalDependencies || ("object" === typeof input.optionalDependencies && null !== input.optionalDependencies && false === Array.isArray(input.optionalDependencies) || _assertGuard(_exceptionable, {
537
+ method: "typia.createAssert",
538
+ path: _path + ".optionalDependencies",
539
+ expected: "(Record<string, string> | undefined)",
540
+ value: input.optionalDependencies
541
+ }, _errorFactory)) && _ao2(input.optionalDependencies, _path + ".optionalDependencies", _exceptionable) || _assertGuard(_exceptionable, {
542
+ method: "typia.createAssert",
543
+ path: _path + ".optionalDependencies",
544
+ expected: "(Record<string, string> | undefined)",
545
+ value: input.optionalDependencies
546
+ }, _errorFactory));
547
+ const _ao1 = (input, _path, _exceptionable = true) => (void 0 === input.access || "public" === input.access || "restricted" === input.access || _assertGuard(_exceptionable, {
548
+ method: "typia.createAssert",
549
+ path: _path + ".access",
550
+ expected: "(\"public\" | \"restricted\" | undefined)",
551
+ value: input.access
552
+ }, _errorFactory)) && (void 0 === input.registry || "string" === typeof input.registry || _assertGuard(_exceptionable, {
553
+ method: "typia.createAssert",
554
+ path: _path + ".registry",
555
+ expected: "(string | undefined)",
556
+ value: input.registry
557
+ }, _errorFactory)) && (void 0 === input.tag || "string" === typeof input.tag || _assertGuard(_exceptionable, {
558
+ method: "typia.createAssert",
559
+ path: _path + ".tag",
560
+ expected: "(string | undefined)",
561
+ value: input.tag
562
+ }, _errorFactory));
563
+ const _ao2 = (input, _path, _exceptionable = true) => false === _exceptionable || Object.keys(input).every((key) => {
564
+ const value = input[key];
565
+ if (void 0 === value) return true;
566
+ return "string" === typeof value || _assertGuard(_exceptionable, {
567
+ method: "typia.createAssert",
568
+ path: _path + _accessExpressionAsString(key),
569
+ expected: "string",
570
+ value
571
+ }, _errorFactory);
572
+ });
573
+ const _ao3 = (input, _path, _exceptionable = true) => (void 0 === input.packages || (Array.isArray(input.packages) || _assertGuard(_exceptionable, {
574
+ method: "typia.createAssert",
575
+ path: _path + ".packages",
576
+ expected: "(Array<string> | undefined)",
577
+ value: input.packages
578
+ }, _errorFactory)) && input.packages.every((elem, _index4) => "string" === typeof elem || _assertGuard(_exceptionable, {
579
+ method: "typia.createAssert",
580
+ path: _path + ".packages[" + _index4 + "]",
581
+ expected: "string",
582
+ value: elem
583
+ }, _errorFactory)) || _assertGuard(_exceptionable, {
584
+ method: "typia.createAssert",
585
+ path: _path + ".packages",
586
+ expected: "(Array<string> | undefined)",
587
+ value: input.packages
588
+ }, _errorFactory)) && (void 0 === input.catalog || ("object" === typeof input.catalog && null !== input.catalog && false === Array.isArray(input.catalog) || _assertGuard(_exceptionable, {
589
+ method: "typia.createAssert",
590
+ path: _path + ".catalog",
591
+ expected: "(Record<string, string> | undefined)",
592
+ value: input.catalog
593
+ }, _errorFactory)) && _ao2(input.catalog, _path + ".catalog", _exceptionable) || _assertGuard(_exceptionable, {
594
+ method: "typia.createAssert",
595
+ path: _path + ".catalog",
596
+ expected: "(Record<string, string> | undefined)",
597
+ value: input.catalog
598
+ }, _errorFactory)) && (void 0 === input.catalogs || ("object" === typeof input.catalogs && null !== input.catalogs && false === Array.isArray(input.catalogs) || _assertGuard(_exceptionable, {
599
+ method: "typia.createAssert",
600
+ path: _path + ".catalogs",
601
+ expected: "(Record<string, Record<string, string>> | undefined)",
602
+ value: input.catalogs
603
+ }, _errorFactory)) && _ao4(input.catalogs, _path + ".catalogs", _exceptionable) || _assertGuard(_exceptionable, {
604
+ method: "typia.createAssert",
605
+ path: _path + ".catalogs",
606
+ expected: "(Record<string, Record<string, string>> | undefined)",
607
+ value: input.catalogs
608
+ }, _errorFactory));
609
+ const _ao4 = (input, _path, _exceptionable = true) => false === _exceptionable || Object.keys(input).every((key) => {
610
+ const value = input[key];
611
+ if (void 0 === value) return true;
612
+ return ("object" === typeof value && null !== value && false === Array.isArray(value) || _assertGuard(_exceptionable, {
613
+ method: "typia.createAssert",
614
+ path: _path + _accessExpressionAsString(key),
615
+ expected: "Record<string, string>",
616
+ value
617
+ }, _errorFactory)) && _ao2(value, _path + _accessExpressionAsString(key), _exceptionable) || _assertGuard(_exceptionable, {
618
+ method: "typia.createAssert",
619
+ path: _path + _accessExpressionAsString(key),
620
+ expected: "Record<string, string>",
621
+ value
622
+ }, _errorFactory);
623
+ });
624
+ const __is = (input) => "object" === typeof input && null !== input && _io0(input);
625
+ let _errorFactory;
626
+ return (input, errorFactory) => {
627
+ if (false === __is(input)) {
628
+ _errorFactory = errorFactory;
629
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _assertGuard(true, {
630
+ method: "typia.createAssert",
631
+ path: _path + "",
632
+ expected: "PackageManifest",
633
+ value: input
634
+ }, _errorFactory)) && _ao0(input, _path + "", true) || _assertGuard(true, {
635
+ method: "typia.createAssert",
636
+ path: _path + "",
637
+ expected: "PackageManifest",
638
+ value: input
639
+ }, _errorFactory))(input, "$input", true);
640
+ }
641
+ return input;
642
+ };
643
+ })();
644
+ const DEP_FIELDS = [
645
+ "dependencies",
646
+ "devDependencies",
647
+ "peerDependencies",
648
+ "optionalDependencies"
649
+ ];
650
+ function listDependencies(graph, pkg) {
651
+ const out = [];
652
+ for (const field of DEP_FIELDS) {
653
+ const table = pkg.manifest[field];
654
+ if (!table) continue;
655
+ for (const [name, raw] of Object.entries(table)) out.push(resolveDependency(graph, pkg, field, name, raw, (range) => {
656
+ table[name] = range;
657
+ }));
658
+ }
659
+ return out;
660
+ }
661
+ function parseDependencySpec(raw) {
662
+ if (raw.startsWith("workspace:")) {
663
+ const body = raw.slice(10);
664
+ if (!body) return {
665
+ protocol: "workspace",
666
+ range: "*"
667
+ };
668
+ if (body.startsWith(".") || body.startsWith("/")) return {
669
+ protocol: "workspace",
670
+ range: body,
671
+ path: body
672
+ };
673
+ const separator = body.lastIndexOf("@");
674
+ if (separator > 0) return {
675
+ protocol: "workspace",
676
+ packageName: body.slice(0, separator),
677
+ range: body.slice(separator + 1) || "*"
678
+ };
679
+ if (separator === 0) return {
680
+ protocol: "workspace",
681
+ packageName: body,
682
+ range: "*"
683
+ };
684
+ return {
685
+ protocol: "workspace",
686
+ range: body
687
+ };
688
+ }
689
+ if (raw.startsWith("file:")) return {
690
+ protocol: "file",
691
+ path: raw.slice(5)
692
+ };
693
+ if (raw.startsWith("portal:")) return {
694
+ protocol: "portal",
695
+ path: raw.slice(7)
696
+ };
697
+ if (raw === "catalog:") return {
698
+ protocol: "catalog",
699
+ catalogName: "default"
700
+ };
701
+ if (raw.startsWith("catalog:")) return {
702
+ protocol: "catalog",
703
+ catalogName: raw.slice(8).trim() || "default"
704
+ };
705
+ if (raw.startsWith("npm:")) {
706
+ const spec = raw.slice(4);
707
+ const separator = spec.lastIndexOf("@");
708
+ if (separator > 0) return {
709
+ protocol: "npm",
710
+ alias: spec.slice(0, separator),
711
+ range: spec.slice(separator + 1)
712
+ };
713
+ }
714
+ return { range: raw };
715
+ }
716
+ function formatDependencySpec(spec, range) {
717
+ switch (spec.protocol) {
718
+ case "workspace":
719
+ if (spec.path) return `workspace:${spec.path}`;
720
+ if (spec.packageName) {
721
+ const next = range ?? spec.range;
722
+ return `workspace:${spec.packageName}@${next}`;
723
+ }
724
+ return `workspace:${range ?? spec.range}`;
725
+ case "file": return `file:${spec.path}`;
726
+ case "portal": return `portal:${spec.path}`;
727
+ case "catalog": return spec.catalogName === "default" ? "catalog:" : `catalog:${spec.catalogName}`;
728
+ case "npm": return `npm:${spec.alias}@${range ?? spec.range}`;
729
+ default: return range ?? spec.range;
730
+ }
731
+ }
732
+ async function resolveNpmGraph(cwd, client) {
733
+ const packages = /* @__PURE__ */ new Map();
734
+ const packagesByPath = /* @__PURE__ */ new Map();
735
+ const catalogSources = [];
736
+ function addPackage(packagePath, manifest) {
737
+ const pkg = new NpmPackage(packagePath, manifest);
738
+ packages.set(pkg.name, pkg);
739
+ packagesByPath.set(packagePath, pkg);
740
+ }
741
+ const patterns = [];
742
+ const rootManifest = await readManifest(cwd).catch(() => void 0);
743
+ if (rootManifest) {
744
+ catalogSources.push(createRootCatalogSource(rootManifest));
745
+ if (rootManifest.name) addPackage(cwd, rootManifest);
746
+ if (Array.isArray(rootManifest.workspaces)) patterns.push(...rootManifest.workspaces);
747
+ else if (rootManifest.workspaces?.packages) patterns.push(...rootManifest.workspaces.packages);
748
+ }
749
+ if (client === "pnpm") {
750
+ const pnpmWorkspacePath = path.join(cwd, "pnpm-workspace.yaml");
751
+ const content = await readFile(pnpmWorkspacePath, "utf8").catch((error) => {
752
+ if (isNodeError(error) && error.code === "ENOENT") return void 0;
753
+ throw error;
754
+ });
755
+ const data = content && assertPnpmWorkspace(parse$1(content));
756
+ if (data) {
757
+ catalogSources.push(createPnpmCatalogSource(pnpmWorkspacePath, data));
758
+ patterns.push(...data.packages ?? []);
759
+ }
760
+ } else if (client === "yarn") {
761
+ const yarnCatalog = await readYarnCatalog(cwd);
762
+ if (yarnCatalog) catalogSources.push(yarnCatalog);
763
+ }
764
+ if (patterns?.length) {
765
+ const candidatePaths = await expandWorkspacePatterns(cwd, patterns);
766
+ await Promise.all(candidatePaths.map(async (packagePath) => {
767
+ const manifest = await readManifest(packagePath).catch(() => void 0);
768
+ if (!manifest) return;
769
+ addPackage(packagePath, manifest);
770
+ }));
771
+ }
772
+ return {
773
+ root: cwd,
774
+ packages,
775
+ packagesByPath,
776
+ catalogs: catalogSources
777
+ };
778
+ }
779
+ function resolveDependency(graph, dependent, field, name, raw, write) {
780
+ const spec = parseDependencySpec(raw);
781
+ const linked = resolveLinkedPackage(graph, dependent, name, spec);
782
+ let range;
783
+ let customSetRange;
784
+ switch (spec.protocol) {
785
+ case "catalog":
786
+ for (const source of graph.catalogs) {
787
+ const resolved = source.resolve(name, spec.catalogName);
788
+ if (!resolved) continue;
789
+ range = resolved;
790
+ customSetRange = (v) => source.setRange(name, spec.catalogName, v);
791
+ break;
792
+ }
793
+ break;
794
+ case "workspace":
795
+ range = semver$1.validRange(spec.range) ? spec.range : void 0;
796
+ break;
797
+ case "npm":
798
+ case void 0:
799
+ range = spec.range;
800
+ break;
801
+ }
802
+ return {
803
+ field,
804
+ name,
805
+ spec,
806
+ linked,
807
+ range,
808
+ setRange(nextRange) {
809
+ if (customSetRange) {
810
+ customSetRange(nextRange);
811
+ return;
812
+ }
813
+ write(formatDependencySpec(spec, nextRange));
814
+ }
815
+ };
816
+ }
817
+ function resolveLinkedPackage(graph, dependent, name, spec) {
818
+ switch (spec.protocol) {
819
+ case "workspace":
820
+ if (spec.path) return findPackageByPath(graph, dependent.path, spec.path);
821
+ return graph.packages.get(spec.packageName || name);
822
+ case "file":
823
+ case "portal": return findPackageByPath(graph, dependent.path, spec.path);
824
+ case "npm": return graph.packages.get(spec.alias);
825
+ default: return graph.packages.get(name);
826
+ }
827
+ }
828
+ function findPackageByPath(graph, from, target) {
829
+ let absolute = path.resolve(from, target);
830
+ if (path.basename(absolute) === "package.json") absolute = path.dirname(absolute);
831
+ return graph.packagesByPath.get(absolute);
832
+ }
833
+ async function expandWorkspacePatterns(cwd, patterns) {
834
+ if (patterns.length === 0) return [];
835
+ return (await glob(patterns, {
836
+ absolute: true,
837
+ cwd,
838
+ ignore: ["**/node_modules/**", "**/dist/**"],
839
+ onlyDirectories: true,
840
+ onlyFiles: false
841
+ })).map((item) => item.endsWith(path.sep) ? item.slice(0, -1) : item);
842
+ }
843
+ async function readManifest(packagePath) {
844
+ const content = await readFile(path.join(packagePath, "package.json"), "utf8");
845
+ const parsed = JSON.parse(content);
846
+ assertPackageManifest(parsed);
847
+ return parsed;
848
+ }
849
+ function createPnpmCatalogSource(filePath, workspace) {
850
+ return {
851
+ resolve(name, catalogName) {
852
+ if (catalogName === "default") return workspace.catalog?.[name];
853
+ return workspace.catalogs?.[catalogName]?.[name];
854
+ },
855
+ setRange(name, catalogName, range) {
856
+ if (catalogName === "default") {
857
+ workspace.catalog ??= {};
858
+ workspace.catalog[name] = range;
859
+ } else {
860
+ workspace.catalogs ??= {};
861
+ workspace.catalogs[catalogName] ??= {};
862
+ workspace.catalogs[catalogName][name] = range;
863
+ }
864
+ },
865
+ async write() {
866
+ await writeFile(filePath, `${stringify(workspace, { lineWidth: 0 }).trim()}\n`);
867
+ }
868
+ };
869
+ }
870
+ function createRootCatalogSource(manifest) {
871
+ return {
872
+ resolve(name, catalogName) {
873
+ const fromWorkspaces = typeof manifest.workspaces === "object" && !Array.isArray(manifest.workspaces) ? catalogName === "default" ? manifest.workspaces.catalog?.[name] : manifest.workspaces.catalogs?.[catalogName]?.[name] : void 0;
874
+ if (fromWorkspaces) return fromWorkspaces;
875
+ if (catalogName === "default") return manifest.catalog?.[name];
876
+ return manifest.catalogs?.[catalogName]?.[name];
877
+ },
878
+ setRange(name, catalogName, range) {
879
+ if (typeof manifest.workspaces === "object" && !Array.isArray(manifest.workspaces)) if (catalogName === "default") {
880
+ manifest.workspaces.catalog ??= {};
881
+ manifest.workspaces.catalog[name] = range;
882
+ } else {
883
+ manifest.workspaces.catalogs ??= {};
884
+ manifest.workspaces.catalogs[catalogName] ??= {};
885
+ manifest.workspaces.catalogs[catalogName][name] = range;
886
+ }
887
+ else if (catalogName === "default") {
888
+ manifest.catalog ??= {};
889
+ manifest.catalog[name] = range;
890
+ } else {
891
+ manifest.catalogs ??= {};
892
+ manifest.catalogs[catalogName] ??= {};
893
+ manifest.catalogs[catalogName][name] = range;
894
+ }
895
+ }
896
+ };
897
+ }
898
+ async function readYarnCatalog(cwd) {
899
+ const filePath = path.join(cwd, ".yarnrc.yml");
900
+ const content = await readFile(filePath, "utf8").catch(() => void 0);
901
+ if (!content) return;
902
+ const doc = parseDocument(content);
903
+ return {
904
+ resolve(name, catalogName) {
905
+ const value = doc.getIn(catalogName === "default" ? ["catalog", name] : [
906
+ "catalogs",
907
+ catalogName,
908
+ name
909
+ ]);
910
+ return typeof value === "string" ? value : void 0;
911
+ },
912
+ setRange(name, catalogName, range) {
913
+ doc.setIn(catalogName === "default" ? ["catalog", name] : [
914
+ "catalogs",
915
+ catalogName,
916
+ name
917
+ ], range);
918
+ },
919
+ async write() {
920
+ const output = doc.toString();
921
+ await writeFile(filePath, output.endsWith("\n") ? output : `${output}\n`);
922
+ }
923
+ };
924
+ }
925
+ //#endregion
926
+ //#region src/providers/npm.ts
927
+ const validateNpmPackageLock = (() => {
928
+ const _io0 = (input) => "string" === typeof input.id && (void 0 === input.distTag || "string" === typeof input.distTag);
929
+ const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.id || _report(_exceptionable, {
930
+ path: _path + ".id",
931
+ expected: "string",
932
+ value: input.id
933
+ }), void 0 === input.distTag || "string" === typeof input.distTag || _report(_exceptionable, {
934
+ path: _path + ".distTag",
935
+ expected: "(string | undefined)",
936
+ value: input.distTag
937
+ })].every((flag) => flag);
938
+ const __is = (input) => "object" === typeof input && null !== input && _io0(input);
939
+ let errors;
940
+ let _report;
941
+ return _createStandardSchema((input) => {
942
+ if (false === __is(input)) {
943
+ errors = [];
944
+ _report = _validateReport(errors);
945
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
946
+ path: _path + "",
947
+ expected: "NpmPackageLock",
948
+ value: input
949
+ })) && _vo0(input, _path + "", true) || _report(true, {
950
+ path: _path + "",
951
+ expected: "NpmPackageLock",
952
+ value: input
953
+ }))(input, "$input", true);
954
+ const success = 0 === errors.length;
955
+ return success ? {
956
+ success,
957
+ data: input
958
+ } : {
959
+ success,
960
+ errors,
961
+ data: input
962
+ };
963
+ }
964
+ return {
965
+ success: true,
966
+ data: input
967
+ };
968
+ });
969
+ })();
970
+ const validateNpmMarkLatestLock = (() => {
971
+ const _io0 = (input) => "string" === typeof input.id;
972
+ const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.id || _report(_exceptionable, {
973
+ path: _path + ".id",
974
+ expected: "string",
975
+ value: input.id
976
+ })].every((flag) => flag);
977
+ const __is = (input) => "object" === typeof input && null !== input && _io0(input);
978
+ let errors;
979
+ let _report;
980
+ return _createStandardSchema((input) => {
604
981
  if (false === __is(input)) {
605
982
  errors = [];
606
983
  _report = _validateReport(errors);
@@ -650,8 +1027,12 @@ function npm({ client: defaultClient, onBreakPeerDep = "set", updateLockFile = t
650
1027
  this.npm = { client };
651
1028
  },
652
1029
  async resolve() {
653
- await discoverNpmPackages(this.cwd, (pkg) => this.graph.add(pkg));
654
- active = this.graph.getPackages().some((pkg) => pkg instanceof NpmPackage);
1030
+ if (!this.npm) return;
1031
+ const graph = await resolveNpmGraph(this.cwd, this.npm.client);
1032
+ if (graph.packages.size === 0) return;
1033
+ this.npm.graph = graph;
1034
+ for (const pkg of graph.packages.values()) this.graph.add(pkg);
1035
+ active = true;
655
1036
  },
656
1037
  async publishPreflight({ pkg }) {
657
1038
  if (!(pkg instanceof NpmPackage)) return;
@@ -720,50 +1101,35 @@ function npm({ client: defaultClient, onBreakPeerDep = "set", updateLockFile = t
720
1101
  plan.addPolicy(depsPolicy(this, getBumpDepType));
721
1102
  },
722
1103
  async applyDraft(draft) {
723
- if (!active) return;
724
- const { graph } = this;
1104
+ if (!active || !this.npm?.graph) return;
1105
+ const npmGraph = this.npm.graph;
725
1106
  const writes = [];
726
- for (const pkg of graph.getPackages()) {
727
- if (!(pkg instanceof NpmPackage)) continue;
1107
+ for (const pkg of npmGraph.packages.values()) {
728
1108
  const bumped = draft.getPackageDraft(pkg.id)?.bumpVersion(pkg);
729
1109
  if (bumped) pkg.manifest.version = bumped;
730
1110
  }
731
- for (const pkg of graph.getPackages()) {
732
- if (!(pkg instanceof NpmPackage)) continue;
733
- for (const field of DEP_FIELDS) {
734
- const dependencies = pkg.manifest[field];
735
- if (!dependencies) continue;
736
- for (const [k, v] of Object.entries(dependencies)) {
737
- const spec = parseDependencySpec(this, pkg, k, v);
738
- if (!spec?.linked || spec.protocol === "workspace" || spec.protocol === "file") continue;
739
- if (!semver$1.validRange(spec.range)) continue;
740
- if (!spec.linked.version || semver$1.satisfies(spec.linked.version, spec.range)) continue;
741
- let updatedRange;
742
- const isPeer = field === "peerDependencies";
743
- if (isPeer && onBreakPeerDep === "ignore") continue;
744
- if (isPeer && onBreakPeerDep === "set") updatedRange = spec.linked.version;
745
- else if (isPeer && onBreakPeerDep === "error") throw new Error(`[Tegami] the version of "${spec.linked.name}" is beyond its peer dependency constraint "${v}" in package "${pkg.name}", please update the constraint to satisfy.`);
746
- else if (spec.range.startsWith("^")) updatedRange = `^${spec.linked.version}`;
747
- else if (spec.range.startsWith("~")) updatedRange = `~${spec.linked.version}`;
748
- else updatedRange = spec.linked.version;
749
- dependencies[k] = formatDependencySpec({
750
- ...spec,
751
- range: updatedRange
752
- });
753
- }
1111
+ for (const pkg of npmGraph.packages.values()) {
1112
+ for (const dep of pkg.listDependencies(npmGraph)) {
1113
+ if (!dep.linked || !dep.range || !dep.setRange) continue;
1114
+ if (!dep.linked.version || semver$1.satisfies(dep.linked.version, dep.range)) continue;
1115
+ const isPeer = dep.field === "peerDependencies";
1116
+ if (isPeer && onBreakPeerDep === "ignore") continue;
1117
+ let updatedRange;
1118
+ if (isPeer && onBreakPeerDep === "set") updatedRange = dep.linked.version;
1119
+ else if (isPeer && onBreakPeerDep === "error") throw new Error(`[Tegami] the version of "${dep.linked.name}" is beyond its peer dependency constraint "${formatDependencySpec(dep.spec)}" in package "${pkg.name}", please update the constraint to satisfy.`);
1120
+ else if (dep.range.startsWith("^")) updatedRange = `^${dep.linked.version}`;
1121
+ else if (dep.range.startsWith("~")) updatedRange = `~${dep.linked.version}`;
1122
+ else updatedRange = dep.linked.version;
1123
+ dep.setRange(updatedRange);
754
1124
  }
755
1125
  writes.push(pkg.write());
756
1126
  }
1127
+ for (const source of npmGraph.catalogs) writes.push(source.write?.());
757
1128
  await Promise.all(writes);
758
1129
  },
759
1130
  async applyCliDraft() {
760
1131
  if (!active || !updateLockFile) return;
761
- let args;
762
- if (client === "npm") args = ["ci"];
763
- else if (client === "yarn") args = ["install", "--immutable"];
764
- else if (client === "bun") args = ["install", "--frozen-lockfile"];
765
- else args = ["install", "--frozen-lockfile"];
766
- const result = await x(client, args, { nodeOptions: { cwd: this.cwd } });
1132
+ const result = await x(client, ["install"], { nodeOptions: { cwd: this.cwd } });
767
1133
  if (result.exitCode !== 0) throw execFailure("Failed to update lockfile.", result);
768
1134
  },
769
1135
  initCli(cli) {
@@ -773,42 +1139,36 @@ function npm({ client: defaultClient, onBreakPeerDep = "set", updateLockFile = t
773
1139
  };
774
1140
  }
775
1141
  function depsPolicy(context, getBumpDepType) {
776
- const { graph } = context;
1142
+ const npmGraph = context.npm?.graph;
1143
+ if (!npmGraph) throw new Error("npm graph is missing");
777
1144
  const dependentMap = /* @__PURE__ */ new Map();
778
- for (const pkg of graph.getPackages()) {
779
- if (!(pkg instanceof NpmPackage)) continue;
780
- for (const kind of DEP_FIELDS) {
781
- const dependencies = pkg.manifest[kind];
782
- if (!dependencies) continue;
783
- for (const [name, range] of Object.entries(dependencies)) {
784
- const spec = parseDependencySpec(context, pkg, name, range);
785
- if (!spec?.linked) continue;
786
- const refs = dependentMap.get(spec.linked.id);
787
- if (refs) refs.push({
788
- dependent: pkg,
789
- kind,
790
- name,
791
- spec
792
- });
793
- else dependentMap.set(spec.linked.id, [{
794
- dependent: pkg,
795
- kind,
796
- name,
797
- spec
798
- }]);
799
- }
800
- }
1145
+ for (const pkg of npmGraph.packages.values()) for (const resolved of pkg.listDependencies(npmGraph)) {
1146
+ if (!resolved.linked) continue;
1147
+ const refs = dependentMap.get(resolved.linked.id);
1148
+ const ref = {
1149
+ dependent: pkg,
1150
+ kind: resolved.field,
1151
+ name: resolved.name,
1152
+ spec: resolved.spec,
1153
+ resolved
1154
+ };
1155
+ if (refs) refs.push(ref);
1156
+ else dependentMap.set(resolved.linked.id, [ref]);
801
1157
  }
802
- function needsUpdate(spec, target) {
803
- if (spec.linked && spec.protocol === "workspace") switch (spec.range) {
804
- case "":
805
- case "*": return true;
806
- case "^":
807
- case "~": return !semver$1.satisfies(target, `${spec.range}${spec.linked.version}`);
1158
+ function needsDependencyUpdate(resolved, target) {
1159
+ if (!resolved.linked) return false;
1160
+ switch (resolved.spec.protocol) {
1161
+ case "file":
1162
+ case "portal": return true;
1163
+ case "workspace": switch (resolved.spec.range) {
1164
+ case "":
1165
+ case "*": return true;
1166
+ case "^":
1167
+ case "~": return !semver$1.satisfies(target, `${resolved.spec.range}${resolved.linked.version ?? "0.0.0"}`);
1168
+ }
808
1169
  }
809
- if (spec.linked && spec.protocol === "file") return true;
810
- if (spec.protocol === "file" || !semver$1.validRange(spec.range)) return false;
811
- return !semver$1.satisfies(target, spec.range);
1170
+ if (!resolved.range || !semver$1.validRange(resolved.range)) return false;
1171
+ return !semver$1.satisfies(target, resolved.range);
812
1172
  }
813
1173
  return {
814
1174
  id: "npm:deps",
@@ -820,7 +1180,7 @@ function depsPolicy(context, getBumpDepType) {
820
1180
  if (!bumped) return;
821
1181
  for (const dep of deps) {
822
1182
  if (pkg.group?.options.syncBump && dep.dependent.group === pkg.group) continue;
823
- if (!needsUpdate(dep.spec, bumped)) continue;
1183
+ if (!needsDependencyUpdate(dep.resolved, bumped)) continue;
824
1184
  const bumpType = getBumpDepType(dep);
825
1185
  if (bumpType === false) continue;
826
1186
  this.bumpPackage(dep.dependent, {
@@ -888,42 +1248,5 @@ async function isPackagePublished(name, version, registry) {
888
1248
  if (!response.ok) throw new Error(`Unable to validate ${name}@${version} against the npm registry${registry ? ` "${registry}"` : ""}.`);
889
1249
  return true;
890
1250
  }
891
- async function discoverNpmPackages(cwd, add) {
892
- const rootManifest = await readManifest(cwd).catch(() => void 0);
893
- const pnpmPatterns = await readFile(path.join(cwd, "pnpm-workspace.yaml"), "utf8").then((content) => assertPnpmWorkspace(parse$1(content))).catch((error) => {
894
- if (isNodeError(error) && error.code === "ENOENT") return void 0;
895
- throw error;
896
- });
897
- if (rootManifest?.name) add(new NpmPackage(cwd, rootManifest));
898
- const patterns = pnpmPatterns?.packages ?? rootManifest?.workspaces;
899
- if (!patterns || patterns.length === 0) return;
900
- const candidatePaths = await expandWorkspacePatterns(cwd, patterns);
901
- const manifests = await Promise.all(candidatePaths.map((path) => readManifest(path).then((manifest) => ({
902
- path,
903
- manifest
904
- })).catch(() => void 0)));
905
- for (const entry of manifests) {
906
- if (!entry) continue;
907
- add(new NpmPackage(entry.path, entry.manifest));
908
- }
909
- }
910
- async function expandWorkspacePatterns(cwd, patterns) {
911
- if (patterns.length === 0) return [];
912
- return (await glob(patterns, {
913
- absolute: true,
914
- cwd,
915
- ignore: ["**/node_modules/**", "**/dist/**"],
916
- onlyDirectories: true,
917
- onlyFiles: false
918
- })).map((item) => {
919
- return item.endsWith(path.sep) ? item.slice(0, -1) : item;
920
- });
921
- }
922
- async function readManifest(packagePath) {
923
- const content = await readFile(path.join(packagePath, "package.json"), "utf8");
924
- const parsed = JSON.parse(content);
925
- assertPackageManifest(parsed);
926
- return parsed;
927
- }
928
1251
  //#endregion
929
- export { runPreflights as a, publishPlanStatus as i, npm as n, runPublishPlan as o, initPublishPlan as r, NpmPackage as t };
1252
+ export { runPreflights as a, publishPlanStatus as i, NpmPackage as n, runPublishPlan as o, initPublishPlan as r, npm as t };