@git.zone/cli 8.6.0 → 8.7.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.
@@ -28,7 +28,10 @@ import {
28
28
  resolveGiteaAssetTransferLimits,
29
29
  resolveGitRemoteTimeoutSeconds,
30
30
  resolveNpmVerificationWindowMinutes,
31
+ resolveNpmMaxPublishBytes,
32
+ normalizeReleaseRegistryUrl,
31
33
  } from "../helpers.workflow.js";
34
+ import { resolvePackageFiles } from "../helpers.packagefiles.js";
32
35
  import { hasInstalledProjectTsdockerBinary } from "../helpers.tsdocker.js";
33
36
  import { TsdockerReleaseClient } from "../mod_release/helpers.tsdockerprotocol.js";
34
37
  import {
@@ -1221,10 +1224,60 @@ async function collectDoctorFindings(): Promise<IDoctorFinding[]> {
1221
1224
  validateCommitConfig(cliConfig.commit || {}, findings);
1222
1225
  await validateReleaseConfig(cliConfig.release, smartconfigData, findings);
1223
1226
  await validateAssetsConfig(cliConfig.assets, smartconfigData, findings);
1227
+ await validatePackageFilesConfig(cliConfig, findings);
1224
1228
 
1225
1229
  return findings;
1226
1230
  }
1227
1231
 
1232
+ /** `packageFiles` must resolve, and package.json must carry what it generates. */
1233
+ async function validatePackageFilesConfig(
1234
+ cliConfig: Record<string, any>,
1235
+ findings: IDoctorFinding[],
1236
+ ): Promise<void> {
1237
+ if (cliConfig.packageFiles === undefined) {
1238
+ findings.push({
1239
+ level: "ok",
1240
+ message: "Package files use every default set",
1241
+ });
1242
+ return;
1243
+ }
1244
+ let packageJson: Record<string, any>;
1245
+ try {
1246
+ packageJson = await readPackageJson();
1247
+ } catch (error) {
1248
+ findings.push({
1249
+ level: "error",
1250
+ message: "package.json is not valid JSON",
1251
+ fix: error instanceof Error ? error.message : String(error),
1252
+ });
1253
+ return;
1254
+ }
1255
+ let files: string[];
1256
+ try {
1257
+ files = resolvePackageFiles({
1258
+ packageFiles: cliConfig.packageFiles,
1259
+ assets: isPlainObject(cliConfig.assets) ? cliConfig.assets : undefined,
1260
+ manifest: packageJson,
1261
+ });
1262
+ } catch (error) {
1263
+ findings.push({
1264
+ level: "error",
1265
+ message: error instanceof Error ? error.message : String(error),
1266
+ fix: "Correct @git.zone/cli.packageFiles as the readme's Package contents section describes.",
1267
+ });
1268
+ return;
1269
+ }
1270
+ findings.push(
1271
+ JSON.stringify(packageJson.files) === JSON.stringify(files)
1272
+ ? { level: "ok", message: "package.json files matches packageFiles" }
1273
+ : {
1274
+ level: "warn",
1275
+ message: "package.json files differs from what packageFiles generates",
1276
+ fix: "Run `gitzone format`; a release refuses the difference.",
1277
+ },
1278
+ );
1279
+ }
1280
+
1228
1281
  /**
1229
1282
  * Where each key gitzone once read from `@ship.zone/szci` lives now.
1230
1283
  */
@@ -2304,6 +2357,31 @@ async function validateNpmTarget(
2304
2357
  });
2305
2358
  }
2306
2359
 
2360
+ try {
2361
+ const limits = resolveNpmMaxPublishBytes(
2362
+ npmTarget.maxPublishBytes,
2363
+ registries
2364
+ .filter((registryArg): registryArg is string => typeof registryArg === "string")
2365
+ .map(normalizeReleaseRegistryUrl),
2366
+ );
2367
+ findings.push({
2368
+ level: "ok",
2369
+ message:
2370
+ Object.keys(limits).length > 0
2371
+ ? `npm publish body limits: ${Object.entries(limits)
2372
+ .map(([registry, limit]) => `${registry} ${limit} bytes`)
2373
+ .join(", ")}`
2374
+ : "npm publish body limits: none configured",
2375
+ });
2376
+ } catch (error) {
2377
+ findings.push({
2378
+ level: "error",
2379
+ message:
2380
+ error instanceof Error ? error.message : "Invalid npm publish body limits",
2381
+ fix: "Set release.targets.npm.maxPublishBytes to an object of configured registry URLs and whole byte limits, or remove it.",
2382
+ });
2383
+ }
2384
+
2307
2385
  const smartNetwork = new plugins.smartnetwork.SmartNetwork();
