@vnejs/monorepo 0.2.3 → 0.2.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/monorepo",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Monorepo tooling for @vnejs",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -39,9 +39,10 @@ module.exports = async (bump, options = {}) => {
39
39
  }
40
40
 
41
41
  console.log(`Пакет ${pkgLabel} успешно опубликован с версией ${publishedVersion}`);
42
- } catch {
42
+ } catch (error) {
43
43
  if (bump && readVersion(pkgDir) !== oldVersion) writeVersion(pkgDir, oldVersion);
44
- console.error(`Не удалось опубликовать пакет${pkgLabel}. Версия не была изменена (${oldVersion}).`);
44
+ const detail = error?.message ? ` ${error.message}` : "";
45
+ console.error(`\n!!! Не удалось опубликовать пакет${pkgLabel} (было ${oldVersion}). Версия не изменена.${detail}\n`);
45
46
  process.exit(1);
46
47
  }
47
48
  };
@@ -39,7 +39,7 @@ const runAsync = (command, pkgDir) =>
39
39
  return;
40
40
  }
41
41
 
42
- reject(new Error(`${command} exited with ${code}`));
42
+ reject(new Error(`${command} in ${pkgDir} exited with ${code}`));
43
43
  });
44
44
  });
45
45
 
@@ -6,7 +6,7 @@ const { buildDependencyGraph, restrictGraph } = require("../workspace/build-grap
6
6
  const { topoSortLayers } = require("../workspace/topo-sort");
7
7
  const { runAsync } = require("../publish/utils");
8
8
  const confirm = require("../utils/confirm");
9
- const { formatPackageLine } = require("../utils/format-package");
9
+ const { formatPackageLine, formatPackageRef } = require("../utils/format-package");
10
10
  const schedulePackages = require("./schedule");
11
11
 
12
12
  const groupChangedByGraph = (root, changedPackages) => {
@@ -111,8 +111,15 @@ module.exports = async (options = {}) => {
111
111
  firstSerial,
112
112
  runFn: async (pkg, index) => {
113
113
  const pkgDir = path.join(root, pkg.dir);
114
- console.log(formatPackageLine(pkg, { leadingNewline: true, tag: `[${index + 1}/${packages.length}]` }));
115
- await runAsync(`npm run ${script}`, pkgDir);
114
+ const tag = `[${index + 1}/${packages.length}]`;
115
+ console.log(formatPackageLine(pkg, { leadingNewline: true, tag }));
116
+
117
+ try {
118
+ await runAsync(`npm run ${script}`, pkgDir);
119
+ } catch (error) {
120
+ const detail = error?.message ?? String(error);
121
+ throw new Error(`${tag} ${formatPackageRef(pkg)} (${pkg.dir}): ${detail}`, { cause: error });
122
+ }
116
123
  },
117
124
  });
118
125
  };
@@ -13,12 +13,14 @@ const rejectFailed = (results, log) => {
13
13
 
14
14
  if (!failed.length) return;
15
15
 
16
- for (const result of failed) {
16
+ const messages = failed.map((result) => {
17
17
  const reason = result.reason;
18
- log(reason?.stack ?? String(reason));
19
- }
18
+ const message = reason?.message ?? String(reason);
19
+ log(reason?.stack ?? message);
20
+ return message;
21
+ });
20
22
 
21
- throw new Error(`${failed.length} package script(s) failed.`);
23
+ throw new Error(`${failed.length} package script(s) failed.\n${messages.map((message) => `- ${message}`).join("\n")}`);
22
24
  };
23
25
 
24
26
  const schedulePackages = async ({ packages = [], layers, runFn, concurrency = 1, parallelMs, firstSerial = false, log = console.log }) => {
@@ -236,4 +236,20 @@ describe("schedulePackages", () => {
236
236
  await expect(done).rejects.toThrow("1 package script(s) failed.");
237
237
  expect(logs.some((message) => String(message).includes("a failed"))).toBe(true);
238
238
  });
239
+
240
+ it("lists each failed package message in the thrown error", async () => {
241
+ const { runFn, resolve, reject } = createTrackedRunner();
242
+ const done = schedulePackages({
243
+ packages: packages("a", "b"),
244
+ runFn,
245
+ concurrency: 2,
246
+ log: () => {},
247
+ });
248
+
249
+ await flush();
250
+ reject("a", new Error("[3/89] @vnejs/foo (plugins/foo): npm run publish:patch exited with 1"));
251
+ resolve("b");
252
+
253
+ await expect(done).rejects.toThrow(/1 package script\(s\) failed\.\n- \[3\/89\] @vnejs\/foo/);
254
+ });
239
255
  });