refactor(bazel): Remove bazel-workspace schematics (#29148)
`bazel-workspace` schematics is no longer needed now that the Bazel files are injected into the project by the Bazel builder. PR Close #29148
This commit is contained in:

committed by
Kara Erickson

parent
36a1550e00
commit
f4f20daee3
@ -12,7 +12,6 @@ ts_library(
|
||||
"schema.json",
|
||||
],
|
||||
deps = [
|
||||
"//packages/bazel/src/schematics/bazel-workspace",
|
||||
"//packages/bazel/src/schematics/utility",
|
||||
"@npm//@angular-devkit/core",
|
||||
"@npm//@angular-devkit/schematics",
|
||||
|
@ -0,0 +1,21 @@
|
||||
// Workaround for https://github.com/angular/angular/issues/18810
|
||||
// This file is required because when using the Angular NPM packages and building
|
||||
// with AOT compilation, NGC needs the "ngsummary.json" files.
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": [
|
||||
"dom",
|
||||
"es2015"
|
||||
],
|
||||
"experimentalDecorators": true,
|
||||
"types": []
|
||||
},
|
||||
"include": [
|
||||
"node_modules/@angular/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules/@angular/bazel/**",
|
||||
"node_modules/@angular/compiler-cli/**",
|
||||
"node_modules/@angular/**/testing/**"
|
||||
]
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
// The function exported from this file is used by the protractor_web_test_suite.
|
||||
// It is passed to the `onPrepare` configuration setting in protractor and executed
|
||||
// before running tests.
|
||||
//
|
||||
// If the function returns a promise, as it does here, protractor will wait
|
||||
// for the promise to resolve before running tests.
|
||||
|
||||
const protractorUtils = require('@angular/bazel/protractor-utils');
|
||||
const protractor = require('protractor');
|
||||
|
||||
module.exports = function(config) {
|
||||
// In this example, `@angular/bazel/protractor-utils` is used to run
|
||||
// the server. protractorUtils.runServer() runs the server on a randomly
|
||||
// selected port (given a port flag to pass to the server as an argument).
|
||||
// The port used is returned in serverSpec and the protractor serverUrl
|
||||
// is the configured.
|
||||
const portFlag = config.server.endsWith('prodserver') ? '-p' : '-port';
|
||||
return protractorUtils.runServer(config.workspace, config.server, portFlag, [])
|
||||
.then(serverSpec => {
|
||||
const serverUrl = `http://localhost:${serverSpec.port}`;
|
||||
protractor.browser.baseUrl = serverUrl;
|
||||
});
|
||||
};
|
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* @fileoverview Provides a script to initialize TestBed before tests are run.
|
||||
* This file should be included in the "runtime_deps" of a "ts_web_test_suite"
|
||||
* rule.
|
||||
*/
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {BrowserDynamicTestingModule, platformBrowserDynamicTesting} from '@angular/platform-browser-dynamic/testing';
|
||||
|
||||
TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
|
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @fileoverview Provides named UMD shims for `rxjs/operators` and `rxjs/testing`.
|
||||
* This file should be included in the "scripts" of a "ts_devserver"
|
||||
* rule and the "deps" of a "ts_web_test_suite" rule.
|
||||
*/
|
||||
// rxjs/operators
|
||||
(function(factory) {
|
||||
if (typeof module === 'object' && typeof module.exports === 'object') {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
define('rxjs/operators', ['exports', 'rxjs'], factory);
|
||||
}
|
||||
})(function(exports, rxjs) {
|
||||
'use strict';
|
||||
Object.keys(rxjs.operators).forEach(function(key) { exports[key] = rxjs.operators[key]; });
|
||||
Object.defineProperty(exports, '__esModule', {value: true});
|
||||
});
|
||||
|
||||
// rxjs/testing
|
||||
(function(factory) {
|
||||
if (typeof module === 'object' && typeof module.exports === 'object') {
|
||||
var v = factory(require, exports);
|
||||
if (v !== undefined) module.exports = v;
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
define('rxjs/testing', ['exports', 'rxjs'], factory);
|
||||
}
|
||||
})(function(exports, rxjs) {
|
||||
'use strict';
|
||||
Object.keys(rxjs.testing).forEach(function(key) { exports[key] = rxjs.testing[key]; });
|
||||
Object.defineProperty(exports, '__esModule', {value: true});
|
||||
});
|
@ -61,20 +61,13 @@ function addDevDependenciesToPackageJson(options: Schema) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Append main.dev.ts and main.prod.ts to src directory. These files are needed
|
||||
* by Bazel for devserver and prodserver, respectively. They are different from
|
||||
* main.ts generated by CLI because they use platformBrowser (AOT) instead of
|
||||
* platformBrowserDynamic (JIT).
|
||||
* Append additional Javascript / Typescript files needed to compile an Angular
|
||||
* project under Bazel.
|
||||
*/
|
||||
function addDevAndProdMainForAot(options: Schema) {
|
||||
function addFilesRequiredByBazel(options: Schema) {
|
||||
return (host: Tree) => {
|
||||
return mergeWith(apply(url('./files'), [
|
||||
applyTemplates({
|
||||
utils: strings,
|
||||
...options,
|
||||
'dot': '.',
|
||||
}),
|
||||
move('/src'),
|
||||
applyTemplates({}),
|
||||
]));
|
||||
};
|
||||
}
|
||||
@ -331,8 +324,7 @@ export default function(options: Schema): Rule {
|
||||
validateProjectName(options.name);
|
||||
|
||||
return chain([
|
||||
schematic('bazel-workspace', options),
|
||||
addDevAndProdMainForAot(options),
|
||||
addFilesRequiredByBazel(options),
|
||||
addDevDependenciesToPackageJson(options),
|
||||
addPostinstallToGenerateNgSummaries(),
|
||||
backupAngularJson(),
|
||||
|
@ -17,54 +17,45 @@ describe('ng-add schematic', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
host = new UnitTestTree(new HostTree());
|
||||
host.create(
|
||||
'package.json', JSON.stringify(
|
||||
{
|
||||
name: 'demo',
|
||||
dependencies: {
|
||||
'@angular/core': '1.2.3',
|
||||
'rxjs': '~6.3.3',
|
||||
},
|
||||
devDependencies: {
|
||||
'typescript': '3.2.2',
|
||||
},
|
||||
},
|
||||
null, 2));
|
||||
host.create(
|
||||
'tsconfig.json', JSON.stringify(
|
||||
{
|
||||
compileOnSave: false,
|
||||
compilerOptions: {
|
||||
baseUrl: './',
|
||||
outDir: './dist/out-tsc',
|
||||
}
|
||||
},
|
||||
null, 2));
|
||||
host.create(
|
||||
'angular.json', JSON.stringify(
|
||||
{
|
||||
projects: {
|
||||
'demo': {
|
||||
architect: {
|
||||
build: {},
|
||||
serve: {},
|
||||
test: {},
|
||||
'extract-i18n': {
|
||||
builder: '@angular-devkit/build-angular:extract-i18n',
|
||||
},
|
||||
},
|
||||
},
|
||||
'demo-e2e': {
|
||||
architect: {
|
||||
e2e: {},
|
||||
lint: {
|
||||
builder: '@angular-devkit/build-angular:tslint',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
null, 2));
|
||||
host.create('package.json', JSON.stringify({
|
||||
name: 'demo',
|
||||
dependencies: {
|
||||
'@angular/core': '1.2.3',
|
||||
'rxjs': '~6.3.3',
|
||||
},
|
||||
devDependencies: {
|
||||
'typescript': '3.2.2',
|
||||
},
|
||||
}));
|
||||
host.create('tsconfig.json', JSON.stringify({
|
||||
compileOnSave: false,
|
||||
compilerOptions: {
|
||||
baseUrl: './',
|
||||
outDir: './dist/out-tsc',
|
||||
}
|
||||
}));
|
||||
host.create('angular.json', JSON.stringify({
|
||||
projects: {
|
||||
'demo': {
|
||||
architect: {
|
||||
build: {},
|
||||
serve: {},
|
||||
test: {},
|
||||
'extract-i18n': {
|
||||
builder: '@angular-devkit/build-angular:extract-i18n',
|
||||
},
|
||||
},
|
||||
},
|
||||
'demo-e2e': {
|
||||
architect: {
|
||||
e2e: {},
|
||||
lint: {
|
||||
builder: '@angular-devkit/build-angular:tslint',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}));
|
||||
schematicRunner =
|
||||
new SchematicTestRunner('@angular/bazel', require.resolve('../collection.json'));
|
||||
});
|
||||
@ -109,11 +100,11 @@ describe('ng-add schematic', () => {
|
||||
expect(devDeps).toContain('@bazel/karma');
|
||||
});
|
||||
|
||||
it('should create Bazel workspace file', () => {
|
||||
it('should not create Bazel workspace file', () => {
|
||||
host = schematicRunner.runSchematic('ng-add', defaultOptions, host);
|
||||
const {files} = host;
|
||||
expect(files).toContain('/WORKSPACE');
|
||||
expect(files).toContain('/BUILD.bazel');
|
||||
expect(files).not.toContain('/WORKSPACE');
|
||||
expect(files).not.toContain('/BUILD.bazel');
|
||||
});
|
||||
|
||||
it('should produce main.dev.ts and main.prod.ts for AOT', () => {
|
||||
@ -225,19 +216,16 @@ describe('ng-add schematic', () => {
|
||||
];
|
||||
for (const [version, upgrade] of cases) {
|
||||
it(`should ${upgrade ? '' : 'not '}upgrade v${version}')`, () => {
|
||||
host.overwrite(
|
||||
'package.json', JSON.stringify(
|
||||
{
|
||||
name: 'demo',
|
||||
dependencies: {
|
||||
'@angular/core': '1.2.3',
|
||||
'rxjs': version,
|
||||
},
|
||||
devDependencies: {
|
||||
'typescript': '3.2.2',
|
||||
},
|
||||
},
|
||||
null, 2));
|
||||
host.overwrite('package.json', JSON.stringify({
|
||||
name: 'demo',
|
||||
dependencies: {
|
||||
'@angular/core': '1.2.3',
|
||||
'rxjs': version,
|
||||
},
|
||||
devDependencies: {
|
||||
'typescript': '3.2.2',
|
||||
},
|
||||
}));
|
||||
host = schematicRunner.runSchematic('ng-add', defaultOptions, host);
|
||||
expect(host.files).toContain('/package.json');
|
||||
const content = host.readContent('/package.json');
|
||||
|
Reference in New Issue
Block a user