@ones-open/cli 1.0.1-8523.1883 → 1.0.1-9456.1922
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 +208 -82
- package/dist/index.js +211 -85
- 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/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/tunnel-client.d.ts +6 -3
- package/dist/types/actions/tunnel/tunnel-client.d.ts.map +1 -1
- package/dist/types/common/error/enums.d.ts +12 -11
- package/dist/types/common/error/enums.d.ts.map +1 -1
- package/dist/types/common/request/types.d.ts +7 -0
- package/dist/types/common/request/types.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -85,17 +85,18 @@ var ErrorCode = ((ErrorCode2) => {
|
|
|
85
85
|
ErrorCode2[ErrorCode2["UNKNOWN_ERROR"] = createOnesApp.ErrorCode.UNKNOWN_ERROR] = "UNKNOWN_ERROR";
|
|
86
86
|
ErrorCode2[ErrorCode2["COMMAND_ERROR"] = createOnesApp.ErrorCode.COMMAND_ERROR] = "COMMAND_ERROR";
|
|
87
87
|
ErrorCode2[ErrorCode2["TEMPLATE_NOT_FOUND"] = createOnesApp.ErrorCode.TEMPLATE_NOT_FOUND] = "TEMPLATE_NOT_FOUND";
|
|
88
|
-
ErrorCode2["
|
|
89
|
-
ErrorCode2["
|
|
90
|
-
ErrorCode2["
|
|
91
|
-
ErrorCode2["
|
|
92
|
-
ErrorCode2["
|
|
93
|
-
ErrorCode2["
|
|
94
|
-
ErrorCode2["
|
|
95
|
-
ErrorCode2["
|
|
96
|
-
ErrorCode2["
|
|
97
|
-
ErrorCode2["
|
|
98
|
-
ErrorCode2["
|
|
88
|
+
ErrorCode2[ErrorCode2["MISSING_PROJECT_PATH"] = createOnesApp.ErrorCode.MISSING_PROJECT_PATH] = "MISSING_PROJECT_PATH";
|
|
89
|
+
ErrorCode2["MISSING_BASE_URL"] = "E04";
|
|
90
|
+
ErrorCode2["MISSING_PORT"] = "E05";
|
|
91
|
+
ErrorCode2["INCORRECT_BASE_URL"] = "E06";
|
|
92
|
+
ErrorCode2["INCORRECT_PORT"] = "E07";
|
|
93
|
+
ErrorCode2["APP_PACKAGE_JSON_PARSE_ERROR"] = "E08";
|
|
94
|
+
ErrorCode2["APP_MANIFEST_JSON_PARSE_ERROR"] = "E09";
|
|
95
|
+
ErrorCode2["BUILD_SCRIPT_NOT_FOUND"] = "E10";
|
|
96
|
+
ErrorCode2["DEV_SCRIPT_NOT_FOUND"] = "E11";
|
|
97
|
+
ErrorCode2["STORE_PERMISSION"] = "E12";
|
|
98
|
+
ErrorCode2["HOSTED_TOKEN_REQUEST_FAILED"] = "E13";
|
|
99
|
+
ErrorCode2["HOSTED_TOKEN_EMPTY"] = "E14";
|
|
99
100
|
return ErrorCode2;
|
|
100
101
|
})(ErrorCode || {});
|
|
101
102
|
const getPublicPath = () => {
|
|
@@ -221,7 +222,11 @@ const build = async function() {
|
|
|
221
222
|
if ((_appPackageJSON$scrip = appPackageJSON.scripts) !== null && _appPackageJSON$scrip !== void 0 && _appPackageJSON$scrip.build) {
|
|
222
223
|
node_child_process.spawnSync("npm", ["run", "build"], {
|
|
223
224
|
cwd: getAppWorkspacePath(),
|
|
224
|
-
stdio: "inherit"
|
|
225
|
+
stdio: "inherit",
|
|
226
|
+
env: {
|
|
227
|
+
...process.env,
|
|
228
|
+
NODE_ENV: "production"
|
|
229
|
+
}
|
|
225
230
|
});
|
|
226
231
|
} else {
|
|
227
232
|
return createOnesApp.throwError(ErrorCode.BUILD_SCRIPT_NOT_FOUND, i18n.t("error.build.scriptNotFound"));
|
|
@@ -264,6 +269,13 @@ const build = async function() {
|
|
|
264
269
|
});
|
|
265
270
|
archive.finalize();
|
|
266
271
|
};
|
|
272
|
+
const config = {
|
|
273
|
+
defaultPort: {
|
|
274
|
+
login: 8200,
|
|
275
|
+
tunnel: 8201
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
const getConfig = () => config;
|
|
267
279
|
var InstallOptions = /* @__PURE__ */ ((InstallOptions2) => {
|
|
268
280
|
InstallOptions2["AUTO"] = "auto";
|
|
269
281
|
InstallOptions2["TRUE"] = "true";
|
|
@@ -297,17 +309,51 @@ const dev = async function() {
|
|
|
297
309
|
options
|
|
298
310
|
} = createOnesApp.getCommandOptions(args, devCommandArguments);
|
|
299
311
|
const normalizedOptions = await normalize$9(options);
|
|
300
|
-
console.log("dev", normalizedOptions);
|
|
301
312
|
const appPackageJSON = getAppPackageJSON();
|
|
302
|
-
console.log("appPackageJSON", appPackageJSON);
|
|
303
313
|
const appManifestJSON = getAppManifestJSON();
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
} else {
|
|
314
|
+
const appRcJSON = getAppRcJSON();
|
|
315
|
+
lodashEs.noop(appManifestJSON);
|
|
316
|
+
lodashEs.noop(appRcJSON);
|
|
317
|
+
if (!((_appPackageJSON$scrip = appPackageJSON.scripts) !== null && _appPackageJSON$scrip !== void 0 && _appPackageJSON$scrip.dev)) {
|
|
309
318
|
return createOnesApp.throwError(ErrorCode.DEV_SCRIPT_NOT_FOUND, i18n.t("error.dev.scriptNotFound"));
|
|
310
319
|
}
|
|
320
|
+
const port = getConfig().defaultPort.tunnel;
|
|
321
|
+
const cwd = getAppWorkspacePath();
|
|
322
|
+
const env = {
|
|
323
|
+
...process.env,
|
|
324
|
+
NODE_ENV: "development",
|
|
325
|
+
ONES_HOSTED_PORT: `${port}`
|
|
326
|
+
};
|
|
327
|
+
const tunnelChild = node_child_process.spawn("ones", ["tunnel", String(port)], {
|
|
328
|
+
cwd,
|
|
329
|
+
stdio: "inherit"
|
|
330
|
+
});
|
|
331
|
+
const devChild = node_child_process.spawn("npm", ["run", "dev"], {
|
|
332
|
+
cwd,
|
|
333
|
+
stdio: "inherit",
|
|
334
|
+
env
|
|
335
|
+
});
|
|
336
|
+
const cleanup = () => {
|
|
337
|
+
tunnelChild.kill();
|
|
338
|
+
devChild.kill();
|
|
339
|
+
};
|
|
340
|
+
const onSignal = () => {
|
|
341
|
+
cleanup();
|
|
342
|
+
process.exit(128 + 2);
|
|
343
|
+
};
|
|
344
|
+
process.on("SIGINT", onSignal);
|
|
345
|
+
process.on("SIGTERM", onSignal);
|
|
346
|
+
if (normalizedOptions.install) {
|
|
347
|
+
lodashEs.noop(normalizedOptions.install);
|
|
348
|
+
}
|
|
349
|
+
await new Promise((resolve) => {
|
|
350
|
+
devChild.on("exit", () => {
|
|
351
|
+
cleanup();
|
|
352
|
+
process.off("SIGINT", onSignal);
|
|
353
|
+
process.off("SIGTERM", onSignal);
|
|
354
|
+
resolve();
|
|
355
|
+
});
|
|
356
|
+
});
|
|
311
357
|
};
|
|
312
358
|
const isPortNumber = /^[1-9]\d{0,4}$/;
|
|
313
359
|
const minPortNumber = 1;
|
|
@@ -435,6 +481,7 @@ const setONESToken = async (token) => {
|
|
|
435
481
|
ones_token: token
|
|
436
482
|
});
|
|
437
483
|
};
|
|
484
|
+
const MAX_RELAY_BODY_BYTES = 64 * 1024 * 1024;
|
|
438
485
|
class TunnelClient {
|
|
439
486
|
constructor(localPort, baseUrl, appID, hostedToken) {
|
|
440
487
|
_defineProperty(this, "ws", null);
|
|
@@ -448,7 +495,8 @@ class TunnelClient {
|
|
|
448
495
|
this.ws = new WebSocket(proxyUrl, {
|
|
449
496
|
headers: {
|
|
450
497
|
Authorization: `Bearer ${this.hostedToken}`
|
|
451
|
-
}
|
|
498
|
+
},
|
|
499
|
+
maxPayload: MAX_RELAY_BODY_BYTES
|
|
452
500
|
});
|
|
453
501
|
this.ws.on("message", async (data) => {
|
|
454
502
|
const message = this.parseMessage(data);
|
|
@@ -481,17 +529,17 @@ class TunnelClient {
|
|
|
481
529
|
return url.toString();
|
|
482
530
|
}
|
|
483
531
|
parseMessage(data) {
|
|
484
|
-
const
|
|
485
|
-
|
|
486
|
-
const message = JSON.parse(payload);
|
|
487
|
-
if (!message) {
|
|
488
|
-
return null;
|
|
489
|
-
}
|
|
490
|
-
return message;
|
|
491
|
-
} catch (error) {
|
|
492
|
-
console.error("Invalid tunnel message:", error);
|
|
532
|
+
const buffer = this.toBuffer(data);
|
|
533
|
+
if (!buffer) {
|
|
493
534
|
return null;
|
|
494
535
|
}
|
|
536
|
+
if (buffer.length >= 4) {
|
|
537
|
+
const binary = this.parseBinaryEnvelope(buffer);
|
|
538
|
+
if (binary) {
|
|
539
|
+
return binary;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
return this.parseJSONEnvelope(buffer.toString());
|
|
495
543
|
}
|
|
496
544
|
async handleMessage(message) {
|
|
497
545
|
const request = this.getRequestPayload(message);
|
|
@@ -499,7 +547,6 @@ class TunnelClient {
|
|
|
499
547
|
return;
|
|
500
548
|
}
|
|
501
549
|
if (request.path === ONES_CLI_MANIFEST_PATH) {
|
|
502
|
-
var _this$ws5;
|
|
503
550
|
const appManifest = getAppManifestJSON().app;
|
|
504
551
|
const baseURL = await buildTunnelUrl();
|
|
505
552
|
const reply = {
|
|
@@ -515,19 +562,17 @@ class TunnelClient {
|
|
|
515
562
|
}
|
|
516
563
|
}
|
|
517
564
|
};
|
|
518
|
-
|
|
565
|
+
this.sendBinaryEnvelope(reply);
|
|
519
566
|
return;
|
|
520
567
|
}
|
|
521
568
|
try {
|
|
522
|
-
var _this$ws6;
|
|
523
569
|
const response = await this.forwardRequest(request);
|
|
524
570
|
const reply = {
|
|
525
571
|
id: message.id,
|
|
526
572
|
payload: response
|
|
527
573
|
};
|
|
528
|
-
|
|
574
|
+
this.sendBinaryEnvelope(reply);
|
|
529
575
|
} catch (error) {
|
|
530
|
-
var _this$ws7;
|
|
531
576
|
const reply = {
|
|
532
577
|
id: message.id,
|
|
533
578
|
payload: {
|
|
@@ -538,7 +583,7 @@ class TunnelClient {
|
|
|
538
583
|
body: "agent request error"
|
|
539
584
|
}
|
|
540
585
|
};
|
|
541
|
-
|
|
586
|
+
this.sendBinaryEnvelope(reply);
|
|
542
587
|
}
|
|
543
588
|
}
|
|
544
589
|
getRequestPayload(message) {
|
|
@@ -553,43 +598,36 @@ class TunnelClient {
|
|
|
553
598
|
if (payload.query) {
|
|
554
599
|
Object.entries(payload.query).forEach((_ref) => {
|
|
555
600
|
let [key, value] = _ref;
|
|
556
|
-
|
|
601
|
+
if (Array.isArray(value)) {
|
|
602
|
+
value.forEach((item) => {
|
|
603
|
+
url.searchParams.append(key, item);
|
|
604
|
+
});
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
url.searchParams.append(key, value);
|
|
557
608
|
});
|
|
558
609
|
}
|
|
559
|
-
const headers = this.normalizeHeaders(payload.headers);
|
|
560
|
-
const body = this.normalizeBody(payload.body);
|
|
561
610
|
const response = await axios.request({
|
|
562
611
|
url: url.toString(),
|
|
563
612
|
method: payload.method,
|
|
564
|
-
headers,
|
|
565
|
-
data: body,
|
|
566
|
-
responseType: "
|
|
567
|
-
validateStatus: () => true
|
|
613
|
+
headers: payload.headers,
|
|
614
|
+
data: payload.body,
|
|
615
|
+
responseType: "arraybuffer",
|
|
616
|
+
validateStatus: () => true,
|
|
617
|
+
maxBodyLength: MAX_RELAY_BODY_BYTES,
|
|
618
|
+
maxContentLength: MAX_RELAY_BODY_BYTES
|
|
568
619
|
});
|
|
620
|
+
const responseBytes = Buffer.from(response.data);
|
|
569
621
|
return {
|
|
570
622
|
status: response.status,
|
|
571
623
|
headers: this.collectHeaders(response.headers),
|
|
572
|
-
body:
|
|
624
|
+
body: responseBytes
|
|
573
625
|
};
|
|
574
626
|
}
|
|
575
|
-
normalizeHeaders(headers) {
|
|
576
|
-
if (!headers) {
|
|
577
|
-
return void 0;
|
|
578
|
-
}
|
|
579
|
-
const normalized = {};
|
|
580
|
-
Object.entries(headers).forEach((_ref2) => {
|
|
581
|
-
let [key, values] = _ref2;
|
|
582
|
-
if (!values || values.length === 0) {
|
|
583
|
-
return;
|
|
584
|
-
}
|
|
585
|
-
normalized[key] = values.join(",");
|
|
586
|
-
});
|
|
587
|
-
return normalized;
|
|
588
|
-
}
|
|
589
627
|
collectHeaders(headers) {
|
|
590
628
|
const collected = {};
|
|
591
|
-
Object.entries(headers).forEach((
|
|
592
|
-
let [key, value] =
|
|
629
|
+
Object.entries(headers).forEach((_ref2) => {
|
|
630
|
+
let [key, value] = _ref2;
|
|
593
631
|
if (Array.isArray(value)) {
|
|
594
632
|
collected[key] = value.map((item) => String(item));
|
|
595
633
|
return;
|
|
@@ -600,25 +638,96 @@ class TunnelClient {
|
|
|
600
638
|
});
|
|
601
639
|
return collected;
|
|
602
640
|
}
|
|
603
|
-
|
|
641
|
+
sendBinaryEnvelope(envelope) {
|
|
642
|
+
var _this$ws5;
|
|
643
|
+
const encoded = this.encodeBinaryEnvelope(envelope);
|
|
644
|
+
(_this$ws5 = this.ws) === null || _this$ws5 === void 0 || _this$ws5.send(encoded);
|
|
645
|
+
}
|
|
646
|
+
encodeBinaryEnvelope(envelope) {
|
|
647
|
+
var _envelope$payload;
|
|
648
|
+
const payload = (_envelope$payload = envelope.payload) !== null && _envelope$payload !== void 0 ? _envelope$payload : {};
|
|
649
|
+
const body = this.toBodyBuffer(payload.body);
|
|
650
|
+
if (body.length > MAX_RELAY_BODY_BYTES) {
|
|
651
|
+
throw new Error("relay body too large");
|
|
652
|
+
}
|
|
653
|
+
const metaPayload = {
|
|
654
|
+
...payload
|
|
655
|
+
};
|
|
656
|
+
delete metaPayload.body;
|
|
657
|
+
const meta = Buffer.from(JSON.stringify({
|
|
658
|
+
id: envelope.id,
|
|
659
|
+
payload: metaPayload
|
|
660
|
+
}), "utf8");
|
|
661
|
+
const header = Buffer.allocUnsafe(4);
|
|
662
|
+
header.writeUInt32BE(meta.length, 0);
|
|
663
|
+
return Buffer.concat([header, meta, body]);
|
|
664
|
+
}
|
|
665
|
+
toBodyBuffer(body) {
|
|
604
666
|
if (body === void 0 || body === null) {
|
|
605
|
-
return
|
|
667
|
+
return Buffer.alloc(0);
|
|
606
668
|
}
|
|
607
|
-
if (
|
|
669
|
+
if (Buffer.isBuffer(body)) {
|
|
608
670
|
return body;
|
|
609
671
|
}
|
|
610
|
-
|
|
672
|
+
if (body instanceof ArrayBuffer) {
|
|
673
|
+
return Buffer.from(body);
|
|
674
|
+
}
|
|
675
|
+
if (ArrayBuffer.isView(body)) {
|
|
676
|
+
return Buffer.from(body.buffer, body.byteOffset, body.byteLength);
|
|
677
|
+
}
|
|
678
|
+
if (typeof body === "string") {
|
|
679
|
+
return Buffer.from(body, "utf8");
|
|
680
|
+
}
|
|
681
|
+
return Buffer.from(JSON.stringify(body), "utf8");
|
|
611
682
|
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
683
|
+
parseBinaryEnvelope(buffer) {
|
|
684
|
+
const metaLength = buffer.readUInt32BE(0);
|
|
685
|
+
if (metaLength <= 0 || 4 + metaLength > buffer.length) {
|
|
686
|
+
return null;
|
|
615
687
|
}
|
|
688
|
+
const metaRaw = buffer.subarray(4, 4 + metaLength).toString("utf8");
|
|
616
689
|
try {
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
690
|
+
const envelope = JSON.parse(metaRaw);
|
|
691
|
+
if (!(envelope !== null && envelope !== void 0 && envelope.payload)) {
|
|
692
|
+
return envelope;
|
|
693
|
+
}
|
|
694
|
+
const body = buffer.subarray(4 + metaLength);
|
|
695
|
+
if (body.length > MAX_RELAY_BODY_BYTES) {
|
|
696
|
+
console.error("Binary tunnel body exceeds size limit");
|
|
697
|
+
return null;
|
|
698
|
+
}
|
|
699
|
+
const payload = envelope.payload;
|
|
700
|
+
payload.body = body;
|
|
701
|
+
return envelope;
|
|
702
|
+
} catch (error) {
|
|
703
|
+
console.error("Invalid binary tunnel message:", error);
|
|
704
|
+
return null;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
parseJSONEnvelope(payload) {
|
|
708
|
+
try {
|
|
709
|
+
const message = JSON.parse(payload);
|
|
710
|
+
if (!message) {
|
|
711
|
+
return null;
|
|
712
|
+
}
|
|
713
|
+
return message;
|
|
714
|
+
} catch (error) {
|
|
715
|
+
console.error("Invalid tunnel message:", error);
|
|
716
|
+
return null;
|
|
620
717
|
}
|
|
621
718
|
}
|
|
719
|
+
toBuffer(data) {
|
|
720
|
+
if (Buffer.isBuffer(data)) {
|
|
721
|
+
return data;
|
|
722
|
+
}
|
|
723
|
+
if (Array.isArray(data)) {
|
|
724
|
+
return Buffer.concat(data);
|
|
725
|
+
}
|
|
726
|
+
if (data instanceof ArrayBuffer) {
|
|
727
|
+
return Buffer.from(data);
|
|
728
|
+
}
|
|
729
|
+
return null;
|
|
730
|
+
}
|
|
622
731
|
}
|
|
623
732
|
const getPath = (path, map2) => {
|
|
624
733
|
var _context;
|
|
@@ -855,13 +964,6 @@ const tunnel = async function() {
|
|
|
855
964
|
const normalizedOptions = await normalize$8(options);
|
|
856
965
|
await invokeTunnel(Number(normalizedOptions.port));
|
|
857
966
|
};
|
|
858
|
-
const config = {
|
|
859
|
-
defaultPort: {
|
|
860
|
-
login: 8200,
|
|
861
|
-
tunnel: 8201
|
|
862
|
-
}
|
|
863
|
-
};
|
|
864
|
-
const getConfig = () => config;
|
|
865
967
|
function createPromise() {
|
|
866
968
|
let resolve;
|
|
867
969
|
let reject;
|
|
@@ -926,7 +1028,7 @@ const login = async function() {
|
|
|
926
1028
|
const port = await getPort({
|
|
927
1029
|
port: config2.defaultPort.login
|
|
928
1030
|
});
|
|
929
|
-
const uuid$1 = uuid.
|
|
1031
|
+
const uuid$1 = uuid.v4();
|
|
930
1032
|
const search = new URLSearchParams();
|
|
931
1033
|
search.set("redirect_path", "/developer/cli");
|
|
932
1034
|
search.set("redirect_url", `http://localhost:${port}`);
|
|
@@ -1048,6 +1150,13 @@ const normalize$4 = async (options) => {
|
|
|
1048
1150
|
lodashEs.noop(options);
|
|
1049
1151
|
return {};
|
|
1050
1152
|
};
|
|
1153
|
+
const invokeInstall = async () => {
|
|
1154
|
+
const runnelUrl = await buildTunnelUrl();
|
|
1155
|
+
const result = await fetchAppInstall({
|
|
1156
|
+
manifest_url: `${runnelUrl}${ONES_CLI_MANIFEST_PATH}`
|
|
1157
|
+
});
|
|
1158
|
+
return result;
|
|
1159
|
+
};
|
|
1051
1160
|
const install = async function() {
|
|
1052
1161
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1053
1162
|
args[_key] = arguments[_key];
|
|
@@ -1058,12 +1167,29 @@ const install = async function() {
|
|
|
1058
1167
|
const normalizedOptions = await normalize$4(options);
|
|
1059
1168
|
lodashEs.noop(normalizedOptions);
|
|
1060
1169
|
await invokeTunnel(getConfig().defaultPort.tunnel);
|
|
1061
|
-
const
|
|
1062
|
-
const result = await fetchAppInstall({
|
|
1063
|
-
manifest_url: `${runnelUrl}${ONES_CLI_MANIFEST_PATH}`
|
|
1064
|
-
});
|
|
1170
|
+
const result = await invokeInstall();
|
|
1065
1171
|
if (result.code === "OK") {
|
|
1172
|
+
var _appList$data$0$insta, _appList$data;
|
|
1066
1173
|
console.log("App installed successfully!");
|
|
1174
|
+
const appID = getAppManifestJSON().app.id;
|
|
1175
|
+
const appList = await fetchAppList(appID);
|
|
1176
|
+
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 : "";
|
|
1177
|
+
if (installationID) {
|
|
1178
|
+
var _tokenInfo$org$uuid, _tokenInfo$org, _tokenInfo$teams$0$uu, _tokenInfo$teams, _tokenInfo$org$visibi, _tokenInfo$org2;
|
|
1179
|
+
const tokenInfo = await fetchTokenInfo();
|
|
1180
|
+
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 : "";
|
|
1181
|
+
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 : "";
|
|
1182
|
+
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;
|
|
1183
|
+
const baseURL = await getBaseURL();
|
|
1184
|
+
if (isOrgVisible && orgUUID) {
|
|
1185
|
+
const url = `${baseURL}/project/#/org/${orgUUID}/setting/app_manager/platform_app/${installationID}`;
|
|
1186
|
+
console.log(`See App detail: ${url}`);
|
|
1187
|
+
}
|
|
1188
|
+
if (!isOrgVisible && teamUUID) {
|
|
1189
|
+
const url = `${baseURL}/project/#/team/${teamUUID}/team_setting/app_manager/platform_app/${installationID}`;
|
|
1190
|
+
console.log(`See App detail: ${url}`);
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1067
1193
|
} else {
|
|
1068
1194
|
console.error(result);
|
|
1069
1195
|
}
|
|
@@ -1205,7 +1331,7 @@ const runCommandONES = async () => {
|
|
|
1205
1331
|
const command = ones;
|
|
1206
1332
|
createOnesApp.setContext("command", command);
|
|
1207
1333
|
const version = `${getPackageJSON().version}`;
|
|
1208
|
-
command.version(version);
|
|
1334
|
+
command.version(version, "-v, --version");
|
|
1209
1335
|
await command.parse();
|
|
1210
1336
|
};
|
|
1211
1337
|
exports.runCommandONES = runCommandONES;
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,10 @@ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/ins
|
|
|
2
2
|
import { Command } from "commander";
|
|
3
3
|
import { ErrorCode as ErrorCode$1, AppPackageJSONSchema, throwError, AppManifestJSONSchema, getPublicPath as getPublicPath$1, PUBLIC_FILENAME, AppRcJSONSchema, getCommandOptions, HostedTokenScope, addCommandUsage, addCommandOutput, $create, setContext } from "create-ones-app";
|
|
4
4
|
import { dirname, join, resolve, basename } from "node:path";
|
|
5
|
-
import { spawnSync } from "node:child_process";
|
|
5
|
+
import { spawnSync, spawn } from "node:child_process";
|
|
6
6
|
import { readFileSync, createWriteStream } from "node:fs";
|
|
7
7
|
import archiver from "archiver";
|
|
8
|
-
import { get,
|
|
8
|
+
import { get, noop, merge } from "lodash-es";
|
|
9
9
|
import process$1, { cwd, exit } from "node:process";
|
|
10
10
|
import { fileURLToPath } from "node:url";
|
|
11
11
|
import { cosmiconfig } from "cosmiconfig";
|
|
@@ -20,7 +20,7 @@ import http from "node:http";
|
|
|
20
20
|
import ora from "ora";
|
|
21
21
|
import open from "open";
|
|
22
22
|
import getPort from "get-port";
|
|
23
|
-
import {
|
|
23
|
+
import { v4 } from "uuid";
|
|
24
24
|
const en = {
|
|
25
25
|
"desc.ones": "cli for ones",
|
|
26
26
|
"desc.build": "build the application",
|
|
@@ -82,17 +82,18 @@ var ErrorCode = ((ErrorCode2) => {
|
|
|
82
82
|
ErrorCode2[ErrorCode2["UNKNOWN_ERROR"] = ErrorCode$1.UNKNOWN_ERROR] = "UNKNOWN_ERROR";
|
|
83
83
|
ErrorCode2[ErrorCode2["COMMAND_ERROR"] = ErrorCode$1.COMMAND_ERROR] = "COMMAND_ERROR";
|
|
84
84
|
ErrorCode2[ErrorCode2["TEMPLATE_NOT_FOUND"] = ErrorCode$1.TEMPLATE_NOT_FOUND] = "TEMPLATE_NOT_FOUND";
|
|
85
|
-
ErrorCode2["
|
|
86
|
-
ErrorCode2["
|
|
87
|
-
ErrorCode2["
|
|
88
|
-
ErrorCode2["
|
|
89
|
-
ErrorCode2["
|
|
90
|
-
ErrorCode2["
|
|
91
|
-
ErrorCode2["
|
|
92
|
-
ErrorCode2["
|
|
93
|
-
ErrorCode2["
|
|
94
|
-
ErrorCode2["
|
|
95
|
-
ErrorCode2["
|
|
85
|
+
ErrorCode2[ErrorCode2["MISSING_PROJECT_PATH"] = ErrorCode$1.MISSING_PROJECT_PATH] = "MISSING_PROJECT_PATH";
|
|
86
|
+
ErrorCode2["MISSING_BASE_URL"] = "E04";
|
|
87
|
+
ErrorCode2["MISSING_PORT"] = "E05";
|
|
88
|
+
ErrorCode2["INCORRECT_BASE_URL"] = "E06";
|
|
89
|
+
ErrorCode2["INCORRECT_PORT"] = "E07";
|
|
90
|
+
ErrorCode2["APP_PACKAGE_JSON_PARSE_ERROR"] = "E08";
|
|
91
|
+
ErrorCode2["APP_MANIFEST_JSON_PARSE_ERROR"] = "E09";
|
|
92
|
+
ErrorCode2["BUILD_SCRIPT_NOT_FOUND"] = "E10";
|
|
93
|
+
ErrorCode2["DEV_SCRIPT_NOT_FOUND"] = "E11";
|
|
94
|
+
ErrorCode2["STORE_PERMISSION"] = "E12";
|
|
95
|
+
ErrorCode2["HOSTED_TOKEN_REQUEST_FAILED"] = "E13";
|
|
96
|
+
ErrorCode2["HOSTED_TOKEN_EMPTY"] = "E14";
|
|
96
97
|
return ErrorCode2;
|
|
97
98
|
})(ErrorCode || {});
|
|
98
99
|
const getPublicPath = () => {
|
|
@@ -218,7 +219,11 @@ const build = async function() {
|
|
|
218
219
|
if ((_appPackageJSON$scrip = appPackageJSON.scripts) !== null && _appPackageJSON$scrip !== void 0 && _appPackageJSON$scrip.build) {
|
|
219
220
|
spawnSync("npm", ["run", "build"], {
|
|
220
221
|
cwd: getAppWorkspacePath(),
|
|
221
|
-
stdio: "inherit"
|
|
222
|
+
stdio: "inherit",
|
|
223
|
+
env: {
|
|
224
|
+
...process.env,
|
|
225
|
+
NODE_ENV: "production"
|
|
226
|
+
}
|
|
222
227
|
});
|
|
223
228
|
} else {
|
|
224
229
|
return throwError(ErrorCode.BUILD_SCRIPT_NOT_FOUND, i18n.t("error.build.scriptNotFound"));
|
|
@@ -261,6 +266,13 @@ const build = async function() {
|
|
|
261
266
|
});
|
|
262
267
|
archive.finalize();
|
|
263
268
|
};
|
|
269
|
+
const config = {
|
|
270
|
+
defaultPort: {
|
|
271
|
+
login: 8200,
|
|
272
|
+
tunnel: 8201
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
const getConfig = () => config;
|
|
264
276
|
var InstallOptions = /* @__PURE__ */ ((InstallOptions2) => {
|
|
265
277
|
InstallOptions2["AUTO"] = "auto";
|
|
266
278
|
InstallOptions2["TRUE"] = "true";
|
|
@@ -294,17 +306,51 @@ const dev = async function() {
|
|
|
294
306
|
options
|
|
295
307
|
} = getCommandOptions(args, devCommandArguments);
|
|
296
308
|
const normalizedOptions = await normalize$9(options);
|
|
297
|
-
console.log("dev", normalizedOptions);
|
|
298
309
|
const appPackageJSON = getAppPackageJSON();
|
|
299
|
-
console.log("appPackageJSON", appPackageJSON);
|
|
300
310
|
const appManifestJSON = getAppManifestJSON();
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
} else {
|
|
311
|
+
const appRcJSON = getAppRcJSON();
|
|
312
|
+
noop(appManifestJSON);
|
|
313
|
+
noop(appRcJSON);
|
|
314
|
+
if (!((_appPackageJSON$scrip = appPackageJSON.scripts) !== null && _appPackageJSON$scrip !== void 0 && _appPackageJSON$scrip.dev)) {
|
|
306
315
|
return throwError(ErrorCode.DEV_SCRIPT_NOT_FOUND, i18n.t("error.dev.scriptNotFound"));
|
|
307
316
|
}
|
|
317
|
+
const port = getConfig().defaultPort.tunnel;
|
|
318
|
+
const cwd2 = getAppWorkspacePath();
|
|
319
|
+
const env = {
|
|
320
|
+
...process.env,
|
|
321
|
+
NODE_ENV: "development",
|
|
322
|
+
ONES_HOSTED_PORT: `${port}`
|
|
323
|
+
};
|
|
324
|
+
const tunnelChild = spawn("ones", ["tunnel", String(port)], {
|
|
325
|
+
cwd: cwd2,
|
|
326
|
+
stdio: "inherit"
|
|
327
|
+
});
|
|
328
|
+
const devChild = spawn("npm", ["run", "dev"], {
|
|
329
|
+
cwd: cwd2,
|
|
330
|
+
stdio: "inherit",
|
|
331
|
+
env
|
|
332
|
+
});
|
|
333
|
+
const cleanup = () => {
|
|
334
|
+
tunnelChild.kill();
|
|
335
|
+
devChild.kill();
|
|
336
|
+
};
|
|
337
|
+
const onSignal = () => {
|
|
338
|
+
cleanup();
|
|
339
|
+
process.exit(128 + 2);
|
|
340
|
+
};
|
|
341
|
+
process.on("SIGINT", onSignal);
|
|
342
|
+
process.on("SIGTERM", onSignal);
|
|
343
|
+
if (normalizedOptions.install) {
|
|
344
|
+
noop(normalizedOptions.install);
|
|
345
|
+
}
|
|
346
|
+
await new Promise((resolve2) => {
|
|
347
|
+
devChild.on("exit", () => {
|
|
348
|
+
cleanup();
|
|
349
|
+
process.off("SIGINT", onSignal);
|
|
350
|
+
process.off("SIGTERM", onSignal);
|
|
351
|
+
resolve2();
|
|
352
|
+
});
|
|
353
|
+
});
|
|
308
354
|
};
|
|
309
355
|
const isPortNumber = /^[1-9]\d{0,4}$/;
|
|
310
356
|
const minPortNumber = 1;
|
|
@@ -432,6 +478,7 @@ const setONESToken = async (token) => {
|
|
|
432
478
|
ones_token: token
|
|
433
479
|
});
|
|
434
480
|
};
|
|
481
|
+
const MAX_RELAY_BODY_BYTES = 64 * 1024 * 1024;
|
|
435
482
|
class TunnelClient {
|
|
436
483
|
constructor(localPort, baseUrl, appID, hostedToken) {
|
|
437
484
|
_defineProperty(this, "ws", null);
|
|
@@ -445,7 +492,8 @@ class TunnelClient {
|
|
|
445
492
|
this.ws = new WebSocket(proxyUrl, {
|
|
446
493
|
headers: {
|
|
447
494
|
Authorization: `Bearer ${this.hostedToken}`
|
|
448
|
-
}
|
|
495
|
+
},
|
|
496
|
+
maxPayload: MAX_RELAY_BODY_BYTES
|
|
449
497
|
});
|
|
450
498
|
this.ws.on("message", async (data) => {
|
|
451
499
|
const message = this.parseMessage(data);
|
|
@@ -478,17 +526,17 @@ class TunnelClient {
|
|
|
478
526
|
return url.toString();
|
|
479
527
|
}
|
|
480
528
|
parseMessage(data) {
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
const message = JSON.parse(payload);
|
|
484
|
-
if (!message) {
|
|
485
|
-
return null;
|
|
486
|
-
}
|
|
487
|
-
return message;
|
|
488
|
-
} catch (error) {
|
|
489
|
-
console.error("Invalid tunnel message:", error);
|
|
529
|
+
const buffer = this.toBuffer(data);
|
|
530
|
+
if (!buffer) {
|
|
490
531
|
return null;
|
|
491
532
|
}
|
|
533
|
+
if (buffer.length >= 4) {
|
|
534
|
+
const binary = this.parseBinaryEnvelope(buffer);
|
|
535
|
+
if (binary) {
|
|
536
|
+
return binary;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return this.parseJSONEnvelope(buffer.toString());
|
|
492
540
|
}
|
|
493
541
|
async handleMessage(message) {
|
|
494
542
|
const request = this.getRequestPayload(message);
|
|
@@ -496,7 +544,6 @@ class TunnelClient {
|
|
|
496
544
|
return;
|
|
497
545
|
}
|
|
498
546
|
if (request.path === ONES_CLI_MANIFEST_PATH) {
|
|
499
|
-
var _this$ws5;
|
|
500
547
|
const appManifest = getAppManifestJSON().app;
|
|
501
548
|
const baseURL = await buildTunnelUrl();
|
|
502
549
|
const reply = {
|
|
@@ -512,19 +559,17 @@ class TunnelClient {
|
|
|
512
559
|
}
|
|
513
560
|
}
|
|
514
561
|
};
|
|
515
|
-
|
|
562
|
+
this.sendBinaryEnvelope(reply);
|
|
516
563
|
return;
|
|
517
564
|
}
|
|
518
565
|
try {
|
|
519
|
-
var _this$ws6;
|
|
520
566
|
const response = await this.forwardRequest(request);
|
|
521
567
|
const reply = {
|
|
522
568
|
id: message.id,
|
|
523
569
|
payload: response
|
|
524
570
|
};
|
|
525
|
-
|
|
571
|
+
this.sendBinaryEnvelope(reply);
|
|
526
572
|
} catch (error) {
|
|
527
|
-
var _this$ws7;
|
|
528
573
|
const reply = {
|
|
529
574
|
id: message.id,
|
|
530
575
|
payload: {
|
|
@@ -535,7 +580,7 @@ class TunnelClient {
|
|
|
535
580
|
body: "agent request error"
|
|
536
581
|
}
|
|
537
582
|
};
|
|
538
|
-
|
|
583
|
+
this.sendBinaryEnvelope(reply);
|
|
539
584
|
}
|
|
540
585
|
}
|
|
541
586
|
getRequestPayload(message) {
|
|
@@ -550,43 +595,36 @@ class TunnelClient {
|
|
|
550
595
|
if (payload.query) {
|
|
551
596
|
Object.entries(payload.query).forEach((_ref) => {
|
|
552
597
|
let [key, value] = _ref;
|
|
553
|
-
|
|
598
|
+
if (Array.isArray(value)) {
|
|
599
|
+
value.forEach((item) => {
|
|
600
|
+
url.searchParams.append(key, item);
|
|
601
|
+
});
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
url.searchParams.append(key, value);
|
|
554
605
|
});
|
|
555
606
|
}
|
|
556
|
-
const headers = this.normalizeHeaders(payload.headers);
|
|
557
|
-
const body = this.normalizeBody(payload.body);
|
|
558
607
|
const response = await axios.request({
|
|
559
608
|
url: url.toString(),
|
|
560
609
|
method: payload.method,
|
|
561
|
-
headers,
|
|
562
|
-
data: body,
|
|
563
|
-
responseType: "
|
|
564
|
-
validateStatus: () => true
|
|
610
|
+
headers: payload.headers,
|
|
611
|
+
data: payload.body,
|
|
612
|
+
responseType: "arraybuffer",
|
|
613
|
+
validateStatus: () => true,
|
|
614
|
+
maxBodyLength: MAX_RELAY_BODY_BYTES,
|
|
615
|
+
maxContentLength: MAX_RELAY_BODY_BYTES
|
|
565
616
|
});
|
|
617
|
+
const responseBytes = Buffer.from(response.data);
|
|
566
618
|
return {
|
|
567
619
|
status: response.status,
|
|
568
620
|
headers: this.collectHeaders(response.headers),
|
|
569
|
-
body:
|
|
621
|
+
body: responseBytes
|
|
570
622
|
};
|
|
571
623
|
}
|
|
572
|
-
normalizeHeaders(headers) {
|
|
573
|
-
if (!headers) {
|
|
574
|
-
return void 0;
|
|
575
|
-
}
|
|
576
|
-
const normalized = {};
|
|
577
|
-
Object.entries(headers).forEach((_ref2) => {
|
|
578
|
-
let [key, values] = _ref2;
|
|
579
|
-
if (!values || values.length === 0) {
|
|
580
|
-
return;
|
|
581
|
-
}
|
|
582
|
-
normalized[key] = values.join(",");
|
|
583
|
-
});
|
|
584
|
-
return normalized;
|
|
585
|
-
}
|
|
586
624
|
collectHeaders(headers) {
|
|
587
625
|
const collected = {};
|
|
588
|
-
Object.entries(headers).forEach((
|
|
589
|
-
let [key, value] =
|
|
626
|
+
Object.entries(headers).forEach((_ref2) => {
|
|
627
|
+
let [key, value] = _ref2;
|
|
590
628
|
if (Array.isArray(value)) {
|
|
591
629
|
collected[key] = value.map((item) => String(item));
|
|
592
630
|
return;
|
|
@@ -597,25 +635,96 @@ class TunnelClient {
|
|
|
597
635
|
});
|
|
598
636
|
return collected;
|
|
599
637
|
}
|
|
600
|
-
|
|
638
|
+
sendBinaryEnvelope(envelope) {
|
|
639
|
+
var _this$ws5;
|
|
640
|
+
const encoded = this.encodeBinaryEnvelope(envelope);
|
|
641
|
+
(_this$ws5 = this.ws) === null || _this$ws5 === void 0 || _this$ws5.send(encoded);
|
|
642
|
+
}
|
|
643
|
+
encodeBinaryEnvelope(envelope) {
|
|
644
|
+
var _envelope$payload;
|
|
645
|
+
const payload = (_envelope$payload = envelope.payload) !== null && _envelope$payload !== void 0 ? _envelope$payload : {};
|
|
646
|
+
const body = this.toBodyBuffer(payload.body);
|
|
647
|
+
if (body.length > MAX_RELAY_BODY_BYTES) {
|
|
648
|
+
throw new Error("relay body too large");
|
|
649
|
+
}
|
|
650
|
+
const metaPayload = {
|
|
651
|
+
...payload
|
|
652
|
+
};
|
|
653
|
+
delete metaPayload.body;
|
|
654
|
+
const meta = Buffer.from(JSON.stringify({
|
|
655
|
+
id: envelope.id,
|
|
656
|
+
payload: metaPayload
|
|
657
|
+
}), "utf8");
|
|
658
|
+
const header = Buffer.allocUnsafe(4);
|
|
659
|
+
header.writeUInt32BE(meta.length, 0);
|
|
660
|
+
return Buffer.concat([header, meta, body]);
|
|
661
|
+
}
|
|
662
|
+
toBodyBuffer(body) {
|
|
601
663
|
if (body === void 0 || body === null) {
|
|
602
|
-
return
|
|
664
|
+
return Buffer.alloc(0);
|
|
603
665
|
}
|
|
604
|
-
if (
|
|
666
|
+
if (Buffer.isBuffer(body)) {
|
|
605
667
|
return body;
|
|
606
668
|
}
|
|
607
|
-
|
|
669
|
+
if (body instanceof ArrayBuffer) {
|
|
670
|
+
return Buffer.from(body);
|
|
671
|
+
}
|
|
672
|
+
if (ArrayBuffer.isView(body)) {
|
|
673
|
+
return Buffer.from(body.buffer, body.byteOffset, body.byteLength);
|
|
674
|
+
}
|
|
675
|
+
if (typeof body === "string") {
|
|
676
|
+
return Buffer.from(body, "utf8");
|
|
677
|
+
}
|
|
678
|
+
return Buffer.from(JSON.stringify(body), "utf8");
|
|
608
679
|
}
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
680
|
+
parseBinaryEnvelope(buffer) {
|
|
681
|
+
const metaLength = buffer.readUInt32BE(0);
|
|
682
|
+
if (metaLength <= 0 || 4 + metaLength > buffer.length) {
|
|
683
|
+
return null;
|
|
612
684
|
}
|
|
685
|
+
const metaRaw = buffer.subarray(4, 4 + metaLength).toString("utf8");
|
|
613
686
|
try {
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
687
|
+
const envelope = JSON.parse(metaRaw);
|
|
688
|
+
if (!(envelope !== null && envelope !== void 0 && envelope.payload)) {
|
|
689
|
+
return envelope;
|
|
690
|
+
}
|
|
691
|
+
const body = buffer.subarray(4 + metaLength);
|
|
692
|
+
if (body.length > MAX_RELAY_BODY_BYTES) {
|
|
693
|
+
console.error("Binary tunnel body exceeds size limit");
|
|
694
|
+
return null;
|
|
695
|
+
}
|
|
696
|
+
const payload = envelope.payload;
|
|
697
|
+
payload.body = body;
|
|
698
|
+
return envelope;
|
|
699
|
+
} catch (error) {
|
|
700
|
+
console.error("Invalid binary tunnel message:", error);
|
|
701
|
+
return null;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
parseJSONEnvelope(payload) {
|
|
705
|
+
try {
|
|
706
|
+
const message = JSON.parse(payload);
|
|
707
|
+
if (!message) {
|
|
708
|
+
return null;
|
|
709
|
+
}
|
|
710
|
+
return message;
|
|
711
|
+
} catch (error) {
|
|
712
|
+
console.error("Invalid tunnel message:", error);
|
|
713
|
+
return null;
|
|
617
714
|
}
|
|
618
715
|
}
|
|
716
|
+
toBuffer(data) {
|
|
717
|
+
if (Buffer.isBuffer(data)) {
|
|
718
|
+
return data;
|
|
719
|
+
}
|
|
720
|
+
if (Array.isArray(data)) {
|
|
721
|
+
return Buffer.concat(data);
|
|
722
|
+
}
|
|
723
|
+
if (data instanceof ArrayBuffer) {
|
|
724
|
+
return Buffer.from(data);
|
|
725
|
+
}
|
|
726
|
+
return null;
|
|
727
|
+
}
|
|
619
728
|
}
|
|
620
729
|
const getPath = (path, map2) => {
|
|
621
730
|
var _context;
|
|
@@ -852,13 +961,6 @@ const tunnel = async function() {
|
|
|
852
961
|
const normalizedOptions = await normalize$8(options);
|
|
853
962
|
await invokeTunnel(Number(normalizedOptions.port));
|
|
854
963
|
};
|
|
855
|
-
const config = {
|
|
856
|
-
defaultPort: {
|
|
857
|
-
login: 8200,
|
|
858
|
-
tunnel: 8201
|
|
859
|
-
}
|
|
860
|
-
};
|
|
861
|
-
const getConfig = () => config;
|
|
862
964
|
function createPromise() {
|
|
863
965
|
let resolve2;
|
|
864
966
|
let reject;
|
|
@@ -923,7 +1025,7 @@ const login = async function() {
|
|
|
923
1025
|
const port = await getPort({
|
|
924
1026
|
port: config2.defaultPort.login
|
|
925
1027
|
});
|
|
926
|
-
const uuid =
|
|
1028
|
+
const uuid = v4();
|
|
927
1029
|
const search = new URLSearchParams();
|
|
928
1030
|
search.set("redirect_path", "/developer/cli");
|
|
929
1031
|
search.set("redirect_url", `http://localhost:${port}`);
|
|
@@ -1045,6 +1147,13 @@ const normalize$4 = async (options) => {
|
|
|
1045
1147
|
noop(options);
|
|
1046
1148
|
return {};
|
|
1047
1149
|
};
|
|
1150
|
+
const invokeInstall = async () => {
|
|
1151
|
+
const runnelUrl = await buildTunnelUrl();
|
|
1152
|
+
const result = await fetchAppInstall({
|
|
1153
|
+
manifest_url: `${runnelUrl}${ONES_CLI_MANIFEST_PATH}`
|
|
1154
|
+
});
|
|
1155
|
+
return result;
|
|
1156
|
+
};
|
|
1048
1157
|
const install = async function() {
|
|
1049
1158
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1050
1159
|
args[_key] = arguments[_key];
|
|
@@ -1055,12 +1164,29 @@ const install = async function() {
|
|
|
1055
1164
|
const normalizedOptions = await normalize$4(options);
|
|
1056
1165
|
noop(normalizedOptions);
|
|
1057
1166
|
await invokeTunnel(getConfig().defaultPort.tunnel);
|
|
1058
|
-
const
|
|
1059
|
-
const result = await fetchAppInstall({
|
|
1060
|
-
manifest_url: `${runnelUrl}${ONES_CLI_MANIFEST_PATH}`
|
|
1061
|
-
});
|
|
1167
|
+
const result = await invokeInstall();
|
|
1062
1168
|
if (result.code === "OK") {
|
|
1169
|
+
var _appList$data$0$insta, _appList$data;
|
|
1063
1170
|
console.log("App installed successfully!");
|
|
1171
|
+
const appID = getAppManifestJSON().app.id;
|
|
1172
|
+
const appList = await fetchAppList(appID);
|
|
1173
|
+
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 : "";
|
|
1174
|
+
if (installationID) {
|
|
1175
|
+
var _tokenInfo$org$uuid, _tokenInfo$org, _tokenInfo$teams$0$uu, _tokenInfo$teams, _tokenInfo$org$visibi, _tokenInfo$org2;
|
|
1176
|
+
const tokenInfo = await fetchTokenInfo();
|
|
1177
|
+
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 : "";
|
|
1178
|
+
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 : "";
|
|
1179
|
+
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;
|
|
1180
|
+
const baseURL = await getBaseURL();
|
|
1181
|
+
if (isOrgVisible && orgUUID) {
|
|
1182
|
+
const url = `${baseURL}/project/#/org/${orgUUID}/setting/app_manager/platform_app/${installationID}`;
|
|
1183
|
+
console.log(`See App detail: ${url}`);
|
|
1184
|
+
}
|
|
1185
|
+
if (!isOrgVisible && teamUUID) {
|
|
1186
|
+
const url = `${baseURL}/project/#/team/${teamUUID}/team_setting/app_manager/platform_app/${installationID}`;
|
|
1187
|
+
console.log(`See App detail: ${url}`);
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1064
1190
|
} else {
|
|
1065
1191
|
console.error(result);
|
|
1066
1192
|
}
|
|
@@ -1202,7 +1328,7 @@ const runCommandONES = async () => {
|
|
|
1202
1328
|
const command = ones;
|
|
1203
1329
|
setContext("command", command);
|
|
1204
1330
|
const version = `${getPackageJSON().version}`;
|
|
1205
|
-
command.version(version);
|
|
1331
|
+
command.version(version, "-v, --version");
|
|
1206
1332
|
await command.parse();
|
|
1207
1333
|
};
|
|
1208
1334
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/actions/build/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAAyB,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAE3E,eAAO,MAAM,KAAK,GAAU,GAAG,MAAM,gBAAgB,CAAC,mBAAmB,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/actions/build/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAAyB,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAE3E,eAAO,MAAM,KAAK,GAAU,GAAG,MAAM,gBAAgB,CAAC,mBAAmB,CAAC,uBAiEzE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/actions/dev/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/actions/dev/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAAuB,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAEvE,eAAO,MAAM,GAAG,GAAU,GAAG,MAAM,gBAAgB,CAAC,iBAAiB,CAAC,uBAiErE,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CommandArguments } from '../../common/command';
|
|
2
2
|
import type { InstallCommandOptions } from '../../command';
|
|
3
|
+
export { invokeInstall } from './install';
|
|
3
4
|
export declare const install: (...args: CommandArguments<InstallCommandOptions>) => Promise<void>;
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/actions/install/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/actions/install/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAA2B,qBAAqB,EAAE,MAAM,WAAW,CAAA;AAE/E,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEzC,eAAO,MAAM,OAAO,GAAU,GAAG,MAAM,gBAAgB,CAAC,qBAAqB,CAAC,kBAgC7E,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../../src/actions/install/install.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAE/D,eAAO,MAAM,aAAa,QAAa,OAAO,CAAC,uBAAuB,CAMrE,CAAA"}
|
|
@@ -12,9 +12,12 @@ export declare class TunnelClient {
|
|
|
12
12
|
private handleMessage;
|
|
13
13
|
private getRequestPayload;
|
|
14
14
|
private forwardRequest;
|
|
15
|
-
private normalizeHeaders;
|
|
16
15
|
private collectHeaders;
|
|
17
|
-
private
|
|
18
|
-
private
|
|
16
|
+
private sendBinaryEnvelope;
|
|
17
|
+
private encodeBinaryEnvelope;
|
|
18
|
+
private toBodyBuffer;
|
|
19
|
+
private parseBinaryEnvelope;
|
|
20
|
+
private parseJSONEnvelope;
|
|
21
|
+
private toBuffer;
|
|
19
22
|
}
|
|
20
23
|
//# sourceMappingURL=tunnel-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tunnel-client.d.ts","sourceRoot":"","sources":["../../../../src/actions/tunnel/tunnel-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tunnel-client.d.ts","sourceRoot":"","sources":["../../../../src/actions/tunnel/tunnel-client.ts"],"names":[],"mappings":"AA8BA,qBAAa,YAAY;IACvB,OAAO,CAAC,EAAE,CAAyB;IACnC,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,WAAW,CAAQ;gBAEf,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAO5E,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA+B9B,KAAK,IAAI,IAAI;IAIb,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,YAAY;YAcN,aAAa;IA4C3B,OAAO,CAAC,iBAAiB;YAQX,cAAc;IAiC5B,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,kBAAkB;IAK1B,OAAO,CAAC,oBAAoB;IAc5B,OAAO,CAAC,YAAY;IAmBpB,OAAO,CAAC,mBAAmB;IAyB3B,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,QAAQ;CAYjB"}
|
|
@@ -2,16 +2,17 @@ export declare enum ErrorCode {
|
|
|
2
2
|
UNKNOWN_ERROR = "E00",
|
|
3
3
|
COMMAND_ERROR = "E01",
|
|
4
4
|
TEMPLATE_NOT_FOUND = "E02",
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
MISSING_PROJECT_PATH = "E03",
|
|
6
|
+
MISSING_BASE_URL = "E04",
|
|
7
|
+
MISSING_PORT = "E05",
|
|
8
|
+
INCORRECT_BASE_URL = "E06",
|
|
9
|
+
INCORRECT_PORT = "E07",
|
|
10
|
+
APP_PACKAGE_JSON_PARSE_ERROR = "E08",
|
|
11
|
+
APP_MANIFEST_JSON_PARSE_ERROR = "E09",
|
|
12
|
+
BUILD_SCRIPT_NOT_FOUND = "E10",
|
|
13
|
+
DEV_SCRIPT_NOT_FOUND = "E11",
|
|
14
|
+
STORE_PERMISSION = "E12",
|
|
15
|
+
HOSTED_TOKEN_REQUEST_FAILED = "E13",
|
|
16
|
+
HOSTED_TOKEN_EMPTY = "E14"
|
|
16
17
|
}
|
|
17
18
|
//# sourceMappingURL=enums.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../../src/common/error/enums.ts"],"names":[],"mappings":"AAEA,oBAAY,SAAS;IACnB,aAAa,QAAgC;IAC7C,aAAa,QAAgC;IAC7C,kBAAkB,QAAqC;IACvD,gBAAgB,QAAQ;IACxB,YAAY,QAAQ;IACpB,kBAAkB,QAAQ;IAC1B,cAAc,QAAQ;IACtB,4BAA4B,QAAQ;IACpC,6BAA6B,QAAQ;IACrC,sBAAsB,QAAQ;IAC9B,oBAAoB,QAAQ;IAC5B,gBAAgB,QAAQ;IACxB,2BAA2B,QAAQ;IACnC,kBAAkB,QAAQ;CAC3B"}
|
|
1
|
+
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../../src/common/error/enums.ts"],"names":[],"mappings":"AAEA,oBAAY,SAAS;IACnB,aAAa,QAAgC;IAC7C,aAAa,QAAgC;IAC7C,kBAAkB,QAAqC;IACvD,oBAAoB,QAAuC;IAC3D,gBAAgB,QAAQ;IACxB,YAAY,QAAQ;IACpB,kBAAkB,QAAQ;IAC1B,cAAc,QAAQ;IACtB,4BAA4B,QAAQ;IACpC,6BAA6B,QAAQ;IACrC,sBAAsB,QAAQ;IAC9B,oBAAoB,QAAQ;IAC5B,gBAAgB,QAAQ;IACxB,2BAA2B,QAAQ;IACnC,kBAAkB,QAAQ;CAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/common/request/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAA;AAE/C,MAAM,WAAW,kBAAkB,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,kBAAkB,CAAC,CAAC,CAAC;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAClC;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE;QACL,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/common/request/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAA;AAE/C,MAAM,WAAW,kBAAkB,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,kBAAkB,CAAC,CAAC,CAAC;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAClC;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE;QACL,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,CAAA;IACD,GAAG,CAAC,EAAE;QACJ,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,UAAU,CAAC,EAAE,OAAO,CAAA;KACrB,CAAA;IACD,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,EAAE,CAAA;CACJ;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB;AAED,MAAM,WAAW,wBAAwB;IACvC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,QAAQ,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE;QACL,eAAe,CAAC,EAAE,MAAM,CAAA;KACzB,EAAE,CAAA;CACJ;AAED,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE;QACR,MAAM,CAAC,EAAE,OAAO,CAAA;KACjB,CAAA;CACF;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,CAAC,EAAE,IAAI,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,CAAC,EAAE,IAAI,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,CAAC,EAAE,IAAI,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,CAAC,EAAE,IAAI,CAAA;CACZ,CAAA;AAED,MAAM,WAAW,gBAAgB;IAC/B,CAAC,MAAM,SAAS,kBAAkB,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;CACjF;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAAA;CACpC;AAED,MAAM,WAAW,oBAAoB;IACnC,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAA;CACpE;AAED,MAAM,WAAW,gBAAgB;IAC/B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;CAC/C;AAED,MAAM,WAAW,mBAAmB;IAClC,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;CAClE;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,OAAO,CAAC,yBAAyB,CAAC,CAAA;CACvC;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAAA;CACpC;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAAA;CACrC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ones-open/cli",
|
|
3
|
-
"version": "1.0.1-
|
|
3
|
+
"version": "1.0.1-9456.1922+cb99c856",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"chalk": "^5.0.1",
|
|
63
63
|
"commander": "~9.4.0",
|
|
64
64
|
"cosmiconfig": "^8.3.6",
|
|
65
|
-
"create-ones-app": "1.0.1-
|
|
65
|
+
"create-ones-app": "1.0.1-9456.1922+cb99c856",
|
|
66
66
|
"env-paths": "3.0.0",
|
|
67
67
|
"execa": "^6.1.0",
|
|
68
68
|
"fs-extra": "^11.3.0",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"ws": "^8.18.3",
|
|
76
76
|
"zod": "^3.22.2"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "cb99c8562240b5643fab4a19db12da88ce6d0bcf"
|
|
79
79
|
}
|