@nx/js 21.5.2 → 21.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.
@@ -2,7 +2,7 @@ import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import type { LibraryGeneratorSchema, NormalizedLibraryGeneratorOptions } from './schema';
3
3
  export declare function libraryGenerator(tree: Tree, schema: LibraryGeneratorSchema): Promise<GeneratorCallback>;
4
4
  export declare function libraryGeneratorInternal(tree: Tree, schema: LibraryGeneratorSchema): Promise<GeneratorCallback>;
5
- export type AddLintOptions = Pick<NormalizedLibraryGeneratorOptions, 'name' | 'linter' | 'projectRoot' | 'unitTestRunner' | 'js' | 'setParserOptionsProject' | 'rootProject' | 'bundler' | 'addPlugin'>;
5
+ export type AddLintOptions = Pick<NormalizedLibraryGeneratorOptions, 'name' | 'linter' | 'projectRoot' | 'unitTestRunner' | 'js' | 'setParserOptionsProject' | 'rootProject' | 'bundler' | 'addPlugin' | 'isUsingTsSolutionConfig'>;
6
6
  export declare function addLint(tree: Tree, options: AddLintOptions): Promise<GeneratorCallback>;
7
7
  export default libraryGenerator;
8
8
  //# sourceMappingURL=library.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/library/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iBAAiB,EAYjB,IAAI,EAKL,MAAM,YAAY,CAAC;AA0CpB,OAAO,KAAK,EAEV,sBAAsB,EACtB,iCAAiC,EAClC,MAAM,UAAU,CAAC;AASlB,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,8BAO/B;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,8BAsL/B;AA4HD,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,iCAAiC,EAC/B,MAAM,GACN,QAAQ,GACR,aAAa,GACb,gBAAgB,GAChB,IAAI,GACJ,yBAAyB,GACzB,aAAa,GACb,SAAS,GACT,WAAW,CACd,CAAC;AAEF,wBAAsB,OAAO,CAC3B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,iBAAiB,CAAC,CAqG5B;AAivBD,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/library/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iBAAiB,EAYjB,IAAI,EAKL,MAAM,YAAY,CAAC;AA0CpB,OAAO,KAAK,EAEV,sBAAsB,EACtB,iCAAiC,EAClC,MAAM,UAAU,CAAC;AASlB,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,8BAO/B;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,8BAsL/B;AA4HD,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,iCAAiC,EAC/B,MAAM,GACN,QAAQ,GACR,aAAa,GACb,gBAAgB,GAChB,IAAI,GACJ,yBAAyB,GACzB,aAAa,GACb,SAAS,GACT,WAAW,GACX,yBAAyB,CAC5B,CAAC;AAEF,wBAAsB,OAAO,CAC3B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,iBAAiB,CAAC,CA4G5B;AAivBD,eAAe,gBAAgB,CAAC"}
@@ -272,7 +272,7 @@ async function addLint(tree, options) {
272
272
  // Since the build target is inferred now, we need to let the generator know to add @nx/dependency-checks regardless.
273
273
  addPackageJsonDependencyChecks: options.bundler !== 'none',
274
274
  });
275
- const { addOverrideToLintConfig, lintConfigHasOverride, isEslintConfigSupported, updateOverrideInLintConfig,
275
+ const { addOverrideToLintConfig, lintConfigHasOverride, isEslintConfigSupported, updateOverrideInLintConfig, addIgnoresToLintConfig,
276
276
  // nx-ignore-next-line
277
277
  } = require('@nx/eslint/src/generators/utils/eslint-file');
278
278
  // if config is not supported, we don't need to do anything
@@ -334,6 +334,10 @@ async function addLint(tree, options) {
334
334
  return o;
335
335
  });
336
336
  }
337
+ // Add out-tsc ignore pattern when using TS solution setup
338
+ if (options.isUsingTsSolutionConfig) {
339
+ addIgnoresToLintConfig(tree, options.projectRoot, ['**/out-tsc']);
340
+ }
337
341
  return task;
338
342
  }
