vibecodingmachine-core 2026.3.9-907 → 2026.3.10-1548
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/package.json +1 -1
- package/src/auth/access-denied.html +119 -119
- package/src/auth/shared-auth-storage.js +267 -267
- package/src/autonomous-mode/feature-implementer.cjs +70 -70
- package/src/autonomous-mode/feature-implementer.js +425 -425
- package/src/beta-request.js +160 -160
- package/src/chat-management/chat-manager.cjs +71 -71
- package/src/chat-management/chat-manager.js +342 -342
- package/src/compliance/compliance-prompt.js +183 -183
- package/src/ide-integration/aider-cli-manager.cjs +850 -850
- package/src/ide-integration/applescript-manager.cjs +3215 -3215
- package/src/ide-integration/applescript-utils.js +314 -314
- package/src/ide-integration/cdp-manager.cjs +221 -221
- package/src/ide-integration/claude-code-cli-manager.cjs +456 -456
- package/src/ide-integration/cline-cli-manager.cjs +2252 -2252
- package/src/ide-integration/continue-cli-manager.js +431 -431
- package/src/ide-integration/provider-manager.cjs +595 -595
- package/src/ide-integration/quota-detector.cjs +399 -399
- package/src/ide-integration/windows-automation-manager.js +532 -4
- package/src/ide-integration/windows-ide-manager.js +12 -3
- package/src/index.cjs +142 -142
- package/src/llm/direct-llm-manager.cjs +1299 -1299
- package/src/localization/index.js +147 -147
- package/src/quota-management/index.js +108 -108
- package/src/requirement-numbering.js +164 -164
- package/src/sync/aws-setup.js +445 -445
- package/src/ui/ButtonComponents.js +247 -247
- package/src/ui/ChatInterface.js +499 -499
- package/src/ui/StateManager.js +259 -259
- package/src/utils/audit-logger.cjs +116 -116
- package/src/utils/config-helpers.cjs +94 -94
- package/src/utils/config-helpers.js +94 -94
- package/src/utils/env-helpers.js +54 -54
- package/src/utils/error-reporter.js +117 -117
- package/src/utils/gcloud-auth.cjs +394 -394
- package/src/utils/git-branch-manager.js +278 -278
- package/src/utils/logger.cjs +193 -193
- package/src/utils/logger.js +191 -191
- package/src/utils/repo-helpers.cjs +120 -120
- package/src/utils/repo-helpers.js +120 -120
- package/src/utils/update-checker.js +246 -246
- package/src/utils/version-checker.js +170 -170
|
@@ -1,246 +1,246 @@
|
|
|
1
|
-
const https = require('https');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const { shouldCheckUpdates } = require('./env-helpers');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Check for updates from npm registry
|
|
8
|
-
* @param {string} packageName - Name of the package to check (e.g., 'vibecodingmachine-cli')
|
|
9
|
-
* @param {string} currentVersion - Current version (e.g., '1.0.0')
|
|
10
|
-
* @returns {Promise<Object>} Update info or null if no update available
|
|
11
|
-
*/
|
|
12
|
-
async function checkForUpdates(packageName, currentVersion) {
|
|
13
|
-
if (!shouldCheckUpdates()) {
|
|
14
|
-
return { hasUpdate: false, currentVersion };
|
|
15
|
-
}
|
|
16
|
-
return new Promise((resolve, reject) => {
|
|
17
|
-
const registryUrl = `https://registry.npmjs.org/${packageName}`;
|
|
18
|
-
|
|
19
|
-
https.get(registryUrl, (res) => {
|
|
20
|
-
let data = '';
|
|
21
|
-
|
|
22
|
-
res.on('data', (chunk) => {
|
|
23
|
-
data += chunk;
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
res.on('end', () => {
|
|
27
|
-
try {
|
|
28
|
-
const packageInfo = JSON.parse(data);
|
|
29
|
-
const latestVersion = packageInfo['dist-tags'].latest;
|
|
30
|
-
|
|
31
|
-
if (latestVersion !== currentVersion) {
|
|
32
|
-
const versionInfo = packageInfo.versions[latestVersion];
|
|
33
|
-
const publishedDate = new Date(packageInfo.time[latestVersion]);
|
|
34
|
-
|
|
35
|
-
// Format date as YYYY-MM-DD
|
|
36
|
-
const year = publishedDate.getFullYear();
|
|
37
|
-
const month = String(publishedDate.getMonth() + 1).padStart(2, '0');
|
|
38
|
-
const day = String(publishedDate.getDate()).padStart(2, '0');
|
|
39
|
-
const formattedDate = `${year}-${month}-${day}`;
|
|
40
|
-
|
|
41
|
-
resolve({
|
|
42
|
-
hasUpdate: true,
|
|
43
|
-
currentVersion,
|
|
44
|
-
latestVersion,
|
|
45
|
-
publishedDate: formattedDate,
|
|
46
|
-
packageName,
|
|
47
|
-
description: versionInfo.description || ''
|
|
48
|
-
});
|
|
49
|
-
} else {
|
|
50
|
-
resolve({
|
|
51
|
-
hasUpdate: false,
|
|
52
|
-
currentVersion,
|
|
53
|
-
latestVersion,
|
|
54
|
-
packageName
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
} catch (error) {
|
|
58
|
-
console.error('Error parsing registry response:', error);
|
|
59
|
-
resolve({ hasUpdate: false, currentVersion, packageName, error: error.message });
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}).on('error', (error) => {
|
|
63
|
-
console.error('Error checking for updates:', error);
|
|
64
|
-
resolve({ hasUpdate: false, currentVersion, packageName, error: error.message });
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Compare two timestamp-based versions (YYYY.MM.DD-HHMM)
|
|
71
|
-
* Returns true if version1 is newer than version2
|
|
72
|
-
*/
|
|
73
|
-
function isVersionNewer(version1, version2) {
|
|
74
|
-
// Versions are in format YYYY.MM.DD-HHMM, so string comparison works
|
|
75
|
-
// Normalize both versions (handle old format with dots too)
|
|
76
|
-
const normalize = (v) => v.replace(/\.(\d{2})(\d{2})$/, '-$1$2');
|
|
77
|
-
return normalize(version1) > normalize(version2);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Check for CLI updates from S3 version manifest (unified with Electron)
|
|
82
|
-
* Both CLI and Electron now use the same timestamp-based versioning from git commits
|
|
83
|
-
* @param {string} currentVersion - Current CLI version (e.g., '2025.11.26-0519')
|
|
84
|
-
* @returns {Promise<Object>} Update info or null if no update available
|
|
85
|
-
*/
|
|
86
|
-
async function checkForCLIUpdates(currentVersion) {
|
|
87
|
-
if (!shouldCheckUpdates()) {
|
|
88
|
-
return { hasUpdate: false, currentVersion };
|
|
89
|
-
}
|
|
90
|
-
return new Promise((resolve, reject) => {
|
|
91
|
-
const manifestUrl = `https://d3fh7zgi8horze.cloudfront.net/downloads/version.json?t=${Date.now()}`;
|
|
92
|
-
|
|
93
|
-
https.get(manifestUrl, (res) => {
|
|
94
|
-
let data = '';
|
|
95
|
-
|
|
96
|
-
// Check HTTP status code
|
|
97
|
-
if (res.statusCode !== 200) {
|
|
98
|
-
console.log(`ℹ️ Update check skipped: version manifest not available (HTTP ${res.statusCode})`);
|
|
99
|
-
resolve({ hasUpdate: false, currentVersion, error: `HTTP ${res.statusCode}` });
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
res.on('data', (chunk) => {
|
|
104
|
-
data += chunk;
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
res.on('end', () => {
|
|
108
|
-
try {
|
|
109
|
-
const manifest = JSON.parse(data);
|
|
110
|
-
const latestVersion = manifest.version;
|
|
111
|
-
const publishedDate = manifest.date;
|
|
112
|
-
|
|
113
|
-
// Only show update if latest version is actually newer than current
|
|
114
|
-
if (latestVersion !== currentVersion && isVersionNewer(latestVersion, currentVersion)) {
|
|
115
|
-
resolve({
|
|
116
|
-
hasUpdate: true,
|
|
117
|
-
currentVersion,
|
|
118
|
-
latestVersion,
|
|
119
|
-
publishedDate,
|
|
120
|
-
commit: manifest.commit || 'Unknown',
|
|
121
|
-
packageName: 'vibecodingmachine-cli'
|
|
122
|
-
});
|
|
123
|
-
} else {
|
|
124
|
-
resolve({
|
|
125
|
-
hasUpdate: false,
|
|
126
|
-
currentVersion,
|
|
127
|
-
latestVersion
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
} catch (error) {
|
|
131
|
-
console.error('Error parsing version manifest:', error);
|
|
132
|
-
resolve({ hasUpdate: false, currentVersion, error: error.message });
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}).on('error', (error) => {
|
|
136
|
-
console.error('Error checking for CLI updates:', error);
|
|
137
|
-
resolve({ hasUpdate: false, currentVersion, error: error.message });
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Get update info cache file path
|
|
145
|
-
* @param {string} packageName - Package name
|
|
146
|
-
* @returns {string} Path to cache file
|
|
147
|
-
*/
|
|
148
|
-
function getUpdateCachePath(packageName) {
|
|
149
|
-
const homeDir = require('os').homedir();
|
|
150
|
-
const cacheDir = path.join(homeDir, '.config', 'vibecodingmachine');
|
|
151
|
-
|
|
152
|
-
// Ensure cache directory exists
|
|
153
|
-
if (!fs.existsSync(cacheDir)) {
|
|
154
|
-
fs.mkdirSync(cacheDir, { recursive: true });
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return path.join(cacheDir, `${packageName}-update-cache.json`);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Load cached update info
|
|
162
|
-
* @param {string} packageName - Package name
|
|
163
|
-
* @returns {Object|null} Cached update info or null
|
|
164
|
-
*/
|
|
165
|
-
function loadUpdateCache(packageName) {
|
|
166
|
-
try {
|
|
167
|
-
const cachePath = getUpdateCachePath(packageName);
|
|
168
|
-
if (fs.existsSync(cachePath)) {
|
|
169
|
-
const data = fs.readFileSync(cachePath, 'utf8');
|
|
170
|
-
const cache = JSON.parse(data);
|
|
171
|
-
|
|
172
|
-
// Cache is valid for 1 hour
|
|
173
|
-
const cacheAge = Date.now() - cache.checkedAt;
|
|
174
|
-
if (cacheAge < 3600000) { // 1 hour
|
|
175
|
-
return cache.updateInfo;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
} catch (error) {
|
|
179
|
-
console.error('Error loading update cache:', error);
|
|
180
|
-
}
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Save update info to cache
|
|
186
|
-
* @param {string} packageName - Package name
|
|
187
|
-
* @param {Object} updateInfo - Update info to cache
|
|
188
|
-
*/
|
|
189
|
-
function saveUpdateCache(packageName, updateInfo) {
|
|
190
|
-
try {
|
|
191
|
-
const cachePath = getUpdateCachePath(packageName);
|
|
192
|
-
const cache = {
|
|
193
|
-
checkedAt: Date.now(),
|
|
194
|
-
updateInfo
|
|
195
|
-
};
|
|
196
|
-
fs.writeFileSync(cachePath, JSON.stringify(cache, null, 2));
|
|
197
|
-
} catch (error) {
|
|
198
|
-
console.error('Error saving update cache:', error);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Check for updates with caching
|
|
204
|
-
* @param {string} packageName - Package name
|
|
205
|
-
* @param {string} currentVersion - Current version
|
|
206
|
-
* @param {boolean} forceCheck - Force check even if cache is valid
|
|
207
|
-
* @returns {Promise<Object>} Update info
|
|
208
|
-
*/
|
|
209
|
-
async function checkForUpdatesWithCache(packageName, currentVersion, forceCheck = false) {
|
|
210
|
-
if (!forceCheck) {
|
|
211
|
-
const cached = loadUpdateCache(packageName);
|
|
212
|
-
if (cached) {
|
|
213
|
-
return cached;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
const updateInfo = await checkForUpdates(packageName, currentVersion);
|
|
218
|
-
saveUpdateCache(packageName, updateInfo);
|
|
219
|
-
return updateInfo;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Clear update notification (mark as dismissed)
|
|
224
|
-
* @param {string} packageName - Package name
|
|
225
|
-
*/
|
|
226
|
-
function clearUpdateNotification(packageName) {
|
|
227
|
-
try {
|
|
228
|
-
const cachePath = getUpdateCachePath(packageName);
|
|
229
|
-
if (fs.existsSync(cachePath)) {
|
|
230
|
-
fs.unlinkSync(cachePath);
|
|
231
|
-
}
|
|
232
|
-
} catch (error) {
|
|
233
|
-
console.error('Error clearing update notification:', error);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
module.exports = {
|
|
238
|
-
checkForUpdates,
|
|
239
|
-
checkForCLIUpdates,
|
|
240
|
-
checkForUpdatesWithCache,
|
|
241
|
-
loadUpdateCache,
|
|
242
|
-
saveUpdateCache,
|
|
243
|
-
clearUpdateNotification,
|
|
244
|
-
getUpdateCachePath
|
|
245
|
-
};
|
|
246
|
-
|
|
1
|
+
const https = require('https');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const { shouldCheckUpdates } = require('./env-helpers');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Check for updates from npm registry
|
|
8
|
+
* @param {string} packageName - Name of the package to check (e.g., 'vibecodingmachine-cli')
|
|
9
|
+
* @param {string} currentVersion - Current version (e.g., '1.0.0')
|
|
10
|
+
* @returns {Promise<Object>} Update info or null if no update available
|
|
11
|
+
*/
|
|
12
|
+
async function checkForUpdates(packageName, currentVersion) {
|
|
13
|
+
if (!shouldCheckUpdates()) {
|
|
14
|
+
return { hasUpdate: false, currentVersion };
|
|
15
|
+
}
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const registryUrl = `https://registry.npmjs.org/${packageName}`;
|
|
18
|
+
|
|
19
|
+
https.get(registryUrl, (res) => {
|
|
20
|
+
let data = '';
|
|
21
|
+
|
|
22
|
+
res.on('data', (chunk) => {
|
|
23
|
+
data += chunk;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
res.on('end', () => {
|
|
27
|
+
try {
|
|
28
|
+
const packageInfo = JSON.parse(data);
|
|
29
|
+
const latestVersion = packageInfo['dist-tags'].latest;
|
|
30
|
+
|
|
31
|
+
if (latestVersion !== currentVersion) {
|
|
32
|
+
const versionInfo = packageInfo.versions[latestVersion];
|
|
33
|
+
const publishedDate = new Date(packageInfo.time[latestVersion]);
|
|
34
|
+
|
|
35
|
+
// Format date as YYYY-MM-DD
|
|
36
|
+
const year = publishedDate.getFullYear();
|
|
37
|
+
const month = String(publishedDate.getMonth() + 1).padStart(2, '0');
|
|
38
|
+
const day = String(publishedDate.getDate()).padStart(2, '0');
|
|
39
|
+
const formattedDate = `${year}-${month}-${day}`;
|
|
40
|
+
|
|
41
|
+
resolve({
|
|
42
|
+
hasUpdate: true,
|
|
43
|
+
currentVersion,
|
|
44
|
+
latestVersion,
|
|
45
|
+
publishedDate: formattedDate,
|
|
46
|
+
packageName,
|
|
47
|
+
description: versionInfo.description || ''
|
|
48
|
+
});
|
|
49
|
+
} else {
|
|
50
|
+
resolve({
|
|
51
|
+
hasUpdate: false,
|
|
52
|
+
currentVersion,
|
|
53
|
+
latestVersion,
|
|
54
|
+
packageName
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error('Error parsing registry response:', error);
|
|
59
|
+
resolve({ hasUpdate: false, currentVersion, packageName, error: error.message });
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}).on('error', (error) => {
|
|
63
|
+
console.error('Error checking for updates:', error);
|
|
64
|
+
resolve({ hasUpdate: false, currentVersion, packageName, error: error.message });
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Compare two timestamp-based versions (YYYY.MM.DD-HHMM)
|
|
71
|
+
* Returns true if version1 is newer than version2
|
|
72
|
+
*/
|
|
73
|
+
function isVersionNewer(version1, version2) {
|
|
74
|
+
// Versions are in format YYYY.MM.DD-HHMM, so string comparison works
|
|
75
|
+
// Normalize both versions (handle old format with dots too)
|
|
76
|
+
const normalize = (v) => v.replace(/\.(\d{2})(\d{2})$/, '-$1$2');
|
|
77
|
+
return normalize(version1) > normalize(version2);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Check for CLI updates from S3 version manifest (unified with Electron)
|
|
82
|
+
* Both CLI and Electron now use the same timestamp-based versioning from git commits
|
|
83
|
+
* @param {string} currentVersion - Current CLI version (e.g., '2025.11.26-0519')
|
|
84
|
+
* @returns {Promise<Object>} Update info or null if no update available
|
|
85
|
+
*/
|
|
86
|
+
async function checkForCLIUpdates(currentVersion) {
|
|
87
|
+
if (!shouldCheckUpdates()) {
|
|
88
|
+
return { hasUpdate: false, currentVersion };
|
|
89
|
+
}
|
|
90
|
+
return new Promise((resolve, reject) => {
|
|
91
|
+
const manifestUrl = `https://d3fh7zgi8horze.cloudfront.net/downloads/version.json?t=${Date.now()}`;
|
|
92
|
+
|
|
93
|
+
https.get(manifestUrl, (res) => {
|
|
94
|
+
let data = '';
|
|
95
|
+
|
|
96
|
+
// Check HTTP status code
|
|
97
|
+
if (res.statusCode !== 200) {
|
|
98
|
+
console.log(`ℹ️ Update check skipped: version manifest not available (HTTP ${res.statusCode})`);
|
|
99
|
+
resolve({ hasUpdate: false, currentVersion, error: `HTTP ${res.statusCode}` });
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
res.on('data', (chunk) => {
|
|
104
|
+
data += chunk;
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
res.on('end', () => {
|
|
108
|
+
try {
|
|
109
|
+
const manifest = JSON.parse(data);
|
|
110
|
+
const latestVersion = manifest.version;
|
|
111
|
+
const publishedDate = manifest.date;
|
|
112
|
+
|
|
113
|
+
// Only show update if latest version is actually newer than current
|
|
114
|
+
if (latestVersion !== currentVersion && isVersionNewer(latestVersion, currentVersion)) {
|
|
115
|
+
resolve({
|
|
116
|
+
hasUpdate: true,
|
|
117
|
+
currentVersion,
|
|
118
|
+
latestVersion,
|
|
119
|
+
publishedDate,
|
|
120
|
+
commit: manifest.commit || 'Unknown',
|
|
121
|
+
packageName: 'vibecodingmachine-cli'
|
|
122
|
+
});
|
|
123
|
+
} else {
|
|
124
|
+
resolve({
|
|
125
|
+
hasUpdate: false,
|
|
126
|
+
currentVersion,
|
|
127
|
+
latestVersion
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
} catch (error) {
|
|
131
|
+
console.error('Error parsing version manifest:', error);
|
|
132
|
+
resolve({ hasUpdate: false, currentVersion, error: error.message });
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}).on('error', (error) => {
|
|
136
|
+
console.error('Error checking for CLI updates:', error);
|
|
137
|
+
resolve({ hasUpdate: false, currentVersion, error: error.message });
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Get update info cache file path
|
|
145
|
+
* @param {string} packageName - Package name
|
|
146
|
+
* @returns {string} Path to cache file
|
|
147
|
+
*/
|
|
148
|
+
function getUpdateCachePath(packageName) {
|
|
149
|
+
const homeDir = require('os').homedir();
|
|
150
|
+
const cacheDir = path.join(homeDir, '.config', 'vibecodingmachine');
|
|
151
|
+
|
|
152
|
+
// Ensure cache directory exists
|
|
153
|
+
if (!fs.existsSync(cacheDir)) {
|
|
154
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return path.join(cacheDir, `${packageName}-update-cache.json`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Load cached update info
|
|
162
|
+
* @param {string} packageName - Package name
|
|
163
|
+
* @returns {Object|null} Cached update info or null
|
|
164
|
+
*/
|
|
165
|
+
function loadUpdateCache(packageName) {
|
|
166
|
+
try {
|
|
167
|
+
const cachePath = getUpdateCachePath(packageName);
|
|
168
|
+
if (fs.existsSync(cachePath)) {
|
|
169
|
+
const data = fs.readFileSync(cachePath, 'utf8');
|
|
170
|
+
const cache = JSON.parse(data);
|
|
171
|
+
|
|
172
|
+
// Cache is valid for 1 hour
|
|
173
|
+
const cacheAge = Date.now() - cache.checkedAt;
|
|
174
|
+
if (cacheAge < 3600000) { // 1 hour
|
|
175
|
+
return cache.updateInfo;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
} catch (error) {
|
|
179
|
+
console.error('Error loading update cache:', error);
|
|
180
|
+
}
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Save update info to cache
|
|
186
|
+
* @param {string} packageName - Package name
|
|
187
|
+
* @param {Object} updateInfo - Update info to cache
|
|
188
|
+
*/
|
|
189
|
+
function saveUpdateCache(packageName, updateInfo) {
|
|
190
|
+
try {
|
|
191
|
+
const cachePath = getUpdateCachePath(packageName);
|
|
192
|
+
const cache = {
|
|
193
|
+
checkedAt: Date.now(),
|
|
194
|
+
updateInfo
|
|
195
|
+
};
|
|
196
|
+
fs.writeFileSync(cachePath, JSON.stringify(cache, null, 2));
|
|
197
|
+
} catch (error) {
|
|
198
|
+
console.error('Error saving update cache:', error);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Check for updates with caching
|
|
204
|
+
* @param {string} packageName - Package name
|
|
205
|
+
* @param {string} currentVersion - Current version
|
|
206
|
+
* @param {boolean} forceCheck - Force check even if cache is valid
|
|
207
|
+
* @returns {Promise<Object>} Update info
|
|
208
|
+
*/
|
|
209
|
+
async function checkForUpdatesWithCache(packageName, currentVersion, forceCheck = false) {
|
|
210
|
+
if (!forceCheck) {
|
|
211
|
+
const cached = loadUpdateCache(packageName);
|
|
212
|
+
if (cached) {
|
|
213
|
+
return cached;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const updateInfo = await checkForUpdates(packageName, currentVersion);
|
|
218
|
+
saveUpdateCache(packageName, updateInfo);
|
|
219
|
+
return updateInfo;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Clear update notification (mark as dismissed)
|
|
224
|
+
* @param {string} packageName - Package name
|
|
225
|
+
*/
|
|
226
|
+
function clearUpdateNotification(packageName) {
|
|
227
|
+
try {
|
|
228
|
+
const cachePath = getUpdateCachePath(packageName);
|
|
229
|
+
if (fs.existsSync(cachePath)) {
|
|
230
|
+
fs.unlinkSync(cachePath);
|
|
231
|
+
}
|
|
232
|
+
} catch (error) {
|
|
233
|
+
console.error('Error clearing update notification:', error);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
module.exports = {
|
|
238
|
+
checkForUpdates,
|
|
239
|
+
checkForCLIUpdates,
|
|
240
|
+
checkForUpdatesWithCache,
|
|
241
|
+
loadUpdateCache,
|
|
242
|
+
saveUpdateCache,
|
|
243
|
+
clearUpdateNotification,
|
|
244
|
+
getUpdateCachePath
|
|
245
|
+
};
|
|
246
|
+
|