feat(core): remove angular devkit deps
This commit is contained in:
parent
7dd44c1e92
commit
a25e081a84
@ -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
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -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/' +
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -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()) {
|
||||
|
||||
28
packages/devkit/src/utils/path.ts
Normal file
28
packages/devkit/src/utils/path.ts
Normal file
@ -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('/');
|
||||
}
|
||||
@ -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,
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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<typeof normalizeOptions> {}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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) => {
|
||||
|
||||
@ -28,7 +28,6 @@
|
||||
},
|
||||
"builders": "./builders.json",
|
||||
"dependencies": {
|
||||
"@angular-devkit/architect": "~0.1100.1",
|
||||
"@nrwl/devkit": "*",
|
||||
"glob": "7.1.4",
|
||||
"minimatch": "3.0.4",
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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', () => {
|
||||
|
||||
@ -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';
|
||||
|
||||
|
||||
@ -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';
|
||||
|
||||
/**
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -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';
|
||||
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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"
|
||||
}
|
||||
|
||||
4
packages/workspace/generators.ts
Normal file
4
packages/workspace/generators.ts
Normal file
@ -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';
|
||||
@ -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;
|
||||
|
||||
@ -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": "*",
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -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 = {
|
||||
|
||||
@ -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';
|
||||
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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 {}
|
||||
|
||||
|
||||
@ -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';
|
||||
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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: {
|
||||
|
||||
@ -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 = [
|
||||
|
||||
@ -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<schema.PromptDefinition>) => {
|
||||
function createPromptProvider(): any {
|
||||
return (definitions: Array<any>) => {
|
||||
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 {
|
||||
|
||||
@ -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';
|
||||
|
||||
|
||||
@ -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', () => {
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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';
|
||||
|
||||
|
||||
@ -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', () => {
|
||||
|
||||
@ -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<
|
||||
|
||||
@ -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', () => {
|
||||
|
||||
@ -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<
|
||||
|
||||
@ -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';
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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', () => {
|
||||
|
||||
@ -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<
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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');
|
||||
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -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 = {
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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', () => {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
});
|
||||
|
||||
@ -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: '',
|
||||
});
|
||||
}
|
||||
@ -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;
|
||||
@ -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;
|
||||
@ -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';
|
||||
|
||||
@ -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;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user