@nx/plugin 17.2.0-beta.5 → 17.2.0-beta.8

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/plugin",
3
- "version": "17.2.0-beta.5",
3
+ "version": "17.2.0-beta.8",
4
4
  "private": false,
5
5
  "description": "This plugin is used to create Nx plugins! It contains generators for generating common plugin features like generators, executors, migrations and more.",
6
6
  "repository": {
@@ -31,11 +31,11 @@
31
31
  "@phenomnomnominal/tsquery": "~5.0.1",
32
32
  "fs-extra": "^11.1.0",
33
33
  "tslib": "^2.3.0",
34
- "@nx/devkit": "17.2.0-beta.5",
35
- "@nx/jest": "17.2.0-beta.5",
36
- "@nx/js": "17.2.0-beta.5",
37
- "@nx/eslint": "17.2.0-beta.5",
38
- "@nrwl/nx-plugin": "17.2.0-beta.5"
34
+ "@nx/devkit": "17.2.0-beta.8",
35
+ "@nx/jest": "17.2.0-beta.8",
36
+ "@nx/js": "17.2.0-beta.8",
37
+ "@nx/eslint": "17.2.0-beta.8",
38
+ "@nrwl/nx-plugin": "17.2.0-beta.8"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
@@ -102,7 +102,6 @@ async function addLintingToApplication(tree, options) {
102
102
  tsConfigPaths: [
103
103
  (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.app.json'),
104
104
  ],
105
- eslintFilePatterns: [`${options.projectRoot}/**/*.ts`],
106
105
  unitTestRunner: 'jest',
107
106
  skipFormat: true,
108
107
  setParserOptionsProject: false,
@@ -44,22 +44,25 @@ function addMigrationJsonChecks(host, options, packageJson) {
44
44
  return;
45
45
  }
46
46
  const migrationsJsonPath = (0, devkit_1.joinPathFragments)(projectConfiguration.root, relativeMigrationsJsonPath);
47
- if (eslintTarget &&
48
- !eslintTargetConfiguration.options?.lintFilePatterns?.includes(migrationsJsonPath)) {
49
- // Add to lintFilePatterns
47
+ if (!eslintTarget) {
48
+ return;
49
+ }
50
+ // Add path to lintFilePatterns if different than default "{projectRoot}"
51
+ if (eslintTargetConfiguration.options?.lintFilePatterns &&
52
+ !eslintTargetConfiguration.options.lintFilePatterns.includes(migrationsJsonPath)) {
50
53
  eslintTargetConfiguration.options.lintFilePatterns.push(migrationsJsonPath);
51
54
  (0, devkit_1.updateProjectConfiguration)(host, options.projectName, projectConfiguration);
52
- // Update project level eslintrc
53
- (0, eslint_file_1.updateOverrideInLintConfig)(host, projectConfiguration.root, (o) => Object.keys(o.rules ?? {})?.includes('@nx/nx-plugin-checks') ||
54
- Object.keys(o.rules ?? {})?.includes('@nrwl/nx/nx-plugin-checks'), (o) => {
55
- const fileSet = new Set(Array.isArray(o.files) ? o.files : [o.files]);
56
- fileSet.add(relativeMigrationsJsonPath);
57
- return {
58
- ...o,
59
- files: Array.from(fileSet),
60
- };
61
- });
62
55
  }
56
+ // Update project level eslintrc
57
+ (0, eslint_file_1.updateOverrideInLintConfig)(host, projectConfiguration.root, (o) => Object.keys(o.rules ?? {})?.includes('@nx/nx-plugin-checks') ||
58
+ Object.keys(o.rules ?? {})?.includes('@nrwl/nx/nx-plugin-checks'), (o) => {
59
+ const fileSet = new Set(Array.isArray(o.files) ? o.files : [o.files]);
60
+ fileSet.add(relativeMigrationsJsonPath);
61
+ return {
62
+ ...o,
63
+ files: Array.from(fileSet),
64
+ };
65
+ });
63
66
  }
64
67
  exports.addMigrationJsonChecks = addMigrationJsonChecks;
65
68
  function updateProjectTarget(host, options, packageJson) {
@@ -68,9 +71,9 @@ function updateProjectTarget(host, options, packageJson) {
68
71
  return;
69
72
  }
70
73
  for (const [target, configuration] of Object.entries(project.targets)) {
71
- if (configuration.executor === '@nx/eslint:lint' ||
72
- configuration.executor === '@nx/linter:eslint' ||
73
- configuration.executor === '@nrwl/linter:eslint') {
74
+ if (configuration.executor === '@nx/eslint:lint' &&
75
+ // only add patterns if there are already hardcoded ones
76
+ configuration.options?.lintFilePatterns) {
74
77
  const opts = configuration.options ?? {};
75
78
  opts.lintFilePatterns ??= [];
76
79
  if (packageJson.generators) {
@@ -35,8 +35,9 @@ exports.runCommandAsync = runCommandAsync;
35
35
  function runNxCommandAsync(command, opts = {
36
36
  silenceError: false,
37
37
  }) {
38
+ const cwd = opts.cwd ?? (0, paths_1.tmpProjPath)();
38
39
  if ((0, utils_1.fileExists)((0, paths_1.tmpProjPath)('package.json'))) {
39
- const pmc = (0, devkit_1.getPackageManagerCommand)();
40
+ const pmc = (0, devkit_1.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(cwd));
40
41
  return runCommandAsync(`${pmc.exec} nx ${command}`, opts);
41
42
  }
42
43
  else if (process.platform === 'win32') {
@@ -16,12 +16,13 @@ function runNxCommand(command, opts = {
16
16
  silenceError: false,
17
17
  }) {
18
18
  function _runNxCommand(c) {
19
+ const cwd = opts.cwd ?? (0, paths_1.tmpProjPath)();
19
20
  const execSyncOptions = {
20
- cwd: opts.cwd ?? (0, paths_1.tmpProjPath)(),
21
+ cwd,
21
22
  env: { ...process.env, ...opts.env },
22
23
  };
23
24
  if ((0, utils_1.fileExists)((0, paths_1.tmpProjPath)('package.json'))) {
24
- const pmc = (0, devkit_1.getPackageManagerCommand)();
25
+ const pmc = (0, devkit_1.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(cwd));
25
26
  return (0, child_process_1.execSync)(`${pmc.exec} nx ${command}`, execSyncOptions);
26
27
  }
27
28
  else if (process.platform === 'win32') {
@@ -37,9 +37,10 @@ exports.uniq = uniq;
37
37
  * @param silent silent output from the install
38
38
  */
39
39
  function runPackageManagerInstall(silent = true) {
40
- const pmc = (0, devkit_2.getPackageManagerCommand)();
40
+ const cwd = (0, paths_1.tmpProjPath)();
41
+ const pmc = (0, devkit_2.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(cwd));
41
42
  const install = (0, child_process_1.execSync)(pmc.install, {
42
- cwd: (0, paths_1.tmpProjPath)(),
43
+ cwd,
43
44
  ...(silent ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}),
44
45
  });
45
46
  return install ? install.toString() : '';