This commit is contained in:
vsavkin 2017-09-23 15:00:24 -04:00
parent e2c8ef7a36
commit a49be880d7
8 changed files with 21 additions and 21 deletions

View File

@ -1,4 +1,4 @@
import {checkFilesExists, cleanup, copyMissingPackages, ngNewBazel, readFile, runCLI, runSchematic} from '../utils'; import {checkFilesExist, cleanup, copyMissingPackages, ngNewBazel, readFile, runCLI, runSchematic} from '../utils';
describe('application', () => { describe('application', () => {
beforeEach(cleanup); beforeEach(cleanup);
@ -8,7 +8,7 @@ describe('application', () => {
ngNewBazel('--collection=@nrwl/bazel --skip-install'); ngNewBazel('--collection=@nrwl/bazel --skip-install');
runSchematic('@nrwl/bazel:app --name=myApp'); runSchematic('@nrwl/bazel:app --name=myApp');
checkFilesExists( checkFilesExist(
`tsconfig.json`, `WORKSPACE`, `BUILD.bazel`, `apps/my-app/BUILD.bazel`, `apps/my-app/src/index.html`, `tsconfig.json`, `WORKSPACE`, `BUILD.bazel`, `apps/my-app/BUILD.bazel`, `apps/my-app/src/index.html`,
`apps/my-app/src/app/app.module.ts`, `apps/my-app/src/app/app.component.ts`); `apps/my-app/src/app/app.module.ts`, `apps/my-app/src/app/app.component.ts`);

View File

@ -1,4 +1,4 @@
import {checkFilesExists, cleanup, copyMissingPackages, ngNewBazel, readFile, runCLI, runSchematic} from '../utils'; import {checkFilesExist, cleanup, copyMissingPackages, ngNewBazel, readFile, runCLI, runSchematic} from '../utils';
describe('library', () => { describe('library', () => {
beforeEach(cleanup); beforeEach(cleanup);
@ -8,7 +8,7 @@ describe('library', () => {
ngNewBazel('--collection=@nrwl/bazel --skip-install'); ngNewBazel('--collection=@nrwl/bazel --skip-install');
runSchematic('@nrwl/bazel:lib --name=myLib'); runSchematic('@nrwl/bazel:lib --name=myLib');
checkFilesExists( checkFilesExist(
'tsconfig.json', 'WORKSPACE', 'BUILD.bazel', 'libs/my-lib/BUILD.bazel', 'libs/my-lib/index.ts', 'tsconfig.json', 'WORKSPACE', 'BUILD.bazel', 'libs/my-lib/BUILD.bazel', 'libs/my-lib/index.ts',
'libs/my-lib/src/my-lib.ts'); 'libs/my-lib/src/my-lib.ts');

View File

@ -1,4 +1,4 @@
import {checkFilesExists, cleanup, copyMissingPackages, ngNew, ngNewBazel, readFile, runCLI, runCommand, runSchematic, updateFile} from '../utils'; import {checkFilesExist, cleanup, copyMissingPackages, ngNew, ngNewBazel, readFile, runCLI, runCommand, runSchematic, updateFile} from '../utils';
describe('angular library', () => { describe('angular library', () => {
beforeEach(cleanup); beforeEach(cleanup);
@ -8,7 +8,7 @@ describe('angular library', () => {
ngNewBazel('--collection=@nrwl/bazel --skip-install'); ngNewBazel('--collection=@nrwl/bazel --skip-install');
runSchematic('@nrwl/bazel:nglib --name=myLib'); runSchematic('@nrwl/bazel:nglib --name=myLib');
checkFilesExists( checkFilesExist(
'tsconfig.json', 'WORKSPACE', 'BUILD.bazel', 'libs/my-lib/BUILD.bazel', 'libs/my-lib/index.ts', 'tsconfig.json', 'WORKSPACE', 'BUILD.bazel', 'libs/my-lib/BUILD.bazel', 'libs/my-lib/index.ts',
'libs/my-lib/src/my-lib.module.ts'); 'libs/my-lib/src/my-lib.module.ts');

View File

@ -1,10 +1,10 @@
import {checkFilesExists, cleanup, copyMissingPackages, ngNew, ngNewBazel, readFile, runCLI, runCommand, runSchematic, updateFile} from '../utils'; import {checkFilesExist, cleanup, copyMissingPackages, ngNew, ngNewBazel, readFile, runCLI, runCommand, runSchematic, updateFile} from '../utils';
describe('workspace', () => { describe('workspace', () => {
beforeEach(cleanup); beforeEach(cleanup);
it('creates a new workspace for developing angular applications', () => { it('creates a new workspace for developing angular applications', () => {
ngNewBazel('--collection=@nrwl/bazel --skip-install'); ngNewBazel('--collection=@nrwl/bazel --skip-install');
checkFilesExists(`tsconfig.json`, `WORKSPACE`, `BUILD.bazel`); checkFilesExist(`tsconfig.json`, `WORKSPACE`, `BUILD.bazel`);
}); });
}); });

View File

@ -1,4 +1,4 @@
import {checkFilesExists, cleanup, ngNew, readFile, runCLI, runSchematic, updateFile} from '../utils'; import {checkFilesExist, cleanup, ngNew, readFile, runCLI, runSchematic, updateFile} from '../utils';
describe('Nrwl Convert to Nx Workspace', () => { describe('Nrwl Convert to Nx Workspace', () => {
beforeEach(cleanup); beforeEach(cleanup);
@ -27,7 +27,7 @@ describe('Nrwl Convert to Nx Workspace', () => {
runSchematic('@nrwl/schematics:convert-to-workspace'); runSchematic('@nrwl/schematics:convert-to-workspace');
// check that files have been moved! // check that files have been moved!
checkFilesExists('apps/proj/src/main.ts', 'apps/proj/src/app/app.module.ts'); checkFilesExist('apps/proj/src/main.ts', 'apps/proj/src/app/app.module.ts');
// check that package.json got merged // check that package.json got merged
const updatedPackageJson = JSON.parse(readFile('package.json')); const updatedPackageJson = JSON.parse(readFile('package.json'));

View File

@ -1,4 +1,4 @@
import {checkFilesExists, cleanup, copyMissingPackages, ngNew, readFile, runCLI} from '../utils'; import {checkFilesExist, cleanup, copyMissingPackages, ngNew, readFile, runCLI} from '../utils';
describe('ngrx', () => { describe('ngrx', () => {
beforeEach(cleanup); beforeEach(cleanup);
@ -8,7 +8,7 @@ describe('ngrx', () => {
ngNew('--skip-install'); ngNew('--skip-install');
runCLI('generate ngrx app --module=src/app/app.module.ts --root --collection=@nrwl/schematics'); runCLI('generate ngrx app --module=src/app/app.module.ts --root --collection=@nrwl/schematics');
checkFilesExists( checkFilesExist(
`src/app/+state/app.actions.ts`, `src/app/+state/app.effects.ts`, `src/app/+state/app.effects.spec.ts`, `src/app/+state/app.actions.ts`, `src/app/+state/app.effects.ts`, `src/app/+state/app.effects.spec.ts`,
`src/app/+state/app.init.ts`, `src/app/+state/app.interfaces.ts`, `src/app/+state/app.reducer.ts`, `src/app/+state/app.init.ts`, `src/app/+state/app.interfaces.ts`, `src/app/+state/app.reducer.ts`,
`src/app/+state/app.reducer.spec.ts`); `src/app/+state/app.reducer.spec.ts`);
@ -45,7 +45,7 @@ describe('ngrx', () => {
ngNew('--skip-install'); ngNew('--skip-install');
runCLI('generate ngrx app --module=src/app/app.module.ts --collection=@nrwl/schematics'); runCLI('generate ngrx app --module=src/app/app.module.ts --collection=@nrwl/schematics');
checkFilesExists( checkFilesExist(
`src/app/+state/app.actions.ts`, `src/app/+state/app.effects.ts`, `src/app/+state/app.effects.spec.ts`, `src/app/+state/app.actions.ts`, `src/app/+state/app.effects.ts`, `src/app/+state/app.effects.spec.ts`,
`src/app/+state/app.init.ts`, `src/app/+state/app.interfaces.ts`, `src/app/+state/app.reducer.ts`, `src/app/+state/app.init.ts`, `src/app/+state/app.interfaces.ts`, `src/app/+state/app.reducer.ts`,
`src/app/+state/app.reducer.spec.ts`); `src/app/+state/app.reducer.spec.ts`);
@ -60,7 +60,7 @@ describe('ngrx', () => {
ngNew('--skip-install'); ngNew('--skip-install');
runCLI('generate ngrx app --module=src/app/app.module.ts --onlyAddFiles --collection=@nrwl/schematics'); runCLI('generate ngrx app --module=src/app/app.module.ts --onlyAddFiles --collection=@nrwl/schematics');
checkFilesExists( checkFilesExist(
`src/app/+state/app.actions.ts`, `src/app/+state/app.effects.ts`, `src/app/+state/app.effects.spec.ts`, `src/app/+state/app.actions.ts`, `src/app/+state/app.effects.ts`, `src/app/+state/app.effects.spec.ts`,
`src/app/+state/app.init.ts`, `src/app/+state/app.interfaces.ts`, `src/app/+state/app.reducer.ts`, `src/app/+state/app.init.ts`, `src/app/+state/app.interfaces.ts`, `src/app/+state/app.reducer.ts`,
`src/app/+state/app.reducer.spec.ts`); `src/app/+state/app.reducer.spec.ts`);

View File

@ -1,4 +1,4 @@
import {checkFilesExists, cleanup, copyMissingPackages, newApp, newLib, ngNew, readFile, runCLI, updateFile} from '../utils'; import {checkFilesExist, cleanup, copyMissingPackages, newApp, newLib, ngNew, readFile, runCLI, updateFile} from '../utils';
describe('Nrwl Workspace', () => { describe('Nrwl Workspace', () => {
beforeEach(cleanup); beforeEach(cleanup);
@ -12,7 +12,7 @@ describe('Nrwl Workspace', () => {
const packageJson = JSON.parse(readFile('package.json')); const packageJson = JSON.parse(readFile('package.json'));
expect(packageJson.devDependencies['@nrwl/schematics']).toBeDefined(); expect(packageJson.devDependencies['@nrwl/schematics']).toBeDefined();
expect(packageJson.dependencies['@nrwl/nx']).toBeDefined(); expect(packageJson.dependencies['@nrwl/nx']).toBeDefined();
checkFilesExists('test.js', 'tsconfig.app.json', 'tsconfig.spec.json', 'tsconfig.e2e.json', 'apps', 'libs'); checkFilesExist('test.js', 'tsconfig.app.json', 'tsconfig.spec.json', 'tsconfig.e2e.json', 'apps', 'libs');
}); });
describe('app', () => { describe('app', () => {
@ -23,7 +23,7 @@ describe('Nrwl Workspace', () => {
const angularCliJson = JSON.parse(readFile('.angular-cli.json')); const angularCliJson = JSON.parse(readFile('.angular-cli.json'));
expect(angularCliJson.apps[0].name).toEqual('myapp'); expect(angularCliJson.apps[0].name).toEqual('myapp');
checkFilesExists( checkFilesExist(
'apps/myapp/src/main.ts', 'apps/myapp/src/app/app.module.ts', 'apps/myapp/src/app/app.component.ts', 'apps/myapp/src/main.ts', 'apps/myapp/src/app/app.module.ts', 'apps/myapp/src/app/app.component.ts',
'apps/myapp/e2e/app.po.ts'); 'apps/myapp/e2e/app.po.ts');
}); });
@ -33,7 +33,7 @@ describe('Nrwl Workspace', () => {
copyMissingPackages(); copyMissingPackages();
newApp('myapp'); newApp('myapp');
runCLI('build --aot'); runCLI('build --aot');
checkFilesExists('dist/apps/myapp/main.bundle.js'); checkFilesExist('dist/apps/myapp/main.bundle.js');
expect(runCLI('test --single-run')).toContain('Executed 1 of 1 SUCCESS'); expect(runCLI('test --single-run')).toContain('Executed 1 of 1 SUCCESS');
}); });
}); });
@ -46,7 +46,7 @@ describe('Nrwl Workspace', () => {
const angularCliJson = JSON.parse(readFile('.angular-cli.json')); const angularCliJson = JSON.parse(readFile('.angular-cli.json'));
expect(angularCliJson.apps[0].name).toEqual('mylib'); expect(angularCliJson.apps[0].name).toEqual('mylib');
checkFilesExists('libs/mylib/src/mylib.ts', 'libs/mylib/src/mylib.spec.ts', 'libs/mylib/index.ts'); checkFilesExist('libs/mylib/src/mylib.ts', 'libs/mylib/src/mylib.spec.ts', 'libs/mylib/index.ts');
}); });
it('should test a lib', () => { it('should test a lib', () => {
@ -64,7 +64,7 @@ describe('Nrwl Workspace', () => {
ngNew('--collection=@nrwl/schematics --skip-install'); ngNew('--collection=@nrwl/schematics --skip-install');
newLib('mylib --ngmodule'); newLib('mylib --ngmodule');
checkFilesExists('libs/mylib/src/mylib.module.ts', 'libs/mylib/src/mylib.module.spec.ts', 'libs/mylib/index.ts'); checkFilesExist('libs/mylib/src/mylib.module.ts', 'libs/mylib/src/mylib.module.spec.ts', 'libs/mylib/index.ts');
}); });
it('should test an ng lib', () => { it('should test an ng lib', () => {

View File

@ -46,7 +46,7 @@ export function updateFile(f: string, content: string): void {
writeFileSync(path.join(getCwd(), 'tmp', 'proj', f), content); writeFileSync(path.join(getCwd(), 'tmp', 'proj', f), content);
} }
export function checkFilesExists(...expectedFiles: string[]) { export function checkFilesExist(...expectedFiles: string[]) {
expectedFiles.forEach(f => { expectedFiles.forEach(f => {
const ff = f.startsWith('/') ? f : path.join(getCwd(), 'tmp', projectName, f); const ff = f.startsWith('/') ? f : path.join(getCwd(), 'tmp', projectName, f);
if (!exists(ff)) { if (!exists(ff)) {