@nocobase/cli 2.1.11-test.1 → 2.1.11-test.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.
@@ -142,6 +142,13 @@ function getInstallMethodCacheFile() {
142
142
  function getInstallMethodCacheKey(packageRoot) {
143
143
  return normalizePath(path.join(packageRoot, 'bin', 'run.js'));
144
144
  }
145
+ function readCurrentBinPath(currentBinPath) {
146
+ const candidate = String(currentBinPath ?? process.argv[1] ?? '').trim();
147
+ if (!candidate) {
148
+ return undefined;
149
+ }
150
+ return normalizePath(candidate);
151
+ }
145
152
  async function readInstallMethodCache() {
146
153
  try {
147
154
  const raw = await fsp.readFile(getInstallMethodCacheFile(), 'utf8');
@@ -188,6 +195,16 @@ async function readYarnGlobalDir(commandOutputFn) {
188
195
  return undefined;
189
196
  }
190
197
  }
198
+ async function readYarnGlobalBin(commandOutputFn) {
199
+ try {
200
+ return (await commandOutputFn('yarn', ['global', 'bin'], {
201
+ errorName: 'yarn global bin',
202
+ })).trim();
203
+ }
204
+ catch {
205
+ return undefined;
206
+ }
207
+ }
191
208
  async function readDistTags(packageName, commandOutputFn) {
192
209
  const output = await commandOutputFn('npm', ['view', packageName, 'dist-tags', '--json'], {
193
210
  errorName: 'npm view',
@@ -244,17 +261,24 @@ export async function inspectSelfInstall(options = {}) {
244
261
  const packageRoot = options.packageRoot ? normalizePath(options.packageRoot) : PACKAGE_ROOT;
245
262
  const commandOutputFn = options.commandOutputFn ?? commandOutput;
246
263
  const cachedInstallMethod = await readCachedInstallMethod(packageRoot);
264
+ const currentBinPath = readCurrentBinPath(options.currentBinPath);
247
265
  const globalPrefix = cachedInstallMethod?.globalPrefix ?? await readGlobalPrefix(commandOutputFn);
248
266
  const yarnGlobalDir = cachedInstallMethod?.yarnGlobalDir ?? await readYarnGlobalDir(commandOutputFn);
267
+ const yarnGlobalBin = cachedInstallMethod?.yarnGlobalBin ?? await readYarnGlobalBin(commandOutputFn);
249
268
  const installMethod = cachedInstallMethod?.installMethod
250
- ?? detectInstallMethod(packageRoot, {
269
+ ?? detectInstallMethodFromSignals({
270
+ packageRoot,
271
+ currentBinPath,
251
272
  globalPrefix,
273
+ yarnGlobalBin,
252
274
  yarnGlobalDir,
253
275
  });
254
- if (!cachedInstallMethod) {
276
+ if (!cachedInstallMethod || cachedInstallMethod.currentBinPath !== currentBinPath) {
255
277
  await writeCachedInstallMethod(packageRoot, {
256
278
  installMethod,
279
+ currentBinPath,
257
280
  globalPrefix,
281
+ yarnGlobalBin,
258
282
  yarnGlobalDir,
259
283
  });
260
284
  }
@@ -264,6 +288,15 @@ export async function inspectSelfInstall(options = {}) {
264
288
  globalPrefix,
265
289
  };
266
290
  }
291
+ function detectInstallMethodFromSignals(options) {
292
+ if (options.currentBinPath && options.yarnGlobalBin && isSubPath(options.yarnGlobalBin, options.currentBinPath)) {
293
+ return 'yarn-global';
294
+ }
295
+ return detectInstallMethod(options.packageRoot, {
296
+ globalPrefix: options.globalPrefix,
297
+ yarnGlobalDir: options.yarnGlobalDir,
298
+ });
299
+ }
267
300
  export async function inspectSelfStatus(options = {}) {
268
301
  const packageRoot = options.packageRoot ? normalizePath(options.packageRoot) : PACKAGE_ROOT;
269
302
  const packageName = options.packageName ?? DEFAULT_PACKAGE_NAME;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli",
3
- "version": "2.1.11-test.1",
3
+ "version": "2.1.11-test.2",
4
4
  "description": "NocoBase Command Line Tool",
5
5
  "type": "module",
6
6
  "main": "dist/generated/command-registry.js",