test: update to support targets & architect fields

This commit is contained in:
Charles Lyding 2018-09-10 15:17:00 -04:00 committed by Keen Yee Liau
parent f107d2de11
commit 57c049e507
39 changed files with 108 additions and 102 deletions

View File

@ -51,7 +51,7 @@ describe('PWA Schematic', () => {
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).toPromise().then(tree => {
const configText = tree.readContent('/angular.json');
const config = JSON.parse(configText);
const swFlag = config.projects.bar.targets.build.configurations.production.serviceWorker;
const swFlag = config.projects.bar.architect.build.configurations.production.serviceWorker;
expect(swFlag).toEqual(true);
done();
}, done.fail);
@ -131,7 +131,7 @@ describe('PWA Schematic', () => {
schematicRunner.runSchematicAsync('ng-add', defaultOptions, appTree).toPromise().then(tree => {
const configText = tree.readContent('/angular.json');
const config = JSON.parse(configText);
const targets = config.projects.bar.targets;
const targets = config.projects.bar.architect;
['build', 'test'].forEach((target) => {
expect(targets[target].options.assets).toContain('projects/bar/src/manifest.json');

View File

@ -64,7 +64,7 @@ describe('App Shell Schematic', () => {
const filePath = '/angular.json';
const content = tree.readContent(filePath);
const workspace = JSON.parse(content);
const target = workspace.projects.bar.targets['app-shell'];
const target = workspace.projects.bar.architect['app-shell'];
expect(target.options.browserTarget).toEqual('bar:build');
expect(target.options.serverTarget).toEqual('bar:server');
expect(target.options.route).toEqual('shell');

View File

@ -207,13 +207,13 @@ describe('Application Schematic', () => {
const config = JSON.parse(tree.readContent('/angular.json'));
const prj = config.projects.foo;
expect(prj.root).toEqual('');
const buildOpt = prj.targets.build.options;
const buildOpt = prj.architect.build.options;
expect(buildOpt.index).toEqual('src/index.html');
expect(buildOpt.main).toEqual('src/main.ts');
expect(buildOpt.polyfills).toEqual('src/polyfills.ts');
expect(buildOpt.tsConfig).toEqual('src/tsconfig.app.json');
const testOpt = prj.targets.test.options;
const testOpt = prj.architect.test.options;
expect(testOpt.main).toEqual('src/test.ts');
expect(testOpt.tsConfig).toEqual('src/tsconfig.spec.json');
expect(testOpt.karmaConfig).toEqual('src/karma.conf.js');

View File

@ -79,14 +79,14 @@ describe('Application Schematic', () => {
it('should set 2 targets for the app', () => {
const tree = schematicRunner.runSchematic('e2e', defaultOptions, workspaceTree);
const workspace = JSON.parse(tree.readContent('/angular.json'));
const targets = workspace.projects.foo.targets;
const targets = workspace.projects.foo.architect;
expect(Object.keys(targets)).toEqual(['e2e', 'lint']);
});
it('should set the e2e options', () => {
const tree = schematicRunner.runSchematic('e2e', defaultOptions, workspaceTree);
const workspace = JSON.parse(tree.readContent('/angular.json'));
const e2eOptions = workspace.projects.foo.targets.e2e.options;
const e2eOptions = workspace.projects.foo.architect.e2e.options;
expect(e2eOptions.protractorConfig).toEqual('projects/foo/protractor.conf.js');
expect(e2eOptions.devServerTarget).toEqual('app:serve');
});
@ -94,7 +94,7 @@ describe('Application Schematic', () => {
it('should set the lint options', () => {
const tree = schematicRunner.runSchematic('e2e', defaultOptions, workspaceTree);
const workspace = JSON.parse(tree.readContent('/angular.json'));
const lintOptions = workspace.projects.foo.targets.lint.options;
const lintOptions = workspace.projects.foo.architect.lint.options;
expect(lintOptions.tsConfig).toEqual('projects/foo/tsconfig.e2e.json');
});
});

View File

@ -121,7 +121,7 @@ function migrateConfiguration(oldConfig: CliConfig, logger: logging.LoggerApi):
}
const targetsConfig = extractTargetsConfig(oldConfig);
if (targetsConfig !== null) {
config.targets = targetsConfig;
config.architect = targetsConfig;
}
context.logger.info(`Removing old config file (${oldConfigPath})`);
@ -577,7 +577,7 @@ function extractProjectsConfig(
};
e2eTargets.lint = e2eLintTarget;
if (protractorConfig) {
e2eProject.targets = e2eTargets;
e2eProject.architect = e2eTargets;
}
return { name, project, e2eProject };

View File

@ -124,6 +124,13 @@ describe('Migration to v6', () => {
return JSON.parse(tree.readContent(configPath));
}
// tslint:disable-next-line:no-any
function getTarget(tree: UnitTestTree, targetName: string): any {
const project = getConfig(tree).projects.foo;
return project.architect[targetName];
}
describe('file creation/deletion', () => {
it('should delete the old config file', () => {
tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));
@ -474,7 +481,7 @@ describe('Migration to v6', () => {
tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));
tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
const config = getConfig(tree);
expect(config.targets).not.toBeDefined();
expect(config.architect).not.toBeDefined();
});
});
@ -526,7 +533,7 @@ describe('Migration to v6', () => {
it('should set build target', () => {
tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));
tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
const build = getConfig(tree).projects.foo.targets.build;
const build = getTarget(tree, 'build');
expect(build.builder).toEqual('@angular-devkit/build-angular:browser');
expect(build.options.scripts).toEqual([]);
expect(build.options.styles).toEqual(['src/styles.css']);
@ -560,7 +567,7 @@ describe('Migration to v6', () => {
it('should not set baseHref on build & serve targets if not defined', () => {
tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));
tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
const build = getConfig(tree).projects.foo.targets.build;
const build = getTarget(tree, 'build');
expect(build.options.baseHref).toBeUndefined();
});
@ -569,7 +576,7 @@ describe('Migration to v6', () => {
config.apps[0].baseHref = '/base/href/';
tree.create(oldConfigPath, JSON.stringify(config, null, 2));
tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
const build = getConfig(tree).projects.foo.targets.build;
const build = getTarget(tree, 'build');
expect(build.options.baseHref).toEqual('/base/href/');
});
@ -577,19 +584,17 @@ describe('Migration to v6', () => {
baseConfig.apps[0].serviceWorker = true;
tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));
tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
const config = getConfig(tree);
expect(config.projects.foo.targets.build.options.serviceWorker).toBeUndefined();
expect(
config.projects.foo.targets.build.configurations.production.serviceWorker,
).toBe(true);
const build = getTarget(tree, 'build');
expect(build.options.serviceWorker).toBeUndefined();
expect(build.configurations.production.serviceWorker).toBe(true);
});
it('should add production configuration when no environments', () => {
delete baseConfig.apps[0].environments;
tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));
tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
const config = getConfig(tree);
expect(config.projects.foo.targets.build.configurations).toEqual({
const build = getTarget(tree, 'build');
expect(build.configurations).toEqual({
production: {
optimization: true,
outputHashing: 'all',
@ -608,8 +613,8 @@ describe('Migration to v6', () => {
tree.delete('/src/environments/environment.prod.ts');
tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));
tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
const config = getConfig(tree);
expect(config.projects.foo.targets.build.configurations).toEqual({
const build = getTarget(tree, 'build');
expect(build.configurations).toEqual({
prod: {
fileReplacements: [{
replace: 'src/environments/environment.ts',
@ -633,7 +638,7 @@ describe('Migration to v6', () => {
it('should set the serve target', () => {
tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));
tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
const serve = getConfig(tree).projects.foo.targets.serve;
const serve = getTarget(tree, 'serve');
expect(serve.builder).toEqual('@angular-devkit/build-angular:dev-server');
expect(serve.options).toEqual({
browserTarget: 'foo:build',
@ -646,7 +651,7 @@ describe('Migration to v6', () => {
it('should set the test target', () => {
tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));
tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
const test = getConfig(tree).projects.foo.targets['test'];
const test = getTarget(tree, 'test');
expect(test.builder).toEqual('@angular-devkit/build-angular:karma');
expect(test.options.main).toEqual('src/test.ts');
expect(test.options.polyfills).toEqual('src/polyfills.ts');
@ -665,7 +670,7 @@ describe('Migration to v6', () => {
it('should set the extract i18n target', () => {
tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));
tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
const extract = getConfig(tree).projects.foo.targets['extract-i18n'];
const extract = getTarget(tree, 'extract-i18n');
expect(extract.builder).toEqual('@angular-devkit/build-angular:extract-i18n');
expect(extract.options).toBeDefined();
expect(extract.options.browserTarget).toEqual(`foo:build` );
@ -674,7 +679,7 @@ describe('Migration to v6', () => {
it('should set the lint target', () => {
tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));
tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
const tslint = getConfig(tree).projects.foo.targets['lint'];
const tslint = getTarget(tree, 'lint');
expect(tslint.builder).toEqual('@angular-devkit/build-angular:tslint');
expect(tslint.options).toBeDefined();
expect(tslint.options.tsConfig)
@ -691,8 +696,8 @@ describe('Migration to v6', () => {
tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));
tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
const config = getConfig(tree);
const budgets = config.projects.foo.targets.build.configurations.production.budgets;
const build = getTarget(tree, 'build');
const budgets = build.configurations.production.budgets;
expect(budgets.length).toEqual(1);
expect(budgets[0].type).toEqual('bundle');
expect(budgets[0].name).toEqual('main');
@ -707,7 +712,7 @@ describe('Migration to v6', () => {
const e2eProject = getConfig(tree).projects['foo-e2e'];
expect(e2eProject.root).toBe('e2e');
expect(e2eProject.sourceRoot).toBe('e2e');
const e2eOptions = e2eProject.targets.e2e;
const e2eOptions = e2eProject.architect.e2e;
expect(e2eOptions.builder).toEqual('@angular-devkit/build-angular:protractor');
const options = e2eOptions.options;
expect(options.protractorConfig).toEqual('./protractor.conf.js');
@ -721,7 +726,7 @@ describe('Migration to v6', () => {
const e2eProject = getConfig(tree).projects['foo-e2e'];
expect(e2eProject.root).toBe('apps/app1/e2e');
expect(e2eProject.sourceRoot).toBe('apps/app1/e2e');
const e2eOptions = e2eProject.targets.e2e;
const e2eOptions = e2eProject.architect.e2e;
expect(e2eOptions.builder).toEqual('@angular-devkit/build-angular:protractor');
const options = e2eOptions.options;
expect(options.protractorConfig).toEqual('./protractor.conf.js');
@ -731,7 +736,7 @@ describe('Migration to v6', () => {
it('should set the lint target', () => {
tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));
tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
const tslint = getConfig(tree).projects['foo-e2e'].targets.lint;
const tslint = getConfig(tree).projects['foo-e2e'].architect.lint;
expect(tslint.builder).toEqual('@angular-devkit/build-angular:tslint');
expect(tslint.options).toBeDefined();
expect(tslint.options.tsConfig).toEqual(['e2e/tsconfig.e2e.json']);
@ -988,7 +993,7 @@ describe('Migration to v6', () => {
tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));
tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
const config = getConfig(tree);
const target = config.projects.foo.targets.server;
const target = config.projects.foo.architect.server;
expect(target).toBeDefined();
expect(target.builder).toEqual('@angular-devkit/build-angular:server');
expect(target.options.outputPath).toEqual('dist/server');

View File

@ -45,11 +45,12 @@ describe('Service Worker Schematic', () => {
appTree = schematicRunner.runSchematic('application', appOptions, appTree);
});
it('should update the proudction configuration', () => {
it('should update the production configuration', () => {
const tree = schematicRunner.runSchematic('service-worker', defaultOptions, appTree);
const configText = tree.readContent('/angular.json');
const config = JSON.parse(configText);
const swFlag = config.projects.bar.targets.build.configurations.production.serviceWorker;
const swFlag = config.projects.bar.architect
.build.configurations.production.serviceWorker;
expect(swFlag).toEqual(true);
});
@ -58,7 +59,8 @@ describe('Service Worker Schematic', () => {
const tree = schematicRunner.runSchematic('service-worker', options, appTree);
const configText = tree.readContent('/angular.json');
const config = JSON.parse(configText);
const swFlag = config.projects.bar.targets.build.options.serviceWorker;
const swFlag = config.projects.bar.architect
.build.options.serviceWorker;
expect(swFlag).toEqual(true);
});

View File

@ -87,8 +87,8 @@ describe('Universal Schematic', () => {
},
});
const angularConfig = JSON.parse(tree.readContent('angular.json'));
expect(angularConfig.projects.workspace.targets.server.options.tsConfig)
.toEqual('src/tsconfig.server.json');
expect(angularConfig.projects.workspace.architect
.server.options.tsConfig).toEqual('src/tsconfig.server.json');
});
it('should create a tsconfig file for a generated application', () => {
@ -107,8 +107,8 @@ describe('Universal Schematic', () => {
},
});
const angularConfig = JSON.parse(tree.readContent('angular.json'));
expect(angularConfig.projects.bar.targets.server.options.tsConfig)
.toEqual('projects/bar/tsconfig.server.json');
expect(angularConfig.projects.bar.architect
.server.options.tsConfig).toEqual('projects/bar/tsconfig.server.json');
});
it('should add dependency: @angular/platform-server', () => {
@ -123,7 +123,7 @@ describe('Universal Schematic', () => {
const filePath = '/angular.json';
const contents = tree.readContent(filePath);
const config = JSON.parse(contents.toString());
const targets = config.projects.bar.targets;
const targets = config.projects.bar.architect;
expect(targets.server).toBeDefined();
expect(targets.server.builder).toBeDefined();
const opts = targets.server.options;

View File

@ -93,9 +93,9 @@ export default function () {
{ 'glob': '**/*', 'input': 'src/folder', 'output': 'folder' },
{ 'glob': 'glob-asset.txt' },
{ 'glob': 'output-asset.txt', 'output': 'output-folder' },
{ 'glob': '**/*', 'input': 'node_modules/some-package/', 'output': 'package-folder' }
{ 'glob': '**/*', 'input': 'node_modules/some-package/', 'output': 'package-folder' },
];
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.assets = assets;
appArchitect.test.options.assets = assets;
}))

View File

@ -25,11 +25,11 @@ export default function () {
'src/input-script.js': 'console.log(\'input-script\');',
'src/lazy-script.js': 'console.log(\'lazy-script\');',
'src/pre-rename-script.js': 'console.log(\'pre-rename-script\');',
'src/pre-rename-lazy-script.js': 'console.log(\'pre-rename-lazy-script\');'
'src/pre-rename-lazy-script.js': 'console.log(\'pre-rename-lazy-script\');',
})
.then(() => appendToFile('src/main.ts', 'import \'./string-script.js\';'))
.then(() => updateJsonFile('angular.json', configJson => {
const appArchitect = configJson.projects['test-project'].targets;
const appArchitect = configJson.projects['test-project'].architect;
appArchitect.build.options.scripts = [
{ input: 'src/string-script.js' },
{ input: 'src/zstring-script.js' },

View File

@ -14,10 +14,10 @@ export default function () {
'src/input-style.css': '.input-style { color: red }',
'src/lazy-style.css': '.lazy-style { color: red }',
'src/pre-rename-style.css': '.pre-rename-style { color: red }',
'src/pre-rename-lazy-style.css': '.pre-rename-lazy-style { color: red }'
'src/pre-rename-lazy-style.css': '.pre-rename-lazy-style { color: red }',
})
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.styles = [
{ input: 'src/string-style.css' },
{ input: 'src/input-style.css' },

View File

@ -26,7 +26,7 @@ export default function () {
return Promise.resolve()
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect['server'] = {
builder: '@angular-devkit/build-angular:server',
options: {

View File

@ -28,14 +28,14 @@ export default function () {
expectation: 'warning',
message: 'Budget warning: all, min warning',
budget: { type: 'all', minimumWarning: '100mb' },
}
},
];
const promiseFactories = budgetConfigs.map(cfg => {
if (cfg.expectation === 'error') {
return () => {
return updateJsonFile('angular.json', (json) => {
json.projects['test-project'].targets.build.options.budgets = [cfg.budget];
json.projects['test-project'].architect.build.options.budgets = [cfg.budget];
})
.then(() => expectToFail(() => ng('build', '--optimization')))
.then(errorMessage => {
@ -47,7 +47,7 @@ export default function () {
} else if (cfg.expectation === 'warning') {
return () => {
return updateJsonFile('angular.json', (json) => {
json.projects['test-project'].targets.build.options.budgets = [cfg.budget];
json.projects['test-project'].architect.build.options.budgets = [cfg.budget];
})
.then(() => ng('build', '--optimization'))
.then(({ stdout }) => {
@ -59,7 +59,7 @@ export default function () {
} else { // pass
return () => {
return updateJsonFile('angular.json', (json) => {
json.projects['test-project'].targets.build.options.budgets = [cfg.budget];
json.projects['test-project'].architect.build.options.budgets = [cfg.budget];
})
.then(() => ng('build', '--optimization'))
.then(({ stdout }) => {

View File

@ -8,9 +8,9 @@ export default async function() {
// Add a lazy module
await ng('generate', 'module', 'lazy');
await updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.lazyModules = [
'src/app/lazy/lazy.module'
'src/app/lazy/lazy.module',
];
});

View File

@ -7,12 +7,12 @@ export default function() {
// Try a prod build.
return Promise.resolve()
.then(() => updateJsonFile('angular.json', configJson => {
const appArchitect = configJson.projects['test-project'].targets;
const appArchitect = configJson.projects['test-project'].architect;
appArchitect.build.configurations['prod-env'] = {
fileReplacements: [
{
src: 'src/environments/environment.ts',
replaceWith: 'src/environments/environment.prod.ts'
replaceWith: 'src/environments/environment.prod.ts',
}
],
};

View File

@ -19,7 +19,7 @@ export default function() {
.then(() => expectFileToExist('./build-output/main.js'))
.then(() => expectToFail(expectGitToBeClean))
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.outputPath = 'config-build-output';
}))
.then(() => ng('build'))

View File

@ -36,14 +36,14 @@ export default function () {
dependencies['@angular/platform-server'] = platformServerVersion;
}))
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect['server'] = {
builder: '@angular-devkit/build-angular:server',
options: {
outputPath: 'dist/test-project-server',
main: 'src/main.server.ts',
tsConfig: 'src/tsconfig.server.json'
}
tsConfig: 'src/tsconfig.server.json',
},
};
}))
.then(() => writeFile('./src/tsconfig.server.json', `

View File

@ -32,7 +32,7 @@ export default function() {
// stuck to the first build done
return silentNpm('remove', '@angular/service-worker')
.then(() => silentNpm('install', '@angular/service-worker'))
.then(() => ng('config', 'projects.test-project.targets.build.options.serviceWorker', 'true'))
.then(() => ng('config', 'projects.test-project.architect.build.options.serviceWorker', 'true'))
.then(() => writeFile('src/ngsw-config.json', JSON.stringify(MANIFEST, null, 2)))
.then(() => ng('build', '--optimization'))
.then(() => expectFileToExist(join(process.cwd(), 'dist')))

View File

@ -21,7 +21,7 @@ export default async function () {
});
await deleteFile('src/app/app.component.css');
await updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.styles = [
{ input: 'src/styles.scss' },
];

View File

@ -17,10 +17,10 @@ export default function () {
'src/input-style.css': '.input-style { color: red }',
'src/lazy-style.css': '.lazy-style { color: red }',
'src/pre-rename-style.css': '.pre-rename-style { color: red }',
'src/pre-rename-lazy-style.css': '.pre-rename-lazy-style { color: red }'
'src/pre-rename-lazy-style.css': '.pre-rename-lazy-style { color: red }',
}))
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.styles = [
{ input: 'src/string-style.css' },
{ input: 'src/input-style.css' },

View File

@ -41,9 +41,9 @@ export default function () {
`})
// change files to use preprocessor
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.styles = [
{ input: `src/styles.${ext}` }
{ input: `src/styles.${ext}` },
];
}))
.then(() => replaceInFile('src/app/app.component.ts',
@ -66,9 +66,9 @@ export default function () {
// Also check imports work on ng test
.then(() => !ejected && ng('test', '--watch=false'))
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.styles = [
{ input: `src/styles.css` }
{ input: `src/styles.css` },
];
}))
.then(() => replaceInFile('src/app/app.component.ts',

View File

@ -47,7 +47,7 @@ export default function () {
.then(() => replaceInFile('src/app/app.component.ts', `'./app.component.css\'`,
`'./app.component.scss', './app.component.styl', './app.component.less'`))
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.styles = [
{ input: 'src/styles.scss' },
{ input: 'src/styles.styl' },

View File

@ -29,9 +29,9 @@ export default function () {
`})
.then(() => deleteFile('src/app/app.component.css'))
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.styles = [
{ input: 'src/styles.less' }
{ input: 'src/styles.less' },
];
}))
.then(() => replaceInFile('src/app/app.component.ts',

View File

@ -27,9 +27,9 @@ export default function () {
`})
.then(() => deleteFile('src/app/app.component.css'))
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.styles = [
{ input: 'src/styles.scss' }
{ input: 'src/styles.scss' },
];
}))
.then(() => replaceInFile('src/app/app.component.ts',

View File

@ -25,9 +25,9 @@ export default function () {
})
// change files to use preprocessor
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.styles = [
{ input: `src/styles.${ext}` }
{ input: `src/styles.${ext}` },
];
}))
.then(() => replaceInFile('src/app/app.component.ts',

View File

@ -29,9 +29,9 @@ export default function () {
`})
.then(() => deleteFile('src/app/app.component.css'))
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.styles = [
{ input: 'src/styles.scss' }
{ input: 'src/styles.scss' },
];
}))
.then(() => replaceInFile('src/app/app.component.ts',

View File

@ -29,9 +29,9 @@ export default function () {
`})
.then(() => deleteFile('src/app/app.component.css'))
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.styles = [
{ input: 'src/styles.styl' }
{ input: 'src/styles.styl' },
];
}))
.then(() => replaceInFile('src/app/app.component.ts',

View File

@ -8,13 +8,10 @@ export default function() {
return Promise.resolve()
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.outputPath = './';
}))
.then(() => expectToFail(() => ng('build')))
.then(() => expectToFail(() => ng('serve')))
.then(() => expectToFail(() => ng('eject')));
}

View File

@ -3,6 +3,6 @@ import { ng } from '../../../utils/process';
export default function() {
return Promise.resolve()
.then(() => ng('config', 'projects.test-project.targets.serve.options.port', '1234'))
.then(() => ng('config', 'projects.test-project.architect.serve.options.port', '1234'))
.then(() => expectFileToMatch('angular.json', /"port": 1234/));
}

View File

@ -10,7 +10,7 @@ export default function () {
return Promise.resolve()
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.lint.options.tsConfig = undefined;
}))
.then(() => ng('lint', 'app', '--type-check'))

View File

@ -16,10 +16,10 @@ export default function () {
.then(() => expectFileToMatch('coverage/lcov.info', 'polyfills.ts'))
.then(() => expectFileToMatch('coverage/lcov.info', 'test.ts'))
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.test.options.codeCoverageExclude = [
'src/polyfills.ts',
'**/test.ts'
'**/test.ts',
];
}))
.then(() => ng('test', '--watch=false', '--code-coverage'))

View File

@ -21,7 +21,7 @@ export default function () {
// should correctly fallback to a changed index
.then(() => moveFile('src/index.html', 'src/not-index.html'))
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.index = 'src/not-index.html';
}))
.then(() => ngServe())

View File

@ -11,7 +11,7 @@ export default function () {
return Promise.resolve()
.then(() => expectToFail(() => ng('e2e', 'test-project-e2e', '--devServerTarget=')))
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.serve.options.port = 4400;
}))
.then(() => ngServe())

View File

@ -38,14 +38,14 @@ export default function () {
}))
// Test failure condition (no assets in angular.json)
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'];
appArchitect.build.options.assets = [];
}))
.then(() => expectToFail(() => ng('test', '--watch=false'),
'Should fail because the assets to serve were not in the Angular CLI config'))
// Test passing condition (assets are included)
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.assets = [
{ 'glob': '**/*', 'input': 'src/assets' },
{ 'glob': 'file.txt' },

View File

@ -15,13 +15,13 @@ export default function () {
`)
.then(() => ng('test', '--watch=false'))
.then(() => updateJsonFile('angular.json', configJson => {
const appArchitect = configJson.projects['test-project'].targets;
const appArchitect = configJson.projects['test-project'].architect;
appArchitect.test.configurations = {
production: {
fileReplacements: [
{
src: 'src/environments/environment.ts',
replaceWith: 'src/environments/environment.prod.ts'
replaceWith: 'src/environments/environment.prod.ts',
}
],
}

View File

@ -63,10 +63,10 @@ export default function () {
// should fail because the global scripts were not added to scripts array
.then(() => expectToFail(() => ng('test', '--watch=false')))
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.test.options.scripts = [
{ input: 'src/string-script.js' },
{ input: 'src/input-script.js' }
{ input: 'src/input-script.js' },
];
}))
// should pass now

View File

@ -10,12 +10,12 @@ export default function() {
return Promise.resolve()
.then(() => silentNpm('install', 'bootstrap@4.0.0-beta.3'))
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.styles = [
{ input: 'node_modules/bootstrap/dist/css/bootstrap.css' }
{ input: 'node_modules/bootstrap/dist/css/bootstrap.css' },
];
appArchitect.build.options.scripts = [
{ input: 'node_modules/bootstrap/dist/js/bootstrap.js' }
{ input: 'node_modules/bootstrap/dist/js/bootstrap.js' },
];
}))
.then(() => ng('build', '--extract-css'))

View File

@ -9,9 +9,9 @@ export default function() {
return Promise.resolve()
.then(() => silentNpm('install', 'material-design-icons@3.0.1'))
.then(() => updateJsonFile('angular.json', workspaceJson => {
const appArchitect = workspaceJson.projects['test-project'].targets;
const appArchitect = workspaceJson.projects['test-project'].architect;
appArchitect.build.options.styles = [
{ input: 'node_modules/material-design-icons/iconfont/material-icons.css' }
{ input: 'node_modules/material-design-icons/iconfont/material-icons.css' },
];
}))
.then(() => ng('build', '--extract-css'))

View File

@ -182,11 +182,13 @@ export function useNgVersion(version: string) {
export function useCIDefaults(projectName = 'test-project') {
return updateJsonFile('angular.json', workspaceJson => {
// Disable progress reporting on CI to reduce spam.
const appTargets = workspaceJson.projects[projectName].targets;
const project = workspaceJson.projects[projectName];
const appTargets = project.targets || project.architect;
appTargets.build.options.progress = false;
appTargets.test.options.progress = false;
// Disable auto-updating webdriver in e2e.
const e2eTargets = workspaceJson.projects[projectName + '-e2e'].targets;
const e2eProject = workspaceJson.projects[projectName + '-e2e'];
const e2eTargets = e2eProject.targets || e2eProject.architect;
e2eTargets.e2e.options.webdriverUpdate = false;
})
.then(() => updateJsonFile('package.json', json => {