tegami 1.1.0 → 1.1.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,35 +1,202 @@
1
1
  import { c as somePromise, i as isNodeError, n as execFailure, r as handlePluginError, s as joinPath } from "./error-BhMYq9iW.js";
2
+ import { t as _accessExpressionAsString } from "./_accessExpressionAsString-QhbUZzwv.js";
3
+ import { n as _validateReport, t as _createStandardSchema } from "./_createStandardSchema-BGQyz-uA.js";
4
+ import { t as _assertGuard } from "./_assertGuard-BBn2NbSz.js";
2
5
  import { n as WorkspacePackage } from "./graph-BmXTJZxx.js";
3
- import { a as parseChangelogFile, i as parsePublishLock, r as packageStoreSchema, t as changelogStoreSchema } from "./draft-BLbt4bSG.js";
6
+ import { a as parseChangelogFile, i as parsePublishLock, n as validateChangelogStore, r as validatePackageStore } from "./draft-DsxZOCOb.js";
4
7
  import fs, { readFile, writeFile } from "node:fs/promises";
5
8
  import path, { join } from "node:path";
6
9
  import { x } from "tinyexec";
7
10
  import * as semver$1 from "semver";
8
- import z from "zod";
9
- import { load } from "js-yaml";
11
+ import { parse as parse$1 } from "yaml";
10
12
  import { glob } from "tinyglobby";
11
13
  import { detect } from "package-manager-detector";
12
14
  import { tmpdir } from "node:os";
13
15
  import { intro, note, outro } from "@clack/prompts";
14
16
  //#region src/providers/npm/schema.ts
15
- const stringRecordSchema = z.record(z.string(), z.string());
16
- const pnpmWorkspaceSchema = z.looseObject({ packages: z.array(z.string()).optional() });
17
- const packageManifestSchema = z.looseObject({
18
- name: z.string(),
19
- version: z.string().optional(),
20
- private: z.boolean().optional(),
21
- publishConfig: z.looseObject({
22
- access: z.enum(["public", "restricted"]).optional(),
23
- registry: z.string().optional(),
24
- tag: z.string().optional()
25
- }).optional(),
26
- scripts: z.record(z.string(), z.string()).optional(),
27
- workspaces: z.array(z.string()).optional(),
28
- dependencies: stringRecordSchema.optional(),
29
- devDependencies: stringRecordSchema.optional(),
30
- peerDependencies: stringRecordSchema.optional(),
31
- optionalDependencies: stringRecordSchema.optional()
32
- });
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
+ })();
33
200
  //#endregion
34
201
  //#region src/plans/publish.ts
