@nocobase/cli 2.1.11-test.5 → 2.1.11-test.6

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.
@@ -116,6 +116,9 @@ function detectInstallMethod(packageRoot, options = {}) {
116
116
  if (options.yarnGlobalDir && isSubPath(options.yarnGlobalDir, packageRoot)) {
117
117
  return 'yarn-global';
118
118
  }
119
+ if (options.pnpmGlobalRoot && isSubPath(options.pnpmGlobalRoot, packageRoot)) {
120
+ return 'pnpm-global';
121
+ }
119
122
  if (isPnpmGlobalPath(packageRoot)) {
120
123
  return 'pnpm-global';
121
124
  }
@@ -140,11 +143,35 @@ function readCurrentBinPath(currentBinPath) {
140
143
  }
141
144
  return normalizePath(candidate);
142
145
  }
146
+ function cleanCommandPath(value) {
147
+ const trimmed = value.trim();
148
+ return trimmed ? trimmed : undefined;
149
+ }
143
150
  async function readGlobalPrefix(commandOutputFn) {
144
151
  try {
145
- return (await commandOutputFn('npm', ['prefix', '-g'], {
152
+ return cleanCommandPath(await commandOutputFn('npm', ['prefix', '-g'], {
146
153
  errorName: 'npm prefix',
147
- })).trim();
154
+ }));
155
+ }
156
+ catch {
157
+ return undefined;
158
+ }
159
+ }
160
+ async function readPnpmGlobalBin(commandOutputFn) {
161
+ try {
162
+ return cleanCommandPath(await commandOutputFn('pnpm', ['bin', '-g'], {
163
+ errorName: 'pnpm bin',
164
+ }));
165
+ }
166
+ catch {
167
+ return undefined;
168
+ }
169
+ }
170
+ async function readPnpmGlobalRoot(commandOutputFn) {
171
+ try {
172
+ return cleanCommandPath(await commandOutputFn('pnpm', ['root', '-g'], {
173
+ errorName: 'pnpm root',
174
+ }));
148
175
  }
149
176
  catch {
150
177
  return undefined;
@@ -152,9 +179,9 @@ async function readGlobalPrefix(commandOutputFn) {
152
179
  }
153
180
  async function readYarnGlobalDir(commandOutputFn) {
154
181
  try {
155
- return (await commandOutputFn('yarn', ['global', 'dir'], {
182
+ return cleanCommandPath(await commandOutputFn('yarn', ['global', 'dir'], {
156
183
  errorName: 'yarn global dir',
157
- })).trim();
184
+ }));
158
185
  }
159
186
  catch {
160
187
  return undefined;
@@ -162,9 +189,9 @@ async function readYarnGlobalDir(commandOutputFn) {
162
189
  }
163
190
  async function readYarnGlobalBin(commandOutputFn) {
164
191
  try {
165
- return (await commandOutputFn('yarn', ['global', 'bin'], {
192
+ return cleanCommandPath(await commandOutputFn('yarn', ['global', 'bin'], {
166
193
  errorName: 'yarn global bin',
167
- })).trim();
194
+ }));
168
195
  }
169
196
  catch {
170
197
  return undefined;
@@ -227,12 +254,16 @@ export async function inspectSelfInstall(options = {}) {
227
254
  const commandOutputFn = options.commandOutputFn ?? commandOutput;
228
255
  const currentBinPath = readCurrentBinPath(options.currentBinPath);
229
256
  const globalPrefix = await readGlobalPrefix(commandOutputFn);
257
+ const pnpmGlobalBin = await readPnpmGlobalBin(commandOutputFn);
258
+ const pnpmGlobalRoot = await readPnpmGlobalRoot(commandOutputFn);
230
259
  const yarnGlobalDir = await readYarnGlobalDir(commandOutputFn);
231
260
  const yarnGlobalBin = await readYarnGlobalBin(commandOutputFn);
232
261
  const installMethod = detectInstallMethodFromSignals({
233
262
  packageRoot,
234
263
  currentBinPath,
235
264
  globalPrefix,
265
+ pnpmGlobalBin,
266
+ pnpmGlobalRoot,
236
267
  yarnGlobalBin,
237
268
  yarnGlobalDir,
238
269
  });
@@ -246,8 +277,12 @@ function detectInstallMethodFromSignals(options) {
246
277
  if (options.currentBinPath && options.yarnGlobalBin && isSubPath(options.yarnGlobalBin, options.currentBinPath)) {
247
278
  return 'yarn-global';
248
279
  }
280
+ if (options.currentBinPath && options.pnpmGlobalBin && isSubPath(options.pnpmGlobalBin, options.currentBinPath)) {
281
+ return 'pnpm-global';
282
+ }
249
283
  return detectInstallMethod(options.packageRoot, {
250
284
  globalPrefix: options.globalPrefix,
285
+ pnpmGlobalRoot: options.pnpmGlobalRoot,
251
286
  yarnGlobalDir: options.yarnGlobalDir,
252
287
  });
253
288
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli",
3
- "version": "2.1.11-test.5",
3
+ "version": "2.1.11-test.6",
4
4
  "description": "NocoBase Command Line Tool",
5
5
  "type": "module",
6
6
  "main": "dist/generated/command-registry.js",