@sevenvip666/rop 0.1.2 → 0.1.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/dist/bin/index.mjs +106 -70
- package/dist/cjs/index.js +52 -38
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +42 -25
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/index.mjs
CHANGED
|
@@ -15,6 +15,7 @@ import JSON5 from 'json5';
|
|
|
15
15
|
import yaml from 'js-yaml';
|
|
16
16
|
import { confirm, select, input, password } from '@inquirer/prompts';
|
|
17
17
|
import * as os from 'node:os';
|
|
18
|
+
import chalk from 'chalk';
|
|
18
19
|
|
|
19
20
|
/******************************************************************************
|
|
20
21
|
Copyright (c) Microsoft Corporation.
|
|
@@ -210,7 +211,6 @@ var TauriConfig = /** @class */ (function () {
|
|
|
210
211
|
this.identifier = identifier;
|
|
211
212
|
}
|
|
212
213
|
TauriConfig.fromBaseConfig = function (tauriDir) {
|
|
213
|
-
console.log(tauriDir);
|
|
214
214
|
if (existsSync(join(tauriDir, 'tauri.conf.json'))) {
|
|
215
215
|
var contents = readFileSync(join(tauriDir, 'tauri.conf.json')).toString();
|
|
216
216
|
var config = _tryParseJsonConfig(contents);
|
|
@@ -559,13 +559,15 @@ function loadJsonWithEnv(_a) {
|
|
|
559
559
|
config = inputConfig;
|
|
560
560
|
}
|
|
561
561
|
if (!config.platforms || Object.keys(config.platforms).length == 0) {
|
|
562
|
-
|
|
562
|
+
console.log(colors.red('The platforms property in rop.json cannot be empty.'));
|
|
563
|
+
return;
|
|
563
564
|
}
|
|
564
565
|
var _autoEnv = getAutoEnvByFramework((_d = config === null || config === void 0 ? void 0 : config.framework) === null || _d === void 0 ? void 0 : _d.name, config.projectPath);
|
|
565
566
|
env = __assign(__assign(__assign({}, env), (_autoEnv !== null && _autoEnv !== void 0 ? _autoEnv : {})), ((_f = (_e = config.framework) === null || _e === void 0 ? void 0 : _e.env) !== null && _f !== void 0 ? _f : {}));
|
|
566
567
|
// 确保配置文件中存在 host 属性
|
|
567
568
|
if (!env.version) {
|
|
568
|
-
|
|
569
|
+
console.log(colors.red('The version property in rop.json cannot be empty.'));
|
|
570
|
+
return;
|
|
569
571
|
}
|
|
570
572
|
// 递归函数来替换对象中的字符串值
|
|
571
573
|
function replaceEnvInObject(obj) {
|
|
@@ -582,8 +584,8 @@ function loadJsonWithEnv(_a) {
|
|
|
582
584
|
}
|
|
583
585
|
replaceEnvInObject(config);
|
|
584
586
|
var targetInfos = getTargetInfo(config.platforms, platform, _arch);
|
|
585
|
-
console.log(
|
|
586
|
-
console.log(targetInfos);
|
|
587
|
+
console.log(colors.cyan("find target file:"));
|
|
588
|
+
console.log("".concat(JSON.stringify(targetInfos)));
|
|
587
589
|
return { config: config, targetInfos: targetInfos, version: env.version, arch: _arch };
|
|
588
590
|
}
|
|
589
591
|
var loadConfigJSON = function () {
|
|
@@ -637,8 +639,13 @@ var RopUploadApi = /** @class */ (function () {
|
|
|
637
639
|
switch (_c.label) {
|
|
638
640
|
case 0:
|
|
639
641
|
if (!config.accessKey) {
|
|
640
|
-
if (!config.token
|
|
641
|
-
|
|
642
|
+
if (!config.token) {
|
|
643
|
+
console.log(colors.red("Either accessKey or token must be used"));
|
|
644
|
+
return [2 /*return*/, false];
|
|
645
|
+
}
|
|
646
|
+
if (!config.projectId) {
|
|
647
|
+
console.log(colors.red("projectId cannot be empty"));
|
|
648
|
+
return [2 /*return*/, false];
|
|
642
649
|
}
|
|
643
650
|
}
|
|
644
651
|
if (!((_b = config.branch) !== null && _b !== void 0)) return [3 /*break*/, 1];
|
|
@@ -651,22 +658,27 @@ var RopUploadApi = /** @class */ (function () {
|
|
|
651
658
|
case 3:
|
|
652
659
|
branch = _a;
|
|
653
660
|
if (!branch) {
|
|
654
|
-
|
|
661
|
+
console.log(colors.red("branch cannot be empty"));
|
|
662
|
+
return [2 /*return*/, false];
|
|
655
663
|
}
|
|
656
664
|
else {
|
|
657
665
|
config.branch = branch;
|
|
658
666
|
}
|
|
659
667
|
if (!config.platform) {
|
|
660
|
-
|
|
668
|
+
console.log(colors.red("platform cannot be empty"));
|
|
669
|
+
return [2 /*return*/, false];
|
|
661
670
|
}
|
|
662
671
|
if (!config.arch) {
|
|
663
|
-
|
|
672
|
+
console.log(colors.red("arch cannot be empty"));
|
|
673
|
+
return [2 /*return*/, false];
|
|
664
674
|
}
|
|
665
675
|
if (!config.targetPath) {
|
|
666
|
-
|
|
676
|
+
console.log(colors.red("target path cannot be empty"));
|
|
677
|
+
return [2 /*return*/, false];
|
|
667
678
|
}
|
|
668
679
|
if (!fs.existsSync(config.targetPath)) {
|
|
669
|
-
|
|
680
|
+
console.log(colors.red("target file not found, file path: ".concat(config.targetPath)));
|
|
681
|
+
return [2 /*return*/, false];
|
|
670
682
|
}
|
|
671
683
|
// 如果更新包不存在的情况使用本身的包
|
|
672
684
|
if (config.updatePath && !fs.existsSync(config.updatePath)) {
|
|
@@ -674,7 +686,8 @@ var RopUploadApi = /** @class */ (function () {
|
|
|
674
686
|
config.updateName = config.targetName;
|
|
675
687
|
}
|
|
676
688
|
if (!config.version) {
|
|
677
|
-
|
|
689
|
+
console.log(colors.red("version cannot be empty"));
|
|
690
|
+
return [2 /*return*/, false];
|
|
678
691
|
}
|
|
679
692
|
return [2 /*return*/, config];
|
|
680
693
|
}
|
|
@@ -691,6 +704,9 @@ var RopUploadApi = /** @class */ (function () {
|
|
|
691
704
|
case 0: return [4 /*yield*/, this.checkParams(_config)];
|
|
692
705
|
case 1:
|
|
693
706
|
config = _c.sent();
|
|
707
|
+
if (!config) {
|
|
708
|
+
return [2 /*return*/];
|
|
709
|
+
}
|
|
694
710
|
formData = new FormData();
|
|
695
711
|
fileStream = fs.createReadStream(config.targetPath);
|
|
696
712
|
multibar = new cliProgress.MultiBar({
|
|
@@ -737,7 +753,7 @@ var RopUploadApi = /** @class */ (function () {
|
|
|
737
753
|
formData.append('signature', config.signature);
|
|
738
754
|
}
|
|
739
755
|
if (config.autoRelease) {
|
|
740
|
-
formData.append('autoRelease', config.autoRelease);
|
|
756
|
+
formData.append('autoRelease', String(config.autoRelease));
|
|
741
757
|
}
|
|
742
758
|
return [4 /*yield*/, fetch$1("".concat(this.baseDomain, "/api/upload"), {
|
|
743
759
|
method: 'POST',
|
|
@@ -755,6 +771,7 @@ var RopUploadApi = /** @class */ (function () {
|
|
|
755
771
|
multibar.stop();
|
|
756
772
|
fileStream.destroy();
|
|
757
773
|
updateFileStream === null || updateFileStream === void 0 ? void 0 : updateFileStream.destroy();
|
|
774
|
+
console.log(colors.green("Upload success!"));
|
|
758
775
|
return [2 /*return*/, { success: res.ok, body: body }];
|
|
759
776
|
}
|
|
760
777
|
});
|
|
@@ -863,8 +880,9 @@ var AuthApi = /** @class */ (function () {
|
|
|
863
880
|
AuthApi.prototype.login = function (req) {
|
|
864
881
|
return __awaiter(this, void 0, void 0, function () {
|
|
865
882
|
var res, resBody, homedir, userFilePath;
|
|
866
|
-
|
|
867
|
-
|
|
883
|
+
var _a;
|
|
884
|
+
return __generator(this, function (_b) {
|
|
885
|
+
switch (_b.label) {
|
|
868
886
|
case 0: return [4 /*yield*/, fetch("".concat(this.baseDomain).concat(LOGIN_API), {
|
|
869
887
|
method: 'POST',
|
|
870
888
|
headers: {
|
|
@@ -873,18 +891,13 @@ var AuthApi = /** @class */ (function () {
|
|
|
873
891
|
body: JSON.stringify(req),
|
|
874
892
|
})];
|
|
875
893
|
case 1:
|
|
876
|
-
res =
|
|
894
|
+
res = _b.sent();
|
|
877
895
|
return [4 /*yield*/, res.json()];
|
|
878
896
|
case 2:
|
|
879
|
-
resBody =
|
|
897
|
+
resBody = _b.sent();
|
|
880
898
|
if (!res.ok || !resBody.data) {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
}
|
|
884
|
-
else {
|
|
885
|
-
console.log(JSON.stringify(resBody));
|
|
886
|
-
}
|
|
887
|
-
return [2 /*return*/];
|
|
899
|
+
console.log(chalk.red("Login failed: status:".concat(res.status, ", message:").concat((_a = resBody.message) !== null && _a !== void 0 ? _a : res.statusText)));
|
|
900
|
+
return [2 /*return*/, false];
|
|
888
901
|
}
|
|
889
902
|
homedir = path.join(os.homedir(), '.rop');
|
|
890
903
|
if (!fs.existsSync(homedir)) {
|
|
@@ -892,7 +905,7 @@ var AuthApi = /** @class */ (function () {
|
|
|
892
905
|
}
|
|
893
906
|
userFilePath = path.join(homedir, 'user');
|
|
894
907
|
fs.writeFileSync(userFilePath, JSON.stringify(resBody.data, null, 2), 'utf8');
|
|
895
|
-
return [2 /*return
|
|
908
|
+
return [2 /*return*/, true];
|
|
896
909
|
}
|
|
897
910
|
});
|
|
898
911
|
});
|
|
@@ -906,8 +919,8 @@ var AuthApi = /** @class */ (function () {
|
|
|
906
919
|
homedir = path.join(os.homedir(), '.rop');
|
|
907
920
|
userFilePath = path.join(homedir, 'user');
|
|
908
921
|
if (!fs.existsSync(userFilePath)) {
|
|
909
|
-
console.log(
|
|
910
|
-
return [2 /*return
|
|
922
|
+
console.log(chalk.red("No permission! Please execute [rop login] or use --accessKey"));
|
|
923
|
+
return [2 /*return*/, false];
|
|
911
924
|
}
|
|
912
925
|
user = JSON.parse(fs.readFileSync(userFilePath, 'utf8'));
|
|
913
926
|
return [4 /*yield*/, fetch("".concat(this.baseDomain).concat(REFRESH_TOKEN_API), {
|
|
@@ -924,17 +937,17 @@ var AuthApi = /** @class */ (function () {
|
|
|
924
937
|
resBody = _a.sent();
|
|
925
938
|
if (!res.ok || !resBody.data) {
|
|
926
939
|
if (!resBody.message || res.status != 400) {
|
|
927
|
-
console.log("Refresh token failed: status
|
|
940
|
+
console.log(chalk.red("Refresh token failed: status:".concat(res.status, ", statusText:").concat(res.statusText)));
|
|
928
941
|
}
|
|
929
942
|
else {
|
|
930
|
-
console.log(
|
|
943
|
+
console.log(chalk.red("Authorization expired please execute the login command"));
|
|
931
944
|
fs.rmSync(userFilePath);
|
|
932
945
|
}
|
|
933
|
-
|
|
946
|
+
return [2 /*return*/, false];
|
|
934
947
|
}
|
|
935
948
|
user.auth = resBody.data;
|
|
936
949
|
fs.writeFileSync(userFilePath, JSON.stringify(user), 'utf8');
|
|
937
|
-
return [2 /*return
|
|
950
|
+
return [2 /*return*/, true];
|
|
938
951
|
}
|
|
939
952
|
});
|
|
940
953
|
});
|
|
@@ -990,14 +1003,14 @@ var AuthApi = /** @class */ (function () {
|
|
|
990
1003
|
};
|
|
991
1004
|
AuthApi.prototype.request = function (req) {
|
|
992
1005
|
return __awaiter(this, void 0, void 0, function () {
|
|
993
|
-
var user, res, resBody, _a;
|
|
1006
|
+
var user, res, resBody, _a, result;
|
|
994
1007
|
return __generator(this, function (_b) {
|
|
995
1008
|
switch (_b.label) {
|
|
996
1009
|
case 0: return [4 /*yield*/, this.getToken()];
|
|
997
1010
|
case 1:
|
|
998
1011
|
user = _b.sent();
|
|
999
1012
|
if (!user) {
|
|
1000
|
-
console.log(
|
|
1013
|
+
console.log(colors.red("No permission! Please execute [rop login]"));
|
|
1001
1014
|
return [2 /*return*/, undefined];
|
|
1002
1015
|
}
|
|
1003
1016
|
return [4 /*yield*/, req(user.auth.accessToken)];
|
|
@@ -1006,26 +1019,28 @@ var AuthApi = /** @class */ (function () {
|
|
|
1006
1019
|
return [4 /*yield*/, res.json()];
|
|
1007
1020
|
case 3:
|
|
1008
1021
|
resBody = _b.sent();
|
|
1009
|
-
if (!(!res.ok || !resBody.data)) return [3 /*break*/,
|
|
1022
|
+
if (!(!res.ok || !resBody.data)) return [3 /*break*/, 11];
|
|
1010
1023
|
_a = res.status;
|
|
1011
1024
|
switch (_a) {
|
|
1012
1025
|
case 400: return [3 /*break*/, 4];
|
|
1013
1026
|
case 401: return [3 /*break*/, 5];
|
|
1014
1027
|
}
|
|
1015
|
-
return [3 /*break*/,
|
|
1028
|
+
return [3 /*break*/, 9];
|
|
1016
1029
|
case 4:
|
|
1017
1030
|
console.log(JSON.stringify(resBody));
|
|
1018
|
-
return [3 /*break*/,
|
|
1031
|
+
return [3 /*break*/, 10];
|
|
1019
1032
|
case 5: return [4 /*yield*/, this.refreshToken()];
|
|
1020
1033
|
case 6:
|
|
1021
|
-
_b.sent();
|
|
1034
|
+
result = _b.sent();
|
|
1035
|
+
if (!result) return [3 /*break*/, 8];
|
|
1022
1036
|
return [4 /*yield*/, this.request(req)];
|
|
1023
1037
|
case 7: return [2 /*return*/, _b.sent()];
|
|
1024
|
-
case 8:
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
case 10: return [2 /*return*/,
|
|
1038
|
+
case 8: return [3 /*break*/, 10];
|
|
1039
|
+
case 9:
|
|
1040
|
+
console.log(colors.red("request failed: status:".concat(res.status, ", statusText:").concat(res.statusText)));
|
|
1041
|
+
_b.label = 10;
|
|
1042
|
+
case 10: return [2 /*return*/, undefined];
|
|
1043
|
+
case 11: return [2 /*return*/, resBody.data];
|
|
1029
1044
|
}
|
|
1030
1045
|
});
|
|
1031
1046
|
});
|
|
@@ -1043,7 +1058,8 @@ var init = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
|
1043
1058
|
case 1:
|
|
1044
1059
|
user = _a.sent();
|
|
1045
1060
|
if (!user) {
|
|
1046
|
-
|
|
1061
|
+
console.log(colors.red("No permission! Please execute [rop login]"));
|
|
1062
|
+
return [2 /*return*/];
|
|
1047
1063
|
}
|
|
1048
1064
|
return [4 /*yield*/, confirm({
|
|
1049
1065
|
message: "Link to existing project?",
|
|
@@ -1072,7 +1088,8 @@ var init = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
|
1072
1088
|
case 6:
|
|
1073
1089
|
project = _a.sent();
|
|
1074
1090
|
if (!project) {
|
|
1075
|
-
|
|
1091
|
+
console.log(colors.yellow("project not found"));
|
|
1092
|
+
return [2 /*return*/];
|
|
1076
1093
|
}
|
|
1077
1094
|
projectId = project.id;
|
|
1078
1095
|
framework = project.framework;
|
|
@@ -1129,7 +1146,8 @@ var init = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
|
1129
1146
|
case 12:
|
|
1130
1147
|
project = _a.sent();
|
|
1131
1148
|
if (!project) {
|
|
1132
|
-
|
|
1149
|
+
console.log(colors.red("project create failed"));
|
|
1150
|
+
return [2 /*return*/];
|
|
1133
1151
|
}
|
|
1134
1152
|
projectId = project.id;
|
|
1135
1153
|
framework = project.framework;
|
|
@@ -1146,9 +1164,11 @@ var init = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
|
1146
1164
|
return [4 /*yield*/, init.initGitignore()];
|
|
1147
1165
|
case 16:
|
|
1148
1166
|
_a.sent();
|
|
1149
|
-
console.log(
|
|
1150
|
-
|
|
1151
|
-
|
|
1167
|
+
console.log(colors.green("Initialize project successfully!"));
|
|
1168
|
+
if (framework.toLowerCase() === 'tauri') {
|
|
1169
|
+
console.log(colors.blue("updater endpoints : ".concat(defaultHost, "/api/tauri/").concat(projectId, "/[your branch]/{{target}}/{{arch}}/{{current_version}}")));
|
|
1170
|
+
console.log('Please replace [your branch] with your own branch');
|
|
1171
|
+
}
|
|
1152
1172
|
return [2 /*return*/, {
|
|
1153
1173
|
projectId: projectId,
|
|
1154
1174
|
accessKey: accessKey,
|
|
@@ -1162,7 +1182,7 @@ var init = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
|
1162
1182
|
}); };
|
|
1163
1183
|
|
|
1164
1184
|
var login = function (options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1165
|
-
var username, password$1, loginReq, auth;
|
|
1185
|
+
var username, password$1, loginReq, auth, result;
|
|
1166
1186
|
return __generator(this, function (_a) {
|
|
1167
1187
|
switch (_a.label) {
|
|
1168
1188
|
case 0:
|
|
@@ -1179,7 +1199,7 @@ var login = function (options) { return __awaiter(void 0, void 0, void 0, functi
|
|
|
1179
1199
|
return [3 /*break*/, 5];
|
|
1180
1200
|
case 4:
|
|
1181
1201
|
_a.sent();
|
|
1182
|
-
console.log('cancel');
|
|
1202
|
+
console.log(colors.gray('cancel'));
|
|
1183
1203
|
return [2 /*return*/];
|
|
1184
1204
|
case 5: return [3 /*break*/, 1];
|
|
1185
1205
|
case 6:
|
|
@@ -1193,7 +1213,7 @@ var login = function (options) { return __awaiter(void 0, void 0, void 0, functi
|
|
|
1193
1213
|
return [3 /*break*/, 10];
|
|
1194
1214
|
case 9:
|
|
1195
1215
|
_a.sent();
|
|
1196
|
-
console.log('cancel');
|
|
1216
|
+
console.log(colors.gray('cancel'));
|
|
1197
1217
|
return [2 /*return*/];
|
|
1198
1218
|
case 10: return [3 /*break*/, 6];
|
|
1199
1219
|
case 11:
|
|
@@ -1204,8 +1224,10 @@ var login = function (options) { return __awaiter(void 0, void 0, void 0, functi
|
|
|
1204
1224
|
auth = new AuthApi({ baseDomain: defaultHost });
|
|
1205
1225
|
return [4 /*yield*/, auth.login(loginReq)];
|
|
1206
1226
|
case 12:
|
|
1207
|
-
_a.sent();
|
|
1208
|
-
|
|
1227
|
+
result = _a.sent();
|
|
1228
|
+
if (result) {
|
|
1229
|
+
console.log(colors.green("Login successful. Please use [rop init] to create a project."));
|
|
1230
|
+
}
|
|
1209
1231
|
return [2 /*return*/];
|
|
1210
1232
|
}
|
|
1211
1233
|
});
|
|
@@ -1223,7 +1245,7 @@ var _upload = function (config) { return __awaiter(void 0, void 0, void 0, funct
|
|
|
1223
1245
|
signature = fs$1.readFileSync(artifact.sig.path, 'utf8');
|
|
1224
1246
|
}
|
|
1225
1247
|
else {
|
|
1226
|
-
console.
|
|
1248
|
+
console.log(colors.cyan('Warn sig file not found'));
|
|
1227
1249
|
}
|
|
1228
1250
|
}
|
|
1229
1251
|
uploadClient = new RopUploadApi({ baseDomain: (_b = config.host) !== null && _b !== void 0 ? _b : defaultHost });
|
|
@@ -1239,6 +1261,7 @@ var _upload = function (config) { return __awaiter(void 0, void 0, void 0, funct
|
|
|
1239
1261
|
updatePath: (_d = artifact.update) === null || _d === void 0 ? void 0 : _d.path,
|
|
1240
1262
|
updateName: (_e = artifact.update) === null || _e === void 0 ? void 0 : _e.name,
|
|
1241
1263
|
signature: signature,
|
|
1264
|
+
branch: config.branch,
|
|
1242
1265
|
autoRelease: autoRelease,
|
|
1243
1266
|
})];
|
|
1244
1267
|
case 1:
|
|
@@ -1248,54 +1271,66 @@ var _upload = function (config) { return __awaiter(void 0, void 0, void 0, funct
|
|
|
1248
1271
|
});
|
|
1249
1272
|
}); };
|
|
1250
1273
|
var upload = function (platform, arch, options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1251
|
-
var configFilePath, data, projectId, token, jsonConfig, initConfig, authApi, user, targetInfos, config, reset, _i, targetInfos_1, item;
|
|
1252
|
-
|
|
1253
|
-
|
|
1274
|
+
var configFilePath, res, data, projectId, token, jsonConfig, initConfig, authApi, user, targetInfos, config, reset, _i, targetInfos_1, item;
|
|
1275
|
+
var _a;
|
|
1276
|
+
return __generator(this, function (_b) {
|
|
1277
|
+
switch (_b.label) {
|
|
1254
1278
|
case 0:
|
|
1255
1279
|
configFilePath = path.join('.', 'rop.json');
|
|
1256
1280
|
if (!!fs$1.existsSync(configFilePath)) return [3 /*break*/, 2];
|
|
1257
1281
|
return [4 /*yield*/, init()];
|
|
1258
1282
|
case 1:
|
|
1259
|
-
|
|
1260
|
-
|
|
1283
|
+
res = _b.sent();
|
|
1284
|
+
if (!res) {
|
|
1285
|
+
return [2 /*return*/];
|
|
1286
|
+
}
|
|
1287
|
+
_b.label = 2;
|
|
1261
1288
|
case 2:
|
|
1262
1289
|
data = loadJsonWithEnv({
|
|
1263
1290
|
platform: platform,
|
|
1264
1291
|
arch: arch,
|
|
1265
1292
|
});
|
|
1293
|
+
if (!data) {
|
|
1294
|
+
return [2 /*return*/];
|
|
1295
|
+
}
|
|
1266
1296
|
if (!!options.accessKey) return [3 /*break*/, 7];
|
|
1267
1297
|
jsonConfig = loadConfigJSON();
|
|
1268
1298
|
if (!!jsonConfig.projectId) return [3 /*break*/, 4];
|
|
1269
1299
|
return [4 /*yield*/, init()];
|
|
1270
1300
|
case 3:
|
|
1271
|
-
initConfig =
|
|
1272
|
-
|
|
1301
|
+
initConfig = _b.sent();
|
|
1302
|
+
if (initConfig) {
|
|
1303
|
+
projectId = initConfig.projectId;
|
|
1304
|
+
}
|
|
1305
|
+
else {
|
|
1306
|
+
return [2 /*return*/];
|
|
1307
|
+
}
|
|
1273
1308
|
return [3 /*break*/, 5];
|
|
1274
1309
|
case 4:
|
|
1275
1310
|
projectId = jsonConfig.projectId;
|
|
1276
|
-
|
|
1311
|
+
_b.label = 5;
|
|
1277
1312
|
case 5:
|
|
1278
1313
|
authApi = new AuthApi({ baseDomain: defaultHost });
|
|
1279
1314
|
return [4 /*yield*/, authApi.checkAndRefreshToken()];
|
|
1280
1315
|
case 6:
|
|
1281
|
-
user =
|
|
1316
|
+
user = _b.sent();
|
|
1282
1317
|
if (!user) {
|
|
1283
|
-
console.log(
|
|
1318
|
+
console.log(colors.red("No permission! Please execute [rop login]"));
|
|
1284
1319
|
return [2 /*return*/];
|
|
1285
1320
|
}
|
|
1286
1321
|
token = user.auth.accessToken;
|
|
1287
|
-
|
|
1322
|
+
_b.label = 7;
|
|
1288
1323
|
case 7:
|
|
1289
1324
|
targetInfos = data.targetInfos, config = data.config, reset = __rest(data, ["targetInfos", "config"]);
|
|
1290
1325
|
_i = 0, targetInfos_1 = targetInfos;
|
|
1291
|
-
|
|
1326
|
+
_b.label = 8;
|
|
1292
1327
|
case 8:
|
|
1293
1328
|
if (!(_i < targetInfos_1.length)) return [3 /*break*/, 11];
|
|
1294
1329
|
item = targetInfos_1[_i];
|
|
1295
|
-
return [4 /*yield*/, _upload(__assign(__assign({ accessKey: options.accessKey, projectId: projectId, token: token }, reset), { artifact: item.artifacts, host: config.host, platform: platform, autoRelease: options.release }))];
|
|
1330
|
+
return [4 /*yield*/, _upload(__assign(__assign({ accessKey: options.accessKey, projectId: projectId, token: token }, reset), { artifact: item.artifacts, host: config.host, platform: platform, branch: options.branch, autoRelease: (_a = options.release) !== null && _a !== void 0 ? _a : false }))];
|
|
1296
1331
|
case 9:
|
|
1297
|
-
|
|
1298
|
-
|
|
1332
|
+
_b.sent();
|
|
1333
|
+
_b.label = 10;
|
|
1299
1334
|
case 10:
|
|
1300
1335
|
_i++;
|
|
1301
1336
|
return [3 /*break*/, 8];
|
|
@@ -1332,6 +1367,7 @@ program
|
|
|
1332
1367
|
.argument('[string]', 'arch')
|
|
1333
1368
|
.option('-a, --accessKey <string>', 'accessKey path')
|
|
1334
1369
|
.option('-r, --release [boolean]', 'auto release')
|
|
1370
|
+
.option('-b, --branch <string>', 'branch')
|
|
1335
1371
|
.action(upload);
|
|
1336
1372
|
// 解析命令行参数
|
|
1337
1373
|
program.parse();
|