Skip to content

Commit

Permalink
feat(core): remove angular devkit deps
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed Jan 25, 2021
1 parent 7dd44c1 commit a25e081
Show file tree
Hide file tree
Showing 211 changed files with 334 additions and 281 deletions.
2 changes: 1 addition & 1 deletion .prettierignore
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions 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",
Expand Down Expand Up @@ -281,4 +281,4 @@
"resolutions": {
"ng-packagr/rxjs": "6.6.3"
}
}
}
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/lib/init-local.ts
Expand Up @@ -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/' +
Expand Down
2 changes: 1 addition & 1 deletion 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';
Expand Down
2 changes: 1 addition & 1 deletion 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 {
Expand Down
5 changes: 3 additions & 2 deletions 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';
Expand Down
2 changes: 1 addition & 1 deletion 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 {
Expand Down
1 change: 1 addition & 0 deletions packages/devkit/index.ts
Expand Up @@ -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';
6 changes: 3 additions & 3 deletions 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');

Expand Down Expand Up @@ -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);
});
}

Expand All @@ -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()) {
Expand Down
28 changes: 28 additions & 0 deletions 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('/');
}
@@ -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,
Expand Down
3 changes: 0 additions & 3 deletions packages/jest/package.json
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/jest/src/generators/init/init.ts
@@ -1,4 +1,3 @@
import { stripIndents } from '@angular-devkit/core/src/utils/literals';
import {
babelCoreVersion,
babelJestVersion,
Expand All @@ -16,6 +15,7 @@ import {
updateJson,
addDependenciesToPackageJson,
convertNxGenerator,
stripIndents,
} from '@nrwl/devkit';

interface NormalizedSchema extends ReturnType<typeof normalizeOptions> {}
Expand Down
20 changes: 16 additions & 4 deletions 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,
},
};
Expand All @@ -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);
Expand Down
Expand Up @@ -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;
Expand Down
Expand Up @@ -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) => {
Expand Down
1 change: 0 additions & 1 deletion packages/linter/package.json
Expand Up @@ -28,7 +28,6 @@
},
"builders": "./builders.json",
"dependencies": {
"@angular-devkit/architect": "~0.1100.1",
"@nrwl/devkit": "*",
"glob": "7.1.4",
"minimatch": "3.0.4",
Expand Down
2 changes: 1 addition & 1 deletion 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) {
Expand Down
6 changes: 3 additions & 3 deletions packages/node/src/builders/package/package.impl.spec.ts
Expand Up @@ -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', () => {
Expand Down
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion 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';

/**
Expand Down
2 changes: 1 addition & 1 deletion 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';
Expand Down
2 changes: 1 addition & 1 deletion 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';

Expand Down
3 changes: 0 additions & 3 deletions packages/tao/package.json
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/builders/package/package.impl.ts
Expand Up @@ -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 {
Expand Down

0 comments on commit a25e081

Please sign in to comment.