com.jimuwd.xian.registry-proxy 1.0.14 → 1.0.16
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/index.js +1 -8
- package/package.json +1 -1
- package/src/index.ts +1 -8
package/dist/index.js
CHANGED
|
@@ -58,7 +58,6 @@ function normalizeUrl(url) {
|
|
|
58
58
|
}
|
|
59
59
|
function resolvePath(path) {
|
|
60
60
|
const resolved = path.startsWith('~/') ? join(homedir(), path.slice(2)) : resolve(path);
|
|
61
|
-
console.debug(`Resolved path: ${path} -> ${resolved}`);
|
|
62
61
|
return resolved;
|
|
63
62
|
}
|
|
64
63
|
function removeRegistryPrefix(tarballUrl, registries) {
|
|
@@ -176,7 +175,6 @@ export async function startProxyServer(proxyConfigPath, localYarnConfigPath, glo
|
|
|
176
175
|
const headers = token ? { Authorization: `Bearer ${token}` } : undefined;
|
|
177
176
|
const response = await fetch(targetUrl, { headers });
|
|
178
177
|
console.log(`Response from ${url}: ${response.status} ${response.statusText}`);
|
|
179
|
-
console.debug(`Response headers from ${url}:`, Object.fromEntries(response.headers.entries()));
|
|
180
178
|
return response.ok ? response : null;
|
|
181
179
|
}
|
|
182
180
|
catch (e) {
|
|
@@ -195,11 +193,9 @@ export async function startProxyServer(proxyConfigPath, localYarnConfigPath, glo
|
|
|
195
193
|
return;
|
|
196
194
|
}
|
|
197
195
|
const contentType = successResponse.headers.get('Content-Type') || 'application/octet-stream';
|
|
198
|
-
console.debug(`Content-Type: ${contentType}`);
|
|
199
196
|
if (contentType.includes('application/json')) {
|
|
200
197
|
try {
|
|
201
198
|
const data = await successResponse.json();
|
|
202
|
-
console.debug('JSON response data:', JSON.stringify(data, null, 2));
|
|
203
199
|
if (data.versions) {
|
|
204
200
|
const proxyBase = `${proxyConfig.https ? 'https' : 'http'}://${req.headers.host || 'localhost:' + proxyPort}${basePath}`;
|
|
205
201
|
console.debug(`Rewriting tarball URLs with proxy base: ${proxyBase}`);
|
|
@@ -215,7 +211,6 @@ export async function startProxyServer(proxyConfigPath, localYarnConfigPath, glo
|
|
|
215
211
|
}
|
|
216
212
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
217
213
|
const jsonResponse = JSON.stringify(data);
|
|
218
|
-
console.debug(`Sending JSON response: ${jsonResponse}`);
|
|
219
214
|
res.end(jsonResponse);
|
|
220
215
|
}
|
|
221
216
|
catch (e) {
|
|
@@ -233,7 +228,6 @@ export async function startProxyServer(proxyConfigPath, localYarnConfigPath, glo
|
|
|
233
228
|
'Content-Type': successResponse.headers.get('Content-Type'),
|
|
234
229
|
'Content-Length': successResponse.headers.get('Content-Length'),
|
|
235
230
|
};
|
|
236
|
-
console.debug(`Streaming response with headers:`, safeHeaders);
|
|
237
231
|
res.writeHead(successResponse.status, safeHeaders);
|
|
238
232
|
successResponse.body.pipe(res).on('error', (err) => {
|
|
239
233
|
console.error(`Stream error for ${relativePath}:`, err);
|
|
@@ -246,7 +240,6 @@ export async function startProxyServer(proxyConfigPath, localYarnConfigPath, glo
|
|
|
246
240
|
const { key, cert } = proxyConfig.https;
|
|
247
241
|
const keyPath = resolvePath(key);
|
|
248
242
|
const certPath = resolvePath(cert);
|
|
249
|
-
console.debug(`Loading HTTPS key: ${keyPath}, cert: ${certPath}`);
|
|
250
243
|
try {
|
|
251
244
|
await fsPromises.access(keyPath);
|
|
252
245
|
await fsPromises.access(certPath);
|
|
@@ -286,7 +279,7 @@ export async function startProxyServer(proxyConfigPath, localYarnConfigPath, glo
|
|
|
286
279
|
}
|
|
287
280
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
288
281
|
const [, , configPath, localYarnPath, globalYarnPath, port] = process.argv;
|
|
289
|
-
console.
|
|
282
|
+
console.log(`Starting server with args: configPath=${configPath}, localYarnPath=${localYarnPath}, globalYarnPath=${globalYarnPath}, port=${port}`);
|
|
290
283
|
startProxyServer(configPath, localYarnPath, globalYarnPath, parseInt(port, 10) || 0).catch(err => {
|
|
291
284
|
console.error('Failed to start server:', err);
|
|
292
285
|
process.exit(1);
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -77,7 +77,6 @@ function normalizeUrl(url: string): string {
|
|
|
77
77
|
|
|
78
78
|
function resolvePath(path: string): string {
|
|
79
79
|
const resolved = path.startsWith('~/') ? join(homedir(), path.slice(2)) : resolve(path);
|
|
80
|
-
console.debug(`Resolved path: ${path} -> ${resolved}`);
|
|
81
80
|
return resolved;
|
|
82
81
|
}
|
|
83
82
|
|
|
@@ -215,7 +214,6 @@ export async function startProxyServer(
|
|
|
215
214
|
const headers = token ? { Authorization: `Bearer ${token}` } : undefined;
|
|
216
215
|
const response = await fetch(targetUrl, { headers });
|
|
217
216
|
console.log(`Response from ${url}: ${response.status} ${response.statusText}`);
|
|
218
|
-
console.debug(`Response headers from ${url}:`, Object.fromEntries(response.headers.entries()));
|
|
219
217
|
return response.ok ? response : null;
|
|
220
218
|
} catch (e) {
|
|
221
219
|
console.error(`Failed to fetch from ${url}:`, e);
|
|
@@ -234,11 +232,9 @@ export async function startProxyServer(
|
|
|
234
232
|
}
|
|
235
233
|
|
|
236
234
|
const contentType = successResponse.headers.get('Content-Type') || 'application/octet-stream';
|
|
237
|
-
console.debug(`Content-Type: ${contentType}`);
|
|
238
235
|
if (contentType.includes('application/json')) {
|
|
239
236
|
try {
|
|
240
237
|
const data = await successResponse.json() as PackageData;
|
|
241
|
-
console.debug('JSON response data:', JSON.stringify(data, null, 2));
|
|
242
238
|
if (data.versions) {
|
|
243
239
|
const proxyBase = `${proxyConfig.https ? 'https' : 'http'}://${req.headers.host || 'localhost:' + proxyPort}${basePath}`;
|
|
244
240
|
console.debug(`Rewriting tarball URLs with proxy base: ${proxyBase}`);
|
|
@@ -254,7 +250,6 @@ export async function startProxyServer(
|
|
|
254
250
|
}
|
|
255
251
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
256
252
|
const jsonResponse = JSON.stringify(data);
|
|
257
|
-
console.debug(`Sending JSON response: ${jsonResponse}`);
|
|
258
253
|
res.end(jsonResponse);
|
|
259
254
|
} catch (e) {
|
|
260
255
|
console.error('Failed to parse JSON response:', e);
|
|
@@ -270,7 +265,6 @@ export async function startProxyServer(
|
|
|
270
265
|
'Content-Type': successResponse.headers.get('Content-Type'),
|
|
271
266
|
'Content-Length': successResponse.headers.get('Content-Length'),
|
|
272
267
|
};
|
|
273
|
-
console.debug(`Streaming response with headers:`, safeHeaders);
|
|
274
268
|
res.writeHead(successResponse.status, safeHeaders);
|
|
275
269
|
successResponse.body.pipe(res).on('error', (err:any) => {
|
|
276
270
|
console.error(`Stream error for ${relativePath}:`, err);
|
|
@@ -284,7 +278,6 @@ export async function startProxyServer(
|
|
|
284
278
|
const { key, cert } = proxyConfig.https;
|
|
285
279
|
const keyPath = resolvePath(key);
|
|
286
280
|
const certPath = resolvePath(cert);
|
|
287
|
-
console.debug(`Loading HTTPS key: ${keyPath}, cert: ${certPath}`);
|
|
288
281
|
try {
|
|
289
282
|
await fsPromises.access(keyPath);
|
|
290
283
|
await fsPromises.access(certPath);
|
|
@@ -324,7 +317,7 @@ export async function startProxyServer(
|
|
|
324
317
|
|
|
325
318
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
326
319
|
const [,, configPath, localYarnPath, globalYarnPath, port] = process.argv;
|
|
327
|
-
console.
|
|
320
|
+
console.log(`Starting server with args: configPath=${configPath}, localYarnPath=${localYarnPath}, globalYarnPath=${globalYarnPath}, port=${port}`);
|
|
328
321
|
startProxyServer(
|
|
329
322
|
configPath,
|
|
330
323
|
localYarnPath,
|