esa-cli 0.0.1-beta.9 → 0.0.2-beta.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.
- package/README.md +4 -6
- package/bin/enter.cjs +0 -1
- package/dist/README.md +4 -6
- package/dist/bin/enter.cjs +0 -1
- package/dist/commands/commit/index.js +2 -2
- package/dist/commands/deploy/index.js +4 -2
- package/dist/commands/deployments/list.js +2 -1
- package/dist/commands/dev/build.js +57 -0
- package/dist/commands/dev/doProcess.js +10 -2
- package/dist/commands/dev/ew2/devEntry.js +9 -0
- package/dist/commands/dev/ew2/devPack.js +185 -0
- package/dist/commands/dev/ew2/mock/cache.js +32 -0
- package/dist/commands/dev/ew2/mock/kv.js +45 -0
- package/dist/commands/dev/ew2/server.js +234 -0
- package/dist/commands/dev/index.js +111 -49
- package/dist/commands/dev/{config → mockWorker}/devEntry.js +3 -2
- package/dist/commands/dev/{devPack.js → mockWorker/devPack.js} +10 -8
- package/dist/commands/dev/{server.js → mockWorker/server.js} +43 -37
- package/dist/commands/init/index.js +117 -42
- package/dist/commands/login/index.js +2 -2
- package/dist/commands/logout.js +0 -4
- package/dist/commands/route/list.js +2 -1
- package/dist/commands/routine/list.js +6 -4
- package/dist/components/mutiLevelSelect.js +69 -0
- package/dist/i18n/locales.json +120 -4
- package/dist/index.js +8 -0
- package/dist/libs/api.js +155 -0
- package/dist/libs/logger.js +42 -31
- package/dist/libs/service.js +178 -0
- package/dist/package.json +13 -5
- package/dist/utils/checkDevPort.js +19 -14
- package/dist/utils/checkOS.js +32 -0
- package/dist/utils/fileMd5.js +18 -0
- package/dist/utils/fileUtils/index.js +1 -1
- package/dist/utils/install/installEw2.sh +33 -0
- package/dist/utils/{installRuntime.js → installDeno.js} +15 -15
- package/dist/utils/installEw2.js +127 -0
- package/dist/utils/stepsRunner.js +33 -0
- package/dist/zh_CN.md +4 -5
- package/package.json +13 -5
- package/dist/commands/dev/config/devBuild.js +0 -26
- package/dist/libs/request.js +0 -98
- /package/dist/commands/dev/{config → mockWorker}/mock/cache.js +0 -0
- /package/dist/commands/dev/{config → mockWorker}/mock/kv.js +0 -0
package/dist/libs/request.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import fetch, { Headers } from 'node-fetch';
|
|
11
|
-
class HttpRequest {
|
|
12
|
-
constructor(defaultHeaders = {
|
|
13
|
-
'Content-Type': 'application/json'
|
|
14
|
-
}, timeout = 15000, retryCount = 3) {
|
|
15
|
-
this.defaultHeaders = new Headers(defaultHeaders);
|
|
16
|
-
this.timeout = timeout;
|
|
17
|
-
this.retryCount = retryCount;
|
|
18
|
-
}
|
|
19
|
-
static getInstance(defaultHeaders, timeout, retryCount) {
|
|
20
|
-
if (!HttpRequest.instance) {
|
|
21
|
-
HttpRequest.instance = new HttpRequest(defaultHeaders, timeout, retryCount);
|
|
22
|
-
Object.freeze(HttpRequest.instance);
|
|
23
|
-
}
|
|
24
|
-
return HttpRequest.instance;
|
|
25
|
-
}
|
|
26
|
-
fetchWithTimeout(url_1) {
|
|
27
|
-
return __awaiter(this, arguments, void 0, function* (url, options = {}) {
|
|
28
|
-
const controller = new AbortController();
|
|
29
|
-
const id = setTimeout(() => controller.abort(), this.timeout);
|
|
30
|
-
options.signal = controller.signal;
|
|
31
|
-
try {
|
|
32
|
-
return yield fetch(url, options);
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
throw new Error(`请求超时或失败: ${error.message}`);
|
|
36
|
-
}
|
|
37
|
-
finally {
|
|
38
|
-
clearTimeout(id);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
fetchWithRetry(url_1) {
|
|
43
|
-
return __awaiter(this, arguments, void 0, function* (url, options = {}) {
|
|
44
|
-
for (let attempt = 1; attempt <= this.retryCount; attempt++) {
|
|
45
|
-
try {
|
|
46
|
-
const response = yield this.fetchWithTimeout(url, options);
|
|
47
|
-
if (response.ok) {
|
|
48
|
-
return response;
|
|
49
|
-
}
|
|
50
|
-
throw new Error(`服务器响应错误: ${response.status} ${response.statusText}`);
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
if (attempt === this.retryCount) {
|
|
54
|
-
throw error;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
throw new Error('达到最大重试次数');
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
get(url, headers) {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
try {
|
|
64
|
-
const response = yield this.fetchWithRetry(url, {
|
|
65
|
-
method: 'GET',
|
|
66
|
-
headers: headers
|
|
67
|
-
? new Headers(Object.assign(Object.assign({}, this.defaultHeaders), headers))
|
|
68
|
-
: this.defaultHeaders
|
|
69
|
-
});
|
|
70
|
-
return yield response.json();
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
console.error(`GET请求错误: ${error.message}`);
|
|
74
|
-
throw error;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
post(url, data, headers) {
|
|
79
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
try {
|
|
81
|
-
const response = yield this.fetchWithRetry(url, {
|
|
82
|
-
method: 'POST',
|
|
83
|
-
body: JSON.stringify(data),
|
|
84
|
-
headers: headers
|
|
85
|
-
? new Headers(Object.assign(Object.assign({}, this.defaultHeaders), headers))
|
|
86
|
-
: this.defaultHeaders
|
|
87
|
-
});
|
|
88
|
-
return yield response.json();
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
console.error(`POST请求错误: ${error.message}`);
|
|
92
|
-
throw error;
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
const request = HttpRequest.getInstance();
|
|
98
|
-
export default request;
|
|
File without changes
|
|
File without changes
|