@app-public/weaverbird-debug 1.0.2 → 1.0.3
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/index.js +7 -2
- package/package.json +1 -1
- package/update.js +6 -4
package/index.js
CHANGED
|
@@ -12,6 +12,7 @@ const { setServiceToken } = require('./token');
|
|
|
12
12
|
const pkg = require('./package.json');
|
|
13
13
|
|
|
14
14
|
const scriptName = resolveScriptName();
|
|
15
|
+
const UPDATE_ALIASES = ['update', 'udpate'];
|
|
15
16
|
|
|
16
17
|
function printStatus() {
|
|
17
18
|
const token = getToken();
|
|
@@ -51,6 +52,8 @@ function registerTokenCommands(yargs) {
|
|
|
51
52
|
|
|
52
53
|
function registerCliSubcommands(yargs) {
|
|
53
54
|
return yargs
|
|
55
|
+
.strictCommands()
|
|
56
|
+
.recommendCommands()
|
|
54
57
|
.command(
|
|
55
58
|
'login',
|
|
56
59
|
`浏览器 OAuth 登录,token 保存至 ~/.weaverbird/token.${ENV}.json`,
|
|
@@ -77,7 +80,7 @@ function registerCliSubcommands(yargs) {
|
|
|
77
80
|
}
|
|
78
81
|
)
|
|
79
82
|
.command(
|
|
80
|
-
|
|
83
|
+
UPDATE_ALIASES,
|
|
81
84
|
'从 npm 更新当前环境 CLI 到最新版本',
|
|
82
85
|
() => {},
|
|
83
86
|
() => {
|
|
@@ -92,8 +95,10 @@ async function main() {
|
|
|
92
95
|
.scriptName(scriptName)
|
|
93
96
|
.usage('$0 <command> [options]')
|
|
94
97
|
.version(pkg.version)
|
|
98
|
+
.strictCommands()
|
|
99
|
+
.recommendCommands()
|
|
95
100
|
.command(
|
|
96
|
-
|
|
101
|
+
UPDATE_ALIASES,
|
|
97
102
|
'从 npm 更新当前环境 CLI 到最新版本',
|
|
98
103
|
() => {},
|
|
99
104
|
() => {
|
package/package.json
CHANGED
package/update.js
CHANGED
|
@@ -3,10 +3,13 @@ const { ENV } = require('./config');
|
|
|
3
3
|
const { getNpmPackageName } = require('./npm-packages');
|
|
4
4
|
const pkg = require('./package.json');
|
|
5
5
|
|
|
6
|
+
function getNpmCommand() {
|
|
7
|
+
return process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
|
8
|
+
}
|
|
9
|
+
|
|
6
10
|
function queryLatestVersion(packageName) {
|
|
7
|
-
const result = spawnSync(
|
|
11
|
+
const result = spawnSync(getNpmCommand(), ['view', packageName, 'version'], {
|
|
8
12
|
encoding: 'utf8',
|
|
9
|
-
shell: true,
|
|
10
13
|
});
|
|
11
14
|
if (result.status !== 0) {
|
|
12
15
|
return null;
|
|
@@ -29,9 +32,8 @@ function runUpdate() {
|
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
console.log(`⬇️ 正在更新 ${packageName}@latest ...`);
|
|
32
|
-
const result = spawnSync(
|
|
35
|
+
const result = spawnSync(getNpmCommand(), ['install', '-g', `${packageName}@latest`], {
|
|
33
36
|
stdio: 'inherit',
|
|
34
|
-
shell: true,
|
|
35
37
|
});
|
|
36
38
|
if (result.status !== 0) {
|
|
37
39
|
throw new Error('更新失败,请检查网络或 npm 登录状态');
|