@cloudbase/cli 2.7.6 → 2.7.7-alpha.0
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.
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
2
18
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
19
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
20
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
21
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
23
|
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
8
31
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
32
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
33
|
};
|
|
@@ -786,7 +809,8 @@ let CloudRunRunCommand = class CloudRunRunCommand extends common_1.Command {
|
|
|
786
809
|
},
|
|
787
810
|
env: {
|
|
788
811
|
FROM_NODEMON: 'true'
|
|
789
|
-
}
|
|
812
|
+
},
|
|
813
|
+
ext: 'js,mjs,cjs,json,ts,yaml,yml'
|
|
790
814
|
})
|
|
791
815
|
.on('start', () => __awaiter(this, void 0, void 0, function* () {
|
|
792
816
|
logger.info('Initializing server in watch mode. Changes in source files will trigger a restart.');
|
|
@@ -823,7 +847,7 @@ let CloudRunRunCommand = class CloudRunRunCommand extends common_1.Command {
|
|
|
823
847
|
});
|
|
824
848
|
}
|
|
825
849
|
openDebugApp(type, port, envId, agentId, isOpen = true) {
|
|
826
|
-
|
|
850
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
827
851
|
let url = `http://127.0.0.1:${port}/cloudrun-run-ui/index.html?type=${type}&envId=${envId}&port=${port}`;
|
|
828
852
|
if (type === 'agent') {
|
|
829
853
|
url += `&agentId=${agentId}`;
|
|
@@ -832,8 +856,32 @@ let CloudRunRunCommand = class CloudRunRunCommand extends common_1.Command {
|
|
|
832
856
|
else {
|
|
833
857
|
console.log(chalk_1.default.green(`点击 [${url}] 可以打开函数调试面板`));
|
|
834
858
|
}
|
|
835
|
-
|
|
836
|
-
|
|
859
|
+
if (isOpen) {
|
|
860
|
+
yield this.waitForPort(url);
|
|
861
|
+
(0, open_1.default)(url, { wait: false });
|
|
862
|
+
}
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
waitForPort(url, timeout = 10000) {
|
|
866
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
867
|
+
const startTime = Date.now();
|
|
868
|
+
const { default: fetch } = yield Promise.resolve().then(() => __importStar(require('node-fetch')));
|
|
869
|
+
while (Date.now() - startTime < timeout) {
|
|
870
|
+
try {
|
|
871
|
+
const response = yield fetch(url, {
|
|
872
|
+
timeout: 1000,
|
|
873
|
+
method: 'HEAD'
|
|
874
|
+
});
|
|
875
|
+
if (response.ok) {
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
catch (e) {
|
|
880
|
+
}
|
|
881
|
+
yield new Promise((resolve) => setTimeout(resolve, 500));
|
|
882
|
+
}
|
|
883
|
+
throw new Error(`等待服务${url}就绪超时`);
|
|
884
|
+
});
|
|
837
885
|
}
|
|
838
886
|
};
|
|
839
887
|
__decorate([
|
package/package.json
CHANGED