@qmuse/qmuse-cli 1.0.3 → 1.0.5-dev.1
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/dist/cli.js +5 -5
- package/dist/import/limits.js +2 -2
- package/dist/login.js +5 -10
- package/package.json +2 -1
package/dist/cli.js
CHANGED
|
@@ -94,8 +94,7 @@ function output(value, flags) {
|
|
|
94
94
|
process.stdout.write(`${json}\n`);
|
|
95
95
|
}
|
|
96
96
|
function fail(message) {
|
|
97
|
-
|
|
98
|
-
process.exit(1);
|
|
97
|
+
throw new Error(message);
|
|
99
98
|
}
|
|
100
99
|
function requireAuth(cfg) {
|
|
101
100
|
if (!hasAuth(cfg)) {
|
|
@@ -821,10 +820,11 @@ async function main() {
|
|
|
821
820
|
const msg = err instanceof Error ? err.message : String(err);
|
|
822
821
|
if (flags['--json'] === true) {
|
|
823
822
|
output({ success: false, message: msg }, flags);
|
|
824
|
-
process.exitCode = 1;
|
|
825
823
|
}
|
|
826
|
-
else
|
|
827
|
-
|
|
824
|
+
else {
|
|
825
|
+
log.error(msg);
|
|
826
|
+
}
|
|
827
|
+
process.exitCode = 1;
|
|
828
828
|
}
|
|
829
829
|
finally {
|
|
830
830
|
finishUpdateNotice();
|
package/dist/import/limits.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export const MAX_IMPORT_ARCHIVE_BYTES =
|
|
1
|
+
export const MAX_IMPORT_ARCHIVE_BYTES = 50 * 1024 * 1024;
|
|
2
2
|
export function assertImportArchiveSize(sizeBytes) {
|
|
3
3
|
if (sizeBytes > MAX_IMPORT_ARCHIVE_BYTES) {
|
|
4
|
-
throw new Error(`源码压缩包超过
|
|
4
|
+
throw new Error(`源码压缩包超过 50 MiB 上传上限:当前 ${(sizeBytes / 1024 / 1024).toFixed(2)} MiB(${sizeBytes} 字节)。请将不参与运行的生成产物加入 .gitignore 后重试`);
|
|
5
5
|
}
|
|
6
6
|
}
|
package/dist/login.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* QMuse 网页确认登录:服务端创建短期请求,浏览器确认后由 CLI 轮询换取会话。
|
|
3
3
|
*/
|
|
4
|
-
import { execFile } from 'node:child_process';
|
|
5
4
|
import { createInterface } from 'node:readline';
|
|
5
|
+
import open from 'open';
|
|
6
6
|
import * as api from './api.js';
|
|
7
7
|
import { buildUrl } from './client.js';
|
|
8
8
|
import { apiOrigin, loadConfig, saveSession } from './config.js';
|
|
@@ -52,10 +52,7 @@ export function closePrompt() {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
export function openBrowser(url) {
|
|
55
|
-
|
|
56
|
-
return new Promise(resolve => {
|
|
57
|
-
execFile(command, [url], error => resolve(!error));
|
|
58
|
-
});
|
|
55
|
+
return open(url, { wait: false }).then(() => true, () => false);
|
|
59
56
|
}
|
|
60
57
|
export function persistSession(sessionId, targetConfig = loadConfig()) {
|
|
61
58
|
const origin = apiOrigin(targetConfig.baseUrl);
|
|
@@ -103,11 +100,9 @@ export async function loginBrowser(cfg, options = {}, dependencyOverrides) {
|
|
|
103
100
|
log.info('正在打开 QMuse 登录页面...');
|
|
104
101
|
log.info(`确认码:${token.slice(-6).toUpperCase()}`);
|
|
105
102
|
if (!await dependencies.open(authUrl.toString())) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
message: '无法打开 QMuse 登录页面,请检查系统默认浏览器配置后重试',
|
|
110
|
-
};
|
|
103
|
+
log.warn('无法自动打开浏览器,请复制下面的一次性地址到浏览器中打开:');
|
|
104
|
+
log.raw(`${authUrl.toString()}\n`);
|
|
105
|
+
log.warn('该地址包含一次性登录凭证,请勿分享');
|
|
111
106
|
}
|
|
112
107
|
log.info('等待网页确认登录...');
|
|
113
108
|
const deadline = dependencies.now() + Math.min(SESSION_EXCHANGE_POLL_TIMEOUT_MS, expiresInSeconds * 1000);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qmuse/qmuse-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5-dev.1",
|
|
4
4
|
"description": "将本地 React 项目安全导入 QMuse 的命令行客户端",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@napi-rs/keyring": "2.0.0",
|
|
23
23
|
"ignore": "^7.0.8",
|
|
24
|
+
"open": "^11.0.4",
|
|
24
25
|
"semver": "7.7.4",
|
|
25
26
|
"yazl": "^3.3.1"
|
|
26
27
|
},
|