@nx/js 19.5.2 → 19.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/js",
3
- "version": "19.5.2",
3
+ "version": "19.5.3",
4
4
  "private": false,
5
5
  "description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ",
6
6
  "repository": {
@@ -58,9 +58,9 @@
58
58
  "semver": "^7.5.3",
59
59
  "source-map-support": "0.5.19",
60
60
  "tslib": "^2.3.0",
61
- "@nx/devkit": "19.5.2",
62
- "@nx/workspace": "19.5.2",
63
- "@nrwl/js": "19.5.2"
61
+ "@nx/devkit": "19.5.3",
62
+ "@nx/workspace": "19.5.3",
63
+ "@nrwl/js": "19.5.3"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "verdaccio": "^5.0.4"
@@ -4,4 +4,5 @@ export interface VerdaccioExecutorSchema {
4
4
  port?: number;
5
5
  config?: string;
6
6
  clear?: boolean;
7
+ scopes?: string[];
7
8
  }
@@ -28,6 +28,13 @@
28
28
  "type": "boolean",
29
29
  "description": "Clear local registry storage before starting Verdaccio",
30
30
  "default": true
31
+ },
32
+ "scopes": {
33
+ "type": "array",
34
+ "description": "Scopes to be added to the Verdaccio config",
35
+ "items": {
36
+ "type": "string"
37
+ }
31
38
  }
32
39
  },
33
40
  "required": ["port"]
@@ -115,41 +115,55 @@ function setupNpm(options) {
115
115
  catch (e) {
116
116
  return () => { };
117
117
  }
118
- let npmRegistryPath;
118
+ let npmRegistryPaths = [];
119
+ const scopes = ['', ...(options.scopes || [])];
119
120
  try {
120
- npmRegistryPath = (0, child_process_1.execSync)(`npm config get registry --location ${options.location}`, { env })
121
- ?.toString()
122
- ?.trim()
123
- ?.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes
124
- (0, child_process_1.execSync)(`npm config set registry http://localhost:${options.port}/ --location ${options.location}`, { env });
125
- (0, child_process_1.execSync)(`npm config set //localhost:${options.port}/:_authToken="secretVerdaccioToken" --location ${options.location}`, { env });
126
- devkit_1.logger.info(`Set npm registry to http://localhost:${options.port}/`);
121
+ scopes.forEach((scope) => {
122
+ const scopeName = scope ? `${scope}:` : '';
123
+ try {
124
+ npmRegistryPaths.push((0, child_process_1.execSync)(`npm config get '${scopeName}registry' --location ${options.location}`, { env })
125
+ ?.toString()
126
+ ?.trim()
127
+ ?.replace('\u001b[2K\u001b[1G', '') // strip out ansi codes
128
+ );
129
+ (0, child_process_1.execSync)(`npm config set '${scopeName}registry' http://localhost:${options.port}/ --location ${options.location}`, { env });
130
+ (0, child_process_1.execSync)(`npm config set //localhost:${options.port}/:_authToken="secretVerdaccioToken" --location ${options.location}`, { env });
131
+ devkit_1.logger.info(`Set npm ${scopeName}registry to http://localhost:${options.port}/`);
132
+ }
133
+ catch (e) {
134
+ throw new Error(`Failed to set npm ${scopeName}registry to http://localhost:${options.port}/: ${e.message}`);
135
+ }
136
+ });
137
+ return () => {
138
+ try {
139
+ const currentNpmRegistryPath = (0, child_process_1.execSync)(`npm config get registry --location ${options.location}`, { env })
140
+ ?.toString()
141
+ ?.trim()
142
+ ?.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes
143
+ if (npmRegistryPaths.length > 0 &&
144
+ currentNpmRegistryPath.includes('localhost')) {
145
+ scopes.forEach((scope, index) => {
146
+ const scopeName = scope ? `${scope}:` : '';
147
+ (0, child_process_1.execSync)(`npm config set '${scopeName}registry' ${npmRegistryPaths[index]} --location ${options.location}`, { env });
148
+ devkit_1.logger.info(`Reset npm ${scopeName}registry to ${npmRegistryPaths[index]}`);
149
+ });
150
+ }
151
+ else {
152
+ (0, child_process_1.execSync)(`npm config delete registry --location ${options.location}`, {
153
+ env,
154
+ });
155
+ devkit_1.logger.info('Cleared custom npm registry');
156
+ }
157
+ (0, child_process_1.execSync)(`npm config delete //localhost:${options.port}/:_authToken --location ${options.location}`, { env });
158
+ }
159
+ catch (e) {
160
+ throw new Error(`Failed to reset npm registry: ${e.message}`);
161
+ }
162
+ };
127
163
  }
128
164
  catch (e) {
129
165
  throw new Error(`Failed to set npm registry to http://localhost:${options.port}/: ${e.message}`);
130
166
  }
131
- return () => {
132
- try {
133
- const currentNpmRegistryPath = (0, child_process_1.execSync)(`npm config get registry --location ${options.location}`, { env })
134
- ?.toString()
135
- ?.trim()
136
- ?.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes
137
- if (npmRegistryPath && currentNpmRegistryPath.includes('localhost')) {
138
- (0, child_process_1.execSync)(`npm config set registry ${npmRegistryPath} --location ${options.location}`, { env });
139
- devkit_1.logger.info(`Reset npm registry to ${npmRegistryPath}`);
140
- }
141
- else {
142
- (0, child_process_1.execSync)(`npm config delete registry --location ${options.location}`, {
143
- env,
144
- });
145
- devkit_1.logger.info('Cleared custom npm registry');
146
- }
147
- (0, child_process_1.execSync)(`npm config delete //localhost:${options.port}/:_authToken --location ${options.location}`, { env });
148
- }
149
- catch (e) {
150
- throw new Error(`Failed to reset npm registry: ${e.message}`);
151
- }
152
- };
153
167
  }
