cleanup(core): create more meaningful file structure in nx package (#9621)
This commit is contained in:
parent
5b34fa4c74
commit
428106f6be
@ -192,7 +192,7 @@ Please follow the following guidelines:
|
|||||||
|
|
||||||
- Make sure unit tests pass (`nx affected --target=test`)
|
- Make sure unit tests pass (`nx affected --target=test`)
|
||||||
- Target a specific project with: `nx run proj:test` (i.e. `nx run angular:test` to target `packages/angular`)
|
- Target a specific project with: `nx run proj:test` (i.e. `nx run angular:test` to target `packages/angular`)
|
||||||
- Target a specific unit test file (i.e. `packages/angular/src/utils/ast-utils.spec.ts`) with `npx jest angular/src/utils/ast-utils` or `npx jest packages/angular/src/utils/ast-utils`
|
- Target a specific unit test file (i.e. `packages/angular/src/utils/ast-command-line-utils.spec.ts`) with `npx jest angular/src/utils/ast-utils` or `npx jest packages/angular/src/utils/ast-utils`
|
||||||
- For more options on running tests - check `npx jest --help` or visit [jestjs.io](https://jestjs.io/)
|
- For more options on running tests - check `npx jest --help` or visit [jestjs.io](https://jestjs.io/)
|
||||||
- Debug with `node --inspect-brk ./node_modules/jest/bin/jest.js build/packages/angular/src/utils/ast-utils.spec.js`
|
- Debug with `node --inspect-brk ./node_modules/jest/bin/jest.js build/packages/angular/src/utils/ast-utils.spec.js`
|
||||||
- Make sure e2e tests pass (this can take a while, so you can always let CI check those) (`yarn e2e`)
|
- Make sure e2e tests pass (this can take a while, so you can always let CI check those) (`yarn e2e`)
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import {
|
|||||||
getPackageManagerCommand,
|
getPackageManagerCommand,
|
||||||
getSelectedPackageManager,
|
getSelectedPackageManager,
|
||||||
} from '@nrwl/e2e/utils';
|
} from '@nrwl/e2e/utils';
|
||||||
import { Workspaces } from 'nx/src/shared/workspace';
|
import { Workspaces } from 'nx/src/config/workspaces';
|
||||||
|
|
||||||
describe('add-nx-to-monorepo', () => {
|
describe('add-nx-to-monorepo', () => {
|
||||||
const packageManagerCommand = getPackageManagerCommand({
|
const packageManagerCommand = getPackageManagerCommand({
|
||||||
|
|||||||
@ -28,7 +28,7 @@ import { promisify } from 'util';
|
|||||||
import chalk = require('chalk');
|
import chalk = require('chalk');
|
||||||
import isCI = require('is-ci');
|
import isCI = require('is-ci');
|
||||||
import treeKill = require('tree-kill');
|
import treeKill = require('tree-kill');
|
||||||
import { Workspaces } from '../../packages/nx/src/shared/workspace';
|
import { Workspaces } from '../../packages/nx/src/config/workspaces';
|
||||||
import { PackageManager } from 'nx/src/utils/package-manager';
|
import { PackageManager } from 'nx/src/utils/package-manager';
|
||||||
|
|
||||||
export function detectPackageManager(dir: string = ''): PackageManager {
|
export function detectPackageManager(dir: string = ''): PackageManager {
|
||||||
|
|||||||
@ -42,7 +42,7 @@ describe('workspace-generator', () => {
|
|||||||
const workspace = uniq('workspace');
|
const workspace = uniq('workspace');
|
||||||
|
|
||||||
updateFile(
|
updateFile(
|
||||||
'tools/utils/utils.ts',
|
'tools/utils/command-line-utils.ts',
|
||||||
`
|
`
|
||||||
export const noop = () => {}
|
export const noop = () => {}
|
||||||
`
|
`
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import {
|
|||||||
} from '@nrwl/devkit';
|
} from '@nrwl/devkit';
|
||||||
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
|
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
|
||||||
import { Linter } from '@nrwl/linter';
|
import { Linter } from '@nrwl/linter';
|
||||||
import { toNewFormat } from 'nx/src/shared/workspace';
|
import { toNewFormat } from 'nx/src/config/workspaces';
|
||||||
import { createApp } from '../../utils/nx-devkit/testing';
|
import { createApp } from '../../utils/nx-devkit/testing';
|
||||||
import { UnitTestRunner } from '../../utils/test-runners';
|
import { UnitTestRunner } from '../../utils/test-runners';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
jest.mock('fs');
|
jest.mock('fs');
|
||||||
jest.mock('@nrwl/devkit');
|
jest.mock('@nrwl/devkit');
|
||||||
jest.mock('@nrwl/workspace/src/utilities/typescript');
|
jest.mock('@nrwl/workspace/src/utilities/typescript');
|
||||||
jest.mock('nx/src/core/file-utils');
|
jest.mock('nx/src/project-graph/file-utils');
|
||||||
jest.mock('nx/src/shared/workspace');
|
|
||||||
import * as graph from '@nrwl/devkit';
|
import * as graph from '@nrwl/devkit';
|
||||||
import * as typescriptUtils from '@nrwl/workspace/src/utilities/typescript';
|
import * as typescriptUtils from '@nrwl/workspace/src/utilities/typescript';
|
||||||
import * as workspace from 'nx/src/core/file-utils';
|
import * as workspace from 'nx/src/project-graph/file-utils';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
|
||||||
import { withModuleFederation } from './with-module-federation';
|
import { withModuleFederation } from './with-module-federation';
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import {
|
|||||||
readTsConfig,
|
readTsConfig,
|
||||||
} from '@nrwl/workspace/src/utilities/typescript';
|
} from '@nrwl/workspace/src/utilities/typescript';
|
||||||
import { ParsedCommandLine } from 'typescript';
|
import { ParsedCommandLine } from 'typescript';
|
||||||
import { readWorkspaceJson } from 'nx/src/core/file-utils';
|
import { readWorkspaceJson } from 'nx/src/project-graph/file-utils';
|
||||||
import ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');
|
import ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');
|
||||||
|
|
||||||
export type MFERemotes = string[] | [remoteName: string, remoteUrl: string][];
|
export type MFERemotes = string[] | [remoteName: string, remoteUrl: string][];
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
/**
|
/**
|
||||||
* @category Tree
|
* @category Tree
|
||||||
*/
|
*/
|
||||||
export type { Tree, FileChange } from 'nx/src/shared/tree';
|
export type { Tree, FileChange } from 'nx/src/config/tree';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @category Workspace
|
* @category Workspace
|
||||||
@ -23,18 +23,24 @@ export type {
|
|||||||
TargetConfiguration,
|
TargetConfiguration,
|
||||||
ProjectConfiguration,
|
ProjectConfiguration,
|
||||||
ProjectType,
|
ProjectType,
|
||||||
|
Workspace,
|
||||||
|
} from 'nx/src/config/workspace-json-project-json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @category Workspace
|
||||||
|
*/
|
||||||
|
export type {
|
||||||
Generator,
|
Generator,
|
||||||
GeneratorCallback,
|
GeneratorCallback,
|
||||||
Executor,
|
Executor,
|
||||||
ExecutorContext,
|
ExecutorContext,
|
||||||
TaskGraphExecutor,
|
TaskGraphExecutor,
|
||||||
Workspace,
|
} from 'nx/src/config/misc-interfaces';
|
||||||
} from 'nx/src/shared/workspace';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @category Workspace
|
* @category Workspace
|
||||||
*/
|
*/
|
||||||
export { Workspaces } from 'nx/src/shared/workspace';
|
export { Workspaces } from 'nx/src/config/workspaces';
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
NxPlugin,
|
NxPlugin,
|
||||||
@ -44,7 +50,7 @@ export type {
|
|||||||
/**
|
/**
|
||||||
* @category Workspace
|
* @category Workspace
|
||||||
*/
|
*/
|
||||||
export type { Task, TaskGraph } from 'nx/src/shared/tasks';
|
export type { Task, TaskGraph } from 'nx/src/config/task-graph';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @category Workspace
|
* @category Workspace
|
||||||
@ -55,7 +61,7 @@ export type {
|
|||||||
NxJsonConfiguration,
|
NxJsonConfiguration,
|
||||||
NxJsonProjectConfiguration,
|
NxJsonProjectConfiguration,
|
||||||
NxAffectedConfig,
|
NxAffectedConfig,
|
||||||
} from 'nx/src/shared/nx';
|
} from 'nx/src/config/nx-json';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @category Logger
|
* @category Logger
|
||||||
@ -160,17 +166,17 @@ export type {
|
|||||||
ProjectGraphProjectNode,
|
ProjectGraphProjectNode,
|
||||||
ProjectGraphExternalNode,
|
ProjectGraphExternalNode,
|
||||||
ProjectGraphProcessorContext,
|
ProjectGraphProcessorContext,
|
||||||
} from 'nx/src/shared/project-graph';
|
} from 'nx/src/config/project-graph';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @category Project Graph
|
* @category Project Graph
|
||||||
*/
|
*/
|
||||||
export { DependencyType } from 'nx/src/shared/project-graph';
|
export { DependencyType } from 'nx/src/config/project-graph';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @category Project Graph
|
* @category Project Graph
|
||||||
*/
|
*/
|
||||||
export { ProjectGraphBuilder } from 'nx/src/core/project-graph/project-graph-builder';
|
export { ProjectGraphBuilder } from 'nx/src/project-graph/project-graph-builder';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @category Utils
|
* @category Utils
|
||||||
@ -270,19 +276,19 @@ export { workspaceRoot, appRootPath } from 'nx/src/utils/app-root';
|
|||||||
/**
|
/**
|
||||||
* @category Utils
|
* @category Utils
|
||||||
*/
|
*/
|
||||||
export { reverse } from 'nx/src/core/project-graph/operators';
|
export { reverse } from 'nx/src/project-graph/operators';
|
||||||
/**
|
/**
|
||||||
* @category Utils
|
* @category Utils
|
||||||
*/
|
*/
|
||||||
export {
|
export {
|
||||||
createProjectGraphAsync,
|
createProjectGraphAsync,
|
||||||
readCachedProjectGraph,
|
readCachedProjectGraph,
|
||||||
} from 'nx/src/core/project-graph/project-graph';
|
} from 'nx/src/project-graph/project-graph';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @category Utils
|
* @category Utils
|
||||||
*/
|
*/
|
||||||
export { readNxJson, workspaceLayout } from 'nx/src/core/file-utils';
|
export { readNxJson, workspaceLayout } from 'nx/src/project-graph/file-utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @category Utils
|
* @category Utils
|
||||||
@ -301,7 +307,7 @@ export {
|
|||||||
/**
|
/**
|
||||||
* @category Utils
|
* @category Utils
|
||||||
*/
|
*/
|
||||||
export { Hash, Hasher } from 'nx/src/core/hasher/hasher';
|
export { Hash, Hasher } from 'nx/src/hasher/hasher';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @category Utils
|
* @category Utils
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import type { Target } from 'nx/src/command-line/run';
|
import type { Target } from 'nx/src/command-line/run';
|
||||||
import type { ExecutorContext } from 'nx/src/shared/workspace';
|
import type { ExecutorContext } from 'nx/src/config/misc-interfaces';
|
||||||
import { Workspaces } from 'nx/src/shared/workspace';
|
import { Workspaces } from 'nx/src/config/workspaces';
|
||||||
import { combineOptionsForExecutor } from 'nx/src/utils/params';
|
import { combineOptionsForExecutor } from 'nx/src/utils/params';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import type { Tree } from 'nx/src/shared/tree';
|
import type { Tree } from 'nx/src/config/tree';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import type * as Prettier from 'prettier';
|
import type * as Prettier from 'prettier';
|
||||||
import { getWorkspacePath } from '../utils/get-workspace-layout';
|
import { getWorkspacePath } from '../utils/get-workspace-layout';
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import type { Tree } from 'nx/src/shared/tree';
|
import type { Tree } from 'nx/src/config/tree';
|
||||||
import { createTree } from '../tests/create-tree';
|
import { createTree } from '../tests/create-tree';
|
||||||
import { generateFiles } from './generate-files';
|
import { generateFiles } from './generate-files';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { readFileSync, readdirSync, statSync } from 'fs';
|
import { readFileSync, readdirSync, statSync } from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import type { Tree } from 'nx/src/shared/tree';
|
import type { Tree } from 'nx/src/config/tree';
|
||||||
import { logger } from 'nx/src/utils/logger';
|
import { logger } from 'nx/src/utils/logger';
|
||||||
|
|
||||||
const binaryExts = new Set([
|
const binaryExts = new Set([
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { Tree } from 'nx/src/shared/tree';
|
import { Tree } from 'nx/src/config/tree';
|
||||||
import { ProjectConfiguration } from 'nx/src/shared/workspace';
|
import { ProjectConfiguration } from 'nx/src/config/workspace-json-project-json';
|
||||||
|
|
||||||
import { createTreeWithEmptyWorkspace } from '../tests/create-tree-with-empty-workspace';
|
import { createTreeWithEmptyWorkspace } from '../tests/create-tree-with-empty-workspace';
|
||||||
import { readJson, updateJson } from '../utils/json';
|
import { readJson, updateJson } from '../utils/json';
|
||||||
|
|||||||
@ -2,12 +2,9 @@ import {
|
|||||||
buildWorkspaceConfigurationFromGlobs,
|
buildWorkspaceConfigurationFromGlobs,
|
||||||
deduplicateProjectFiles,
|
deduplicateProjectFiles,
|
||||||
globForProjectFiles,
|
globForProjectFiles,
|
||||||
ProjectConfiguration,
|
|
||||||
RawWorkspaceJsonConfiguration,
|
|
||||||
reformattedWorkspaceJsonOrNull,
|
reformattedWorkspaceJsonOrNull,
|
||||||
toNewFormat,
|
toNewFormat,
|
||||||
WorkspaceJsonConfiguration,
|
} from 'nx/src/config/workspaces';
|
||||||
} from 'nx/src/shared/workspace';
|
|
||||||
import { basename, dirname, relative } from 'path';
|
import { basename, dirname, relative } from 'path';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -16,9 +13,14 @@ import {
|
|||||||
} from '../utils/get-workspace-layout';
|
} from '../utils/get-workspace-layout';
|
||||||
import { readJson, updateJson, writeJson } from '../utils/json';
|
import { readJson, updateJson, writeJson } from '../utils/json';
|
||||||
|
|
||||||
import type { Tree } from 'nx/src/shared/tree';
|
import type { Tree } from 'nx/src/config/tree';
|
||||||
import type { NxJsonConfiguration } from 'nx/src/shared/nx';
|
import type { NxJsonConfiguration } from 'nx/src/config/nx-json';
|
||||||
import { joinPathFragments } from 'nx/src/utils/path';
|
import { joinPathFragments } from 'nx/src/utils/path';
|
||||||
|
import {
|
||||||
|
ProjectConfiguration,
|
||||||
|
RawWorkspaceJsonConfiguration,
|
||||||
|
WorkspaceJsonConfiguration,
|
||||||
|
} from 'nx/src/config/workspace-json-project-json';
|
||||||
|
|
||||||
export type WorkspaceConfiguration = Omit<
|
export type WorkspaceConfiguration = Omit<
|
||||||
WorkspaceJsonConfiguration,
|
WorkspaceJsonConfiguration,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import type { Tree } from 'nx/src/shared/tree';
|
import type { Tree } from 'nx/src/config/tree';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rename and transpile any new typescript files created to javascript files
|
* Rename and transpile any new typescript files created to javascript files
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import type { Tree } from 'nx/src/shared/tree';
|
import type { Tree } from 'nx/src/config/tree';
|
||||||
import { updateJson } from '../utils/json';
|
import { updateJson } from '../utils/json';
|
||||||
|
|
||||||
export function updateTsConfigsToJs(
|
export function updateTsConfigsToJs(
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { createTree } from '../tests/create-tree';
|
import { createTree } from '../tests/create-tree';
|
||||||
import type { Tree } from 'nx/src/shared/tree';
|
import type { Tree } from 'nx/src/config/tree';
|
||||||
import { visitNotIgnoredFiles } from './visit-not-ignored-files';
|
import { visitNotIgnoredFiles } from './visit-not-ignored-files';
|
||||||
|
|
||||||
describe('visitNotIgnoredFiles', () => {
|
describe('visitNotIgnoredFiles', () => {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import type { Tree } from 'nx/src/shared/tree';
|
import type { Tree } from 'nx/src/config/tree';
|
||||||
import ignore, { Ignore } from 'ignore';
|
import ignore, { Ignore } from 'ignore';
|
||||||
import { join, relative, sep } from 'path';
|
import { join, relative, sep } from 'path';
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import type { Tree } from 'nx/src/shared/tree';
|
import type { Tree } from 'nx/src/config/tree';
|
||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { FsTree } from 'nx/src/shared/tree';
|
import { FsTree } from 'nx/src/config/tree';
|
||||||
import type { Tree } from 'nx/src/shared/tree';
|
import type { Tree } from 'nx/src/config/tree';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a host for testing.
|
* Creates a host for testing.
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { FsTree } from 'nx/src/shared/tree';
|
import { FsTree } from 'nx/src/config/tree';
|
||||||
import type { Tree } from 'nx/src/shared/tree';
|
import type { Tree } from 'nx/src/config/tree';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a host for testing.
|
* Creates a host for testing.
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import type { Observable } from 'rxjs';
|
import type { Observable } from 'rxjs';
|
||||||
import type { Executor, ExecutorContext } from 'nx/src/shared/workspace';
|
import { Workspaces } from 'nx/src/config/workspaces';
|
||||||
import { Workspaces } from 'nx/src/shared/workspace';
|
import { Executor, ExecutorContext } from 'nx/src/config/misc-interfaces';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert an Nx Executor into an Angular Devkit Builder
|
* Convert an Nx Executor into an Angular Devkit Builder
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import { RawWorkspaceJsonConfiguration } from 'nx/src/shared/workspace';
|
import { RawWorkspaceJsonConfiguration } from 'nx/src/config/workspace-json-project-json';
|
||||||
|
|
||||||
import { readNxJson } from '../generators/project-configuration';
|
import { readNxJson } from '../generators/project-configuration';
|
||||||
import { readJson } from './json';
|
import { readJson } from './json';
|
||||||
|
|
||||||
import type { Tree } from 'nx/src/shared/tree';
|
import type { Tree } from 'nx/src/config/tree';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns workspace defaults. It includes defaults folders for apps and libs,
|
* Returns workspace defaults. It includes defaults folders for apps and libs,
|
||||||
|
|||||||
@ -1,11 +1,7 @@
|
|||||||
import { logger, stripIndent } from 'nx/src/utils/logger';
|
import { logger, stripIndent } from 'nx/src/utils/logger';
|
||||||
import type { FileChange, Tree, TreeWriteOptions } from 'nx/src/shared/tree';
|
import type { FileChange, Tree, TreeWriteOptions } from 'nx/src/config/tree';
|
||||||
import {
|
import { toNewFormat, toOldFormatOrNull } from 'nx/src/config/workspaces';
|
||||||
Generator,
|
import { Generator, GeneratorCallback } from 'nx/src/config/misc-interfaces';
|
||||||
GeneratorCallback,
|
|
||||||
toNewFormat,
|
|
||||||
toOldFormatOrNull,
|
|
||||||
} from 'nx/src/shared/workspace';
|
|
||||||
import { parseJson, serializeJson } from 'nx/src/utils/json';
|
import { parseJson, serializeJson } from 'nx/src/utils/json';
|
||||||
import { join, relative } from 'path';
|
import { join, relative } from 'path';
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import type { Tree } from 'nx/src/shared/tree';
|
import type { Tree } from 'nx/src/config/tree';
|
||||||
import { parseJson, serializeJson } from 'nx/src/utils/json';
|
import { parseJson, serializeJson } from 'nx/src/utils/json';
|
||||||
import type { JsonParseOptions, JsonSerializeOptions } from 'nx/src/utils/json';
|
import type { JsonParseOptions, JsonSerializeOptions } from 'nx/src/utils/json';
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Tree } from 'nx/src/shared/tree';
|
import { Tree } from 'nx/src/config/tree';
|
||||||
import { relative } from 'path';
|
import { relative } from 'path';
|
||||||
import { visitNotIgnoredFiles } from '../generators/visit-not-ignored-files';
|
import { visitNotIgnoredFiles } from '../generators/visit-not-ignored-files';
|
||||||
import { normalizePath } from 'nx/src/utils/path';
|
import { normalizePath } from 'nx/src/utils/path';
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import type { Tree } from 'nx/src/shared/tree';
|
import type { Tree } from 'nx/src/config/tree';
|
||||||
import { readJson, writeJson } from './json';
|
import { readJson, writeJson } from './json';
|
||||||
import { addDependenciesToPackageJson } from './package-json';
|
import { addDependenciesToPackageJson } from './package-json';
|
||||||
import { createTree } from '../tests/create-tree';
|
import { createTree } from '../tests/create-tree';
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { readJson, updateJson } from './json';
|
import { readJson, updateJson } from './json';
|
||||||
import { installPackagesTask } from '../tasks/install-packages-task';
|
import { installPackagesTask } from '../tasks/install-packages-task';
|
||||||
import type { Tree } from 'nx/src/shared/tree';
|
import type { Tree } from 'nx/src/config/tree';
|
||||||
import type { GeneratorCallback } from 'nx/src/shared/workspace';
|
import { GeneratorCallback } from 'nx/src/config/misc-interfaces';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add Dependencies and Dev Dependencies to package.json
|
* Add Dependencies and Dev Dependencies to package.json
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { vol } from 'memfs';
|
|||||||
import enforceModuleBoundaries, {
|
import enforceModuleBoundaries, {
|
||||||
RULE_NAME as enforceModuleBoundariesRuleName,
|
RULE_NAME as enforceModuleBoundariesRuleName,
|
||||||
} from '../../src/rules/enforce-module-boundaries';
|
} from '../../src/rules/enforce-module-boundaries';
|
||||||
import { TargetProjectLocator } from 'nx/src/core/target-project-locator';
|
import { TargetProjectLocator } from 'nx/src/utils/target-project-locator';
|
||||||
import { mapProjectGraphFiles } from '@nrwl/workspace/src/utils/runtime-lint-utils';
|
import { mapProjectGraphFiles } from '@nrwl/workspace/src/utils/runtime-lint-utils';
|
||||||
|
|
||||||
jest.mock('fs', () => require('memfs').fs);
|
jest.mock('fs', () => require('memfs').fs);
|
||||||
|
|||||||
@ -34,7 +34,7 @@ import {
|
|||||||
TSESTree,
|
TSESTree,
|
||||||
} from '@typescript-eslint/experimental-utils';
|
} from '@typescript-eslint/experimental-utils';
|
||||||
import { createESLintRule } from '../utils/create-eslint-rule';
|
import { createESLintRule } from '../utils/create-eslint-rule';
|
||||||
import { TargetProjectLocator } from 'nx/src/core/target-project-locator';
|
import { TargetProjectLocator } from 'nx/src/utils/target-project-locator';
|
||||||
import {
|
import {
|
||||||
checkCircularPath,
|
checkCircularPath,
|
||||||
findFilesInCircularPath,
|
findFilesInCircularPath,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { getJestProjects } from './get-jest-projects';
|
import { getJestProjects } from './get-jest-projects';
|
||||||
import * as Workspace from 'nx/src/core/file-utils';
|
import * as Workspace from 'nx/src/project-graph/file-utils';
|
||||||
import type { WorkspaceJsonConfiguration } from '@nrwl/devkit';
|
import type { WorkspaceJsonConfiguration } from '@nrwl/devkit';
|
||||||
|
|
||||||
describe('getJestProjects', () => {
|
describe('getJestProjects', () => {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { dirname, join } from 'path';
|
import { dirname, join } from 'path';
|
||||||
import type { WorkspaceJsonConfiguration } from '@nrwl/devkit';
|
import type { WorkspaceJsonConfiguration } from '@nrwl/devkit';
|
||||||
import { readWorkspaceConfig } from 'nx/src/core/file-utils';
|
import { readWorkspaceConfig } from 'nx/src/project-graph/file-utils';
|
||||||
|
|
||||||
const JEST_RUNNER_TOKEN = '@nrwl/jest:jest';
|
const JEST_RUNNER_TOKEN = '@nrwl/jest:jest';
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { createProjectGraphAsync } from '../src/core/project-graph/project-graph';
|
import { createProjectGraphAsync } from '../src/project-graph/project-graph';
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import {
|
|||||||
import * as chalk from 'chalk';
|
import * as chalk from 'chalk';
|
||||||
import { initLocal } from './init-local';
|
import { initLocal } from './init-local';
|
||||||
import { detectPackageManager } from '../src/utils/package-manager';
|
import { detectPackageManager } from '../src/utils/package-manager';
|
||||||
import { output } from 'nx/src/utils/output';
|
import { output } from '../src/utils/output';
|
||||||
|
|
||||||
// new is a special case because there is no local workspace to load
|
// new is a special case because there is no local workspace to load
|
||||||
if (process.argv[2] === 'new' || process.argv[2] === '_migrate') {
|
if (process.argv[2] === 'new' || process.argv[2] === '_migrate') {
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import {
|
|||||||
resolveOldFormatWithInlineProjects,
|
resolveOldFormatWithInlineProjects,
|
||||||
workspaceConfigName,
|
workspaceConfigName,
|
||||||
Workspaces,
|
Workspaces,
|
||||||
} from '../shared/workspace';
|
} from '../config/workspaces';
|
||||||
import { workspaceRoot } from '../utils/app-root';
|
import { workspaceRoot } from '../utils/app-root';
|
||||||
|
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|||||||
@ -15,18 +15,15 @@ import { createConsoleLogger, NodeJsSyncHost } from '@angular-devkit/core/node';
|
|||||||
import { Stats } from 'fs';
|
import { Stats } from 'fs';
|
||||||
import { detectPackageManager } from '../utils/package-manager';
|
import { detectPackageManager } from '../utils/package-manager';
|
||||||
import { GenerateOptions } from '../command-line/generate';
|
import { GenerateOptions } from '../command-line/generate';
|
||||||
import { FileChange, Tree } from '../shared/tree';
|
import { FileChange, Tree } from '../config/tree';
|
||||||
import {
|
import {
|
||||||
buildWorkspaceConfigurationFromGlobs,
|
buildWorkspaceConfigurationFromGlobs,
|
||||||
globForProjectFiles,
|
globForProjectFiles,
|
||||||
ProjectConfiguration,
|
|
||||||
RawWorkspaceJsonConfiguration,
|
|
||||||
toNewFormat,
|
toNewFormat,
|
||||||
toNewFormatOrNull,
|
toNewFormatOrNull,
|
||||||
toOldFormatOrNull,
|
toOldFormatOrNull,
|
||||||
workspaceConfigName,
|
workspaceConfigName,
|
||||||
WorkspaceJsonConfiguration,
|
} from '../config/workspaces';
|
||||||
} from '../shared/workspace';
|
|
||||||
import { dirname, extname, resolve, join, basename } from 'path';
|
import { dirname, extname, resolve, join, basename } from 'path';
|
||||||
import { FileBuffer } from '@angular-devkit/core/src/virtual-fs/host/interface';
|
import { FileBuffer } from '@angular-devkit/core/src/virtual-fs/host/interface';
|
||||||
import type { Architect } from '@angular-devkit/architect';
|
import type { Architect } from '@angular-devkit/architect';
|
||||||
@ -35,7 +32,12 @@ import { catchError, map, switchMap, toArray, tap } from 'rxjs/operators';
|
|||||||
import { NX_ERROR, NX_PREFIX } from '../utils/logger';
|
import { NX_ERROR, NX_PREFIX } from '../utils/logger';
|
||||||
import { readJsonFile } from '../utils/fileutils';
|
import { readJsonFile } from '../utils/fileutils';
|
||||||
import { parseJson, serializeJson } from '../utils/json';
|
import { parseJson, serializeJson } from '../utils/json';
|
||||||
import { NxJsonConfiguration } from '../shared/nx';
|
import { NxJsonConfiguration } from '../config/nx-json';
|
||||||
|
import {
|
||||||
|
ProjectConfiguration,
|
||||||
|
RawWorkspaceJsonConfiguration,
|
||||||
|
WorkspaceJsonConfiguration,
|
||||||
|
} from '../config/workspace-json-project-json';
|
||||||
|
|
||||||
export async function scheduleTarget(
|
export async function scheduleTarget(
|
||||||
root: string,
|
root: string,
|
||||||
@ -760,50 +762,6 @@ function isWorkspaceConfigPath(p: Path | string) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function processConfigWhenReading(content: ArrayBuffer) {
|
|
||||||
try {
|
|
||||||
const json = parseJson(Buffer.from(content).toString());
|
|
||||||
Object.values(json.projects).forEach((p: any) => {
|
|
||||||
try {
|
|
||||||
Object.values(p.architect || p.targets).forEach((e: any) => {
|
|
||||||
if (
|
|
||||||
(e.builder === '@nrwl/jest:jest' ||
|
|
||||||
e.executor === '@nrwl/jest:jest') &&
|
|
||||||
!e.options.tsConfig
|
|
||||||
) {
|
|
||||||
e.options.tsConfig = `${p.root}/tsconfig.spec.json`;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (e) {}
|
|
||||||
});
|
|
||||||
return Buffer.from(serializeJson(json));
|
|
||||||
} catch (e) {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function processConfigWhenWriting(content: ArrayBuffer) {
|
|
||||||
try {
|
|
||||||
const json = parseJson(Buffer.from(content).toString());
|
|
||||||
Object.values(json.projects).forEach((p: any) => {
|
|
||||||
try {
|
|
||||||
Object.values(p.architect || p.targets).forEach((e: any) => {
|
|
||||||
if (
|
|
||||||
(e.builder === '@nrwl/jest:jest' ||
|
|
||||||
e.executor === '@nrwl/jest:jest') &&
|
|
||||||
e.options.tsConfig
|
|
||||||
) {
|
|
||||||
delete e.options.tsConfig;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (e) {}
|
|
||||||
});
|
|
||||||
return Buffer.from(serializeJson(json));
|
|
||||||
} catch (e) {
|
|
||||||
return content;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function generate(
|
export async function generate(
|
||||||
root: string,
|
root: string,
|
||||||
opts: GenerateOptions,
|
opts: GenerateOptions,
|
||||||
|
|||||||
@ -1,18 +1,22 @@
|
|||||||
import * as yargs from 'yargs';
|
import * as yargs from 'yargs';
|
||||||
import { filterAffected } from '../core/affected-project-graph';
|
import { calculateFileChanges } from '../project-graph/file-utils';
|
||||||
import { calculateFileChanges, readEnvironment } from '../core/file-utils';
|
|
||||||
import { runCommand } from '../tasks-runner/run-command';
|
import { runCommand } from '../tasks-runner/run-command';
|
||||||
import { output } from '../utils/output';
|
import { output } from '../utils/output';
|
||||||
import { generateGraph } from './dep-graph';
|
import { generateGraph } from './dep-graph';
|
||||||
import { printAffected } from './print-affected';
|
import { printAffected } from './print-affected';
|
||||||
import { connectToNxCloudUsingScan } from './connect-to-nx-cloud';
|
import { connectToNxCloudUsingScan } from './connect-to-nx-cloud';
|
||||||
import type { NxArgs, RawNxArgs } from './utils';
|
import type { NxArgs, RawNxArgs } from '../utils/command-line-utils';
|
||||||
import { parseFiles, splitArgsIntoNxArgsAndOverrides } from './utils';
|
import {
|
||||||
|
parseFiles,
|
||||||
|
splitArgsIntoNxArgsAndOverrides,
|
||||||
|
} from '../utils/command-line-utils';
|
||||||
import { performance } from 'perf_hooks';
|
import { performance } from 'perf_hooks';
|
||||||
import { createProjectGraphAsync } from 'nx/src/core/project-graph/project-graph';
|
import { createProjectGraphAsync } from '../project-graph/project-graph';
|
||||||
import { withDeps } from 'nx/src/core/project-graph/operators';
|
import { withDeps } from '../project-graph/operators';
|
||||||
import { ProjectGraph, ProjectGraphProjectNode } from '../shared/project-graph';
|
import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
|
||||||
import { projectHasTarget } from '../utils/project-graph-utils';
|
import { projectHasTarget } from '../utils/project-graph-utils';
|
||||||
|
import { filterAffected } from '../project-graph/affected/affected-project-graph';
|
||||||
|
import { readEnvironment } from './read-environment';
|
||||||
|
|
||||||
export async function affected(
|
export async function affected(
|
||||||
command: 'apps' | 'libs' | 'graph' | 'print-affected' | 'affected',
|
command: 'apps' | 'libs' | 'graph' | 'print-affected' | 'affected',
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { readNxJson } from '../core/file-utils';
|
import { readNxJson } from '../project-graph/file-utils';
|
||||||
import { output } from '../utils/output';
|
import { output } from '../utils/output';
|
||||||
import { getPackageManagerCommand } from '../utils/package-manager';
|
import { getPackageManagerCommand } from '../utils/package-manager';
|
||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import type { Arguments } from 'yargs';
|
import type { Arguments } from 'yargs';
|
||||||
import { DAEMON_OUTPUT_LOG_FILE } from '../core/project-graph/daemon/tmp-dir';
|
import { DAEMON_OUTPUT_LOG_FILE } from '../daemon/tmp-dir';
|
||||||
import { output } from '../utils/output';
|
import { output } from '../utils/output';
|
||||||
|
|
||||||
export async function daemonHandler(args: Arguments) {
|
export async function daemonHandler(args: Arguments) {
|
||||||
const { startInBackground, startInCurrentProcess } = await import(
|
const { startInBackground, startInCurrentProcess } = await import(
|
||||||
'../core/project-graph/daemon/client/client'
|
'../daemon/client/client'
|
||||||
);
|
);
|
||||||
if (!args.background) {
|
if (!args.background) {
|
||||||
return startInCurrentProcess();
|
return startInCurrentProcess();
|
||||||
|
|||||||
@ -9,18 +9,18 @@ import * as open from 'open';
|
|||||||
import { basename, dirname, extname, isAbsolute, join, parse } from 'path';
|
import { basename, dirname, extname, isAbsolute, join, parse } from 'path';
|
||||||
import { performance } from 'perf_hooks';
|
import { performance } from 'perf_hooks';
|
||||||
import { URL, URLSearchParams } from 'url';
|
import { URL, URLSearchParams } from 'url';
|
||||||
import { workspaceLayout } from '../core/file-utils';
|
import { workspaceLayout } from '../project-graph/file-utils';
|
||||||
import { defaultFileHasher } from '../core/hasher/file-hasher';
|
import { defaultFileHasher } from '../hasher/file-hasher';
|
||||||
import { output } from '../utils/output';
|
import { output } from '../utils/output';
|
||||||
import { writeJsonFile } from 'nx/src/utils/fileutils';
|
import { writeJsonFile } from '../utils/fileutils';
|
||||||
import { joinPathFragments } from 'nx/src/utils/path';
|
import { joinPathFragments } from '../utils/path';
|
||||||
import {
|
import {
|
||||||
ProjectGraph,
|
ProjectGraph,
|
||||||
ProjectGraphDependency,
|
ProjectGraphDependency,
|
||||||
ProjectGraphProjectNode,
|
ProjectGraphProjectNode,
|
||||||
} from 'nx/src/shared/project-graph';
|
} from '../config/project-graph';
|
||||||
import { pruneExternalNodes } from 'nx/src/core/project-graph/operators';
|
import { pruneExternalNodes } from '../project-graph/operators';
|
||||||
import { createProjectGraphAsync } from 'nx/src/core/project-graph/project-graph';
|
import { createProjectGraphAsync } from '../project-graph/project-graph';
|
||||||
|
|
||||||
export interface DepGraphClientResponse {
|
export interface DepGraphClientResponse {
|
||||||
hash: string;
|
hash: string;
|
||||||
|
|||||||
@ -5,27 +5,29 @@ import {
|
|||||||
NxArgs,
|
NxArgs,
|
||||||
parseFiles,
|
parseFiles,
|
||||||
splitArgsIntoNxArgsAndOverrides,
|
splitArgsIntoNxArgsAndOverrides,
|
||||||
} from './utils';
|
} from '../utils/command-line-utils';
|
||||||
import { fileExists } from '../utils/fileutils';
|
import { fileExists } from '../utils/fileutils';
|
||||||
import { filterAffected } from '../core/affected-project-graph';
|
import { calculateFileChanges, FileData } from '../project-graph/file-utils';
|
||||||
import { calculateFileChanges, FileData } from '../core/file-utils';
|
|
||||||
import * as yargs from 'yargs';
|
import * as yargs from 'yargs';
|
||||||
import {
|
import {
|
||||||
ProjectConfiguration,
|
|
||||||
reformattedWorkspaceJsonOrNull,
|
reformattedWorkspaceJsonOrNull,
|
||||||
workspaceConfigName,
|
workspaceConfigName,
|
||||||
WorkspaceJsonConfiguration,
|
} from '../config/workspaces';
|
||||||
} from 'nx/src/shared/workspace';
|
import { workspaceRoot } from '../utils/app-root';
|
||||||
import { workspaceRoot } from 'nx/src/utils/app-root';
|
|
||||||
import * as prettier from 'prettier';
|
import * as prettier from 'prettier';
|
||||||
import { sortObjectByKeys } from 'nx/src/utils/object-sort';
|
import { sortObjectByKeys } from '../utils/object-sort';
|
||||||
import {
|
import {
|
||||||
getRootTsConfigFileName,
|
getRootTsConfigFileName,
|
||||||
getRootTsConfigPath,
|
getRootTsConfigPath,
|
||||||
} from '../utils/typescript';
|
} from '../utils/typescript';
|
||||||
import { readJsonFile, writeJsonFile } from 'nx/src/utils/fileutils';
|
import { readJsonFile, writeJsonFile } from '../utils/fileutils';
|
||||||
import { NxJsonConfiguration } from 'nx/src/shared/nx';
|
import { NxJsonConfiguration } from '../config/nx-json';
|
||||||
import { createProjectGraphAsync } from '../core/project-graph/project-graph';
|
import { createProjectGraphAsync } from '../project-graph/project-graph';
|
||||||
|
import { filterAffected } from '../project-graph/affected/affected-project-graph';
|
||||||
|
import {
|
||||||
|
ProjectConfiguration,
|
||||||
|
WorkspaceJsonConfiguration,
|
||||||
|
} from '../config/workspace-json-project-json';
|
||||||
|
|
||||||
const PRETTIER_PATH = require.resolve('prettier/bin-prettier');
|
const PRETTIER_PATH = require.resolve('prettier/bin-prettier');
|
||||||
|
|
||||||
|
|||||||
@ -4,13 +4,13 @@ import {
|
|||||||
Options,
|
Options,
|
||||||
Schema,
|
Schema,
|
||||||
} from '../utils/params';
|
} from '../utils/params';
|
||||||
import { Workspaces } from '../shared/workspace';
|
import { Workspaces } from '../config/workspaces';
|
||||||
import { FileChange, flushChanges, FsTree } from '../shared/tree';
|
import { FileChange, flushChanges, FsTree } from '../config/tree';
|
||||||
import { logger } from '../utils/logger';
|
import { logger } from '../utils/logger';
|
||||||
import * as chalk from 'chalk';
|
import * as chalk from 'chalk';
|
||||||
import { workspaceRoot } from 'nx/src/utils/app-root';
|
import { workspaceRoot } from '../utils/app-root';
|
||||||
import { NxJsonConfiguration } from 'nx/src/shared/nx';
|
import { NxJsonConfiguration } from '../config/nx-json';
|
||||||
import { printHelp } from 'nx/src/utils/print-help';
|
import { printHelp } from '../utils/print-help';
|
||||||
|
|
||||||
export interface GenerateOptions {
|
export interface GenerateOptions {
|
||||||
collectionName: string;
|
collectionName: string;
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import { WorkspaceIntegrityChecks } from './workspace-integrity-checks';
|
import { WorkspaceIntegrityChecks } from './workspace-integrity-checks';
|
||||||
import { FileData, workspaceLayout } from '../core/file-utils';
|
import { FileData, workspaceLayout } from '../project-graph/file-utils';
|
||||||
import { output } from '../utils/output';
|
import { output } from '../utils/output';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { createProjectGraphAsync } from '../core/project-graph/project-graph';
|
import { createProjectGraphAsync } from '../project-graph/project-graph';
|
||||||
import { pruneExternalNodes } from '../core/project-graph/operators';
|
import { pruneExternalNodes } from '../project-graph/operators';
|
||||||
|
|
||||||
export async function workspaceLint(): Promise<void> {
|
export async function workspaceLint(): Promise<void> {
|
||||||
const graph = await createProjectGraphAsync();
|
const graph = await createProjectGraphAsync();
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { workspaceRoot } from 'nx/src/utils/app-root';
|
import { workspaceRoot } from '../utils/app-root';
|
||||||
import { output } from '../utils/output';
|
import { output } from '../utils/output';
|
||||||
import {
|
import {
|
||||||
fetchCommunityPlugins,
|
fetchCommunityPlugins,
|
||||||
|
|||||||
@ -3,8 +3,8 @@ import { copyFileSync, removeSync } from 'fs-extra';
|
|||||||
import { dirname, join } from 'path';
|
import { dirname, join } from 'path';
|
||||||
import { gt, lte } from 'semver';
|
import { gt, lte } from 'semver';
|
||||||
import { dirSync } from 'tmp';
|
import { dirSync } from 'tmp';
|
||||||
import { NxJsonConfiguration } from '../shared/nx';
|
import { NxJsonConfiguration } from '../config/nx-json';
|
||||||
import { flushChanges, FsTree } from '../shared/tree';
|
import { flushChanges, FsTree } from '../config/tree';
|
||||||
import {
|
import {
|
||||||
extractFileFromTarball,
|
extractFileFromTarball,
|
||||||
JsonReadOptions,
|
JsonReadOptions,
|
||||||
|
|||||||
@ -2,12 +2,12 @@ import * as chalk from 'chalk';
|
|||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as yargs from 'yargs';
|
import * as yargs from 'yargs';
|
||||||
import { generateDaemonHelpOutput } from '../core/project-graph/daemon/client/generate-help-output';
|
import { generateDaemonHelpOutput } from '../daemon/client/generate-help-output';
|
||||||
import { nxVersion } from '../utils/versions';
|
import { nxVersion } from '../utils/versions';
|
||||||
import { examples } from './examples';
|
import { examples } from './examples';
|
||||||
import { workspaceRoot } from 'nx/src/utils/app-root';
|
import { workspaceRoot } from '../utils/app-root';
|
||||||
import { getPackageManagerCommand } from '../utils/package-manager';
|
import { getPackageManagerCommand } from '../utils/package-manager';
|
||||||
import { writeJsonFile } from 'nx/src/utils/fileutils';
|
import { writeJsonFile } from '../utils/fileutils';
|
||||||
|
|
||||||
const isGenerateDocsProcess = process.env.NX_GENERATE_DOCS_PROCESS === 'true';
|
const isGenerateDocsProcess = process.env.NX_GENERATE_DOCS_PROCESS === 'true';
|
||||||
const daemonHelpOutput = generateDaemonHelpOutput(isGenerateDocsProcess);
|
const daemonHelpOutput = generateDaemonHelpOutput(isGenerateDocsProcess);
|
||||||
|
|||||||
@ -1,13 +1,10 @@
|
|||||||
import type { Environment } from '../core/shared-interfaces';
|
|
||||||
import { createTask } from '../tasks-runner/run-command';
|
import { createTask } from '../tasks-runner/run-command';
|
||||||
import { getCommandAsString, getOutputs } from '../tasks-runner/utils';
|
import { getCommandAsString, getOutputs } from '../tasks-runner/utils';
|
||||||
import * as yargs from 'yargs';
|
import * as yargs from 'yargs';
|
||||||
import type { NxArgs } from './utils';
|
import type { NxArgs } from '../utils/command-line-utils';
|
||||||
import {
|
import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
|
||||||
ProjectGraph,
|
import { Task } from '../config/task-graph';
|
||||||
ProjectGraphProjectNode,
|
import { Environment } from './read-environment';
|
||||||
} from 'nx/src/shared/project-graph';
|
|
||||||
import { Task } from 'nx/src/shared/tasks';
|
|
||||||
|
|
||||||
export async function printAffected(
|
export async function printAffected(
|
||||||
affectedProjectsWithTargetAndConfig: ProjectGraphProjectNode[],
|
affectedProjectsWithTargetAndConfig: ProjectGraphProjectNode[],
|
||||||
|
|||||||
19
packages/nx/src/command-line/read-environment.ts
Normal file
19
packages/nx/src/command-line/read-environment.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { readNxJson, readWorkspaceJson } from '../project-graph/file-utils';
|
||||||
|
import { NxJsonConfiguration } from '../config/nx-json';
|
||||||
|
|
||||||
|
export interface Environment {
|
||||||
|
nxJson: NxJsonConfiguration;
|
||||||
|
workspaceJson: any;
|
||||||
|
/**
|
||||||
|
* @deprecated the field will be removed after Nx 14 is released. It's left here
|
||||||
|
* not to break the type checker in case someone extends
|
||||||
|
* the tasks runner
|
||||||
|
*/
|
||||||
|
workspaceResults: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function readEnvironment(): Environment {
|
||||||
|
const nxJson = readNxJson();
|
||||||
|
const workspaceJson = readWorkspaceJson();
|
||||||
|
return { nxJson, workspaceJson, workspaceResults: null } as any;
|
||||||
|
}
|
||||||
@ -1,12 +1,12 @@
|
|||||||
import * as chalk from 'chalk';
|
import * as chalk from 'chalk';
|
||||||
import { workspaceRoot } from 'nx/src/utils/app-root';
|
import { workspaceRoot } from '../utils/app-root';
|
||||||
import { output } from '../utils/output';
|
import { output } from '../utils/output';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import {
|
import {
|
||||||
detectPackageManager,
|
detectPackageManager,
|
||||||
getPackageManagerVersion,
|
getPackageManagerVersion,
|
||||||
} from 'nx/src/utils/package-manager';
|
} from '../utils/package-manager';
|
||||||
import { readJsonFile } from 'nx/src/utils/fileutils';
|
import { readJsonFile } from '../utils/fileutils';
|
||||||
|
|
||||||
export const packagesWeCareAbout = [
|
export const packagesWeCareAbout = [
|
||||||
'nx',
|
'nx',
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { removeSync } from 'fs-extra';
|
import { removeSync } from 'fs-extra';
|
||||||
import { stop as stopDaemon } from '../core/project-graph/daemon/client/client';
|
import { stop as stopDaemon } from '../daemon/client/client';
|
||||||
import { cacheDir } from '../utils/cache-directory';
|
import { cacheDir } from '../utils/cache-directory';
|
||||||
import { output } from '../utils/output';
|
import { output } from '../utils/output';
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
import * as yargs from 'yargs';
|
import * as yargs from 'yargs';
|
||||||
import { runCommand } from '../tasks-runner/run-command';
|
import { runCommand } from '../tasks-runner/run-command';
|
||||||
import type { NxArgs, RawNxArgs } from './utils';
|
import type { NxArgs, RawNxArgs } from '../utils/command-line-utils';
|
||||||
import { splitArgsIntoNxArgsAndOverrides } from './utils';
|
import { splitArgsIntoNxArgsAndOverrides } from '../utils/command-line-utils';
|
||||||
import { readEnvironment } from '../core/file-utils';
|
|
||||||
import { projectHasTarget } from '../utils/project-graph-utils';
|
import { projectHasTarget } from '../utils/project-graph-utils';
|
||||||
import { output } from '../utils/output';
|
import { output } from '../utils/output';
|
||||||
import { connectToNxCloudUsingScan } from './connect-to-nx-cloud';
|
import { connectToNxCloudUsingScan } from './connect-to-nx-cloud';
|
||||||
import { performance } from 'perf_hooks';
|
import { performance } from 'perf_hooks';
|
||||||
import { ProjectGraph, ProjectGraphProjectNode } from '../shared/project-graph';
|
import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
|
||||||
import { createProjectGraphAsync } from '../core/project-graph/project-graph';
|
import { createProjectGraphAsync } from '../project-graph/project-graph';
|
||||||
|
import { readEnvironment } from './read-environment';
|
||||||
|
|
||||||
export async function runMany(parsedArgs: yargs.Arguments & RawNxArgs) {
|
export async function runMany(parsedArgs: yargs.Arguments & RawNxArgs) {
|
||||||
performance.mark('command-execution-begins');
|
performance.mark('command-execution-begins');
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
import { runCommand } from '../tasks-runner/run-command';
|
import { runCommand } from '../tasks-runner/run-command';
|
||||||
import { readEnvironment, readNxJson } from '../core/file-utils';
|
import { splitArgsIntoNxArgsAndOverrides } from '../utils/command-line-utils';
|
||||||
import { splitArgsIntoNxArgsAndOverrides } from './utils';
|
|
||||||
import { connectToNxCloudUsingScan } from './connect-to-nx-cloud';
|
import { connectToNxCloudUsingScan } from './connect-to-nx-cloud';
|
||||||
import { performance } from 'perf_hooks';
|
import { performance } from 'perf_hooks';
|
||||||
import { createProjectGraphAsync } from '../core/project-graph/project-graph';
|
import { createProjectGraphAsync } from '../project-graph/project-graph';
|
||||||
import { ProjectGraph } from '../shared/project-graph';
|
import { ProjectGraph } from '../config/project-graph';
|
||||||
import { WorkspaceJsonConfiguration } from 'nx/src/shared/workspace';
|
import { NxJsonConfiguration } from '../config/nx-json';
|
||||||
import { NxJsonConfiguration } from 'nx/src/shared/nx';
|
import { workspaceRoot } from '../utils/app-root';
|
||||||
import { workspaceRoot } from 'nx/src/utils/app-root';
|
import { splitTarget } from '../utils/split-target';
|
||||||
import { splitTarget } from 'nx/src/utils/split-target';
|
import { output } from '../utils/output';
|
||||||
import { output } from 'nx/src/utils/output';
|
import { readEnvironment } from './read-environment';
|
||||||
|
import { WorkspaceJsonConfiguration } from '../config/workspace-json-project-json';
|
||||||
|
|
||||||
export async function runOne(
|
export async function runOne(
|
||||||
cwd: string,
|
cwd: string,
|
||||||
|
|||||||
@ -4,15 +4,8 @@ import {
|
|||||||
Schema,
|
Schema,
|
||||||
} from '../utils/params';
|
} from '../utils/params';
|
||||||
import { printHelp } from '../utils/print-help';
|
import { printHelp } from '../utils/print-help';
|
||||||
import {
|
import { Workspaces } from '../config/workspaces';
|
||||||
Executor,
|
import { NxJsonConfiguration } from '../config/nx-json';
|
||||||
ExecutorContext,
|
|
||||||
ProjectConfiguration,
|
|
||||||
TargetConfiguration,
|
|
||||||
WorkspaceJsonConfiguration,
|
|
||||||
Workspaces,
|
|
||||||
} from '../shared/workspace';
|
|
||||||
import { NxJsonConfiguration } from '../shared/nx';
|
|
||||||
import { readJsonFile } from '../utils/fileutils';
|
import { readJsonFile } from '../utils/fileutils';
|
||||||
import { buildTargetFromScript, PackageJson } from '../utils/package-json';
|
import { buildTargetFromScript, PackageJson } from '../utils/package-json';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
@ -21,6 +14,12 @@ import {
|
|||||||
loadNxPlugins,
|
loadNxPlugins,
|
||||||
mergePluginTargetsWithNxTargets,
|
mergePluginTargetsWithNxTargets,
|
||||||
} from '../utils/nx-plugin';
|
} from '../utils/nx-plugin';
|
||||||
|
import {
|
||||||
|
ProjectConfiguration,
|
||||||
|
TargetConfiguration,
|
||||||
|
WorkspaceJsonConfiguration,
|
||||||
|
} from '../config/workspace-json-project-json';
|
||||||
|
import { Executor, ExecutorContext } from '../config/misc-interfaces';
|
||||||
|
|
||||||
export interface Target {
|
export interface Target {
|
||||||
project: string;
|
project: string;
|
||||||
|
|||||||
@ -4,13 +4,13 @@ import { readdirSync, existsSync } from 'fs';
|
|||||||
import { copySync, removeSync } from 'fs-extra';
|
import { copySync, removeSync } from 'fs-extra';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as yargsParser from 'yargs-parser';
|
import * as yargsParser from 'yargs-parser';
|
||||||
import { workspaceRoot } from 'nx/src/utils/app-root';
|
import { workspaceRoot } from '../utils/app-root';
|
||||||
import { fileExists } from '../utils/fileutils';
|
import { fileExists } from '../utils/fileutils';
|
||||||
import { output } from '../utils/output';
|
import { output } from '../utils/output';
|
||||||
import type { CompilerOptions } from 'typescript';
|
import type { CompilerOptions } from 'typescript';
|
||||||
import { generate } from 'nx/src/command-line/generate';
|
import { generate } from './generate';
|
||||||
import { readJsonFile, writeJsonFile } from 'nx/src/utils/fileutils';
|
import { readJsonFile, writeJsonFile } from '../utils/fileutils';
|
||||||
import { logger } from 'nx/src/utils/logger';
|
import { logger } from '../utils/logger';
|
||||||
import { getPackageManagerCommand } from '../utils/package-manager';
|
import { getPackageManagerCommand } from '../utils/package-manager';
|
||||||
import { normalizePath } from '../utils/path';
|
import { normalizePath } from '../utils/path';
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { output } from '../utils/output';
|
import { output } from '../utils/output';
|
||||||
import type { CLIErrorMessageConfig } from '../utils/output';
|
import type { CLIErrorMessageConfig } from '../utils/output';
|
||||||
import { workspaceFileName } from '../core/file-utils';
|
import { workspaceFileName } from '../project-graph/file-utils';
|
||||||
import { ProjectGraph } from 'nx/src/shared/project-graph';
|
import { ProjectGraph } from '../config/project-graph';
|
||||||
|
|
||||||
export class WorkspaceIntegrityChecks {
|
export class WorkspaceIntegrityChecks {
|
||||||
constructor(private projectGraph: ProjectGraph, private files: string[]) {}
|
constructor(private projectGraph: ProjectGraph, private files: string[]) {}
|
||||||
|
|||||||
102
packages/nx/src/config/misc-interfaces.ts
Normal file
102
packages/nx/src/config/misc-interfaces.ts
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
import type { NxJsonConfiguration } from './nx-json';
|
||||||
|
import { TaskGraph } from './task-graph';
|
||||||
|
import {
|
||||||
|
TargetConfiguration,
|
||||||
|
WorkspaceJsonConfiguration,
|
||||||
|
} from './workspace-json-project-json';
|
||||||
|
/**
|
||||||
|
* A callback function that is executed after changes are made to the file system
|
||||||
|
*/
|
||||||
|
export type GeneratorCallback = () => void | Promise<void>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A function that schedules updates to the filesystem to be done atomically
|
||||||
|
*/
|
||||||
|
export type Generator<T = unknown> = (
|
||||||
|
tree,
|
||||||
|
schema: T
|
||||||
|
) => void | GeneratorCallback | Promise<void | GeneratorCallback>;
|
||||||
|
|
||||||
|
export interface ExecutorConfig {
|
||||||
|
schema: any;
|
||||||
|
hasherFactory?: () => any;
|
||||||
|
implementationFactory: () => Executor;
|
||||||
|
batchImplementationFactory?: () => TaskGraphExecutor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of a target of a project
|
||||||
|
*/
|
||||||
|
export type Executor<T = any> = (
|
||||||
|
/**
|
||||||
|
* Options that users configure or pass via the command line
|
||||||
|
*/
|
||||||
|
options: T,
|
||||||
|
context: ExecutorContext
|
||||||
|
) =>
|
||||||
|
| Promise<{ success: boolean }>
|
||||||
|
| AsyncIterableIterator<{ success: boolean }>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of a target of a project that handles multiple projects to be batched
|
||||||
|
*/
|
||||||
|
export type TaskGraphExecutor<T = any> = (
|
||||||
|
/**
|
||||||
|
* Graph of Tasks to be executed
|
||||||
|
*/
|
||||||
|
taskGraph: TaskGraph,
|
||||||
|
/**
|
||||||
|
* Map of Task IDs to options for the task
|
||||||
|
*/
|
||||||
|
options: Record<string, T>,
|
||||||
|
/**
|
||||||
|
* Set of overrides for the overall execution
|
||||||
|
*/
|
||||||
|
overrides: T,
|
||||||
|
context: ExecutorContext
|
||||||
|
) => Promise<Record<string, { success: boolean; terminalOutput: string }>>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context that is passed into an executor
|
||||||
|
*/
|
||||||
|
export interface ExecutorContext {
|
||||||
|
/**
|
||||||
|
* The root of the workspace
|
||||||
|
*/
|
||||||
|
root: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the project being executed on
|
||||||
|
*/
|
||||||
|
projectName?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the target being executed
|
||||||
|
*/
|
||||||
|
targetName?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the configuration being executed
|
||||||
|
*/
|
||||||
|
configurationName?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The configuration of the target being executed
|
||||||
|
*/
|
||||||
|
target?: TargetConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The full workspace configuration
|
||||||
|
*/
|
||||||
|
workspace: WorkspaceJsonConfiguration & NxJsonConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current working directory
|
||||||
|
*/
|
||||||
|
cwd: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable verbose logging
|
||||||
|
*/
|
||||||
|
isVerbose: boolean;
|
||||||
|
}
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import { PackageManager } from '../utils/package-manager';
|
import { PackageManager } from '../utils/package-manager';
|
||||||
import { TargetDependencyConfig } from './workspace';
|
import { TargetDependencyConfig } from './workspace-json-project-json';
|
||||||
|
|
||||||
export type ImplicitDependencyEntry<T = '*' | string[]> = {
|
export type ImplicitDependencyEntry<T = '*' | string[]> = {
|
||||||
[key: string]: T | ImplicitJsonSubsetDependency<T>;
|
[key: string]: T | ImplicitJsonSubsetDependency<T>;
|
||||||
@ -1,4 +1,7 @@
|
|||||||
import type { TargetConfiguration, Workspace } from './workspace';
|
import type {
|
||||||
|
TargetConfiguration,
|
||||||
|
Workspace,
|
||||||
|
} from './workspace-json-project-json';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some metadata about a file
|
* Some metadata about a file
|
||||||
145
packages/nx/src/config/workspace-json-project-json.ts
Normal file
145
packages/nx/src/config/workspace-json-project-json.ts
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
import type { NxJsonConfiguration } from './nx-json';
|
||||||
|
|
||||||
|
export interface Workspace
|
||||||
|
extends WorkspaceJsonConfiguration,
|
||||||
|
NxJsonConfiguration {
|
||||||
|
projects: Record<string, ProjectConfiguration>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Workspace configuration
|
||||||
|
*/
|
||||||
|
export interface WorkspaceJsonConfiguration {
|
||||||
|
/**
|
||||||
|
* Version of the configuration format
|
||||||
|
*/
|
||||||
|
version: number;
|
||||||
|
/**
|
||||||
|
* Projects' projects
|
||||||
|
*/
|
||||||
|
projects: {
|
||||||
|
[projectName: string]: ProjectConfiguration;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RawWorkspaceJsonConfiguration
|
||||||
|
extends Omit<WorkspaceJsonConfiguration, 'projects'> {
|
||||||
|
projects: { [projectName: string]: ProjectConfiguration | string };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of project supported
|
||||||
|
*/
|
||||||
|
export type ProjectType = 'library' | 'application';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project configuration
|
||||||
|
*/
|
||||||
|
export interface ProjectConfiguration {
|
||||||
|
/**
|
||||||
|
* Project's name. Optional if specified in workspace.json
|
||||||
|
*/
|
||||||
|
name?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project's targets
|
||||||
|
*/
|
||||||
|
targets?: { [targetName: string]: TargetConfiguration };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project's location relative to the root of the workspace
|
||||||
|
*/
|
||||||
|
root: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The location of project's sources relative to the root of the workspace
|
||||||
|
*/
|
||||||
|
sourceRoot?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project type
|
||||||
|
*/
|
||||||
|
projectType?: ProjectType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of default values used by generators.
|
||||||
|
*
|
||||||
|
* These defaults are project specific.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* {
|
||||||
|
* "@nrwl/react": {
|
||||||
|
* "library": {
|
||||||
|
* "style": "scss"
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
generators?: { [collectionName: string]: { [generatorName: string]: any } };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of projects which are added as a dependency
|
||||||
|
*/
|
||||||
|
implicitDependencies?: string[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of tags used by nx-enforce-module-boundaries / project graph
|
||||||
|
*/
|
||||||
|
tags?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TargetDependencyConfig {
|
||||||
|
/**
|
||||||
|
* This the projects that the targets belong to
|
||||||
|
*
|
||||||
|
* 'self': This target depends on another target of the same project
|
||||||
|
* 'deps': This target depends on targets of the projects of it's deps.
|
||||||
|
*/
|
||||||
|
projects: 'self' | 'dependencies';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the target
|
||||||
|
*/
|
||||||
|
target: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Target's configuration
|
||||||
|
*/
|
||||||
|
export interface TargetConfiguration {
|
||||||
|
/**
|
||||||
|
* The executor/builder used to implement the target.
|
||||||
|
*
|
||||||
|
* Example: '@nrwl/web:rollup'
|
||||||
|
*/
|
||||||
|
executor: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of the target's outputs. The outputs will be cached by the Nx computation
|
||||||
|
* caching engine.
|
||||||
|
*/
|
||||||
|
outputs?: string[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This describes other targets that a target depends on.
|
||||||
|
*/
|
||||||
|
dependsOn?: TargetDependencyConfig[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Target's options. They are passed in to the executor.
|
||||||
|
*/
|
||||||
|
options?: any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets of options
|
||||||
|
*/
|
||||||
|
configurations?: { [config: string]: any };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A default named configuration to use when a target configuration is not provided.
|
||||||
|
*/
|
||||||
|
defaultConfiguration?: string;
|
||||||
|
}
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import { toProjectName, Workspaces } from './workspace';
|
import { toProjectName, Workspaces } from './workspaces';
|
||||||
import { NxJsonConfiguration } from './nx';
|
import { NxJsonConfiguration } from './nx-json';
|
||||||
import { vol } from 'memfs';
|
import { vol } from 'memfs';
|
||||||
|
|
||||||
import * as fastGlob from 'fast-glob';
|
import * as fastGlob from 'fast-glob';
|
||||||
@ -10,8 +10,17 @@ import { readJsonFile } from '../utils/fileutils';
|
|||||||
import { logger } from '../utils/logger';
|
import { logger } from '../utils/logger';
|
||||||
import { loadNxPlugins, readPluginPackageJson } from '../utils/nx-plugin';
|
import { loadNxPlugins, readPluginPackageJson } from '../utils/nx-plugin';
|
||||||
|
|
||||||
import type { NxJsonConfiguration } from './nx';
|
import type { NxJsonConfiguration } from './nx-json';
|
||||||
import { TaskGraph } from 'nx/src/shared/tasks';
|
import {
|
||||||
|
ProjectConfiguration,
|
||||||
|
WorkspaceJsonConfiguration,
|
||||||
|
} from './workspace-json-project-json';
|
||||||
|
import {
|
||||||
|
Executor,
|
||||||
|
ExecutorConfig,
|
||||||
|
TaskGraphExecutor,
|
||||||
|
Generator,
|
||||||
|
} from './misc-interfaces';
|
||||||
|
|
||||||
export function workspaceConfigName(root: string) {
|
export function workspaceConfigName(root: string) {
|
||||||
if (existsSync(path.join(root, 'angular.json'))) {
|
if (existsSync(path.join(root, 'angular.json'))) {
|
||||||
@ -23,246 +32,6 @@ export function workspaceConfigName(root: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Workspace
|
|
||||||
extends WorkspaceJsonConfiguration,
|
|
||||||
NxJsonConfiguration {
|
|
||||||
projects: Record<string, ProjectConfiguration>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Workspace configuration
|
|
||||||
*/
|
|
||||||
export interface WorkspaceJsonConfiguration {
|
|
||||||
/**
|
|
||||||
* Version of the configuration format
|
|
||||||
*/
|
|
||||||
version: number;
|
|
||||||
/**
|
|
||||||
* Projects' projects
|
|
||||||
*/
|
|
||||||
projects: {
|
|
||||||
[projectName: string]: ProjectConfiguration;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RawWorkspaceJsonConfiguration
|
|
||||||
extends Omit<WorkspaceJsonConfiguration, 'projects'> {
|
|
||||||
projects: { [projectName: string]: ProjectConfiguration | string };
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type of project supported
|
|
||||||
*/
|
|
||||||
export type ProjectType = 'library' | 'application';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Project configuration
|
|
||||||
*/
|
|
||||||
export interface ProjectConfiguration {
|
|
||||||
/**
|
|
||||||
* Project's name. Optional if specified in workspace.json
|
|
||||||
*/
|
|
||||||
name?: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Project's targets
|
|
||||||
*/
|
|
||||||
targets?: { [targetName: string]: TargetConfiguration };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Project's location relative to the root of the workspace
|
|
||||||
*/
|
|
||||||
root: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The location of project's sources relative to the root of the workspace
|
|
||||||
*/
|
|
||||||
sourceRoot?: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Project type
|
|
||||||
*/
|
|
||||||
projectType?: ProjectType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List of default values used by generators.
|
|
||||||
*
|
|
||||||
* These defaults are project specific.
|
|
||||||
*
|
|
||||||
* Example:
|
|
||||||
*
|
|
||||||
* ```
|
|
||||||
* {
|
|
||||||
* "@nrwl/react": {
|
|
||||||
* "library": {
|
|
||||||
* "style": "scss"
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
generators?: { [collectionName: string]: { [generatorName: string]: any } };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List of projects which are added as a dependency
|
|
||||||
*/
|
|
||||||
implicitDependencies?: string[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List of tags used by nx-enforce-module-boundaries / project graph
|
|
||||||
*/
|
|
||||||
tags?: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TargetDependencyConfig {
|
|
||||||
/**
|
|
||||||
* This the projects that the targets belong to
|
|
||||||
*
|
|
||||||
* 'self': This target depends on another target of the same project
|
|
||||||
* 'deps': This target depends on targets of the projects of it's deps.
|
|
||||||
*/
|
|
||||||
projects: 'self' | 'dependencies';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the target
|
|
||||||
*/
|
|
||||||
target: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Target's configuration
|
|
||||||
*/
|
|
||||||
export interface TargetConfiguration {
|
|
||||||
/**
|
|
||||||
* The executor/builder used to implement the target.
|
|
||||||
*
|
|
||||||
* Example: '@nrwl/web:rollup'
|
|
||||||
*/
|
|
||||||
executor: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List of the target's outputs. The outputs will be cached by the Nx computation
|
|
||||||
* caching engine.
|
|
||||||
*/
|
|
||||||
outputs?: string[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This describes other targets that a target depends on.
|
|
||||||
*/
|
|
||||||
dependsOn?: TargetDependencyConfig[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Target's options. They are passed in to the executor.
|
|
||||||
*/
|
|
||||||
options?: any;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets of options
|
|
||||||
*/
|
|
||||||
configurations?: { [config: string]: any };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A default named configuration to use when a target configuration is not provided.
|
|
||||||
*/
|
|
||||||
defaultConfiguration?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A callback function that is executed after changes are made to the file system
|
|
||||||
*/
|
|
||||||
export type GeneratorCallback = () => void | Promise<void>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A function that schedules updates to the filesystem to be done atomically
|
|
||||||
*/
|
|
||||||
export type Generator<T = unknown> = (
|
|
||||||
tree,
|
|
||||||
schema: T
|
|
||||||
) => void | GeneratorCallback | Promise<void | GeneratorCallback>;
|
|
||||||
|
|
||||||
export interface ExecutorConfig {
|
|
||||||
schema: any;
|
|
||||||
hasherFactory?: () => any;
|
|
||||||
implementationFactory: () => Executor;
|
|
||||||
batchImplementationFactory?: () => TaskGraphExecutor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of a target of a project
|
|
||||||
*/
|
|
||||||
export type Executor<T = any> = (
|
|
||||||
/**
|
|
||||||
* Options that users configure or pass via the command line
|
|
||||||
*/
|
|
||||||
options: T,
|
|
||||||
context: ExecutorContext
|
|
||||||
) =>
|
|
||||||
| Promise<{ success: boolean }>
|
|
||||||
| AsyncIterableIterator<{ success: boolean }>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of a target of a project that handles multiple projects to be batched
|
|
||||||
*/
|
|
||||||
export type TaskGraphExecutor<T = any> = (
|
|
||||||
/**
|
|
||||||
* Graph of Tasks to be executed
|
|
||||||
*/
|
|
||||||
taskGraph: TaskGraph,
|
|
||||||
/**
|
|
||||||
* Map of Task IDs to options for the task
|
|
||||||
*/
|
|
||||||
options: Record<string, T>,
|
|
||||||
/**
|
|
||||||
* Set of overrides for the overall execution
|
|
||||||
*/
|
|
||||||
overrides: T,
|
|
||||||
context: ExecutorContext
|
|
||||||
) => Promise<Record<string, { success: boolean; terminalOutput: string }>>;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Context that is passed into an executor
|
|
||||||
*/
|
|
||||||
export interface ExecutorContext {
|
|
||||||
/**
|
|
||||||
* The root of the workspace
|
|
||||||
*/
|
|
||||||
root: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the project being executed on
|
|
||||||
*/
|
|
||||||
projectName?: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the target being executed
|
|
||||||
*/
|
|
||||||
targetName?: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The name of the configuration being executed
|
|
||||||
*/
|
|
||||||
configurationName?: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The configuration of the target being executed
|
|
||||||
*/
|
|
||||||
target?: TargetConfiguration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The full workspace configuration
|
|
||||||
*/
|
|
||||||
workspace: WorkspaceJsonConfiguration & NxJsonConfiguration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The current working directory
|
|
||||||
*/
|
|
||||||
cwd: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable verbose logging
|
|
||||||
*/
|
|
||||||
isVerbose: boolean;
|
|
||||||
}
|
|
||||||
export class Workspaces {
|
export class Workspaces {
|
||||||
private cachedWorkspaceConfig: WorkspaceJsonConfiguration &
|
private cachedWorkspaceConfig: WorkspaceJsonConfiguration &
|
||||||
NxJsonConfiguration;
|
NxJsonConfiguration;
|
||||||
@ -444,7 +213,14 @@ export class Workspaces {
|
|||||||
return { executorsFilePath, executorConfig };
|
return { executorsFilePath, executorConfig };
|
||||||
}
|
}
|
||||||
|
|
||||||
private readGeneratorsJson(collectionName: string, generator: string) {
|
private readGeneratorsJson(
|
||||||
|
collectionName: string,
|
||||||
|
generator: string
|
||||||
|
): {
|
||||||
|
generatorsFilePath: string;
|
||||||
|
generatorsJson: any;
|
||||||
|
normalizedGeneratorName: string;
|
||||||
|
} {
|
||||||
let generatorsFilePath;
|
let generatorsFilePath;
|
||||||
if (collectionName.endsWith('.json')) {
|
if (collectionName.endsWith('.json')) {
|
||||||
generatorsFilePath = require.resolve(collectionName, {
|
generatorsFilePath = require.resolve(collectionName, {
|
||||||
@ -1,2 +0,0 @@
|
|||||||
export * from './affected-project-graph';
|
|
||||||
export * from './affected-project-graph-models';
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
import { NxJsonConfiguration } from 'nx/src/shared/nx';
|
|
||||||
|
|
||||||
export interface Environment {
|
|
||||||
nxJson: NxJsonConfiguration;
|
|
||||||
workspaceJson: any;
|
|
||||||
/**
|
|
||||||
* @deprecated the field will be removed after Nx 14 is released. It's left here
|
|
||||||
* not to break the type checker in case someone extends
|
|
||||||
* the tasks runner
|
|
||||||
*/
|
|
||||||
workspaceResults: any;
|
|
||||||
}
|
|
||||||
@ -1,11 +1,11 @@
|
|||||||
import { workspaceRoot } from 'nx/src/utils/app-root';
|
import { workspaceRoot } from '../../utils/app-root';
|
||||||
import { ChildProcess, spawn, spawnSync } from 'child_process';
|
import { ChildProcess, spawn, spawnSync } from 'child_process';
|
||||||
import { openSync, readFileSync } from 'fs';
|
import { openSync, readFileSync } from 'fs';
|
||||||
import { ensureDirSync, ensureFileSync } from 'fs-extra';
|
import { ensureDirSync, ensureFileSync } from 'fs-extra';
|
||||||
import { connect } from 'net';
|
import { connect } from 'net';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { performance } from 'perf_hooks';
|
import { performance } from 'perf_hooks';
|
||||||
import { output } from '../../../../utils/output';
|
import { output } from '../../utils/output';
|
||||||
import {
|
import {
|
||||||
safelyCleanUpExistingProcess,
|
safelyCleanUpExistingProcess,
|
||||||
writeDaemonJsonProcessCache,
|
writeDaemonJsonProcessCache,
|
||||||
@ -15,7 +15,7 @@ import {
|
|||||||
DAEMON_DIR_FOR_CURRENT_WORKSPACE,
|
DAEMON_DIR_FOR_CURRENT_WORKSPACE,
|
||||||
DAEMON_OUTPUT_LOG_FILE,
|
DAEMON_OUTPUT_LOG_FILE,
|
||||||
} from '../tmp-dir';
|
} from '../tmp-dir';
|
||||||
import { ProjectGraph } from 'nx/src/shared/project-graph';
|
import { ProjectGraph } from '../../config/project-graph';
|
||||||
|
|
||||||
export async function startInBackground(): Promise<ChildProcess['pid']> {
|
export async function startInBackground(): Promise<ChildProcess['pid']> {
|
||||||
await safelyCleanUpExistingProcess();
|
await safelyCleanUpExistingProcess();
|
||||||
@ -1,20 +1,20 @@
|
|||||||
import { performance } from 'perf_hooks';
|
import { performance } from 'perf_hooks';
|
||||||
import { readWorkspaceJson } from '../../../file-utils';
|
import { readWorkspaceJson } from '../../project-graph/file-utils';
|
||||||
import { defaultFileHasher } from '../../../hasher/file-hasher';
|
import { defaultFileHasher } from '../../hasher/file-hasher';
|
||||||
import { serverLogger } from './logger';
|
import { serverLogger } from './logger';
|
||||||
import { buildProjectGraphUsingProjectFileMap } from '../../build-project-graph';
|
import { buildProjectGraphUsingProjectFileMap } from '../../project-graph/build-project-graph';
|
||||||
import {
|
import {
|
||||||
nxDepsPath,
|
nxDepsPath,
|
||||||
ProjectGraphCache,
|
ProjectGraphCache,
|
||||||
readCache,
|
readCache,
|
||||||
} from '../../../nx-deps/nx-deps-cache';
|
} from '../../project-graph/nx-deps-cache';
|
||||||
import { fileExists } from '../../../../utils/fileutils';
|
import { fileExists } from '../../utils/fileutils';
|
||||||
import { HashingImpl } from '../../../hasher/hashing-impl';
|
import { HashingImpl } from '../../hasher/hashing-impl';
|
||||||
import {
|
import {
|
||||||
createProjectFileMap,
|
createProjectFileMap,
|
||||||
updateProjectFileMap,
|
updateProjectFileMap,
|
||||||
} from '../../../file-map-utils';
|
} from '../../project-graph/file-map-utils';
|
||||||
import { FileData, ProjectFileMap } from 'nx/src/shared/project-graph';
|
import { FileData, ProjectFileMap } from '../../config/project-graph';
|
||||||
|
|
||||||
let cachedSerializedProjectGraphPromise: Promise<{
|
let cachedSerializedProjectGraphPromise: Promise<{
|
||||||
error: Error | null;
|
error: Error | null;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { workspaceRoot } from 'nx/src/utils/app-root';
|
import { workspaceRoot } from '../../utils/app-root';
|
||||||
import { createServer, Server, Socket } from 'net';
|
import { createServer, Server, Socket } from 'net';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { performance, PerformanceObserver } from 'perf_hooks';
|
import { performance, PerformanceObserver } from 'perf_hooks';
|
||||||
@ -25,8 +25,8 @@ import {
|
|||||||
getCachedSerializedProjectGraphPromise,
|
getCachedSerializedProjectGraphPromise,
|
||||||
} from './project-graph-incremental-recomputation';
|
} from './project-graph-incremental-recomputation';
|
||||||
import { existsSync, statSync } from 'fs';
|
import { existsSync, statSync } from 'fs';
|
||||||
import { HashingImpl } from '../../../hasher/hashing-impl';
|
import { HashingImpl } from '../../hasher/hashing-impl';
|
||||||
import { defaultFileHasher } from 'nx/src/core/hasher/file-hasher';
|
import { defaultFileHasher } from '../../hasher/file-hasher';
|
||||||
|
|
||||||
function respondToClient(socket: Socket, message: string) {
|
function respondToClient(socket: Socket, message: string) {
|
||||||
return new Promise((res) => {
|
return new Promise((res) => {
|
||||||
@ -271,7 +271,7 @@ const handleWorkspaceChanges: SubscribeToWorkspaceChangesCallback = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export async function startServer(): Promise<Server> {
|
export async function startServer(): Promise<Server> {
|
||||||
// See notes in socket-utils.ts on OS differences regarding clean up of existings connections.
|
// See notes in socket-command-line-utils.ts on OS differences regarding clean up of existings connections.
|
||||||
if (!isWindows) {
|
if (!isWindows) {
|
||||||
killSocketOrPath();
|
killSocketOrPath();
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { workspaceRoot } from 'nx/src/utils/app-root';
|
import { workspaceRoot } from '../../utils/app-root';
|
||||||
import type { Server } from 'net';
|
import type { Server } from 'net';
|
||||||
import { serverLogger } from './logger';
|
import { serverLogger } from './logger';
|
||||||
import type { WatcherSubscription } from './watcher';
|
import type { WatcherSubscription } from './watcher';
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { output } from '../../../../utils/output';
|
import { output } from '../../utils/output';
|
||||||
import { startServer } from './server';
|
import { startServer } from './server';
|
||||||
import * as process from 'process';
|
import * as process from 'process';
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { output } from '../../../../utils/output';
|
import { output } from '../../utils/output';
|
||||||
import { safelyCleanUpExistingProcess } from '../cache';
|
import { safelyCleanUpExistingProcess } from '../cache';
|
||||||
import { stopServer } from './server';
|
import { stopServer } from './server';
|
||||||
|
|
||||||
@ -5,15 +5,15 @@
|
|||||||
*
|
*
|
||||||
* See https://github.com/parcel-bundler/watcher for more details.
|
* See https://github.com/parcel-bundler/watcher for more details.
|
||||||
*/
|
*/
|
||||||
import { workspaceRoot } from 'nx/src/utils/app-root';
|
import { workspaceRoot } from '../../utils/app-root';
|
||||||
import type { AsyncSubscription, Event } from '@parcel/watcher';
|
import type { AsyncSubscription, Event } from '@parcel/watcher';
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { join, relative } from 'path';
|
import { join, relative } from 'path';
|
||||||
import { FULL_OS_SOCKET_PATH } from '../socket-utils';
|
import { FULL_OS_SOCKET_PATH } from '../socket-utils';
|
||||||
import { handleServerProcessTermination } from 'nx/src/core/project-graph/daemon/server/shutdown-utils';
|
import { handleServerProcessTermination } from './shutdown-utils';
|
||||||
import { Server } from 'net';
|
import { Server } from 'net';
|
||||||
import ignore from 'ignore';
|
import ignore from 'ignore';
|
||||||
import { normalizePath } from 'nx/src/utils/path';
|
import { normalizePath } from '../../utils/path';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This configures the files and directories which we always want to ignore as part of file watching
|
* This configures the files and directories which we always want to ignore as part of file watching
|
||||||
@ -2,7 +2,7 @@ import { unlinkSync } from 'fs';
|
|||||||
import { platform } from 'os';
|
import { platform } from 'os';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
import { DAEMON_SOCKET_PATH } from './tmp-dir';
|
import { DAEMON_SOCKET_PATH } from './tmp-dir';
|
||||||
import { ProjectGraph } from 'nx/src/shared/project-graph';
|
import { ProjectGraph } from '../config/project-graph';
|
||||||
|
|
||||||
export const isWindows = platform() === 'win32';
|
export const isWindows = platform() === 'win32';
|
||||||
|
|
||||||
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
import { statSync, writeFileSync } from 'fs';
|
import { statSync, writeFileSync } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { cacheDir } from '../../../utils/cache-directory';
|
import { cacheDir } from '../utils/cache-directory';
|
||||||
|
|
||||||
export const DAEMON_DIR_FOR_CURRENT_WORKSPACE = join(cacheDir, 'd');
|
export const DAEMON_DIR_FOR_CURRENT_WORKSPACE = join(cacheDir, 'd');
|
||||||
|
|
||||||
@ -1,8 +1,8 @@
|
|||||||
import { workspaceRoot } from 'nx/src/utils/app-root';
|
import { workspaceRoot } from '../utils/app-root';
|
||||||
import { performance } from 'perf_hooks';
|
import { performance } from 'perf_hooks';
|
||||||
import { defaultHashing } from './hashing-impl';
|
import { defaultHashing } from './hashing-impl';
|
||||||
import { FileData } from 'nx/src/shared/project-graph';
|
import { FileData } from '../config/project-graph';
|
||||||
import { joinPathFragments, normalizePath } from 'nx/src/utils/path';
|
import { joinPathFragments, normalizePath } from '../utils/path';
|
||||||
|
|
||||||
export abstract class FileHasherBase {
|
export abstract class FileHasherBase {
|
||||||
protected fileHashes: Map<string, string>;
|
protected fileHashes: Map<string, string>;
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import { GitBasedFileHasher } from './git-based-file-hasher';
|
import { GitBasedFileHasher } from './git-based-file-hasher';
|
||||||
import { workspaceRoot } from 'nx/src/utils/app-root';
|
import { workspaceRoot } from '../utils/app-root';
|
||||||
import { NodeBasedFileHasher } from './node-based-file-hasher';
|
import { NodeBasedFileHasher } from './node-based-file-hasher';
|
||||||
import { FileHasherBase } from './file-hasher-base';
|
import { FileHasherBase } from './file-hasher-base';
|
||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { workspaceRoot } from 'nx/src/utils/app-root';
|
import { workspaceRoot } from '../utils/app-root';
|
||||||
import { performance } from 'perf_hooks';
|
import { performance } from 'perf_hooks';
|
||||||
import { getFileHashes, getGitHashForFiles } from './git-hasher';
|
import { getFileHashes, getGitHashForFiles } from './git-hasher';
|
||||||
import { existsSync, readFileSync } from 'fs';
|
import { existsSync, readFileSync } from 'fs';
|
||||||
@ -1,6 +1,6 @@
|
|||||||
import { spawn } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
import { fileExists } from '../../utils/fileutils';
|
import { fileExists } from '../utils/fileutils';
|
||||||
import { joinPathFragments } from '../../utils/path';
|
import { joinPathFragments } from '../utils/path';
|
||||||
|
|
||||||
export async function getGitHashForFiles(
|
export async function getGitHashForFiles(
|
||||||
potentialFilesToHash: string[],
|
potentialFilesToHash: string[],
|
||||||
@ -1,18 +1,18 @@
|
|||||||
// This must come before the Hasher import
|
// This must come before the Hasher import
|
||||||
import { DependencyType } from 'nx/src/shared/project-graph';
|
import { DependencyType } from '../config/project-graph';
|
||||||
|
|
||||||
jest.doMock('../../utils/app-root', () => {
|
jest.doMock('../utils/app-root', () => {
|
||||||
return {
|
return {
|
||||||
workspaceRoot: '',
|
workspaceRoot: '',
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
import fs = require('fs');
|
import fs = require('fs');
|
||||||
import tsUtils = require('../../utils/typescript');
|
import tsUtils = require('../utils/typescript');
|
||||||
import { Hasher } from './hasher';
|
import { Hasher } from './hasher';
|
||||||
|
|
||||||
jest.mock('fs');
|
jest.mock('fs');
|
||||||
jest.mock('../../utils/typescript');
|
jest.mock('../utils/typescript');
|
||||||
|
|
||||||
fs.existsSync = () => true;
|
fs.existsSync = () => true;
|
||||||
|
|
||||||
@ -1,20 +1,18 @@
|
|||||||
import {
|
import { resolveNewFormatWithInlineProjects } from '../config/workspaces';
|
||||||
resolveNewFormatWithInlineProjects,
|
|
||||||
WorkspaceJsonConfiguration,
|
|
||||||
} from 'nx/src/shared/workspace';
|
|
||||||
import { exec } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
import { existsSync } from 'fs';
|
import { existsSync } from 'fs';
|
||||||
import * as minimatch from 'minimatch';
|
import * as minimatch from 'minimatch';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { performance } from 'perf_hooks';
|
import { performance } from 'perf_hooks';
|
||||||
import { getRootTsConfigFileName } from '../../utils/typescript';
|
import { getRootTsConfigFileName } from '../utils/typescript';
|
||||||
import { workspaceRoot } from '../../utils/app-root';
|
import { workspaceRoot } from '../utils/app-root';
|
||||||
import { workspaceFileName } from '../file-utils';
|
import { workspaceFileName } from '../project-graph/file-utils';
|
||||||
import { defaultHashing, HashingImpl } from './hashing-impl';
|
import { defaultHashing, HashingImpl } from './hashing-impl';
|
||||||
import { ProjectGraph } from 'nx/src/shared/project-graph';
|
import { ProjectGraph } from '../config/project-graph';
|
||||||
import { NxJsonConfiguration } from 'nx/src/shared/nx';
|
import { NxJsonConfiguration } from '../config/nx-json';
|
||||||
import { Task } from 'nx/src/shared/tasks';
|
import { Task } from '../config/task-graph';
|
||||||
import { readJsonFile } from 'nx/src/utils/fileutils';
|
import { readJsonFile } from '../utils/fileutils';
|
||||||
|
import { WorkspaceJsonConfiguration } from '../config/workspace-json-project-json';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A data structure returned by the default hasher.
|
* A data structure returned by the default hasher.
|
||||||
@ -1,12 +1,12 @@
|
|||||||
import { workspaceRoot } from 'nx/src/utils/app-root';
|
import { workspaceRoot } from '../utils/app-root';
|
||||||
import { performance } from 'perf_hooks';
|
import { performance } from 'perf_hooks';
|
||||||
import { FileData } from 'nx/src/shared/project-graph';
|
import { FileData } from '../config/project-graph';
|
||||||
import { join, relative } from 'path';
|
import { join, relative } from 'path';
|
||||||
import { existsSync, readdirSync, readFileSync, statSync } from 'fs';
|
import { existsSync, readdirSync, readFileSync, statSync } from 'fs';
|
||||||
import { FileHasherBase } from './file-hasher-base';
|
import { FileHasherBase } from './file-hasher-base';
|
||||||
import { stripIndents } from '../../utils/strip-indents';
|
import { stripIndents } from '../utils/strip-indents';
|
||||||
import ignore from 'ignore';
|
import ignore from 'ignore';
|
||||||
import { normalizePath } from 'nx/src/utils/path';
|
import { normalizePath } from '../utils/path';
|
||||||
|
|
||||||
export class NodeBasedFileHasher extends FileHasherBase {
|
export class NodeBasedFileHasher extends FileHasherBase {
|
||||||
ignoredGlobs = getIgnoredGlobs();
|
ignoredGlobs = getIgnoredGlobs();
|
||||||
@ -1,6 +1,6 @@
|
|||||||
import type { Change, FileChange } from '../file-utils';
|
import type { Change, FileChange } from '../file-utils';
|
||||||
import { NxJsonConfiguration } from 'nx/src/shared/nx';
|
import { NxJsonConfiguration } from '../../config/nx-json';
|
||||||
import { ProjectGraph } from 'nx/src/shared/project-graph';
|
import { ProjectGraph } from '../../config/project-graph';
|
||||||
|
|
||||||
export interface AffectedProjectGraphContext {
|
export interface AffectedProjectGraphContext {
|
||||||
workspaceJson: any;
|
workspaceJson: any;
|
||||||
@ -2,10 +2,10 @@ import { jsonDiff } from '../../utils/json-diff';
|
|||||||
import { vol } from 'memfs';
|
import { vol } from 'memfs';
|
||||||
import { filterAffected } from './affected-project-graph';
|
import { filterAffected } from './affected-project-graph';
|
||||||
import { WholeFileChange } from '../file-utils';
|
import { WholeFileChange } from '../file-utils';
|
||||||
import { buildProjectGraph } from '../project-graph/build-project-graph';
|
import { buildProjectGraph } from '../build-project-graph';
|
||||||
import { defaultFileHasher } from '../hasher/file-hasher';
|
import { defaultFileHasher } from '../../hasher/file-hasher';
|
||||||
import { WorkspaceJsonConfiguration } from 'nx/src/shared/workspace';
|
import { WorkspaceJsonConfiguration } from '../../config/workspace-json-project-json';
|
||||||
import { NxJsonConfiguration } from 'nx/src/shared/nx';
|
import { NxJsonConfiguration } from '../../config/nx-json';
|
||||||
import { stripIndents } from '../../utils/strip-indents';
|
import { stripIndents } from '../../utils/strip-indents';
|
||||||
|
|
||||||
jest.mock('fs', () => require('memfs').fs);
|
jest.mock('fs', () => require('memfs').fs);
|
||||||
@ -17,10 +17,10 @@ import {
|
|||||||
import { normalizeNxJson } from '../normalize-nx-json';
|
import { normalizeNxJson } from '../normalize-nx-json';
|
||||||
import { getTouchedProjectsInWorkspaceJson } from './locators/workspace-json-changes';
|
import { getTouchedProjectsInWorkspaceJson } from './locators/workspace-json-changes';
|
||||||
import { getTouchedProjectsFromTsConfig } from './locators/tsconfig-json-changes';
|
import { getTouchedProjectsFromTsConfig } from './locators/tsconfig-json-changes';
|
||||||
import { WorkspaceJsonConfiguration } from 'nx/src/shared/workspace';
|
import { NxJsonConfiguration } from '../../config/nx-json';
|
||||||
import { NxJsonConfiguration } from 'nx/src/shared/nx';
|
import { ProjectGraph } from '../../config/project-graph';
|
||||||
import { ProjectGraph } from 'nx/src/shared/project-graph';
|
import { reverse } from '../operators';
|
||||||
import { reverse } from '../project-graph/operators';
|
import { WorkspaceJsonConfiguration } from '../../config/workspace-json-project-json';
|
||||||
|
|
||||||
export function filterAffected(
|
export function filterAffected(
|
||||||
graph: ProjectGraph,
|
graph: ProjectGraph,
|
||||||
@ -1,7 +1,7 @@
|
|||||||
import { getImplicitlyTouchedProjectsByJsonChanges } from './implicit-json-changes';
|
import { getImplicitlyTouchedProjectsByJsonChanges } from './implicit-json-changes';
|
||||||
import { WholeFileChange } from '../../file-utils';
|
import { WholeFileChange } from '../../file-utils';
|
||||||
import { DiffType } from '../../../utils/json-diff';
|
import { DiffType } from '../../../utils/json-diff';
|
||||||
import { NxJsonConfiguration } from 'nx/src/shared/nx';
|
import { NxJsonConfiguration } from '../../../config/nx-json';
|
||||||
|
|
||||||
function getModifiedChange(path: string[]) {
|
function getModifiedChange(path: string[]) {
|
||||||
return {
|
return {
|
||||||
@ -7,7 +7,7 @@ import {
|
|||||||
walkJsonTree,
|
walkJsonTree,
|
||||||
} from '../../../utils/json-diff';
|
} from '../../../utils/json-diff';
|
||||||
import { TouchedProjectLocator } from '../affected-project-graph-models';
|
import { TouchedProjectLocator } from '../affected-project-graph-models';
|
||||||
import { ImplicitDependencyEntry } from 'nx/src/shared/nx';
|
import { ImplicitDependencyEntry } from '../../../config/nx-json';
|
||||||
|
|
||||||
export const getImplicitlyTouchedProjectsByJsonChanges: TouchedProjectLocator<
|
export const getImplicitlyTouchedProjectsByJsonChanges: TouchedProjectLocator<
|
||||||
WholeFileChange | JsonChange
|
WholeFileChange | JsonChange
|
||||||
@ -1,8 +1,8 @@
|
|||||||
import { getTouchedNpmPackages } from './npm-packages';
|
import { getTouchedNpmPackages } from './npm-packages';
|
||||||
import { WholeFileChange } from '../../file-utils';
|
import { WholeFileChange } from '../../file-utils';
|
||||||
import { DiffType } from '../../../utils/json-diff';
|
import { DiffType } from '../../../utils/json-diff';
|
||||||
import { NxJsonConfiguration } from 'nx/src/shared/nx';
|
import { NxJsonConfiguration } from '../../../config/nx-json';
|
||||||
import { ProjectGraph } from 'nx/src/shared/project-graph';
|
import { ProjectGraph } from '../../../config/project-graph';
|
||||||
|
|
||||||
describe('getTouchedNpmPackages', () => {
|
describe('getTouchedNpmPackages', () => {
|
||||||
let workspaceJson;
|
let workspaceJson;
|
||||||
@ -2,7 +2,7 @@ import { WholeFileChange } from '../../file-utils';
|
|||||||
import { jsonDiff } from '../../../utils/json-diff';
|
import { jsonDiff } from '../../../utils/json-diff';
|
||||||
import { getTouchedProjectsFromTsConfig } from './tsconfig-json-changes';
|
import { getTouchedProjectsFromTsConfig } from './tsconfig-json-changes';
|
||||||
import * as tsUtils from '../../../utils/typescript';
|
import * as tsUtils from '../../../utils/typescript';
|
||||||
import { DependencyType, ProjectGraph } from 'nx/src/shared/project-graph';
|
import { DependencyType, ProjectGraph } from '../../../config/project-graph';
|
||||||
|
|
||||||
describe('getTouchedProjectsFromTsConfig', () => {
|
describe('getTouchedProjectsFromTsConfig', () => {
|
||||||
let graph: ProjectGraph;
|
let graph: ProjectGraph;
|
||||||
@ -2,7 +2,7 @@ import { WholeFileChange } from '../../file-utils';
|
|||||||
import { DiffType, isJsonChange, JsonChange } from '../../../utils/json-diff';
|
import { DiffType, isJsonChange, JsonChange } from '../../../utils/json-diff';
|
||||||
import { getRootTsConfigFileName } from '../../../utils/typescript';
|
import { getRootTsConfigFileName } from '../../../utils/typescript';
|
||||||
import { TouchedProjectLocator } from '../affected-project-graph-models';
|
import { TouchedProjectLocator } from '../affected-project-graph-models';
|
||||||
import { ProjectGraphProjectNode } from 'nx/src/shared/project-graph';
|
import { ProjectGraphProjectNode } from '../../../config/project-graph';
|
||||||
|
|
||||||
export const getTouchedProjectsFromTsConfig: TouchedProjectLocator<
|
export const getTouchedProjectsFromTsConfig: TouchedProjectLocator<
|
||||||
WholeFileChange | JsonChange
|
WholeFileChange | JsonChange
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user