diff --git a/.gitignore b/.gitignore index cf358d2e01..8e6ab08609 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ node_modules .vscode dist build +test .DS_Store tmp yarn-error diff --git a/karma.conf.js b/karma.conf.js index 8aad07a746..75765d99e1 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,15 +1,15 @@ module.exports = function(config) { const webpackConfig = { - "node": { - "fs": "empty", - "global": true, - "crypto": "empty", - "tls": "empty", - "net": "empty", - "process": true, - "module": false, - "clearImmediate": false, - "setImmediate": false + node: { + fs: 'empty', + global: true, + crypto: 'empty', + tls: 'empty', + net: 'empty', + process: true, + module: false, + clearImmediate: false, + setImmediate: false } }; config.set({ @@ -20,9 +20,7 @@ module.exports = function(config) { frameworks: ['jasmine'], // list of files / patterns to load in the browser - files: [ - { pattern: 'build/test.js', watched: false} - ], + files: [{ pattern: 'test/test.js', watched: false }], // list of files to exclude exclude: [], @@ -30,7 +28,7 @@ module.exports = function(config) { // preprocess matching files before serving them to the browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { - 'build/test.js': ['webpack'] + 'test/test.js': ['webpack'] }, reporters: ['dots'], @@ -54,7 +52,7 @@ module.exports = function(config) { colors: true, // level of logging - logLevel:config.LOG_INFO, + logLevel: config.LOG_INFO, // enable / disable watching file and executing tests whenever any file changes autoWatch: true, @@ -66,7 +64,7 @@ module.exports = function(config) { } }, - browsers: process.env.TRAVIS ? ['Chrome_travis_ci'] : ['Chrome'], + browsers: process.env.TRAVIS ? ['Chrome_travis_ci'] : ['Chrome'], // Concurrency level // how many browser should be started simultaneous diff --git a/package.json b/package.json index 6827a61645..3d261bd10c 100644 --- a/package.json +++ b/package.json @@ -13,9 +13,9 @@ "release": "./scripts/release.sh", "copy": "./scripts/copy.sh", "test:schematics": "yarn linknpm && ./scripts/test_schematics.sh", - "test:nx": "./scripts/link-spec.sh && ./scripts/test_nx.sh", + "test:nx": "yarn linknpm && ./scripts/test_nx.sh", "test": - "./scripts/link-spec.sh && ./scripts/test_nx.sh && ./scripts/test_schematics.sh", + "yarn linknpm && ./scripts/test_nx.sh && ./scripts/test_schematics.sh", "checkformat": "echo 1", "publish_npm": "./scripts/publish.sh", "precommit": "yarn checkformat" diff --git a/packages/schematics/src/collection/app/index.ts b/packages/schematics/src/collection/app/index.ts index 29f04f0dd6..48110b98ab 100644 --- a/packages/schematics/src/collection/app/index.ts +++ b/packages/schematics/src/collection/app/index.ts @@ -44,7 +44,6 @@ function addBootstrap(path: string): Rule { const modulePath = `${path}/app/app.module.ts`; const moduleSource = host.read(modulePath)!.toString('utf-8'); const sourceFile = ts.createSourceFile( -<<<<<<< HEAD modulePath, moduleSource, ts.ScriptTarget.Latest, @@ -64,15 +63,6 @@ function addBootstrap(path: string): Rule { 'AppComponent', './app.component' ) -======= - modulePath, moduleSource, ts.ScriptTarget.Latest, true); - insert(host, modulePath, [ - insertImport( - sourceFile, modulePath, 'BrowserModule', '@angular/platform-browser'), - ...addImportToModule(sourceFile, modulePath, 'BrowserModule'), - ...addBootstrapToModule( - sourceFile, modulePath, 'AppComponent', './app.component') ->>>>>>> Rebasing issues resolved ]); return host; }; @@ -83,15 +73,11 @@ function addNxModule(path: string): Rule { const modulePath = `${path}/app/app.module.ts`; const moduleSource = host.read(modulePath)!.toString('utf-8'); const sourceFile = ts.createSourceFile( -<<<<<<< HEAD modulePath, moduleSource, ts.ScriptTarget.Latest, true ); -======= - modulePath, moduleSource, ts.ScriptTarget.Latest, true); ->>>>>>> Rebasing issues resolved insert(host, modulePath, [ insertImport(sourceFile, modulePath, 'NxModule', '@nrwl/nx'), ...addImportToModule(sourceFile, modulePath, 'NxModule.forRoot()') @@ -151,7 +137,6 @@ function addRouterRootConfiguration(path: string): Rule { const modulePath = `${path}/app/app.module.ts`; const moduleSource = host.read(modulePath)!.toString('utf-8'); const sourceFile = ts.createSourceFile( -<<<<<<< HEAD modulePath, moduleSource, ts.ScriptTarget.Latest, @@ -164,14 +149,6 @@ function addRouterRootConfiguration(path: string): Rule { modulePath, `RouterModule.forRoot([], {initialNavigation: 'enabled'})` ) -======= - modulePath, moduleSource, ts.ScriptTarget.Latest, true); - insert(host, modulePath, [ - insertImport(sourceFile, modulePath, 'RouterModule', '@angular/router'), - ...addImportToModule( - sourceFile, modulePath, - `RouterModule.forRoot([], {initialNavigation: 'enabled'})`) ->>>>>>> Rebasing issues resolved ]); const componentSpecPath = `${path}/app/app.component.spec.ts`; @@ -180,7 +157,6 @@ function addRouterRootConfiguration(path: string): Rule { componentSpecPath, componentSpecSource, ts.ScriptTarget.Latest, true); insert(host, componentSpecPath, [ insertImport( -<<<<<<< HEAD componentSpecSourceFile, componentSpecPath, 'RouterTestingModule', @@ -191,12 +167,6 @@ function addRouterRootConfiguration(path: string): Rule { componentSpecPath, `RouterTestingModule` ) -======= - componentSpecSourceFile, componentSpecPath, 'RouterTestingModule', - '@angular/router/testing'), - ...addImportToTestBed( - componentSpecSourceFile, componentSpecPath, `RouterTestingModule`) ->>>>>>> Rebasing issues resolved ]); return host; }; @@ -280,14 +250,9 @@ export default function(schema: Schema): Rule { function normalizeOptions(options: Schema): NormalizedSchema { const name = toFileName(options.name); -<<<<<<< HEAD const fullName = options.directory ? `${toFileName(options.directory)}/${name}` : name; -======= - const fullName = - options.directory ? `${toFileName(options.directory)}/${name}` : name; ->>>>>>> Rebasing issues resolved const fullPath = `apps/${fullName}/src`; return {...options, sourceDir: 'src', name, fullName, fullPath}; } diff --git a/packages/schematics/src/collection/lib/index.ts b/packages/schematics/src/collection/lib/index.ts index d32ea18d90..981b6a4b28 100644 --- a/packages/schematics/src/collection/lib/index.ts +++ b/packages/schematics/src/collection/lib/index.ts @@ -7,7 +7,8 @@ import { Rule, template, Tree, - url + url, + Source } from '@angular-devkit/schematics'; import { Schema } from './schema'; import * as path from 'path'; diff --git a/scripts/e2e-bazel.sh b/scripts/e2e-bazel.sh deleted file mode 100755 index d0cd7647d3..0000000000 --- a/scripts/e2e-bazel.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -./scripts/link.sh -rm -rf tmp -jest --maxWorkers=1 ./build/e2e/bazel diff --git a/scripts/link-spec.sh b/scripts/link-spec.sh deleted file mode 100755 index 92a47d76dd..0000000000 --- a/scripts/link-spec.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -rm -rf build/ - -tsc - -rsync -a --exclude=*.ts packages/ build/packages - -rm -rf node_modules/@nrwl -cp -r build/packages node_modules/@nrwl diff --git a/scripts/link.sh b/scripts/link.sh index 3a4563aef5..a012e61882 100755 --- a/scripts/link.sh +++ b/scripts/link.sh @@ -4,3 +4,12 @@ rm -rf node_modules/@nrwl cp -r build/packages node_modules/@nrwl + +rm -rf test/ + +tsc -p tsconfig.spec.json + +rsync -a --exclude=*.ts packages/ test/packages + +rm -rf node_modules/@nrwl +cp -r build/packages node_modules/@nrwl \ No newline at end of file diff --git a/scripts/test_schematics.sh b/scripts/test_schematics.sh index c6a7f82607..4a4410db69 100755 --- a/scripts/test_schematics.sh +++ b/scripts/test_schematics.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash if [ -n "$1" ]; then - jest --maxWorkers=1 ./build/packages/$1.spec.js + jest --maxWorkers=1 ./test/packages/$1.spec.js else - jest --maxWorkers=1 ./build/packages/{schematics,bazel} + jest --maxWorkers=1 ./test/packages/{schematics,bazel} fi diff --git a/tsconfig.json b/tsconfig.json index e2fdc8d025..d045a572b9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,15 +8,25 @@ "experimentalDecorators": true, "emitDecoratorMetadata": true, "skipLibCheck": true, - "lib": ["es2017"], + "lib": [ + "es2017" + ], "declaration": true, "baseUrl": ".", "paths": { - "@nrwl/schematics": ["./packages/schematics"], - "@nrwl/schematics/*": ["./packages/schematics/*"] + "@nrwl/schematics": [ + "./packages/schematics" + ], + "@nrwl/schematics/*": [ + "./packages/schematics/*" + ] } }, - "exclude": ["tmp", "node_modules"], + "exclude": [ + "tmp", + "node_modules", + "packages/schematics/src/*/files/**/*" + ], "angularCompilerOptions": { "strictMetadataEmit": true, "skipTemplateCodegen": true, diff --git a/tsconfig.spec.json b/tsconfig.spec.json new file mode 100644 index 0000000000..5569d6b560 --- /dev/null +++ b/tsconfig.spec.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "moduleResolution": "node", + "outDir": "test", + "typeRoots": ["node_modules/@types"], + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "skipLibCheck": true, + "lib": ["es2017"], + "declaration": true, + "baseUrl": "." + }, + "exclude": ["tmp", "node_modules"], + "angularCompilerOptions": { + "strictMetadataEmit": true, + "skipTemplateCodegen": true, + "annotationsAs": "decorators" + } +}