154
168
  function getYarnUnsafeHttpWhitelist(isYarnV1) {
155
169
  return !isYarnV1
@@ -169,6 +183,8 @@ function setYarnUnsafeHttpWhitelist(currentWhitelist, options) {
169
183
  }
170
184
  function setupYarn(options) {
171
185
  let isYarnV1;
186
+ let yarnRegistryPaths = [];
187
+ const scopes = ['', ...(options.scopes || [])];
172
188
  try {
173
189
  isYarnV1 =
174
190
  (0, semver_1.major)((0, child_process_1.execSync)('yarn --version', { env }).toString().trim()) === 1;
@@ -179,15 +195,19 @@ function setupYarn(options) {
179
195
  }
180
196
  try {
181
197
  const registryConfigName = isYarnV1 ? 'registry' : 'npmRegistryServer';
182
- const yarnRegistryPath = (0, child_process_1.execSync)(`yarn config get ${registryConfigName}`, {
183
- env,
184
- })
185
- ?.toString()
186
- ?.trim()
187
- ?.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes
188
- (0, child_process_1.execSync)(`yarn config set ${registryConfigName} http://localhost:${options.port}/` +
189
- (options.location === 'user' ? ' --home' : ''), { env });
190
- devkit_1.logger.info(`Set yarn registry to http://localhost:${options.port}/`);
198
+ scopes.forEach((scope) => {
199
+ const scopeName = scope ? `${scope}:` : '';
200
+ yarnRegistryPaths.push((0, child_process_1.execSync)(`yarn config get ${scopeName}${registryConfigName}`, {
201
+ env,
202
+ })
203
+ ?.toString()
204
+ ?.trim()
205
+ ?.replace('\u001b[2K\u001b[1G', '') // strip out ansi codes
206
+ );
207
+ (0, child_process_1.execSync)(`yarn config set ${scopeName}${registryConfigName} http://localhost:${options.port}/` +
208
+ (options.location === 'user' ? ' --home' : ''), { env });
209
+ devkit_1.logger.info(`Set yarn ${scopeName}registry to http://localhost:${options.port}/`);
210
+ });
191
211
  const currentWhitelist = getYarnUnsafeHttpWhitelist(isYarnV1);
192
212
  let whitelistedLocalhost = false;
193
213
  if (!isYarnV1 && !currentWhitelist.has('localhost')) {
@@ -202,10 +222,14 @@ function setupYarn(options) {
202
222
  ?.toString()
203
223
  ?.trim()
204
224
  ?.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes
205
- if (yarnRegistryPath && currentYarnRegistryPath.includes('localhost')) {
206
- (0, child_process_1.execSync)(`yarn config set ${registryConfigName} ${yarnRegistryPath}` +
207
- (options.location === 'user' ? ' --home' : ''), { env });
208
- devkit_1.logger.info(`Reset yarn ${registryConfigName} to ${yarnRegistryPath}`);
225
+ if (yarnRegistryPaths.length > 0 &&
226
+ currentYarnRegistryPath.includes('localhost')) {
227
+ scopes.forEach((scope, index) => {
228
+ const scopeName = scope ? `${scope}:` : '';
229
+ (0, child_process_1.execSync)(`yarn config set ${scopeName}${registryConfigName} ${yarnRegistryPaths[index]}` +
230
+ (options.location === 'user' ? ' --home' : ''), { env });
231
+ devkit_1.logger.info(`Reset yarn ${scopeName}${registryConfigName} to ${yarnRegistryPaths[index]}`);
232
+ });
209
233
  }
210
234
  else {
211
235
  (0, child_process_1.execSync)(`yarn config ${isYarnV1 ? 'delete' : 'unset'} ${registryConfigName}` +