@nx/js 16.4.0-beta.14 → 16.4.0-beta.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/js",
3
- "version": "16.4.0-beta.14",
3
+ "version": "16.4.0-beta.16",
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": {
@@ -39,9 +39,9 @@
39
39
  "@babel/preset-env": "^7.15.0",
40
40
  "@babel/preset-typescript": "^7.15.0",
41
41
  "@babel/runtime": "^7.14.8",
42
- "@nrwl/js": "16.4.0-beta.14",
43
- "@nx/devkit": "16.4.0-beta.14",
44
- "@nx/workspace": "16.4.0-beta.14",
42
+ "@nrwl/js": "16.4.0-beta.16",
43
+ "@nx/devkit": "16.4.0-beta.16",
44
+ "@nx/workspace": "16.4.0-beta.16",
45
45
  "@phenomnomnominal/tsquery": "~5.0.1",
46
46
  "babel-plugin-const-enum": "^1.0.1",
47
47
  "babel-plugin-macros": "^2.8.0",
@@ -69,5 +69,5 @@
69
69
  "access": "public"
70
70
  },
71
71
  "types": "./src/index.d.ts",
72
- "gitHead": "796c91c34b96d82306a62e90f9146ae8e68762b5"
72
+ "gitHead": "720cf9de0102e6829b93d259ef5f8955dbd983f1"
73
73
  }
@@ -135,80 +135,71 @@ function setupNpm(options) {
135
135
  }
136
136
  };
137
137
  }
