Skip to content

Commit 0a714a4

Browse files
committed
Merge branch fix-cache-replace-bug.
2 parents d2bce52 + 9ce20a4 commit 0a714a4

File tree

4 files changed

+33
-20
lines changed

4 files changed

+33
-20
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [1.0.4] - 2026-01-13
4+
5+
### Fixed
6+
7+
- Fix mock Cache replacement bug
8+
39
## [1.0.3] - 2025-11-28
410

511
### Fixed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "esa-cli",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "A CLI for operating Alibaba Cloud ESA Functions and Pages.",
55
"main": "bin/enter.cjs",
66
"type": "module",
@@ -19,6 +19,7 @@
1919
"dev": "tsc --watch",
2020
"eslint": "eslint src/ --ext .js,.jsx,.ts,.tsx",
2121
"prepare": "husky install",
22+
"prepublishOnly": "npm run build",
2223
"lint-staged": "lint-staged",
2324
"test": "vitest --coverage",
2425
"coverage": "vitest --coverage",

src/commands/dev/build.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,17 @@ const renameMock = {
3333
traverse(ast, {
3434
Identifier(path) {
3535
const name = path.node.name;
36-
if (replacements.hasOwnProperty(name)) {
37-
path.node.name = replacements[name as ReplacementKeys];
36+
if (!replacements.hasOwnProperty(name)) {
37+
return;
38+
}
39+
if (
40+
path.parentPath?.type === 'MemberExpression' &&
41+
path.key === 'object' &&
42+
path.node.name === 'cache'
43+
) {
44+
path.node.name = 'mockCache';
45+
} else if (path.node.name === 'EdgeKV') {
46+
path.node.name = 'mockKV';
3847
}
3948
}
4049
});

src/utils/installEw2.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { execSync } from 'child_process';
2-
import https from 'https';
2+
import http from 'http';
33
import os from 'os';
44
import path from 'path';
55
import util from 'util';
@@ -72,22 +72,19 @@ export async function preCheckEw2(): Promise<boolean> {
7272

7373
export function fetchRemoteManifest(): Promise<Ew2Manifest> {
7474
return new Promise((resolve, reject) => {
75-
https
76-
.get(
77-
'https://edgestar-cn.oss-cn-beijing.aliyuncs.com/ew2/manifest.json',
78-
(res) => {
79-
let data = '';
80-
res.on('data', (chunk) => (data += chunk));
81-
res.on('end', () => {
82-
try {
83-
const json = JSON.parse(data);
84-
resolve(json);
85-
} catch (err) {
86-
reject(null);
87-
}
88-
});
89-
}
90-
)
75+
http
76+
.get('http://esa-runtime.myalicdn.com/ew2/manifest.json', (res) => {
77+
let data = '';
78+
res.on('data', (chunk) => (data += chunk));
79+
res.on('end', () => {
80+
try {
81+
const json = JSON.parse(data);
82+
resolve(json);
83+
} catch (err) {
84+
reject(null);
85+
}
86+
});
87+
})
9188
.on('error', () => reject);
9289
});
9390
}

0 commit comments

Comments
 (0)