339
343
  function addBabelRc(tree, options) {
@@ -0,0 +1,3 @@
1
+ export declare function isValidRange(range: string): boolean;
2
+ export declare function isMatchingDependencyRange(version: string, range: string): boolean;
3
+ //# sourceMappingURL=semver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semver.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/release/utils/semver.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,WAIzC;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,WAGvE"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidRange = isValidRange;
4
+ exports.isMatchingDependencyRange = isMatchingDependencyRange;
5
+ const semver_1 = require("semver");
6
+ function isValidRange(range) {
7
+ // valid() will return null if a range (including ~,^,*) is used
8
+ // Check that it is null, and therefore a range
9
+ return !(0, semver_1.valid)(range) && (0, semver_1.validRange)(range) !== null;
10
+ }
11
+ function isMatchingDependencyRange(version, range) {
12
+ const coercedVersion = (0, semver_1.coerce)(version, { includePrerelease: true })?.version;
13
+ return isValidRange(range) && (0, semver_1.satisfies)(coercedVersion, range);
14
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"version-actions.d.ts","sourceRoot":"","sources":["../../../../../packages/js/src/release/version-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EAEZ,IAAI,EAGL,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,yBAAyB,EAAE,cAA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AACvE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAM3E,eAAO,MAAM,yBAAyB,EAAE,yBAmBvC,CAAC;AAKF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,cAAc;IAC1D,sBAAsB,WAAoB;IAEpC,oCAAoC,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC;QAC9D,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IAkBI,8BAA8B,CAClC,IAAI,EAAE,IAAI,EACV,8BAA8B,EAAE,6BAA6B,CAAC,gCAAgC,CAAC,GAC9F,OAAO,CAAC;QACT,cAAc,EAAE,MAAM,CAAC;QACvB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IAkEI,8BAA8B,CAClC,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,qBAAqB,EAAE,MAAM,GAC5B,OAAO,CAAC;QACT,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;QAC9B,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;KACrC,CAAC;IA+BI,oBAAoB,CACxB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC;IAcd,yBAAyB,CAC7B,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3C,OAAO,CAAC,MAAM,EAAE,CAAC;IAuFpB,OAAO,CAAC,yBAAyB;CAyClC"}
@@ -8,6 +8,7 @@ const release_1 = require("nx/release");
8
8
  const npm_config_1 = require("../utils/npm-config");
9
9
  const update_lock_file_1 = require("./utils/update-lock-file");
10
10
  const chalk = require("chalk");
11
+ const semver_1 = require("./utils/semver");
11
12
  const afterAllProjectsVersioned = async (cwd, { rootVersionActionsOptions, ...opts }) => {
12
13
  return {
13
14
  changedFiles: await (0, update_lock_file_1.updateLockFile)(cwd, {
@@ -136,6 +137,13 @@ class JsVersionActions extends release_1.VersionActions {
136
137
  'peerDependencies',
137
138
  'optionalDependencies',
138
139
  ];
140
+ // TODO(v22): Flip this to all by default
141
+ const preserveMatchingDependencyRanges = this.finalConfigForProject.preserveMatchingDependencyRanges === true
142
+ ? dependencyTypes
143
+ : this.finalConfigForProject.preserveMatchingDependencyRanges ===
144
+ false
145
+ ? []
146
+ : this.finalConfigForProject.preserveMatchingDependencyRanges || [];
139
147
  for (const depType of dependencyTypes) {
140
148
  if (json[depType]) {
141
149
  for (const [dep, version] of Object.entries(dependenciesToUpdate)) {
@@ -153,6 +161,18 @@ class JsVersionActions extends release_1.VersionActions {
153
161
  numDependenciesToUpdate--;
154
162
  continue;
155
163
  }
164
+ else if (preserveMatchingDependencyRanges.includes(depType) &&
165
+ !this.isLocalDependencyProtocol(currentVersion)) {
166
+ // If the dependency is specified using a range, do some additional processing to determine whether to update the version
167
+ if ((0, semver_1.isValidRange)(currentVersion) &&
168
+ !(0, semver_1.isMatchingDependencyRange)(version, currentVersion)) {
169
+ throw new Error(`"preserveMatchingDependencyRanges" is enabled for "${depType}" and the new version "${version}" is outside the current range for "${packageName}" in manifest "${manifestToUpdate.manifestPath}". Please update the range before releasing.`);
170
+ }
171
+ else if ((0, semver_1.isValidRange)(currentVersion)) {
172
+ // it is a range, but it is valid
173
+ continue;
174
+ }
175
+ }
156
176
  json[depType][packageName] = version;
157
177
  }
158
178
  }