diff --git a/.prettierignore b/.prettierignore index 946393c006..274f5e1d33 100644 --- a/.prettierignore +++ b/.prettierignore @@ -3,7 +3,7 @@ tmp /build node_modules /package.json -packages/workspace/src/schematics/**/files/**/*.json +packages/workspace/src/generators/**/files/**/*.json packages/workspace/src/core/dep-graph/vendor.js packages/angular/src/schematics/**/files/**/*.json packages/angular/src/migrations/**/files/**/*.json diff --git a/package.json b/package.json index 4bdc692221..ca9fb3cc4f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nrwl/nx-source", - "version": "11.99.0", + "version": "11.1.5", "description": "Extensible Dev Tools for Monorepos", "homepage": "https://nx.dev", "main": "index.js", @@ -281,4 +281,4 @@ "resolutions": { "ng-packagr/rxjs": "6.6.3" } -} \ No newline at end of file +} diff --git a/packages/angular/src/schematics/move/lib/update-module-name.ts b/packages/angular/src/schematics/move/lib/update-module-name.ts index 241ce48128..8b34124642 100644 --- a/packages/angular/src/schematics/move/lib/update-module-name.ts +++ b/packages/angular/src/schematics/move/lib/update-module-name.ts @@ -1,7 +1,7 @@ import { classify } from '@angular-devkit/core/src/utils/strings'; import { SchematicContext, Tree } from '@angular-devkit/schematics'; import { getWorkspace } from '@nrwl/workspace'; -import { getNewProjectName } from '@nrwl/workspace/src/schematics/move/lib/utils'; +import { getNewProjectName } from '@nrwl/workspace/src/generators/move/lib/utils'; import { from, Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { Schema } from '../schema'; diff --git a/packages/cli/lib/init-local.ts b/packages/cli/lib/init-local.ts index 2bbde1149f..9eedf0eb20 100644 --- a/packages/cli/lib/init-local.ts +++ b/packages/cli/lib/init-local.ts @@ -11,7 +11,7 @@ import { parseRunOneOptions } from './parse-run-one-options'; process.env.NX_CLI_SET = 'true'; export function initLocal(workspace: Workspace) { - require('@nrwl/workspace/' + 'src/utils/perf-logging'); + require('@nrwl/workspace/' + 'src/utilities/perf-logging'); require('@nrwl/tao/src/compat/compat.js'); const supportedNxCommands = require('@nrwl/workspace/' + diff --git a/packages/create-nx-plugin/bin/create-nx-plugin.ts b/packages/create-nx-plugin/bin/create-nx-plugin.ts index 3cf8e03e5b..68e682fc7f 100644 --- a/packages/create-nx-plugin/bin/create-nx-plugin.ts +++ b/packages/create-nx-plugin/bin/create-nx-plugin.ts @@ -1,7 +1,7 @@ #!/usr/bin/env node // we can't import from '@nrwl/workspace' because it will require typescript -import { output } from '@nrwl/workspace/src/utils/output'; +import { output } from '@nrwl/workspace/src/utilities/output'; import { getPackageManagerCommand } from '@nrwl/tao/src/shared/package-manager'; import { dirSync } from 'tmp'; import { writeFileSync, readFileSync, removeSync } from 'fs-extra'; diff --git a/packages/create-nx-plugin/bin/shared.ts b/packages/create-nx-plugin/bin/shared.ts index 9b1566e9c5..609ad14156 100644 --- a/packages/create-nx-plugin/bin/shared.ts +++ b/packages/create-nx-plugin/bin/shared.ts @@ -1,6 +1,6 @@ import * as path from 'path'; import { execSync } from 'child_process'; -import { output } from '@nrwl/workspace/src/utils/output'; +import { output } from '@nrwl/workspace/src/utilities/output'; export function showNxWarning(workspaceName: string) { try { diff --git a/packages/create-nx-workspace/bin/create-nx-workspace.ts b/packages/create-nx-workspace/bin/create-nx-workspace.ts index ac7f03377a..48055f94fc 100644 --- a/packages/create-nx-workspace/bin/create-nx-workspace.ts +++ b/packages/create-nx-workspace/bin/create-nx-workspace.ts @@ -1,7 +1,8 @@ #!/usr/bin/env node -import { output, unparse } from '@nrwl/workspace'; -import { Schema, Preset } from '@nrwl/workspace/src/schematics/new/new'; +import { output } from '@nrwl/workspace/src/utilities/output'; +import { unparse } from '@nrwl/workspace/src/tasks-runner/utils'; +import { Schema, Preset } from '@nrwl/workspace/src/generators/new/new'; import { getPackageManagerCommand } from '@nrwl/tao/src/shared/package-manager'; import { execSync } from 'child_process'; import { writeFileSync } from 'fs'; diff --git a/packages/create-nx-workspace/bin/shared.ts b/packages/create-nx-workspace/bin/shared.ts index 9b1566e9c5..609ad14156 100644 --- a/packages/create-nx-workspace/bin/shared.ts +++ b/packages/create-nx-workspace/bin/shared.ts @@ -1,6 +1,6 @@ import * as path from 'path'; import { execSync } from 'child_process'; -import { output } from '@nrwl/workspace/src/utils/output'; +import { output } from '@nrwl/workspace/src/utilities/output'; export function showNxWarning(workspaceName: string) { try { diff --git a/packages/devkit/index.ts b/packages/devkit/index.ts index 3a2365ecac..387f268d08 100644 --- a/packages/devkit/index.ts +++ b/packages/devkit/index.ts @@ -49,3 +49,4 @@ export { offsetFromRoot } from './src/utils/offset-from-root'; export { convertNxGenerator } from './src/utils/invoke-nx-generator'; export { convertNxExecutor } from './src/utils/convert-nx-executor'; export { stripIndents } from './src/utils/strip-indents'; +export { joinPathFragments, normalizePath } from './src/utils/path'; diff --git a/packages/devkit/src/generators/generate-files.ts b/packages/devkit/src/generators/generate-files.ts index 6345cb7e2a..6cedfc30d3 100644 --- a/packages/devkit/src/generators/generate-files.ts +++ b/packages/devkit/src/generators/generate-files.ts @@ -1,6 +1,6 @@ -import * as path from 'path'; import * as fs from 'fs'; import { Tree } from '@nrwl/tao/src/shared/tree'; +import { joinPathFragments } from '../utils/path'; const ejs = require('ejs'); @@ -41,7 +41,7 @@ export function generateFiles( substitutions ); const newContent = ejs.render(fs.readFileSync(f).toString(), substitutions); - host.write(path.join(target, relativeToTarget), newContent); + host.write(joinPathFragments(target, relativeToTarget), newContent); }); } @@ -59,7 +59,7 @@ function allFilesInDir(parent: string) { let res = []; try { fs.readdirSync(parent).forEach((c) => { - const child = path.join(parent, c); + const child = joinPathFragments(parent, c); try { const s = fs.statSync(child); if (!s.isDirectory()) { diff --git a/packages/devkit/src/utils/path.ts b/packages/devkit/src/utils/path.ts new file mode 100644 index 0000000000..1770a220d8 --- /dev/null +++ b/packages/devkit/src/utils/path.ts @@ -0,0 +1,28 @@ +import * as path from 'path'; + +function removeWindowsDriveLetter(osSpecificPath: string): string { + return osSpecificPath.replace(/^[A-Z]:/, ''); +} + +/** + * Coverts an os specific path to a unix style path + */ +export function normalizePath(osSpecificPath: string): string { + return removeWindowsDriveLetter(osSpecificPath).split(path.sep).join('/'); +} + +/** + * Normalized path fragments and joins them + */ +export function joinPathFragments(...fragments: string[]): string { + const normalizedFragments = []; + for (let i = 0; i < fragments.length; ++i) { + if (i === 0) { + normalizedFragments.push(normalizePath(fragments[i])); + } else { + const n = normalizePath(fragments[i]); + normalizedFragments.push(n.startsWith('/') ? n.substring(1) : n); + } + } + return normalizedFragments.join('/'); +} diff --git a/packages/eslint-plugin-nx/src/rules/enforce-module-boundaries.ts b/packages/eslint-plugin-nx/src/rules/enforce-module-boundaries.ts index 533bc42345..3e4c9c4920 100644 --- a/packages/eslint-plugin-nx/src/rules/enforce-module-boundaries.ts +++ b/packages/eslint-plugin-nx/src/rules/enforce-module-boundaries.ts @@ -1,4 +1,4 @@ -import { appRootPath } from '@nrwl/workspace/src/utils/app-root'; +import { appRootPath } from '@nrwl/workspace/src/utilities/app-root'; import { DepConstraint, findConstraintsFor, diff --git a/packages/jest/package.json b/packages/jest/package.json index 6e3b43ca56..f1cc950b6c 100644 --- a/packages/jest/package.json +++ b/packages/jest/package.json @@ -33,9 +33,6 @@ }, "dependencies": { "@nrwl/devkit": "*", - "@angular-devkit/architect": "~0.1100.1", - "@angular-devkit/core": "~11.0.1", - "@angular-devkit/schematics": "~11.0.1", "jest-resolve": "^26.6.2", "rxjs": "^6.5.4", "strip-json-comments": "2.0.1", diff --git a/packages/jest/src/generators/init/init.ts b/packages/jest/src/generators/init/init.ts index 435a86cb19..6199701f7e 100644 --- a/packages/jest/src/generators/init/init.ts +++ b/packages/jest/src/generators/init/init.ts @@ -1,4 +1,3 @@ -import { stripIndents } from '@angular-devkit/core/src/utils/literals'; import { babelCoreVersion, babelJestVersion, @@ -16,6 +15,7 @@ import { updateJson, addDependenciesToPackageJson, convertNxGenerator, + stripIndents, } from '@nrwl/devkit'; interface NormalizedSchema extends ReturnType {} diff --git a/packages/jest/src/generators/jest-project/lib/update-workspace.ts b/packages/jest/src/generators/jest-project/lib/update-workspace.ts index 2c3de9e300..a93402e980 100644 --- a/packages/jest/src/generators/jest-project/lib/update-workspace.ts +++ b/packages/jest/src/generators/jest-project/lib/update-workspace.ts @@ -1,18 +1,27 @@ -import { join, normalize } from '@angular-devkit/core'; import { JestProjectSchema } from '../schema'; import { readProjectConfiguration, Tree, updateProjectConfiguration, + joinPathFragments, + normalizePath, } from '@nrwl/devkit'; export function updateWorkspace(tree: Tree, options: JestProjectSchema) { const projectConfig = readProjectConfiguration(tree, options.project); projectConfig.targets.test = { executor: '@nrwl/jest:jest', - outputs: [join(normalize('coverage'), normalize(projectConfig.root))], + outputs: [ + joinPathFragments( + normalizePath('coverage'), + normalizePath(projectConfig.root) + ), + ], options: { - jestConfig: join(normalize(projectConfig.root), 'jest.config.js'), + jestConfig: joinPathFragments( + normalizePath(projectConfig.root), + 'jest.config.js' + ), passWithNoTests: true, }, }; @@ -24,7 +33,10 @@ export function updateWorkspace(tree: Tree, options: JestProjectSchema) { if (isUsingTSLint) { projectConfig.targets.lint.options.tsConfig = [ ...(projectConfig.targets.lint.options.tsConfig || []), - join(normalize(projectConfig.root), 'tsconfig.spec.json'), + joinPathFragments( + normalizePath(projectConfig.root), + 'tsconfig.spec.json' + ), ]; } updateProjectConfiguration(tree, options.project, projectConfig); diff --git a/packages/jest/src/migrations/update-10-0-0/update-jest-configs.ts b/packages/jest/src/migrations/update-10-0-0/update-jest-configs.ts index 64eb062443..3cd6224187 100644 --- a/packages/jest/src/migrations/update-10-0-0/update-jest-configs.ts +++ b/packages/jest/src/migrations/update-10-0-0/update-jest-configs.ts @@ -13,7 +13,7 @@ import { } from '@nrwl/workspace'; import { addPropertyToJestConfig } from '../utils/config/legacy/update-config'; import { getJestObject } from './require-jest-config'; -import { appRootPath } from '@nrwl/workspace/src/utils/app-root'; +import { appRootPath } from '@nrwl/workspace/src/utilities/app-root'; function checkJestPropertyObject(object: unknown): object is object { return object !== null && object !== undefined; diff --git a/packages/jest/src/migrations/update-10-3-0/update-ts-jest.ts b/packages/jest/src/migrations/update-10-3-0/update-ts-jest.ts index 0a588bbf24..78d332ae08 100644 --- a/packages/jest/src/migrations/update-10-3-0/update-ts-jest.ts +++ b/packages/jest/src/migrations/update-10-3-0/update-ts-jest.ts @@ -16,7 +16,7 @@ import { } from '../utils/config/legacy/update-config'; import { getJestObject } from '../update-10-0-0/require-jest-config'; import { stripIndents } from '@angular-devkit/core/src/utils/literals'; -import { appRootPath } from '@nrwl/workspace/src/utils/app-root'; +import { appRootPath } from '@nrwl/workspace/src/utilities/app-root'; function updateAstTransformers(): Rule { return async (host: Tree, context: SchematicContext) => { diff --git a/packages/linter/package.json b/packages/linter/package.json index 7ebb2c1c70..e1a7abeeba 100644 --- a/packages/linter/package.json +++ b/packages/linter/package.json @@ -28,7 +28,6 @@ }, "builders": "./builders.json", "dependencies": { - "@angular-devkit/architect": "~0.1100.1", "@nrwl/devkit": "*", "glob": "7.1.4", "minimatch": "3.0.4", diff --git a/packages/next/plugins/with-nx.ts b/packages/next/plugins/with-nx.ts index 1816a1de09..c3a7d9266e 100644 --- a/packages/next/plugins/with-nx.ts +++ b/packages/next/plugins/with-nx.ts @@ -1,5 +1,5 @@ const { join } = require('path'); -const { appRootPath } = require('@nrwl/workspace/src/utils/app-root'); +const { appRootPath } = require('@nrwl/workspace/src/utilities/app-root'); const { workspaceLayout } = require('@nrwl/workspace/src/core/file-utils'); function regexEqual(x, y) { diff --git a/packages/node/src/builders/package/package.impl.spec.ts b/packages/node/src/builders/package/package.impl.spec.ts index 50e0488e87..e6f3392487 100644 --- a/packages/node/src/builders/package/package.impl.spec.ts +++ b/packages/node/src/builders/package/package.impl.spec.ts @@ -16,9 +16,9 @@ jest.mock('glob'); import * as glob from 'glob'; jest.mock('fs-extra'); import * as fs from 'fs-extra'; -jest.mock('@nrwl/workspace/src/utils/fileutils'); -import * as fsUtility from '@nrwl/workspace/src/utils/fileutils'; -import * as tsUtils from '@nrwl/workspace/src/utils/typescript'; +jest.mock('@nrwl/workspace/src/utilities/fileutils'); +import * as fsUtility from '@nrwl/workspace/src/utilities/fileutils'; +import * as tsUtils from '@nrwl/workspace/src/utilities/typescript'; import * as ts from 'typescript'; describe('NodePackageBuilder', () => { diff --git a/packages/node/src/builders/package/utils/update-package-json.ts b/packages/node/src/builders/package/utils/update-package-json.ts index a2e7432593..8bc8e1e619 100644 --- a/packages/node/src/builders/package/utils/update-package-json.ts +++ b/packages/node/src/builders/package/utils/update-package-json.ts @@ -1,7 +1,7 @@ import { BuilderContext } from '@angular-devkit/architect'; import { normalize } from '@angular-devkit/core'; import { readJsonFile } from '@nrwl/workspace'; -import { writeJsonFile } from '@nrwl/workspace/src/utils/fileutils'; +import { writeJsonFile } from '@nrwl/workspace/src/utilities/fileutils'; import { basename, join } from 'path'; import { NormalizedBuilderOptions } from './models'; diff --git a/packages/node/src/utils/generate-package-json.ts b/packages/node/src/utils/generate-package-json.ts index f392cfd731..d7c574fa42 100644 --- a/packages/node/src/utils/generate-package-json.ts +++ b/packages/node/src/utils/generate-package-json.ts @@ -1,6 +1,6 @@ import { ProjectGraph, readJsonFile } from '@nrwl/workspace'; import { BuildNodeBuilderOptions } from './types'; -import { writeJsonFile } from '@nrwl/workspace/src/utils/fileutils'; +import { writeJsonFile } from '@nrwl/workspace/src/utilities/fileutils'; import { OUT_FILENAME } from './config'; /** diff --git a/packages/nx-plugin/src/utils/testing-utils/nx-project.ts b/packages/nx-plugin/src/utils/testing-utils/nx-project.ts index 1eb4c0b04a..3ea3f058e6 100644 --- a/packages/nx-plugin/src/utils/testing-utils/nx-project.ts +++ b/packages/nx-plugin/src/utils/testing-utils/nx-project.ts @@ -1,4 +1,4 @@ -import { appRootPath } from '@nrwl/workspace/src/utils/app-root'; +import { appRootPath } from '@nrwl/workspace/src/utilities/app-root'; import { getPackageManagerCommand } from '@nrwl/tao/src/shared/package-manager'; import { execSync } from 'child_process'; import { readFileSync, writeFileSync } from 'fs'; diff --git a/packages/react/src/utils/babel-utils.ts b/packages/react/src/utils/babel-utils.ts index e29dc83c87..68f853f3b7 100644 --- a/packages/react/src/utils/babel-utils.ts +++ b/packages/react/src/utils/babel-utils.ts @@ -1,4 +1,4 @@ -import { appRootPath } from '@nrwl/workspace/src/utils/app-root'; +import { appRootPath } from '@nrwl/workspace/src/utilities/app-root'; import { readJsonFile } from '@nrwl/workspace'; import { join } from 'path'; diff --git a/packages/tao/package.json b/packages/tao/package.json index bfdc4fb2c3..3703b271a7 100644 --- a/packages/tao/package.json +++ b/packages/tao/package.json @@ -29,9 +29,6 @@ }, "homepage": "https://nx.dev", "dependencies": { - "@angular-devkit/schematics": "~11.0.1", - "@angular-devkit/core": "~11.0.1", - "@angular-devkit/architect": "~0.1100.1", "chalk": "4.1.0", "inquirer": "^6.3.1", "minimist": "^1.2.5", diff --git a/packages/web/src/builders/package/package.impl.ts b/packages/web/src/builders/package/package.impl.ts index 237287522a..da8f380d5f 100644 --- a/packages/web/src/builders/package/package.impl.ts +++ b/packages/web/src/builders/package/package.impl.ts @@ -16,7 +16,7 @@ import { BuildResult } from '@angular-devkit/build-webpack'; import { readJsonFile, writeJsonFile, -} from '@nrwl/workspace/src/utils/fileutils'; +} from '@nrwl/workspace/src/utilities/fileutils'; import { createProjectGraph } from '@nrwl/workspace/src/core/project-graph'; import { diff --git a/packages/workspace/collection.json b/packages/workspace/collection.json index 3c52932698..fe67dcfba6 100644 --- a/packages/workspace/collection.json +++ b/packages/workspace/collection.json @@ -3,128 +3,128 @@ "version": "0.1", "schematics": { "workspace": { - "factory": "./src/schematics/workspace/workspace#workspaceSchematic", - "schema": "./src/schematics/workspace/schema.json", + "factory": "./src/generators/workspace/workspace#workspaceSchematic", + "schema": "./src/generators/workspace/schema.json", "description": "Create an empty workspace", "hidden": true }, "ng-add": { - "factory": "./src/schematics/init/init#initSchematic", - "schema": "./src/schematics/init/schema.json", + "factory": "./src/generators/init/init#initSchematic", + "schema": "./src/generators/init/schema.json", "description": "Convert an existing CLI project into an Nx Workspace", "hidden": true }, "preset": { - "factory": "./src/schematics/preset/preset#presetSchematic", - "schema": "./src/schematics/preset/schema.json", + "factory": "./src/generators/preset/preset#presetSchematic", + "schema": "./src/generators/preset/schema.json", "description": "Create application in an empty workspace", "hidden": true }, "move": { - "factory": "./src/schematics/move/move#moveSchematic", - "schema": "./src/schematics/move/schema.json", + "factory": "./src/generators/move/move#moveSchematic", + "schema": "./src/generators/move/schema.json", "aliases": ["mv"], "description": "Move an application or library to another folder" }, "remove": { - "factory": "./src/schematics/remove/remove#moveSchematic", - "schema": "./src/schematics/remove/schema.json", + "factory": "./src/generators/remove/remove#moveSchematic", + "schema": "./src/generators/remove/schema.json", "aliases": ["rm"], "description": "Remove an application or library" }, "new": { - "factory": "./src/schematics/new/new#newSchematic", - "schema": "./src/schematics/new/schema.json", + "factory": "./src/generators/new/new#newSchematic", + "schema": "./src/generators/new/schema.json", "description": "Create a workspace", "hidden": true }, "library": { - "factory": "./src/schematics/library/library#librarySchematic", - "schema": "./src/schematics/library/schema.json", + "factory": "./src/generators/library/library#librarySchematic", + "schema": "./src/generators/library/schema.json", "aliases": ["lib"], "description": "Create a library" }, "workspace-generator": { - "factory": "./src/schematics/workspace-generator/workspace-generator", - "schema": "./src/schematics/workspace-generator/schema.json", + "factory": "./src/generators/workspace-generator/workspace-generator", + "schema": "./src/generators/workspace-generator/schema.json", "aliases": ["workspace-schematic"], "description": "Generates a workspace generator" }, "run-commands": { - "factory": "./src/schematics/run-commands/run-commands#runCommandsSchematic", - "schema": "./src/schematics/run-commands/schema.json", + "factory": "./src/generators/run-commands/run-commands#runCommandsSchematic", + "schema": "./src/generators/run-commands/schema.json", "aliases": ["run-command", "target"], "description": "Generates a target to run any command in the terminal" } }, "generators": { "workspace": { - "factory": "./src/schematics/workspace/workspace#workspaceGenerator", - "schema": "./src/schematics/workspace/schema.json", + "factory": "./src/generators/workspace/workspace#workspaceGenerator", + "schema": "./src/generators/workspace/schema.json", "description": "Create an empty workspace", "hidden": true }, "ng-add": { - "factory": "./src/schematics/init/init#initGenerator", - "schema": "./src/schematics/init/schema.json", + "factory": "./src/generators/init/init#initGenerator", + "schema": "./src/generators/init/schema.json", "description": "Convert an existing CLI project into an Nx Workspace", "hidden": true }, "preset": { - "factory": "./src/schematics/preset/preset#presetGenerator", - "schema": "./src/schematics/preset/schema.json", + "factory": "./src/generators/preset/preset#presetGenerator", + "schema": "./src/generators/preset/schema.json", "description": "Create application in an empty workspace", "hidden": true }, "move": { - "factory": "./src/schematics/move/move#moveGenerator", - "schema": "./src/schematics/move/schema.json", + "factory": "./src/generators/move/move#moveGenerator", + "schema": "./src/generators/move/schema.json", "aliases": ["mv"], "description": "Move an application or library to another folder" }, "remove": { - "factory": "./src/schematics/remove/remove#removeGenerator", - "schema": "./src/schematics/remove/schema.json", + "factory": "./src/generators/remove/remove#removeGenerator", + "schema": "./src/generators/remove/schema.json", "aliases": ["rm"], "description": "Remove an application or library" }, "new": { - "factory": "./src/schematics/new/new#newGenerator", - "schema": "./src/schematics/new/schema.json", + "factory": "./src/generators/new/new#newGenerator", + "schema": "./src/generators/new/schema.json", "description": "Create a workspace", "hidden": true }, "library": { - "factory": "./src/schematics/library/library#libraryGenerator", - "schema": "./src/schematics/library/schema.json", + "factory": "./src/generators/library/library#libraryGenerator", + "schema": "./src/generators/library/schema.json", "aliases": ["lib"], "description": "Create a library" }, "workspace-generator": { - "factory": "./src/schematics/workspace-generator/workspace-generator", - "schema": "./src/schematics/workspace-generator/schema.json", + "factory": "./src/generators/workspace-generator/workspace-generator", + "schema": "./src/generators/workspace-generator/schema.json", "aliases": ["workspace-schematic"], "description": "Generates a workspace generator" }, "run-commands": { - "factory": "./src/schematics/run-commands/run-commands#runCommandsGenerator", - "schema": "./src/schematics/run-commands/schema.json", + "factory": "./src/generators/run-commands/run-commands#runCommandsGenerator", + "schema": "./src/generators/run-commands/schema.json", "aliases": ["run-command", "target"], "description": "Generates a target to run any command in the terminal" } diff --git a/packages/workspace/generators.ts b/packages/workspace/generators.ts new file mode 100644 index 0000000000..14e3677af0 --- /dev/null +++ b/packages/workspace/generators.ts @@ -0,0 +1,4 @@ +export { libraryGenerator } from './src/generators/library/library'; +export { moveGenerator } from './src/generators/move/move'; +export { removeGenerator } from './src/generators/remove/remove'; +export { runCommandsGenerator } from './src/generators/run-commands/run-commands'; diff --git a/packages/workspace/index.ts b/packages/workspace/index.ts index e994ca26f0..b11929ffe6 100644 --- a/packages/workspace/index.ts +++ b/packages/workspace/index.ts @@ -1,4 +1,4 @@ -export { readTsConfig } from './src/utils/typescript'; +export { readTsConfig } from './src/utilities/typescript'; export { ProjectType, projectRootDir } from './src/utils/project-type'; export { serializeJson, @@ -7,7 +7,7 @@ export { readJsonFile, copyFile, createDirectory, -} from './src/utils/fileutils'; +} from './src/utilities/fileutils'; // TODO: vsavkin delete after Nx 12 export * from './src/devkit-reexport'; @@ -15,9 +15,9 @@ export * from './src/devkit-reexport'; export { ExistingPrettierConfig, resolveUserExistingPrettierConfig, -} from './src/utils/common'; +} from './src/utilities/prettier'; -export { output } from './src/utils/output'; +export { output } from './src/utilities/output'; export { commandsObject } from './src/command-line/nx-commands'; export { supportedNxCommands } from './src/command-line/supported-nx-commands'; export { @@ -91,9 +91,9 @@ import * as strings from './src/utils/strings'; export { checkAndCleanWithSemver } from './src/utils/version-utils'; export { updatePackagesInPackageJson } from './src/utils/update-packages-in-package-json'; -export { libraryGenerator } from './src/schematics/library/library'; -export { moveGenerator } from './src/schematics/move/move'; -export { removeGenerator } from './src/schematics/remove/remove'; -export { runCommandsGenerator } from './src/schematics/run-commands/run-commands'; +export { libraryGenerator } from './src/generators/library/library'; +export { moveGenerator } from './src/generators/move/move'; +export { removeGenerator } from './src/generators/remove/remove'; +export { runCommandsGenerator } from './src/generators/run-commands/run-commands'; export const stringUtils = strings; diff --git a/packages/workspace/package.json b/packages/workspace/package.json index dbd4b4be6b..6988e9f12f 100644 --- a/packages/workspace/package.json +++ b/packages/workspace/package.json @@ -53,9 +53,6 @@ "prettier": "^2.0.4" }, "dependencies": { - "@angular-devkit/architect": "~0.1100.1", - "@angular-devkit/core": "~11.0.1", - "@angular-devkit/schematics": "~11.0.1", "@nrwl/cli": "*", "@nrwl/devkit": "*", "@nrwl/jest": "*", diff --git a/packages/workspace/src/command-line/affected.ts b/packages/workspace/src/command-line/affected.ts index f1caa3d23a..99f0c99e17 100644 --- a/packages/workspace/src/command-line/affected.ts +++ b/packages/workspace/src/command-line/affected.ts @@ -10,8 +10,8 @@ import { } from '../core/project-graph'; import { DefaultReporter } from '../tasks-runner/default-reporter'; import { runCommand } from '../tasks-runner/run-command'; -import { output } from '../utils/output'; -import { projectHasTarget } from '../utils/project-graph-utils'; +import { output } from '../utilities/output'; +import { projectHasTarget } from '../utilities/project-graph-utils'; import { generateGraph } from './dep-graph'; import { printAffected } from './print-affected'; import { promptForNxCloud } from './prompt-for-nx-cloud'; diff --git a/packages/workspace/src/command-line/dep-graph.ts b/packages/workspace/src/command-line/dep-graph.ts index 4dc3a19a8e..3f209bda1d 100644 --- a/packages/workspace/src/command-line/dep-graph.ts +++ b/packages/workspace/src/command-line/dep-graph.ts @@ -10,8 +10,8 @@ import { ProjectGraph, ProjectGraphNode, } from '../core/project-graph'; -import { appRootPath } from '../utils/app-root'; -import { output } from '../utils/output'; +import { appRootPath } from '../utilities/app-root'; +import { output } from '../utilities/output'; // maps file extention to MIME types const mimeType = { diff --git a/packages/workspace/src/command-line/format.ts b/packages/workspace/src/command-line/format.ts index dec1d14f2e..149af4e0e0 100644 --- a/packages/workspace/src/command-line/format.ts +++ b/packages/workspace/src/command-line/format.ts @@ -2,7 +2,7 @@ import { execSync } from 'child_process'; import * as path from 'path'; import * as resolve from 'resolve'; import { getProjectRoots, parseFiles } from './shared'; -import { fileExists } from '../utils/fileutils'; +import { fileExists } from '../utilities/fileutils'; import { createProjectGraph, onlyWorkspaceProjects, @@ -15,7 +15,7 @@ import { reformattedWorkspaceJsonOrNull, workspaceConfigName, } from '@nrwl/tao/src/shared/workspace'; -import { appRootPath } from '@nrwl/workspace/src/utils/app-root'; +import { appRootPath } from '@nrwl/workspace/src/utilities/app-root'; import { readFileSync, writeFileSync } from 'fs-extra'; import * as stripJsonComments from 'strip-json-comments'; diff --git a/packages/workspace/src/command-line/lint.ts b/packages/workspace/src/command-line/lint.ts index 6c9e83c2aa..4487978b7f 100644 --- a/packages/workspace/src/command-line/lint.ts +++ b/packages/workspace/src/command-line/lint.ts @@ -4,7 +4,7 @@ import { } from '../core/project-graph'; import { WorkspaceIntegrityChecks } from './workspace-integrity-checks'; import { readWorkspaceFiles, workspaceLayout } from '../core/file-utils'; -import { output } from '../utils/output'; +import { output } from '../utilities/output'; import * as path from 'path'; export function workspaceLint() { diff --git a/packages/workspace/src/command-line/list.ts b/packages/workspace/src/command-line/list.ts index 85a168406c..1b93a2a7b5 100644 --- a/packages/workspace/src/command-line/list.ts +++ b/packages/workspace/src/command-line/list.ts @@ -1,6 +1,6 @@ import * as yargs from 'yargs'; -import { appRootPath } from '../utils/app-root'; -import { output } from '../utils/output'; +import { appRootPath } from '../utilities/app-root'; +import { output } from '../utilities/output'; import { fetchCommunityPlugins, fetchCorePlugins, @@ -9,7 +9,7 @@ import { listCorePlugins, listInstalledPlugins, listPluginCapabilities, -} from '../utils/plugins'; +} from '../utilities/plugins'; export interface YargsListArgs extends yargs.Arguments, ListArgs {} diff --git a/packages/workspace/src/command-line/prompt-for-nx-cloud.ts b/packages/workspace/src/command-line/prompt-for-nx-cloud.ts index c045718293..b1594f1365 100644 --- a/packages/workspace/src/command-line/prompt-for-nx-cloud.ts +++ b/packages/workspace/src/command-line/prompt-for-nx-cloud.ts @@ -1,6 +1,6 @@ import * as inquirer from 'inquirer'; import { readNxJson } from '../core/file-utils'; -import { output } from '../utils/output'; +import { output } from '../utilities/output'; import { getPackageManagerCommand } from '@nrwl/tao/src/shared/package-manager'; import { execSync } from 'child_process'; diff --git a/packages/workspace/src/command-line/report.ts b/packages/workspace/src/command-line/report.ts index b125c5b35c..808ea00a2a 100644 --- a/packages/workspace/src/command-line/report.ts +++ b/packages/workspace/src/command-line/report.ts @@ -1,9 +1,9 @@ import * as chalk from 'chalk'; import { execSync } from 'child_process'; import { readFileSync } from 'fs'; -import { appRootPath } from '../utils/app-root'; +import { appRootPath } from '../utilities/app-root'; import { detectPackageManager } from '@nrwl/tao/src/shared/package-manager'; -import { output } from '../utils/output'; +import { output } from '../utilities/output'; export const packagesWeCareAbout = [ 'nx', diff --git a/packages/workspace/src/command-line/run-many.ts b/packages/workspace/src/command-line/run-many.ts index ff4d8bcb18..5ef50ac6ca 100644 --- a/packages/workspace/src/command-line/run-many.ts +++ b/packages/workspace/src/command-line/run-many.ts @@ -11,8 +11,8 @@ import { } from '../core/project-graph'; import { readEnvironment } from '../core/file-utils'; import { DefaultReporter } from '../tasks-runner/default-reporter'; -import { projectHasTarget } from '../utils/project-graph-utils'; -import { output } from '../utils/output'; +import { projectHasTarget } from '../utilities/project-graph-utils'; +import { output } from '../utilities/output'; import { promptForNxCloud } from './prompt-for-nx-cloud'; export async function runMany(parsedArgs: yargs.Arguments) { diff --git a/packages/workspace/src/command-line/run-one.ts b/packages/workspace/src/command-line/run-one.ts index 21a51eb274..ac55bd1d65 100644 --- a/packages/workspace/src/command-line/run-one.ts +++ b/packages/workspace/src/command-line/run-one.ts @@ -3,7 +3,7 @@ import { createProjectGraph, ProjectGraph } from '../core/project-graph'; import { readEnvironment } from '../core/file-utils'; import { EmptyReporter } from '../tasks-runner/empty-reporter'; import { splitArgsIntoNxArgsAndOverrides } from './utils'; -import { projectHasTarget } from '../utils/project-graph-utils'; +import { projectHasTarget } from '../utilities/project-graph-utils'; import { promptForNxCloud } from './prompt-for-nx-cloud'; export async function runOne(opts: { diff --git a/packages/workspace/src/command-line/utils.ts b/packages/workspace/src/command-line/utils.ts index 2b0e40fb78..ca2c79b71d 100644 --- a/packages/workspace/src/command-line/utils.ts +++ b/packages/workspace/src/command-line/utils.ts @@ -2,7 +2,7 @@ import * as yargsParser from 'yargs-parser'; import * as yargs from 'yargs'; import * as fileUtils from '../core/file-utils'; import { NxAffectedConfig } from '../core/shared-interfaces'; -import { output } from '../utils/output'; +import { output } from '../utilities/output'; import { names } from '@nrwl/devkit'; const runOne = [ diff --git a/packages/workspace/src/command-line/workspace-generators.ts b/packages/workspace/src/command-line/workspace-generators.ts index 3804936830..93603ec9e3 100644 --- a/packages/workspace/src/command-line/workspace-generators.ts +++ b/packages/workspace/src/command-line/workspace-generators.ts @@ -1,23 +1,4 @@ -import { - JsonObject, - logging, - normalize, - schema, - tags, - virtualFs, -} from '@angular-devkit/core'; import * as chalk from 'chalk'; -import { createConsoleLogger, NodeJsSyncHost } from '@angular-devkit/core/node'; -import { - formats, - SchematicEngine, - UnsuccessfulWorkflowExecution, -} from '@angular-devkit/schematics'; -import { - NodeModulesEngineHost, - NodeWorkflow, - validateOptionsWithSchema, -} from '@angular-devkit/schematics/tools'; import { execSync } from 'child_process'; import * as fs from 'fs'; import { writeFileSync } from 'fs'; @@ -25,15 +6,20 @@ import { copySync, removeSync } from 'fs-extra'; import * as inquirer from 'inquirer'; import * as path from 'path'; import * as yargsParser from 'yargs-parser'; -import { appRootPath } from '../utils/app-root'; +import { appRootPath } from '../utilities/app-root'; import { detectPackageManager, getPackageManagerCommand, } from '@nrwl/tao/src/shared/package-manager'; -import { fileExists, readJsonFile, writeJsonFile } from '../utils/fileutils'; -import { output } from '../utils/output'; +import { + fileExists, + readJsonFile, + writeJsonFile, +} from '../utilities/fileutils'; +import { output } from '../utilities/output'; import { CompilerOptions } from 'typescript'; import { Workspaces } from '@nrwl/tao/src/shared/workspace'; +import { logger, normalizePath } from '@nrwl/devkit'; const rootDirectory = appRootPath; @@ -49,14 +35,10 @@ type TsConfig = { export async function workspaceGenerators(args: string[]) { const outDir = compileTools(); const parsedArgs = parseOptions(args, outDir); - const logger = createConsoleLogger( - parsedArgs.verbose, - process.stdout, - process.stderr - ); + const collectionFile = path.join(outDir, 'workspace-generators.json'); if (parsedArgs.listGenerators) { - return listGenerators(collectionFile, logger); + return listGenerators(collectionFile); } const generatorName = args[0]; const ws = new Workspaces(rootDirectory); @@ -72,6 +54,11 @@ export async function workspaceGenerators(args: string[]) { process.exit(1); } } else { + const logger = require('@angular-devkit/core/node').createConsoleLogger( + parsedArgs.verbose, + process.stdout, + process.stderr + ); try { const workflow = createWorkflow(parsedArgs.dryRun); await executeAngularDevkitSchematic( @@ -129,7 +116,7 @@ function constructCollection() { if (exists(path.join(childDir, 'schema.json'))) { generators[c] = { factory: `./${c}`, - schema: `./${normalize(path.join(c, 'schema.json'))}`, + schema: `./${normalizePath(path.join(c, 'schema.json'))}`, description: `Schematic ${c}`, }; } @@ -137,7 +124,7 @@ function constructCollection() { return { name: 'workspace-generators', version: '1.0', - schematics: generators, // TODO vsavkin: remove this + generators: generators, }; } @@ -165,29 +152,31 @@ function toolsTsConfig() { } function createWorkflow(dryRun: boolean) { - const root = normalize(rootDirectory); + const { virtualFs, schema } = require('@angular-devkit/core'); + const { NodeJsSyncHost } = require('@angular-devkit/core/node'); + const { formats } = require('@angular-devkit/schematics'); + const { NodeWorkflow } = require('@angular-devkit/schematics/tools'); + const root = normalizePath(rootDirectory); const host = new virtualFs.ScopedHost(new NodeJsSyncHost(), root); return new NodeWorkflow(host, { packageManager: detectPackageManager(), - root, dryRun, registry: new schema.CoreSchemaRegistry(formats.standardFormats), resolvePaths: [process.cwd(), rootDirectory], }); } -function listGenerators(collectionName: string, logger: logging.Logger) { +function listGenerators(collectionFile: string) { try { - const engineHost = new NodeModulesEngineHost(); - const engine = new SchematicEngine(engineHost); - const collection = engine.createCollection(collectionName); const bodyLines: string[] = []; + const collection = JSON.parse(fs.readFileSync(collectionFile).toString()); + bodyLines.push(chalk.bold(chalk.green('WORKSPACE GENERATORS'))); bodyLines.push(''); bodyLines.push( - ...Object.entries(collection.description.schematics).map( - ([schematicName, schematicMeta]) => { + ...Object.entries(collection.generators).map( + ([schematicName, schematicMeta]: [string, any]) => { return `${chalk.bold(schematicName)} : ${schematicMeta.description}`; } ) @@ -205,8 +194,8 @@ function listGenerators(collectionName: string, logger: logging.Logger) { return 0; } -function createPromptProvider(): schema.PromptProvider { - return (definitions: Array) => { +function createPromptProvider(): any { + return (definitions: Array) => { const questions: inquirer.Questions = definitions.map((definition) => { const question: inquirer.Question = { name: definition.id, @@ -252,10 +241,18 @@ function createPromptProvider(): schema.PromptProvider { async function executeAngularDevkitSchematic( schematicName: string, options: { [p: string]: any }, - workflow: NodeWorkflow, + workflow: any, outDir: string, - logger: logging.Logger + logger: any ) { + const { schema } = require('@angular-devkit/core'); + const { + validateOptionsWithSchema, + } = require('@angular-devkit/schematics/tools'); + const { + UnsuccessfulWorkflowExecution, + } = require('@angular-devkit/schematics'); + output.logSingleLine( `${output.colors.gray(`Executing your local schematic`)}: ${schematicName}` ); @@ -281,27 +278,27 @@ async function executeAngularDevkitSchematic( break; case 'update': loggingQueue.push( - tags.oneLine`${chalk.white('UPDATE')} ${eventPath} (${ + `${chalk.white('UPDATE')} ${eventPath} (${ event.content.length } bytes)` ); break; case 'create': loggingQueue.push( - tags.oneLine`${chalk.green('CREATE')} ${eventPath} (${ + `${chalk.green('CREATE')} ${eventPath} (${ event.content.length } bytes)` ); break; case 'delete': - loggingQueue.push(tags.oneLine`${chalk.yellow('DELETE')} ${eventPath}`); + loggingQueue.push(`${chalk.yellow('DELETE')} ${eventPath}`); break; case 'rename': const eventToPath = event.to.startsWith('/') ? event.to.substr(1) : event.to; loggingQueue.push( - tags.oneLine`${chalk.blue('RENAME')} ${eventPath} => ${eventToPath}` + `${chalk.blue('RENAME')} ${eventPath} => ${eventToPath}` ); break; } @@ -319,7 +316,7 @@ async function executeAngularDevkitSchematic( }); const args = options._.slice(1); - workflow.registry.addSmartDefaultProvider('argv', (schema: JsonObject) => { + workflow.registry.addSmartDefaultProvider('argv', (schema: any) => { if ('index' in schema) { return args[+schema.index]; } else { diff --git a/packages/workspace/src/command-line/workspace-integrity-checks.ts b/packages/workspace/src/command-line/workspace-integrity-checks.ts index c3a1f5be9c..0f0f7e1c0c 100644 --- a/packages/workspace/src/command-line/workspace-integrity-checks.ts +++ b/packages/workspace/src/command-line/workspace-integrity-checks.ts @@ -1,4 +1,4 @@ -import { output, CLIErrorMessageConfig } from '../utils/output'; +import { output, CLIErrorMessageConfig } from '../utilities/output'; import { ProjectGraph } from '../core/project-graph'; import { workspaceFileName } from '../core/file-utils'; diff --git a/packages/workspace/src/command-line/workspace-results.spec.ts b/packages/workspace/src/command-line/workspace-results.spec.ts index 68dae4c7f4..457a27227a 100644 --- a/packages/workspace/src/command-line/workspace-results.spec.ts +++ b/packages/workspace/src/command-line/workspace-results.spec.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import { WorkspaceResults } from './workspace-results'; -import { serializeJson } from '../utils/fileutils'; +import { serializeJson } from '../utilities/fileutils'; import { ProjectType } from '../core/project-graph'; describe('WorkspacesResults', () => { diff --git a/packages/workspace/src/command-line/workspace-results.ts b/packages/workspace/src/command-line/workspace-results.ts index 85fa36628e..4e21613a9f 100644 --- a/packages/workspace/src/command-line/workspace-results.ts +++ b/packages/workspace/src/command-line/workspace-results.ts @@ -3,16 +3,16 @@ import { directoryExists, readJsonFile, writeJsonFile, -} from '../utils/fileutils'; +} from '../utilities/fileutils'; import { existsSync, unlinkSync } from 'fs'; import { ProjectGraphNode } from '../core/project-graph'; import { join } from 'path'; -import { appRootPath } from '@nrwl/workspace/src/utils/app-root'; +import { appRootPath } from '@nrwl/workspace/src/utilities/app-root'; import * as fsExtra from 'fs-extra'; import { cacheDirectory, readCacheDirectoryProperty, -} from '../utils/cache-directory'; +} from '../utilities/cache-directory'; const resultsDir = cacheDirectory( appRootPath, diff --git a/packages/workspace/src/core/affected-project-graph/affected-project-graph.spec.ts b/packages/workspace/src/core/affected-project-graph/affected-project-graph.spec.ts index 1846ddb99f..c042fb9cdc 100644 --- a/packages/workspace/src/core/affected-project-graph/affected-project-graph.spec.ts +++ b/packages/workspace/src/core/affected-project-graph/affected-project-graph.spec.ts @@ -1,5 +1,5 @@ import { extname } from 'path'; -import { jsonDiff } from '../../utils/json-diff'; +import { jsonDiff } from '../../utilities/json-diff'; import { vol } from 'memfs'; import { stripIndents } from '@angular-devkit/core/src/utils/literals'; import { createProjectGraph } from '../project-graph'; @@ -8,7 +8,7 @@ import { FileData, WholeFileChange } from '../file-utils'; import { NxJson } from '../shared-interfaces'; jest.mock('fs', () => require('memfs').fs); -jest.mock('../../utils/app-root', () => ({ appRootPath: '/root' })); +jest.mock('../../utilities/app-root', () => ({ appRootPath: '/root' })); describe('project graph', () => { let packageJson: any; diff --git a/packages/workspace/src/core/affected-project-graph/locators/implicit-json-changes.spec.ts b/packages/workspace/src/core/affected-project-graph/locators/implicit-json-changes.spec.ts index 6fbf2c8c43..549dda7ffc 100644 --- a/packages/workspace/src/core/affected-project-graph/locators/implicit-json-changes.spec.ts +++ b/packages/workspace/src/core/affected-project-graph/locators/implicit-json-changes.spec.ts @@ -1,7 +1,7 @@ import { getImplicitlyTouchedProjectsByJsonChanges } from './implicit-json-changes'; import { NxJson } from '../../shared-interfaces'; import { WholeFileChange } from '../../file-utils'; -import { DiffType } from '../../../utils/json-diff'; +import { DiffType } from '../../../utilities/json-diff'; function getModifiedChange(path: string[]) { return { diff --git a/packages/workspace/src/core/affected-project-graph/locators/implicit-json-changes.ts b/packages/workspace/src/core/affected-project-graph/locators/implicit-json-changes.ts index ed27c95fb8..7d59134845 100644 --- a/packages/workspace/src/core/affected-project-graph/locators/implicit-json-changes.ts +++ b/packages/workspace/src/core/affected-project-graph/locators/implicit-json-changes.ts @@ -5,7 +5,7 @@ import { isJsonChange, JsonChange, walkJsonTree, -} from '../../../utils/json-diff'; +} from '../../../utilities/json-diff'; import { TouchedProjectLocator } from '../affected-project-graph-models'; import { ImplicitDependencyEntry } from '../../shared-interfaces'; diff --git a/packages/workspace/src/core/affected-project-graph/locators/npm-packages.spec.ts b/packages/workspace/src/core/affected-project-graph/locators/npm-packages.spec.ts index c210d432f1..3401a61fdd 100644 --- a/packages/workspace/src/core/affected-project-graph/locators/npm-packages.spec.ts +++ b/packages/workspace/src/core/affected-project-graph/locators/npm-packages.spec.ts @@ -1,7 +1,7 @@ import { getTouchedNpmPackages } from './npm-packages'; import { NxJson } from '../../shared-interfaces'; import { WholeFileChange } from '../../file-utils'; -import { DiffType } from '../../../utils/json-diff'; +import { DiffType } from '../../../utilities/json-diff'; import { ProjectGraph } from '../../project-graph'; describe('getTouchedNpmPackages', () => { diff --git a/packages/workspace/src/core/affected-project-graph/locators/npm-packages.ts b/packages/workspace/src/core/affected-project-graph/locators/npm-packages.ts index b5b9e0be3d..6796670353 100644 --- a/packages/workspace/src/core/affected-project-graph/locators/npm-packages.ts +++ b/packages/workspace/src/core/affected-project-graph/locators/npm-packages.ts @@ -1,5 +1,9 @@ import { isWholeFileChange, WholeFileChange } from '../../file-utils'; -import { DiffType, isJsonChange, JsonChange } from '../../../utils/json-diff'; +import { + DiffType, + isJsonChange, + JsonChange, +} from '../../../utilities/json-diff'; import { TouchedProjectLocator } from '../affected-project-graph-models'; export const getTouchedNpmPackages: TouchedProjectLocator< diff --git a/packages/workspace/src/core/affected-project-graph/locators/nx-json-changes.spec.ts b/packages/workspace/src/core/affected-project-graph/locators/nx-json-changes.spec.ts index b5d79cb44a..3b279a4b43 100644 --- a/packages/workspace/src/core/affected-project-graph/locators/nx-json-changes.spec.ts +++ b/packages/workspace/src/core/affected-project-graph/locators/nx-json-changes.spec.ts @@ -1,6 +1,6 @@ import { getTouchedProjectsInNxJson } from './nx-json-changes'; import { WholeFileChange } from '../../file-utils'; -import { DiffType } from '../../../utils/json-diff'; +import { DiffType } from '../../../utilities/json-diff'; describe('getTouchedProjectsInNxJson', () => { it('should not return changes when nx.json is not touched', () => { diff --git a/packages/workspace/src/core/affected-project-graph/locators/nx-json-changes.ts b/packages/workspace/src/core/affected-project-graph/locators/nx-json-changes.ts index 3a4e56d5d8..4ab7074a30 100644 --- a/packages/workspace/src/core/affected-project-graph/locators/nx-json-changes.ts +++ b/packages/workspace/src/core/affected-project-graph/locators/nx-json-changes.ts @@ -1,5 +1,9 @@ import { isWholeFileChange, WholeFileChange } from '../../file-utils'; -import { DiffType, isJsonChange, JsonChange } from '../../../utils/json-diff'; +import { + DiffType, + isJsonChange, + JsonChange, +} from '../../../utilities/json-diff'; import { TouchedProjectLocator } from '../affected-project-graph-models'; export const getTouchedProjectsInNxJson: TouchedProjectLocator< diff --git a/packages/workspace/src/core/affected-project-graph/locators/tsconfig-json-changes.spec.ts b/packages/workspace/src/core/affected-project-graph/locators/tsconfig-json-changes.spec.ts index aff0853898..abe782b9f1 100644 --- a/packages/workspace/src/core/affected-project-graph/locators/tsconfig-json-changes.spec.ts +++ b/packages/workspace/src/core/affected-project-graph/locators/tsconfig-json-changes.spec.ts @@ -1,5 +1,5 @@ import { WholeFileChange } from '../../file-utils'; -import { jsonDiff } from '../../../utils/json-diff'; +import { jsonDiff } from '../../../utilities/json-diff'; import { getTouchedProjectsFromTsConfig } from './tsconfig-json-changes'; import { DependencyType, ProjectGraph } from '../../project-graph'; diff --git a/packages/workspace/src/core/affected-project-graph/locators/tsconfig-json-changes.ts b/packages/workspace/src/core/affected-project-graph/locators/tsconfig-json-changes.ts index 53b3a31c25..ceedd70d17 100644 --- a/packages/workspace/src/core/affected-project-graph/locators/tsconfig-json-changes.ts +++ b/packages/workspace/src/core/affected-project-graph/locators/tsconfig-json-changes.ts @@ -1,14 +1,18 @@ import { join } from 'path'; import { WholeFileChange } from '../../file-utils'; -import { DiffType, isJsonChange, JsonChange } from '../../../utils/json-diff'; +import { + DiffType, + isJsonChange, + JsonChange, +} from '../../../utilities/json-diff'; import { TouchedProjectLocator } from '../affected-project-graph-models'; import { getSortedProjectNodes, onlyWorkspaceProjects, ProjectGraphNode, } from '../../project-graph'; -import { appRootPath } from '../../../utils/app-root'; +import { appRootPath } from '../../../utilities/app-root'; export const getTouchedProjectsFromTsConfig: TouchedProjectLocator< WholeFileChange | JsonChange diff --git a/packages/workspace/src/core/affected-project-graph/locators/workspace-json-changes.spec.ts b/packages/workspace/src/core/affected-project-graph/locators/workspace-json-changes.spec.ts index b16a7672dd..a2af75869c 100644 --- a/packages/workspace/src/core/affected-project-graph/locators/workspace-json-changes.spec.ts +++ b/packages/workspace/src/core/affected-project-graph/locators/workspace-json-changes.spec.ts @@ -1,6 +1,6 @@ import { getTouchedProjectsInWorkspaceJson } from './workspace-json-changes'; import { WholeFileChange } from '../../file-utils'; -import { DiffType } from '../../../utils/json-diff'; +import { DiffType } from '../../../utilities/json-diff'; describe('getTouchedProjectsInWorkspaceJson', () => { it('should not return changes when workspace.json is not touched', () => { diff --git a/packages/workspace/src/core/affected-project-graph/locators/workspace-json-changes.ts b/packages/workspace/src/core/affected-project-graph/locators/workspace-json-changes.ts index 1e7b9b9301..a0acb652db 100644 --- a/packages/workspace/src/core/affected-project-graph/locators/workspace-json-changes.ts +++ b/packages/workspace/src/core/affected-project-graph/locators/workspace-json-changes.ts @@ -3,7 +3,11 @@ import { WholeFileChange, workspaceFileName, } from '../../file-utils'; -import { DiffType, isJsonChange, JsonChange } from '../../../utils/json-diff'; +import { + DiffType, + isJsonChange, + JsonChange, +} from '../../../utilities/json-diff'; import { TouchedProjectLocator } from '../affected-project-graph-models'; export const getTouchedProjectsInWorkspaceJson: TouchedProjectLocator< diff --git a/packages/workspace/src/core/assert-workspace-validity.spec.ts b/packages/workspace/src/core/assert-workspace-validity.spec.ts index 6ca998ea34..41111d9cfc 100644 --- a/packages/workspace/src/core/assert-workspace-validity.spec.ts +++ b/packages/workspace/src/core/assert-workspace-validity.spec.ts @@ -1,5 +1,5 @@ import { assertWorkspaceValidity } from './assert-workspace-validity'; -import { output } from '../utils/output'; +import { output } from '../utilities/output'; describe('assertWorkspaceValidity', () => { let mockNxJson: any; diff --git a/packages/workspace/src/core/assert-workspace-validity.ts b/packages/workspace/src/core/assert-workspace-validity.ts index a5cf7ae124..ec4a90fcc4 100644 --- a/packages/workspace/src/core/assert-workspace-validity.ts +++ b/packages/workspace/src/core/assert-workspace-validity.ts @@ -3,7 +3,7 @@ import { ImplicitJsonSubsetDependency, NxJson, } from '@nrwl/workspace/src/core/shared-interfaces'; -import { output } from '../utils/output'; +import { output } from '../utilities/output'; export function assertWorkspaceValidity(workspaceJson, nxJson: NxJson) { const workspaceJsonProjects = Object.keys(workspaceJson.projects); diff --git a/packages/workspace/src/core/file-utils.spec.ts b/packages/workspace/src/core/file-utils.spec.ts index d3cf79c836..0f57b3f454 100644 --- a/packages/workspace/src/core/file-utils.spec.ts +++ b/packages/workspace/src/core/file-utils.spec.ts @@ -1,5 +1,5 @@ import { calculateFileChanges, WholeFileChange } from './file-utils'; -import { DiffType, JsonChange, jsonDiff } from '../utils/json-diff'; +import { DiffType, JsonChange, jsonDiff } from '../utilities/json-diff'; const ignore = require('ignore'); diff --git a/packages/workspace/src/core/file-utils.ts b/packages/workspace/src/core/file-utils.ts index 2b76e14c58..23be7bafee 100644 --- a/packages/workspace/src/core/file-utils.ts +++ b/packages/workspace/src/core/file-utils.ts @@ -5,9 +5,9 @@ import * as path from 'path'; import { extname, join } from 'path'; import { NxArgs } from '../command-line/utils'; import { WorkspaceResults } from '../command-line/workspace-results'; -import { appRootPath } from '../utils/app-root'; -import { fileExists, readJsonFile } from '../utils/fileutils'; -import { jsonDiff } from '../utils/json-diff'; +import { appRootPath } from '../utilities/app-root'; +import { fileExists, readJsonFile } from '../utilities/fileutils'; +import { jsonDiff } from '../utilities/json-diff'; import { ProjectGraphNode } from './project-graph'; import { Environment, NxJson } from './shared-interfaces'; import { defaultFileHasher } from './hasher/file-hasher'; diff --git a/packages/workspace/src/core/hasher/file-hasher.ts b/packages/workspace/src/core/hasher/file-hasher.ts index ccef046f45..86a94d576a 100644 --- a/packages/workspace/src/core/hasher/file-hasher.ts +++ b/packages/workspace/src/core/hasher/file-hasher.ts @@ -1,7 +1,7 @@ import { getFileHashes } from './git-hasher'; import { readFileSync } from 'fs'; import { defaultHashing, HashingImp } from './hashing-impl'; -import { appRootPath } from '../../utils/app-root'; +import { appRootPath } from '../../utilities/app-root'; import { performance } from 'perf_hooks'; type PathAndTransformer = { diff --git a/packages/workspace/src/core/nx-deps/nx-deps-cache.ts b/packages/workspace/src/core/nx-deps/nx-deps-cache.ts index a7498d853c..e8299b0405 100644 --- a/packages/workspace/src/core/nx-deps/nx-deps-cache.ts +++ b/packages/workspace/src/core/nx-deps/nx-deps-cache.ts @@ -5,7 +5,7 @@ import { ProjectGraphNode, } from '../project-graph'; import { join } from 'path'; -import { appRootPath } from '../../utils/app-root'; +import { appRootPath } from '../../utilities/app-root'; import { existsSync } from 'fs'; import * as fsExtra from 'fs-extra'; import { @@ -13,13 +13,13 @@ import { fileExists, readJsonFile, writeJsonFile, -} from '../../utils/fileutils'; +} from '../../utilities/fileutils'; import { FileMap } from '@nrwl/workspace/src/core/file-graph'; import { performance } from 'perf_hooks'; import { cacheDirectory, readCacheDirectoryProperty, -} from '../../utils/cache-directory'; +} from '../../utilities/cache-directory'; export interface ProjectGraphCache { version: string; diff --git a/packages/workspace/src/core/project-graph/build-dependencies/explicit-project-dependencies.spec.ts b/packages/workspace/src/core/project-graph/build-dependencies/explicit-project-dependencies.spec.ts index 500e09a2c5..29652b8853 100644 --- a/packages/workspace/src/core/project-graph/build-dependencies/explicit-project-dependencies.spec.ts +++ b/packages/workspace/src/core/project-graph/build-dependencies/explicit-project-dependencies.spec.ts @@ -1,4 +1,4 @@ -jest.mock('../../../utils/app-root', () => ({ +jest.mock('../../../utilities/app-root', () => ({ appRootPath: '/root', })); jest.mock('fs', () => require('memfs').fs); @@ -13,7 +13,7 @@ import { import { buildExplicitTypeScriptDependencies } from './explicit-project-dependencies'; import { createFileMap } from '../../file-graph'; import { readWorkspaceFiles } from '../../file-utils'; -import { appRootPath } from '../../../utils/app-root'; +import { appRootPath } from '../../../utilities/app-root'; import { string } from 'prop-types'; describe('explicit project dependencies', () => { diff --git a/packages/workspace/src/core/project-graph/build-dependencies/typescript-import-locator.ts b/packages/workspace/src/core/project-graph/build-dependencies/typescript-import-locator.ts index 0470b00665..216599f1ad 100644 --- a/packages/workspace/src/core/project-graph/build-dependencies/typescript-import-locator.ts +++ b/packages/workspace/src/core/project-graph/build-dependencies/typescript-import-locator.ts @@ -1,7 +1,7 @@ import * as ts from 'typescript'; import * as path from 'path'; import { DependencyType } from '../project-graph-models'; -import { stripSourceCode } from '../../../utils/strip-source-code'; +import { stripSourceCode } from '../../../utilities/strip-source-code'; import { FileRead } from '../../file-utils'; export class TypeScriptImportLocator { diff --git a/packages/workspace/src/core/project-graph/project-graph.spec.ts b/packages/workspace/src/core/project-graph/project-graph.spec.ts index fe8028f98d..2e1d09627f 100644 --- a/packages/workspace/src/core/project-graph/project-graph.spec.ts +++ b/packages/workspace/src/core/project-graph/project-graph.spec.ts @@ -1,6 +1,6 @@ import { vol, fs } from 'memfs'; jest.mock('fs', () => require('memfs').fs); -jest.mock('../../utils/app-root', () => ({ appRootPath: '/root' })); +jest.mock('../../utilities/app-root', () => ({ appRootPath: '/root' })); import { stripIndents } from '@angular-devkit/core/src/utils/literals'; import { createProjectGraph } from './project-graph'; diff --git a/packages/workspace/src/core/target-project-locator.spec.ts b/packages/workspace/src/core/target-project-locator.spec.ts index 2c4bf8790c..25d5c5b6a0 100644 --- a/packages/workspace/src/core/target-project-locator.spec.ts +++ b/packages/workspace/src/core/target-project-locator.spec.ts @@ -5,7 +5,7 @@ import { } from './project-graph/project-graph-models'; import { TargetProjectLocator } from './target-project-locator'; -jest.mock('../utils/app-root', () => ({ +jest.mock('../utilities/app-root', () => ({ appRootPath: '/root', })); jest.mock('fs', () => require('memfs').fs); diff --git a/packages/workspace/src/core/target-project-locator.ts b/packages/workspace/src/core/target-project-locator.ts index ab98c49dfd..c59eec7dd9 100644 --- a/packages/workspace/src/core/target-project-locator.ts +++ b/packages/workspace/src/core/target-project-locator.ts @@ -1,4 +1,4 @@ -import { resolveModuleByImport } from '../utils/typescript'; +import { resolveModuleByImport } from '../utilities/typescript'; import { defaultFileRead, FileRead, normalizedProjectRoot } from './file-utils'; import { ProjectGraphNode, @@ -9,9 +9,9 @@ import { isNpmProject, isWorkspaceProject, } from './project-graph'; -import { isRelativePath, parseJsonWithComments } from '../utils/fileutils'; +import { isRelativePath, parseJsonWithComments } from '../utilities/fileutils'; import { dirname, join } from 'path'; -import { appRootPath } from '@nrwl/workspace/src/utils/app-root'; +import { appRootPath } from '@nrwl/workspace/src/utilities/app-root'; export class TargetProjectLocator { private sortedProjects = getSortedProjectNodes(this.nodes); diff --git a/packages/workspace/src/schematics/init/__snapshots__/init.spec.ts.snap b/packages/workspace/src/generators/init/__snapshots__/init.spec.ts.snap similarity index 100% rename from packages/workspace/src/schematics/init/__snapshots__/init.spec.ts.snap rename to packages/workspace/src/generators/init/__snapshots__/init.spec.ts.snap diff --git a/packages/workspace/src/schematics/init/files/prettier/.prettierignore b/packages/workspace/src/generators/init/files/prettier/.prettierignore similarity index 100% rename from packages/workspace/src/schematics/init/files/prettier/.prettierignore rename to packages/workspace/src/generators/init/files/prettier/.prettierignore diff --git a/packages/workspace/src/schematics/init/files/root/karma.conf.js b/packages/workspace/src/generators/init/files/root/karma.conf.js similarity index 100% rename from packages/workspace/src/schematics/init/files/root/karma.conf.js rename to packages/workspace/src/generators/init/files/root/karma.conf.js diff --git a/packages/workspace/src/schematics/init/files/root/tools/schematics/.gitkeep b/packages/workspace/src/generators/init/files/root/tools/schematics/.gitkeep similarity index 100% rename from packages/workspace/src/schematics/init/files/root/tools/schematics/.gitkeep rename to packages/workspace/src/generators/init/files/root/tools/schematics/.gitkeep diff --git a/packages/workspace/src/schematics/init/files/root/tools/tsconfig.tools.json b/packages/workspace/src/generators/init/files/root/tools/tsconfig.tools.json similarity index 100% rename from packages/workspace/src/schematics/init/files/root/tools/tsconfig.tools.json rename to packages/workspace/src/generators/init/files/root/tools/tsconfig.tools.json diff --git a/packages/workspace/src/schematics/init/init.spec.ts b/packages/workspace/src/generators/init/init.spec.ts similarity index 99% rename from packages/workspace/src/schematics/init/init.spec.ts rename to packages/workspace/src/generators/init/init.spec.ts index 98f6a5581f..951c5bf2f9 100644 --- a/packages/workspace/src/schematics/init/init.spec.ts +++ b/packages/workspace/src/generators/init/init.spec.ts @@ -293,6 +293,7 @@ describe('workspace', () => { expect(tree.exists('/apps/myApp/tsconfig.app.json')).toBe(true); expect(tree.exists('/apps/myApp/karma.conf.js')).toBe(true); + expect(tree.exists('/karma.conf.js')).toBe(true); }); diff --git a/packages/workspace/src/schematics/init/init.ts b/packages/workspace/src/generators/init/init.ts similarity index 89% rename from packages/workspace/src/schematics/init/init.ts rename to packages/workspace/src/generators/init/init.ts index 62317e86a0..984d6683df 100755 --- a/packages/workspace/src/schematics/init/init.ts +++ b/packages/workspace/src/generators/init/init.ts @@ -17,9 +17,10 @@ import { updateWorkspaceConfiguration, visitNotIgnoredFiles, writeJson, + normalizePath, + joinPathFragments, } from '@nrwl/devkit'; -import { basename, join } from 'path'; -import { JsonArray, normalize } from '@angular-devkit/core'; +import { basename } from 'path'; import { Schema } from './schema'; import { angularCliVersion, @@ -28,8 +29,8 @@ import { } from '../../utils/versions'; import { DEFAULT_NRWL_PRETTIER_CONFIG } from '../workspace/workspace'; import { readFileSync } from 'fs'; -import { serializeJson } from '../../utils/fileutils'; -import { resolveUserExistingPrettierConfig } from '../../utils/common'; +import { serializeJson } from '../../utilities/fileutils'; +import { resolveUserExistingPrettierConfig } from '../../utilities/prettier'; function updatePackageJson(tree) { updateJson(tree, 'package.json', (packageJson) => { @@ -90,19 +91,20 @@ function updateAngularCLIJson(host: Tree, options: Schema) { const workspaceConfig = readWorkspaceConfiguration(host); const appName = workspaceConfig.defaultProject; const e2eName = appName + '-e2e'; - const e2eRoot = join('apps', e2eName); + const e2eRoot = joinPathFragments('apps', e2eName); delete (workspaceConfig as any).newProjectRoot; const defaultProject = readProjectConfiguration(host, appName); const oldSourceRoot = defaultProject.sourceRoot; - const newRoot = join('apps', appName); + const newRoot = joinPathFragments('apps', appName); defaultProject.root = newRoot; - defaultProject.sourceRoot = join(newRoot, 'src'); + defaultProject.sourceRoot = joinPathFragments(newRoot, 'src'); function convertBuildOptions(buildOptions) { buildOptions.outputPath = - buildOptions.outputPath && join(normalize('dist'), 'apps', appName); + buildOptions.outputPath && + joinPathFragments(normalizePath('dist'), 'apps', appName); buildOptions.index = buildOptions.index && convertAsset(buildOptions.index as string); buildOptions.main = @@ -110,16 +112,13 @@ function updateAngularCLIJson(host: Tree, options: Schema) { buildOptions.polyfills = buildOptions.polyfills && convertAsset(buildOptions.polyfills as string); buildOptions.tsConfig = - buildOptions.tsConfig && join(newRoot, 'tsconfig.app.json'); + buildOptions.tsConfig && joinPathFragments(newRoot, 'tsconfig.app.json'); buildOptions.assets = - buildOptions.assets && - (buildOptions.assets as JsonArray).map(convertAsset); + buildOptions.assets && (buildOptions.assets as any).map(convertAsset); buildOptions.styles = - buildOptions.styles && - (buildOptions.styles as JsonArray).map(convertAsset); + buildOptions.styles && (buildOptions.styles as any).map(convertAsset); buildOptions.scripts = - buildOptions.scripts && - (buildOptions.scripts as JsonArray).map(convertAsset); + buildOptions.scripts && (buildOptions.scripts as any).map(convertAsset); buildOptions.fileReplacements = buildOptions.fileReplacements && buildOptions.fileReplacements.map((replacement) => ({ @@ -137,34 +136,37 @@ function updateAngularCLIJson(host: Tree, options: Schema) { testOptions.main = testOptions.main && convertAsset(testOptions.main); testOptions.polyfills = testOptions.polyfills && convertAsset(testOptions.polyfills); - testOptions.tsConfig = join(newRoot, 'tsconfig.spec.json'); - testOptions.karmaConfig = join(newRoot, 'karma.conf.js'); + testOptions.tsConfig = joinPathFragments(newRoot, 'tsconfig.spec.json'); + testOptions.karmaConfig = joinPathFragments(newRoot, 'karma.conf.js'); testOptions.assets = - testOptions.assets && (testOptions.assets as JsonArray).map(convertAsset); + testOptions.assets && (testOptions.assets as any).map(convertAsset); testOptions.styles = - testOptions.styles && (testOptions.styles as JsonArray).map(convertAsset); + testOptions.styles && (testOptions.styles as any).map(convertAsset); testOptions.scripts = - testOptions.scripts && - (testOptions.scripts as JsonArray).map(convertAsset); + testOptions.scripts && (testOptions.scripts as any).map(convertAsset); } const lintTarget = defaultProject.targets.lint; if (lintTarget) { lintTarget.options.tsConfig = [ - join(newRoot, 'tsconfig.app.json'), - join(newRoot, 'tsconfig.spec.json'), + joinPathFragments(newRoot, 'tsconfig.app.json'), + joinPathFragments(newRoot, 'tsconfig.spec.json'), ]; } function convertServerOptions(serverOptions) { serverOptions.outputPath = serverOptions.outputPath && - join(normalize('dist'), 'apps', options.name + '-server'); + joinPathFragments( + normalizePath('dist'), + 'apps', + options.name + '-server' + ); serverOptions.main = serverOptions.main && convertAsset(serverOptions.main); serverOptions.tsConfig = serverOptions.tsConfig && - join(normalize('apps'), appName, 'tsconfig.server.json'); + joinPathFragments(normalizePath('apps'), appName, 'tsconfig.server.json'); serverOptions.fileReplacements = serverOptions.fileReplacements && serverOptions.fileReplacements.map((replacement) => ({ @@ -191,14 +193,14 @@ function updateAngularCLIJson(host: Tree, options: Schema) { ...defaultProject.targets.e2e, options: { ...defaultProject.targets.e2e.options, - protractorConfig: join(e2eRoot, 'protractor.conf.js'), + protractorConfig: joinPathFragments(e2eRoot, 'protractor.conf.js'), }, }, lint: { executor: '@angular-devkit/build-angular:tslint', options: { ...lintTargetOptions, - tsConfig: join(e2eRoot, 'tsconfig.json'), + tsConfig: joinPathFragments(e2eRoot, 'tsconfig.json'), }, }, }, @@ -349,7 +351,9 @@ function moveOutOfSrc( } const filename = !!filePath ? basename(filePath) : ''; const from = filePath; - const to = filename ? join('apps', appName, filename) : join('apps', appName); + const to = filename + ? joinPathFragments('apps', appName, filename) + : joinPathFragments('apps', appName); renameSyncInTree(tree, from, to, required); } @@ -395,11 +399,14 @@ function moveExistingFiles(host: Tree, options: Schema) { moveOutOfSrc(host, options.name, app.architect.server.options.tsConfig); } const oldAppSourceRoot = app.sourceRoot; - const newAppSourceRoot = join('apps', options.name, 'src'); + const newAppSourceRoot = joinPathFragments('apps', options.name, 'src'); renameDirSyncInTree(host, oldAppSourceRoot, newAppSourceRoot); if (e2eApp) { - const oldE2eRoot = join(app.root || '', 'e2e'); - const newE2eRoot = join('apps', getE2eKey(workspaceJson) + '-e2e'); + const oldE2eRoot = joinPathFragments(app.root || '', 'e2e'); + const newE2eRoot = joinPathFragments( + 'apps', + getE2eKey(workspaceJson) + '-e2e' + ); renameDirSyncInTree(host, oldE2eRoot, newE2eRoot); } else { console.warn( @@ -562,7 +569,12 @@ function createNxJson(host: Tree) { function decorateAngularClI(host: Tree) { const decorateCli = readFileSync( - join(__dirname as any, '..', 'utils', 'decorate-angular-cli.js__tmpl__') + joinPathFragments( + __dirname as any, + '..', + 'utils', + 'decorate-angular-cli.js__tmpl__' + ) ).toString(); host.write('decorate-angular-cli.js', decorateCli); updateJson(host, 'package.json', (json) => { @@ -586,12 +598,12 @@ function decorateAngularClI(host: Tree) { } function addFiles(host: Tree) { - generateFiles(host, join(__dirname, './files/root'), '.', { + generateFiles(host, joinPathFragments(__dirname, './files/root'), '.', { tmpl: '', }); if (!host.exists('.prettierignore')) { - generateFiles(host, join(__dirname, './files/prettier'), '.', { + generateFiles(host, joinPathFragments(__dirname, './files/prettier'), '.', { tmpl: '', }); } diff --git a/packages/workspace/src/schematics/init/schema.d.ts b/packages/workspace/src/generators/init/schema.d.ts similarity index 100% rename from packages/workspace/src/schematics/init/schema.d.ts rename to packages/workspace/src/generators/init/schema.d.ts diff --git a/packages/workspace/src/schematics/init/schema.json b/packages/workspace/src/generators/init/schema.json similarity index 100% rename from packages/workspace/src/schematics/init/schema.json rename to packages/workspace/src/generators/init/schema.json diff --git a/packages/workspace/src/schematics/library/files/lib/README.md b/packages/workspace/src/generators/library/files/lib/README.md similarity index 100% rename from packages/workspace/src/schematics/library/files/lib/README.md rename to packages/workspace/src/generators/library/files/lib/README.md diff --git a/packages/workspace/src/schematics/library/files/lib/src/index.ts__tmpl__ b/packages/workspace/src/generators/library/files/lib/src/index.ts__tmpl__ similarity index 100% rename from packages/workspace/src/schematics/library/files/lib/src/index.ts__tmpl__ rename to packages/workspace/src/generators/library/files/lib/src/index.ts__tmpl__ diff --git a/packages/workspace/src/schematics/library/files/lib/src/lib/__fileName__.spec.ts__tmpl__ b/packages/workspace/src/generators/library/files/lib/src/lib/__fileName__.spec.ts__tmpl__ similarity index 100% rename from packages/workspace/src/schematics/library/files/lib/src/lib/__fileName__.spec.ts__tmpl__ rename to packages/workspace/src/generators/library/files/lib/src/lib/__fileName__.spec.ts__tmpl__ diff --git a/packages/workspace/src/schematics/library/files/lib/src/lib/__fileName__.ts__tmpl__ b/packages/workspace/src/generators/library/files/lib/src/lib/__fileName__.ts__tmpl__ similarity index 100% rename from packages/workspace/src/schematics/library/files/lib/src/lib/__fileName__.ts__tmpl__ rename to packages/workspace/src/generators/library/files/lib/src/lib/__fileName__.ts__tmpl__ diff --git a/packages/workspace/src/schematics/library/files/lib/tsconfig.json b/packages/workspace/src/generators/library/files/lib/tsconfig.json similarity index 100% rename from packages/workspace/src/schematics/library/files/lib/tsconfig.json rename to packages/workspace/src/generators/library/files/lib/tsconfig.json diff --git a/packages/workspace/src/schematics/library/files/lib/tsconfig.lib.json b/packages/workspace/src/generators/library/files/lib/tsconfig.lib.json similarity index 100% rename from packages/workspace/src/schematics/library/files/lib/tsconfig.lib.json rename to packages/workspace/src/generators/library/files/lib/tsconfig.lib.json diff --git a/packages/workspace/src/schematics/library/library.spec.ts b/packages/workspace/src/generators/library/library.spec.ts similarity index 100% rename from packages/workspace/src/schematics/library/library.spec.ts rename to packages/workspace/src/generators/library/library.spec.ts diff --git a/packages/workspace/src/schematics/library/library.ts b/packages/workspace/src/generators/library/library.ts similarity index 100% rename from packages/workspace/src/schematics/library/library.ts rename to packages/workspace/src/generators/library/library.ts diff --git a/packages/workspace/src/schematics/library/schema.d.ts b/packages/workspace/src/generators/library/schema.d.ts similarity index 100% rename from packages/workspace/src/schematics/library/schema.d.ts rename to packages/workspace/src/generators/library/schema.d.ts diff --git a/packages/workspace/src/schematics/library/schema.json b/packages/workspace/src/generators/library/schema.json similarity index 100% rename from packages/workspace/src/schematics/library/schema.json rename to packages/workspace/src/generators/library/schema.json diff --git a/packages/workspace/src/schematics/move/lib/__snapshots__/update-imports.spec.ts.snap b/packages/workspace/src/generators/move/lib/__snapshots__/update-imports.spec.ts.snap similarity index 100% rename from packages/workspace/src/schematics/move/lib/__snapshots__/update-imports.spec.ts.snap rename to packages/workspace/src/generators/move/lib/__snapshots__/update-imports.spec.ts.snap diff --git a/packages/workspace/src/schematics/move/lib/check-destination.spec.ts b/packages/workspace/src/generators/move/lib/check-destination.spec.ts similarity index 100% rename from packages/workspace/src/schematics/move/lib/check-destination.spec.ts rename to packages/workspace/src/generators/move/lib/check-destination.spec.ts diff --git a/packages/workspace/src/schematics/move/lib/check-destination.ts b/packages/workspace/src/generators/move/lib/check-destination.ts similarity index 100% rename from packages/workspace/src/schematics/move/lib/check-destination.ts rename to packages/workspace/src/generators/move/lib/check-destination.ts diff --git a/packages/workspace/src/schematics/move/lib/move-project-configuration.spec.ts b/packages/workspace/src/generators/move/lib/move-project-configuration.spec.ts similarity index 98% rename from packages/workspace/src/schematics/move/lib/move-project-configuration.spec.ts rename to packages/workspace/src/generators/move/lib/move-project-configuration.spec.ts index afd862011f..6b060a9478 100644 --- a/packages/workspace/src/schematics/move/lib/move-project-configuration.spec.ts +++ b/packages/workspace/src/generators/move/lib/move-project-configuration.spec.ts @@ -8,7 +8,7 @@ import { import { NxJson } from '@nrwl/workspace'; import { Schema } from '../schema'; import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; -import { moveProjectConfiguration } from '@nrwl/workspace/src/schematics/move/lib/move-project-configuration'; +import { moveProjectConfiguration } from '@nrwl/workspace/src/generators/move/lib/move-project-configuration'; describe('moveProjectConfiguration', () => { let tree: Tree; diff --git a/packages/workspace/src/schematics/move/lib/move-project-configuration.ts b/packages/workspace/src/generators/move/lib/move-project-configuration.ts similarity index 100% rename from packages/workspace/src/schematics/move/lib/move-project-configuration.ts rename to packages/workspace/src/generators/move/lib/move-project-configuration.ts diff --git a/packages/workspace/src/schematics/move/lib/move-project.spec.ts b/packages/workspace/src/generators/move/lib/move-project.spec.ts similarity index 94% rename from packages/workspace/src/schematics/move/lib/move-project.spec.ts rename to packages/workspace/src/generators/move/lib/move-project.spec.ts index 39079d8122..f71b88cbc2 100644 --- a/packages/workspace/src/schematics/move/lib/move-project.spec.ts +++ b/packages/workspace/src/generators/move/lib/move-project.spec.ts @@ -6,7 +6,7 @@ import { import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; import { Schema } from '../schema'; import { libraryGenerator } from '../../library/library'; -import { moveProject } from '@nrwl/workspace/src/schematics/move/lib/move-project'; +import { moveProject } from '@nrwl/workspace/src/generators/move/lib/move-project'; describe('moveProject', () => { let tree: Tree; diff --git a/packages/workspace/src/schematics/move/lib/move-project.ts b/packages/workspace/src/generators/move/lib/move-project.ts similarity index 80% rename from packages/workspace/src/schematics/move/lib/move-project.ts rename to packages/workspace/src/generators/move/lib/move-project.ts index 1fbaaa862b..4318ec2cd8 100644 --- a/packages/workspace/src/schematics/move/lib/move-project.ts +++ b/packages/workspace/src/generators/move/lib/move-project.ts @@ -1,8 +1,4 @@ -import { SchematicContext } from '@angular-devkit/schematics'; import { ProjectConfiguration, Tree, visitNotIgnoredFiles } from '@nrwl/devkit'; -import { getWorkspace } from '@nrwl/workspace'; -import { from, Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; import { Schema } from '../schema'; import { getDestination } from './utils'; diff --git a/packages/workspace/src/schematics/move/lib/update-build-targets.spec.ts b/packages/workspace/src/generators/move/lib/update-build-targets.spec.ts similarity index 100% rename from packages/workspace/src/schematics/move/lib/update-build-targets.spec.ts rename to packages/workspace/src/generators/move/lib/update-build-targets.spec.ts diff --git a/packages/workspace/src/schematics/move/lib/update-build-targets.ts b/packages/workspace/src/generators/move/lib/update-build-targets.ts similarity index 100% rename from packages/workspace/src/schematics/move/lib/update-build-targets.ts rename to packages/workspace/src/generators/move/lib/update-build-targets.ts diff --git a/packages/workspace/src/schematics/move/lib/update-cypress-json.spec.ts b/packages/workspace/src/generators/move/lib/update-cypress-json.spec.ts similarity index 100% rename from packages/workspace/src/schematics/move/lib/update-cypress-json.spec.ts rename to packages/workspace/src/generators/move/lib/update-cypress-json.spec.ts diff --git a/packages/workspace/src/schematics/move/lib/update-cypress-json.ts b/packages/workspace/src/generators/move/lib/update-cypress-json.ts similarity index 100% rename from packages/workspace/src/schematics/move/lib/update-cypress-json.ts rename to packages/workspace/src/generators/move/lib/update-cypress-json.ts diff --git a/packages/workspace/src/schematics/move/lib/update-default-project.spec.ts b/packages/workspace/src/generators/move/lib/update-default-project.spec.ts similarity index 85% rename from packages/workspace/src/schematics/move/lib/update-default-project.spec.ts rename to packages/workspace/src/generators/move/lib/update-default-project.spec.ts index d37eb6fbb7..af72f5d450 100644 --- a/packages/workspace/src/schematics/move/lib/update-default-project.spec.ts +++ b/packages/workspace/src/generators/move/lib/update-default-project.spec.ts @@ -1,4 +1,4 @@ -import { Schema } from '@nrwl/workspace/src/schematics/move/schema'; +import { Schema } from '@nrwl/workspace/src/generators/move/schema'; import { addProjectConfiguration, readWorkspaceConfiguration, @@ -6,7 +6,7 @@ import { updateWorkspaceConfiguration, } from '@nrwl/devkit'; import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; -import { updateDefaultProject } from '@nrwl/workspace/src/schematics/move/lib/update-default-project'; +import { updateDefaultProject } from '@nrwl/workspace/src/generators/move/lib/update-default-project'; describe('updateDefaultProject', () => { let tree: Tree; diff --git a/packages/workspace/src/schematics/move/lib/update-default-project.ts b/packages/workspace/src/generators/move/lib/update-default-project.ts similarity index 100% rename from packages/workspace/src/schematics/move/lib/update-default-project.ts rename to packages/workspace/src/generators/move/lib/update-default-project.ts diff --git a/packages/workspace/src/schematics/move/lib/update-eslintrc-json.spec.ts b/packages/workspace/src/generators/move/lib/update-eslintrc-json.spec.ts similarity index 100% rename from packages/workspace/src/schematics/move/lib/update-eslintrc-json.spec.ts rename to packages/workspace/src/generators/move/lib/update-eslintrc-json.spec.ts diff --git a/packages/workspace/src/schematics/move/lib/update-eslintrc-json.ts b/packages/workspace/src/generators/move/lib/update-eslintrc-json.ts similarity index 100% rename from packages/workspace/src/schematics/move/lib/update-eslintrc-json.ts rename to packages/workspace/src/generators/move/lib/update-eslintrc-json.ts diff --git a/packages/workspace/src/schematics/move/lib/update-implicit-dependencies.spec.ts b/packages/workspace/src/generators/move/lib/update-implicit-dependencies.spec.ts similarity index 100% rename from packages/workspace/src/schematics/move/lib/update-implicit-dependencies.spec.ts rename to packages/workspace/src/generators/move/lib/update-implicit-dependencies.spec.ts diff --git a/packages/workspace/src/schematics/move/lib/update-implicit-dependencies.ts b/packages/workspace/src/generators/move/lib/update-implicit-dependencies.ts similarity index 100% rename from packages/workspace/src/schematics/move/lib/update-implicit-dependencies.ts rename to packages/workspace/src/generators/move/lib/update-implicit-dependencies.ts diff --git a/packages/workspace/src/schematics/move/lib/update-imports.spec.ts b/packages/workspace/src/generators/move/lib/update-imports.spec.ts similarity index 100% rename from packages/workspace/src/schematics/move/lib/update-imports.spec.ts rename to packages/workspace/src/generators/move/lib/update-imports.spec.ts diff --git a/packages/workspace/src/schematics/move/lib/update-imports.ts b/packages/workspace/src/generators/move/lib/update-imports.ts similarity index 100% rename from packages/workspace/src/schematics/move/lib/update-imports.ts rename to packages/workspace/src/generators/move/lib/update-imports.ts diff --git a/packages/workspace/src/schematics/move/lib/update-jest-config.spec.ts b/packages/workspace/src/generators/move/lib/update-jest-config.spec.ts similarity index 100% rename from packages/workspace/src/schematics/move/lib/update-jest-config.spec.ts rename to packages/workspace/src/generators/move/lib/update-jest-config.spec.ts diff --git a/packages/workspace/src/schematics/move/lib/update-jest-config.ts b/packages/workspace/src/generators/move/lib/update-jest-config.ts similarity index 100% rename from packages/workspace/src/schematics/move/lib/update-jest-config.ts rename to packages/workspace/src/generators/move/lib/update-jest-config.ts diff --git a/packages/workspace/src/schematics/move/lib/update-project-root-files.spec.ts b/packages/workspace/src/generators/move/lib/update-project-root-files.spec.ts similarity index 100% rename from packages/workspace/src/schematics/move/lib/update-project-root-files.spec.ts rename to packages/workspace/src/generators/move/lib/update-project-root-files.spec.ts diff --git a/packages/workspace/src/schematics/move/lib/update-project-root-files.ts b/packages/workspace/src/generators/move/lib/update-project-root-files.ts similarity index 95% rename from packages/workspace/src/schematics/move/lib/update-project-root-files.ts rename to packages/workspace/src/generators/move/lib/update-project-root-files.ts index 0ed72565e8..55d79c660b 100644 --- a/packages/workspace/src/schematics/move/lib/update-project-root-files.ts +++ b/packages/workspace/src/generators/move/lib/update-project-root-files.ts @@ -2,7 +2,7 @@ import * as path from 'path'; import { ProjectConfiguration, Tree } from '@nrwl/devkit'; -import { appRootPath } from '../../../utils/app-root'; +import { appRootPath } from '../../../utilities/app-root'; import { Schema } from '../schema'; import { getDestination } from './utils'; import { extname, join } from 'path'; diff --git a/packages/workspace/src/schematics/move/lib/update-storybook-config.spec.ts b/packages/workspace/src/generators/move/lib/update-storybook-config.spec.ts similarity index 100% rename from packages/workspace/src/schematics/move/lib/update-storybook-config.spec.ts rename to packages/workspace/src/generators/move/lib/update-storybook-config.spec.ts diff --git a/packages/workspace/src/schematics/move/lib/update-storybook-config.ts b/packages/workspace/src/generators/move/lib/update-storybook-config.ts similarity index 95% rename from packages/workspace/src/schematics/move/lib/update-storybook-config.ts rename to packages/workspace/src/generators/move/lib/update-storybook-config.ts index 72003dc7f0..14e9060566 100644 --- a/packages/workspace/src/schematics/move/lib/update-storybook-config.ts +++ b/packages/workspace/src/generators/move/lib/update-storybook-config.ts @@ -2,7 +2,7 @@ import { ProjectConfiguration, Tree } from '@nrwl/devkit'; import * as path from 'path'; -import { appRootPath } from '../../../utils/app-root'; +import { appRootPath } from '../../../utilities/app-root'; import { Schema } from '../schema'; import { getDestination } from './utils'; import { join } from 'path'; diff --git a/packages/workspace/src/schematics/move/lib/utils.ts b/packages/workspace/src/generators/move/lib/utils.ts similarity index 100% rename from packages/workspace/src/schematics/move/lib/utils.ts rename to packages/workspace/src/generators/move/lib/utils.ts diff --git a/packages/workspace/src/schematics/move/move.ts b/packages/workspace/src/generators/move/move.ts similarity index 100% rename from packages/workspace/src/schematics/move/move.ts rename to packages/workspace/src/generators/move/move.ts diff --git a/packages/workspace/src/schematics/move/schema.d.ts b/packages/workspace/src/generators/move/schema.d.ts similarity index 100% rename from packages/workspace/src/schematics/move/schema.d.ts rename to packages/workspace/src/generators/move/schema.d.ts diff --git a/packages/workspace/src/schematics/move/schema.json b/packages/workspace/src/generators/move/schema.json similarity index 100% rename from packages/workspace/src/schematics/move/schema.json rename to packages/workspace/src/generators/move/schema.json diff --git a/packages/workspace/src/schematics/new/__snapshots__/new.spec.ts.snap b/packages/workspace/src/generators/new/__snapshots__/new.spec.ts.snap similarity index 100% rename from packages/workspace/src/schematics/new/__snapshots__/new.spec.ts.snap rename to packages/workspace/src/generators/new/__snapshots__/new.spec.ts.snap diff --git a/packages/workspace/src/schematics/new/new.spec.ts b/packages/workspace/src/generators/new/new.spec.ts similarity index 100% rename from packages/workspace/src/schematics/new/new.spec.ts rename to packages/workspace/src/generators/new/new.spec.ts diff --git a/packages/workspace/src/schematics/new/new.ts b/packages/workspace/src/generators/new/new.ts similarity index 100% rename from packages/workspace/src/schematics/new/new.ts rename to packages/workspace/src/generators/new/new.ts diff --git a/packages/workspace/src/schematics/new/schema.json b/packages/workspace/src/generators/new/schema.json similarity index 100% rename from packages/workspace/src/schematics/new/schema.json rename to packages/workspace/src/generators/new/schema.json diff --git a/packages/workspace/src/schematics/preset/files/angular/app.module.ts b/packages/workspace/src/generators/preset/files/angular/app.module.ts similarity index 100% rename from packages/workspace/src/schematics/preset/files/angular/app.module.ts rename to packages/workspace/src/generators/preset/files/angular/app.module.ts diff --git a/packages/workspace/src/schematics/preset/preset.spec.ts b/packages/workspace/src/generators/preset/preset.spec.ts similarity index 100% rename from packages/workspace/src/schematics/preset/preset.spec.ts rename to packages/workspace/src/generators/preset/preset.spec.ts diff --git a/packages/workspace/src/schematics/preset/preset.ts b/packages/workspace/src/generators/preset/preset.ts similarity index 100% rename from packages/workspace/src/schematics/preset/preset.ts rename to packages/workspace/src/generators/preset/preset.ts diff --git a/packages/workspace/src/schematics/preset/schema.d.ts b/packages/workspace/src/generators/preset/schema.d.ts similarity index 100% rename from packages/workspace/src/schematics/preset/schema.d.ts rename to packages/workspace/src/generators/preset/schema.d.ts diff --git a/packages/workspace/src/schematics/preset/schema.json b/packages/workspace/src/generators/preset/schema.json similarity index 100% rename from packages/workspace/src/schematics/preset/schema.json rename to packages/workspace/src/generators/preset/schema.json diff --git a/packages/workspace/src/schematics/remove/lib/__snapshots__/update-jest-config.spec.ts.snap b/packages/workspace/src/generators/remove/lib/__snapshots__/update-jest-config.spec.ts.snap similarity index 100% rename from packages/workspace/src/schematics/remove/lib/__snapshots__/update-jest-config.spec.ts.snap rename to packages/workspace/src/generators/remove/lib/__snapshots__/update-jest-config.spec.ts.snap diff --git a/packages/workspace/src/schematics/remove/lib/check-dependencies.spec.ts b/packages/workspace/src/generators/remove/lib/check-dependencies.spec.ts similarity index 100% rename from packages/workspace/src/schematics/remove/lib/check-dependencies.spec.ts rename to packages/workspace/src/generators/remove/lib/check-dependencies.spec.ts diff --git a/packages/workspace/src/schematics/remove/lib/check-dependencies.ts b/packages/workspace/src/generators/remove/lib/check-dependencies.ts similarity index 90% rename from packages/workspace/src/schematics/remove/lib/check-dependencies.ts rename to packages/workspace/src/generators/remove/lib/check-dependencies.ts index 6a97d6b639..c144efa96b 100644 --- a/packages/workspace/src/schematics/remove/lib/check-dependencies.ts +++ b/packages/workspace/src/generators/remove/lib/check-dependencies.ts @@ -5,7 +5,7 @@ import { reverse, } from '../../../core/project-graph'; import { Schema } from '../schema'; -import { createProjectGraphFromTree } from '../../../utils/create-project-graph-from-tree'; +import { createProjectGraphFromTree } from '../../../utilities/create-project-graph-from-tree'; /** * Check whether the project to be removed is depended on by another project diff --git a/packages/workspace/src/schematics/remove/lib/check-targets.spec.ts b/packages/workspace/src/generators/remove/lib/check-targets.spec.ts similarity index 100% rename from packages/workspace/src/schematics/remove/lib/check-targets.spec.ts rename to packages/workspace/src/generators/remove/lib/check-targets.spec.ts diff --git a/packages/workspace/src/schematics/remove/lib/check-targets.ts b/packages/workspace/src/generators/remove/lib/check-targets.ts similarity index 100% rename from packages/workspace/src/schematics/remove/lib/check-targets.ts rename to packages/workspace/src/generators/remove/lib/check-targets.ts diff --git a/packages/workspace/src/schematics/remove/lib/remove-project-config.spec.ts b/packages/workspace/src/generators/remove/lib/remove-project-config.spec.ts similarity index 100% rename from packages/workspace/src/schematics/remove/lib/remove-project-config.spec.ts rename to packages/workspace/src/generators/remove/lib/remove-project-config.spec.ts diff --git a/packages/workspace/src/schematics/remove/lib/remove-project-config.ts b/packages/workspace/src/generators/remove/lib/remove-project-config.ts similarity index 100% rename from packages/workspace/src/schematics/remove/lib/remove-project-config.ts rename to packages/workspace/src/generators/remove/lib/remove-project-config.ts diff --git a/packages/workspace/src/schematics/remove/lib/remove-project.spec.ts b/packages/workspace/src/generators/remove/lib/remove-project.spec.ts similarity index 92% rename from packages/workspace/src/schematics/remove/lib/remove-project.spec.ts rename to packages/workspace/src/generators/remove/lib/remove-project.spec.ts index 7928ed9224..c6dd60301c 100644 --- a/packages/workspace/src/schematics/remove/lib/remove-project.spec.ts +++ b/packages/workspace/src/generators/remove/lib/remove-project.spec.ts @@ -2,7 +2,7 @@ import { readProjectConfiguration, Tree } from '@nrwl/devkit'; import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; import { Schema } from '../schema'; import { libraryGenerator } from '../../library/library'; -import { removeProject } from '@nrwl/workspace/src/schematics/remove/lib/remove-project'; +import { removeProject } from '@nrwl/workspace/src/generators/remove/lib/remove-project'; describe('moveProject', () => { let schema: Schema; diff --git a/packages/workspace/src/schematics/remove/lib/remove-project.ts b/packages/workspace/src/generators/remove/lib/remove-project.ts similarity index 100% rename from packages/workspace/src/schematics/remove/lib/remove-project.ts rename to packages/workspace/src/generators/remove/lib/remove-project.ts diff --git a/packages/workspace/src/schematics/remove/lib/test-files/jest.config.js b/packages/workspace/src/generators/remove/lib/test-files/jest.config.js similarity index 100% rename from packages/workspace/src/schematics/remove/lib/test-files/jest.config.js rename to packages/workspace/src/generators/remove/lib/test-files/jest.config.js diff --git a/packages/workspace/src/schematics/remove/lib/update-jest-config.spec.ts b/packages/workspace/src/generators/remove/lib/update-jest-config.spec.ts similarity index 100% rename from packages/workspace/src/schematics/remove/lib/update-jest-config.spec.ts rename to packages/workspace/src/generators/remove/lib/update-jest-config.spec.ts diff --git a/packages/workspace/src/schematics/remove/lib/update-jest-config.ts b/packages/workspace/src/generators/remove/lib/update-jest-config.ts similarity index 100% rename from packages/workspace/src/schematics/remove/lib/update-jest-config.ts rename to packages/workspace/src/generators/remove/lib/update-jest-config.ts diff --git a/packages/workspace/src/schematics/remove/lib/update-tsconfig.spec.ts b/packages/workspace/src/generators/remove/lib/update-tsconfig.spec.ts similarity index 100% rename from packages/workspace/src/schematics/remove/lib/update-tsconfig.spec.ts rename to packages/workspace/src/generators/remove/lib/update-tsconfig.spec.ts diff --git a/packages/workspace/src/schematics/remove/lib/update-tsconfig.ts b/packages/workspace/src/generators/remove/lib/update-tsconfig.ts similarity index 100% rename from packages/workspace/src/schematics/remove/lib/update-tsconfig.ts rename to packages/workspace/src/generators/remove/lib/update-tsconfig.ts diff --git a/packages/workspace/src/schematics/remove/remove.ts b/packages/workspace/src/generators/remove/remove.ts similarity index 100% rename from packages/workspace/src/schematics/remove/remove.ts rename to packages/workspace/src/generators/remove/remove.ts diff --git a/packages/workspace/src/generators/remove/schema.d.ts b/packages/workspace/src/generators/remove/schema.d.ts new file mode 100644 index 0000000000..d698591096 --- /dev/null +++ b/packages/workspace/src/generators/remove/schema.d.ts @@ -0,0 +1,9 @@ +export interface Json { + [k: string]: any; +} + +export interface Schema extends Json { + projectName: string; + skipFormat: boolean; + forceRemove: boolean; +} diff --git a/packages/workspace/src/schematics/remove/schema.json b/packages/workspace/src/generators/remove/schema.json similarity index 100% rename from packages/workspace/src/schematics/remove/schema.json rename to packages/workspace/src/generators/remove/schema.json diff --git a/packages/workspace/src/schematics/run-commands/run-commands.spec.ts b/packages/workspace/src/generators/run-commands/run-commands.spec.ts similarity index 100% rename from packages/workspace/src/schematics/run-commands/run-commands.spec.ts rename to packages/workspace/src/generators/run-commands/run-commands.spec.ts diff --git a/packages/workspace/src/schematics/run-commands/run-commands.ts b/packages/workspace/src/generators/run-commands/run-commands.ts similarity index 100% rename from packages/workspace/src/schematics/run-commands/run-commands.ts rename to packages/workspace/src/generators/run-commands/run-commands.ts diff --git a/packages/workspace/src/schematics/run-commands/schema.d.ts b/packages/workspace/src/generators/run-commands/schema.d.ts similarity index 100% rename from packages/workspace/src/schematics/run-commands/schema.d.ts rename to packages/workspace/src/generators/run-commands/schema.d.ts diff --git a/packages/workspace/src/schematics/run-commands/schema.json b/packages/workspace/src/generators/run-commands/schema.json similarity index 100% rename from packages/workspace/src/schematics/run-commands/schema.json rename to packages/workspace/src/generators/run-commands/schema.json diff --git a/packages/workspace/src/schematics/utils/decorate-angular-cli.js__tmpl__ b/packages/workspace/src/generators/utils/decorate-angular-cli.js__tmpl__ similarity index 100% rename from packages/workspace/src/schematics/utils/decorate-angular-cli.js__tmpl__ rename to packages/workspace/src/generators/utils/decorate-angular-cli.js__tmpl__ diff --git a/packages/workspace/src/schematics/utils/insert-import.spec.ts b/packages/workspace/src/generators/utils/insert-import.spec.ts similarity index 100% rename from packages/workspace/src/schematics/utils/insert-import.spec.ts rename to packages/workspace/src/generators/utils/insert-import.spec.ts diff --git a/packages/workspace/src/schematics/utils/insert-import.ts b/packages/workspace/src/generators/utils/insert-import.ts similarity index 100% rename from packages/workspace/src/schematics/utils/insert-import.ts rename to packages/workspace/src/generators/utils/insert-import.ts diff --git a/packages/workspace/src/schematics/utils/insert-statement.spec.ts b/packages/workspace/src/generators/utils/insert-statement.spec.ts similarity index 100% rename from packages/workspace/src/schematics/utils/insert-statement.spec.ts rename to packages/workspace/src/generators/utils/insert-statement.spec.ts diff --git a/packages/workspace/src/schematics/utils/insert-statement.ts b/packages/workspace/src/generators/utils/insert-statement.ts similarity index 100% rename from packages/workspace/src/schematics/utils/insert-statement.ts rename to packages/workspace/src/generators/utils/insert-statement.ts diff --git a/packages/workspace/src/schematics/workspace-generator/files/index.ts__tmpl__ b/packages/workspace/src/generators/workspace-generator/files/index.ts__tmpl__ similarity index 80% rename from packages/workspace/src/schematics/workspace-generator/files/index.ts__tmpl__ rename to packages/workspace/src/generators/workspace-generator/files/index.ts__tmpl__ index 6335a40333..9ee433719b 100644 --- a/packages/workspace/src/schematics/workspace-generator/files/index.ts__tmpl__ +++ b/packages/workspace/src/generators/workspace-generator/files/index.ts__tmpl__ @@ -1,5 +1,5 @@ import { Tree, formatFiles, installPackagesTask } from '@nrwl/devkit'; -import { libraryGenerator } from '@nrwl/workspace'; +import { libraryGenerator } from '@nrwl/workspace/generators'; export default async function(host: Tree, schema: any) { await libraryGenerator(host, {name: schema.name}); @@ -7,4 +7,4 @@ export default async function(host: Tree, schema: any) { return () => { installPackagesTask(host) } -} \ No newline at end of file +} diff --git a/packages/workspace/src/schematics/workspace-generator/files/schema.json__tmpl__ b/packages/workspace/src/generators/workspace-generator/files/schema.json__tmpl__ similarity index 100% rename from packages/workspace/src/schematics/workspace-generator/files/schema.json__tmpl__ rename to packages/workspace/src/generators/workspace-generator/files/schema.json__tmpl__ diff --git a/packages/workspace/src/schematics/workspace-generator/schema.d.ts b/packages/workspace/src/generators/workspace-generator/schema.d.ts similarity index 100% rename from packages/workspace/src/schematics/workspace-generator/schema.d.ts rename to packages/workspace/src/generators/workspace-generator/schema.d.ts diff --git a/packages/workspace/src/schematics/workspace-generator/schema.json b/packages/workspace/src/generators/workspace-generator/schema.json similarity index 100% rename from packages/workspace/src/schematics/workspace-generator/schema.json rename to packages/workspace/src/generators/workspace-generator/schema.json diff --git a/packages/workspace/src/schematics/workspace-generator/workspace-generator.spec.ts b/packages/workspace/src/generators/workspace-generator/workspace-generator.spec.ts similarity index 100% rename from packages/workspace/src/schematics/workspace-generator/workspace-generator.spec.ts rename to packages/workspace/src/generators/workspace-generator/workspace-generator.spec.ts diff --git a/packages/workspace/src/schematics/workspace-generator/workspace-generator.ts b/packages/workspace/src/generators/workspace-generator/workspace-generator.ts similarity index 65% rename from packages/workspace/src/schematics/workspace-generator/workspace-generator.ts rename to packages/workspace/src/generators/workspace-generator/workspace-generator.ts index 01de14c7ce..ddefeedb6f 100644 --- a/packages/workspace/src/schematics/workspace-generator/workspace-generator.ts +++ b/packages/workspace/src/generators/workspace-generator/workspace-generator.ts @@ -1,13 +1,18 @@ import { Schema } from './schema'; -import { Tree, formatFiles, generateFiles, names } from '@nrwl/devkit'; -import * as path from 'path'; +import { + Tree, + formatFiles, + generateFiles, + names, + joinPathFragments, +} from '@nrwl/devkit'; export default async function (host: Tree, schema: Schema) { const options = normalizeOptions(schema); generateFiles( host, - path.join(__dirname, 'files'), - path.join('tools/generators', schema.name), + joinPathFragments(__dirname, 'files'), + joinPathFragments('tools/generators', schema.name), options ); if (!schema.skipFormat) { diff --git a/packages/workspace/src/schematics/workspace/__snapshots__/workspace.spec.ts.snap b/packages/workspace/src/generators/workspace/__snapshots__/workspace.spec.ts.snap similarity index 100% rename from packages/workspace/src/schematics/workspace/__snapshots__/workspace.spec.ts.snap rename to packages/workspace/src/generators/workspace/__snapshots__/workspace.spec.ts.snap diff --git a/packages/workspace/src/schematics/workspace/files/README.md__tmpl__ b/packages/workspace/src/generators/workspace/files/README.md__tmpl__ similarity index 100% rename from packages/workspace/src/schematics/workspace/files/README.md__tmpl__ rename to packages/workspace/src/generators/workspace/files/README.md__tmpl__ diff --git a/packages/workspace/src/schematics/workspace/files/__dot__editorconfig b/packages/workspace/src/generators/workspace/files/__dot__editorconfig similarity index 100% rename from packages/workspace/src/schematics/workspace/files/__dot__editorconfig rename to packages/workspace/src/generators/workspace/files/__dot__editorconfig diff --git a/packages/workspace/src/schematics/workspace/files/__dot__gitignore b/packages/workspace/src/generators/workspace/files/__dot__gitignore similarity index 100% rename from packages/workspace/src/schematics/workspace/files/__dot__gitignore rename to packages/workspace/src/generators/workspace/files/__dot__gitignore diff --git a/packages/workspace/src/schematics/workspace/files/__dot__prettierignore b/packages/workspace/src/generators/workspace/files/__dot__prettierignore similarity index 100% rename from packages/workspace/src/schematics/workspace/files/__dot__prettierignore rename to packages/workspace/src/generators/workspace/files/__dot__prettierignore diff --git a/packages/workspace/src/schematics/workspace/files/__dot__vscode/extensions.json__tmpl__ b/packages/workspace/src/generators/workspace/files/__dot__vscode/extensions.json__tmpl__ similarity index 100% rename from packages/workspace/src/schematics/workspace/files/__dot__vscode/extensions.json__tmpl__ rename to packages/workspace/src/generators/workspace/files/__dot__vscode/extensions.json__tmpl__ diff --git a/packages/workspace/src/schematics/workspace/files/__workspaceFile__.json b/packages/workspace/src/generators/workspace/files/__workspaceFile__.json similarity index 100% rename from packages/workspace/src/schematics/workspace/files/__workspaceFile__.json rename to packages/workspace/src/generators/workspace/files/__workspaceFile__.json diff --git a/packages/workspace/src/schematics/workspace/files/nx.json b/packages/workspace/src/generators/workspace/files/nx.json similarity index 100% rename from packages/workspace/src/schematics/workspace/files/nx.json rename to packages/workspace/src/generators/workspace/files/nx.json diff --git a/packages/workspace/src/schematics/workspace/files/package.json__tmpl__ b/packages/workspace/src/generators/workspace/files/package.json__tmpl__ similarity index 100% rename from packages/workspace/src/schematics/workspace/files/package.json__tmpl__ rename to packages/workspace/src/generators/workspace/files/package.json__tmpl__ diff --git a/packages/workspace/src/schematics/workspace/files/tools/generators/.gitkeep b/packages/workspace/src/generators/workspace/files/tools/generators/.gitkeep similarity index 100% rename from packages/workspace/src/schematics/workspace/files/tools/generators/.gitkeep rename to packages/workspace/src/generators/workspace/files/tools/generators/.gitkeep diff --git a/packages/workspace/src/schematics/workspace/files/tools/tsconfig.tools.json b/packages/workspace/src/generators/workspace/files/tools/tsconfig.tools.json similarity index 100% rename from packages/workspace/src/schematics/workspace/files/tools/tsconfig.tools.json rename to packages/workspace/src/generators/workspace/files/tools/tsconfig.tools.json diff --git a/packages/workspace/src/schematics/workspace/files/tsconfig.base.json b/packages/workspace/src/generators/workspace/files/tsconfig.base.json similarity index 100% rename from packages/workspace/src/schematics/workspace/files/tsconfig.base.json rename to packages/workspace/src/generators/workspace/files/tsconfig.base.json diff --git a/packages/workspace/src/schematics/workspace/schema.d.ts b/packages/workspace/src/generators/workspace/schema.d.ts similarity index 100% rename from packages/workspace/src/schematics/workspace/schema.d.ts rename to packages/workspace/src/generators/workspace/schema.d.ts diff --git a/packages/workspace/src/schematics/workspace/schema.json b/packages/workspace/src/generators/workspace/schema.json similarity index 100% rename from packages/workspace/src/schematics/workspace/schema.json rename to packages/workspace/src/generators/workspace/schema.json diff --git a/packages/workspace/src/schematics/workspace/workspace.spec.ts b/packages/workspace/src/generators/workspace/workspace.spec.ts similarity index 100% rename from packages/workspace/src/schematics/workspace/workspace.spec.ts rename to packages/workspace/src/generators/workspace/workspace.spec.ts diff --git a/packages/workspace/src/schematics/workspace/workspace.ts b/packages/workspace/src/generators/workspace/workspace.ts similarity index 100% rename from packages/workspace/src/schematics/workspace/workspace.ts rename to packages/workspace/src/generators/workspace/workspace.ts diff --git a/packages/workspace/src/migrations/update-10-3-0/add-cli-dependency.spec.ts b/packages/workspace/src/migrations/update-10-3-0/add-cli-dependency.spec.ts index 4dcfd6ba78..918e408ce7 100644 --- a/packages/workspace/src/migrations/update-10-3-0/add-cli-dependency.spec.ts +++ b/packages/workspace/src/migrations/update-10-3-0/add-cli-dependency.spec.ts @@ -1,7 +1,7 @@ import { Tree } from '@angular-devkit/schematics'; import { callRule, runMigration } from '../../utils/testing'; import { readJsonInTree, serializeJson } from '@nrwl/workspace'; -import { nxVersion } from '../../../src/utils/versions'; +import { nxVersion } from '../../utils/versions'; describe('CLI dependency migration', () => { let tree: Tree; diff --git a/packages/workspace/src/migrations/update-8-12-0/update-enforce-boundary-lint-rule.spec.ts b/packages/workspace/src/migrations/update-8-12-0/update-enforce-boundary-lint-rule.spec.ts index 87d192e692..143326599c 100644 --- a/packages/workspace/src/migrations/update-8-12-0/update-enforce-boundary-lint-rule.spec.ts +++ b/packages/workspace/src/migrations/update-8-12-0/update-enforce-boundary-lint-rule.spec.ts @@ -1,8 +1,6 @@ import { Tree } from '@angular-devkit/schematics'; import { readJsonInTree } from '../../utils/ast-utils'; -import { serializeJson } from '../../utils/fileutils'; import { runMigration } from '../../utils/testing'; -import { createEmptyWorkspace } from '../../utils/testing-utils'; import { _test_addWorkspaceFile, WorkspaceFormat, diff --git a/packages/workspace/src/migrations/update-8-12-0/update-package-json-deps.spec.ts b/packages/workspace/src/migrations/update-8-12-0/update-package-json-deps.spec.ts index 5f4eae6caf..2e38dd6e5d 100644 --- a/packages/workspace/src/migrations/update-8-12-0/update-package-json-deps.spec.ts +++ b/packages/workspace/src/migrations/update-8-12-0/update-package-json-deps.spec.ts @@ -1,6 +1,6 @@ import { Tree } from '@angular-devkit/schematics'; import { readJsonInTree } from '../../utils/ast-utils'; -import { serializeJson } from '../../utils/fileutils'; +import { serializeJson } from '../../utilities/fileutils'; import { runMigration } from '../../utils/testing'; import { createEmptyWorkspace } from '../../utils/testing-utils'; diff --git a/packages/workspace/src/migrations/update-9-4-0/add-decorate-cli.ts b/packages/workspace/src/migrations/update-9-4-0/add-decorate-cli.ts index 0f1e571cb1..45fa45b2b0 100644 --- a/packages/workspace/src/migrations/update-9-4-0/add-decorate-cli.ts +++ b/packages/workspace/src/migrations/update-9-4-0/add-decorate-cli.ts @@ -11,7 +11,7 @@ const decorateAngularClI = (host: Tree, context: SchematicContext) => { __dirname as any, '..', '..', - 'schematics', + 'generators', 'utils', 'decorate-angular-cli.js__tmpl__' ) diff --git a/packages/workspace/src/schematics/remove/schema.d.ts b/packages/workspace/src/schematics/remove/schema.d.ts deleted file mode 100644 index 92e515787e..0000000000 --- a/packages/workspace/src/schematics/remove/schema.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { JsonObject } from '@angular-devkit/core'; - -export interface Schema extends JsonObject { - projectName: string; - skipFormat: boolean; - forceRemove: boolean; -} diff --git a/packages/workspace/src/tasks-runner/cache.ts b/packages/workspace/src/tasks-runner/cache.ts index d11dd47301..9e465aa811 100644 --- a/packages/workspace/src/tasks-runner/cache.ts +++ b/packages/workspace/src/tasks-runner/cache.ts @@ -1,4 +1,4 @@ -import { appRootPath } from '../utils/app-root'; +import { appRootPath } from '../utilities/app-root'; import { Task } from './tasks-runner'; import { existsSync, @@ -11,7 +11,7 @@ import { join, resolve } from 'path'; import * as fsExtra from 'fs-extra'; import { DefaultTasksRunnerOptions } from './default-tasks-runner'; import { spawn } from 'child_process'; -import { cacheDirectory } from '../utils/cache-directory'; +import { cacheDirectory } from '../utilities/cache-directory'; export type CachedResult = { terminalOutput: string; outputsPath: string }; export type TaskWithCachedResult = { task: Task; cachedResult: CachedResult }; diff --git a/packages/workspace/src/tasks-runner/default-reporter.ts b/packages/workspace/src/tasks-runner/default-reporter.ts index 9c1b33730c..b48e743640 100644 --- a/packages/workspace/src/tasks-runner/default-reporter.ts +++ b/packages/workspace/src/tasks-runner/default-reporter.ts @@ -1,4 +1,4 @@ -import { output } from '../utils/output'; +import { output } from '../utilities/output'; export interface ReporterArgs { target?: string; diff --git a/packages/workspace/src/tasks-runner/run-command.ts b/packages/workspace/src/tasks-runner/run-command.ts index 18a813bb3a..0ed17d077a 100644 --- a/packages/workspace/src/tasks-runner/run-command.ts +++ b/packages/workspace/src/tasks-runner/run-command.ts @@ -1,15 +1,15 @@ import { AffectedEventType, Task, TasksRunner } from './tasks-runner'; import { join } from 'path'; -import { appRootPath } from '../utils/app-root'; +import { appRootPath } from '../utilities/app-root'; import { ReporterArgs } from './default-reporter'; import * as yargs from 'yargs'; import { ProjectGraph, ProjectGraphNode } from '../core/project-graph'; import { Environment, NxJson } from '../core/shared-interfaces'; import { NxArgs } from '@nrwl/workspace/src/command-line/utils'; -import { isRelativePath } from '../utils/fileutils'; +import { isRelativePath } from '../utilities/fileutils'; import { Hasher } from '../core/hasher/hasher'; -import { projectHasTargetAndConfiguration } from '../utils/project-graph-utils'; -import { output } from '../utils/output'; +import { projectHasTargetAndConfiguration } from '../utilities/project-graph-utils'; +import { output } from '../utilities/output'; type RunArgs = yargs.Arguments & ReporterArgs; diff --git a/packages/workspace/src/tasks-runner/run-one-reporter.ts b/packages/workspace/src/tasks-runner/run-one-reporter.ts index 3377132ac5..ed130b0e36 100644 --- a/packages/workspace/src/tasks-runner/run-one-reporter.ts +++ b/packages/workspace/src/tasks-runner/run-one-reporter.ts @@ -1,4 +1,4 @@ -import { output } from '../utils/output'; +import { output } from '../utilities/output'; export interface ReporterArgs { target?: string; diff --git a/packages/workspace/src/tasks-runner/task-orchestrator.ts b/packages/workspace/src/tasks-runner/task-orchestrator.ts index a0b813d044..4c0d156bbe 100644 --- a/packages/workspace/src/tasks-runner/task-orchestrator.ts +++ b/packages/workspace/src/tasks-runner/task-orchestrator.ts @@ -4,9 +4,9 @@ import { AffectedEventType, Task } from './tasks-runner'; import { getOutputs, unparse } from './utils'; import { ChildProcess, fork } from 'child_process'; import { DefaultTasksRunnerOptions } from './default-tasks-runner'; -import { output } from '../utils/output'; +import { output } from '../utilities/output'; import * as fs from 'fs'; -import { appRootPath } from '../utils/app-root'; +import { appRootPath } from '../utilities/app-root'; import * as dotenv from 'dotenv'; import { Workspaces } from '@nrwl/tao/src/shared/workspace'; diff --git a/packages/workspace/src/tslint/nxEnforceModuleBoundariesRule.spec.ts b/packages/workspace/src/tslint/nxEnforceModuleBoundariesRule.spec.ts index 0b27fc3671..73da20a3e8 100644 --- a/packages/workspace/src/tslint/nxEnforceModuleBoundariesRule.spec.ts +++ b/packages/workspace/src/tslint/nxEnforceModuleBoundariesRule.spec.ts @@ -12,7 +12,7 @@ import { TargetProjectLocator } from '../core/target-project-locator'; import { readFileSync } from 'fs'; jest.mock('fs', () => require('memfs').fs); -jest.mock('../utils/app-root', () => ({ appRootPath: '/root' })); +jest.mock('../utilities/app-root', () => ({ appRootPath: '/root' })); const tsconfig = { compilerOptions: { diff --git a/packages/workspace/src/tslint/nxEnforceModuleBoundariesRule.ts b/packages/workspace/src/tslint/nxEnforceModuleBoundariesRule.ts index 19e327f311..1414ff3e35 100644 --- a/packages/workspace/src/tslint/nxEnforceModuleBoundariesRule.ts +++ b/packages/workspace/src/tslint/nxEnforceModuleBoundariesRule.ts @@ -7,7 +7,7 @@ import { ProjectGraph, ProjectType, } from '../core/project-graph'; -import { appRootPath } from '../utils/app-root'; +import { appRootPath } from '../utilities/app-root'; import { DepConstraint, findConstraintsFor, @@ -22,7 +22,7 @@ import { matchImportWithWildcard, onlyLoadChildren, } from '../utils/runtime-lint-utils'; -import { normalize } from '@angular-devkit/core'; +import { normalize } from 'path'; import { readNxJson, readWorkspaceJson, diff --git a/packages/workspace/src/utils/app-root.ts b/packages/workspace/src/utilities/app-root.ts similarity index 100% rename from packages/workspace/src/utils/app-root.ts rename to packages/workspace/src/utilities/app-root.ts diff --git a/packages/workspace/src/utils/cache-directory.ts b/packages/workspace/src/utilities/cache-directory.ts similarity index 100% rename from packages/workspace/src/utils/cache-directory.ts rename to packages/workspace/src/utilities/cache-directory.ts diff --git a/packages/workspace/src/utils/create-project-graph-from-tree.ts b/packages/workspace/src/utilities/create-project-graph-from-tree.ts similarity index 100% rename from packages/workspace/src/utils/create-project-graph-from-tree.ts rename to packages/workspace/src/utilities/create-project-graph-from-tree.ts diff --git a/packages/workspace/src/utils/fileutils.spec.ts b/packages/workspace/src/utilities/fileutils.spec.ts similarity index 100% rename from packages/workspace/src/utils/fileutils.spec.ts rename to packages/workspace/src/utilities/fileutils.spec.ts diff --git a/packages/workspace/src/utils/fileutils.ts b/packages/workspace/src/utilities/fileutils.ts similarity index 100% rename from packages/workspace/src/utils/fileutils.ts rename to packages/workspace/src/utilities/fileutils.ts diff --git a/packages/workspace/src/utils/json-diff.spec.ts b/packages/workspace/src/utilities/json-diff.spec.ts similarity index 100% rename from packages/workspace/src/utils/json-diff.spec.ts rename to packages/workspace/src/utilities/json-diff.spec.ts diff --git a/packages/workspace/src/utils/json-diff.ts b/packages/workspace/src/utilities/json-diff.ts similarity index 100% rename from packages/workspace/src/utils/json-diff.ts rename to packages/workspace/src/utilities/json-diff.ts diff --git a/packages/workspace/src/utils/output.ts b/packages/workspace/src/utilities/output.ts similarity index 100% rename from packages/workspace/src/utils/output.ts rename to packages/workspace/src/utilities/output.ts diff --git a/packages/workspace/src/utils/perf-logging.ts b/packages/workspace/src/utilities/perf-logging.ts similarity index 100% rename from packages/workspace/src/utils/perf-logging.ts rename to packages/workspace/src/utilities/perf-logging.ts diff --git a/packages/workspace/src/utils/plugins/community-plugins.ts b/packages/workspace/src/utilities/plugins/community-plugins.ts similarity index 100% rename from packages/workspace/src/utils/plugins/community-plugins.ts rename to packages/workspace/src/utilities/plugins/community-plugins.ts diff --git a/packages/workspace/src/utils/plugins/core-plugins.ts b/packages/workspace/src/utilities/plugins/core-plugins.ts similarity index 100% rename from packages/workspace/src/utils/plugins/core-plugins.ts rename to packages/workspace/src/utilities/plugins/core-plugins.ts diff --git a/packages/workspace/src/utils/plugins/index.ts b/packages/workspace/src/utilities/plugins/index.ts similarity index 100% rename from packages/workspace/src/utils/plugins/index.ts rename to packages/workspace/src/utilities/plugins/index.ts diff --git a/packages/workspace/src/utils/plugins/installed-plugins.ts b/packages/workspace/src/utilities/plugins/installed-plugins.ts similarity index 100% rename from packages/workspace/src/utils/plugins/installed-plugins.ts rename to packages/workspace/src/utilities/plugins/installed-plugins.ts diff --git a/packages/workspace/src/utils/plugins/models.ts b/packages/workspace/src/utilities/plugins/models.ts similarity index 100% rename from packages/workspace/src/utils/plugins/models.ts rename to packages/workspace/src/utilities/plugins/models.ts diff --git a/packages/workspace/src/utils/plugins/plugin-capabilities.ts b/packages/workspace/src/utilities/plugins/plugin-capabilities.ts similarity index 100% rename from packages/workspace/src/utils/plugins/plugin-capabilities.ts rename to packages/workspace/src/utilities/plugins/plugin-capabilities.ts diff --git a/packages/workspace/src/utils/plugins/shared.ts b/packages/workspace/src/utilities/plugins/shared.ts similarity index 100% rename from packages/workspace/src/utils/plugins/shared.ts rename to packages/workspace/src/utilities/plugins/shared.ts diff --git a/packages/workspace/src/utils/common.ts b/packages/workspace/src/utilities/prettier.ts similarity index 100% rename from packages/workspace/src/utils/common.ts rename to packages/workspace/src/utilities/prettier.ts diff --git a/packages/workspace/src/utils/project-graph-utils.ts b/packages/workspace/src/utilities/project-graph-utils.ts similarity index 100% rename from packages/workspace/src/utils/project-graph-utils.ts rename to packages/workspace/src/utilities/project-graph-utils.ts diff --git a/packages/workspace/src/utils/strip-source-code.spec.ts b/packages/workspace/src/utilities/strip-source-code.spec.ts similarity index 100% rename from packages/workspace/src/utils/strip-source-code.spec.ts rename to packages/workspace/src/utilities/strip-source-code.spec.ts diff --git a/packages/workspace/src/utils/strip-source-code.ts b/packages/workspace/src/utilities/strip-source-code.ts similarity index 100% rename from packages/workspace/src/utils/strip-source-code.ts rename to packages/workspace/src/utilities/strip-source-code.ts diff --git a/packages/workspace/src/utils/typescript.ts b/packages/workspace/src/utilities/typescript.ts similarity index 91% rename from packages/workspace/src/utils/typescript.ts rename to packages/workspace/src/utilities/typescript.ts index a150bfaece..9b80dbe110 100644 --- a/packages/workspace/src/utils/typescript.ts +++ b/packages/workspace/src/utilities/typescript.ts @@ -1,8 +1,6 @@ -import { dirname, join } from 'path'; +import { dirname } from 'path'; import * as ts from 'typescript'; import { appRootPath } from './app-root'; -import { existsSync } from 'fs'; -import { FileRead } from '@nrwl/workspace/src/core/file-utils'; const normalizedAppRoot = appRootPath.replace(/\\/g, '/'); diff --git a/packages/workspace/src/utils/ast-utils.spec.ts b/packages/workspace/src/utils/ast-utils.spec.ts index 1d9c80dfce..20fa013aca 100644 --- a/packages/workspace/src/utils/ast-utils.spec.ts +++ b/packages/workspace/src/utils/ast-utils.spec.ts @@ -10,7 +10,7 @@ import { } from '@angular-devkit/schematics/testing'; import { join } from 'path'; import { Tree, SchematicContext, TaskId } from '@angular-devkit/schematics'; -import { serializeJson } from './fileutils'; +import { serializeJson } from '../utilities/fileutils'; import { createEmptyWorkspace } from './testing-utils'; describe('readJsonInTree', () => { diff --git a/packages/workspace/src/utils/ast-utils.ts b/packages/workspace/src/utils/ast-utils.ts index 69df364f84..12c0184716 100644 --- a/packages/workspace/src/utils/ast-utils.ts +++ b/packages/workspace/src/utils/ast-utils.ts @@ -19,7 +19,7 @@ import { } from '@angular-devkit/schematics'; import * as ts from 'typescript'; import * as stripJsonComments from 'strip-json-comments'; -import { serializeJson } from './fileutils'; +import { serializeJson } from '../utilities/fileutils'; import { getWorkspacePath } from './cli-config-utils'; import { createProjectGraph, diff --git a/packages/workspace/src/utils/buildable-libs-utils.ts b/packages/workspace/src/utils/buildable-libs-utils.ts index 05f230c8c0..48ceff83a7 100644 --- a/packages/workspace/src/utils/buildable-libs-utils.ts +++ b/packages/workspace/src/utils/buildable-libs-utils.ts @@ -9,7 +9,7 @@ import { fileExists, readJsonFile, writeJsonFile, -} from '@nrwl/workspace/src/utils/fileutils'; +} from '@nrwl/workspace/src/utilities/fileutils'; import { stripIndents } from '@angular-devkit/core/src/utils/literals'; import { getOutputsForTargetAndConfiguration } from '@nrwl/workspace/src/tasks-runner/utils'; import * as ts from 'typescript'; diff --git a/packages/workspace/src/utils/rules/format-files.spec.ts b/packages/workspace/src/utils/rules/format-files.spec.ts index 57c65ee008..76f2f8ebde 100644 --- a/packages/workspace/src/utils/rules/format-files.spec.ts +++ b/packages/workspace/src/utils/rules/format-files.spec.ts @@ -4,7 +4,7 @@ import { Tree } from '@angular-devkit/schematics'; import * as prettier from 'prettier'; import * as path from 'path'; import { formatFiles } from './format-files'; -import { appRootPath } from '../app-root'; +import { appRootPath } from '../../utilities/app-root'; describe('formatFiles', () => { let tree: Tree; diff --git a/packages/workspace/src/utils/rules/format-files.ts b/packages/workspace/src/utils/rules/format-files.ts index ecab031771..86f139d324 100644 --- a/packages/workspace/src/utils/rules/format-files.ts +++ b/packages/workspace/src/utils/rules/format-files.ts @@ -9,7 +9,7 @@ import { import { from } from 'rxjs'; import { filter, map, mergeMap } from 'rxjs/operators'; import * as path from 'path'; -import { appRootPath } from '../app-root'; +import { appRootPath } from '../../utilities/app-root'; import { reformattedWorkspaceJsonOrNull } from '@nrwl/tao/src/shared/workspace'; import * as stripJsonComments from 'strip-json-comments'; diff --git a/packages/workspace/src/utils/runtime-lint-utils.ts b/packages/workspace/src/utils/runtime-lint-utils.ts index cd09b01242..bc7cbe040b 100644 --- a/packages/workspace/src/utils/runtime-lint-utils.ts +++ b/packages/workspace/src/utils/runtime-lint-utils.ts @@ -1,4 +1,3 @@ -import { normalize } from '@angular-devkit/core'; import * as path from 'path'; import { FileData } from '../core/file-utils'; import { @@ -9,6 +8,7 @@ import { ProjectGraphNode, } from '../core/project-graph'; import { TargetProjectLocator } from '../core/target-project-locator'; +import { normalizePath, joinPathFragments } from '@nrwl/devkit'; export type Deps = { [projectName: string]: ProjectGraphDependency[] }; export type DepConstraint = { @@ -37,14 +37,6 @@ function removeExt(file: string): string { return file.replace(/\.[^/.]+$/, ''); } -function removeWindowsDriveLetter(osSpecificPath: string): string { - return osSpecificPath.replace(/^[A-Z]:/, ''); -} - -function normalizePath(osSpecificPath: string): string { - return removeWindowsDriveLetter(osSpecificPath).split(path.sep).join('/'); -} - export function matchImportWithWildcard( // This may or may not contain wildcards ("*") allowableImport: string, @@ -285,7 +277,7 @@ export function onlyLoadChildren( } export function getSourceFilePath(sourceFileName: string, projectPath: string) { - return normalize(sourceFileName).substring(projectPath.length + 1); + return normalizePath(sourceFileName).substring(projectPath.length + 1); } /** diff --git a/scripts/check-imports.js b/scripts/check-imports.js index 8726c56345..eab086a5b8 100644 --- a/scripts/check-imports.js +++ b/scripts/check-imports.js @@ -30,8 +30,8 @@ function check() { 'packages/create-nx-plugin/bin/create-nx-plugin.ts', 'packages/workspace/src/command-line/affected.ts', 'packages/workspace/src/core/file-utils.ts', - 'packages/workspace/src/schematics/preset/preset.ts', - 'packages/workspace/src/schematics/init/init.ts', + 'packages/workspace/src/generators/preset/preset.ts', + 'packages/workspace/src/generators/init/init.ts', 'packages/workspace/src/utils/update-task.ts', 'packages/workspace/src/migrations/update-8-3-0/update-8-3-0.spec.ts', 'packages/workspace/src/migrations/update-8-3-0/update-ng-cli-8-1.ts',