@lark-people/cli 0.0.5 → 0.0.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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-people/cli",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "description": "The official CLI for People open platform",
5
5
  "bin": {
6
6
  "people-cli": "scripts/run.js"
@@ -309,6 +309,29 @@ function sameResolvedPath(a, b) {
309
309
  }
310
310
  }
311
311
 
312
+ function resolveExistingPath(targetPath) {
313
+ if (!targetPath) {
314
+ return null;
315
+ }
316
+ try {
317
+ return fs.realpathSync(targetPath);
318
+ } catch (_) {
319
+ return targetPath;
320
+ }
321
+ }
322
+
323
+ function isNpxCachePath(packageDir) {
324
+ if (!packageDir) {
325
+ return false;
326
+ }
327
+ const normalized = String(packageDir).replace(/\\/g, "/");
328
+ return normalized.includes("/_npx/") && normalized.includes("/node_modules/");
329
+ }
330
+
331
+ function packageInstallTarget(packageName, version) {
332
+ return version ? `${packageName}@${version}` : packageName;
333
+ }
334
+
312
335
  function parseVersion(version) {
313
336
  if (!version) {
314
337
  return null;
@@ -355,10 +378,19 @@ function planGlobalInstall({
355
378
  currentPackageDir = CURRENT_PACKAGE_DIR,
356
379
  globalPackageDir = resolveGlobalPackageDir(currentPackageName),
357
380
  } = {}) {
381
+ const resolvedCurrentPackageDir = resolveExistingPath(currentPackageDir);
382
+ const resolvedGlobalPackageDir = resolveExistingPath(globalPackageDir);
383
+ const currentPackageFromNpxCache = isNpxCachePath(currentPackageDir) || isNpxCachePath(resolvedCurrentPackageDir);
384
+ const globalPackageLinkedToNpxCache = isNpxCachePath(globalPackageDir) || isNpxCachePath(resolvedGlobalPackageDir);
385
+ const missingGlobalInstallFromNpxCache = currentPackageFromNpxCache && !installedVersion;
386
+ const registryInstallVersion = currentVersion || latestVersion || installedVersion || null;
387
+ const registryInstallTarget = packageInstallTarget(currentPackageName, registryInstallVersion);
358
388
  const useCurrentPackage = Boolean(
359
389
  currentPackageDir &&
360
390
  globalPackageDir &&
361
- !sameResolvedPath(currentPackageDir, globalPackageDir),
391
+ !sameResolvedPath(currentPackageDir, globalPackageDir) &&
392
+ !currentPackageFromNpxCache &&
393
+ !globalPackageLinkedToNpxCache,
362
394
  );
363
395
 
364
396
  if (useCurrentPackage) {
@@ -377,11 +409,12 @@ function planGlobalInstall({
377
409
  installVersion &&
378
410
  compareVersions(installedVersion, installVersion) < 0,
379
411
  );
412
+ const needsRepair = Boolean(globalPackageLinkedToNpxCache || missingGlobalInstallFromNpxCache);
380
413
 
381
414
  return {
382
- skip: Boolean(installedVersion && !needsUpgrade),
415
+ skip: Boolean(installedVersion && !needsUpgrade && !needsRepair),
383
416
  needsUpgrade,
384
- installTarget: currentPackageName,
417
+ installTarget: needsRepair ? registryInstallTarget : currentPackageName,
385
418
  installVersion,
386
419
  useCurrentPackage: false,
387
420
  };
Binary file