35
202
  async function initPublishPlan(context, options) {
@@ -43,15 +210,17 @@ async function initPublishPlan(context, options) {
43
210
  const packages = /* @__PURE__ */ new Map();
44
211
  const changelogs = /* @__PURE__ */ new Map();
45
212
  while (data = lock.read("core:changelogs")) {
46
- const entry = changelogStoreSchema.safeParse(data).data;
47
- if (!entry) continue;
213
+ const validated = validateChangelogStore(data);
214
+ if (!validated.success) continue;
215
+ const entry = validated.data;
48
216
  const parsed = parseChangelogFile(entry.filename, entry.content);
49
217
  if (!parsed) continue;
50
218
  changelogs.set(parsed.id, parsed);
51
219
  }
52
220
  while (data = lock.read("core:packages")) {
53
- const parsed = packageStoreSchema.safeParse(data).data;
54
- if (!parsed) continue;
221
+ const validated = validatePackageStore(data);
222
+ if (!validated.success) continue;
223
+ const parsed = validated.data;
55
224
  if (!context.graph.get(parsed.id)) continue;
56
225
  const pkgChangelogs = [];
57
226
  for (const id of parsed.changelogIds ?? []) {
@@ -378,11 +547,88 @@ function formatDependencySpec(spec) {
378
547
  if (spec.protocol === "npm") return `npm:${spec.alias}@${spec.range}`;
379
548
  return spec.range;
380
549
  }
381
- const packageLockSchema = z.object({
382
- id: z.string(),
383
- distTag: z.string().optional()
384
- });
385
- const markLatestLockSchema = z.object({ id: z.string() });
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
+ };
591
+ });
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) => {
604
+ if (false === __is(input)) {
605
+ errors = [];
606
+ _report = _validateReport(errors);
607
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
608
+ path: _path + "",
609
+ expected: "NpmMarkLatestLock",
610
+ value: input
611
+ })) && _vo0(input, _path + "", true) || _report(true, {
612
+ path: _path + "",
613
+ expected: "NpmMarkLatestLock",
614
+ value: input
615
+ }))(input, "$input", true);
616
+ const success = 0 === errors.length;
617
+ return success ? {
618
+ success,
619
+ data: input
620
+ } : {
621
+ success,
622
+ errors,
623
+ data: input
624
+ };
625
+ }
626
+ return {
627
+ success: true,
628
+ data: input
629
+ };
630
+ });
631
+ })();
386
632
  function npm({ client: defaultClient, onBreakPeerDep = "set", updateLockFile = true, trustedPublish, bumpDep: getBumpDepType = ({ kind }) => {
387
633
  switch (kind) {
388
634
  case "dependencies":
@@ -432,15 +678,17 @@ function npm({ client: defaultClient, onBreakPeerDep = "set", updateLockFile = t
432
678
  initPublishPlan({ lock, plan }) {
433
679
  let data;
434
680
  while (data = lock.read("npm:packages")) {
435
- const parsed = packageLockSchema.safeParse(data).data;
436
- if (!parsed) continue;
681
+ const validated = validateNpmPackageLock(data);
682
+ if (!validated.success) continue;
683
+ const parsed = validated.data;
437
684
  const packagePlan = plan.packages.get(parsed.id);
438
685
  if (!packagePlan) continue;
439
686
  packagePlan.npm = { distTag: parsed.distTag };
440
687
  }
441
688
  while (data = lock.read("npm:mark-latest")) {
442
- const parsed = markLatestLockSchema.safeParse(data).data;
443
- if (!parsed) continue;
689
+ const validated = validateNpmMarkLatestLock(data);
690
+ if (!validated.success) continue;
691
+ const parsed = validated.data;
444
692
  const packagePlan = plan.packages.get(parsed.id);
445
693
  if (!packagePlan) continue;
446
694
  packagePlan.npm ??= {};
@@ -642,7 +890,7 @@ async function isPackagePublished(name, version, registry) {
642
890
  }
643
891
  async function discoverNpmPackages(cwd, add) {
644
892
  const rootManifest = await readManifest(cwd).catch(() => void 0);
645
- const pnpmPatterns = await readFile(path.join(cwd, "pnpm-workspace.yaml"), "utf8").then((content) => pnpmWorkspaceSchema.parse(load(content) ?? {})).catch((error) => {
893
+ const pnpmPatterns = await readFile(path.join(cwd, "pnpm-workspace.yaml"), "utf8").then((content) => assertPnpmWorkspace(parse$1(content))).catch((error) => {
646
894
  if (isNodeError(error) && error.code === "ENOENT") return void 0;
647
895
  throw error;
648
896
  });
@@ -674,7 +922,7 @@ async function expandWorkspacePatterns(cwd, patterns) {
674
922
  async function readManifest(packagePath) {
675
923
  const content = await readFile(path.join(packagePath, "package.json"), "utf8");
676
924
  const parsed = JSON.parse(content);
677
- packageManifestSchema.parse(parsed);
925
+ assertPackageManifest(parsed);
678
926
  return parsed;
679
927
  }
680
928
  //#endregion
@@ -1,2 +1,2 @@
1
- import { C as CargoPackage, S as CargoGraph, T as cargo, w as CargoPluginOptions } from "../types-BoQR7Hlg.js";
1
+ import { C as CargoPackage, S as CargoGraph, T as cargo, w as CargoPluginOptions } from "../types-VvvN6oyT.js";
2
2
  export { CargoGraph, CargoPackage, CargoPluginOptions, cargo };