rman 2.40.0 → 2.40.2
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.
|
@@ -41,14 +41,18 @@ export declare class NodePlatform implements Platform {
|
|
|
41
41
|
* rman's core. It is npm's directory layout from end to end: a Cargo or Go repository has no
|
|
42
42
|
* `node_modules` to walk, and nothing here would ever fire for it.
|
|
43
43
|
*
|
|
44
|
-
* **The running `node`'s own directory goes last**, after the walk
|
|
45
|
-
*
|
|
46
|
-
* rather than whatever the shell would pick
|
|
47
|
-
*
|
|
48
|
-
* resolves to the globally installed one, not to the repository's. Shim it in
|
|
49
|
-
* `<root>/node_modules/.bin` when that has to be overridden - the walk above reaches there first.
|
|
44
|
+
* **The running `node`'s own directory goes last**, after the walk - and only when the inherited
|
|
45
|
+
* PATH would find a different `node`. It is there so a script calling `node` gets the interpreter
|
|
46
|
+
* rman itself runs on rather than whatever the shell would pick; where the shell already picks
|
|
47
|
+
* that one, the inherited PATH keeps its own order.
|
|
50
48
|
*/
|
|
51
49
|
getBinPaths(cwd: string): string[];
|
|
50
|
+
/** Whether the inherited PATH's first `node` is the interpreter rman is running on. */
|
|
51
|
+
protected inheritsNode(): boolean;
|
|
52
|
+
/** The PATH a child process inherits, before anything is put in front of it. */
|
|
53
|
+
protected inheritedPath(): string;
|
|
54
|
+
/** `file`'s real path, or `undefined` when it does not exist. */
|
|
55
|
+
protected realPath(file: string): string | undefined;
|
|
52
56
|
/** The `packages` globs of `dir`'s `pnpm-workspace.yaml`, or `undefined` when there is no such
|
|
53
57
|
* file or it lists none. Throws when the file is not valid YAML. */
|
|
54
58
|
protected pnpmWorkspacePackages(dir: string): string[] | undefined;
|
|
@@ -3,6 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import parseNpmScript from '@netlify/parse-npm-script';
|
|
4
4
|
import glob from 'fast-glob';
|
|
5
5
|
import * as yaml from 'js-yaml';
|
|
6
|
+
import { BinPath } from '../../../utils/bin-path.js';
|
|
6
7
|
import { NodeDependencyUpdater } from './node-dependency-updater.js';
|
|
7
8
|
import { NodeManifestProvider } from './node-manifest.provider.js';
|
|
8
9
|
import { NodeVersionPlanService } from './services/version-plan.service.js';
|
|
@@ -121,13 +122,24 @@ export class NodePlatform {
|
|
|
121
122
|
* rman's core. It is npm's directory layout from end to end: a Cargo or Go repository has no
|
|
122
123
|
* `node_modules` to walk, and nothing here would ever fire for it.
|
|
123
124
|
*
|
|
124
|
-
* **The running `node`'s own directory goes last**, after the walk
|
|
125
|
-
*
|
|
126
|
-
* rather than whatever the shell would pick
|
|
127
|
-
*
|
|
128
|
-
* resolves to the globally installed one, not to the repository's. Shim it in
|
|
129
|
-
* `<root>/node_modules/.bin` when that has to be overridden - the walk above reaches there first.
|
|
125
|
+
* **The running `node`'s own directory goes last**, after the walk - and only when the inherited
|
|
126
|
+
* PATH would find a different `node`. It is there so a script calling `node` gets the interpreter
|
|
127
|
+
* rman itself runs on rather than whatever the shell would pick; where the shell already picks
|
|
128
|
+
* that one, the inherited PATH keeps its own order.
|
|
130
129
|
*/
|
|
130
|
+
/* **Unconditional, it put every global npm binary ahead of the user's PATH**, since the
|
|
131
|
+
* interpreter's directory is also where `npm install -g` writes. Measured on this machine: the
|
|
132
|
+
* shell's `pnpm` was 12.10.1 from `~/Library/pnpm/bin`, rman's children got 9.9.0 from the nvm
|
|
133
|
+
* directory, so `deps -u` reported `Not verified: pnpm 9.9.0` and read no `minimumReleaseAge` -
|
|
134
|
+
* while the shell's `node` was the very interpreter rman ran on, so the prepend bought nothing.
|
|
135
|
+
* A nested `rman` inside a `run` script reached the global one the same way.
|
|
136
|
+
*
|
|
137
|
+
* **When the two `node`s differ the directory still goes ahead**, and its neighbours with it:
|
|
138
|
+
* someone ran rman on another interpreter (an `nvm exec`, an absolute path), and the guarantee
|
|
139
|
+
* that a step's `node` is that one outranks the shell's choice of tools. A directory holding only
|
|
140
|
+
* `node` would separate the two and needs a shim on disk; nothing has asked for it yet.
|
|
141
|
+
*
|
|
142
|
+
* Compared by real path, so a Homebrew `bin/node` symlink is the Cellar file `execPath` names. */
|
|
131
143
|
getBinPaths(cwd) {
|
|
132
144
|
const result = [];
|
|
133
145
|
let previous;
|
|
@@ -137,9 +149,38 @@ export class NodePlatform {
|
|
|
137
149
|
previous = dir;
|
|
138
150
|
dir = path.resolve(dir, '..');
|
|
139
151
|
}
|
|
140
|
-
|
|
152
|
+
if (!this.inheritsNode())
|
|
153
|
+
result.push(path.resolve(cwd, process.execPath, '..'));
|
|
141
154
|
return result;
|
|
142
155
|
}
|
|
156
|
+
/** Whether the inherited PATH's first `node` is the interpreter rman is running on. */
|
|
157
|
+
inheritsNode() {
|
|
158
|
+
const names = process.platform === 'win32' ? ['node.exe', 'node.cmd', 'node'] : ['node'];
|
|
159
|
+
const running = this.realPath(process.execPath);
|
|
160
|
+
for (const dir of this.inheritedPath().split(path.delimiter)) {
|
|
161
|
+
if (!dir || !path.isAbsolute(dir))
|
|
162
|
+
continue;
|
|
163
|
+
for (const name of names) {
|
|
164
|
+
const found = this.realPath(path.join(dir, name));
|
|
165
|
+
if (found)
|
|
166
|
+
return found === running;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
/** The PATH a child process inherits, before anything is put in front of it. */
|
|
172
|
+
inheritedPath() {
|
|
173
|
+
return process.env[BinPath.pathKey()] ?? '';
|
|
174
|
+
}
|
|
175
|
+
/** `file`'s real path, or `undefined` when it does not exist. */
|
|
176
|
+
realPath(file) {
|
|
177
|
+
try {
|
|
178
|
+
return fs.realpathSync(file);
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
143
184
|
/** The `packages` globs of `dir`'s `pnpm-workspace.yaml`, or `undefined` when there is no such
|
|
144
185
|
* file or it lists none. Throws when the file is not valid YAML. */
|
|
145
186
|
/* Thrown rather than swallowed, unlike a malformed `package.json` above: nothing else in rman
|
package/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.40.
|
|
1
|
+
export const version = '2.40.2';
|