@riebeckite/test 0.0.21 → 0.0.22

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.
package/dist/e2e/index.js CHANGED
@@ -317,8 +317,42 @@ function createLogger(label = "e2e") {
317
317
  // e2e/pack.ts
318
318
  import fs3 from "node:fs";
319
319
  import path4 from "node:path";
320
+ function packageLevels(repoRoot, packages) {
321
+ const byName = new Map(packages.map((pkg) => [pkg.name, pkg]));
322
+ const dependencies = /* @__PURE__ */ new Map();
323
+ for (const pkg of packages) {
324
+ const manifest = JSON.parse(
325
+ fs3.readFileSync(
326
+ path4.join(repoRoot, pkg.directory, "package.json"),
327
+ "utf8"
328
+ )
329
+ );
330
+ dependencies.set(
331
+ pkg.name,
332
+ Object.keys(manifest.dependencies ?? {}).filter(
333
+ (name) => byName.has(name)
334
+ )
335
+ );
336
+ }
337
+ const remaining = new Set(byName.keys());
338
+ const levels = [];
339
+ while (remaining.size > 0) {
340
+ const level = packages.filter(
341
+ (pkg) => remaining.has(pkg.name) && (dependencies.get(pkg.name) ?? []).every(
342
+ (dependency) => !remaining.has(dependency)
343
+ )
344
+ );
345
+ if (level.length === 0) {
346
+ throw new Error("Workspace package dependency cycle");
347
+ }
348
+ levels.push(level);
349
+ for (const pkg of level) remaining.delete(pkg.name);
350
+ }
351
+ return levels;
352
+ }
320
353
  async function packPackages(tarballDir, options) {
321
354
  const { repoRoot, packages, logger, concurrency = 4 } = options;
355
+ const levels = packageLevels(repoRoot, packages);
322
356
  logger.step(
323
357
  `packing ${packages.length} packages with pnpm pack (concurrency ${concurrency})`
324
358
  );
@@ -344,28 +378,30 @@ async function packPackages(tarballDir, options) {
344
378
  console.log(` packed ${pkg.name} -> ${path4.basename(tarball)}`);
345
379
  return { pkg, version: manifest.version, tarball };
346
380
  };
347
- const results = new Array(packages.length);
348
- let nextIndex = 0;
349
- const worker = async () => {
350
- while (nextIndex < packages.length) {
351
- const index = nextIndex;
352
- nextIndex += 1;
353
- const pkg = packages[index];
354
- if (pkg === void 0) continue;
355
- results[index] = await packOne(pkg);
356
- }
357
- };
358
- const batch = await Promise.allSettled(
359
- Array.from(
360
- { length: Math.min(concurrency, packages.length) },
361
- () => worker()
362
- )
363
- );
364
- const failure = batch.find(
365
- (result) => result.status === "rejected"
366
- );
367
- if (failure) {
368
- throw failure.reason;
381
+ const results = [];
382
+ for (const level of levels) {
383
+ const levelResults = new Array(level.length);
384
+ let nextIndex = 0;
385
+ const worker = async () => {
386
+ while (nextIndex < level.length) {
387
+ const index = nextIndex;
388
+ nextIndex += 1;
389
+ const pkg = level[index];
390
+ if (pkg === void 0) continue;
391
+ levelResults[index] = await packOne(pkg);
392
+ }
393
+ };
394
+ const batch = await Promise.allSettled(
395
+ Array.from(
396
+ { length: Math.min(concurrency, level.length) },
397
+ () => worker()
398
+ )
399
+ );
400
+ const failure = batch.find(
401
+ (result) => result.status === "rejected"
402
+ );
403
+ if (failure) throw failure.reason;
404
+ results.push(...levelResults);
369
405
  }
370
406
  const packed = /* @__PURE__ */ new Map();
371
407
  for (const result of results) {
@@ -22,9 +22,4 @@ export interface PackPackagesOptions {
22
22
  concurrency?: number;
23
23
  logger: Logger;
24
24
  }
25
- /**
26
- * Pack every package with `pnpm pack` into `tarballDir`, using a
27
- * limited-concurrency pool. Returns a map from package name to its tarball and
28
- * version. The first failure rejects the returned promise.
29
- */
30
25
  export declare function packPackages(tarballDir: string, options: PackPackagesOptions): Promise<PackedPackages>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riebeckite/test",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",