esa-cli 0.0.2-beta.10 → 0.0.2-beta.13

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.
Files changed (75) hide show
  1. package/dist/commands/commit/index.js +26 -115
  2. package/dist/commands/commit/prodBuild.js +2 -3
  3. package/dist/commands/common/routineUtils.js +276 -0
  4. package/dist/commands/config.js +1 -1
  5. package/dist/commands/deploy/helper.js +40 -61
  6. package/dist/commands/deploy/index.js +90 -188
  7. package/dist/commands/deployments/delete.js +32 -22
  8. package/dist/commands/deployments/index.js +2 -2
  9. package/dist/commands/deployments/list.js +22 -38
  10. package/dist/commands/dev/build.js +3 -3
  11. package/dist/commands/dev/doProcess.js +5 -5
  12. package/dist/commands/dev/ew2/cacheService.js +33 -0
  13. package/dist/commands/dev/ew2/devEntry.js +2 -1
  14. package/dist/commands/dev/ew2/devPack.js +22 -11
  15. package/dist/commands/dev/ew2/kvService.js +27 -0
  16. package/dist/commands/dev/ew2/mock/cache.js +99 -15
  17. package/dist/commands/dev/ew2/mock/kv.js +142 -21
  18. package/dist/commands/dev/ew2/server.js +162 -27
  19. package/dist/commands/dev/index.js +14 -15
  20. package/dist/commands/dev/mockWorker/devPack.js +16 -7
  21. package/dist/commands/dev/mockWorker/server.js +7 -6
  22. package/dist/commands/domain/add.js +2 -2
  23. package/dist/commands/domain/delete.js +7 -7
  24. package/dist/commands/domain/index.js +2 -2
  25. package/dist/commands/domain/list.js +10 -10
  26. package/dist/commands/init/helper.js +87 -13
  27. package/dist/commands/init/index.js +461 -57
  28. package/dist/commands/init/template.jsonc +34 -0
  29. package/dist/commands/lang.js +2 -2
  30. package/dist/commands/login/index.js +57 -7
  31. package/dist/commands/logout.js +5 -5
  32. package/dist/commands/route/add.js +138 -49
  33. package/dist/commands/route/delete.js +33 -27
  34. package/dist/commands/route/helper.js +124 -0
  35. package/dist/commands/route/index.js +2 -2
  36. package/dist/commands/route/list.js +56 -17
  37. package/dist/commands/routine/delete.js +2 -2
  38. package/dist/commands/routine/index.js +2 -2
  39. package/dist/commands/routine/list.js +9 -21
  40. package/dist/commands/site/index.js +1 -1
  41. package/dist/commands/site/list.js +6 -7
  42. package/dist/commands/utils.js +55 -19
  43. package/dist/components/descriptionInput.js +1 -1
  44. package/dist/components/mutiSelectTable.js +1 -1
  45. package/dist/components/selectInput.js +2 -3
  46. package/dist/components/selectItem.js +1 -1
  47. package/dist/docs/Commands_en.md +25 -15
  48. package/dist/docs/Commands_zh_CN.md +12 -2
  49. package/dist/docs/eslint-config-en.md +1 -0
  50. package/dist/docs/eslint-config.md +73 -0
  51. package/dist/docs/init-command-quick-test.md +208 -0
  52. package/dist/docs/init-command-test-guide.md +598 -0
  53. package/dist/i18n/index.js +2 -2
  54. package/dist/i18n/locales.json +261 -17
  55. package/dist/index.js +17 -12
  56. package/dist/libs/api.js +32 -9
  57. package/dist/libs/apiService.js +258 -85
  58. package/dist/libs/git/index.js +8 -4
  59. package/dist/libs/interface.js +0 -1
  60. package/dist/libs/logger.js +63 -7
  61. package/dist/libs/service.js +2 -2
  62. package/dist/libs/templates/index.js +1 -1
  63. package/dist/utils/checkAssetsExist.js +80 -0
  64. package/dist/utils/checkDevPort.js +3 -17
  65. package/dist/utils/checkEntryFileExist.js +10 -0
  66. package/dist/utils/checkIsRoutineCreated.js +16 -31
  67. package/dist/utils/checkVersion.js +1 -1
  68. package/dist/utils/compress.js +80 -0
  69. package/dist/utils/download.js +5 -5
  70. package/dist/utils/fileMd5.js +1 -1
  71. package/dist/utils/fileUtils/index.js +71 -22
  72. package/dist/utils/installDeno.js +3 -3
  73. package/dist/utils/installEw2.js +7 -7
  74. package/dist/utils/openInBrowser.js +1 -1
  75. package/package.json +11 -6
