@lark-people/cli 0.0.0-beta.1 → 0.0.0-beta.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.
- package/bin/people-cli_darwin_amd64 +0 -0
- package/bin/people-cli_darwin_arm64 +0 -0
- package/bin/people-cli_linux_amd64 +0 -0
- package/bin/people-cli_linux_arm64 +0 -0
- package/bin/people-cli_windows_amd64.exe +0 -0
- package/bin/people-cli_windows_arm64.exe +0 -0
- package/package.json +1 -1
- package/scripts/install-wizard.js +121 -5
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -32,6 +32,9 @@ const messages = {
|
|
|
32
32
|
step1Done: "已全局安装",
|
|
33
33
|
step1Upgraded: "已升级到 v%s",
|
|
34
34
|
step1Fail: "全局安装失败。运行以下命令重试: npm install -g %s",
|
|
35
|
+
step1MigrateSpinner: "检测到旧版包 %s 占用 people-cli 命令,正在迁移...",
|
|
36
|
+
step1MigrateDone: "已卸载旧版包 %s",
|
|
37
|
+
step1MigrateFail: "卸载旧版包 %s 失败,请手动运行: npm uninstall -g %s",
|
|
35
38
|
step2Spinner: "正在安装 Skills...",
|
|
36
39
|
step2Skip: "官方 Skills 已齐全,跳过",
|
|
37
40
|
step2Done: "Skills 已安装",
|
|
@@ -62,6 +65,9 @@ const messages = {
|
|
|
62
65
|
step1Done: "Installed globally",
|
|
63
66
|
step1Upgraded: "Upgraded to v%s",
|
|
64
67
|
step1Fail: "Failed to install globally. Run manually: npm install -g %s",
|
|
68
|
+
step1MigrateSpinner: "Legacy package %s owns the people-cli command. Migrating...",
|
|
69
|
+
step1MigrateDone: "Removed legacy package %s",
|
|
70
|
+
step1MigrateFail: "Failed to remove legacy package %s. Run manually: npm uninstall -g %s",
|
|
65
71
|
step2Spinner: "Installing skills...",
|
|
66
72
|
step2Skip: "Official skills already present. Skipped",
|
|
67
73
|
step2Done: "Skills installed",
|
|
@@ -212,6 +218,76 @@ function resolveGlobalPackageDir(packageName = PKG) {
|
|
|
212
218
|
}
|
|
213
219
|
}
|
|
214
220
|
|
|
221
|
+
// Extract the owning npm package name from a resolved path that points inside a
|
|
222
|
+
// node_modules tree, e.g. ".../node_modules/@people/people-cli/scripts/run.js"
|
|
223
|
+
// -> "@people/people-cli". Returns null when the path is not inside a package.
|
|
224
|
+
function packageNameFromModulePath(resolvedPath) {
|
|
225
|
+
if (!resolvedPath) {
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
const normalized = String(resolvedPath).replace(/\\/g, "/");
|
|
229
|
+
const marker = "/node_modules/";
|
|
230
|
+
const idx = normalized.lastIndexOf(marker);
|
|
231
|
+
if (idx === -1) {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
const segments = normalized.slice(idx + marker.length).split("/").filter(Boolean);
|
|
235
|
+
if (segments.length === 0) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
if (segments[0].startsWith("@")) {
|
|
239
|
+
return segments.length >= 2 ? `${segments[0]}/${segments[1]}` : null;
|
|
240
|
+
}
|
|
241
|
+
return segments[0];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Resolve which npm package currently owns the global `people-cli` bin. On
|
|
245
|
+
// POSIX the bin is a symlink into the owning package; on Windows the .cmd shim
|
|
246
|
+
// is not a symlink, so ownership cannot be resolved and we return null.
|
|
247
|
+
function resolveGlobalBinOwner(binName = BIN_NAME, deps = {}) {
|
|
248
|
+
const runSilentFn = deps.runSilent || runSilent;
|
|
249
|
+
const realpathSync = deps.realpathSync || fs.realpathSync;
|
|
250
|
+
try {
|
|
251
|
+
const prefix = runSilentFn("npm", ["prefix", "-g"], { timeout: 15000 }).toString().trim();
|
|
252
|
+
const binPath = isWindows
|
|
253
|
+
? path.join(prefix, `${binName}.cmd`)
|
|
254
|
+
: path.join(prefix, "bin", binName);
|
|
255
|
+
const resolved = realpathSync(binPath);
|
|
256
|
+
return packageNameFromModulePath(resolved);
|
|
257
|
+
} catch (_) {
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Decide whether a globally installed package owns the `people-cli` bin under a
|
|
263
|
+
// DIFFERENT package name than the one we are about to install. This is the root
|
|
264
|
+
// cause of `npm EEXIST` after a package rename: npm refuses to overwrite a bin
|
|
265
|
+
// owned by another package. Returns the conflicting owner name, or null.
|
|
266
|
+
function findConflictingBinOwner(targetPackageName = PKG, deps = {}) {
|
|
267
|
+
const owner = deps.resolveGlobalBinOwner
|
|
268
|
+
? deps.resolveGlobalBinOwner(BIN_NAME)
|
|
269
|
+
: resolveGlobalBinOwner();
|
|
270
|
+
if (!owner || owner === targetPackageName) {
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
return owner;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// Uninstall a conflicting legacy package that owns the `people-cli` bin so the
|
|
277
|
+
// renamed package can claim the bin without `npm EEXIST`.
|
|
278
|
+
function removeConflictingLegacyPackage(owner, deps = {}) {
|
|
279
|
+
if (!owner) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
const runSilentFn = deps.runSilent || runSilent;
|
|
283
|
+
try {
|
|
284
|
+
runSilentFn("npm", ["uninstall", "-g", owner], { timeout: 120000 });
|
|
285
|
+
return true;
|
|
286
|
+
} catch (_) {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
215
291
|
function sameResolvedPath(a, b) {
|
|
216
292
|
if (!a || !b) {
|
|
217
293
|
return false;
|
|
@@ -503,6 +579,32 @@ async function stepInstallGlobally(msg) {
|
|
|
503
579
|
return false;
|
|
504
580
|
}
|
|
505
581
|
|
|
582
|
+
// Detect a legacy package that owns the `people-cli` bin under a different
|
|
583
|
+
// name (e.g. after renaming @people/people-cli -> @lark-people/cli). Left in
|
|
584
|
+
// place, npm aborts the install with EEXIST. Remove it first so the renamed
|
|
585
|
+
// package (always installed under currentPkg's name) can claim the bin.
|
|
586
|
+
const conflictingOwner = findConflictingBinOwner(currentPkg);
|
|
587
|
+
if (conflictingOwner) {
|
|
588
|
+
const migrateSpinner = p ? p.spinner() : null;
|
|
589
|
+
if (migrateSpinner) {
|
|
590
|
+
migrateSpinner.start(fmt(msg.step1MigrateSpinner, conflictingOwner));
|
|
591
|
+
} else {
|
|
592
|
+
console.log(fmt(msg.step1MigrateSpinner, conflictingOwner));
|
|
593
|
+
}
|
|
594
|
+
const removed = removeConflictingLegacyPackage(conflictingOwner);
|
|
595
|
+
if (removed) {
|
|
596
|
+
if (migrateSpinner) {
|
|
597
|
+
migrateSpinner.stop(fmt(msg.step1MigrateDone, conflictingOwner));
|
|
598
|
+
} else {
|
|
599
|
+
console.log(fmt(msg.step1MigrateDone, conflictingOwner));
|
|
600
|
+
}
|
|
601
|
+
} else if (migrateSpinner) {
|
|
602
|
+
migrateSpinner.stop(fmt(msg.step1MigrateFail, conflictingOwner, conflictingOwner));
|
|
603
|
+
} else {
|
|
604
|
+
console.error(fmt(msg.step1MigrateFail, conflictingOwner, conflictingOwner));
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
506
608
|
const spinner = p ? p.spinner() : null;
|
|
507
609
|
if (spinner) {
|
|
508
610
|
spinner.start(
|
|
@@ -518,12 +620,22 @@ async function stepInstallGlobally(msg) {
|
|
|
518
620
|
}
|
|
519
621
|
return true;
|
|
520
622
|
} catch (_) {
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
623
|
+
// Last-resort retry: force npm to overwrite any bin left behind by a legacy
|
|
624
|
+
// package that could not be cleanly removed above.
|
|
625
|
+
try {
|
|
626
|
+
await runSilentAsync("npm", ["install", "-g", "--force", plan.installTarget], { timeout: 120000 });
|
|
627
|
+
if (spinner) {
|
|
628
|
+
spinner.stop(plan.needsUpgrade ? fmt(msg.step1Upgraded, plan.installVersion) : msg.step1Done);
|
|
629
|
+
}
|
|
630
|
+
return true;
|
|
631
|
+
} catch (_) {
|
|
632
|
+
if (spinner) {
|
|
633
|
+
spinner.stop(fmt(msg.step1Fail, PKG));
|
|
634
|
+
} else {
|
|
635
|
+
console.error(fmt(msg.step1Fail, PKG));
|
|
636
|
+
}
|
|
637
|
+
process.exit(1);
|
|
525
638
|
}
|
|
526
|
-
process.exit(1);
|
|
527
639
|
}
|
|
528
640
|
}
|
|
529
641
|
|
|
@@ -672,15 +784,19 @@ module.exports = {
|
|
|
672
784
|
buildInstallAuthLoginArgs,
|
|
673
785
|
DEFAULT_SKILLS_DIR,
|
|
674
786
|
diffMissingSkills,
|
|
787
|
+
findConflictingBinOwner,
|
|
675
788
|
formatCommandFailure,
|
|
676
789
|
buildSkillsCommandArgs,
|
|
677
790
|
inspectExistingAppConfig,
|
|
678
791
|
listBundledSkills,
|
|
679
792
|
listInstalledGlobalSkills,
|
|
793
|
+
packageNameFromModulePath,
|
|
680
794
|
parseGlobalSkillsJSON,
|
|
681
795
|
parseGlobalSkillsText,
|
|
682
796
|
parseLangArg,
|
|
683
797
|
planGlobalInstall,
|
|
798
|
+
removeConflictingLegacyPackage,
|
|
799
|
+
resolveGlobalBinOwner,
|
|
684
800
|
resolveSkillsLauncher,
|
|
685
801
|
stepInstallSkills,
|
|
686
802
|
main,
|