esa-cli 0.0.2-beta.6 → 0.0.2-beta.8

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.
@@ -106,27 +106,13 @@ const prepare = (configPath, entry, port, localUpstream, userRoot) => __awaiter(
106
106
  if (currentIds[0] && /^\d+$/.test(currentIds[0])) {
107
107
  // 删除没有用到的入口
108
108
  for (let currentId of currentIds) {
109
- const useful = yield checkPort(currentConfigObj[currentId].port);
110
- if (useful) {
111
- const unusedEntry = path.resolve(userRoot, `.dev/index-${currentId}.js`);
112
- const unusedTemp = path.resolve(userRoot, `.dev/devEntry-${currentId}.js`);
113
- const unusedConfig = path.resolve(userRoot, `.dev/config-${currentId}.toml`);
114
- if (fs.existsSync(unusedEntry)) {
115
- fs.rmSync(unusedEntry, {
116
- force: true,
117
- recursive: true,
118
- maxRetries: 5
119
- });
120
- }
121
- if (fs.existsSync(unusedTemp)) {
122
- fs.rmSync(unusedTemp, {
123
- force: true,
124
- recursive: true,
125
- maxRetries: 5
126
- });
127
- }
128
- if (fs.existsSync(unusedConfig)) {
129
- fs.rmSync(unusedConfig, {
109
+ const unused = yield checkPort(currentConfigObj[currentId].port);
110
+ if (unused) {
111
+ const devDir = path.resolve(userRoot, '.dev');
112
+ const files = fs.readdirSync(devDir);
113
+ const filesToDelete = files.filter((file) => file.includes(currentId));
114
+ for (const file of filesToDelete) {
115
+ fs.rmSync(path.resolve(devDir, file), {
130
116
  force: true,
131
117
  recursive: true,
132
118
  maxRetries: 5
@@ -164,8 +150,7 @@ const devPack = (...args_1) => __awaiter(void 0, [...args_1], void 0, function*
164
150
  .then(() => {
165
151
  logger.ora.succeed(t('dev_pack_config_success').d('Config created successfully'));
166
152
  return devBuild({
167
- minify,
168
- isNode: true
153
+ minify
169
154
  });
170
155
  })
171
156
  .then(() => {
@@ -51,22 +51,24 @@ const prepare = (configPath, entry, port, localUpstream, userRoot) => __awaiter(
51
51
  .readFileSync(configPath, 'utf-8')
52
52
  .replace('export default ', '');
53
53
  const currentConfigObj = JSON.parse(currentConfig);
54
- const cIds = Object.keys(currentConfigObj);
55
- if (cIds[0] && /^\d+$/.test(cIds[0])) {
56
- for (let cid of cIds) {
57
- const useful = yield checkPort(currentConfigObj[cid].port);
58
- if (useful) {
59
- const unusedEntry = path.resolve(userRoot, `.dev/index-${cid}.js`);
60
- const unusedTemp = path.resolve(userRoot, `.dev/devEntry-${cid}.js`);
61
- if (fs.existsSync(unusedEntry)) {
62
- fs.rmSync(unusedEntry);
63
- }
64
- if (fs.existsSync(unusedTemp)) {
65
- fs.rmSync(unusedTemp);
54
+ const currentIds = Object.keys(currentConfigObj);
55
+ if (currentIds[0] && /^\d+$/.test(currentIds[0])) {
56
+ for (let currentId of currentIds) {
57
+ const unused = yield checkPort(currentConfigObj[currentId].port);
58
+ if (unused) {
59
+ const devDir = path.resolve(userRoot, '.dev');
60
+ const files = fs.readdirSync(devDir);
61
+ const filesToDelete = files.filter((file) => file.includes(currentId));
62
+ for (const file of filesToDelete) {
63
+ fs.rmSync(path.resolve(devDir, file), {
64
+ force: true,
65
+ recursive: true,
66
+ maxRetries: 5
67
+ });
66
68
  }
67
69
  }
68
70
  else {
69
- options[cid] = currentConfigObj[cid];
71
+ options[currentId] = currentConfigObj[currentId];
70
72
  }
71
73
  }
72
74
  }
@@ -476,8 +476,8 @@
476
476
  "zh_CN": "route不合法"
477
477
  },
478
478
  "install_runtime_explain": {
479
- "en": "Under the beta phase, we are temporarily using Deno as the local development runtime. It needs to be installed first.",
480
- "zh_CN": "在Beta阶段,我们使用了Deno暂时作为本地开发运行时,需要先安装才可以dev。"
479
+ "en": "Our runtime does not yet support this OS. We are temporarily using Deno as the local development runtime, which needs to be installed first.",
480
+ "zh_CN": "我们的Runtime还不支持此操作系统,我们暂时使用Deno作为本地开发runtime,需要先安装。"
481
481
  },
482
482
  "install_runtime_tip": {
483
483
  "en": "🔔 Runtime must be installed to use esa dev. Installing...",
@@ -917,6 +917,6 @@
917
917
  },
918
918
  "deno_install_success_tips": {
919
919
  "en": "Please run ${dev} again",
920
- "zh_CN": ""
920
+ "zh_CN": "请重新运行 ${dev}"
921
921
  }
922
922
  }
@@ -111,43 +111,50 @@ export function downloadRuntimeAndUnzipForWindows() {
111
111
  const DenoZip = path.join(BinDir, 'deno.zip');
112
112
  const Target = 'x86_64-pc-windows-msvc';
113
113
  const DownloadUrl = `http://esa-runtime.myalicdn.com/runtime/deno-${Target}.zip`;
114
+ logger.ora.start('Downloading...');
114
115
  try {
115
116
  yield fs.mkdir(BinDir, { recursive: true });
116
117
  }
117
118
  catch (error) {
118
119
  const err = error;
120
+ logger.ora.fail();
119
121
  logger.error(`mkdir error ${BinDir}: ${err.message}`);
120
122
  process.exit(1);
121
123
  }
122
124
  try {
123
125
  yield downloadFile(DownloadUrl, DenoZip);
124
- logger.success(`${t('deno_download_success').d('Download success')}: ${DenoZip}`);
125
126
  }
126
127
  catch (error) {
127
128
  const err = error;
129
+ logger.ora.fail();
128
130
  logger.error(`${t('deno_download_failed').d('Download failed')}: ${err.message}`);
129
131
  process.exit(1);
130
132
  }
131
133
  logger.info(`Unzip file to: ${BinDir}`);
132
134
  try {
135
+ logger.ora.text = 'Unzip...';
133
136
  unzipFile(DenoZip, BinDir);
134
137
  }
135
138
  catch (error) {
136
139
  const err = error;
140
+ logger.ora.fail();
137
141
  logger.error(`${t('deno_unzip_failed').d('Unzip failed')}: ${err.message}`);
138
142
  process.exit(1);
139
143
  }
140
144
  try {
145
+ logger.ora.text = 'Deleting temp file...';
141
146
  yield fs.unlink(DenoZip);
147
+ logger.ora.succeed('Download success');
142
148
  logger.info(`Delete temp file: ${DenoZip}`);
143
149
  }
144
150
  catch (error) {
145
151
  logger.warn(`Delete temp file ${DenoZip} failed: ${error}`);
146
152
  }
147
153
  try {
154
+ logger.ora.text = 'Adding Bin dir to PATH...';
148
155
  const inPath = yield isBinDirInPath(BinDir);
149
156
  if (!inPath) {
150
- logger.info(`${BinDir} not in PATH, adding...`);
157
+ logger.info(`${BinDir} not in PATH`);
151
158
  yield addBinDirToPath(BinDir);
152
159
  }
153
160
  else {
@@ -156,6 +163,7 @@ export function downloadRuntimeAndUnzipForWindows() {
156
163
  }
157
164
  catch (error) {
158
165
  const err = error;
166
+ logger.ora.fail();
159
167
  logger.error(`${t('deno_add_path_failed').d('Add BinDir to Path failed')}: ${err.message}`);
160
168
  process.exit(1);
161
169
  }
@@ -166,6 +174,7 @@ export function downloadRuntimeAndUnzipForWindows() {
166
174
  }
167
175
  catch (error) {
168
176
  const err = error;
177
+ logger.ora.fail();
169
178
  logger.error(`Download Error: ${err.message}`);
170
179
  process.exit(1);
171
180
  }
@@ -18,7 +18,7 @@ export function preCheckDeno() {
18
18
  return __awaiter(this, void 0, void 0, function* () {
19
19
  const command = yield checkDenoInstalled();
20
20
  if (!command) {
21
- logger.error(t('install_runtime_explain').d('Under the beta phase, we are temporarily using Deno as the local development runtime. It needs to be installed first.'));
21
+ logger.error(t('install_runtime_explain').d('Our runtime does not yet support this OS. We are temporarily using Deno as the local development runtime, which needs to be installed first.'));
22
22
  yield installDeno();
23
23
  return false;
24
24
  }
@@ -46,7 +46,6 @@ export function checkDenoInstalled() {
46
46
  resolve(res);
47
47
  })
48
48
  .catch((err) => {
49
- console.log(err);
50
49
  resolve(false);
51
50
  });
52
51
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esa-cli",
3
- "version": "0.0.2-beta.6",
3
+ "version": "0.0.2-beta.8",
4
4
  "description": "A CLI for operating Alibaba Cloud ESA EdgeRoutine (Edge Functions).",
5
5
  "main": "bin/enter.cjs",
6
6
  "type": "module",