turbo 2.10.3-canary.7 → 2.10.3

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.
Files changed (2) hide show
  1. package/bin/turbo +68 -2
  2. package/package.json +7 -7
package/bin/turbo CHANGED
@@ -37,6 +37,39 @@ function hasPackage(sourceObject, packageName) {
37
37
  return !!sourceObject[packageName] || !!sourceObject[`node_modules/${packageName}`];
38
38
  }
39
39
 
40
+ // When invoked through a package manager's scripts (or npx/pnpm dlx/etc.),
41
+ // the package manager identifies itself in npm_config_user_agent,
42
+ // e.g. "pnpm/9.1.0 npm/? node/v20.11.0 darwin arm64".
43
+ function detectPackageManager() {
44
+ const userAgent = process.env.npm_config_user_agent;
45
+ if (!userAgent) {
46
+ return null;
47
+ }
48
+
49
+ const match = userAgent.match(/^(\S+)\/(\d+)/);
50
+ if (!match) {
51
+ return null;
52
+ }
53
+
54
+ return { name: match[1], majorVersion: Number(match[2]) };
55
+ }
56
+
57
+ function repairInstructions(packageManager) {
58
+ switch (packageManager.name) {
59
+ case 'pnpm':
60
+ return 'pnpm install --force';
61
+ case 'bun':
62
+ return 'bun install --force';
63
+ case 'yarn':
64
+ if (packageManager.majorVersion === 1) {
65
+ return 'yarn install --check-files';
66
+ }
67
+ return 'yarn install (after deleting your repository\'s node_modules directory)';
68
+ default:
69
+ return `${packageManager.name} install (after deleting your repository's node_modules directory)`;
70
+ }
71
+ }
72
+
40
73
  // Binary packages were renamed from `turbo-<os>-<arch>` to `@turbo/<os>-<arch>`.
41
74
  // We try the scoped name first, then fall back to the legacy unscoped name so
42
75
  // that upgrades across the rename boundary still work without re-installing.
@@ -127,8 +160,33 @@ function getBinaryPath() {
127
160
  console.warn('Installation has succeeded.');
128
161
  return resolvedPath;
129
162
  }
130
- } catch (e) {}
131
- console.warn('Installation has failed.');
163
+ console.warn('Installation has failed.');
164
+ console.warn();
165
+ console.warn('npm reported success, but the binary is still missing.');
166
+ console.warn('npm skips failed optional dependencies without reporting an error.');
167
+ console.warn('The reason for the failure is recorded in the debug log of your npm cache\'s _logs directory (see `npm config get cache`).');
168
+ } catch (e) {
169
+ console.warn('Installation has failed.');
170
+
171
+ // Show the underlying error so that failures are diagnosable.
172
+ const stderr = e?.stderr?.toString().trim();
173
+ const reason = stderr || e?.message;
174
+ if (reason) {
175
+ console.warn();
176
+ console.warn('The installation attempt reported:');
177
+ console.warn(reason);
178
+ }
179
+ }
180
+
181
+ // The repair attempt above uses npm regardless of the package manager
182
+ // that installed this tree. If the user came through a different package
183
+ // manager, point them at its equivalent repair command.
184
+ const packageManager = detectPackageManager();
185
+ if (packageManager !== null && packageManager.name !== 'npm') {
186
+ console.warn();
187
+ console.warn(`It looks like your project uses ${packageManager.name}. To reinstall the missing binary, run:`);
188
+ console.warn(repairInstructions(packageManager));
189
+ }
132
190
  }
133
191
 
134
192
  // 3. Both Windows and macOS ARM boxes can run x64 binaries. Attempt to run under emulation.
@@ -219,6 +277,14 @@ function getBinaryPath() {
219
277
  console.error('Turborepo checked to see if binaries for another platform are installed.');
220
278
  console.error('This typically indicates an error in sharing of pre-resolved node_modules across platforms.');
221
279
  console.error('One common reason for this is copying files to Docker.');
280
+
281
+ if (platform === 'windows' && otherInstalled.some((binaryPath) => binaryPath.includes('linux'))) {
282
+ console.error();
283
+ console.error('Turborepo found Linux binaries, but you are running on Windows.');
284
+ console.error('This usually means dependencies were installed from WSL in a directory shared with Windows.');
285
+ console.error('To fix this, delete your node_modules directory and reinstall your dependencies in the environment where you run turbo.');
286
+ }
287
+
222
288
  console.error();
223
289
  console.error(`We found these unnecessary binaries:`);
224
290
  console.error(otherInstalled.join('\n'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turbo",
3
- "version": "2.10.3-canary.7",
3
+ "version": "2.10.3",
4
4
  "description": "Turborepo is a high-performance build system for JavaScript and TypeScript codebases.",
5
5
  "homepage": "https://turborepo.dev",
6
6
  "bugs": "https://github.com/vercel/turborepo/issues",
@@ -15,12 +15,12 @@
15
15
  ],
16
16
  "main": "./bin/turbo",
17
17
  "optionalDependencies": {
18
- "@turbo/darwin-64": "2.10.3-canary.7",
19
- "@turbo/darwin-arm64": "2.10.3-canary.7",
20
- "@turbo/linux-64": "2.10.3-canary.7",
21
- "@turbo/linux-arm64": "2.10.3-canary.7",
22
- "@turbo/windows-64": "2.10.3-canary.7",
23
- "@turbo/windows-arm64": "2.10.3-canary.7"
18
+ "@turbo/darwin-64": "2.10.3",
19
+ "@turbo/darwin-arm64": "2.10.3",
20
+ "@turbo/linux-64": "2.10.3",
21
+ "@turbo/linux-arm64": "2.10.3",
22
+ "@turbo/windows-64": "2.10.3",
23
+ "@turbo/windows-arm64": "2.10.3"
24
24
  },
25
25
  "scripts": {
26
26
  "postversion": "node bump-version.js"