inup 1.6.0 → 1.6.3
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/README.md +81 -4
- package/dist/cli.js +23 -3
- package/dist/config/constants.js +6 -3
- package/dist/core/package-detector.js +20 -0
- package/dist/core/upgrade-runner.js +8 -0
- package/dist/core/upgrader.js +36 -15
- package/dist/features/debug/index.js +1 -0
- package/dist/features/debug/renderer/performance-modal.js +17 -1
- package/dist/features/debug/services/perf-logger.js +129 -0
- package/dist/features/debug/services/performance-tracker.js +15 -3
- package/dist/features/headless/headless-runner.js +89 -5
- package/dist/services/http/adaptive-controller.js +153 -0
- package/dist/services/http/etag-store.js +91 -0
- package/dist/services/http/resizable-semaphore.js +71 -0
- package/dist/services/http/retry.js +23 -1
- package/dist/services/npm-registry.js +195 -86
- package/dist/services/package-manager-detector.js +4 -0
- package/dist/utils/debug-logger.js +8 -1
- package/dist/utils/filesystem/scan.js +13 -2
- package/dist/utils/index.js +1 -0
- package/dist/utils/local-env.js +81 -0
- package/package.json +7 -10
- package/dist/services/cache-manager.js +0 -95
- package/dist/services/persistent-cache.js +0 -237
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.packageCache = exports.CacheManager = void 0;
|
|
4
|
-
const config_1 = require("../config");
|
|
5
|
-
const persistent_cache_1 = require("./persistent-cache");
|
|
6
|
-
// Single TTL policy for both memory and disk.
|
|
7
|
-
class CacheManager {
|
|
8
|
-
memoryCache = new Map();
|
|
9
|
-
ttl;
|
|
10
|
-
constructor(ttl = config_1.CACHE_TTL) {
|
|
11
|
-
this.ttl = ttl;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Get cached data for a key, checking memory first, then disk.
|
|
15
|
-
* Returns null if not found or expired.
|
|
16
|
-
*/
|
|
17
|
-
get(key) {
|
|
18
|
-
// Check in-memory cache first (fastest)
|
|
19
|
-
const memoryCached = this.memoryCache.get(key);
|
|
20
|
-
if (memoryCached && Date.now() - memoryCached.timestamp < this.ttl) {
|
|
21
|
-
return memoryCached.data;
|
|
22
|
-
}
|
|
23
|
-
// Check persistent disk cache (survives restarts)
|
|
24
|
-
const diskCached = persistent_cache_1.persistentCache.get(key);
|
|
25
|
-
if (diskCached && Date.now() - diskCached.timestamp < this.ttl) {
|
|
26
|
-
// Populate in-memory cache for subsequent accesses
|
|
27
|
-
this.memoryCache.set(key, {
|
|
28
|
-
data: diskCached,
|
|
29
|
-
timestamp: diskCached.timestamp,
|
|
30
|
-
});
|
|
31
|
-
return diskCached;
|
|
32
|
-
}
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Store data in both memory and disk cache.
|
|
37
|
-
*/
|
|
38
|
-
set(key, data) {
|
|
39
|
-
// Cache in memory
|
|
40
|
-
this.memoryCache.set(key, {
|
|
41
|
-
data,
|
|
42
|
-
timestamp: Date.now(),
|
|
43
|
-
});
|
|
44
|
-
// Cache to disk for persistence
|
|
45
|
-
persistent_cache_1.persistentCache.set(key, data);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Get data from cache or fetch it using the provided fetcher function.
|
|
49
|
-
* This is the main entry point for cache-aside pattern.
|
|
50
|
-
*/
|
|
51
|
-
async getOrFetch(key, fetcher) {
|
|
52
|
-
// Try cache first
|
|
53
|
-
const cached = this.get(key);
|
|
54
|
-
if (cached) {
|
|
55
|
-
return cached;
|
|
56
|
-
}
|
|
57
|
-
// Fetch fresh data
|
|
58
|
-
const data = await fetcher();
|
|
59
|
-
if (data) {
|
|
60
|
-
this.set(key, data);
|
|
61
|
-
}
|
|
62
|
-
return data;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Check if a key exists and is not expired in cache.
|
|
66
|
-
*/
|
|
67
|
-
has(key) {
|
|
68
|
-
return this.get(key) !== null;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Clear in-memory cache (useful for testing).
|
|
72
|
-
*/
|
|
73
|
-
clear() {
|
|
74
|
-
this.memoryCache.clear();
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Flush pending disk cache writes.
|
|
78
|
-
*/
|
|
79
|
-
flush() {
|
|
80
|
-
persistent_cache_1.persistentCache.flush();
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Get cache statistics.
|
|
84
|
-
*/
|
|
85
|
-
getStats() {
|
|
86
|
-
return {
|
|
87
|
-
memoryEntries: this.memoryCache.size,
|
|
88
|
-
diskStats: persistent_cache_1.persistentCache.getStats(),
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
exports.CacheManager = CacheManager;
|
|
93
|
-
// Default package version cache instance
|
|
94
|
-
exports.packageCache = new CacheManager();
|
|
95
|
-
//# sourceMappingURL=cache-manager.js.map
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.persistentCache = void 0;
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
|
-
const path_1 = require("path");
|
|
9
|
-
const env_paths_1 = __importDefault(require("env-paths"));
|
|
10
|
-
const config_1 = require("../config");
|
|
11
|
-
// Maximum cache size (number of packages)
|
|
12
|
-
const MAX_CACHE_ENTRIES = 5000;
|
|
13
|
-
// Cache file format version (increment when structure changes)
|
|
14
|
-
const CACHE_VERSION = 2;
|
|
15
|
-
/**
|
|
16
|
-
* Persistent cache manager for package registry data.
|
|
17
|
-
* Stores cache on disk for fast repeated runs across CLI invocations.
|
|
18
|
-
*/
|
|
19
|
-
class PersistentCacheManager {
|
|
20
|
-
cacheDir;
|
|
21
|
-
indexPath;
|
|
22
|
-
index = null;
|
|
23
|
-
dirty = false;
|
|
24
|
-
constructor() {
|
|
25
|
-
const paths = (0, env_paths_1.default)(config_1.PACKAGE_NAME);
|
|
26
|
-
this.cacheDir = (0, path_1.join)(paths.cache, 'registry');
|
|
27
|
-
this.indexPath = (0, path_1.join)(this.cacheDir, 'index.json');
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Ensure cache directory exists
|
|
31
|
-
*/
|
|
32
|
-
ensureCacheDir() {
|
|
33
|
-
if (!(0, fs_1.existsSync)(this.cacheDir)) {
|
|
34
|
-
(0, fs_1.mkdirSync)(this.cacheDir, { recursive: true });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Load cache index from disk
|
|
39
|
-
*/
|
|
40
|
-
loadIndex() {
|
|
41
|
-
if (this.index) {
|
|
42
|
-
return this.index;
|
|
43
|
-
}
|
|
44
|
-
try {
|
|
45
|
-
if ((0, fs_1.existsSync)(this.indexPath)) {
|
|
46
|
-
const content = (0, fs_1.readFileSync)(this.indexPath, 'utf-8');
|
|
47
|
-
const parsed = JSON.parse(content);
|
|
48
|
-
// Check cache version - invalidate if outdated
|
|
49
|
-
if (parsed.version !== CACHE_VERSION) {
|
|
50
|
-
this.clearCache();
|
|
51
|
-
this.index = { version: CACHE_VERSION, entries: {} };
|
|
52
|
-
return this.index;
|
|
53
|
-
}
|
|
54
|
-
this.index = parsed;
|
|
55
|
-
return this.index;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
catch {
|
|
59
|
-
// Corrupted index, start fresh
|
|
60
|
-
}
|
|
61
|
-
this.index = { version: CACHE_VERSION, entries: {} };
|
|
62
|
-
return this.index;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Save cache index to disk
|
|
66
|
-
*/
|
|
67
|
-
saveIndex() {
|
|
68
|
-
if (!this.dirty || !this.index) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
try {
|
|
72
|
-
this.ensureCacheDir();
|
|
73
|
-
(0, fs_1.writeFileSync)(this.indexPath, JSON.stringify(this.index), 'utf-8');
|
|
74
|
-
this.dirty = false;
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
// Silently fail - cache is not critical
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Generate a safe filename for a package name
|
|
82
|
-
*/
|
|
83
|
-
getFilename(packageName) {
|
|
84
|
-
// Handle scoped packages: @scope/name -> scope__name
|
|
85
|
-
const safeName = packageName.replace(/^@/, '').replace(/\//g, '__');
|
|
86
|
-
return `${safeName}.json`;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Get cached data for a package
|
|
90
|
-
*/
|
|
91
|
-
get(packageName) {
|
|
92
|
-
const index = this.loadIndex();
|
|
93
|
-
const entry = index.entries[packageName];
|
|
94
|
-
if (!entry) {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
// Read the actual cache file
|
|
98
|
-
try {
|
|
99
|
-
const filePath = (0, path_1.join)(this.cacheDir, entry.file);
|
|
100
|
-
if (!(0, fs_1.existsSync)(filePath)) {
|
|
101
|
-
delete index.entries[packageName];
|
|
102
|
-
this.dirty = true;
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
const content = (0, fs_1.readFileSync)(filePath, 'utf-8');
|
|
106
|
-
const cached = JSON.parse(content);
|
|
107
|
-
return {
|
|
108
|
-
latestVersion: cached.latestVersion,
|
|
109
|
-
allVersions: cached.allVersions,
|
|
110
|
-
timestamp: entry.timestamp,
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
catch {
|
|
114
|
-
// Corrupted cache file, remove from index
|
|
115
|
-
delete index.entries[packageName];
|
|
116
|
-
this.dirty = true;
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Store data for a package
|
|
122
|
-
*/
|
|
123
|
-
set(packageName, data) {
|
|
124
|
-
const index = this.loadIndex();
|
|
125
|
-
// Evict old entries if cache is too large
|
|
126
|
-
const entryCount = Object.keys(index.entries).length;
|
|
127
|
-
if (entryCount >= MAX_CACHE_ENTRIES) {
|
|
128
|
-
this.evictOldest(Math.floor(MAX_CACHE_ENTRIES * 0.1)); // Evict 10%
|
|
129
|
-
}
|
|
130
|
-
const filename = this.getFilename(packageName);
|
|
131
|
-
const entry = {
|
|
132
|
-
...data,
|
|
133
|
-
timestamp: Date.now(),
|
|
134
|
-
};
|
|
135
|
-
try {
|
|
136
|
-
this.ensureCacheDir();
|
|
137
|
-
const filePath = (0, path_1.join)(this.cacheDir, filename);
|
|
138
|
-
(0, fs_1.writeFileSync)(filePath, JSON.stringify(entry), 'utf-8');
|
|
139
|
-
index.entries[packageName] = {
|
|
140
|
-
file: filename,
|
|
141
|
-
timestamp: Date.now(),
|
|
142
|
-
};
|
|
143
|
-
this.dirty = true;
|
|
144
|
-
}
|
|
145
|
-
catch {
|
|
146
|
-
// Silently fail - cache is not critical
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Batch get multiple packages (returns map of found entries)
|
|
151
|
-
*/
|
|
152
|
-
getMany(packageNames) {
|
|
153
|
-
const results = new Map();
|
|
154
|
-
for (const name of packageNames) {
|
|
155
|
-
const cached = this.get(name);
|
|
156
|
-
if (cached) {
|
|
157
|
-
results.set(name, cached);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return results;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Batch set multiple packages
|
|
164
|
-
*/
|
|
165
|
-
setMany(entries) {
|
|
166
|
-
for (const [name, data] of entries) {
|
|
167
|
-
this.set(name, data);
|
|
168
|
-
}
|
|
169
|
-
this.flush();
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Evict oldest cache entries
|
|
173
|
-
*/
|
|
174
|
-
evictOldest(count) {
|
|
175
|
-
const index = this.loadIndex();
|
|
176
|
-
const entries = Object.entries(index.entries);
|
|
177
|
-
// Sort by timestamp (oldest first)
|
|
178
|
-
entries.sort((a, b) => a[1].timestamp - b[1].timestamp);
|
|
179
|
-
// Remove oldest entries
|
|
180
|
-
const toRemove = entries.slice(0, count);
|
|
181
|
-
for (const [packageName, entry] of toRemove) {
|
|
182
|
-
try {
|
|
183
|
-
const filePath = (0, path_1.join)(this.cacheDir, entry.file);
|
|
184
|
-
if ((0, fs_1.existsSync)(filePath)) {
|
|
185
|
-
(0, fs_1.unlinkSync)(filePath);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
catch {
|
|
189
|
-
// Ignore deletion errors
|
|
190
|
-
}
|
|
191
|
-
delete index.entries[packageName];
|
|
192
|
-
}
|
|
193
|
-
this.dirty = true;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Clear all cache
|
|
197
|
-
*/
|
|
198
|
-
clearCache() {
|
|
199
|
-
try {
|
|
200
|
-
if ((0, fs_1.existsSync)(this.cacheDir)) {
|
|
201
|
-
const files = (0, fs_1.readdirSync)(this.cacheDir);
|
|
202
|
-
for (const file of files) {
|
|
203
|
-
try {
|
|
204
|
-
(0, fs_1.unlinkSync)((0, path_1.join)(this.cacheDir, file));
|
|
205
|
-
}
|
|
206
|
-
catch {
|
|
207
|
-
// Ignore
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
catch {
|
|
213
|
-
// Ignore
|
|
214
|
-
}
|
|
215
|
-
this.index = { version: CACHE_VERSION, entries: {} };
|
|
216
|
-
this.dirty = true;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Flush pending changes to disk
|
|
220
|
-
*/
|
|
221
|
-
flush() {
|
|
222
|
-
this.saveIndex();
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Get cache statistics
|
|
226
|
-
*/
|
|
227
|
-
getStats() {
|
|
228
|
-
const index = this.loadIndex();
|
|
229
|
-
return {
|
|
230
|
-
entries: Object.keys(index.entries).length,
|
|
231
|
-
cacheDir: this.cacheDir,
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
// Export singleton instance
|
|
236
|
-
exports.persistentCache = new PersistentCacheManager();
|
|
237
|
-
//# sourceMappingURL=persistent-cache.js.map
|