yingmi-skill-cli 0.0.7 → 0.0.8
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/README.md +1 -1
- package/bin/index.js +26 -29
- package/package.json +1 -1
package/README.md
CHANGED
package/bin/index.js
CHANGED
|
@@ -11,7 +11,7 @@ var crypto = require('crypto');
|
|
|
11
11
|
var child_process = require('child_process');
|
|
12
12
|
|
|
13
13
|
var name = "yingmi-skill-cli";
|
|
14
|
-
var version = "0.0.
|
|
14
|
+
var version = "0.0.8";
|
|
15
15
|
|
|
16
16
|
function fail(message) {
|
|
17
17
|
console.error(message);
|
|
@@ -1484,10 +1484,10 @@ function registerRemoteSkillCommand(program) {
|
|
|
1484
1484
|
});
|
|
1485
1485
|
}
|
|
1486
1486
|
|
|
1487
|
-
const REGISTRY_URL
|
|
1487
|
+
const REGISTRY_URL = "https://registry.npmmirror.com";
|
|
1488
1488
|
async function fetchLatestVersion() {
|
|
1489
1489
|
const response = await axios.get(
|
|
1490
|
-
`${REGISTRY_URL
|
|
1490
|
+
`${REGISTRY_URL}/${encodeURIComponent(name)}`,
|
|
1491
1491
|
{
|
|
1492
1492
|
timeout: 1e4
|
|
1493
1493
|
}
|
|
@@ -1499,26 +1499,26 @@ async function fetchLatestVersion() {
|
|
|
1499
1499
|
return latestVersion;
|
|
1500
1500
|
}
|
|
1501
1501
|
|
|
1502
|
+
const UPGRADE_REGISTRY_URL = "https://registry.npmmirror.com";
|
|
1503
|
+
const UPGRADE_INSTALL_ARGS = [
|
|
1504
|
+
"install",
|
|
1505
|
+
"-g",
|
|
1506
|
+
`${name}@latest`,
|
|
1507
|
+
`--registry=${UPGRADE_REGISTRY_URL}`,
|
|
1508
|
+
"--prefer-online"
|
|
1509
|
+
];
|
|
1510
|
+
const UPGRADE_INSTALL_HINT_COMMAND = `npm ${UPGRADE_INSTALL_ARGS.join(" ")}`;
|
|
1511
|
+
|
|
1502
1512
|
async function installLatestVersion() {
|
|
1503
1513
|
const npmCommand = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
1504
1514
|
await new Promise((resolve, reject) => {
|
|
1505
|
-
const child = child_process.spawn(
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
"
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
"--prefer-online"
|
|
1513
|
-
],
|
|
1514
|
-
{
|
|
1515
|
-
env: {
|
|
1516
|
-
...process.env,
|
|
1517
|
-
PUPPETEER_SKIP_DOWNLOAD: "true"
|
|
1518
|
-
},
|
|
1519
|
-
stdio: "inherit"
|
|
1520
|
-
}
|
|
1521
|
-
);
|
|
1515
|
+
const child = child_process.spawn(npmCommand, [...UPGRADE_INSTALL_ARGS], {
|
|
1516
|
+
env: {
|
|
1517
|
+
...process.env,
|
|
1518
|
+
PUPPETEER_SKIP_DOWNLOAD: "true"
|
|
1519
|
+
},
|
|
1520
|
+
stdio: "inherit"
|
|
1521
|
+
});
|
|
1522
1522
|
child.on("error", reject);
|
|
1523
1523
|
child.on("exit", (code) => {
|
|
1524
1524
|
if (code === 0) {
|
|
@@ -1555,23 +1555,20 @@ function isNewerVersion(latestVersion, currentVersion) {
|
|
|
1555
1555
|
return false;
|
|
1556
1556
|
}
|
|
1557
1557
|
|
|
1558
|
-
const REGISTRY_URL = "https://registry.npmmirror.com";
|
|
1559
1558
|
async function checkAndUpdate(checkOnly = false) {
|
|
1560
|
-
console.
|
|
1559
|
+
console.error("\u6B63\u5728\u68C0\u67E5\u66F4\u65B0...");
|
|
1561
1560
|
const latestVersion = await fetchLatestVersion();
|
|
1562
1561
|
if (!isNewerVersion(latestVersion, version)) {
|
|
1563
|
-
console.
|
|
1562
|
+
console.error(`\u5F53\u524D\u5DF2\u662F\u6700\u65B0\u7248\u672C: ${version}`);
|
|
1564
1563
|
return;
|
|
1565
1564
|
}
|
|
1566
|
-
console.
|
|
1565
|
+
console.error(`\u53D1\u73B0\u65B0\u7248\u672C: ${version} -> ${latestVersion}`);
|
|
1567
1566
|
if (checkOnly) {
|
|
1568
|
-
console.
|
|
1569
|
-
`\u53EF\u6267\u884C PUPPETEER_SKIP_DOWNLOAD=true npm install -g ${name}@latest --registry=${REGISTRY_URL} --prefer-online \u8FDB\u884C\u5347\u7EA7`
|
|
1570
|
-
);
|
|
1567
|
+
console.error(`\u53EF\u6267\u884C ${UPGRADE_INSTALL_HINT_COMMAND} \u8FDB\u884C\u5347\u7EA7`);
|
|
1571
1568
|
return;
|
|
1572
1569
|
}
|
|
1573
1570
|
await installLatestVersion();
|
|
1574
|
-
console.
|
|
1571
|
+
console.error(`\u5347\u7EA7\u5B8C\u6210\uFF0C\u5F53\u524D\u6700\u65B0\u7248\u672C: ${latestVersion}`);
|
|
1575
1572
|
}
|
|
1576
1573
|
|
|
1577
1574
|
function registerUpgradeCommand(program) {
|
|
@@ -1586,7 +1583,7 @@ function registerUpgradeCommand(program) {
|
|
|
1586
1583
|
yingmi-skill-cli upgrade
|
|
1587
1584
|
|
|
1588
1585
|
\u8BF4\u660E:
|
|
1589
|
-
- --check-only \u53EA\u68C0\u67E5\u7248\u672C\uFF0C\u4E0D\u6267\u884C\u5B89\u88C5
|
|
1586
|
+
- --check-only \u53EA\u68C0\u67E5\u7248\u672C\uFF0C\u4E0D\u6267\u884C\u5B89\u88C5\uFF1B\u53D1\u73B0\u65B0\u7248\u672C\u65F6\u4F1A\u8F93\u51FA\u53EF\u590D\u5236\u7684 npm \u5B89\u88C5\u547D\u4EE4
|
|
1590
1587
|
- \u771F\u6B63\u5347\u7EA7\u524D\u5E94\u660E\u786E\u4E86\u89E3\u526F\u4F5C\u7528
|
|
1591
1588
|
- \u975E\u4EA4\u4E92\u73AF\u5883\u4E0B\u4E0D\u5E94\u4F9D\u8D56\u786E\u8BA4\u8F93\u5165
|
|
1592
1589
|
`
|