@vizamodo/viza-cli 1.2.30 → 1.2.34
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/src/core/version.js +7 -16
- package/package.json +1 -1
package/dist/src/core/version.js
CHANGED
|
@@ -98,31 +98,22 @@ function semverCompare(a, b) {
|
|
|
98
98
|
export async function checkForCliUpdateSoft() {
|
|
99
99
|
const cachePath = resolveUpdateCachePath();
|
|
100
100
|
const now = Date.now();
|
|
101
|
-
const ttl = 10 * 60 * 1000;
|
|
101
|
+
const ttl = 10 * 60 * 1000; // 10 minutes (Fixed window)
|
|
102
102
|
const current = getCliVersion();
|
|
103
103
|
try {
|
|
104
104
|
if (existsSync(cachePath)) {
|
|
105
105
|
const raw = readFileSync(cachePath, "utf8");
|
|
106
106
|
const cached = JSON.parse(raw);
|
|
107
|
-
//
|
|
108
|
-
//
|
|
107
|
+
// Kiểm tra Version Mismatch HOẶC Cache Expired
|
|
108
|
+
// KHÔNG cập nhật checkedAt ở đây để đảm bảo đúng 10p sẽ check lại 1 lần
|
|
109
109
|
if (cached.current === current && cached.checkedAt && (now - cached.checkedAt) < ttl) {
|
|
110
|
-
|
|
111
|
-
if (cached.latest === cached.current && (now - cached.checkedAt) > 60 * 1000) {
|
|
112
|
-
// fall through to fetch
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
return cached;
|
|
116
|
-
}
|
|
110
|
+
return cached;
|
|
117
111
|
}
|
|
118
112
|
}
|
|
119
113
|
}
|
|
120
|
-
catch {
|
|
121
|
-
|
|
122
|
-
}
|
|
114
|
+
catch { /* ignore */ }
|
|
115
|
+
// --- Bắt đầu Fetch mới khi cache hết hạn hoặc sai version ---
|
|
123
116
|
try {
|
|
124
|
-
// FIX 2: Thêm timestamp để đảm bảo lấy data mới nhất từ NPM,
|
|
125
|
-
// tránh trường hợp registry chưa cập nhật kịp edge node.
|
|
126
117
|
const registryUrl = `https://registry.npmjs.org/@vizamodo/viza-cli/latest?t=${now}`;
|
|
127
118
|
const res = await fetch(registryUrl, {
|
|
128
119
|
cache: "no-store",
|
|
@@ -140,7 +131,7 @@ export async function checkForCliUpdateSoft() {
|
|
|
140
131
|
current,
|
|
141
132
|
latest,
|
|
142
133
|
hasUpdate,
|
|
143
|
-
checkedAt: now,
|
|
134
|
+
checkedAt: now, // Chỉ cập nhật mốc thời gian tại đây
|
|
144
135
|
};
|
|
145
136
|
try {
|
|
146
137
|
const configDir = dirname(cachePath);
|