com.jimuwd.xian.registry-proxy 1.1.24 → 1.1.26
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/client/yarn-install.js +17 -16
- package/package.json +2 -2
|
@@ -99,14 +99,13 @@ async function startLocalRegistryProxyServerAndYarnInstallWithoutCleanup() {
|
|
|
99
99
|
// Change to project root
|
|
100
100
|
process.chdir(INSTALLATION_ROOT);
|
|
101
101
|
// Start registry proxy
|
|
102
|
-
console.log(`Starting registry-proxy@${REGISTRY_PROXY_VERSION} in the background...`);
|
|
102
|
+
console.log(`Starting registry-proxy@${REGISTRY_PROXY_VERSION} local server in the background...`);
|
|
103
103
|
// 提示:这里借助了execa调用"yarn dlx"后台运行registry proxy server的功能,没有直接使用本地ts函数调用的方式启动本地代理服务器,因为后者不太容易达到后台运行的效果。
|
|
104
104
|
proxyProcess = execa('yarn', [
|
|
105
|
-
'dlx', '-p', `com.jimuwd.xian.registry-proxy@${REGISTRY_PROXY_VERSION}`,
|
|
106
|
-
'registry-proxy',
|
|
107
|
-
'.
|
|
108
|
-
'.yarnrc.yml',
|
|
109
|
-
path.join(process.env.HOME || '', '.yarnrc.yml'),
|
|
105
|
+
'dlx', '-p', `com.jimuwd.xian.registry-proxy@${REGISTRY_PROXY_VERSION}`, 'registry-proxy',
|
|
106
|
+
/*是不是可以传空,让server使用默认值?*/ '.registry-proxy.yml',
|
|
107
|
+
/*是不是可以传空,让server使用默认值?*/ '.yarnrc.yml',
|
|
108
|
+
/*是不是可以传空,让server使用默认值?*/ path.join(process.env.HOME || '', '.yarnrc.yml'),
|
|
110
109
|
/*之前是写死的静态端口40061,它有个缺点就是本地无法为多个项目工程并发执行yarn-install,现改为使用随机可用端口作为本地代理服务器端口,传'0'/''空串即可*/ '0'
|
|
111
110
|
], {
|
|
112
111
|
detached: true,
|
|
@@ -114,14 +113,14 @@ async function startLocalRegistryProxyServerAndYarnInstallWithoutCleanup() {
|
|
|
114
113
|
});
|
|
115
114
|
registerCleanup(async (_exitCode) => {
|
|
116
115
|
if (proxyProcess && !proxyProcess.killed) {
|
|
117
|
-
console.log('Stopping proxy server...');
|
|
116
|
+
console.log('Stopping registry-proxy local server...');
|
|
118
117
|
try {
|
|
119
118
|
proxyProcess.kill('SIGTERM');
|
|
120
119
|
await proxyProcess;
|
|
121
|
-
console.log('
|
|
120
|
+
console.log('Registry-proxy local server stopped.');
|
|
122
121
|
}
|
|
123
122
|
catch (err) { // cleanup程序不要抛出异常
|
|
124
|
-
console.error('
|
|
123
|
+
console.error('Registry-proxy local server stopping with error', err);
|
|
125
124
|
}
|
|
126
125
|
}
|
|
127
126
|
});
|
|
@@ -139,23 +138,25 @@ async function startLocalRegistryProxyServerAndYarnInstallWithoutCleanup() {
|
|
|
139
138
|
// Configure yarn
|
|
140
139
|
const { exitCode, stdout } = await execa('yarn', ['config', 'get', 'npmRegistryServer']);
|
|
141
140
|
const npmRegistryServer = (exitCode === 0 && stdout) ? stdout.trim() : undefined;
|
|
142
|
-
const localNpmRegistryServer = (await readYarnConfig('.yarnrc.yml')).npmRegistryServer;
|
|
141
|
+
const localNpmRegistryServer = (await readYarnConfig('.yarnrc.yml')).npmRegistryServer?.trim();
|
|
143
142
|
if (localNpmRegistryServer && localNpmRegistryServer === npmRegistryServer)
|
|
144
|
-
console.log(
|
|
143
|
+
console.log(`NpmRegistryServer value in project local .yarnrc.yml: ${localNpmRegistryServer}`);
|
|
145
144
|
else
|
|
146
|
-
console.log(
|
|
145
|
+
console.log(`NpmRegistryServer value in ${path.join(process.env.HOME || '', '.yarnrc.yml')}: ${npmRegistryServer}`);
|
|
147
146
|
await execa('yarn', ['config', 'set', 'npmRegistryServer', `http://127.0.0.1:${PROXY_PORT}`]);
|
|
148
|
-
console.log(`Set npmRegistryServer to http://127.0.0.1:${PROXY_PORT}`);
|
|
147
|
+
console.log(`Set npmRegistryServer config value to http://127.0.0.1:${PROXY_PORT}`);
|
|
148
|
+
console.log('Read npmRegistryServer after set using yarn config get cmd:', (await execa('yarn', ['config', 'get', 'npmRegistryServer'])).stdout);
|
|
149
|
+
console.log('Read npmRegistryServer after set using reading .yarnrc.yml file:', (await readYarnConfig('.yarnrc.yml')).npmRegistryServer?.trim());
|
|
149
150
|
registerCleanup(async () => {
|
|
150
151
|
try {
|
|
151
152
|
//if (npmRegistryServer) {//不能用这个变量来恢复为原来的 npmRegistryServer,因为它可能是全局配置~/.yarnrc.yml内的配置值或yarn工具官方默认值,而非本地.yarnrc.yml配置值。
|
|
152
|
-
if (localNpmRegistryServer
|
|
153
|
+
if (localNpmRegistryServer) { //恢复为本地配置文件原来的 npmRegistryServer 配置值
|
|
153
154
|
await execa('yarn', ['config', 'set', 'npmRegistryServer', localNpmRegistryServer]);
|
|
154
|
-
console.log(`Recover npmRegistryServer to ${localNpmRegistryServer}
|
|
155
|
+
console.log(`Recover npmRegistryServer to ${localNpmRegistryServer} in local '.yarnrc.yml'.`);
|
|
155
156
|
}
|
|
156
157
|
else { //原来本地配置文件中没有npmRegistryServer,则重置npmRegistryServer
|
|
157
158
|
await execa('yarn', ['config', 'unset', 'npmRegistryServer']);
|
|
158
|
-
console.log(`Unset npmRegistryServer.`);
|
|
159
|
+
console.log(`Unset npmRegistryServer value in local '.yarnrc.yml'.`);
|
|
159
160
|
}
|
|
160
161
|
}
|
|
161
162
|
catch (err) { //cleanup程序不要抛出异常
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "com.jimuwd.xian.registry-proxy",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.26",
|
|
4
4
|
"description": "A lightweight npm registry local proxy with fallback support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/server/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"execa": "9.5.2",
|
|
21
|
-
"js-yaml": "4.1.
|
|
21
|
+
"js-yaml": "4.1.1",
|
|
22
22
|
"node-fetch": "3.3.2"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|