Skip to content

Commit

Permalink
feat(repo): build nx with nx
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed Jun 3, 2020
1 parent 2a3116f commit d0cbc35
Show file tree
Hide file tree
Showing 147 changed files with 7,447 additions and 7,587 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
- setup
- run:
name: Run Unit Tests
command: yarn test:all
command: yarn test
- run:
name: Check Documentation
command: yarn documentation
Expand Down
41 changes: 41 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",
"project": "./tsconfig.json"
},
"ignorePatterns": ["**/*"],
"plugins": ["@typescript-eslint", "@nrwl/nx"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint"
],
"rules": {
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-parameter-properties": "off",
"@nrwl/nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{ "sourceTag": "*", "onlyDependOnLibsWithTags": ["*"] }
]
}
]
},
"overrides": [
{
"files": ["*.tsx"],
"rules": {
"@typescript-eslint/no-unused-vars": "off"
}
}
]
}
2 changes: 1 addition & 1 deletion e2e/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {

forEachCli('nx', () => {
describe('Help', () => {
it('should show help', async () => {
fit('should show help', async () => {
ensureProject();
const myapp = uniq('myapp');
runCLI(`generate @nrwl/web:app ${myapp}`);
Expand Down
3 changes: 0 additions & 3 deletions e2e/jest-config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
const pkg = require('../../package.json');

module.exports = {
...pkg.jest,
globalSetup: '<rootDir>/local-registry/setup.js',
globalTeardown: '<rootDir>/local-registry/teardown.js',
};
10 changes: 5 additions & 5 deletions e2e/ng-add.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
readJson,
runCLI,
runCommand,
runNew,
runNgNew,
updateFile,
forEachCli,
runNgAdd,
Expand All @@ -16,7 +16,7 @@ forEachCli('angular', () => {
afterAll(cleanup);

it('should generate a workspace', () => {
runNew('', false, false);
runNgNew();

// update package.json
const packageJson = readJson('package.json');
Expand Down Expand Up @@ -246,7 +246,7 @@ forEachCli('angular', () => {

it('should generate a workspace and not change dependencies, devDependencies, or vscode extensions if they already exist', () => {
// create a new AngularCLI app
runNew();
runNgNew();
const nxVersion = '0.0.0';
const schematicsVersion = '0.0.0';
const ngrxVersion = '0.0.0';
Expand Down Expand Up @@ -295,7 +295,7 @@ forEachCli('angular', () => {

it('should handle different types of errors', () => {
// create a new AngularCLI app
runNew();
runNgNew();

// Only remove e2e directory
runCommand('mv e2e e2e-bak');
Expand Down Expand Up @@ -339,7 +339,7 @@ forEachCli('angular', () => {
});

it('should support preserveAngularCLILayout', () => {
runNew('', false, false);
runNgNew();
runNgAdd('add @nrwl/workspace --preserveAngularCLILayout');

const updatedAngularCLIJson = readJson('angular.json');
Expand Down
4 changes: 2 additions & 2 deletions e2e/node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
readJson,
runCLI,
runCLIAsync,
runNew,
runNgNew,
runNgAdd,
tmpProjPath,
uniq,
Expand Down Expand Up @@ -160,7 +160,7 @@ forEachCli((currentCLIName) => {
// described in the docs) the tsconfig file could miss required options if Angular removes
// them from their config files as happened with emitDecoratorMetadata.
cleanup();
runNew('', false, false);
runNgNew();
runNgAdd('add @nrwl/workspace --npmScope projscope');
yarnAdd('@nrwl/nest');
} else {
Expand Down
9 changes: 9 additions & 0 deletions e2e/tsconfig.e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../build/e2e-out",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": ["**/*.ts"]
}
65 changes: 9 additions & 56 deletions e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,54 +108,11 @@ export const getDirectories = (source) =>
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);

export function runNgcc(silent: boolean = true, async: boolean = true) {
const install = execSync(
'node ./node_modules/@angular/compiler-cli/ngcc/main-ngcc.js' +
(!async ? ' --async=false' : ''),
{
cwd: tmpProjPath(),
...(silent ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}),
env: process.env,
}
);
return install ? install.toString() : '';
}

/**
* Run the `new` command for the currently selected CLI
*
* @param args Extra arguments to pass to the `new` command
* @param silent Run in silent mode (no output)
* @param addWorkspace Include `@nrwl/workspace` when patching the `package.json` paths
*/
export function runNew(
args?: string,
silent?: boolean,
addWorkspace = true
): string {
let gen;
if (cli === 'angular') {
gen = execSync(
`../../node_modules/.bin/ng new proj --no-interactive ${args || ''}`,
{
cwd: `./tmp/${cli}`,
...(silent ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}),
env: process.env,
}
);
} else {
gen = execSync(
`node ../../node_modules/@nrwl/tao/index.js new proj --no-interactive ${
args || ''
}`,
{
cwd: `./tmp/${cli}`,
...(silent && false ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}),
env: process.env,
}
);
}
return silent ? null : `${gen ? gen.toString() : ''}`;
export function runNgNew(): string {
return execSync(`../../node_modules/.bin/ng new proj --no-interactive`, {
cwd: `./tmp/${cli}`,
env: process.env,
}).toString();
}

/**
Expand All @@ -165,7 +122,7 @@ export function runNew(
export function newProject(): void {
cleanup();
if (!directoryExists(tmpBackupProjPath())) {
runNew('--collection=@nrwl/workspace --npmScope=proj', true);
runCreateWorkspace('proj', { preset: 'empty' });
const packages = [
`@nrwl/angular`,
`@nrwl/express`,
Expand All @@ -174,14 +131,14 @@ export function newProject(): void {
`@nrwl/react`,
`@nrwl/storybook`,
`@nrwl/nx-plugin`,
`@nrwl/eslint-plugin-nx`,
];
yarnAdd([`@nrwl/eslint-plugin-nx`].concat(packages).join(` `));
yarnAdd(packages.join(` `));
packages
.filter((f) => f != '@nrwl/nx-plugin')
.filter((f) => f !== '@nrwl/nx-plugin' && f !== `@nrwl/eslint-plugin-nx`)
.forEach((p) => {
runCLI(`g ${p}:init`);
});

execSync(`mv ${tmpProjPath()} ${tmpBackupProjPath()}`);
}
execSync(`cp -a ${tmpBackupProjPath()} ${tmpProjPath()}`);
Expand Down Expand Up @@ -414,10 +371,6 @@ export function rmDist() {
execSync(`rm -rf ${tmpProjPath()}/dist`);
}

export function getCwd(): string {
return process.cwd();
}

export function directoryExists(filePath: string): boolean {
try {
return statSync(filePath).isDirectory();
Expand Down
10 changes: 10 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
transform: {
'^.+\\.(ts|js|html)$': 'ts-jest',
},
resolver: '@nrwl/jest/plugins/resolver',
moduleFileExtensions: ['ts', 'js', 'html'],
coverageReporters: ['html'],
maxWorkers: 2,
};
86 changes: 86 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"npmScope": "nrwl",
"implicitDependencies": {
"workspace.json": "*",
"package.json": {
"dependencies": "*",
"devDependencies": "*"
},
"tsconfig.json": "*",
"tslint.json": "*",
"nx.json": "*"
},
"tasksRunnerOptions": {
"default": {
"runner": "@nrwl/workspace/tasks-runners/default",
"options": {
"cacheableOperations": ["build", "lint", "test", "e2e"]
}
}
},
"workspaceLayout": {
"libsDir": "packages"
},
"projects": {
"tao": {
"tags": []
},
"workspace": {
"tags": []
},
"web": {
"tags": [],
"implicitDependencies": ["cypress"]
},
"cypress": {
"tags": []
},
"jest": {
"tags": []
},
"react": {
"tags": []
},
"storybook": {
"tags": [],
"implicitDependencies": ["cypress"]
},
"nx-plugin": {
"tags": []
},
"node": {
"tags": []
},
"next": {
"tags": [],
"implicitDependencies": ["cypress"]
},
"nest": {
"tags": []
},
"linter": {
"tags": []
},
"express": {
"tags": []
},
"eslint-plugin-nx": {
"tags": []
},
"create-nx-workspace": {
"tags": []
},
"create-nx-plugin": {
"tags": []
},
"cli": {
"tags": []
},
"bazel": {
"tags": []
},
"angular": {
"tags": []
}
}
}
Loading

0 comments on commit d0cbc35

Please sign in to comment.