cleanup(core): create more meaningful file structure in nx package (#9621)

This commit is contained in:
Victor Savkin 2022-03-31 09:07:22 -04:00 committed by GitHub
parent 5b34fa4c74
commit 428106f6be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
190 changed files with 719 additions and 769 deletions

View File

@ -192,7 +192,7 @@ Please follow the following guidelines:
- 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 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/)
- 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`)

View File

@ -7,7 +7,7 @@ import {
getPackageManagerCommand,
getSelectedPackageManager,
} from '@nrwl/e2e/utils';
import { Workspaces } from 'nx/src/shared/workspace';
import { Workspaces } from 'nx/src/config/workspaces';
describe('add-nx-to-monorepo', () => {
const packageManagerCommand = getPackageManagerCommand({

View File

@ -28,7 +28,7 @@ import { promisify } from 'util';
import chalk = require('chalk');
import isCI = require('is-ci');
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';
export function detectPackageManager(dir: string = ''): PackageManager {

View File

@ -42,7 +42,7 @@ describe('workspace-generator', () => {
const workspace = uniq('workspace');
updateFile(
'tools/utils/utils.ts',
'tools/utils/command-line-utils.ts',
`
export const noop = () => {}
`

View File

@ -9,7 +9,7 @@ import {
} from '@nrwl/devkit';
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
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 { UnitTestRunner } from '../../utils/test-runners';
import {

View File

@ -1,11 +1,10 @@
jest.mock('fs');
jest.mock('@nrwl/devkit');
jest.mock('@nrwl/workspace/src/utilities/typescript');
jest.mock('nx/src/core/file-utils');
jest.mock('nx/src/shared/workspace');
jest.mock('nx/src/project-graph/file-utils');
import * as graph from '@nrwl/devkit';
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 { withModuleFederation } from './with-module-federation';

View File

@ -15,7 +15,7 @@ import {
readTsConfig,
} from '@nrwl/workspace/src/utilities/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');
export type MFERemotes = string[] | [remoteName: string, remoteUrl: string][];

View File

@ -12,7 +12,7 @@
/**
* @category Tree
*/
export type { Tree, FileChange } from 'nx/src/shared/tree';
export type { Tree, FileChange } from 'nx/src/config/tree';
/**
* @category Workspace
@ -23,18 +23,24 @@ export type {
TargetConfiguration,
ProjectConfiguration,
ProjectType,
Workspace,
} from 'nx/src/config/workspace-json-project-json';
/**
* @category Workspace
*/
export type {
Generator,
GeneratorCallback,
Executor,
ExecutorContext,
TaskGraphExecutor,
Workspace,
} from 'nx/src/shared/workspace';
} from 'nx/src/config/misc-interfaces';
/**
* @category Workspace
*/
export { Workspaces } from 'nx/src/shared/workspace';
export { Workspaces } from 'nx/src/config/workspaces';
export type {
NxPlugin,
@ -44,7 +50,7 @@ export type {
/**
* @category Workspace
*/
export type { Task, TaskGraph } from 'nx/src/shared/tasks';
export type { Task, TaskGraph } from 'nx/src/config/task-graph';
/**
* @category Workspace
@ -55,7 +61,7 @@ export type {
NxJsonConfiguration,
NxJsonProjectConfiguration,
NxAffectedConfig,
} from 'nx/src/shared/nx';
} from 'nx/src/config/nx-json';
/**
* @category Logger
@ -160,17 +166,17 @@ export type {
ProjectGraphProjectNode,
ProjectGraphExternalNode,
ProjectGraphProcessorContext,
} from 'nx/src/shared/project-graph';
} from 'nx/src/config/project-graph';
/**
* @category Project Graph
*/
export { DependencyType } from 'nx/src/shared/project-graph';
export { DependencyType } from 'nx/src/config/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
@ -270,19 +276,19 @@ export { workspaceRoot, appRootPath } from 'nx/src/utils/app-root';
/**
* @category Utils
*/
export { reverse } from 'nx/src/core/project-graph/operators';
export { reverse } from 'nx/src/project-graph/operators';
/**
* @category Utils
*/
export {
createProjectGraphAsync,
readCachedProjectGraph,
} from 'nx/src/core/project-graph/project-graph';
} from 'nx/src/project-graph/project-graph';
/**
* @category Utils
*/
export { readNxJson, workspaceLayout } from 'nx/src/core/file-utils';
export { readNxJson, workspaceLayout } from 'nx/src/project-graph/file-utils';
/**
* @category Utils
@ -301,7 +307,7 @@ export {
/**
* @category Utils
*/
export { Hash, Hasher } from 'nx/src/core/hasher/hasher';
export { Hash, Hasher } from 'nx/src/hasher/hasher';
/**
* @category Utils

View File

@ -1,6 +1,6 @@
import type { Target } from 'nx/src/command-line/run';
import type { ExecutorContext } from 'nx/src/shared/workspace';
import { Workspaces } from 'nx/src/shared/workspace';
import type { ExecutorContext } from 'nx/src/config/misc-interfaces';
import { Workspaces } from 'nx/src/config/workspaces';
import { combineOptionsForExecutor } from 'nx/src/utils/params';
/**

View File

@ -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 type * as Prettier from 'prettier';
import { getWorkspacePath } from '../utils/get-workspace-layout';

View File

@ -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 { generateFiles } from './generate-files';
import { join } from 'path';

View File

@ -1,6 +1,6 @@
import { readFileSync, readdirSync, statSync } from 'fs';
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';
const binaryExts = new Set([

View File

@ -1,5 +1,5 @@
import { Tree } from 'nx/src/shared/tree';
import { ProjectConfiguration } from 'nx/src/shared/workspace';
import { Tree } from 'nx/src/config/tree';
import { ProjectConfiguration } from 'nx/src/config/workspace-json-project-json';
import { createTreeWithEmptyWorkspace } from '../tests/create-tree-with-empty-workspace';
import { readJson, updateJson } from '../utils/json';

View File

@ -2,12 +2,9 @@ import {
buildWorkspaceConfigurationFromGlobs,
deduplicateProjectFiles,
globForProjectFiles,
ProjectConfiguration,
RawWorkspaceJsonConfiguration,
reformattedWorkspaceJsonOrNull,
toNewFormat,
WorkspaceJsonConfiguration,
} from 'nx/src/shared/workspace';
} from 'nx/src/config/workspaces';
import { basename, dirname, relative } from 'path';
import {
@ -16,9 +13,14 @@ import {
} from '../utils/get-workspace-layout';
import { readJson, updateJson, writeJson } from '../utils/json';
import type { Tree } from 'nx/src/shared/tree';
import type { NxJsonConfiguration } from 'nx/src/shared/nx';
import type { Tree } from 'nx/src/config/tree';
import type { NxJsonConfiguration } from 'nx/src/config/nx-json';
import { joinPathFragments } from 'nx/src/utils/path';
import {
ProjectConfiguration,
RawWorkspaceJsonConfiguration,
WorkspaceJsonConfiguration,
} from 'nx/src/config/workspace-json-project-json';
export type WorkspaceConfiguration = Omit<
WorkspaceJsonConfiguration,

View File

@ -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

View File

@ -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';
export function updateTsConfigsToJs(

View File

@ -1,5 +1,5 @@
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';
describe('visitNotIgnoredFiles', () => {

View File

@ -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 { join, relative, sep } from 'path';

View File

@ -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 { join } from 'path';
import {

View File

@ -1,5 +1,5 @@
import { FsTree } from 'nx/src/shared/tree';
import type { Tree } from 'nx/src/shared/tree';
import { FsTree } from 'nx/src/config/tree';
import type { Tree } from 'nx/src/config/tree';
/**
* Creates a host for testing.

View File

@ -1,5 +1,5 @@
import { FsTree } from 'nx/src/shared/tree';
import type { Tree } from 'nx/src/shared/tree';
import { FsTree } from 'nx/src/config/tree';
import type { Tree } from 'nx/src/config/tree';
/**
* Creates a host for testing.

View File

@ -1,6 +1,6 @@
import type { Observable } from 'rxjs';
import type { Executor, ExecutorContext } from 'nx/src/shared/workspace';
import { Workspaces } from 'nx/src/shared/workspace';
import { Workspaces } from 'nx/src/config/workspaces';
import { Executor, ExecutorContext } from 'nx/src/config/misc-interfaces';
/**
* Convert an Nx Executor into an Angular Devkit Builder

View File

@ -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 { 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,

View File

@ -1,11 +1,7 @@
import { logger, stripIndent } from 'nx/src/utils/logger';
import type { FileChange, Tree, TreeWriteOptions } from 'nx/src/shared/tree';
import {
Generator,
GeneratorCallback,
toNewFormat,
toOldFormatOrNull,
} from 'nx/src/shared/workspace';
import type { FileChange, Tree, TreeWriteOptions } from 'nx/src/config/tree';
import { toNewFormat, toOldFormatOrNull } from 'nx/src/config/workspaces';
import { Generator, GeneratorCallback } from 'nx/src/config/misc-interfaces';
import { parseJson, serializeJson } from 'nx/src/utils/json';
import { join, relative } from 'path';

View File

@ -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 type { JsonParseOptions, JsonSerializeOptions } from 'nx/src/utils/json';

View File

@ -1,4 +1,4 @@
import { Tree } from 'nx/src/shared/tree';
import { Tree } from 'nx/src/config/tree';
import { relative } from 'path';
import { visitNotIgnoredFiles } from '../generators/visit-not-ignored-files';
import { normalizePath } from 'nx/src/utils/path';

View File

@ -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 { addDependenciesToPackageJson } from './package-json';
import { createTree } from '../tests/create-tree';

View File

@ -1,7 +1,7 @@
import { readJson, updateJson } from './json';
import { installPackagesTask } from '../tasks/install-packages-task';
import type { Tree } from 'nx/src/shared/tree';
import type { GeneratorCallback } from 'nx/src/shared/workspace';
import type { Tree } from 'nx/src/config/tree';
import { GeneratorCallback } from 'nx/src/config/misc-interfaces';
/**
* Add Dependencies and Dev Dependencies to package.json

View File

@ -6,7 +6,7 @@ import { vol } from 'memfs';
import enforceModuleBoundaries, {
RULE_NAME as enforceModuleBoundariesRuleName,
} 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';
jest.mock('fs', () => require('memfs').fs);

View File

@ -34,7 +34,7 @@ import {
TSESTree,
} from '@typescript-eslint/experimental-utils';
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 {
checkCircularPath,
findFilesInCircularPath,

View File

@ -1,5 +1,5 @@
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';
describe('getJestProjects', () => {

View File

@ -1,6 +1,6 @@
import { dirname, join } from 'path';
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';

View File

@ -1,4 +1,4 @@
import { createProjectGraphAsync } from '../src/core/project-graph/project-graph';
import { createProjectGraphAsync } from '../src/project-graph/project-graph';
(async () => {
try {

View File

@ -6,7 +6,7 @@ import {
import * as chalk from 'chalk';
import { initLocal } from './init-local';
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
if (process.argv[2] === 'new' || process.argv[2] === '_migrate') {

View File

@ -3,7 +3,7 @@ import {
resolveOldFormatWithInlineProjects,
workspaceConfigName,
Workspaces,
} from '../shared/workspace';
} from '../config/workspaces';
import { workspaceRoot } from '../utils/app-root';
/* eslint-disable */

View File

@ -15,18 +15,15 @@ import { createConsoleLogger, NodeJsSyncHost } from '@angular-devkit/core/node';
import { Stats } from 'fs';
import { detectPackageManager } from '../utils/package-manager';
import { GenerateOptions } from '../command-line/generate';
import { FileChange, Tree } from '../shared/tree';
import { FileChange, Tree } from '../config/tree';
import {
buildWorkspaceConfigurationFromGlobs,
globForProjectFiles,
ProjectConfiguration,
RawWorkspaceJsonConfiguration,
toNewFormat,
toNewFormatOrNull,
toOldFormatOrNull,
workspaceConfigName,
WorkspaceJsonConfiguration,
} from '../shared/workspace';
} from '../config/workspaces';
import { dirname, extname, resolve, join, basename } from 'path';
import { FileBuffer } from '@angular-devkit/core/src/virtual-fs/host/interface';
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 { readJsonFile } from '../utils/fileutils';
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(
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(
root: string,
opts: GenerateOptions,

View File

@ -1,18 +1,22 @@
import * as yargs from 'yargs';
import { filterAffected } from '../core/affected-project-graph';
import { calculateFileChanges, readEnvironment } from '../core/file-utils';
import { calculateFileChanges } from '../project-graph/file-utils';
import { runCommand } from '../tasks-runner/run-command';
import { output } from '../utils/output';
import { generateGraph } from './dep-graph';
import { printAffected } from './print-affected';
import { connectToNxCloudUsingScan } from './connect-to-nx-cloud';
import type { NxArgs, RawNxArgs } from './utils';
import { parseFiles, splitArgsIntoNxArgsAndOverrides } from './utils';
import type { NxArgs, RawNxArgs } from '../utils/command-line-utils';
import {
parseFiles,
splitArgsIntoNxArgsAndOverrides,
} from '../utils/command-line-utils';
import { performance } from 'perf_hooks';
import { createProjectGraphAsync } from 'nx/src/core/project-graph/project-graph';
import { withDeps } from 'nx/src/core/project-graph/operators';
import { ProjectGraph, ProjectGraphProjectNode } from '../shared/project-graph';
import { createProjectGraphAsync } from '../project-graph/project-graph';
import { withDeps } from '../project-graph/operators';
import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
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(
command: 'apps' | 'libs' | 'graph' | 'print-affected' | 'affected',

View File

@ -1,4 +1,4 @@
import { readNxJson } from '../core/file-utils';
import { readNxJson } from '../project-graph/file-utils';
import { output } from '../utils/output';
import { getPackageManagerCommand } from '../utils/package-manager';
import { execSync } from 'child_process';

View File

@ -1,10 +1,10 @@
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';
export async function daemonHandler(args: Arguments) {
const { startInBackground, startInCurrentProcess } = await import(
'../core/project-graph/daemon/client/client'
'../daemon/client/client'
);
if (!args.background) {
return startInCurrentProcess();

View File

@ -9,18 +9,18 @@ import * as open from 'open';
import { basename, dirname, extname, isAbsolute, join, parse } from 'path';
import { performance } from 'perf_hooks';
import { URL, URLSearchParams } from 'url';
import { workspaceLayout } from '../core/file-utils';
import { defaultFileHasher } from '../core/hasher/file-hasher';
import { workspaceLayout } from '../project-graph/file-utils';
import { defaultFileHasher } from '../hasher/file-hasher';
import { output } from '../utils/output';
import { writeJsonFile } from 'nx/src/utils/fileutils';
import { joinPathFragments } from 'nx/src/utils/path';
import { writeJsonFile } from '../utils/fileutils';
import { joinPathFragments } from '../utils/path';
import {
ProjectGraph,
ProjectGraphDependency,
ProjectGraphProjectNode,
} from 'nx/src/shared/project-graph';
import { pruneExternalNodes } from 'nx/src/core/project-graph/operators';
import { createProjectGraphAsync } from 'nx/src/core/project-graph/project-graph';
} from '../config/project-graph';
import { pruneExternalNodes } from '../project-graph/operators';
import { createProjectGraphAsync } from '../project-graph/project-graph';
export interface DepGraphClientResponse {
hash: string;

View File

@ -5,27 +5,29 @@ import {
NxArgs,
parseFiles,
splitArgsIntoNxArgsAndOverrides,
} from './utils';
} from '../utils/command-line-utils';
import { fileExists } from '../utils/fileutils';
import { filterAffected } from '../core/affected-project-graph';
import { calculateFileChanges, FileData } from '../core/file-utils';
import { calculateFileChanges, FileData } from '../project-graph/file-utils';
import * as yargs from 'yargs';
import {
ProjectConfiguration,
reformattedWorkspaceJsonOrNull,
workspaceConfigName,
WorkspaceJsonConfiguration,
} from 'nx/src/shared/workspace';
import { workspaceRoot } from 'nx/src/utils/app-root';
} from '../config/workspaces';
import { workspaceRoot } from '../utils/app-root';
import * as prettier from 'prettier';
import { sortObjectByKeys } from 'nx/src/utils/object-sort';
import { sortObjectByKeys } from '../utils/object-sort';
import {
getRootTsConfigFileName,
getRootTsConfigPath,
} from '../utils/typescript';
import { readJsonFile, writeJsonFile } from 'nx/src/utils/fileutils';
import { NxJsonConfiguration } from 'nx/src/shared/nx';
import { createProjectGraphAsync } from '../core/project-graph/project-graph';
import { readJsonFile, writeJsonFile } from '../utils/fileutils';
import { NxJsonConfiguration } from '../config/nx-json';
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');

View File

@ -4,13 +4,13 @@ import {
Options,
Schema,
} from '../utils/params';
import { Workspaces } from '../shared/workspace';
import { FileChange, flushChanges, FsTree } from '../shared/tree';
import { Workspaces } from '../config/workspaces';
import { FileChange, flushChanges, FsTree } from '../config/tree';
import { logger } from '../utils/logger';
import * as chalk from 'chalk';
import { workspaceRoot } from 'nx/src/utils/app-root';
import { NxJsonConfiguration } from 'nx/src/shared/nx';
import { printHelp } from 'nx/src/utils/print-help';
import { workspaceRoot } from '../utils/app-root';
import { NxJsonConfiguration } from '../config/nx-json';
import { printHelp } from '../utils/print-help';
export interface GenerateOptions {
collectionName: string;

View File

@ -1,9 +1,9 @@
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 * as path from 'path';
import { createProjectGraphAsync } from '../core/project-graph/project-graph';
import { pruneExternalNodes } from '../core/project-graph/operators';
import { createProjectGraphAsync } from '../project-graph/project-graph';
import { pruneExternalNodes } from '../project-graph/operators';
export async function workspaceLint(): Promise<void> {
const graph = await createProjectGraphAsync();

View File

@ -1,4 +1,4 @@
import { workspaceRoot } from 'nx/src/utils/app-root';
import { workspaceRoot } from '../utils/app-root';
import { output } from '../utils/output';
import {
fetchCommunityPlugins,

View File

@ -3,8 +3,8 @@ import { copyFileSync, removeSync } from 'fs-extra';
import { dirname, join } from 'path';
import { gt, lte } from 'semver';
import { dirSync } from 'tmp';
import { NxJsonConfiguration } from '../shared/nx';
import { flushChanges, FsTree } from '../shared/tree';
import { NxJsonConfiguration } from '../config/nx-json';
import { flushChanges, FsTree } from '../config/tree';
import {
extractFileFromTarball,
JsonReadOptions,

View File

@ -2,12 +2,12 @@ import * as chalk from 'chalk';
import { execSync } from 'child_process';
import * as path from 'path';
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 { examples } from './examples';
import { workspaceRoot } from 'nx/src/utils/app-root';
import { workspaceRoot } from '../utils/app-root';
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 daemonHelpOutput = generateDaemonHelpOutput(isGenerateDocsProcess);

View File

@ -1,13 +1,10 @@
import type { Environment } from '../core/shared-interfaces';
import { createTask } from '../tasks-runner/run-command';
import { getCommandAsString, getOutputs } from '../tasks-runner/utils';
import * as yargs from 'yargs';
import type { NxArgs } from './utils';
import {
ProjectGraph,
ProjectGraphProjectNode,
} from 'nx/src/shared/project-graph';
import { Task } from 'nx/src/shared/tasks';
import type { NxArgs } from '../utils/command-line-utils';
import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
import { Task } from '../config/task-graph';
import { Environment } from './read-environment';
export async function printAffected(
affectedProjectsWithTargetAndConfig: ProjectGraphProjectNode[],

View 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;
}

View File

@ -1,12 +1,12 @@
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 { join } from 'path';
import {
detectPackageManager,
getPackageManagerVersion,
} from 'nx/src/utils/package-manager';
import { readJsonFile } from 'nx/src/utils/fileutils';
} from '../utils/package-manager';
import { readJsonFile } from '../utils/fileutils';
export const packagesWeCareAbout = [
'nx',

View File

@ -1,5 +1,5 @@
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 { output } from '../utils/output';

View File

@ -1,14 +1,14 @@
import * as yargs from 'yargs';
import { runCommand } from '../tasks-runner/run-command';
import type { NxArgs, RawNxArgs } from './utils';
import { splitArgsIntoNxArgsAndOverrides } from './utils';
import { readEnvironment } from '../core/file-utils';
import type { NxArgs, RawNxArgs } from '../utils/command-line-utils';
import { splitArgsIntoNxArgsAndOverrides } from '../utils/command-line-utils';
import { projectHasTarget } from '../utils/project-graph-utils';
import { output } from '../utils/output';
import { connectToNxCloudUsingScan } from './connect-to-nx-cloud';
import { performance } from 'perf_hooks';
import { ProjectGraph, ProjectGraphProjectNode } from '../shared/project-graph';
import { createProjectGraphAsync } from '../core/project-graph/project-graph';
import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
import { createProjectGraphAsync } from '../project-graph/project-graph';
import { readEnvironment } from './read-environment';
export async function runMany(parsedArgs: yargs.Arguments & RawNxArgs) {
performance.mark('command-execution-begins');

View File

@ -1,15 +1,15 @@
import { runCommand } from '../tasks-runner/run-command';
import { readEnvironment, readNxJson } from '../core/file-utils';
import { splitArgsIntoNxArgsAndOverrides } from './utils';
import { splitArgsIntoNxArgsAndOverrides } from '../utils/command-line-utils';
import { connectToNxCloudUsingScan } from './connect-to-nx-cloud';
import { performance } from 'perf_hooks';
import { createProjectGraphAsync } from '../core/project-graph/project-graph';
import { ProjectGraph } from '../shared/project-graph';
import { WorkspaceJsonConfiguration } from 'nx/src/shared/workspace';
import { NxJsonConfiguration } from 'nx/src/shared/nx';
import { workspaceRoot } from 'nx/src/utils/app-root';
import { splitTarget } from 'nx/src/utils/split-target';
import { output } from 'nx/src/utils/output';
import { createProjectGraphAsync } from '../project-graph/project-graph';
import { ProjectGraph } from '../config/project-graph';
import { NxJsonConfiguration } from '../config/nx-json';
import { workspaceRoot } from '../utils/app-root';
import { splitTarget } from '../utils/split-target';
import { output } from '../utils/output';
import { readEnvironment } from './read-environment';
import { WorkspaceJsonConfiguration } from '../config/workspace-json-project-json';
export async function runOne(
cwd: string,

View File

@ -4,15 +4,8 @@ import {
Schema,
} from '../utils/params';
import { printHelp } from '../utils/print-help';
import {
Executor,
ExecutorContext,
ProjectConfiguration,
TargetConfiguration,
WorkspaceJsonConfiguration,
Workspaces,
} from '../shared/workspace';
import { NxJsonConfiguration } from '../shared/nx';
import { Workspaces } from '../config/workspaces';
import { NxJsonConfiguration } from '../config/nx-json';
import { readJsonFile } from '../utils/fileutils';
import { buildTargetFromScript, PackageJson } from '../utils/package-json';
import { join } from 'path';
@ -21,6 +14,12 @@ import {
loadNxPlugins,
mergePluginTargetsWithNxTargets,
} from '../utils/nx-plugin';
import {
ProjectConfiguration,
TargetConfiguration,
WorkspaceJsonConfiguration,
} from '../config/workspace-json-project-json';
import { Executor, ExecutorContext } from '../config/misc-interfaces';
export interface Target {
project: string;

View File

@ -4,13 +4,13 @@ import { readdirSync, existsSync } from 'fs';
import { copySync, removeSync } from 'fs-extra';
import * as path from 'path';
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 { output } from '../utils/output';
import type { CompilerOptions } from 'typescript';
import { generate } from 'nx/src/command-line/generate';
import { readJsonFile, writeJsonFile } from 'nx/src/utils/fileutils';
import { logger } from 'nx/src/utils/logger';
import { generate } from './generate';
import { readJsonFile, writeJsonFile } from '../utils/fileutils';
import { logger } from '../utils/logger';
import { getPackageManagerCommand } from '../utils/package-manager';
import { normalizePath } from '../utils/path';

View File

@ -1,7 +1,7 @@
import { output } from '../utils/output';
import type { CLIErrorMessageConfig } from '../utils/output';
import { workspaceFileName } from '../core/file-utils';
import { ProjectGraph } from 'nx/src/shared/project-graph';
import { workspaceFileName } from '../project-graph/file-utils';
import { ProjectGraph } from '../config/project-graph';
export class WorkspaceIntegrityChecks {
constructor(private projectGraph: ProjectGraph, private files: string[]) {}

View 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;
}

View File

@ -1,5 +1,5 @@
import { PackageManager } from '../utils/package-manager';
import { TargetDependencyConfig } from './workspace';
import { TargetDependencyConfig } from './workspace-json-project-json';
export type ImplicitDependencyEntry<T = '*' | string[]> = {
[key: string]: T | ImplicitJsonSubsetDependency<T>;

View File

@ -1,4 +1,7 @@
import type { TargetConfiguration, Workspace } from './workspace';
import type {
TargetConfiguration,
Workspace,
} from './workspace-json-project-json';
/**
* Some metadata about a file

View 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;
}

View File

@ -1,5 +1,5 @@
import { toProjectName, Workspaces } from './workspace';
import { NxJsonConfiguration } from './nx';
import { toProjectName, Workspaces } from './workspaces';
import { NxJsonConfiguration } from './nx-json';
import { vol } from 'memfs';
import * as fastGlob from 'fast-glob';

View File

@ -10,8 +10,17 @@ import { readJsonFile } from '../utils/fileutils';
import { logger } from '../utils/logger';
import { loadNxPlugins, readPluginPackageJson } from '../utils/nx-plugin';
import type { NxJsonConfiguration } from './nx';
import { TaskGraph } from 'nx/src/shared/tasks';
import type { NxJsonConfiguration } from './nx-json';
import {
ProjectConfiguration,
WorkspaceJsonConfiguration,
} from './workspace-json-project-json';
import {
Executor,
ExecutorConfig,
TaskGraphExecutor,
Generator,
} from './misc-interfaces';
export function workspaceConfigName(root: string) {
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 {
private cachedWorkspaceConfig: WorkspaceJsonConfiguration &
NxJsonConfiguration;
@ -444,7 +213,14 @@ export class Workspaces {
return { executorsFilePath, executorConfig };
}
private readGeneratorsJson(collectionName: string, generator: string) {
private readGeneratorsJson(
collectionName: string,
generator: string
): {
generatorsFilePath: string;
generatorsJson: any;
normalizedGeneratorName: string;
} {
let generatorsFilePath;
if (collectionName.endsWith('.json')) {
generatorsFilePath = require.resolve(collectionName, {

View File

@ -1,2 +0,0 @@
export * from './affected-project-graph';
export * from './affected-project-graph-models';

View File

@ -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;
}

View File

@ -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 { openSync, readFileSync } from 'fs';
import { ensureDirSync, ensureFileSync } from 'fs-extra';
import { connect } from 'net';
import { join } from 'path';
import { performance } from 'perf_hooks';
import { output } from '../../../../utils/output';
import { output } from '../../utils/output';
import {
safelyCleanUpExistingProcess,
writeDaemonJsonProcessCache,
@ -15,7 +15,7 @@ import {
DAEMON_DIR_FOR_CURRENT_WORKSPACE,
DAEMON_OUTPUT_LOG_FILE,
} from '../tmp-dir';
import { ProjectGraph } from 'nx/src/shared/project-graph';
import { ProjectGraph } from '../../config/project-graph';
export async function startInBackground(): Promise<ChildProcess['pid']> {
await safelyCleanUpExistingProcess();

View File

@ -1,20 +1,20 @@
import { performance } from 'perf_hooks';
import { readWorkspaceJson } from '../../../file-utils';
import { defaultFileHasher } from '../../../hasher/file-hasher';
import { readWorkspaceJson } from '../../project-graph/file-utils';
import { defaultFileHasher } from '../../hasher/file-hasher';
import { serverLogger } from './logger';
import { buildProjectGraphUsingProjectFileMap } from '../../build-project-graph';
import { buildProjectGraphUsingProjectFileMap } from '../../project-graph/build-project-graph';
import {
nxDepsPath,
ProjectGraphCache,
readCache,
} from '../../../nx-deps/nx-deps-cache';
import { fileExists } from '../../../../utils/fileutils';
import { HashingImpl } from '../../../hasher/hashing-impl';
} from '../../project-graph/nx-deps-cache';
import { fileExists } from '../../utils/fileutils';
import { HashingImpl } from '../../hasher/hashing-impl';
import {
createProjectFileMap,
updateProjectFileMap,
} from '../../../file-map-utils';
import { FileData, ProjectFileMap } from 'nx/src/shared/project-graph';
} from '../../project-graph/file-map-utils';
import { FileData, ProjectFileMap } from '../../config/project-graph';
let cachedSerializedProjectGraphPromise: Promise<{
error: Error | null;

View File

@ -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 { join } from 'path';
import { performance, PerformanceObserver } from 'perf_hooks';
@ -25,8 +25,8 @@ import {
getCachedSerializedProjectGraphPromise,
} from './project-graph-incremental-recomputation';
import { existsSync, statSync } from 'fs';
import { HashingImpl } from '../../../hasher/hashing-impl';
import { defaultFileHasher } from 'nx/src/core/hasher/file-hasher';
import { HashingImpl } from '../../hasher/hashing-impl';
import { defaultFileHasher } from '../../hasher/file-hasher';
function respondToClient(socket: Socket, message: string) {
return new Promise((res) => {
@ -271,7 +271,7 @@ const handleWorkspaceChanges: SubscribeToWorkspaceChangesCallback = async (
};
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) {
killSocketOrPath();
}

View File

@ -1,4 +1,4 @@
import { workspaceRoot } from 'nx/src/utils/app-root';
import { workspaceRoot } from '../../utils/app-root';
import type { Server } from 'net';
import { serverLogger } from './logger';
import type { WatcherSubscription } from './watcher';

View File

@ -1,4 +1,4 @@
import { output } from '../../../../utils/output';
import { output } from '../../utils/output';
import { startServer } from './server';
import * as process from 'process';

View File

@ -1,4 +1,4 @@
import { output } from '../../../../utils/output';
import { output } from '../../utils/output';
import { safelyCleanUpExistingProcess } from '../cache';
import { stopServer } from './server';

View File

@ -5,15 +5,15 @@
*
* 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 { readFileSync } from 'fs';
import { join, relative } from 'path';
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 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

View File

@ -2,7 +2,7 @@ import { unlinkSync } from 'fs';
import { platform } from 'os';
import { resolve } from 'path';
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';

View File

@ -5,7 +5,7 @@
*/
import { statSync, writeFileSync } from 'fs';
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');

View File

@ -1,8 +1,8 @@
import { workspaceRoot } from 'nx/src/utils/app-root';
import { workspaceRoot } from '../utils/app-root';
import { performance } from 'perf_hooks';
import { defaultHashing } from './hashing-impl';
import { FileData } from 'nx/src/shared/project-graph';
import { joinPathFragments, normalizePath } from 'nx/src/utils/path';
import { FileData } from '../config/project-graph';
import { joinPathFragments, normalizePath } from '../utils/path';
export abstract class FileHasherBase {
protected fileHashes: Map<string, string>;

View File

@ -1,5 +1,5 @@
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 { FileHasherBase } from './file-hasher-base';
import { execSync } from 'child_process';

View File

@ -1,4 +1,4 @@
import { workspaceRoot } from 'nx/src/utils/app-root';
import { workspaceRoot } from '../utils/app-root';
import { performance } from 'perf_hooks';
import { getFileHashes, getGitHashForFiles } from './git-hasher';
import { existsSync, readFileSync } from 'fs';

View File

@ -1,6 +1,6 @@
import { spawn } from 'child_process';
import { fileExists } from '../../utils/fileutils';
import { joinPathFragments } from '../../utils/path';
import { fileExists } from '../utils/fileutils';
import { joinPathFragments } from '../utils/path';
export async function getGitHashForFiles(
potentialFilesToHash: string[],

View File

@ -1,18 +1,18 @@
// 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 {
workspaceRoot: '',
};
});
import fs = require('fs');
import tsUtils = require('../../utils/typescript');
import tsUtils = require('../utils/typescript');
import { Hasher } from './hasher';
jest.mock('fs');
jest.mock('../../utils/typescript');
jest.mock('../utils/typescript');
fs.existsSync = () => true;

View File

@ -1,20 +1,18 @@
import {
resolveNewFormatWithInlineProjects,
WorkspaceJsonConfiguration,
} from 'nx/src/shared/workspace';
import { resolveNewFormatWithInlineProjects } from '../config/workspaces';
import { exec } from 'child_process';
import { existsSync } from 'fs';
import * as minimatch from 'minimatch';
import { join } from 'path';
import { performance } from 'perf_hooks';
import { getRootTsConfigFileName } from '../../utils/typescript';
import { workspaceRoot } from '../../utils/app-root';
import { workspaceFileName } from '../file-utils';
import { getRootTsConfigFileName } from '../utils/typescript';
import { workspaceRoot } from '../utils/app-root';
import { workspaceFileName } from '../project-graph/file-utils';
import { defaultHashing, HashingImpl } from './hashing-impl';
import { ProjectGraph } from 'nx/src/shared/project-graph';
import { NxJsonConfiguration } from 'nx/src/shared/nx';
import { Task } from 'nx/src/shared/tasks';
import { readJsonFile } from 'nx/src/utils/fileutils';
import { ProjectGraph } from '../config/project-graph';
import { NxJsonConfiguration } from '../config/nx-json';
import { Task } from '../config/task-graph';
import { readJsonFile } from '../utils/fileutils';
import { WorkspaceJsonConfiguration } from '../config/workspace-json-project-json';
/**
* A data structure returned by the default hasher.

View File

@ -1,12 +1,12 @@
import { workspaceRoot } from 'nx/src/utils/app-root';
import { workspaceRoot } from '../utils/app-root';
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 { existsSync, readdirSync, readFileSync, statSync } from 'fs';
import { FileHasherBase } from './file-hasher-base';
import { stripIndents } from '../../utils/strip-indents';
import { stripIndents } from '../utils/strip-indents';
import ignore from 'ignore';
import { normalizePath } from 'nx/src/utils/path';
import { normalizePath } from '../utils/path';
export class NodeBasedFileHasher extends FileHasherBase {
ignoredGlobs = getIgnoredGlobs();

View File

@ -1,6 +1,6 @@
import type { Change, FileChange } from '../file-utils';
import { NxJsonConfiguration } from 'nx/src/shared/nx';
import { ProjectGraph } from 'nx/src/shared/project-graph';
import { NxJsonConfiguration } from '../../config/nx-json';
import { ProjectGraph } from '../../config/project-graph';
export interface AffectedProjectGraphContext {
workspaceJson: any;

View File

@ -2,10 +2,10 @@ import { jsonDiff } from '../../utils/json-diff';
import { vol } from 'memfs';
import { filterAffected } from './affected-project-graph';
import { WholeFileChange } from '../file-utils';
import { buildProjectGraph } from '../project-graph/build-project-graph';
import { defaultFileHasher } from '../hasher/file-hasher';
import { WorkspaceJsonConfiguration } from 'nx/src/shared/workspace';
import { NxJsonConfiguration } from 'nx/src/shared/nx';
import { buildProjectGraph } from '../build-project-graph';
import { defaultFileHasher } from '../../hasher/file-hasher';
import { WorkspaceJsonConfiguration } from '../../config/workspace-json-project-json';
import { NxJsonConfiguration } from '../../config/nx-json';
import { stripIndents } from '../../utils/strip-indents';
jest.mock('fs', () => require('memfs').fs);

View File

@ -17,10 +17,10 @@ import {
import { normalizeNxJson } from '../normalize-nx-json';
import { getTouchedProjectsInWorkspaceJson } from './locators/workspace-json-changes';
import { getTouchedProjectsFromTsConfig } from './locators/tsconfig-json-changes';
import { WorkspaceJsonConfiguration } from 'nx/src/shared/workspace';
import { NxJsonConfiguration } from 'nx/src/shared/nx';
import { ProjectGraph } from 'nx/src/shared/project-graph';
import { reverse } from '../project-graph/operators';
import { NxJsonConfiguration } from '../../config/nx-json';
import { ProjectGraph } from '../../config/project-graph';
import { reverse } from '../operators';
import { WorkspaceJsonConfiguration } from '../../config/workspace-json-project-json';
export function filterAffected(
graph: ProjectGraph,

View File

@ -1,7 +1,7 @@
import { getImplicitlyTouchedProjectsByJsonChanges } from './implicit-json-changes';
import { WholeFileChange } from '../../file-utils';
import { DiffType } from '../../../utils/json-diff';
import { NxJsonConfiguration } from 'nx/src/shared/nx';
import { NxJsonConfiguration } from '../../../config/nx-json';
function getModifiedChange(path: string[]) {
return {

View File

@ -7,7 +7,7 @@ import {
walkJsonTree,
} from '../../../utils/json-diff';
import { TouchedProjectLocator } from '../affected-project-graph-models';
import { ImplicitDependencyEntry } from 'nx/src/shared/nx';
import { ImplicitDependencyEntry } from '../../../config/nx-json';
export const getImplicitlyTouchedProjectsByJsonChanges: TouchedProjectLocator<
WholeFileChange | JsonChange

View File

@ -1,8 +1,8 @@
import { getTouchedNpmPackages } from './npm-packages';
import { WholeFileChange } from '../../file-utils';
import { DiffType } from '../../../utils/json-diff';
import { NxJsonConfiguration } from 'nx/src/shared/nx';
import { ProjectGraph } from 'nx/src/shared/project-graph';
import { NxJsonConfiguration } from '../../../config/nx-json';
import { ProjectGraph } from '../../../config/project-graph';
describe('getTouchedNpmPackages', () => {
let workspaceJson;

View File

@ -2,7 +2,7 @@ import { WholeFileChange } from '../../file-utils';
import { jsonDiff } from '../../../utils/json-diff';
import { getTouchedProjectsFromTsConfig } from './tsconfig-json-changes';
import * as tsUtils from '../../../utils/typescript';
import { DependencyType, ProjectGraph } from 'nx/src/shared/project-graph';
import { DependencyType, ProjectGraph } from '../../../config/project-graph';
describe('getTouchedProjectsFromTsConfig', () => {
let graph: ProjectGraph;

View File

@ -2,7 +2,7 @@ import { WholeFileChange } from '../../file-utils';
import { DiffType, isJsonChange, JsonChange } from '../../../utils/json-diff';
import { getRootTsConfigFileName } from '../../../utils/typescript';
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<
WholeFileChange | JsonChange

Some files were not shown because too many files have changed in this diff Show More