@ones-open/cli 1.0.1-4995.1947 → 1.0.1-6440.1942
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/index.cjs +210 -352
- package/dist/index.js +211 -353
- package/dist/types/actions/build/index.d.ts.map +1 -1
- package/dist/types/actions/dev/index.d.ts.map +1 -1
- package/dist/types/actions/disable/index.d.ts.map +1 -1
- package/dist/types/actions/enable/index.d.ts.map +1 -1
- package/dist/types/actions/install/index.d.ts +1 -0
- package/dist/types/actions/install/index.d.ts.map +1 -1
- package/dist/types/actions/install/install.d.ts +3 -0
- package/dist/types/actions/install/install.d.ts.map +1 -0
- package/dist/types/actions/tunnel/consts.d.ts +0 -3
- package/dist/types/actions/tunnel/consts.d.ts.map +1 -1
- package/dist/types/actions/tunnel/index.d.ts +1 -3
- package/dist/types/actions/tunnel/index.d.ts.map +1 -1
- package/dist/types/actions/tunnel/tunnel-client.d.ts.map +1 -1
- package/dist/types/actions/tunnel/tunnel.d.ts +7 -1
- package/dist/types/actions/tunnel/tunnel.d.ts.map +1 -1
- package/dist/types/actions/uninstall/index.d.ts.map +1 -1
- package/dist/types/actions/whoami/index.d.ts.map +1 -1
- package/dist/types/common/package/utils.d.ts +0 -2
- package/dist/types/common/package/utils.d.ts.map +1 -1
- package/dist/types/common/request/fetch.d.ts.map +1 -1
- package/dist/types/common/request/utils.d.ts +2 -3
- package/dist/types/common/request/utils.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/types/actions/tunnel/types.d.ts +0 -33
- package/dist/types/actions/tunnel/types.d.ts.map +0 -1
- package/dist/types/actions/tunnel/utils.d.ts +0 -7
- package/dist/types/actions/tunnel/utils.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -6,12 +6,12 @@ const createOnesApp = require("create-ones-app");
|
|
|
6
6
|
const node_path = require("node:path");
|
|
7
7
|
const node_child_process = require("node:child_process");
|
|
8
8
|
const node_fs = require("node:fs");
|
|
9
|
-
const fse = require("fs-extra");
|
|
10
9
|
const archiver = require("archiver");
|
|
11
10
|
const lodashEs = require("lodash-es");
|
|
12
11
|
const process$1 = require("node:process");
|
|
13
12
|
const node_url = require("node:url");
|
|
14
13
|
const cosmiconfig = require("cosmiconfig");
|
|
14
|
+
const fse = require("fs-extra");
|
|
15
15
|
const envPaths = require("env-paths");
|
|
16
16
|
const zod = require("zod");
|
|
17
17
|
const axios = require("axios");
|
|
@@ -152,10 +152,9 @@ const getAppManifestJSON = () => {
|
|
|
152
152
|
return createOnesApp.throwError(ErrorCode.APP_MANIFEST_JSON_PARSE_ERROR, `${i18n.t("error.schema.app.manifest.parseError")}: ${details}`);
|
|
153
153
|
}
|
|
154
154
|
};
|
|
155
|
-
const defaultAppRcJSONDevCommand = "npm run dev";
|
|
156
155
|
const defaultAppRcJSON = {
|
|
157
156
|
dev: {
|
|
158
|
-
command: [
|
|
157
|
+
command: ["npm run dev"]
|
|
159
158
|
}
|
|
160
159
|
};
|
|
161
160
|
let storeAppRcJSON = null;
|
|
@@ -206,11 +205,8 @@ const normalize$a = async (options) => {
|
|
|
206
205
|
output
|
|
207
206
|
};
|
|
208
207
|
};
|
|
209
|
-
const {
|
|
210
|
-
existsSync
|
|
211
|
-
} = fse;
|
|
212
208
|
const build = async function() {
|
|
213
|
-
var _appRcJSON$build$comp, _appRcJSON$build;
|
|
209
|
+
var _appPackageJSON$scrip, _appRcJSON$build$comp, _appRcJSON$build;
|
|
214
210
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
215
211
|
args[_key] = arguments[_key];
|
|
216
212
|
}
|
|
@@ -218,35 +214,22 @@ const build = async function() {
|
|
|
218
214
|
options
|
|
219
215
|
} = createOnesApp.getCommandOptions(args, buildCommandArguments);
|
|
220
216
|
const normalizedOptions = await normalize$a(options);
|
|
217
|
+
const appPackageJSON = getAppPackageJSON();
|
|
221
218
|
const appManifestJSON = getAppManifestJSON();
|
|
222
219
|
const appRcJSON = await getAppRcJSON();
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
stdio: "inherit",
|
|
232
|
-
env: {
|
|
233
|
-
...process.env,
|
|
234
|
-
NODE_ENV: "production"
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
if (buildResult.status !== 0 || buildResult.signal) {
|
|
238
|
-
var _buildResult$status;
|
|
239
|
-
process.exit((_buildResult$status = buildResult.status) !== null && _buildResult$status !== void 0 ? _buildResult$status : 1);
|
|
220
|
+
appManifestJSON.app.name;
|
|
221
|
+
if ((_appPackageJSON$scrip = appPackageJSON.scripts) !== null && _appPackageJSON$scrip !== void 0 && _appPackageJSON$scrip.build) {
|
|
222
|
+
node_child_process.spawnSync("npm", ["run", "build"], {
|
|
223
|
+
cwd: getAppWorkspacePath(),
|
|
224
|
+
stdio: "inherit",
|
|
225
|
+
env: {
|
|
226
|
+
...process.env,
|
|
227
|
+
NODE_ENV: "production"
|
|
240
228
|
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
229
|
+
});
|
|
230
|
+
} else {
|
|
231
|
+
return createOnesApp.throwError(ErrorCode.BUILD_SCRIPT_NOT_FOUND, i18n.t("error.build.scriptNotFound"));
|
|
244
232
|
}
|
|
245
|
-
const appName = appManifestJSON.app.name;
|
|
246
|
-
const outputPath = normalizedOptions.output;
|
|
247
|
-
const outputFilename = node_path.basename(outputPath);
|
|
248
|
-
const outputStream = node_fs.createWriteStream(normalizedOptions.output);
|
|
249
|
-
const files = (_appRcJSON$build$comp = (_appRcJSON$build = appRcJSON.build) === null || _appRcJSON$build === void 0 || (_appRcJSON$build = _appRcJSON$build.compress) === null || _appRcJSON$build === void 0 ? void 0 : _appRcJSON$build.files) !== null && _appRcJSON$build$comp !== void 0 ? _appRcJSON$build$comp : [];
|
|
250
233
|
const archive = archiver("zip", {
|
|
251
234
|
zlib: {
|
|
252
235
|
level: 9
|
|
@@ -269,13 +252,12 @@ const build = async function() {
|
|
|
269
252
|
});
|
|
270
253
|
archive.on("finish", () => {
|
|
271
254
|
process.stdout.write("\n");
|
|
272
|
-
console.log(
|
|
273
|
-
console.log(
|
|
274
|
-
console.log(`App "${appName}" built successfully!`);
|
|
275
|
-
console.log(`OPKX "${outputFilename}" created successfully!`);
|
|
276
|
-
console.log(`Output file: ${outputPath}`);
|
|
255
|
+
console.log(`Output file: ${normalizedOptions.output}`);
|
|
256
|
+
console.log(`OPKX "${node_path.basename(normalizedOptions.output)}" created successfully!`);
|
|
277
257
|
});
|
|
258
|
+
const outputStream = node_fs.createWriteStream(normalizedOptions.output);
|
|
278
259
|
archive.pipe(outputStream);
|
|
260
|
+
const files = (_appRcJSON$build$comp = (_appRcJSON$build = appRcJSON.build) === null || _appRcJSON$build === void 0 || (_appRcJSON$build = _appRcJSON$build.compress) === null || _appRcJSON$build === void 0 ? void 0 : _appRcJSON$build.files) !== null && _appRcJSON$build$comp !== void 0 ? _appRcJSON$build$comp : [];
|
|
279
261
|
files.forEach((file) => {
|
|
280
262
|
archive.glob(file, {
|
|
281
263
|
cwd: getAppWorkspacePath()
|
|
@@ -399,39 +381,6 @@ const getHostToken = async () => {
|
|
|
399
381
|
const store = await getStore();
|
|
400
382
|
return (_store$host_token = store.host_token) !== null && _store$host_token !== void 0 ? _store$host_token : "";
|
|
401
383
|
};
|
|
402
|
-
const setHostToken = async (token) => {
|
|
403
|
-
return mergeStore({
|
|
404
|
-
host_token: token
|
|
405
|
-
});
|
|
406
|
-
};
|
|
407
|
-
const isPortNumber = /^[1-9]\d{0,4}$/;
|
|
408
|
-
const minPortNumber = 1;
|
|
409
|
-
const maxPortNumber = 65535;
|
|
410
|
-
const MANIFEST_PATH = "/manifest";
|
|
411
|
-
const ONES_CLI_INTERNAL_MANIFEST_PATH = "/__ones_cli_internal_manifest__";
|
|
412
|
-
const MAX_RELAY_BODY_BYTES = 64 * 1024 * 1024;
|
|
413
|
-
const normalize$9 = async (options) => {
|
|
414
|
-
const portInput = options.port;
|
|
415
|
-
if (portInput)
|
|
416
|
-
;
|
|
417
|
-
else {
|
|
418
|
-
return createOnesApp.throwError(ErrorCode.MISSING_PORT, i18n.t("error.tunnel.missingPort"));
|
|
419
|
-
}
|
|
420
|
-
const portString = String(portInput);
|
|
421
|
-
const portNumber = Number(portString);
|
|
422
|
-
if (isPortNumber.test(portString))
|
|
423
|
-
;
|
|
424
|
-
else {
|
|
425
|
-
return createOnesApp.throwError(ErrorCode.INCORRECT_PORT, i18n.t("error.tunnel.incorrectPort"));
|
|
426
|
-
}
|
|
427
|
-
if (portNumber < minPortNumber || portNumber > maxPortNumber) {
|
|
428
|
-
return createOnesApp.throwError(ErrorCode.INCORRECT_PORT, i18n.t("error.tunnel.incorrectPort"));
|
|
429
|
-
}
|
|
430
|
-
const port = portString;
|
|
431
|
-
return {
|
|
432
|
-
port
|
|
433
|
-
};
|
|
434
|
-
};
|
|
435
384
|
const API = {
|
|
436
385
|
TOKEN_INFO: "/project/api/project/auth/token_info",
|
|
437
386
|
HOSTED_TOKEN: "/platform/runtime_manager/hosted_token",
|
|
@@ -454,11 +403,6 @@ const getPath = (path, map2) => {
|
|
|
454
403
|
const consoleUnauthorizedMessage = () => {
|
|
455
404
|
console.log("Not logged in");
|
|
456
405
|
console.log('Login with "ones login" command');
|
|
457
|
-
process.exit(1);
|
|
458
|
-
};
|
|
459
|
-
const consoleAppNotInstalledMessage = () => {
|
|
460
|
-
console.log("App not installed");
|
|
461
|
-
process.exit(1);
|
|
462
406
|
};
|
|
463
407
|
const getURL = async (path, pathMap, queryMap) => {
|
|
464
408
|
const base = await getRegionURL();
|
|
@@ -467,6 +411,7 @@ const getURL = async (path, pathMap, queryMap) => {
|
|
|
467
411
|
return `${base}${getPath(path, pathMap !== null && pathMap !== void 0 ? pathMap : {})}${query ? `?${query}` : ""}`;
|
|
468
412
|
}
|
|
469
413
|
consoleUnauthorizedMessage();
|
|
414
|
+
process$1.exit(1);
|
|
470
415
|
};
|
|
471
416
|
const getHeaders = async (value) => {
|
|
472
417
|
const token = await getONESToken();
|
|
@@ -476,24 +421,16 @@ const getHeaders = async (value) => {
|
|
|
476
421
|
}, value);
|
|
477
422
|
}
|
|
478
423
|
consoleUnauthorizedMessage();
|
|
479
|
-
process.exit(1);
|
|
424
|
+
process$1.exit(1);
|
|
480
425
|
};
|
|
481
426
|
const handleError = (error) => {
|
|
482
|
-
var _error$response
|
|
427
|
+
var _error$response;
|
|
483
428
|
if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 401) {
|
|
484
429
|
console.log(error.response.statusText);
|
|
485
430
|
consoleUnauthorizedMessage();
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
if ((_error$response2 = error.response) !== null && _error$response2 !== void 0 && _error$response2.data) {
|
|
489
|
-
try {
|
|
490
|
-
const message = JSON.stringify(error.response.data, null, 2);
|
|
491
|
-
console.error(message);
|
|
492
|
-
process.exit(1);
|
|
493
|
-
} catch (error2) {
|
|
494
|
-
}
|
|
431
|
+
} else {
|
|
432
|
+
console.error(error);
|
|
495
433
|
}
|
|
496
|
-
console.error(error);
|
|
497
434
|
return {};
|
|
498
435
|
};
|
|
499
436
|
const fetchAppBase = async (params) => {
|
|
@@ -546,97 +483,66 @@ const fetchAppUninstall = async () => {
|
|
|
546
483
|
const appID = getAppManifestJSON().app.id;
|
|
547
484
|
const appList = await fetchAppList(appID);
|
|
548
485
|
const installationID = (_appList$data$0$insta2 = (_appList$data2 = appList.data) === null || _appList$data2 === void 0 || (_appList$data2 = _appList$data2[0]) === null || _appList$data2 === void 0 ? void 0 : _appList$data2.installation_id) !== null && _appList$data$0$insta2 !== void 0 ? _appList$data$0$insta2 : "";
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
}).catch(handleError);
|
|
557
|
-
}
|
|
558
|
-
consoleAppNotInstalledMessage();
|
|
559
|
-
process.exit(1);
|
|
486
|
+
return await fetchAppBase({
|
|
487
|
+
url: API.APP_UNINSTALL,
|
|
488
|
+
method: "POST",
|
|
489
|
+
pathMap: {
|
|
490
|
+
installation_id: installationID
|
|
491
|
+
}
|
|
492
|
+
}).catch(handleError);
|
|
560
493
|
};
|
|
561
494
|
const fetchAppEnable = async () => {
|
|
562
495
|
var _appList$data$0$insta3, _appList$data3;
|
|
563
496
|
const appID = getAppManifestJSON().app.id;
|
|
564
497
|
const appList = await fetchAppList(appID);
|
|
565
498
|
const installationID = (_appList$data$0$insta3 = (_appList$data3 = appList.data) === null || _appList$data3 === void 0 || (_appList$data3 = _appList$data3[0]) === null || _appList$data3 === void 0 ? void 0 : _appList$data3.installation_id) !== null && _appList$data$0$insta3 !== void 0 ? _appList$data$0$insta3 : "";
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
}).catch(handleError);
|
|
574
|
-
}
|
|
575
|
-
consoleAppNotInstalledMessage();
|
|
576
|
-
process.exit(1);
|
|
499
|
+
return await fetchAppBase({
|
|
500
|
+
url: API.APP_ENABLE,
|
|
501
|
+
method: "POST",
|
|
502
|
+
pathMap: {
|
|
503
|
+
installation_id: installationID
|
|
504
|
+
}
|
|
505
|
+
}).catch(handleError);
|
|
577
506
|
};
|
|
578
507
|
const fetchAppDisable = async () => {
|
|
579
508
|
var _appList$data$0$insta4, _appList$data4;
|
|
580
509
|
const appID = getAppManifestJSON().app.id;
|
|
581
510
|
const appList = await fetchAppList(appID);
|
|
582
511
|
const installationID = (_appList$data$0$insta4 = (_appList$data4 = appList.data) === null || _appList$data4 === void 0 || (_appList$data4 = _appList$data4[0]) === null || _appList$data4 === void 0 ? void 0 : _appList$data4.installation_id) !== null && _appList$data$0$insta4 !== void 0 ? _appList$data$0$insta4 : "";
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}).catch(handleError);
|
|
591
|
-
}
|
|
592
|
-
consoleAppNotInstalledMessage();
|
|
593
|
-
process.exit(1);
|
|
594
|
-
};
|
|
595
|
-
const getTunnelContext = async () => {
|
|
596
|
-
var _appManifestJSON$app$, _appManifestJSON$app, _store$region_url, _store$ones_token;
|
|
597
|
-
const appManifestJSON = getAppManifestJSON();
|
|
598
|
-
const appID = (_appManifestJSON$app$ = (_appManifestJSON$app = appManifestJSON.app) === null || _appManifestJSON$app === void 0 ? void 0 : _appManifestJSON$app.id) !== null && _appManifestJSON$app$ !== void 0 ? _appManifestJSON$app$ : "";
|
|
599
|
-
const store = await getStore();
|
|
600
|
-
const regionURL = (_store$region_url = store.region_url) !== null && _store$region_url !== void 0 ? _store$region_url : "";
|
|
601
|
-
const onesToken = (_store$ones_token = store.ones_token) !== null && _store$ones_token !== void 0 ? _store$ones_token : "";
|
|
602
|
-
if (appID && regionURL && onesToken) {
|
|
603
|
-
return {
|
|
604
|
-
appID,
|
|
605
|
-
regionURL,
|
|
606
|
-
onesToken,
|
|
607
|
-
store,
|
|
608
|
-
appManifestJSON
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
consoleUnauthorizedMessage();
|
|
612
|
-
process.exit(1);
|
|
512
|
+
return await fetchAppBase({
|
|
513
|
+
url: API.APP_DISABLE,
|
|
514
|
+
method: "POST",
|
|
515
|
+
pathMap: {
|
|
516
|
+
installation_id: installationID
|
|
517
|
+
}
|
|
518
|
+
}).catch(handleError);
|
|
613
519
|
};
|
|
614
|
-
const
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
520
|
+
const isPortNumber = /^[1-9]\d{0,4}$/;
|
|
521
|
+
const minPortNumber = 1;
|
|
522
|
+
const maxPortNumber = 65535;
|
|
523
|
+
const normalize$9 = async (options) => {
|
|
524
|
+
const portInput = options.port;
|
|
525
|
+
if (portInput)
|
|
526
|
+
;
|
|
527
|
+
else {
|
|
528
|
+
return createOnesApp.throwError(ErrorCode.MISSING_PORT, i18n.t("error.tunnel.missingPort"));
|
|
618
529
|
}
|
|
619
|
-
const
|
|
620
|
-
|
|
621
|
-
|
|
530
|
+
const portString = String(portInput);
|
|
531
|
+
const portNumber = Number(portString);
|
|
532
|
+
if (isPortNumber.test(portString))
|
|
533
|
+
;
|
|
534
|
+
else {
|
|
535
|
+
return createOnesApp.throwError(ErrorCode.INCORRECT_PORT, i18n.t("error.tunnel.incorrectPort"));
|
|
622
536
|
}
|
|
623
|
-
if (
|
|
624
|
-
|
|
537
|
+
if (portNumber < minPortNumber || portNumber > maxPortNumber) {
|
|
538
|
+
return createOnesApp.throwError(ErrorCode.INCORRECT_PORT, i18n.t("error.tunnel.incorrectPort"));
|
|
625
539
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
};
|
|
631
|
-
const buildTunnelUrl = async () => {
|
|
632
|
-
const {
|
|
633
|
-
appID,
|
|
634
|
-
regionURL
|
|
635
|
-
} = await getTunnelContext();
|
|
636
|
-
const url = new URL(regionURL);
|
|
637
|
-
url.pathname = `/platform/app/relay/dispatch/${appID}`;
|
|
638
|
-
return url.toString();
|
|
540
|
+
const port = portString;
|
|
541
|
+
return {
|
|
542
|
+
port
|
|
543
|
+
};
|
|
639
544
|
};
|
|
545
|
+
const MAX_RELAY_BODY_BYTES = 64 * 1024 * 1024;
|
|
640
546
|
class TunnelClient {
|
|
641
547
|
constructor(localPort, baseUrl, appID, hostedToken) {
|
|
642
548
|
let enableInternalManifestRoute = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : true;
|
|
@@ -889,16 +795,64 @@ class TunnelClient {
|
|
|
889
795
|
return null;
|
|
890
796
|
}
|
|
891
797
|
}
|
|
798
|
+
const ONES_CLI_INTERNAL_MANIFEST_PATH = "/__ones_cli_internal_manifest__";
|
|
799
|
+
const buildTunnelContext = async () => {
|
|
800
|
+
var _appManifestJSON$app$, _appManifestJSON$app;
|
|
801
|
+
const appManifestJSON = getAppManifestJSON();
|
|
802
|
+
const appID = (_appManifestJSON$app$ = (_appManifestJSON$app = appManifestJSON.app) === null || _appManifestJSON$app === void 0 ? void 0 : _appManifestJSON$app.id) !== null && _appManifestJSON$app$ !== void 0 ? _appManifestJSON$app$ : "";
|
|
803
|
+
if (!appID) {
|
|
804
|
+
throw new Error("app id is empty");
|
|
805
|
+
}
|
|
806
|
+
const regionURL = await getRegionURL();
|
|
807
|
+
if (!regionURL) {
|
|
808
|
+
throw new Error("region url is empty");
|
|
809
|
+
}
|
|
810
|
+
return {
|
|
811
|
+
appManifestJSON,
|
|
812
|
+
appID,
|
|
813
|
+
regionURL
|
|
814
|
+
};
|
|
815
|
+
};
|
|
816
|
+
const getHostedTokenScopes = (ones2) => {
|
|
817
|
+
const storage = ones2 === null || ones2 === void 0 ? void 0 : ones2.storage;
|
|
818
|
+
if (!storage) {
|
|
819
|
+
return [];
|
|
820
|
+
}
|
|
821
|
+
const scopes = /* @__PURE__ */ new Set();
|
|
822
|
+
if (Array.isArray(storage.entities) && storage.entities.length > 0) {
|
|
823
|
+
scopes.add(createOnesApp.HostedTokenScope.STORAGE_ENTITY);
|
|
824
|
+
}
|
|
825
|
+
if (storage.object !== void 0 && storage.object !== null && storage.object !== false) {
|
|
826
|
+
scopes.add(createOnesApp.HostedTokenScope.STORAGE_OBJECT);
|
|
827
|
+
}
|
|
828
|
+
return Array.from(scopes);
|
|
829
|
+
};
|
|
830
|
+
const getRelayScope = () => {
|
|
831
|
+
return createOnesApp.HostedTokenScope.RELAY;
|
|
832
|
+
};
|
|
833
|
+
const buildTunnelUrl = async () => {
|
|
834
|
+
const {
|
|
835
|
+
appID,
|
|
836
|
+
regionURL
|
|
837
|
+
} = await buildTunnelContext();
|
|
838
|
+
const url = new URL(regionURL);
|
|
839
|
+
return `${url.protocol}//${url.host}/platform/app/relay/dispatch/${appID}`;
|
|
840
|
+
};
|
|
892
841
|
const invokeTunnel = async function(port) {
|
|
893
|
-
var _options$rebuildWhenE, _options$enableIntern
|
|
842
|
+
var _options$rebuildWhenE, _hostedTokenResponse$, _options$enableIntern;
|
|
894
843
|
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
895
844
|
const {
|
|
896
845
|
appManifestJSON,
|
|
897
846
|
appID,
|
|
898
847
|
regionURL
|
|
899
|
-
} = await
|
|
848
|
+
} = await buildTunnelContext();
|
|
849
|
+
const runnelUrl = await buildTunnelUrl();
|
|
900
850
|
const rebuildWhenExists = (_options$rebuildWhenE = options.rebuildWhenExists) !== null && _options$rebuildWhenE !== void 0 ? _options$rebuildWhenE : true;
|
|
901
|
-
const
|
|
851
|
+
const onesToken = await getONESToken();
|
|
852
|
+
if (!onesToken) {
|
|
853
|
+
consoleUnauthorizedMessage();
|
|
854
|
+
process$1.exit(1);
|
|
855
|
+
}
|
|
902
856
|
const storageScopes = getHostedTokenScopes(appManifestJSON.ones);
|
|
903
857
|
const scopes = Array.from(/* @__PURE__ */ new Set([...storageScopes, getRelayScope()]));
|
|
904
858
|
const hostedTokenResponse = await fetchHostedToken({
|
|
@@ -909,9 +863,10 @@ const invokeTunnel = async function(port) {
|
|
|
909
863
|
if (!hostedToken) {
|
|
910
864
|
return createOnesApp.throwError(ErrorCode.HOSTED_TOKEN_EMPTY, i18n.t("error.hostedToken.empty"));
|
|
911
865
|
}
|
|
912
|
-
|
|
913
|
-
const client = new TunnelClient(port, regionURL, appID, hostedToken, enableInternalManifestRoute, rebuildWhenExists);
|
|
866
|
+
process.env.ONES_HOSTED_TOKEN = hostedToken;
|
|
867
|
+
const client = new TunnelClient(port, regionURL, appID, hostedToken, (_options$enableIntern = options.enableInternalManifestRoute) !== null && _options$enableIntern !== void 0 ? _options$enableIntern : true, rebuildWhenExists);
|
|
914
868
|
await client.connect();
|
|
869
|
+
console.log(`Relay endpoint: ${runnelUrl}`);
|
|
915
870
|
};
|
|
916
871
|
const tunnel = async function() {
|
|
917
872
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -921,12 +876,55 @@ const tunnel = async function() {
|
|
|
921
876
|
options
|
|
922
877
|
} = createOnesApp.getCommandOptions(args, tunnelCommandArguments);
|
|
923
878
|
const normalizedOptions = await normalize$9(options);
|
|
924
|
-
await invokeTunnel(Number(normalizedOptions.port)
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
879
|
+
await invokeTunnel(Number(normalizedOptions.port));
|
|
880
|
+
};
|
|
881
|
+
const normalize$8 = async (options) => {
|
|
882
|
+
lodashEs.noop(options);
|
|
883
|
+
return {};
|
|
884
|
+
};
|
|
885
|
+
const invokeInstall = async () => {
|
|
928
886
|
const runnelUrl = await buildTunnelUrl();
|
|
929
|
-
|
|
887
|
+
const result = await fetchAppInstall({
|
|
888
|
+
manifest_url: `${runnelUrl}${ONES_CLI_INTERNAL_MANIFEST_PATH}`
|
|
889
|
+
});
|
|
890
|
+
return result;
|
|
891
|
+
};
|
|
892
|
+
const install = async function() {
|
|
893
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
894
|
+
args[_key] = arguments[_key];
|
|
895
|
+
}
|
|
896
|
+
const {
|
|
897
|
+
options
|
|
898
|
+
} = createOnesApp.getCommandOptions(args, installCommandArguments);
|
|
899
|
+
const normalizedOptions = await normalize$8(options);
|
|
900
|
+
lodashEs.noop(normalizedOptions);
|
|
901
|
+
await invokeTunnel(getConfig().defaultPort.tunnel);
|
|
902
|
+
const result = await invokeInstall();
|
|
903
|
+
if (result.code === "OK") {
|
|
904
|
+
var _appList$data$0$insta, _appList$data;
|
|
905
|
+
console.log("App installed successfully!");
|
|
906
|
+
const appID = getAppManifestJSON().app.id;
|
|
907
|
+
const appList = await fetchAppList(appID);
|
|
908
|
+
const installationID = (_appList$data$0$insta = (_appList$data = appList.data) === null || _appList$data === void 0 || (_appList$data = _appList$data[0]) === null || _appList$data === void 0 ? void 0 : _appList$data.installation_id) !== null && _appList$data$0$insta !== void 0 ? _appList$data$0$insta : "";
|
|
909
|
+
if (installationID) {
|
|
910
|
+
var _tokenInfo$org$uuid, _tokenInfo$org, _tokenInfo$teams$0$uu, _tokenInfo$teams, _tokenInfo$org$visibi, _tokenInfo$org2;
|
|
911
|
+
const tokenInfo = await fetchTokenInfo();
|
|
912
|
+
const orgUUID = (_tokenInfo$org$uuid = (_tokenInfo$org = tokenInfo.org) === null || _tokenInfo$org === void 0 ? void 0 : _tokenInfo$org.uuid) !== null && _tokenInfo$org$uuid !== void 0 ? _tokenInfo$org$uuid : "";
|
|
913
|
+
const teamUUID = (_tokenInfo$teams$0$uu = (_tokenInfo$teams = tokenInfo.teams) === null || _tokenInfo$teams === void 0 || (_tokenInfo$teams = _tokenInfo$teams[0]) === null || _tokenInfo$teams === void 0 ? void 0 : _tokenInfo$teams.uuid) !== null && _tokenInfo$teams$0$uu !== void 0 ? _tokenInfo$teams$0$uu : "";
|
|
914
|
+
const isOrgVisible = (_tokenInfo$org$visibi = (_tokenInfo$org2 = tokenInfo.org) === null || _tokenInfo$org2 === void 0 ? void 0 : _tokenInfo$org2.visibility) !== null && _tokenInfo$org$visibi !== void 0 ? _tokenInfo$org$visibi : false;
|
|
915
|
+
const baseURL = await getBaseURL();
|
|
916
|
+
if (isOrgVisible && orgUUID) {
|
|
917
|
+
const url = `${baseURL}/project/#/org/${orgUUID}/setting/app_manager/platform_app/${installationID}`;
|
|
918
|
+
console.log(`See App detail: ${url}`);
|
|
919
|
+
}
|
|
920
|
+
if (!isOrgVisible && teamUUID) {
|
|
921
|
+
const url = `${baseURL}/project/#/team/${teamUUID}/team_setting/app_manager/platform_app/${installationID}`;
|
|
922
|
+
console.log(`See App detail: ${url}`);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
} else {
|
|
926
|
+
console.error(result);
|
|
927
|
+
}
|
|
930
928
|
};
|
|
931
929
|
var InstallOptions = /* @__PURE__ */ ((InstallOptions2) => {
|
|
932
930
|
InstallOptions2["AUTO"] = "auto";
|
|
@@ -935,7 +933,7 @@ var InstallOptions = /* @__PURE__ */ ((InstallOptions2) => {
|
|
|
935
933
|
return InstallOptions2;
|
|
936
934
|
})(InstallOptions || {});
|
|
937
935
|
const defaultInstall = InstallOptions.AUTO;
|
|
938
|
-
const normalize$
|
|
936
|
+
const normalize$7 = async (options) => {
|
|
939
937
|
var _options$install;
|
|
940
938
|
let install2 = (_options$install = options.install) !== null && _options$install !== void 0 ? _options$install : defaultInstall;
|
|
941
939
|
switch (true) {
|
|
@@ -952,67 +950,25 @@ const normalize$8 = async (options) => {
|
|
|
952
950
|
install: install2
|
|
953
951
|
};
|
|
954
952
|
};
|
|
955
|
-
const IDLE_MS = 100;
|
|
956
|
-
function createReadyStatusPipes(onReady) {
|
|
957
|
-
let readyTimer = null;
|
|
958
|
-
let summaryPrinted = false;
|
|
959
|
-
const scheduleReady = () => {
|
|
960
|
-
if (summaryPrinted)
|
|
961
|
-
return;
|
|
962
|
-
if (readyTimer)
|
|
963
|
-
clearTimeout(readyTimer);
|
|
964
|
-
readyTimer = setTimeout(() => {
|
|
965
|
-
readyTimer = null;
|
|
966
|
-
if (!summaryPrinted) {
|
|
967
|
-
summaryPrinted = true;
|
|
968
|
-
onReady();
|
|
969
|
-
}
|
|
970
|
-
}, IDLE_MS);
|
|
971
|
-
};
|
|
972
|
-
const pipe = (stream, isStderr) => {
|
|
973
|
-
const write = (chunk) => {
|
|
974
|
-
if (isStderr)
|
|
975
|
-
process.stderr.write(chunk);
|
|
976
|
-
else
|
|
977
|
-
process.stdout.write(chunk);
|
|
978
|
-
};
|
|
979
|
-
stream.on("data", (chunk) => {
|
|
980
|
-
const str = typeof chunk === "string" ? chunk : chunk.toString();
|
|
981
|
-
write(str);
|
|
982
|
-
scheduleReady();
|
|
983
|
-
});
|
|
984
|
-
};
|
|
985
|
-
return pipe;
|
|
986
|
-
}
|
|
987
953
|
const dev = async function() {
|
|
988
|
-
var
|
|
954
|
+
var _appPackageJSON$scrip;
|
|
989
955
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
990
956
|
args[_key] = arguments[_key];
|
|
991
957
|
}
|
|
992
958
|
const {
|
|
993
959
|
options
|
|
994
960
|
} = createOnesApp.getCommandOptions(args, devCommandArguments);
|
|
995
|
-
const normalizedOptions = await normalize$
|
|
996
|
-
const appRcJSON = await getAppRcJSON();
|
|
961
|
+
const normalizedOptions = await normalize$7(options);
|
|
997
962
|
const appPackageJSON = getAppPackageJSON();
|
|
998
|
-
const
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
if (
|
|
1003
|
-
|
|
1004
|
-
if (!((_appPackageJSON$scrip = appPackageJSON.scripts) !== null && _appPackageJSON$scrip !== void 0 && _appPackageJSON$scrip.dev)) {
|
|
1005
|
-
return createOnesApp.throwError(ErrorCode.DEV_SCRIPT_NOT_FOUND, i18n.t("error.dev.scriptNotFound"));
|
|
1006
|
-
}
|
|
963
|
+
const appManifestJSON = getAppManifestJSON();
|
|
964
|
+
const appRcJSON = getAppRcJSON();
|
|
965
|
+
lodashEs.noop(appManifestJSON);
|
|
966
|
+
lodashEs.noop(appRcJSON);
|
|
967
|
+
if (!((_appPackageJSON$scrip = appPackageJSON.scripts) !== null && _appPackageJSON$scrip !== void 0 && _appPackageJSON$scrip.dev)) {
|
|
968
|
+
return createOnesApp.throwError(ErrorCode.DEV_SCRIPT_NOT_FOUND, i18n.t("error.dev.scriptNotFound"));
|
|
1007
969
|
}
|
|
1008
|
-
const port = getConfig().defaultPort.tunnel;
|
|
1009
|
-
await invokeTunnel(port, {
|
|
1010
|
-
enableInternalManifestRoute: true,
|
|
1011
|
-
rebuildWhenExists: true
|
|
1012
|
-
});
|
|
1013
|
-
const runnelUrl = await buildTunnelUrl();
|
|
1014
|
-
const manifestUrl = `${runnelUrl}${ONES_CLI_INTERNAL_MANIFEST_PATH}`;
|
|
1015
970
|
const ONES_HOSTED_TOKEN = await getHostToken();
|
|
971
|
+
const port = getConfig().defaultPort.tunnel;
|
|
1016
972
|
const cwd = getAppWorkspacePath();
|
|
1017
973
|
const env2 = {
|
|
1018
974
|
...process.env,
|
|
@@ -1020,40 +976,18 @@ const dev = async function() {
|
|
|
1020
976
|
ONES_HOSTED_PORT: `${port}`,
|
|
1021
977
|
ONES_HOSTED_TOKEN
|
|
1022
978
|
};
|
|
1023
|
-
const {
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
const
|
|
1028
|
-
console.log("");
|
|
1029
|
-
console.log(`Local: http://localhost:${port}`);
|
|
1030
|
-
console.log(`Relay endpoint: ${runnelUrl}`);
|
|
1031
|
-
console.log(`Manifest URL: ${manifestUrl}`);
|
|
1032
|
-
console.log("");
|
|
1033
|
-
switch (normalizedOptions.install) {
|
|
1034
|
-
case InstallOptions.TRUE:
|
|
1035
|
-
console.log("InstallOptions.TRUE");
|
|
1036
|
-
break;
|
|
1037
|
-
case InstallOptions.AUTO:
|
|
1038
|
-
console.log("InstallOptions.AUTO");
|
|
1039
|
-
break;
|
|
1040
|
-
case InstallOptions.FALSE:
|
|
1041
|
-
break;
|
|
1042
|
-
}
|
|
1043
|
-
};
|
|
1044
|
-
const child = node_child_process.spawn(currentCommand, [], {
|
|
979
|
+
const tunnelChild = node_child_process.spawn("ones", ["tunnel", String(port)], {
|
|
980
|
+
cwd,
|
|
981
|
+
stdio: "inherit"
|
|
982
|
+
});
|
|
983
|
+
const devChild = node_child_process.spawn("npm", ["run", "dev"], {
|
|
1045
984
|
cwd,
|
|
1046
|
-
stdio:
|
|
1047
|
-
env: env2
|
|
1048
|
-
shell: true
|
|
985
|
+
stdio: "inherit",
|
|
986
|
+
env: env2
|
|
1049
987
|
});
|
|
1050
|
-
const pipe = createReadyStatusPipes(onReady);
|
|
1051
|
-
if (child.stdout)
|
|
1052
|
-
pipe(child.stdout, false);
|
|
1053
|
-
if (child.stderr)
|
|
1054
|
-
pipe(child.stderr, true);
|
|
1055
988
|
const cleanup = () => {
|
|
1056
|
-
|
|
989
|
+
tunnelChild.kill();
|
|
990
|
+
devChild.kill();
|
|
1057
991
|
};
|
|
1058
992
|
const onSignal = () => {
|
|
1059
993
|
cleanup();
|
|
@@ -1061,8 +995,16 @@ const dev = async function() {
|
|
|
1061
995
|
};
|
|
1062
996
|
process.on("SIGINT", onSignal);
|
|
1063
997
|
process.on("SIGTERM", onSignal);
|
|
998
|
+
console.log(`Local: http://localhost:${port}`);
|
|
999
|
+
if (normalizedOptions.install === InstallOptions.TRUE) {
|
|
1000
|
+
setTimeout(() => {
|
|
1001
|
+
invokeInstall().catch((error) => {
|
|
1002
|
+
console.error(error);
|
|
1003
|
+
});
|
|
1004
|
+
}, 2e3);
|
|
1005
|
+
}
|
|
1064
1006
|
await new Promise((resolve) => {
|
|
1065
|
-
|
|
1007
|
+
devChild.on("exit", () => {
|
|
1066
1008
|
cleanup();
|
|
1067
1009
|
process.off("SIGINT", onSignal);
|
|
1068
1010
|
process.off("SIGTERM", onSignal);
|
|
@@ -1090,7 +1032,7 @@ const sleep = (number) => {
|
|
|
1090
1032
|
};
|
|
1091
1033
|
const isURL = /^https?:\/\//;
|
|
1092
1034
|
const HostBlackList = ["ones.cn", "www.ones.cn", "ones.com", "www.ones.com"];
|
|
1093
|
-
const normalize$
|
|
1035
|
+
const normalize$6 = async (options) => {
|
|
1094
1036
|
const baseURLInput = options.baseURL;
|
|
1095
1037
|
if (baseURLInput)
|
|
1096
1038
|
;
|
|
@@ -1127,7 +1069,7 @@ const login = async function() {
|
|
|
1127
1069
|
const {
|
|
1128
1070
|
options
|
|
1129
1071
|
} = createOnesApp.getCommandOptions(args, loginCommandArguments);
|
|
1130
|
-
const normalizedOptions = await normalize$
|
|
1072
|
+
const normalizedOptions = await normalize$6(options);
|
|
1131
1073
|
const base = normalizedOptions.baseURL;
|
|
1132
1074
|
const path = "project/oauth2.html";
|
|
1133
1075
|
const config2 = getConfig();
|
|
@@ -1211,7 +1153,7 @@ const login = async function() {
|
|
|
1211
1153
|
ora("Waiting for authorization...").start();
|
|
1212
1154
|
await open(url);
|
|
1213
1155
|
};
|
|
1214
|
-
const normalize$
|
|
1156
|
+
const normalize$5 = async (options) => {
|
|
1215
1157
|
lodashEs.noop(options);
|
|
1216
1158
|
return {};
|
|
1217
1159
|
};
|
|
@@ -1222,12 +1164,12 @@ const logout = async function() {
|
|
|
1222
1164
|
const {
|
|
1223
1165
|
options
|
|
1224
1166
|
} = createOnesApp.getCommandOptions(args, logoutCommandArguments);
|
|
1225
|
-
const normalizedOptions = await normalize$
|
|
1167
|
+
const normalizedOptions = await normalize$5(options);
|
|
1226
1168
|
lodashEs.noop(normalizedOptions);
|
|
1227
1169
|
await setStore({});
|
|
1228
1170
|
console.log("Logged out successfully!");
|
|
1229
1171
|
};
|
|
1230
|
-
const normalize$
|
|
1172
|
+
const normalize$4 = async (options) => {
|
|
1231
1173
|
lodashEs.noop(options);
|
|
1232
1174
|
return {};
|
|
1233
1175
|
};
|
|
@@ -1239,97 +1181,19 @@ const whoami = async function() {
|
|
|
1239
1181
|
const {
|
|
1240
1182
|
options
|
|
1241
1183
|
} = createOnesApp.getCommandOptions(args, whoamiCommandArguments);
|
|
1242
|
-
const normalizedOptions = await normalize$
|
|
1184
|
+
const normalizedOptions = await normalize$4(options);
|
|
1243
1185
|
lodashEs.noop(normalizedOptions);
|
|
1244
1186
|
const baseURL = await getBaseURL();
|
|
1245
1187
|
const tokenInfo = await fetchTokenInfo();
|
|
1246
1188
|
const name2 = (_tokenInfo$user = tokenInfo.user) === null || _tokenInfo$user === void 0 ? void 0 : _tokenInfo$user.name;
|
|
1247
1189
|
const email = (_tokenInfo$user2 = tokenInfo.user) === null || _tokenInfo$user2 === void 0 ? void 0 : _tokenInfo$user2.email;
|
|
1248
1190
|
if (name2 && email) {
|
|
1249
|
-
console.log(
|
|
1250
|
-
console.log(`Email: ${email}`);
|
|
1191
|
+
console.log(`${name2} <${email}>`);
|
|
1251
1192
|
console.log(`ONES: ${baseURL}`);
|
|
1252
1193
|
} else {
|
|
1253
1194
|
consoleUnauthorizedMessage();
|
|
1254
1195
|
}
|
|
1255
1196
|
};
|
|
1256
|
-
const normalize$4 = async (options) => {
|
|
1257
|
-
lodashEs.noop(options);
|
|
1258
|
-
return {};
|
|
1259
|
-
};
|
|
1260
|
-
const getManifestUrl = async () => {
|
|
1261
|
-
const runnelUrl = await buildTunnelUrl();
|
|
1262
|
-
const customManifestUrl = `${runnelUrl}${MANIFEST_PATH}`;
|
|
1263
|
-
const internalManifestUrl = `${runnelUrl}${ONES_CLI_INTERNAL_MANIFEST_PATH}`;
|
|
1264
|
-
const internalResult = await axios.get(internalManifestUrl).then((response) => {
|
|
1265
|
-
if (response.status === 200) {
|
|
1266
|
-
return internalManifestUrl;
|
|
1267
|
-
}
|
|
1268
|
-
return null;
|
|
1269
|
-
}).catch(lodashEs.noop);
|
|
1270
|
-
if (internalResult) {
|
|
1271
|
-
return internalResult;
|
|
1272
|
-
}
|
|
1273
|
-
const customResult = await axios.get(customManifestUrl).then((response) => {
|
|
1274
|
-
if (response.status === 200) {
|
|
1275
|
-
return customManifestUrl;
|
|
1276
|
-
}
|
|
1277
|
-
return null;
|
|
1278
|
-
}).catch(lodashEs.noop);
|
|
1279
|
-
if (customResult) {
|
|
1280
|
-
return customResult;
|
|
1281
|
-
}
|
|
1282
|
-
return null;
|
|
1283
|
-
};
|
|
1284
|
-
const install = async function() {
|
|
1285
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1286
|
-
args[_key] = arguments[_key];
|
|
1287
|
-
}
|
|
1288
|
-
const {
|
|
1289
|
-
options
|
|
1290
|
-
} = createOnesApp.getCommandOptions(args, installCommandArguments);
|
|
1291
|
-
const normalizedOptions = await normalize$4(options);
|
|
1292
|
-
lodashEs.noop(normalizedOptions);
|
|
1293
|
-
const {
|
|
1294
|
-
app
|
|
1295
|
-
} = getAppManifestJSON();
|
|
1296
|
-
const appName = app.name;
|
|
1297
|
-
const appID = app.id;
|
|
1298
|
-
const manifestUrl = await getManifestUrl();
|
|
1299
|
-
if (!manifestUrl) {
|
|
1300
|
-
console.log(`App "${appName}" server not available!`);
|
|
1301
|
-
console.log('Use "ones dev" command or "ones tunnel" command to start the server first');
|
|
1302
|
-
process.exit(1);
|
|
1303
|
-
}
|
|
1304
|
-
const result = await fetchAppInstall({
|
|
1305
|
-
manifest_url: manifestUrl
|
|
1306
|
-
});
|
|
1307
|
-
if (result.code === "OK") {
|
|
1308
|
-
var _appList$data$0$insta, _appList$data;
|
|
1309
|
-
console.log(`App "${appName}" installed successfully!`);
|
|
1310
|
-
const appList = await fetchAppList(appID);
|
|
1311
|
-
const installationID = (_appList$data$0$insta = (_appList$data = appList.data) === null || _appList$data === void 0 || (_appList$data = _appList$data[0]) === null || _appList$data === void 0 ? void 0 : _appList$data.installation_id) !== null && _appList$data$0$insta !== void 0 ? _appList$data$0$insta : "";
|
|
1312
|
-
if (installationID) {
|
|
1313
|
-
var _tokenInfo$org$uuid, _tokenInfo$org, _tokenInfo$teams$0$uu, _tokenInfo$teams, _tokenInfo$org$visibi, _tokenInfo$org2;
|
|
1314
|
-
const tokenInfo = await fetchTokenInfo();
|
|
1315
|
-
const orgUUID = (_tokenInfo$org$uuid = (_tokenInfo$org = tokenInfo.org) === null || _tokenInfo$org === void 0 ? void 0 : _tokenInfo$org.uuid) !== null && _tokenInfo$org$uuid !== void 0 ? _tokenInfo$org$uuid : "";
|
|
1316
|
-
const teamUUID = (_tokenInfo$teams$0$uu = (_tokenInfo$teams = tokenInfo.teams) === null || _tokenInfo$teams === void 0 || (_tokenInfo$teams = _tokenInfo$teams[0]) === null || _tokenInfo$teams === void 0 ? void 0 : _tokenInfo$teams.uuid) !== null && _tokenInfo$teams$0$uu !== void 0 ? _tokenInfo$teams$0$uu : "";
|
|
1317
|
-
const isOrgVisible = (_tokenInfo$org$visibi = (_tokenInfo$org2 = tokenInfo.org) === null || _tokenInfo$org2 === void 0 ? void 0 : _tokenInfo$org2.visibility) !== null && _tokenInfo$org$visibi !== void 0 ? _tokenInfo$org$visibi : false;
|
|
1318
|
-
const baseURL = await getBaseURL();
|
|
1319
|
-
if (isOrgVisible && orgUUID) {
|
|
1320
|
-
const url = `${baseURL}/project/#/org/${orgUUID}/setting/app_manager/platform_app/${installationID}`;
|
|
1321
|
-
console.log(`See App detail: ${url}`);
|
|
1322
|
-
}
|
|
1323
|
-
if (!isOrgVisible && teamUUID) {
|
|
1324
|
-
const url = `${baseURL}/project/#/team/${teamUUID}/team_setting/app_manager/platform_app/${installationID}`;
|
|
1325
|
-
console.log(`See App detail: ${url}`);
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
} else {
|
|
1329
|
-
console.log(`App "${appName}" installed failed!`);
|
|
1330
|
-
console.error(JSON.stringify(result, null, 2));
|
|
1331
|
-
}
|
|
1332
|
-
};
|
|
1333
1197
|
const normalize$3 = async (options) => {
|
|
1334
1198
|
lodashEs.noop(options);
|
|
1335
1199
|
return {};
|
|
@@ -1343,13 +1207,11 @@ const enable = async function() {
|
|
|
1343
1207
|
} = createOnesApp.getCommandOptions(args, enableCommandArguments);
|
|
1344
1208
|
const normalizedOptions = await normalize$3(options);
|
|
1345
1209
|
lodashEs.noop(normalizedOptions);
|
|
1346
|
-
const appName = getAppManifestJSON().app.name;
|
|
1347
1210
|
const result = await fetchAppEnable();
|
|
1348
1211
|
if (result.code === "OK") {
|
|
1349
|
-
console.log(
|
|
1212
|
+
console.log("App enabled successfully!");
|
|
1350
1213
|
} else {
|
|
1351
|
-
console.
|
|
1352
|
-
console.error(JSON.stringify(result, null, 2));
|
|
1214
|
+
console.error(result);
|
|
1353
1215
|
}
|
|
1354
1216
|
};
|
|
1355
1217
|
const normalize$2 = async (options) => {
|
|
@@ -1365,13 +1227,11 @@ const disable = async function() {
|
|
|
1365
1227
|
} = createOnesApp.getCommandOptions(args, disableCommandArguments);
|
|
1366
1228
|
const normalizedOptions = await normalize$2(options);
|
|
1367
1229
|
lodashEs.noop(normalizedOptions);
|
|
1368
|
-
const appName = getAppManifestJSON().app.name;
|
|
1369
1230
|
const result = await fetchAppDisable();
|
|
1370
1231
|
if (result.code === "OK") {
|
|
1371
|
-
console.log(
|
|
1232
|
+
console.log("App disabled successfully!");
|
|
1372
1233
|
} else {
|
|
1373
|
-
console.
|
|
1374
|
-
console.error(JSON.stringify(result, null, 2));
|
|
1234
|
+
console.error(result);
|
|
1375
1235
|
}
|
|
1376
1236
|
};
|
|
1377
1237
|
const normalize$1 = async (options) => {
|
|
@@ -1387,13 +1247,11 @@ const uninstall = async function() {
|
|
|
1387
1247
|
} = createOnesApp.getCommandOptions(args, uninstallCommandArguments);
|
|
1388
1248
|
const normalizedOptions = await normalize$1(options);
|
|
1389
1249
|
lodashEs.noop(normalizedOptions);
|
|
1390
|
-
const appName = getAppManifestJSON().app.name;
|
|
1391
1250
|
const result = await fetchAppUninstall();
|
|
1392
1251
|
if (result.code === "OK") {
|
|
1393
|
-
console.log(
|
|
1252
|
+
console.log("App uninstalled successfully!");
|
|
1394
1253
|
} else {
|
|
1395
|
-
console.
|
|
1396
|
-
console.error(JSON.stringify(result, null, 2));
|
|
1254
|
+
console.error(result);
|
|
1397
1255
|
}
|
|
1398
1256
|
};
|
|
1399
1257
|
const normalize = async (options) => {
|