138
- function getYarnUnsafeHttpWhitelist(isYarnV1, options) {
139
- return isYarnV1
140
- ? new Set(JSON.parse((0, child_process_1.execSync)(`yarn config get unsafeHttpWhitelist --json` + options.location ===
141
- 'home'
142
- ? ' --home'
143
- : '').toString()))
138
+ function getYarnUnsafeHttpWhitelist(isYarnV1) {
139
+ return !isYarnV1
140
+ ? new Set(JSON.parse((0, child_process_1.execSync)(`yarn config get unsafeHttpWhitelist --json`).toString()))
144
141
  : null;
145
142
  }
146
143
  function setYarnUnsafeHttpWhitelist(currentWhitelist, options) {
147
- (0, child_process_1.execSync)(`yarn config set unsafeHttpWhitelist --json '${JSON.stringify(Array.from(currentWhitelist))}'` +
148
- options.location ===
149
- 'home'
150
- ? ' --home'
151
- : '');
144
+ if (currentWhitelist.size > 1) {
145
+ (0, child_process_1.execSync)(`yarn config set unsafeHttpWhitelist --json '${JSON.stringify(Array.from(currentWhitelist))}'` + (options.location === 'user' ? ' --home' : ''));
146
+ }
147
+ else {
148
+ (0, child_process_1.execSync)(`yarn config unset unsafeHttpWhitelist` +
149
+ (options.location === 'user' ? ' --home' : ''));
150
+ }
152
151
  }
153
152
  function setupYarn(options) {
154
153
  var _a, _b, _c;
154
+ let isYarnV1;
155
155
  try {
156
- const isYarnV1 = (0, semver_1.major)((0, child_process_1.execSync)('yarn --version').toString().trim()) === 1;
157
- try {
158
- const registryConfigName = isYarnV1 ? 'registry' : 'npmRegistryServer';
159
- const yarnRegistryPath = (_c = (_b = (_a = (0, child_process_1.execSync)(`yarn config get ${registryConfigName}`)) === null || _a === void 0 ? void 0 : _a.toString()) === null || _b === void 0 ? void 0 : _b.trim()) === null || _c === void 0 ? void 0 : _c.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes
160
- (0, child_process_1.execSync)(`yarn config set ${registryConfigName} http://localhost:${options.port}/` +
161
- options.location ===
162
- 'home'
163
- ? ' --home'
164
- : '');
165
- devkit_1.logger.info(`Set yarn registry to http://localhost:${options.port}/`);
166
- const currentWhitelist = getYarnUnsafeHttpWhitelist(isYarnV1, options);
167
- let whitelistedLocalhost = false;
168
- if (!isYarnV1) {
169
- if (!currentWhitelist.has('localhost')) {
170
- whitelistedLocalhost = true;
171
- currentWhitelist.add('localhost');
172
- setYarnUnsafeHttpWhitelist(currentWhitelist, options);
173
- devkit_1.logger.info(`Whitelisted http://localhost:${options.port}/ as an unsafe http server`);
156
+ isYarnV1 = (0, semver_1.major)((0, child_process_1.execSync)('yarn --version').toString().trim()) === 1;
157
+ }
158
+ catch (_d) {
159
+ // This would fail if yarn is not installed which is okay
160
+ return () => { };
161
+ }
162
+ try {
163
+ const registryConfigName = isYarnV1 ? 'registry' : 'npmRegistryServer';
164
+ const yarnRegistryPath = (_c = (_b = (_a = (0, child_process_1.execSync)(`yarn config get ${registryConfigName}`)) === null || _a === void 0 ? void 0 : _a.toString()) === null || _b === void 0 ? void 0 : _b.trim()) === null || _c === void 0 ? void 0 : _c.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes
165
+ (0, child_process_1.execSync)(`yarn config set ${registryConfigName} http://localhost:${options.port}/` +
166
+ (options.location === 'user' ? ' --home' : ''));
167
+ devkit_1.logger.info(`Set yarn registry to http://localhost:${options.port}/`);
168
+ const currentWhitelist = getYarnUnsafeHttpWhitelist(isYarnV1);
169
+ let whitelistedLocalhost = false;
170
+ if (!isYarnV1 && !currentWhitelist.has('localhost')) {
171
+ whitelistedLocalhost = true;
172
+ currentWhitelist.add('localhost');
173
+ setYarnUnsafeHttpWhitelist(currentWhitelist, options);
174
+ devkit_1.logger.info(`Whitelisted http://localhost:${options.port}/ as an unsafe http server`);
175
+ }
176
+ return () => {
177
+ try {
178
+ if (yarnRegistryPath) {
179
+ (0, child_process_1.execSync)(`yarn config set ${registryConfigName} ${yarnRegistryPath}` +
180
+ (options.location === 'user' ? ' --home' : ''));
181
+ devkit_1.logger.info(`Reset yarn ${registryConfigName} to ${yarnRegistryPath}`);
174
182
  }
175
- }
176
- return () => {
177
- try {
178
- if (yarnRegistryPath) {
179
- (0, child_process_1.execSync)(`yarn config set ${registryConfigName} ${yarnRegistryPath}` +
180
- options.location ===
181
- 'home'
182
- ? ' --home'
183
- : '');
184
- devkit_1.logger.info(`Reset yarn ${registryConfigName} to ${yarnRegistryPath}`);
185
- }
186
- else {
187
- (0, child_process_1.execSync)(`yarn config delete ${registryConfigName}` + options.location ===
188
- 'home'
189
- ? ' --home'
190
- : '');
191
- }
192
- if (whitelistedLocalhost) {
193
- const currentWhitelist = getYarnUnsafeHttpWhitelist(isYarnV1, options);
194
- if (currentWhitelist.has('localhost')) {
195
- currentWhitelist.delete('localhost');
196
- setYarnUnsafeHttpWhitelist(currentWhitelist, options);
197
- devkit_1.logger.info(`Removed http://localhost:${options.port}/ as an unsafe http server`);
198
- }
199
- }
183
+ else {
184
+ (0, child_process_1.execSync)(`yarn config ${isYarnV1 ? 'delete' : 'unset'} ${registryConfigName}` +
185
+ (options.location === 'user' ? ' --home' : ''));
200
186
  }
201
- catch (e) {
202
- throw new Error(`Failed to reset yarn registry: ${e.message}`);
187
+ if (whitelistedLocalhost) {
188
+ const currentWhitelist = getYarnUnsafeHttpWhitelist(isYarnV1);
189
+ if (currentWhitelist.has('localhost')) {
190
+ currentWhitelist.delete('localhost');
191
+ setYarnUnsafeHttpWhitelist(currentWhitelist, options);
192
+ devkit_1.logger.info(`Removed http://localhost:${options.port}/ as an unsafe http server`);
193
+ }
203
194
  }
204
- };
205
- }
206
- catch (e) {
207
- throw new Error(`Failed to set yarn registry to http://localhost:${options.port}/: ${e.message}`);
208
- }
195
+ }
196
+ catch (e) {
197
+ throw new Error(`Failed to reset yarn registry: ${e.message}`);
198
+ }
199
+ };
209
200
  }
210
201
  catch (e) {
211
- return () => { };
202
+ throw new Error(`Failed to set yarn registry to http://localhost:${options.port}/: ${e.message}`);
212
203
  }
213
204
  }
214
205
  exports.default = verdaccioExecutor;
package/src/internal.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { resolveModuleByImport } from './utils/typescript/ast-utils';
2
2
  export { registerTsProject, registerTsConfigPaths, } from 'nx/src/plugins/js/utils/register';
3
3
  export { TargetProjectLocator } from 'nx/src/plugins/js/project-graph/build-dependencies/target-project-locator';
4
+ export { findProjectsNpmDependencies } from 'nx/src/plugins/js/package-json/create-package-json';
package/src/internal.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TargetProjectLocator = exports.registerTsConfigPaths = exports.registerTsProject = exports.resolveModuleByImport = void 0;
3
+ exports.findProjectsNpmDependencies = exports.TargetProjectLocator = exports.registerTsConfigPaths = exports.registerTsProject = exports.resolveModuleByImport = void 0;
4
4
  var ast_utils_1 = require("./utils/typescript/ast-utils");
5
5
  Object.defineProperty(exports, "resolveModuleByImport", { enumerable: true, get: function () { return ast_utils_1.resolveModuleByImport; } });
6
6
  // eslint-disable-next-line @typescript-eslint/no-restricted-imports
@@ -10,3 +10,6 @@ Object.defineProperty(exports, "registerTsConfigPaths", { enumerable: true, get:
10
10
  // eslint-disable-next-line @typescript-eslint/no-restricted-imports
11
11
  var target_project_locator_1 = require("nx/src/plugins/js/project-graph/build-dependencies/target-project-locator");
12
12
  Object.defineProperty(exports, "TargetProjectLocator", { enumerable: true, get: function () { return target_project_locator_1.TargetProjectLocator; } });
13
+ // eslint-disable-next-line @typescript-eslint/no-restricted-imports
14
+ var create_package_json_1 = require("nx/src/plugins/js/package-json/create-package-json");
15
+ Object.defineProperty(exports, "findProjectsNpmDependencies", { enumerable: true, get: function () { return create_package_json_1.findProjectsNpmDependencies; } });
@@ -28,8 +28,12 @@ function startLocalRegistry({ localRegistryTarget, storage, verbose, }) {
28
28
  console.log('Local registry started on port ' + port);
29
29
  const registry = `http://localhost:${port}`;
30
30
  process.env.npm_config_registry = registry;
31
- process.env.YARN_REGISTRY = registry;
32
31
  (0, child_process_1.execSync)(`npm config set //localhost:${port}/:_authToken "secretVerdaccioToken"`);
32
+ // yarnv1
33
+ process.env.YARN_REGISTRY = registry;
34
+ // yarnv2
35
+ process.env.YARN_NPM_REGISTRY_SERVER = registry;
36
+ process.env.YARN_UNSAFE_HTTP_WHITELIST = 'localhost';
33
37
  console.log('Set npm and yarn config registry to ' + registry);
34
38
  resolve(() => {
35
39
  childProcess.kill();
@@ -85,8 +85,7 @@ function getHelperDependenciesFromProjectGraph(contextRoot, sourceProject, proje
85
85
  const internalDependencies = sourceDependencies.reduce((result, dependency) => {
86
86
  // we check if a dependency is part of the workspace and if it's a library
87
87
  // because we wouldn't want to include external dependencies (npm packages)
88
- if (!dependency.target.startsWith('npm:') &&
89
- !!projectGraph.nodes[dependency.target] &&
88
+ if (projectGraph.nodes[dependency.target] &&
90
89
  projectGraph.nodes[dependency.target].type === 'lib') {
91
90
  const targetData = projectGraph.nodes[dependency.target].data;
92
91
  // check if the dependency has a buildable target with one of the jsExecutors