diff --git a/packages/angular/src/builders/webpack-dev-server/webpack-dev-server.impl.ts b/packages/angular/src/builders/webpack-dev-server/webpack-dev-server.impl.ts index 60554c9131dafe..525d24dbb67236 100644 --- a/packages/angular/src/builders/webpack-dev-server/webpack-dev-server.impl.ts +++ b/packages/angular/src/builders/webpack-dev-server/webpack-dev-server.impl.ts @@ -17,7 +17,7 @@ import type { Schema } from './schema'; import { createTmpTsConfigForBuildableLibs } from '../utilities/buildable-libs'; import { from } from 'rxjs'; import { switchMap } from 'rxjs/operators'; -import { getRootTsConfigPath } from 'nx/src/utils/typescript'; +import { getRootTsConfigPath } from 'nx/src/plugins/js'; type BuildTargetOptions = { tsConfig: string; diff --git a/packages/angular/src/generators/component-cypress-spec/lib/get-component-selector.ts b/packages/angular/src/generators/component-cypress-spec/lib/get-component-selector.ts index ab3aacdbae95f2..8c570beb5f56b1 100644 --- a/packages/angular/src/generators/component-cypress-spec/lib/get-component-selector.ts +++ b/packages/angular/src/generators/component-cypress-spec/lib/get-component-selector.ts @@ -1,6 +1,6 @@ import type { Tree } from '@nrwl/devkit'; import { ensureTypescript } from '@nrwl/js/src/utils/typescript/ensure-typescript'; -import { findNodes } from 'nx/src/utils/typescript'; +import { findNodes } from 'nx/src/plugins/js'; import type { PropertyAssignment } from 'typescript'; import { diff --git a/packages/angular/src/generators/utils/storybook-ast/module-info.ts b/packages/angular/src/generators/utils/storybook-ast/module-info.ts index d1d0a9f14f40d8..7338ed9105361f 100644 --- a/packages/angular/src/generators/utils/storybook-ast/module-info.ts +++ b/packages/angular/src/generators/utils/storybook-ast/module-info.ts @@ -5,7 +5,7 @@ import { stripIndents, visitNotIgnoredFiles, } from '@nrwl/devkit'; -import { findNodes } from 'nx/src/utils/typescript'; +import { findNodes } from 'nx/src/plugins/js'; import { extname } from 'path'; import type { ClassDeclaration, diff --git a/packages/angular/src/generators/utils/storybook-ast/storybook-inputs.ts b/packages/angular/src/generators/utils/storybook-ast/storybook-inputs.ts index 24fabadbc3833b..12cc7132e2f027 100644 --- a/packages/angular/src/generators/utils/storybook-ast/storybook-inputs.ts +++ b/packages/angular/src/generators/utils/storybook-ast/storybook-inputs.ts @@ -1,5 +1,5 @@ import type { Tree } from '@nrwl/devkit'; -import { findNodes } from 'nx/src/utils/typescript'; +import { findNodes } from 'nx/src/plugins/js'; import { getSourceNodes } from '@nrwl/js'; import type { PropertyDeclaration } from 'typescript'; import { getTsSourceFile } from '../../../utils/nx-devkit/ast-utils'; diff --git a/packages/angular/src/utils/nx-devkit/ast-utils.ts b/packages/angular/src/utils/nx-devkit/ast-utils.ts index ae4c6e255b708b..afe09551f46a0d 100644 --- a/packages/angular/src/utils/nx-devkit/ast-utils.ts +++ b/packages/angular/src/utils/nx-devkit/ast-utils.ts @@ -1,5 +1,5 @@ import type * as ts from 'typescript'; -import { findNodes } from 'nx/src/utils/typescript'; +import { findNodes } from 'nx/src/plugins/js'; import { getImport, getSourceNodes, diff --git a/packages/devkit/src/utils/module-federation/share.ts b/packages/devkit/src/utils/module-federation/share.ts index 5aceb98d9bde27..12e62d5bdd5cf0 100644 --- a/packages/devkit/src/utils/module-federation/share.ts +++ b/packages/devkit/src/utils/module-federation/share.ts @@ -12,7 +12,7 @@ import { collectWorkspaceLibrarySecondaryEntryPoints, } from './secondary-entry-points'; // eslint-disable-next-line @typescript-eslint/no-restricted-imports -import { getRootTsConfigPath } from 'nx/src/utils/typescript'; +import { getRootTsConfigPath } from 'nx/src/plugins/js'; import type { ProjectGraph } from 'nx/src/config/project-graph'; import { requireNx } from '../../../nx'; diff --git a/packages/devkit/src/utils/module-federation/typescript.ts b/packages/devkit/src/utils/module-federation/typescript.ts index 4b5c8ad816709f..cf0c068c19d2d5 100644 --- a/packages/devkit/src/utils/module-federation/typescript.ts +++ b/packages/devkit/src/utils/module-federation/typescript.ts @@ -1,7 +1,7 @@ import { existsSync } from 'fs'; import { ParsedCommandLine } from 'typescript'; // eslint-disable-next-line @typescript-eslint/no-restricted-imports -import { getRootTsConfigPath } from 'nx/src/utils/typescript'; +import { getRootTsConfigPath } from 'nx/src/plugins/js'; import { dirname } from 'path'; let tsConfig: ParsedCommandLine; diff --git a/packages/eslint-plugin-nx/src/utils/ast-utils.ts b/packages/eslint-plugin-nx/src/utils/ast-utils.ts index df3ec305e2f3d5..e4296ffe192cbf 100644 --- a/packages/eslint-plugin-nx/src/utils/ast-utils.ts +++ b/packages/eslint-plugin-nx/src/utils/ast-utils.ts @@ -3,7 +3,7 @@ import { ProjectGraphProjectNode, readJsonFile, } from '@nrwl/devkit'; -import { findNodes } from 'nx/src/utils/typescript'; +import { findNodes } from 'nx/src/plugins/js'; import { existsSync, readFileSync } from 'fs'; import { dirname } from 'path'; import ts = require('typescript'); diff --git a/packages/eslint-plugin-nx/src/utils/runtime-lint-utils.ts b/packages/eslint-plugin-nx/src/utils/runtime-lint-utils.ts index 30d9898fd611f2..63a599b1ad5e53 100644 --- a/packages/eslint-plugin-nx/src/utils/runtime-lint-utils.ts +++ b/packages/eslint-plugin-nx/src/utils/runtime-lint-utils.ts @@ -21,7 +21,7 @@ import { import { getRootTsConfigFileName, resolveModuleByImport, -} from 'nx/src/utils/typescript'; +} from 'nx/src/plugins/js'; export type Deps = { [projectName: string]: ProjectGraphDependency[] }; type SingleSourceTagConstraint = { diff --git a/packages/expo/src/generators/component/lib/add-import.ts b/packages/expo/src/generators/component/lib/add-import.ts index 5e51c4bb21f736..d0d46cdf5e3e86 100644 --- a/packages/expo/src/generators/component/lib/add-import.ts +++ b/packages/expo/src/generators/component/lib/add-import.ts @@ -1,4 +1,4 @@ -import { findNodes } from 'nx/src/utils/typescript'; +import { findNodes } from 'nx/src/plugins/js'; import * as ts from 'typescript'; import { ChangeType, StringChange } from '@nrwl/devkit'; diff --git a/packages/js/src/utils/typescript/ast-utils.ts b/packages/js/src/utils/typescript/ast-utils.ts index db49d274eed083..4d57d7bc20fe0b 100644 --- a/packages/js/src/utils/typescript/ast-utils.ts +++ b/packages/js/src/utils/typescript/ast-utils.ts @@ -2,7 +2,7 @@ import type { Tree } from '@nrwl/devkit'; import type * as ts from 'typescript'; // TODO(colum): replace when https://github.com/nrwl/nx/pull/15497 is merged import { getSourceNodes } from '@nrwl/workspace/src/utilities/typescript'; -import { findNodes } from 'nx/src/utils/typescript'; +import { findNodes } from 'nx/src/plugins/js'; import { ensureTypescript } from './ensure-typescript'; let tsModule: typeof import('typescript'); diff --git a/packages/nx/src/command-line/format.ts b/packages/nx/src/command-line/format.ts index 5d637f0d56efaf..bcb801314ab3f0 100644 --- a/packages/nx/src/command-line/format.ts +++ b/packages/nx/src/command-line/format.ts @@ -15,7 +15,7 @@ import { sortObjectByKeys } from '../utils/object-sort'; import { getRootTsConfigFileName, getRootTsConfigPath, -} from '../utils/typescript'; +} from '../plugins/js/utils/typescript'; import { createProjectGraphAsync } from '../project-graph/project-graph'; import { filterAffected } from '../project-graph/affected/affected-project-graph'; import { readNxJson } from '../config/configuration'; diff --git a/packages/nx/src/hasher/hasher.spec.ts b/packages/nx/src/hasher/hasher.spec.ts index a23fa9b60f7692..2330b38be169d8 100644 --- a/packages/nx/src/hasher/hasher.spec.ts +++ b/packages/nx/src/hasher/hasher.spec.ts @@ -8,10 +8,10 @@ jest.doMock('../utils/workspace-root', () => { }); jest.mock('fs', () => require('memfs').fs); -jest.mock('../utils/typescript'); +jest.mock('../plugins/js/utils/typescript'); import { vol } from 'memfs'; -import tsUtils = require('../utils/typescript'); +import tsUtils = require('../plugins/js/utils/typescript'); import { expandNamedInput, filterUsingGlobPatterns, diff --git a/packages/nx/src/hasher/hasher.ts b/packages/nx/src/hasher/hasher.ts index 1b33607f7e5f1d..f0b41672245d70 100644 --- a/packages/nx/src/hasher/hasher.ts +++ b/packages/nx/src/hasher/hasher.ts @@ -1,6 +1,6 @@ import { exec } from 'child_process'; import * as minimatch from 'minimatch'; -import { getRootTsConfigFileName } from '../utils/typescript'; +import { getRootTsConfigFileName } from '../plugins/js/utils/typescript'; import { defaultHashing, HashingImpl } from './hashing-impl'; import { FileData, diff --git a/packages/nx/src/plugins/js/index.ts b/packages/nx/src/plugins/js/index.ts index deb4a55aeab023..33c1fcf4bdef29 100644 --- a/packages/nx/src/plugins/js/index.ts +++ b/packages/nx/src/plugins/js/index.ts @@ -18,6 +18,13 @@ import { workspaceRoot } from '../../utils/workspace-root'; import { ensureDirSync } from 'fs-extra'; import { removeNpmNodes } from 'nx/src/plugins/js/lock-file/remove-npm-nodes'; +export { + findNodes, + getRootTsConfigPath, + getRootTsConfigFileName, + resolveModuleByImport, +} from './utils/typescript'; + export const processProjectGraph: ProjectGraphProcessor = async ( graph, context diff --git a/packages/nx/src/plugins/js/project-graph/affected/lock-file-changes.spec.ts b/packages/nx/src/plugins/js/project-graph/affected/lock-file-changes.spec.ts new file mode 100644 index 00000000000000..4722fae6a9e7be --- /dev/null +++ b/packages/nx/src/plugins/js/project-graph/affected/lock-file-changes.spec.ts @@ -0,0 +1,75 @@ +import { ProjectGraph } from '../../../../config/project-graph'; +import { WholeFileChange } from '../../../../project-graph/file-utils'; +import { getTouchedProjectsFromLockFile } from './lock-file-changes'; + +describe('getTouchedProjectsFromLockFile', () => { + let graph: ProjectGraph; + let allNodes = []; + + beforeEach(() => { + graph = { + nodes: { + proj1: { + name: 'proj1', + type: 'app', + data: { + root: 'libs/proj1', + files: [], + }, + }, + proj2: { + name: 'proj2', + type: 'lib', + data: { + root: 'packages/proj2', + files: [], + }, + }, + app1: { + name: 'app1', + type: 'app', + data: { + root: 'apps/app1', + files: [], + }, + }, + }, + dependencies: {}, + }; + allNodes = Object.keys(graph.nodes); + }); + + ['package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'pnpm-lock.yml'].forEach( + (lockFile) => { + describe(`"${lockFile}"`, () => { + it(`should not return changes when "${lockFile}" is not touched`, () => { + const result = getTouchedProjectsFromLockFile( + [ + { + file: 'source.ts', + hash: 'some-hash', + getChanges: () => [new WholeFileChange()], + }, + ], + graph.nodes + ); + expect(result).toEqual([]); + }); + + it(`should return all nodes when "${lockFile}" is touched`, () => { + const result = getTouchedProjectsFromLockFile( + [ + { + file: lockFile, + hash: 'some-hash', + getChanges: () => [new WholeFileChange()], + }, + ], + graph.nodes + ); + expect(result).toEqual(allNodes); + }); + }); + } + ); +}); diff --git a/packages/nx/src/plugins/js/project-graph/affected/lock-file-changes.ts b/packages/nx/src/plugins/js/project-graph/affected/lock-file-changes.ts new file mode 100644 index 00000000000000..7e6827b3a4b477 --- /dev/null +++ b/packages/nx/src/plugins/js/project-graph/affected/lock-file-changes.ts @@ -0,0 +1,19 @@ +import { TouchedProjectLocator } from '../../../../project-graph/affected/affected-project-graph-models'; +import { WholeFileChange } from '../../../../project-graph/file-utils'; +import { JsonChange } from '../../../../utils/json-diff'; + +export const getTouchedProjectsFromLockFile: TouchedProjectLocator< + WholeFileChange | JsonChange +> = (fileChanges, projectGraphNodes): string[] => { + const lockFiles = [ + 'package-lock.json', + 'yarn.lock', + 'pnpm-lock.yaml', + 'pnpm-lock.yml', + ]; + + if (fileChanges.some((f) => lockFiles.includes(f.file))) { + return Object.values(projectGraphNodes).map((p) => p.name); + } + return []; +}; diff --git a/packages/nx/src/project-graph/affected/locators/npm-packages.spec.ts b/packages/nx/src/plugins/js/project-graph/affected/npm-packages.spec.ts similarity index 96% rename from packages/nx/src/project-graph/affected/locators/npm-packages.spec.ts rename to packages/nx/src/plugins/js/project-graph/affected/npm-packages.spec.ts index d4554e1c5fec3b..957d5a9addcf36 100644 --- a/packages/nx/src/project-graph/affected/locators/npm-packages.spec.ts +++ b/packages/nx/src/plugins/js/project-graph/affected/npm-packages.spec.ts @@ -1,8 +1,8 @@ -import { NxJsonConfiguration } from '../../../config/nx-json'; -import { ProjectGraph } from '../../../config/project-graph'; -import { JsonDiffType } from '../../../utils/json-diff'; -import { logger } from '../../../utils/logger'; -import { WholeFileChange } from '../../file-utils'; +import { NxJsonConfiguration } from '../../../../config/nx-json'; +import { ProjectGraph } from '../../../../config/project-graph'; +import { JsonDiffType } from '../../../../utils/json-diff'; +import { logger } from '../../../../utils/logger'; +import { WholeFileChange } from '../../../../project-graph/file-utils'; import { getTouchedNpmPackages } from './npm-packages'; describe('getTouchedNpmPackages', () => { diff --git a/packages/nx/src/project-graph/affected/locators/npm-packages.ts b/packages/nx/src/plugins/js/project-graph/affected/npm-packages.ts similarity index 87% rename from packages/nx/src/project-graph/affected/locators/npm-packages.ts rename to packages/nx/src/plugins/js/project-graph/affected/npm-packages.ts index 1199ced1dc9c0e..33b02fb1b4f271 100644 --- a/packages/nx/src/project-graph/affected/locators/npm-packages.ts +++ b/packages/nx/src/plugins/js/project-graph/affected/npm-packages.ts @@ -1,15 +1,18 @@ -import { isWholeFileChange, WholeFileChange } from '../../file-utils'; +import { + isWholeFileChange, + WholeFileChange, +} from '../../../../project-graph/file-utils'; import { JsonDiffType, isJsonChange, JsonChange, -} from '../../../utils/json-diff'; -import { logger } from '../../../utils/logger'; -import { TouchedProjectLocator } from '../affected-project-graph-models'; +} from '../../../../utils/json-diff'; +import { logger } from '../../../../utils/logger'; +import { TouchedProjectLocator } from '../../../../project-graph/affected/affected-project-graph-models'; import { ProjectGraphExternalNode, ProjectGraphProjectNode, -} from '../../../config/project-graph'; +} from '../../../../config/project-graph'; export const getTouchedNpmPackages: TouchedProjectLocator< WholeFileChange | JsonChange diff --git a/packages/nx/src/plugins/js/project-graph/affected/touched-projects.ts b/packages/nx/src/plugins/js/project-graph/affected/touched-projects.ts new file mode 100644 index 00000000000000..edcd2a4861b096 --- /dev/null +++ b/packages/nx/src/plugins/js/project-graph/affected/touched-projects.ts @@ -0,0 +1,26 @@ +import { TouchedProjectLocator } from '../../../../project-graph/affected/affected-project-graph-models'; +import { getTouchedProjectsFromLockFile } from './lock-file-changes'; +import { getTouchedNpmPackages } from './npm-packages'; +import { getTouchedProjectsFromTsConfig } from './tsconfig-json-changes'; + +export const getTouchedProjects: TouchedProjectLocator = ( + touchedFiles, + nodes, + nxJson, + packageJson, + graph +): string[] => { + const touchedProjects = new Set(); + + [ + getTouchedProjectsFromLockFile, + getTouchedNpmPackages, + getTouchedProjectsFromTsConfig, + ].forEach((fn) => { + (fn(touchedFiles, nodes, nxJson, packageJson, graph) as string[]).forEach( + (p) => touchedProjects.add(p) + ); + }); + + return Array.from(touchedProjects); +}; diff --git a/packages/nx/src/project-graph/affected/locators/tsconfig-json-changes.spec.ts b/packages/nx/src/plugins/js/project-graph/affected/tsconfig-json-changes.spec.ts similarity index 97% rename from packages/nx/src/project-graph/affected/locators/tsconfig-json-changes.spec.ts rename to packages/nx/src/plugins/js/project-graph/affected/tsconfig-json-changes.spec.ts index a7d60a2223f0fd..968159824a05f5 100644 --- a/packages/nx/src/project-graph/affected/locators/tsconfig-json-changes.spec.ts +++ b/packages/nx/src/plugins/js/project-graph/affected/tsconfig-json-changes.spec.ts @@ -1,8 +1,8 @@ -import { WholeFileChange } from '../../file-utils'; -import { jsonDiff } from '../../../utils/json-diff'; +import { WholeFileChange } from '../../../../project-graph/file-utils'; +import { jsonDiff } from '../../../../utils/json-diff'; import { getTouchedProjectsFromTsConfig } from './tsconfig-json-changes'; -import * as tsUtils from '../../../utils/typescript'; -import { DependencyType, ProjectGraph } from '../../../config/project-graph'; +import * as tsUtils from '../../utils/typescript'; +import { DependencyType, ProjectGraph } from '../../../../config/project-graph'; describe('getTouchedProjectsFromTsConfig', () => { let graph: ProjectGraph; diff --git a/packages/nx/src/project-graph/affected/locators/tsconfig-json-changes.ts b/packages/nx/src/plugins/js/project-graph/affected/tsconfig-json-changes.ts similarity index 86% rename from packages/nx/src/project-graph/affected/locators/tsconfig-json-changes.ts rename to packages/nx/src/plugins/js/project-graph/affected/tsconfig-json-changes.ts index aa337801011022..f34d3ba9604ee0 100644 --- a/packages/nx/src/project-graph/affected/locators/tsconfig-json-changes.ts +++ b/packages/nx/src/plugins/js/project-graph/affected/tsconfig-json-changes.ts @@ -1,12 +1,12 @@ -import { WholeFileChange } from '../../file-utils'; +import { WholeFileChange } from '../../../../project-graph/file-utils'; import { JsonDiffType, isJsonChange, JsonChange, -} from '../../../utils/json-diff'; -import { getRootTsConfigFileName } from '../../../utils/typescript'; -import { TouchedProjectLocator } from '../affected-project-graph-models'; -import { ProjectGraphProjectNode } from '../../../config/project-graph'; +} from '../../../../utils/json-diff'; +import { getRootTsConfigFileName } from '../../utils/typescript'; +import { TouchedProjectLocator } from '../../../../project-graph/affected/affected-project-graph-models'; +import { ProjectGraphProjectNode } from '../../../../config/project-graph'; export const getTouchedProjectsFromTsConfig: TouchedProjectLocator< WholeFileChange | JsonChange diff --git a/packages/nx/src/plugins/js/project-graph/build-dependencies/target-project-locator.ts b/packages/nx/src/plugins/js/project-graph/build-dependencies/target-project-locator.ts index f66ca5223cbc74..c79519762df67f 100644 --- a/packages/nx/src/plugins/js/project-graph/build-dependencies/target-project-locator.ts +++ b/packages/nx/src/plugins/js/project-graph/build-dependencies/target-project-locator.ts @@ -1,7 +1,7 @@ import { getRootTsConfigFileName, resolveModuleByImport, -} from '../../../../utils/typescript'; +} from '../../utils/typescript'; import { isRelativePath, readJsonFile } from '../../../../utils/fileutils'; import { dirname, join, posix } from 'path'; import { workspaceRoot } from '../../../../utils/workspace-root'; diff --git a/packages/nx/src/utils/typescript.ts b/packages/nx/src/plugins/js/utils/typescript.ts similarity index 98% rename from packages/nx/src/utils/typescript.ts rename to packages/nx/src/plugins/js/utils/typescript.ts index 0670e7a072310f..b377f6d5225d15 100644 --- a/packages/nx/src/utils/typescript.ts +++ b/packages/nx/src/plugins/js/utils/typescript.ts @@ -1,4 +1,4 @@ -import { workspaceRoot } from './workspace-root'; +import { workspaceRoot } from '../../../utils/workspace-root'; import { existsSync } from 'fs'; import { dirname, join } from 'path'; import type * as ts from 'typescript'; diff --git a/packages/nx/src/project-graph/affected/affected-project-graph-models.ts b/packages/nx/src/project-graph/affected/affected-project-graph-models.ts index 3bad2d0ed5cd8d..5870c7c4e05184 100644 --- a/packages/nx/src/project-graph/affected/affected-project-graph-models.ts +++ b/packages/nx/src/project-graph/affected/affected-project-graph-models.ts @@ -4,7 +4,6 @@ import { ProjectGraph, ProjectGraphProjectNode, } from '../../config/project-graph'; -import { ProjectConfiguration } from '../../config/workspace-json-project-json'; export interface AffectedProjectGraphContext { projectGraphNodes: Record; diff --git a/packages/nx/src/project-graph/affected/affected-project-graph.ts b/packages/nx/src/project-graph/affected/affected-project-graph.ts index be49968dc4f0d0..7bbfd3c731a1d8 100644 --- a/packages/nx/src/project-graph/affected/affected-project-graph.ts +++ b/packages/nx/src/project-graph/affected/affected-project-graph.ts @@ -3,12 +3,11 @@ import { getImplicitlyTouchedProjects, getTouchedProjects, } from './locators/workspace-projects'; -import { getTouchedNpmPackages } from './locators/npm-packages'; +import { getTouchedProjects as getJSTouchedProjects } from '../../plugins/js/project-graph/affected/touched-projects'; import { AffectedProjectGraphContext, TouchedProjectLocator, } from './affected-project-graph-models'; -import { getTouchedProjectsFromTsConfig } from './locators/tsconfig-json-changes'; import { NxJsonConfiguration } from '../../config/nx-json'; import { ProjectGraph } from '../../config/project-graph'; import { reverse } from '../operators'; @@ -25,9 +24,8 @@ export async function filterAffected( const touchedProjectLocators: TouchedProjectLocator[] = [ getTouchedProjects, getImplicitlyTouchedProjects, - getTouchedNpmPackages, - getTouchedProjectsFromTsConfig, getTouchedProjectsFromProjectGlobChanges, + getJSTouchedProjects, ]; const touchedProjects = []; diff --git a/packages/nx/src/project-graph/affected/locators/workspace-projects.ts b/packages/nx/src/project-graph/affected/locators/workspace-projects.ts index 118f651e16de9b..04b34a75e5010a 100644 --- a/packages/nx/src/project-graph/affected/locators/workspace-projects.ts +++ b/packages/nx/src/project-graph/affected/locators/workspace-projects.ts @@ -27,14 +27,7 @@ export const getImplicitlyTouchedProjects: TouchedProjectLocator = ( nxJson ): string[] => { const implicits = {}; - const globalFiles = [ - ...extractGlobalFilesFromInputs(nxJson), - 'nx.json', - 'package-lock.json', - 'yarn.lock', - 'pnpm-lock.yaml', - 'pnpm-lock.yml', - ]; + const globalFiles = [...extractGlobalFilesFromInputs(nxJson), 'nx.json']; globalFiles.forEach((file) => { implicits[file] = '*' as any; }); diff --git a/packages/nx/src/project-graph/build-project-graph.ts b/packages/nx/src/project-graph/build-project-graph.ts index fa61c5e2ab442c..8e525fcb9c09e4 100644 --- a/packages/nx/src/project-graph/build-project-graph.ts +++ b/packages/nx/src/project-graph/build-project-graph.ts @@ -16,7 +16,7 @@ import { buildWorkspaceProjectNodes } from './build-nodes'; import { loadNxPlugins } from '../utils/nx-plugin'; import { defaultFileHasher } from '../hasher/file-hasher'; import { createProjectFileMap } from './file-map-utils'; -import { getRootTsConfigPath } from '../utils/typescript'; +import { getRootTsConfigPath } from '../plugins/js/utils/typescript'; import { ProjectFileMap, ProjectGraph, diff --git a/packages/nx/src/utils/nx-plugin.ts b/packages/nx/src/utils/nx-plugin.ts index 92fa396d596203..af4eae871586fe 100644 --- a/packages/nx/src/utils/nx-plugin.ts +++ b/packages/nx/src/utils/nx-plugin.ts @@ -24,7 +24,7 @@ import { import { normalizePath } from './path'; import { join } from 'path'; import { getNxRequirePaths } from './installation-directory'; -import { readTsConfig } from './typescript'; +import { readTsConfig } from '../plugins/js/utils/typescript'; import type * as ts from 'typescript'; diff --git a/packages/react-native/src/generators/component/lib/add-import.ts b/packages/react-native/src/generators/component/lib/add-import.ts index 46035d9023be93..2ad2d05b944729 100644 --- a/packages/react-native/src/generators/component/lib/add-import.ts +++ b/packages/react-native/src/generators/component/lib/add-import.ts @@ -1,4 +1,4 @@ -import { findNodes } from 'nx/src/utils/typescript'; +import { findNodes } from 'nx/src/plugins/js'; import type * as ts from 'typescript'; import { ChangeType, StringChange } from '@nrwl/devkit'; import { ensureTypescript } from '@nrwl/js/src/utils/typescript/ensure-typescript'; diff --git a/packages/react/src/migrations/update-13-0-0/webpack5-changes-utils.ts b/packages/react/src/migrations/update-13-0-0/webpack5-changes-utils.ts index d856735cefa592..8923f9f69b2777 100644 --- a/packages/react/src/migrations/update-13-0-0/webpack5-changes-utils.ts +++ b/packages/react/src/migrations/update-13-0-0/webpack5-changes-utils.ts @@ -7,7 +7,7 @@ import { } from '@nrwl/devkit'; import ts = require('typescript'); -import { findNodes } from 'nx/src/utils/typescript'; +import { findNodes } from 'nx/src/plugins/js'; export async function migrateToWebPack5(tree: Tree) { allReactProjectsWithStorybookConfiguration(tree).forEach((project) => { diff --git a/packages/react/src/migrations/update-14-0-0/update-react-dom-render-for-v18.ts b/packages/react/src/migrations/update-14-0-0/update-react-dom-render-for-v18.ts index ef5e3eb1c7d6a7..e682974ab188b5 100644 --- a/packages/react/src/migrations/update-14-0-0/update-react-dom-render-for-v18.ts +++ b/packages/react/src/migrations/update-14-0-0/update-react-dom-render-for-v18.ts @@ -7,7 +7,7 @@ import { Tree, formatFiles, } from '@nrwl/devkit'; -import { findNodes } from 'nx/src/utils/typescript'; +import { findNodes } from 'nx/src/plugins/js'; import * as ts from 'typescript'; export async function update(tree: Tree) { diff --git a/packages/react/src/module-federation/ast-utils.ts b/packages/react/src/module-federation/ast-utils.ts index c784722980b323..cf32dbf6e969da 100644 --- a/packages/react/src/module-federation/ast-utils.ts +++ b/packages/react/src/module-federation/ast-utils.ts @@ -1,6 +1,6 @@ import type * as ts from 'typescript'; import { ChangeType, StringChange } from '@nrwl/devkit'; -import { findNodes } from 'nx/src/utils/typescript'; +import { findNodes } from 'nx/src/plugins/js'; import { findClosestOpening, findElements, diff --git a/packages/react/src/utils/ast-utils.ts b/packages/react/src/utils/ast-utils.ts index 69ccd77a3455db..b4aa0a38a39f93 100644 --- a/packages/react/src/utils/ast-utils.ts +++ b/packages/react/src/utils/ast-utils.ts @@ -1,5 +1,5 @@ import type * as ts from 'typescript'; -import { findNodes } from 'nx/src/utils/typescript'; +import { findNodes } from 'nx/src/plugins/js'; import { ChangeType, logger, diff --git a/packages/storybook/src/executors/utils.ts b/packages/storybook/src/executors/utils.ts index a1d1657b7bb1e8..9d167b95b46d0a 100644 --- a/packages/storybook/src/executors/utils.ts +++ b/packages/storybook/src/executors/utils.ts @@ -1,5 +1,5 @@ import { joinPathFragments, logger } from '@nrwl/devkit'; -import { findNodes } from 'nx/src/utils/typescript'; +import { findNodes } from 'nx/src/plugins/js'; import 'dotenv/config'; import { existsSync, readFileSync } from 'fs'; import { join } from 'path'; @@ -50,9 +50,9 @@ function isStorybookV62onwards(uiFramework: string) { } catch (e) { throw new Error( `Error: ${e} - - It looks like you don\'t have Storybook installed. - Please run the @nrwl/storybook:configuration generator, + + It looks like you don\'t have Storybook installed. + Please run the @nrwl/storybook:configuration generator, or run "npm/yarn" again to install your dependencies.` ); } @@ -70,7 +70,7 @@ export function runStorybookSetupCheck( export function pleaseUpgrade() { logger.warn( ` - Please consider upgrading to Storybook version 7, + Please consider upgrading to Storybook version 7, as version 6 is no longer maintained. Here is a guide on how to upgrade: @@ -93,9 +93,9 @@ function reactWebpack5Check(options: CLIOptions & CommonNxStorybookConfig) { It looks like you use Webpack 5 but your Storybook setup is not configured to leverage that and thus falls back to Webpack 4. Make sure you upgrade your Storybook config to use Webpack 5. - + - https://gist.github.com/shilman/8856ea1786dcd247139b47b270912324#upgrade - + `); } } diff --git a/packages/storybook/src/migrations/update-14-0-0/migrate-stories-to-6-2/migrate-stories-to-6-2.spec.ts b/packages/storybook/src/migrations/update-14-0-0/migrate-stories-to-6-2/migrate-stories-to-6-2.spec.ts index 83369028e6a2b2..193eac62d0b225 100644 --- a/packages/storybook/src/migrations/update-14-0-0/migrate-stories-to-6-2/migrate-stories-to-6-2.spec.ts +++ b/packages/storybook/src/migrations/update-14-0-0/migrate-stories-to-6-2/migrate-stories-to-6-2.spec.ts @@ -6,7 +6,7 @@ import { import { joinPathFragments, writeJson } from '@nrwl/devkit'; import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; import { storybookVersion } from '@nrwl/storybook'; -import { findNodes } from 'nx/src/utils/typescript'; +import { findNodes } from 'nx/src/plugins/js'; import * as ts from 'typescript'; import { SyntaxKind } from 'typescript'; import { nxVersion } from '../../../utils/versions'; diff --git a/packages/storybook/src/migrations/update-14-0-0/migrate-stories-to-6-2/migrate-stories-to-6-2.ts b/packages/storybook/src/migrations/update-14-0-0/migrate-stories-to-6-2/migrate-stories-to-6-2.ts index f907177590385b..bdcdd894db5c3d 100644 --- a/packages/storybook/src/migrations/update-14-0-0/migrate-stories-to-6-2/migrate-stories-to-6-2.ts +++ b/packages/storybook/src/migrations/update-14-0-0/migrate-stories-to-6-2/migrate-stories-to-6-2.ts @@ -9,7 +9,7 @@ import { visitNotIgnoredFiles, } from '@nrwl/devkit'; import { fileExists } from '@nrwl/workspace/src/utilities/fileutils'; -import { findNodes } from 'nx/src/utils/typescript'; +import { findNodes } from 'nx/src/plugins/js'; import { join, normalize } from 'path'; import { SyntaxKind } from 'typescript'; import { getTsSourceFile } from '../../../utils/utilities'; diff --git a/packages/storybook/src/utils/utilities.ts b/packages/storybook/src/utils/utilities.ts index 0b82a709cfc424..f177ecc0973f8d 100644 --- a/packages/storybook/src/utils/utilities.ts +++ b/packages/storybook/src/utils/utilities.ts @@ -7,7 +7,7 @@ import { import { CompilerOptions } from 'typescript'; import { storybookVersion } from './versions'; import { statSync } from 'fs'; -import { findNodes } from 'nx/src/utils/typescript'; +import { findNodes } from 'nx/src/plugins/js'; import ts = require('typescript'); import { gte, major } from 'semver'; import { join } from 'path'; diff --git a/packages/vite/src/migrations/update-15-3-1/update-vite-tsconfig-paths.ts b/packages/vite/src/migrations/update-15-3-1/update-vite-tsconfig-paths.ts index f7424600a847f6..bafd477608b2fa 100644 --- a/packages/vite/src/migrations/update-15-3-1/update-vite-tsconfig-paths.ts +++ b/packages/vite/src/migrations/update-15-3-1/update-vite-tsconfig-paths.ts @@ -7,7 +7,7 @@ import { } from '@nrwl/devkit'; import { forEachExecutorOptions } from '@nrwl/devkit/src/generators/executor-options-utils'; import { tsquery } from '@phenomnomnominal/tsquery'; -import { findNodes } from 'nx/src/utils/typescript'; +import { findNodes } from 'nx/src/plugins/js'; import { normalizeViteConfigFilePathWithTree } from '../../utils/generator-utils'; import ts = require('typescript'); diff --git a/packages/vite/src/utils/vite-config-edit-utils.ts b/packages/vite/src/utils/vite-config-edit-utils.ts index d7a279658549b6..c55320006cd8c1 100644 --- a/packages/vite/src/utils/vite-config-edit-utils.ts +++ b/packages/vite/src/utils/vite-config-edit-utils.ts @@ -1,5 +1,5 @@ import { applyChangesToString, ChangeType, Tree } from '@nrwl/devkit'; -import { findNodes } from 'nx/src/utils/typescript'; +import { findNodes } from 'nx/src/plugins/js'; import { TargetFlags } from './generator-utils'; import type { Node, ReturnStatement } from 'typescript'; diff --git a/packages/workspace/src/generators/move/lib/update-imports.ts b/packages/workspace/src/generators/move/lib/update-imports.ts index 37ebecf7c30727..2f27598972ed12 100644 --- a/packages/workspace/src/generators/move/lib/update-imports.ts +++ b/packages/workspace/src/generators/move/lib/update-imports.ts @@ -14,7 +14,7 @@ import { } from '@nrwl/devkit'; import type * as ts from 'typescript'; import { getRootTsConfigPathInTree } from '../../../utilities/ts-config'; -import { findNodes } from 'nx/src/utils/typescript'; +import { findNodes } from 'nx/src/plugins/js'; import { NormalizedSchema } from '../schema'; import { normalizeSlashes } from './utils'; import { relative } from 'path'; diff --git a/packages/workspace/src/utilities/typescript/find-nodes.ts b/packages/workspace/src/utilities/typescript/find-nodes.ts index 32169f92dbcec4..f3aa2909e70851 100644 --- a/packages/workspace/src/utilities/typescript/find-nodes.ts +++ b/packages/workspace/src/utilities/typescript/find-nodes.ts @@ -1,4 +1,4 @@ -import { findNodes as _findNodes } from 'nx/src/utils/typescript'; +import { findNodes as _findNodes } from 'nx/src/plugins/js'; import type { Node, SyntaxKind } from 'typescript'; // TODO(v16): This should be removed.