2308
2386
  await Promise.all(
2309
2387
  registries.map(async (registry) => {
@@ -3,6 +3,7 @@ import type { IPlannedChange } from '../interfaces.format.js';
3
3
  import * as plugins from '../mod.plugins.js';
4
4
  import * as paths from '../../paths.js';
5
5
  import { logger, logVerbose } from '../../gitzone.logging.js';
6
+ import { resolvePackageFiles } from '../../helpers.packagefiles.js';
6
7
 
7
8
  export class PackageJsonFormatter extends BaseFormatter {
8
9
  get name(): string {
@@ -103,33 +104,12 @@ export class PackageJsonFormatter extends BaseFormatter {
103
104
  }
104
105
  }
105
106
 
106
- // Set files array
107
- const sourceFolders = ['ts', 'ts_web'];
108
- const files = [
109
- ...sourceFolders.map((folderArg) => `${folderArg}/**/*`),
110
- 'dist/**/*',
111
- 'dist_*/**/*',
112
- 'dist_ts/**/*',
113
- 'dist_ts_web/**/*',
114
- 'assets/**/*',
115
- 'cli.js',
116
- '.smartconfig.json',
117
- 'readme.md',
118
- ];
119
-
120
- if (assetsConfig?.kind === 'denoBinaryCli' && assetsConfig.installer?.enabled !== false) {
121
- files.push(assetsConfig.installer?.file || 'install.sh');
122
- }
123
- if (assetsConfig?.kind === 'denoBinaryCli' && assetsConfig.npmWrapper?.enabled) {
124
- files.push('bin/');
125
- files.push(assetsConfig.npmWrapper.postinstallFile || 'scripts/install-binary.js');
126
- }
127
- // @git.zone/tsbuild reads a folder's compiler options from <folder>/tsconfig.json,
128
- // which extends the root tsconfig.json. The package does not ship the root file,
129
- // so a shipped folder file would extend a file that is not there. pnpm 10 and 12
130
- // apply an exclusion only after the entries that include the file, so it comes last.
131
- files.push(...sourceFolders.map((folderArg) => `!${folderArg}/tsconfig.json`));
132
- packageJson.files = [...new Set(files)];
107
+ // gitzone format is the one writer of `files`; see helpers.packagefiles.ts.
108
+ packageJson.files = resolvePackageFiles({
109
+ packageFiles: gitzoneData.packageFiles,
110
+ assets: rawAssetsConfig,
111
+ manifest: packageJson,
112
+ });
133
113
 
134
114
  // Set pnpm overrides from assets
135
115
  try {
@@ -0,0 +1,397 @@
1
+ import * as plugins from "./mod.plugins.js";
2
+ import type {
3
+ IReleaseArtifact,
4
+ TReleaseNpmAccess,
5
+ } from "./classes.releasejournal.js";
6
+ import { normalizeNpmRegistryUrl } from "./helpers.npmartifact.js";
7
+ import type { IResolvedReleaseWorkflow } from "../helpers.workflow.js";
8
+ import { isPlainObject } from "../helpers.objects.js";
9
+
10
+ /** The packed-artifact check that refused a release. */
11
+ export type TNpmArtifactCheck = "contents" | "entryPoints" | "publishSize";
12
+
13
+ /**
14
+ * A packed tarball failed `core.packNpmArtifact.entryPoints` or
15
+ * `core.packNpmArtifact.publishSize`. The release commit itself causes the
16
+ * failure, so preparing the same commit again fails the same way.
17
+ */
18
+ export class NpmArtifactCheckError extends Error {
19
+ public readonly check: TNpmArtifactCheck;
20
+
21
+ constructor(checkArg: TNpmArtifactCheck, messageArg: string) {
22
+ super(messageArg);
23
+ this.name = "NpmArtifactCheckError";
24
+ this.check = checkArg;
25
+ }
26
+ }
27
+
28
+ /** The artifact check error in an error's cause chain, if there is one. */
29
+ export const findNpmArtifactCheckError = (
30
+ errorArg: unknown,
31
+ ): NpmArtifactCheckError | undefined => {
32
+ let current: unknown = errorArg;
33
+ for (let depth = 0; depth < 16 && current instanceof Error; depth++) {
34
+ if (current instanceof NpmArtifactCheckError) return current;
35
+ current = current.cause;
36
+ }
37
+ return undefined;
38
+ };
39
+
40
+ /** What a packed npm tarball holds, read from the tarball itself. */
41
+ export interface INpmArtifactContents {
42
+ /** Every regular file, relative to the package root. */
43
+ files: string[];
44
+ /** The packed package.json, as pnpm wrote it into the tarball. */
45
+ manifest: Record<string, unknown>;
46
+ /** The root readme.md the publish document carries, when there is one. */
47
+ readme?: string;
48
+ }
49
+
50
+ const packagePrefix = "package/";
51
+
52
+ /** How much of a packed tarball the checks read before they refuse it. */
53
+ export interface INpmArtifactReadLimits {
54
+ maxUncompressedArchiveBytes: number;
55
+ maxEntries: number;
56
+ /** For the selected package.json and readme, each. */
57
+ maxUncompressedEntryBytes: number;
58
+ }
59
+
60
+ export const defaultNpmArtifactReadLimits: INpmArtifactReadLimits = {
61
+ maxUncompressedArchiveBytes: 2 * 1024 ** 3,
62
+ maxEntries: 1_000_000,
63
+ maxUncompressedEntryBytes: 64 * 1024 ** 2,
64
+ };
65
+
66
+ /** The limits a tarball itself can exceed; they refuse it like a failed check. */
67
+ const artifactLimitCodes = new Set<string>([
68
+ plugins.smartarchive.GZIP_ERROR_CODES.UNCOMPRESSED_SIZE_LIMIT,
69
+ plugins.smartarchive.TAR_ERROR_CODES.ENTRY_COUNT_LIMIT,
70
+ plugins.smartarchive.TAR_ERROR_CODES.UNCOMPRESSED_SIZE_LIMIT,
71
+ plugins.smartarchive.TAR_ERROR_CODES.TOTAL_UNCOMPRESSED_SIZE_LIMIT,
72
+ ]);
73
+
74
+ /**
75
+ * Reads the packed file list, manifest and readme from the tarball. pnpm 12
76
+ * puts a root `readme.md` (any case) into the publish document and prefers
77
+ * `README.md` when there are several. A tarball beyond the read limits comes
78
+ * from the release commit, so it fails as an `NpmArtifactCheckError`.
79
+ */
80
+ export const readNpmArtifactContents = async (
81
+ artifactPathArg: string,
82
+ limitsArg: INpmArtifactReadLimits = defaultNpmArtifactReadLimits,
83
+ ): Promise<INpmArtifactContents> => {
84
+ const bytes = await plugins.fs.readFile(artifactPathArg);
85
+ const files: string[] = [];
86
+ let entries: Awaited<
87
+ ReturnType<plugins.smartarchive.TarTools["extractSelectedTarGzEntries"]>
88
+ >;
89
+ try {
90
+ entries = await new plugins.smartarchive.TarTools().extractSelectedTarGzEntries(
91
+ bytes,
92
+ {
93
+ filter: (entryArg) => {
94
+ if (entryArg.entryType !== "file" || !entryArg.path.startsWith(packagePrefix))
95
+ return false;
96
+ const path = entryArg.path.slice(packagePrefix.length);
97
+ files.push(path);
98
+ return path === "package.json" || path.toLowerCase() === "readme.md";
99
+ },
100
+ maxArchiveBytes: bytes.byteLength,
101
+ maxUncompressedArchiveBytes: limitsArg.maxUncompressedArchiveBytes,
102
+ maxEntries: limitsArg.maxEntries,
103
+ maxSelectedEntries: 64,
104
+ maxUncompressedEntryBytes: limitsArg.maxUncompressedEntryBytes,
105
+ maxTotalUncompressedBytes: 4 * limitsArg.maxUncompressedEntryBytes,
106
+ },
107
+ );
108
+ } catch (error) {
109
+ if (
110
+ error instanceof plugins.smartarchive.SmartArchiveError &&
111
+ artifactLimitCodes.has(error.code)
112
+ ) {
113
+ throw new NpmArtifactCheckError(
114
+ "contents",
115
+ `The packed tarball ${plugins.path.basename(artifactPathArg)} exceeds what the release reads to check it (${error.code}: ${error.message}; at most ${limitsArg.maxUncompressedArchiveBytes} bytes unpacked, ${limitsArg.maxEntries} entries). Leave files out through @git.zone/cli.packageFiles, then \`gitzone format\`.`,
116
+ );
117
+ }
118
+ throw error;
119
+ }
120
+ const decoder = new TextDecoder();
121
+ const manifestEntry = entries.find(
122
+ (entryArg) => entryArg.path === `${packagePrefix}package.json`,
123
+ );
124
+ if (!manifestEntry)
125
+ throw new Error("The packed npm artifact carries no package/package.json.");
126
+ const manifest: unknown = JSON.parse(decoder.decode(manifestEntry.content));
127
+ if (!isPlainObject(manifest))
128
+ throw new Error("The packed package.json is not a JSON object.");
129
+ const readmes = entries.filter(
130
+ (entryArg) => entryArg.path !== `${packagePrefix}package.json`,
131
+ );
132
+ const readme =
133
+ readmes.find((entryArg) => entryArg.path === `${packagePrefix}README.md`) ??
134
+ readmes[0];
135
+ return {
136
+ files,
137
+ manifest,
138
+ ...(readme ? { readme: decoder.decode(readme.content) } : {}),
139
+ };
140
+ };
141
+
142
+ const normalizeTarget = (targetArg: string): string =>
143
+ targetArg.replace(/^(\.\/)+/, "");
144
+
145
+ /** Node's resolution of a `main` without its extension or as a folder. */
146
+ const mainCandidates = (mainArg: string): string[] => {
147
+ const main = normalizeTarget(mainArg).replace(/\/+$/, "");
148
+ return [
149
+ main,
150
+ `${main}.js`,
151
+ `${main}.json`,
152
+ `${main}.node`,
153
+ `${main}/index.js`,
154
+ `${main}/index.json`,
155
+ `${main}/index.node`,
156
+ ];
157
+ };
158
+
159
+ interface IEntryPoint {
160
+ /** Where the manifest names it, e.g. `exports["./x"].import`. */
161
+ field: string;
162
+ target: string;
163
+ }
164
+
165
+ const collectExportTargets = (
166
+ valueArg: unknown,
167
+ fieldArg: string,
168
+ targetsArg: IEntryPoint[],
169
+ ): void => {
170
+ if (typeof valueArg === "string") {
171
+ targetsArg.push({ field: fieldArg, target: valueArg });
172
+ } else if (Array.isArray(valueArg)) {
173
+ valueArg.forEach((itemArg, indexArg) =>
174
+ collectExportTargets(itemArg, `${fieldArg}[${indexArg}]`, targetsArg),
175
+ );
176
+ } else if (isPlainObject(valueArg)) {
177
+ for (const [keyArg, itemArg] of Object.entries(valueArg))
178
+ collectExportTargets(itemArg, `${fieldArg}[${JSON.stringify(keyArg)}]`, targetsArg);
179
+ }
180
+ };
181
+
182
+ const escapeRegExp = (valueArg: string): string =>
183
+ valueArg.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
184
+
185
+ /**
186
+ * Every `main`, `module`, `types`/`typings`, `bin` and `exports` target the
187
+ * packed manifest names, with the reason each missing one is missing. An
188
+ * `exports` target with `*` must match at least one packed file, and a
189
+ * folder target (trailing `/`) must contain one.
190
+ */
191
+ export const findMissingNpmEntryPoints = (
192
+ contentsArg: Pick<INpmArtifactContents, "files" | "manifest">,
193
+ ): string[] => {
194
+ const files = new Set(contentsArg.files);
195
+ const manifest = contentsArg.manifest;
196
+ const missing: string[] = [];
197
+ if (typeof manifest.main === "string") {
198
+ if (!mainCandidates(manifest.main).some((candidateArg) => files.has(candidateArg)))
199
+ missing.push(`main -> ${manifest.main}`);
200
+ }
201
+ const plain: IEntryPoint[] = [];
202
+ for (const field of ["module", "types", "typings"] as const) {
203
+ const value = manifest[field];
204
+ if (typeof value === "string") plain.push({ field, target: value });
205
+ }
206
+ if (typeof manifest.bin === "string") {
207
+ plain.push({ field: "bin", target: manifest.bin });
208
+ } else if (isPlainObject(manifest.bin)) {
209
+ for (const [name, target] of Object.entries(manifest.bin))
210
+ if (typeof target === "string")
211
+ plain.push({ field: `bin[${JSON.stringify(name)}]`, target });
212
+ }
213
+ for (const entry of plain)
214
+ if (!files.has(normalizeTarget(entry.target)))
215
+ missing.push(`${entry.field} -> ${entry.target}`);
216
+ const exportTargets: IEntryPoint[] = [];
217
+ collectExportTargets(manifest.exports, "exports", exportTargets);
218
+ for (const entry of exportTargets) {
219
+ // Only package-relative targets name files; anything else is not ours to check.
220
+ if (!entry.target.startsWith("./")) continue;
221
+ const target = normalizeTarget(entry.target);
222
+ let present: boolean;
223
+ if (target.includes("*")) {
224
+ const pattern = new RegExp(
225
+ `^${target.split("*").map(escapeRegExp).join(".+")}$`,
226
+ );
227
+ present = contentsArg.files.some((fileArg) => pattern.test(fileArg));
228
+ } else if (target.endsWith("/")) {
229
+ present = contentsArg.files.some((fileArg) => fileArg.startsWith(target));
230
+ } else {
231
+ present = files.has(target);
232
+ }
233
+ if (!present) missing.push(`${entry.field} -> ${entry.target}`);
234
+ }
235
+ return missing;
236
+ };
237
+
238
+ export const assertNpmEntryPointsPacked = (
239
+ contentsArg: Pick<INpmArtifactContents, "files" | "manifest">,
240
+ packageNameArg: string,
241
+ ): void => {
242
+ const missing = findMissingNpmEntryPoints(contentsArg);
243
+ if (missing.length === 0) return;
244
+ throw new NpmArtifactCheckError(
245
+ "entryPoints",
246
+ `The packed ${packageNameArg} tarball lacks entry points its package.json names: ${missing.join("; ")}. ` +
247
+ "Ship them through package.json files (@git.zone/cli.packageFiles, then `gitzone format`) or fix the build.",
248
+ );
249
+ };
250
+
251
+ export interface INpmPublishBodyOptions {
252
+ contents: Pick<INpmArtifactContents, "manifest" | "readme">;
253
+ artifact: Pick<IReleaseArtifact, "packageName" | "version" | "size" | "sha1" | "integrity">;
254
+ registry: string;
255
+ distTag: string;
256
+ access: TReleaseNpmAccess;
257
+ }
258
+
259
+ /**
260
+ * The byte length of the document `pnpm publish <tarball>` PUTs to a
261
+ * registry: the packed manifest with its readme and `dist` record, the
262
+ * dist-tag, the access level, and the tarball as base64. Measured against
263
+ * pnpm 12's actual upload; it is an estimate for other publishers.
264
+ */
265
+ export const estimateNpmPublishBodyBytes = (
266
+ optionsArg: INpmPublishBodyOptions,
267
+ ): number => {
268
+ const { artifact, contents } = optionsArg;
269
+ const name = artifact.packageName;
270
+ const registry = normalizeNpmRegistryUrl(optionsArg.registry);
271
+ const description = contents.manifest.description;
272
+ const placeholder = "\u0000";
273
+ const document = {
274
+ _id: name,
275
+ name,
276
+ ...(description !== undefined ? { description } : {}),
277
+ "dist-tags": { [optionsArg.distTag]: artifact.version },
278
+ versions: {
279
+ [artifact.version]: {
280
+ ...contents.manifest,
281
+ ...(contents.readme !== undefined ? { readme: contents.readme } : {}),
282
+ _id: `${name}@${artifact.version}`,
283
+ dist: {
284
+ integrity: artifact.integrity,
285
+ shasum: artifact.sha1,
286
+ tarball: `${registry}/${name}/-/${name}-${artifact.version}.tgz`,
287
+ },
288
+ },
289
+ },
290
+ access: optionsArg.access === "private" ? "restricted" : "public",
291
+ _attachments: {
292
+ [`${name}-${artifact.version}.tgz`]: {
293
+ content_type: "application/octet-stream",
294
+ data: placeholder,
295
+ length: artifact.size,
296
+ },
297
+ },
298
+ };
299
+ const metadataBytes =
300
+ Buffer.byteLength(JSON.stringify(document), "utf8") -
301
+ Buffer.byteLength(JSON.stringify(placeholder), "utf8") +
302
+ 2;
303
+ return metadataBytes + 4 * Math.ceil(artifact.size / 3);
304
+ };
305
+
306
+ const formatBytes = (bytesArg: number): string =>
307
+ `${bytesArg.toLocaleString("en-US")} bytes (${(bytesArg / 1024 ** 2).toFixed(1)} MiB)`;
308
+
309
+ export interface INpmPublishSizeCheck {
310
+ registry: string;
311
+ bodyBytes: number;
312
+ limit?: number;
313
+ }
314
+
315
+ /**
316
+ * The packed size and the estimated publish body per registry, checked
317
+ * against the registry's configured `maxPublishBytes`. Prints both and fails
318
+ * when a body exceeds its registry's limit. Without limits it only reports.
319
+ */
320
+ export const assertNpmPublishSize = (optionsArg: {
321
+ contents: Pick<INpmArtifactContents, "manifest" | "readme">;
322
+ artifact: Pick<IReleaseArtifact, "packageName" | "version" | "size" | "sha1" | "integrity">;
323
+ registries: string[];
324
+ distTag: string;
325
+ access: TReleaseNpmAccess;
326
+ maxPublishBytes: Record<string, number>;
327
+ log?: (lineArg: string) => void;
328
+ }): INpmPublishSizeCheck[] => {
329
+ const log = optionsArg.log ?? ((lineArg: string) => console.log(lineArg));
330
+ log(`${optionsArg.artifact.packageName}: packed ${formatBytes(optionsArg.artifact.size)}`);
331
+ // Registries and limit keys are both in the resolved release form.
332
+ const checks = optionsArg.registries.map((registry) => {
333
+ const limit = optionsArg.maxPublishBytes[registry];
334
+ return {
335
+ registry,
336
+ bodyBytes: estimateNpmPublishBodyBytes({
337
+ contents: optionsArg.contents,
338
+ artifact: optionsArg.artifact,
339
+ registry,
340
+ distTag: optionsArg.distTag,
341
+ access: optionsArg.access,
342
+ }),
343
+ ...(limit !== undefined ? { limit } : {}),
344
+ };
345
+ });
346
+ for (const check of checks)
347
+ log(
348
+ ` publish body to ${check.registry}: ${formatBytes(check.bodyBytes)}${check.limit !== undefined ? `, limit ${formatBytes(check.limit)}` : ", no limit configured"}`,
349
+ );
350
+ const exceeded = checks.filter(
351
+ (checkArg) => checkArg.limit !== undefined && checkArg.bodyBytes > checkArg.limit,
352
+ );
353
+ if (exceeded.length > 0)
354
+ throw new NpmArtifactCheckError(
355
+ "publishSize",
356
+ `The ${optionsArg.artifact.packageName} publish body exceeds release.targets.npm.maxPublishBytes: ${exceeded
357
+ .map((checkArg) => `${checkArg.registry} ${checkArg.bodyBytes} > ${checkArg.limit} bytes`)
358
+ .join("; ")}. Leave large files out through @git.zone/cli.packageFiles, then \`gitzone format\`.`,
359
+ );
360
+ return checks;
361
+ };
362
+
363
+ /**
364
+ * The checks between packing and the journal: every packed tarball must
365
+ * carry its entry points (`core.packNpmArtifact.entryPoints`), and its
366
+ * publish body must fit every registry limit (`core.packNpmArtifact.publishSize`).
367
+ * The size of each tarball and body is printed either way. A failure here
368
+ * leaves the release where a failed pack leaves it.
369
+ */
370
+ export const verifyPackedNpmArtifacts = async (optionsArg: {
371
+ workflow: Pick<
372
+ IResolvedReleaseWorkflow,
373
+ "npmRegistries" | "npmDistTag" | "npmAccessLevel" | "npmMaxPublishBytes"
374
+ >;
375
+ artifactDirectory: string;
376
+ artifacts: IReleaseArtifact[];
377
+ log?: (lineArg: string) => void;
378
+ }): Promise<void> => {
379
+ const packed: Array<{ artifact: IReleaseArtifact; contents: INpmArtifactContents }> = [];
380
+ for (const artifact of optionsArg.artifacts) {
381
+ const contents = await readNpmArtifactContents(
382
+ plugins.path.join(optionsArg.artifactDirectory, artifact.file),
383
+ );
384
+ assertNpmEntryPointsPacked(contents, artifact.packageName);
385
+ packed.push({ artifact, contents });
386
+ }
387
+ for (const { artifact, contents } of packed)
388
+ assertNpmPublishSize({
389
+ contents,
390
+ artifact,
391
+ registries: optionsArg.workflow.npmRegistries,
392
+ distTag: optionsArg.workflow.npmDistTag,
393
+ access: optionsArg.workflow.npmAccessLevel,
394
+ maxPublishBytes: optionsArg.workflow.npmMaxPublishBytes,
395
+ ...(optionsArg.log ? { log: optionsArg.log } : {}),
396
+ });
397
+ };