diff --git a/e2e/schematics/command-line.test.ts b/e2e/schematics/command-line.test.ts index 106eae3a5f..328ad41e51 100644 --- a/e2e/schematics/command-line.test.ts +++ b/e2e/schematics/command-line.test.ts @@ -236,8 +236,9 @@ describe('Command line', () => { }, 1000000); it('should pass tests', () => { - expect(runCommand('npm run test -- --single-run').toString()) - .toContain('Executed 1 of 1 SUCCESS'); + expect(runCommand('npm run test -- --single-run').toString()).toContain( + 'Executed 1 of 1 SUCCESS' + ); }); it('should not be able to run tests on an individual app', () => { @@ -246,14 +247,16 @@ describe('Command line', () => { fail('boom'); } catch (e) { const errorOutput = e.stderr.toString(); - expect(errorOutput) - .toContain('Nx only supports running unit tests for all apps and libs.'); + expect(errorOutput).toContain( + 'Nx only supports running unit tests for all apps and libs.' + ); } }); it('should pass e2e tests', () => { - expect(runCommand('npm run e2e -- --app app1').toString()) - .toContain('should display welcome message'); + expect(runCommand('npm run e2e -- --app app1').toString()).toContain( + 'should display welcome message' + ); }); it('should not be able to run e2e tests without specifying an app', () => { @@ -262,8 +265,9 @@ describe('Command line', () => { fail('boom'); } catch (e) { const errorOutput = e.stderr.toString(); - expect(errorOutput) - .toContain('Please provide the app name using --app or -a.') + expect(errorOutput).toContain( + 'Please provide the app name using --app or -a.' + ); } }); }); diff --git a/e2e/schematics/workspace.test.ts b/e2e/schematics/workspace.test.ts index 52a4e9c76d..5079c7cb71 100644 --- a/e2e/schematics/workspace.test.ts +++ b/e2e/schematics/workspace.test.ts @@ -82,9 +82,15 @@ describe('Nrwl Convert to Nx Workspace', () => { '@nrwl/schematics' ); - expect(updatedAngularCLIJson.lint[0].project).toEqual('apps/proj/src/tsconfig.app.json'); - expect(updatedAngularCLIJson.lint[1].project).toEqual('./tsconfig.spec.json'); - expect(updatedAngularCLIJson.lint[2].project).toEqual('apps/proj/e2e/tsconfig.e2e.json'); + expect(updatedAngularCLIJson.lint[0].project).toEqual( + 'apps/proj/src/tsconfig.app.json' + ); + expect(updatedAngularCLIJson.lint[1].project).toEqual( + './tsconfig.spec.json' + ); + expect(updatedAngularCLIJson.lint[2].project).toEqual( + 'apps/proj/e2e/tsconfig.e2e.json' + ); // check if tsconfig.json get merged const updatedTsConfig = JSON.parse(readFile('tsconfig.json')); diff --git a/package.json b/package.json index e2911d1ffe..fd4b650417 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "scripts": { "build": "./scripts/build.sh", "e2e": "./scripts/e2e.sh", - "format": "precise-commits --whitelist=\"{packages,e2e}/**/*.ts\"", + "format": "prettier \"{packages,e2e}/**/*.ts\" --write", "linknpm": "./scripts/link.sh", "package": "./scripts/package.sh", "release": "./scripts/release.sh", @@ -16,9 +16,8 @@ "test:nx": "yarn linknpm fast && ./scripts/test_nx.sh", "test": "yarn linknpm && ./scripts/test_nx.sh && ./scripts/test_schematics.sh", - "checkformat": "yarn format --check-only", - "publish_npm": "./scripts/publish.sh", - "precommit": "yarn checkformat" + "checkformat": "prettier \"{packages,e2e}/**/*.ts\" --list-different", + "publish_npm": "./scripts/publish.sh" }, "dependencies": { "jasmine-marbles": "0.2.0" diff --git a/packages/bazel/src/collection/lib/index.ts b/packages/bazel/src/collection/lib/index.ts index bc4ca48d2c..9667c7e641 100644 --- a/packages/bazel/src/collection/lib/index.ts +++ b/packages/bazel/src/collection/lib/index.ts @@ -1,12 +1,34 @@ -import { apply, branchAndMerge, chain, mergeWith, noop, Rule, template, Tree, url } from '@angular-devkit/schematics'; +import { + apply, + branchAndMerge, + chain, + mergeWith, + noop, + Rule, + template, + Tree, + url +} from '@angular-devkit/schematics'; import { insertImport } from '@schematics/angular/utility/route-utils'; import * as path from 'path'; import * as ts from 'typescript'; -import { addGlobal, addImportToModule, addIncludeToTsConfig, addReexport, addRoute, insert } from '../../utils/ast-utils'; +import { + addGlobal, + addImportToModule, + addIncludeToTsConfig, + addReexport, + addRoute, + insert +} from '../../utils/ast-utils'; import { offsetFromRoot } from '../../utils/common'; import { addApp, cliConfig, serializeJson } from '../../utils/fileutils'; -import { names, toClassName, toFileName, toPropertyName } from '../../utils/name-utils'; +import { + names, + toClassName, + toFileName, + toPropertyName +} from '../../utils/name-utils'; import { wrapIntoFormat } from '../../utils/tasks'; import { Schema } from './schema'; @@ -236,28 +258,32 @@ function validateLibSchema(schema) { } const routingRules: Array = [ - options.routing && options.lazy ? - addLazyLoadedRouterConfiguration(modulePath) : - noop(), - options.routing && options.lazy && options.parentModule ? - addLoadChildren(options) : - noop(), + options.routing && options.lazy + ? addLazyLoadedRouterConfiguration(modulePath) + : noop(), + options.routing && options.lazy && options.parentModule + ? addLoadChildren(options) + : noop(), - options.routing && !options.lazy ? - addRouterConfiguration(options, indexFile, moduleFileName, modulePath) : - noop(), - options.routing && !options.lazy && options.parentModule ? - addChildren(options) : - noop() + options.routing && !options.lazy + ? addRouterConfiguration(options, indexFile, moduleFileName, modulePath) + : noop(), + options.routing && !options.lazy && options.parentModule + ? addChildren(options) + : noop() ]; - const templateSource = - apply(url(options.nomodule ? './files' : './ngfiles'), [template({ - ...names(options.name), - dot: '.', - tmpl: '', - ...(options as object) - })]); + const templateSource = apply( + url(options.nomodule ? './files' : './ngfiles'), + [ + template({ + ...names(options.name), + dot: '.', + tmpl: '', + ...(options as object) + }) + ] + ); return { options, @@ -271,9 +297,11 @@ function validateLibSchema(schema) { export default function(schema: Schema): Rule { return wrapIntoFormat(() => { - const {templateSource, routingRules} = validateLibSchema(schema); + const { templateSource, routingRules } = validateLibSchema(schema); - return chain( - [branchAndMerge(chain([mergeWith(templateSource)])), ...routingRules]); + return chain([ + branchAndMerge(chain([mergeWith(templateSource)])), + ...routingRules + ]); }); } diff --git a/packages/bazel/src/collection/module/index.ts b/packages/bazel/src/collection/module/index.ts index 84d3427bb9..75e416b519 100644 --- a/packages/bazel/src/collection/module/index.ts +++ b/packages/bazel/src/collection/module/index.ts @@ -13,7 +13,7 @@ import { Tree, url, TaskConfigurationGenerator, - TaskConfiguration, + TaskConfiguration } from '@angular-devkit/schematics'; import { Schema } from './schema'; diff --git a/packages/schematics/migrations/20180321-add-karma-app-check.ts b/packages/schematics/migrations/20180321-add-karma-app-check.ts index 55685d85c3..8aa0475c0f 100644 --- a/packages/schematics/migrations/20180321-add-karma-app-check.ts +++ b/packages/schematics/migrations/20180321-add-karma-app-check.ts @@ -7,16 +7,22 @@ export default { description: 'Add makeSureNoAppIsSelected(); to karma conf', run: async () => { const contents = fs.readFileSync('karma.conf.js').toString(); - const sourceFile = ts.createSourceFile('karma.conf.js', contents, ts.ScriptTarget.Latest); + const sourceFile = ts.createSourceFile( + 'karma.conf.js', + contents, + ts.ScriptTarget.Latest + ); const nodes = getSourceNodes(sourceFile); const isPresent = nodes .filter(ts.isCallExpression) - .filter((callExpr: ts.CallExpression) => ts.isIdentifier(callExpr.expression)) + .filter((callExpr: ts.CallExpression) => + ts.isIdentifier(callExpr.expression) + ) .some((callExpr: ts.CallExpression) => { const identifier = callExpr.expression as ts.Identifier; return identifier.escapedText === 'makeSureNoAppIsSelected'; }); - + if (isPresent) { return; } diff --git a/packages/schematics/src/command-line/affected.ts b/packages/schematics/src/command-line/affected.ts index f93ad5f7db..27c4344434 100644 --- a/packages/schematics/src/command-line/affected.ts +++ b/packages/schematics/src/command-line/affected.ts @@ -52,12 +52,15 @@ function build(apps: string[], rest: string[]) { console.log(`Building ${apps.join(', ')}`); const buildCommands = rest.filter(a => !a.startsWith('--parallel')); - runAll(apps.map(app => `ng build -- ${buildCommands.join(' ')} -a=${app}`), { - parallel, - stdin: process.stdin, - stdout: process.stdout, - stderr: process.stderr - }) + runAll( + apps.map(app => `ng build -- ${buildCommands.join(' ')} -a=${app}`), + { + parallel, + stdin: process.stdin, + stdout: process.stdout, + stderr: process.stderr + } + ) .then(() => console.log('Build succeeded.')) .catch(err => console.error('Build failed.')); } else { diff --git a/packages/schematics/src/command-line/shared.ts b/packages/schematics/src/command-line/shared.ts index 1687e09517..bf373b587b 100644 --- a/packages/schematics/src/command-line/shared.ts +++ b/packages/schematics/src/command-line/shared.ts @@ -75,7 +75,9 @@ export function getProjectNodes(config) { } export function readCliConfig(): any { - const config = JSON.parse(fs.readFileSync(`${appRoot.path}/.angular-cli.json`, 'utf-8')); + const config = JSON.parse( + fs.readFileSync(`${appRoot.path}/.angular-cli.json`, 'utf-8') + ); if (!config.project.npmScope) { throw new Error(`.angular-cli.json must define the npmScope property.`); @@ -97,7 +99,9 @@ export function getAffectedApps(touchedFiles: string[]): string[] { } export function getTouchedProjects(touchedFiles: string[]): string[] { - return touchedProjects(getProjectNodes(readCliConfig()), touchedFiles).filter(p => !!p); + return touchedProjects(getProjectNodes(readCliConfig()), touchedFiles).filter( + p => !!p + ); } export function getProjectRoots(projectNames: string[]): string[] { @@ -131,7 +135,10 @@ export function readDependencies( if (!directoryExists(`${appRoot.path}/dist`)) { fs.mkdirSync(`${appRoot.path}/dist`); } - if (!fileExists(`${appRoot.path}/dist/nxdeps.json`) || m > mtime(`${appRoot.path}/dist/nxdeps.json`)) { + if ( + !fileExists(`${appRoot.path}/dist/nxdeps.json`) || + m > mtime(`${appRoot.path}/dist/nxdeps.json`) + ) { const deps = dependencies(npmScope, projectNodes, f => fs.readFileSync(`${appRoot.path}/${f}`, 'UTF-8') ); @@ -142,7 +149,9 @@ export function readDependencies( ); return deps; } else { - return JSON.parse(fs.readFileSync(`${appRoot.path}/dist/nxdeps.json`, 'UTF-8')); + return JSON.parse( + fs.readFileSync(`${appRoot.path}/dist/nxdeps.json`, 'UTF-8') + ); } } diff --git a/scripts/build.sh b/scripts/build.sh index 7b3e0a43d8..95ffc109a5 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -7,6 +7,7 @@ rm -rf build #Nx client side lib cp -r packages/nx/dist build/packages/nx rm -rf build/packages/nx/dist +rm -rf packages/nx/dist #TODO This is a temporary hack until we can publish named umds sed -i.bak "s/define(\[/define('@nrwl\/nx',\[/" build/packages/nx/bundles/nrwl-nx.umd.js