diff --git a/packages/angular/pwa/pwa/index_spec.ts b/packages/angular/pwa/pwa/index_spec.ts index b607a797c8..f716847f47 100644 --- a/packages/angular/pwa/pwa/index_spec.ts +++ b/packages/angular/pwa/pwa/index_spec.ts @@ -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'); diff --git a/packages/schematics/angular/app-shell/index_spec.ts b/packages/schematics/angular/app-shell/index_spec.ts index 6cc865556f..deef63477f 100644 --- a/packages/schematics/angular/app-shell/index_spec.ts +++ b/packages/schematics/angular/app-shell/index_spec.ts @@ -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'); diff --git a/packages/schematics/angular/application/index_spec.ts b/packages/schematics/angular/application/index_spec.ts index aca5907287..5fd2be343e 100644 --- a/packages/schematics/angular/application/index_spec.ts +++ b/packages/schematics/angular/application/index_spec.ts @@ -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'); diff --git a/packages/schematics/angular/e2e/index_spec.ts b/packages/schematics/angular/e2e/index_spec.ts index 39bed6479f..204f3f941b 100644 --- a/packages/schematics/angular/e2e/index_spec.ts +++ b/packages/schematics/angular/e2e/index_spec.ts @@ -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'); }); }); diff --git a/packages/schematics/angular/migrations/update-6/index.ts b/packages/schematics/angular/migrations/update-6/index.ts index d8c239b2c2..e5338f1921 100644 --- a/packages/schematics/angular/migrations/update-6/index.ts +++ b/packages/schematics/angular/migrations/update-6/index.ts @@ -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 }; diff --git a/packages/schematics/angular/migrations/update-6/index_spec.ts b/packages/schematics/angular/migrations/update-6/index_spec.ts index c9298b08f5..d4ff5748eb 100644 --- a/packages/schematics/angular/migrations/update-6/index_spec.ts +++ b/packages/schematics/angular/migrations/update-6/index_spec.ts @@ -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'); diff --git a/packages/schematics/angular/service-worker/index_spec.ts b/packages/schematics/angular/service-worker/index_spec.ts index c64888f924..47c36824a4 100644 --- a/packages/schematics/angular/service-worker/index_spec.ts +++ b/packages/schematics/angular/service-worker/index_spec.ts @@ -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); }); diff --git a/packages/schematics/angular/universal/index_spec.ts b/packages/schematics/angular/universal/index_spec.ts index 0ca8c034ac..9f228e3529 100644 --- a/packages/schematics/angular/universal/index_spec.ts +++ b/packages/schematics/angular/universal/index_spec.ts @@ -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; diff --git a/tests/legacy-cli/e2e/tests/basic/assets.ts b/tests/legacy-cli/e2e/tests/basic/assets.ts index d8b8dafce3..f35ebc6979 100644 --- a/tests/legacy-cli/e2e/tests/basic/assets.ts +++ b/tests/legacy-cli/e2e/tests/basic/assets.ts @@ -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; })) diff --git a/tests/legacy-cli/e2e/tests/basic/scripts-array.ts b/tests/legacy-cli/e2e/tests/basic/scripts-array.ts index 64cd6c24f8..2bea2dabfc 100644 --- a/tests/legacy-cli/e2e/tests/basic/scripts-array.ts +++ b/tests/legacy-cli/e2e/tests/basic/scripts-array.ts @@ -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' }, diff --git a/tests/legacy-cli/e2e/tests/basic/styles-array.ts b/tests/legacy-cli/e2e/tests/basic/styles-array.ts index 380e9d40e1..4815c503d1 100644 --- a/tests/legacy-cli/e2e/tests/basic/styles-array.ts +++ b/tests/legacy-cli/e2e/tests/basic/styles-array.ts @@ -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' }, diff --git a/tests/legacy-cli/e2e/tests/build/build-app-shell.ts b/tests/legacy-cli/e2e/tests/build/build-app-shell.ts index b836abc35f..fc26d43aab 100644 --- a/tests/legacy-cli/e2e/tests/build/build-app-shell.ts +++ b/tests/legacy-cli/e2e/tests/build/build-app-shell.ts @@ -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: { diff --git a/tests/legacy-cli/e2e/tests/build/bundle-budgets.ts b/tests/legacy-cli/e2e/tests/build/bundle-budgets.ts index c5e40be628..974a4b189d 100644 --- a/tests/legacy-cli/e2e/tests/build/bundle-budgets.ts +++ b/tests/legacy-cli/e2e/tests/build/bundle-budgets.ts @@ -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 }) => { diff --git a/tests/legacy-cli/e2e/tests/build/dynamic-import.ts b/tests/legacy-cli/e2e/tests/build/dynamic-import.ts index 436a4457b4..296cab2ef2 100644 --- a/tests/legacy-cli/e2e/tests/build/dynamic-import.ts +++ b/tests/legacy-cli/e2e/tests/build/dynamic-import.ts @@ -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', ]; }); diff --git a/tests/legacy-cli/e2e/tests/build/environment.ts b/tests/legacy-cli/e2e/tests/build/environment.ts index 450d2919af..f00b73680b 100644 --- a/tests/legacy-cli/e2e/tests/build/environment.ts +++ b/tests/legacy-cli/e2e/tests/build/environment.ts @@ -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', } ], }; diff --git a/tests/legacy-cli/e2e/tests/build/output-dir.ts b/tests/legacy-cli/e2e/tests/build/output-dir.ts index ad502c1be4..5b245bb3d9 100644 --- a/tests/legacy-cli/e2e/tests/build/output-dir.ts +++ b/tests/legacy-cli/e2e/tests/build/output-dir.ts @@ -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')) diff --git a/tests/legacy-cli/e2e/tests/build/platform-server.ts b/tests/legacy-cli/e2e/tests/build/platform-server.ts index ef40c90da6..efca00d14c 100644 --- a/tests/legacy-cli/e2e/tests/build/platform-server.ts +++ b/tests/legacy-cli/e2e/tests/build/platform-server.ts @@ -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', ` diff --git a/tests/legacy-cli/e2e/tests/build/service-worker.ts b/tests/legacy-cli/e2e/tests/build/service-worker.ts index fe696a94ac..ff2d165256 100644 --- a/tests/legacy-cli/e2e/tests/build/service-worker.ts +++ b/tests/legacy-cli/e2e/tests/build/service-worker.ts @@ -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'))) diff --git a/tests/legacy-cli/e2e/tests/build/styles/dart-sass.ts b/tests/legacy-cli/e2e/tests/build/styles/dart-sass.ts index be6811976c..9bef49828c 100644 --- a/tests/legacy-cli/e2e/tests/build/styles/dart-sass.ts +++ b/tests/legacy-cli/e2e/tests/build/styles/dart-sass.ts @@ -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' }, ]; diff --git a/tests/legacy-cli/e2e/tests/build/styles/extract-css.ts b/tests/legacy-cli/e2e/tests/build/styles/extract-css.ts index db761f5d8a..35c993cf33 100644 --- a/tests/legacy-cli/e2e/tests/build/styles/extract-css.ts +++ b/tests/legacy-cli/e2e/tests/build/styles/extract-css.ts @@ -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' }, diff --git a/tests/legacy-cli/e2e/tests/build/styles/imports.ts b/tests/legacy-cli/e2e/tests/build/styles/imports.ts index c9716592f1..c7a5f7cc1e 100644 --- a/tests/legacy-cli/e2e/tests/build/styles/imports.ts +++ b/tests/legacy-cli/e2e/tests/build/styles/imports.ts @@ -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', diff --git a/tests/legacy-cli/e2e/tests/build/styles/include-paths.ts b/tests/legacy-cli/e2e/tests/build/styles/include-paths.ts index 5930eac4c7..c685abe6f9 100644 --- a/tests/legacy-cli/e2e/tests/build/styles/include-paths.ts +++ b/tests/legacy-cli/e2e/tests/build/styles/include-paths.ts @@ -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' }, diff --git a/tests/legacy-cli/e2e/tests/build/styles/less.ts b/tests/legacy-cli/e2e/tests/build/styles/less.ts index 8963d1f023..a8616a7848 100644 --- a/tests/legacy-cli/e2e/tests/build/styles/less.ts +++ b/tests/legacy-cli/e2e/tests/build/styles/less.ts @@ -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', diff --git a/tests/legacy-cli/e2e/tests/build/styles/loaders.ts b/tests/legacy-cli/e2e/tests/build/styles/loaders.ts index 9c9ae0c1ee..8f52edc87b 100644 --- a/tests/legacy-cli/e2e/tests/build/styles/loaders.ts +++ b/tests/legacy-cli/e2e/tests/build/styles/loaders.ts @@ -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', diff --git a/tests/legacy-cli/e2e/tests/build/styles/material-import.ts b/tests/legacy-cli/e2e/tests/build/styles/material-import.ts index cafd96174e..03699182c9 100644 --- a/tests/legacy-cli/e2e/tests/build/styles/material-import.ts +++ b/tests/legacy-cli/e2e/tests/build/styles/material-import.ts @@ -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', diff --git a/tests/legacy-cli/e2e/tests/build/styles/scss.ts b/tests/legacy-cli/e2e/tests/build/styles/scss.ts index 1a0da9839f..6017338114 100644 --- a/tests/legacy-cli/e2e/tests/build/styles/scss.ts +++ b/tests/legacy-cli/e2e/tests/build/styles/scss.ts @@ -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', diff --git a/tests/legacy-cli/e2e/tests/build/styles/stylus.ts b/tests/legacy-cli/e2e/tests/build/styles/stylus.ts index 0f47cf82f0..83d3307471 100644 --- a/tests/legacy-cli/e2e/tests/build/styles/stylus.ts +++ b/tests/legacy-cli/e2e/tests/build/styles/stylus.ts @@ -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', diff --git a/tests/legacy-cli/e2e/tests/commands/build/build-outdir.ts b/tests/legacy-cli/e2e/tests/commands/build/build-outdir.ts index f62d8aa81f..38de272bde 100644 --- a/tests/legacy-cli/e2e/tests/commands/build/build-outdir.ts +++ b/tests/legacy-cli/e2e/tests/commands/build/build-outdir.ts @@ -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'))); } - - - diff --git a/tests/legacy-cli/e2e/tests/commands/config/config-set-serve-port.ts b/tests/legacy-cli/e2e/tests/commands/config/config-set-serve-port.ts index 451e4ff561..7557c6f534 100644 --- a/tests/legacy-cli/e2e/tests/commands/config/config-set-serve-port.ts +++ b/tests/legacy-cli/e2e/tests/commands/config/config-set-serve-port.ts @@ -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/)); } diff --git a/tests/legacy-cli/e2e/tests/lint/lint-no-project.ts b/tests/legacy-cli/e2e/tests/lint/lint-no-project.ts index 449989811f..6253087a99 100644 --- a/tests/legacy-cli/e2e/tests/lint/lint-no-project.ts +++ b/tests/legacy-cli/e2e/tests/lint/lint-no-project.ts @@ -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')) diff --git a/tests/legacy-cli/e2e/tests/misc/coverage.ts b/tests/legacy-cli/e2e/tests/misc/coverage.ts index 0675894578..3170532da7 100644 --- a/tests/legacy-cli/e2e/tests/misc/coverage.ts +++ b/tests/legacy-cli/e2e/tests/misc/coverage.ts @@ -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')) diff --git a/tests/legacy-cli/e2e/tests/misc/fallback.ts b/tests/legacy-cli/e2e/tests/misc/fallback.ts index 12b7656cb7..1c8d1ca56e 100644 --- a/tests/legacy-cli/e2e/tests/misc/fallback.ts +++ b/tests/legacy-cli/e2e/tests/misc/fallback.ts @@ -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()) diff --git a/tests/legacy-cli/e2e/tests/test/e2e-baseurl.ts b/tests/legacy-cli/e2e/tests/test/e2e-baseurl.ts index 393f9a3d39..c7abf7c66d 100644 --- a/tests/legacy-cli/e2e/tests/test/e2e-baseurl.ts +++ b/tests/legacy-cli/e2e/tests/test/e2e-baseurl.ts @@ -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()) diff --git a/tests/legacy-cli/e2e/tests/test/test-assets.ts b/tests/legacy-cli/e2e/tests/test/test-assets.ts index eba7980a0f..d647d07f8d 100644 --- a/tests/legacy-cli/e2e/tests/test/test-assets.ts +++ b/tests/legacy-cli/e2e/tests/test/test-assets.ts @@ -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' }, diff --git a/tests/legacy-cli/e2e/tests/test/test-environment.ts b/tests/legacy-cli/e2e/tests/test/test-environment.ts index 32e22a0d73..09152caee4 100644 --- a/tests/legacy-cli/e2e/tests/test/test-environment.ts +++ b/tests/legacy-cli/e2e/tests/test/test-environment.ts @@ -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', } ], } diff --git a/tests/legacy-cli/e2e/tests/test/test-scripts.ts b/tests/legacy-cli/e2e/tests/test/test-scripts.ts index 24cbd4908e..bf5299647e 100644 --- a/tests/legacy-cli/e2e/tests/test/test-scripts.ts +++ b/tests/legacy-cli/e2e/tests/test/test-scripts.ts @@ -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 diff --git a/tests/legacy-cli/e2e/tests/third-party/bootstrap.ts b/tests/legacy-cli/e2e/tests/third-party/bootstrap.ts index 80c1f62b90..847bce3bba 100644 --- a/tests/legacy-cli/e2e/tests/third-party/bootstrap.ts +++ b/tests/legacy-cli/e2e/tests/third-party/bootstrap.ts @@ -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')) diff --git a/tests/legacy-cli/e2e/tests/third-party/material-icons.ts b/tests/legacy-cli/e2e/tests/third-party/material-icons.ts index 4747eda502..07d5ac97b9 100644 --- a/tests/legacy-cli/e2e/tests/third-party/material-icons.ts +++ b/tests/legacy-cli/e2e/tests/third-party/material-icons.ts @@ -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')) diff --git a/tests/legacy-cli/e2e/utils/project.ts b/tests/legacy-cli/e2e/utils/project.ts index ceaa5acc97..4eacb97d60 100644 --- a/tests/legacy-cli/e2e/utils/project.ts +++ b/tests/legacy-cli/e2e/utils/project.ts @@ -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 => {