@@ -8,15 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import * as http from 'http';
11
+ import chalk from 'chalk';
11
12
  import spawn from 'cross-spawn';
13
+ import { HttpProxyAgent } from 'http-proxy-agent';
12
14
  import fetch from 'node-fetch';
15
+ import t from '../../../i18n/index.js';
13
16
  import logger from '../../../libs/logger.js';
14
17
  import { getRoot } from '../../../utils/fileUtils/base.js';
15
18
  import { EW2BinPath } from '../../../utils/installEw2.js';
16
- import { HttpProxyAgent } from 'http-proxy-agent';
17
- import chalk from 'chalk';
18
- import t from '../../../i18n/index.js';
19
19
  import sleep from '../../../utils/sleep.js';
20
+ import CacheService from './cacheService.js';
21
+ import EdgeKV from './kvService.js';
20
22
  const getColorForStatusCode = (statusCode, message) => {
21
23
  if (statusCode >= 100 && statusCode < 200) {
22
24
  return chalk.blue(`${statusCode} ${message}`);
@@ -40,6 +42,8 @@ const getColorForStatusCode = (statusCode, message) => {
40
42
  class Ew2Server {
41
43
  constructor(props) {
42
44
  this.worker = null;
45
+ this.cache = null;
46
+ this.kv = null;
43
47
  this.startingWorker = false;
44
48
  this.workerStartTimeout = undefined;
45
49
  this.server = null;
@@ -57,6 +61,8 @@ class Ew2Server {
57
61
  return __awaiter(this, void 0, void 0, function* () {
58
62
  this.startingWorker = true;
59
63
  const result = yield this.openEdgeWorker();
64
+ this.cache = new CacheService();
65
+ this.kv = new EdgeKV();
60
66
  if (!result) {
61
67
  throw new Error('Worker start failed');
62
68
  }
@@ -81,8 +87,9 @@ class Ew2Server {
81
87
  stdio: ['pipe', 'pipe', 'pipe']
82
88
  });
83
89
  this.workerStartTimeout = setTimeout(() => {
90
+ var _a;
84
91
  reject(new Error(t('dev_worker_timeout').d('Worker start timeout')));
85
- this.worker && this.worker.kill();
92
+ (_a = this.worker) === null || _a === void 0 ? void 0 : _a.kill();
86
93
  }, 60000);
87
94
  const sendToRuntime = () => {
88
95
  return new Promise((resolveStart) => {
@@ -96,7 +103,7 @@ class Ew2Server {
96
103
  const req = http.get(options, (res) => {
97
104
  resolveStart(res.statusCode);
98
105
  });
99
- req.on('error', (err) => {
106
+ req.on('error', () => {
100
107
  resolveStart(null);
101
108
  });
102
109
  req.end();
@@ -119,7 +126,8 @@ class Ew2Server {
119
126
  this.worker.on('close', this.closeHandler.bind(this));
120
127
  this.worker.on('error', this.errorHandler.bind(this));
121
128
  process.on('SIGTERM', () => {
122
- this.worker && this.worker.kill();
129
+ var _a;
130
+ (_a = this.worker) === null || _a === void 0 ? void 0 : _a.kill();
123
131
  });
124
132
  });
125
133
  }
@@ -128,37 +136,60 @@ class Ew2Server {
128
136
  }
129
137
  createServer() {
130
138
  this.server = http.createServer((req, res) => __awaiter(this, void 0, void 0, function* () {
139
+ var _a, _b, _c;
140
+ if (req.url === '/favicon.ico') {
141
+ res.writeHead(204, {
142
+ 'Content-Type': 'image/x-icon',
143
+ 'Content-Length': 0
144
+ });
145
+ return res.end();
146
+ }
147
+ if ((_a = req.url) === null || _a === void 0 ? void 0 : _a.includes('/mock_cache')) {
148
+ const cacheResult = yield this.handleCache(req);
149
+ return res.end(JSON.stringify(cacheResult));
150
+ }
151
+ if ((_b = req.url) === null || _b === void 0 ? void 0 : _b.includes('/mock_kv')) {
152
+ const kvResult = yield this.handleKV(req);
153
+ if ((_c = req.url) === null || _c === void 0 ? void 0 : _c.includes('/get')) {
154
+ if (kvResult.success) {
155
+ return res.end(kvResult.value);
156
+ }
157
+ else {
158
+ res.setHeader('Kv-Get-Empty', 'true');
159
+ return res.end();
160
+ }
161
+ }
162
+ else {
163
+ return res.end(JSON.stringify(kvResult));
164
+ }
165
+ }
131
166
  try {
132
167
  const host = req.headers.host;
133
168
  const url = req.url;
169
+ const method = req.method;
170
+ const headers = Object.entries(req.headers).reduce((acc, [key, value]) => {
171
+ if (Array.isArray(value)) {
172
+ acc[key] = value.join(', ');
173
+ }
174
+ else {
175
+ acc[key] = value;
176
+ }
177
+ return acc;
178
+ }, {});
134
179
  // @ts-ignore
135
180
  const ew2Port = global.ew2Port;
136
181
  // @ts-ignore
137
182
  const localUpstream = global.localUpstream;
138
183
  const workerRes = yield fetch(`http://${localUpstream ? localUpstream : host}${url}`, {
139
- method: 'GET',
140
- headers: {
141
- 'x-er-context': 'eyJzaXRlX2lkIjogIjYyMjcxODQ0NjgwNjA4IiwgInNpdGVfbmFtZSI6ICJjb21wdXRlbHguYWxpY2RuLXRlc3QuY29tIiwgInNpdGVfcmVjb3JkIjogIm1vY2hlbi1uY2RuLmNvbXB1dGVseC5hbGljZG4tdGVzdC5jb20iLCAiYWxpdWlkIjogIjEzMjI0OTI2ODY2NjU2MDgiLCAic2NoZW1lIjoiaHR0cCIsICAiaW1hZ2VfZW5hYmxlIjogdHJ1ZX0=',
142
- 'x-er-id': 'a.bA'
143
- },
184
+ method,
185
+ headers: Object.assign(Object.assign({}, headers), { 'x-er-context': 'eyJzaXRlX2lkIjogIjYyMjcxODQ0NjgwNjA4IiwgInNpdGVfbmFtZSI6ICJjb21wdXRlbHguYWxpY2RuLXRlc3QuY29tIiwgInNpdGVfcmVjb3JkIjogIm1vY2hlbi1uY2RuLmNvbXB1dGVseC5hbGljZG4tdGVzdC5jb20iLCAiYWxpdWlkIjogIjEzMjI0OTI2ODY2NjU2MDgiLCAic2NoZW1lIjoiaHR0cCIsICAiaW1hZ2VfZW5hYmxlIjogdHJ1ZX0=', 'x-er-id': 'a.bA' }),
186
+ body: req.method === 'GET' ? undefined : req,
144
187
  agent: new HttpProxyAgent(`http://127.0.0.1:${ew2Port}`)
145
188
  });
146
189
  const workerHeaders = Object.fromEntries(workerRes.headers.entries());
147
190
  // 解决 gzip 兼容性问题,防止net::ERR_CONTENT_DECODING_FAILED
148
191
  workerHeaders['content-encoding'] = 'identity';
149
192
  if (workerRes.body) {
150
- // if (workerRes.headers.get('content-type')?.includes('text/')) {
151
- // const text = await workerRes.text();
152
- // // 出现换行符之类会导致 content-length 不一致
153
- // workerHeaders['content-length'] =
154
- // Buffer.byteLength(text).toString();
155
- // console.log(workerHeaders['content-length']);
156
- // res.writeHead(workerRes.status, workerHeaders);
157
- // res.end(text);
158
- // } else {
159
- // res.writeHead(workerRes.status, workerHeaders);
160
- // workerRes.body.pipe(res);
161
- // }
162
193
  res.writeHead(workerRes.status, workerHeaders);
163
194
  workerRes.body.pipe(res);
164
195
  logger.log(`[ESA Dev] ${req.method} ${url} ${getColorForStatusCode(workerRes.status, workerRes.statusText)}`);
@@ -176,6 +207,65 @@ class Ew2Server {
176
207
  logger.log(`listening on port ${this.port}`);
177
208
  });
178
209
  }
210
+ handleCache(req) {
211
+ return __awaiter(this, void 0, void 0, function* () {
212
+ var _a, _b, _c, _d, _e, _f;
213
+ const body = yield this.parseCacheBody(req);
214
+ if ((_a = req.url) === null || _a === void 0 ? void 0 : _a.includes('/put')) {
215
+ (_b = this.cache) === null || _b === void 0 ? void 0 : _b.put(body.key, body);
216
+ return { success: true };
217
+ }
218
+ if ((_c = req.url) === null || _c === void 0 ? void 0 : _c.includes('/get')) {
219
+ const res = (_d = this.cache) === null || _d === void 0 ? void 0 : _d.get(body.key);
220
+ if (!res) {
221
+ return { success: false, key: body.key };
222
+ }
223
+ return { success: true, key: body.key, data: res === null || res === void 0 ? void 0 : res.serializedResponse };
224
+ }
225
+ if ((_e = req.url) === null || _e === void 0 ? void 0 : _e.includes('/delete')) {
226
+ const res = (_f = this.cache) === null || _f === void 0 ? void 0 : _f.delete(body.key);
227
+ return { success: !!res };
228
+ }
229
+ return { success: false };
230
+ });
231
+ }
232
+ handleKV(req) {
233
+ return __awaiter(this, void 0, void 0, function* () {
234
+ var _a, _b, _c, _d, _e, _f;
235
+ const url = new URL(req.url, 'http://localhost');
236
+ const key = url.searchParams.get('key');
237
+ const namespace = url.searchParams.get('namespace');
238
+ const body = yield this.parseKVBody(req);
239
+ if (!key || !namespace) {
240
+ return {
241
+ success: false
242
+ };
243
+ }
244
+ if ((_a = req.url) === null || _a === void 0 ? void 0 : _a.includes('/put')) {
245
+ (_b = this.kv) === null || _b === void 0 ? void 0 : _b.put(key, body, namespace);
246
+ return {
247
+ success: true
248
+ };
249
+ }
250
+ if ((_c = req.url) === null || _c === void 0 ? void 0 : _c.includes('/get')) {
251
+ const res = (_d = this.kv) === null || _d === void 0 ? void 0 : _d.get(key, namespace);
252
+ const params = { success: true, value: res };
253
+ if (!res) {
254
+ params.success = false;
255
+ }
256
+ return params;
257
+ }
258
+ if ((_e = req.url) === null || _e === void 0 ? void 0 : _e.includes('/delete')) {
259
+ const res = (_f = this.kv) === null || _f === void 0 ? void 0 : _f.delete(key, namespace);
260
+ return {
261
+ success: res
262
+ };
263
+ }
264
+ return {
265
+ success: false
266
+ };
267
+ });
268
+ }
179
269
  stdoutHandler(chunk) {
180
270
  logger.log(`${chalk.bgGreen('[Worker]')} ${chunk.toString().trim()}`);
181
271
  }
@@ -189,17 +279,60 @@ class Ew2Server {
189
279
  }
190
280
  this.stop();
191
281
  }
192
- closeHandler(code, signal) {
282
+ closeHandler() {
193
283
  if (this.restarting) {
194
284
  this.restarting = false;
195
285
  return;
196
286
  }
197
287
  this.stop().then(() => {
288
+ var _a;
198
289
  logger.log(t('dev_server_closed').d('Worker server closed'));
199
290
  logger.info('Worker server closed');
200
291
  // @ts-ignore
201
292
  global.port = undefined;
202
- this.onClose && this.onClose();
293
+ (_a = this.onClose) === null || _a === void 0 ? void 0 : _a.call(this);
294
+ });
295
+ }
296
+ parseCacheBody(req) {
297
+ return new Promise((resolve, reject) => {
298
+ const chunks = [];
299
+ let totalLength = 0;
300
+ req.on('data', (chunk) => {
301
+ chunks.push(chunk);
302
+ totalLength += chunk.length;
303
+ });
304
+ req.on('end', () => {
305
+ try {
306
+ const buffer = Buffer.concat(chunks, totalLength);
307
+ const rawBody = buffer.toString('utf8');
308
+ resolve(rawBody ? JSON.parse(rawBody) : {});
309
+ }
310
+ catch (err) {
311
+ reject(new Error(`Invalid JSON: ${err.message}`));
312
+ }
313
+ });
314
+ req.on('error', reject);
315
+ });
316
+ }
317
+ parseKVBody(req) {
318
+ return new Promise((resolve, reject) => {
319
+ const chunks = [];
320
+ let totalLength = 0;
321
+ req.on('data', (chunk) => {
322
+ chunks.push(chunk);
323
+ totalLength += chunk.length;
324
+ });
325
+ req.on('end', () => {
326
+ try {
327
+ const buffer = Buffer.concat(chunks, totalLength);
328
+ const rawBody = buffer.toString();
329
+ resolve(rawBody);
330
+ }
331
+ catch (err) {
332
+ reject(new Error(`Invalid JSON: ${err.message}`));
333
+ }
334
+ });
335
+ req.on('error', reject);
203
336
  });
204
337
  }
205
338
  runCommand(command) {
@@ -213,7 +346,7 @@ class Ew2Server {
213
346
  resolve(false);
214
347
  return;
215
348
  }
216
- const onExit = (code, signal) => {
349
+ const onExit = () => {
217
350
  this.worker = null;
218
351
  resolve(true);
219
352
  };
@@ -222,10 +355,12 @@ class Ew2Server {
222
355
  (_a = this.server) === null || _a === void 0 ? void 0 : _a.close();
223
356
  });
224
357
  }
225
- restart() {
358
+ restart(devPack) {
226
359
  return __awaiter(this, void 0, void 0, function* () {
227
360
  this.restarting = true;
361
+ console.clear();
228
362
  yield this.stop();
363
+ yield devPack();
229
364
  this.start();
230
365
  logger.log(t('dev_server_restart').d('Worker server restarted'));
231
366
  logger.info('Worker server restarted');
@@ -10,21 +10,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { exec } from 'child_process';
11
11
  import { isIP } from 'net';
12
12
  import chokidar from 'chokidar';
13
- import doProcess from './doProcess.js';
14
- import { getProjectConfig, generateConfigFile, getDevConf } from '../../utils/fileUtils/index.js';
15
- import { getRoot } from '../../utils/fileUtils/base.js';
16
13
  import SelectItems from '../../components/selectInput.js';
17
- import logger from '../../libs/logger.js';
18
- import MockServer from './mockWorker/server.js';
19
- import mockPack from './mockWorker/devPack.js';
20
- import Ew2Server from './ew2/server.js';
21
- import ew2Pack from './ew2/devPack.js';
22
- import { preCheckDeno } from '../../utils/installDeno.js';
23
- import { preCheckEw2 } from '../../utils/installEw2.js';
24
- import debounce from '../../utils/debounce.js';
25
14
  import t from '../../i18n/index.js';
15
+ import logger from '../../libs/logger.js';
26
16
  import checkAndInputPort from '../../utils/checkDevPort.js';
27
17
  import { checkOS, Platforms } from '../../utils/checkOS.js';
18
+ import debounce from '../../utils/debounce.js';
19
+ import { getRoot } from '../../utils/fileUtils/base.js';
20
+ import { getProjectConfig, generateConfigFile, getDevConf } from '../../utils/fileUtils/index.js';
21
+ import { preCheckDeno } from '../../utils/installDeno.js';
22
+ import { preCheckEw2 } from '../../utils/installEw2.js';
23
+ import doProcess from './doProcess.js';
24
+ import ew2Pack from './ew2/devPack.js';
25
+ import Ew2Server from './ew2/server.js';
26
+ import mockPack from './mockWorker/devPack.js';
27
+ import MockServer from './mockWorker/server.js';
28
28
  let yargsIns;
29
29
  const OS = checkOS();
30
30
  const EW2OS = [Platforms.AppleArm, Platforms.AppleIntel, Platforms.LinuxX86];
@@ -203,7 +203,7 @@ const dev = {
203
203
  userFileRepacking = false;
204
204
  return;
205
205
  }
206
- worker.restart();
206
+ worker.restart(devPack);
207
207
  return;
208
208
  }
209
209
  logger.info('Dev repack');
@@ -215,14 +215,13 @@ const dev = {
215
215
  catch (err) { }
216
216
  }
217
217
  userFileRepacking = true;
218
- yield devPack();
219
- yield worker.restart();
218
+ yield worker.restart(devPack);
220
219
  }), 500));
221
220
  var { devElement, exit } = doProcess(worker);
222
221
  const { waitUntilExit } = devElement;
223
222
  yield waitUntilExit();
224
223
  function onWorkerClosed() {
225
- exit && exit();
224
+ exit === null || exit === void 0 ? void 0 : exit();
226
225
  }
227
226
  watcher.close();
228
227
  })
@@ -7,14 +7,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import path from 'path';
11
10
  import fs from 'fs';
12
- import logger from '../../../libs/logger.js';
13
- import devBuild from '../build.js';
11
+ import path from 'path';
14
12
  import t from '../../../i18n/index.js';
15
- import { getDevConf } from '../../../utils/fileUtils/index.js';
16
- import { getRoot, getDirName } from '../../../utils/fileUtils/base.js';
13
+ import logger from '../../../libs/logger.js';
17
14
  import { checkPort } from '../../../utils/checkDevPort.js';
15
+ import { getRoot, getDirName } from '../../../utils/fileUtils/base.js';
16
+ import { getDevConf } from '../../../utils/fileUtils/index.js';
17
+ import devBuild from '../build.js';
18
18
  const generateEntry = (id, projectEntry, userRoot) => __awaiter(void 0, void 0, void 0, function* () {
19
19
  const __dirname = getDirName(import.meta.url);
20
20
  const devDir = path.resolve(userRoot, '.dev');
@@ -78,10 +78,19 @@ const prepare = (configPath, entry, port, localUpstream, userRoot) => __awaiter(
78
78
  const devPack = () => __awaiter(void 0, void 0, void 0, function* () {
79
79
  logger.ora.start('Processing...\n');
80
80
  const userRoot = getRoot();
81
- const configPath = path.resolve(userRoot, 'esa.toml');
81
+ // Try to find config file in order of preference: .jsonc, .toml
82
+ const configFormats = ['esa.jsonc', 'esa.toml'];
83
+ let configPath = null;
84
+ for (const format of configFormats) {
85
+ const testPath = path.resolve(userRoot, format);
86
+ if (fs.existsSync(testPath)) {
87
+ configPath = testPath;
88
+ break;
89
+ }
90
+ }
82
91
  let port, minify, localUpstream, entry;
83
92
  let projectEntry = path.resolve(userRoot, 'src/index.js');
84
- if (fs.existsSync(configPath)) {
93
+ if (configPath) {
85
94
  port = getDevConf('port', 'dev', 18080);
86
95
  minify = getDevConf('minify', 'dev', false);
87
96
  localUpstream = getDevConf('localUpstream', 'dev', '');
@@ -7,12 +7,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import spawn from 'cross-spawn';
11
- import logger from '../../../libs/logger.js';
12
10
  import path from 'path';
11
+ import spawn from 'cross-spawn';
13
12
  import t from '../../../i18n/index.js';
14
- import { getDevConf } from '../../../utils/fileUtils/index.js';
13
+ import logger from '../../../libs/logger.js';
15
14
  import { getRoot } from '../../../utils/fileUtils/base.js';
15
+ import { getDevConf } from '../../../utils/fileUtils/index.js';
16
16
  class MockWorkerServer {
17
17
  constructor(props) {
18
18
  this.instance = null;
@@ -63,10 +63,11 @@ class MockWorkerServer {
63
63
  logger.subError(chunk.toString().trim());
64
64
  }
65
65
  errorHandler(err) {
66
+ var _a;
66
67
  logger.error(err.message ? err.message : err);
67
- this.instance && this.instance.kill();
68
+ (_a = this.instance) === null || _a === void 0 ? void 0 : _a.kill();
68
69
  }
69
- closeHandler(code, signal) {
70
+ closeHandler() {
70
71
  if (this.restarting) {
71
72
  this.restarting = false;
72
73
  return;
@@ -86,7 +87,7 @@ class MockWorkerServer {
86
87
  resolve(false);
87
88
  return;
88
89
  }
89
- const onExit = (code, signal) => {
90
+ const onExit = () => {
90
91
  this.instance = null;
91
92
  resolve(true);
92
93
  };
@@ -7,11 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { bindRoutineWithDomain, checkDirectory, checkIsLoginSuccess, validDomain, validName } from '../utils.js';
11
- import { getProjectConfig } from '../../utils/fileUtils/index.js';
12
10
  import t from '../../i18n/index.js';
13
11
  import logger from '../../libs/logger.js';
14
12
  import { validRoutine } from '../../utils/checkIsRoutineCreated.js';
13
+ import { getProjectConfig } from '../../utils/fileUtils/index.js';
14
+ import { bindRoutineWithDomain, checkDirectory, checkIsLoginSuccess, validDomain, validName } from '../utils.js';
15
15
  const addDomain = {
16
16
  command: 'add <domain>',
17
17
  describe: `📥 ${t('domain_add_describe').d('Bind a domain to a routine')}`,
@@ -7,12 +7,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { getProjectConfig } from '../../utils/fileUtils/index.js';
11
- import { checkDirectory, checkIsLoginSuccess } from '../utils.js';
12
- import { ApiService } from '../../libs/apiService.js';
13
10
  import t from '../../i18n/index.js';
11
+ import { ApiService } from '../../libs/apiService.js';
14
12
  import logger from '../../libs/logger.js';
15
13
  import { validRoutine } from '../../utils/checkIsRoutineCreated.js';
14
+ import { getProjectConfig } from '../../utils/fileUtils/index.js';
15
+ import { checkDirectory, checkIsLoginSuccess } from '../utils.js';
16
16
  const deleteDomain = {
17
17
  command: 'delete <domain>',
18
18
  describe: `🗑 ${t('domain_delete_describe').d('Delete a related domain')}`,
@@ -31,7 +31,7 @@ const deleteDomain = {
31
31
  export default deleteDomain;
32
32
  export function handleDeleteDomain(argv) {
33
33
  return __awaiter(this, void 0, void 0, function* () {
34
- var _a, _b;
34
+ var _a;
35
35
  if (!checkDirectory()) {
36
36
  return;
37
37
  }
@@ -44,10 +44,10 @@ export function handleDeleteDomain(argv) {
44
44
  yield validRoutine(projectConfig.name);
45
45
  const server = yield ApiService.getInstance();
46
46
  const req = { Name: projectConfig.name || '' };
47
- const routineDetail = yield server.getRoutine(req);
48
- if (!routineDetail)
47
+ const listRoutineRelatedRecordRes = yield server.listRoutineRelatedRecords(req);
48
+ if (!listRoutineRelatedRecordRes)
49
49
  return;
50
- const relatedRecords = (_b = (_a = routineDetail.data) === null || _a === void 0 ? void 0 : _a.RelatedRecords) !== null && _b !== void 0 ? _b : [];
50
+ const relatedRecords = ((_a = listRoutineRelatedRecordRes.data) === null || _a === void 0 ? void 0 : _a.RelatedRecords) || [];
51
51
  const relatedDomain = argv.domain;
52
52
  const matchedSite = relatedRecords.find((item) => {
53
53
  return String(item.RecordName) === relatedDomain;
@@ -1,7 +1,7 @@
1
+ import t from '../../i18n/index.js';
1
2
  import addDomain from './add.js';
2
- import listDomain from './list.js';
3
3
  import deleteDomain from './delete.js';
4
- import t from '../../i18n/index.js';
4
+ import listDomain from './list.js';
5
5
  let yargsIns;
6
6
  const domainCommand = {
7
7
  command: 'domain [script]',
@@ -7,21 +7,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { checkDirectory, checkIsLoginSuccess } from '../utils.js';
11
- import logger from '../../libs/logger.js';
12
- import { getProjectConfig } from '../../utils/fileUtils/index.js';
13
- import { ApiService } from '../../libs/apiService.js';
14
10
  import t from '../../i18n/index.js';
11
+ import { ApiService } from '../../libs/apiService.js';
12
+ import logger from '../../libs/logger.js';
15
13
  import { validRoutine } from '../../utils/checkIsRoutineCreated.js';
14
+ import { getProjectConfig } from '../../utils/fileUtils/index.js';
15
+ import { checkDirectory, checkIsLoginSuccess } from '../utils.js';
16
16
  const listDomain = {
17
17
  command: 'list',
18
18
  describe: `🔍 ${t('domain_list_describe').d('List all related domains')}`,
19
- handler: (argv) => __awaiter(void 0, void 0, void 0, function* () {
20
- handleListDomains(argv);
19
+ handler: () => __awaiter(void 0, void 0, void 0, function* () {
20
+ handleListDomains();
21
21
  })
22
22
  };
23
23
  export default listDomain;
24
- export function handleListDomains(argv) {
24
+ export function handleListDomains() {
25
25
  return __awaiter(this, void 0, void 0, function* () {
26
26
  var _a, _b;
27
27
  if (!checkDirectory()) {
@@ -36,10 +36,10 @@ export function handleListDomains(argv) {
36
36
  yield validRoutine(projectConfig.name);
37
37
  const server = yield ApiService.getInstance();
38
38
  const req = { Name: projectConfig.name };
39
- const routineDetail = yield server.getRoutine(req);
40
- if (!routineDetail)
39
+ const res = yield server.listRoutineRelatedRecords(req);
40
+ if (!res)
41
41
  return;
42
- const relatedRecords = (_b = (_a = routineDetail.data) === null || _a === void 0 ? void 0 : _a.RelatedRecords) !== null && _b !== void 0 ? _b : [];
42
+ const relatedRecords = (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.RelatedRecords) !== null && _b !== void 0 ? _b : [];
43
43
  if (relatedRecords.length === 0) {
44
44
  logger.log(`🙅 ${t('domain_list_empty').d('No related domains found')}`);
45
45
  return;