@dainprotocol/cli 1.2.26 → 1.2.28
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/__tests__/deploy.test.js +143 -0
- package/dist/__tests__/dev.test.js +132 -0
- package/dist/__tests__/integration.test.js +151 -0
- package/dist/__tests__/logs.test.js +135 -0
- package/dist/commands/deploy.js +116 -90
- package/dist/commands/dev.js +143 -128
- package/dist/commands/logs.js +99 -28
- package/dist/commands/status.js +43 -10
- package/dist/commands/undeploy.js +48 -19
- package/dist/index.js +0 -0
- package/package.json +12 -5
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -42,6 +53,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
53
|
exports.default = undeploy;
|
|
43
54
|
var utils_1 = require("../utils");
|
|
44
55
|
var ora_1 = __importDefault(require("ora"));
|
|
56
|
+
var FETCH_TIMEOUT_MS = 30000;
|
|
57
|
+
function fetchWithTimeout(url_1, options_1) {
|
|
58
|
+
return __awaiter(this, arguments, void 0, function (url, options, timeoutMs) {
|
|
59
|
+
var controller, timeoutId, response;
|
|
60
|
+
if (timeoutMs === void 0) { timeoutMs = FETCH_TIMEOUT_MS; }
|
|
61
|
+
return __generator(this, function (_a) {
|
|
62
|
+
switch (_a.label) {
|
|
63
|
+
case 0:
|
|
64
|
+
controller = new AbortController();
|
|
65
|
+
timeoutId = setTimeout(function () { return controller.abort(); }, timeoutMs);
|
|
66
|
+
_a.label = 1;
|
|
67
|
+
case 1:
|
|
68
|
+
_a.trys.push([1, , 3, 4]);
|
|
69
|
+
return [4 /*yield*/, fetch(url, __assign(__assign({}, options), { signal: controller.signal }))];
|
|
70
|
+
case 2:
|
|
71
|
+
response = _a.sent();
|
|
72
|
+
return [2 /*return*/, response];
|
|
73
|
+
case 3:
|
|
74
|
+
clearTimeout(timeoutId);
|
|
75
|
+
return [7 /*endfinally*/];
|
|
76
|
+
case 4: return [2 /*return*/];
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
45
81
|
function undeploy(options) {
|
|
46
82
|
return __awaiter(this, void 0, void 0, function () {
|
|
47
83
|
var config, spinner, orgId, _a, apiKey, deploymentId, undeployUrl, response, error_1;
|
|
@@ -52,41 +88,35 @@ function undeploy(options) {
|
|
|
52
88
|
spinner = (0, ora_1.default)("Undeploying deployment ".concat(config["deployment-id"], "...")).start();
|
|
53
89
|
_b.label = 1;
|
|
54
90
|
case 1:
|
|
55
|
-
_b.trys.push([1, 3,
|
|
91
|
+
_b.trys.push([1, 3, , 4]);
|
|
56
92
|
orgId = "hackathon";
|
|
57
93
|
_a = initializeConfig(config, orgId), apiKey = _a.apiKey, deploymentId = _a.deploymentId, undeployUrl = _a.undeployUrl;
|
|
58
|
-
if (!
|
|
59
|
-
(0, utils_1.logError)("
|
|
60
|
-
|
|
94
|
+
if (!deploymentId) {
|
|
95
|
+
(0, utils_1.logError)("Deployment ID not found");
|
|
96
|
+
process.exit(1);
|
|
61
97
|
}
|
|
62
|
-
return [4 /*yield*/,
|
|
98
|
+
return [4 /*yield*/, fetchWithTimeout(undeployUrl, {
|
|
63
99
|
method: "DELETE",
|
|
64
100
|
headers: {
|
|
65
101
|
"Content-Type": "application/json",
|
|
66
|
-
"X-DAIN-SIGNATORY-ADDRESS": "TODO: X-DAIN-SIGNATORY-ADDRESS",
|
|
67
|
-
"X-DAIN-SIGNATURE": "TODO: X-DAIN-SIGNATORY-SIGNATURE",
|
|
68
102
|
Authorization: "Bearer ".concat(apiKey),
|
|
69
103
|
},
|
|
70
104
|
})];
|
|
71
105
|
case 2:
|
|
72
106
|
response = _b.sent();
|
|
73
107
|
if (!response.ok) {
|
|
74
|
-
throw new Error("Undeployment failed: ".concat(response.statusText));
|
|
108
|
+
throw new Error("Undeployment failed: ".concat(response.status, " ").concat(response.statusText));
|
|
75
109
|
}
|
|
76
110
|
spinner.succeed("Undeployment completed successfully.");
|
|
77
|
-
|
|
78
|
-
return [3 /*break*/,
|
|
111
|
+
process.exit(0);
|
|
112
|
+
return [3 /*break*/, 4];
|
|
79
113
|
case 3:
|
|
80
114
|
error_1 = _b.sent();
|
|
81
115
|
spinner.fail("Failed to undeploy project.");
|
|
82
116
|
(0, utils_1.logError)("Error during undeployment", error_1);
|
|
83
117
|
process.exit(1);
|
|
84
|
-
return [3 /*break*/,
|
|
85
|
-
case 4:
|
|
86
|
-
spinner.stop();
|
|
87
|
-
process.exit(0);
|
|
88
|
-
return [7 /*endfinally*/];
|
|
89
|
-
case 5: return [2 /*return*/];
|
|
118
|
+
return [3 /*break*/, 4];
|
|
119
|
+
case 4: return [2 /*return*/];
|
|
90
120
|
}
|
|
91
121
|
});
|
|
92
122
|
});
|
|
@@ -94,10 +124,9 @@ function undeploy(options) {
|
|
|
94
124
|
var initializeConfig = function (config, orgId) {
|
|
95
125
|
var baseUrl = config["platform-base-url"] || "https://codegen-deploy-service.dainapp.com/";
|
|
96
126
|
var apiKey = config["api-key"];
|
|
97
|
-
var orgIdToBeUsed = orgId || (0, utils_1.extractOrgId)(apiKey);
|
|
98
127
|
var deploymentId = config["deployment-id"];
|
|
99
128
|
var environment = config["environment"];
|
|
100
129
|
var serviceId = config["service-id"];
|
|
101
|
-
var undeployUrl = "".concat(baseUrl, "/codegen-deploy/undeploy/").concat(
|
|
102
|
-
return {
|
|
130
|
+
var undeployUrl = "".concat(baseUrl, "/codegen-deploy/undeploy/").concat(orgId, "/").concat(serviceId, "/").concat(deploymentId, "/").concat(environment);
|
|
131
|
+
return { apiKey: apiKey, deploymentId: deploymentId, undeployUrl: undeployUrl };
|
|
103
132
|
};
|
package/dist/index.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dainprotocol/cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.28",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -10,6 +10,13 @@
|
|
|
10
10
|
"bin": {
|
|
11
11
|
"dain": "./dist/index.js"
|
|
12
12
|
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc && cp -r templates dist/",
|
|
15
|
+
"test": "jest",
|
|
16
|
+
"test:watch": "jest --watch",
|
|
17
|
+
"test:coverage": "jest --coverage",
|
|
18
|
+
"prepublishOnly": "pnpm run build && pnpm test"
|
|
19
|
+
},
|
|
13
20
|
"files": [
|
|
14
21
|
"dist",
|
|
15
22
|
"README.md"
|
|
@@ -34,11 +41,11 @@
|
|
|
34
41
|
},
|
|
35
42
|
"devDependencies": {
|
|
36
43
|
"@types/archiver": "^6.0.3",
|
|
44
|
+
"@types/jest": "^30.0.0",
|
|
37
45
|
"@types/node": "^22.5.4",
|
|
46
|
+
"jest": "^30.2.0",
|
|
47
|
+
"ts-jest": "^29.4.6",
|
|
38
48
|
"ts-node": "^10.9.2",
|
|
39
49
|
"typescript": "^5.9.3"
|
|
40
|
-
},
|
|
41
|
-
"scripts": {
|
|
42
|
-
"build": "tsc && cp -r templates dist/"
|
|
43
50
|
}
|
|
44
|
-
}
|
|
51
|
+
}
|