refactor(upgrade): use Bazel packages to avoid symlinks in the source (#29466)

Previously we had to share code between upgrade/dynamic and upgrade/static
by symlinking the `src` folder, which allowed both packages to access
the upgrade/common files.

These symlinks are always problematic on Windows, where we had to run
a script to re-link them, and restore them.

This change uses Bazel packages to share the `upgrade/common` code,
which avoids the need for symlinking the `src` folder.

Also, the Windows specific scripts that fixup the symlinks have also
been removed as there is no more need for them.

PR Close #29466
This commit is contained in:
Pete Bacon Darwin 2019-03-22 09:42:52 +00:00 committed by Jason Aden
parent e5201f92fc
commit 9f54d76ef5
49 changed files with 219 additions and 162 deletions

View File

@ -17,8 +17,6 @@ steps:
commands:
# Install dependencies
- yarn install --frozen-lockfile --non-interactive --network-timeout 100000 --no-progress
# Create symlinks needed for Windows.
- scripts\windows\create-symlinks.cmd
# Add Bazel CI config
- copy .codefresh\bazel.rc %ProgramData%\bazel.bazelrc
# Run tests

View File

@ -41,16 +41,6 @@ Here are the most important tasks you might need to use:
- `yarn example-e2e --filter=foo` - limit e2e tests to those containing the word "foo"
- `yarn example-e2e --setup --local` - run e2e tests with the local version of Angular contained in the "dist" folder
## Developing on Windows
The `packages/` directory may contain Linux-specific symlinks, which are not recognized by Windows.
These unresolved links cause the docs generation process to fail because it cannot locate certain files.
> Hint: The following steps require administration rights or [Windows Developer Mode](https://docs.microsoft.com/en-us/windows/uwp/get-started/enable-your-device-for-development) enabled!
To fix this problem, run `scripts/windows/create-symlinks.sh`. This command creates temporary files where the symlinks used to be. Make sure not to commit those files with your documentation changes.
When you are done making and testing your documentation changes, you can restore the original symlinks and delete the temporary files by running `scripts/windows/remove-symlinks.sh`.
It's necessary to remove the temporary files, because otherwise they're displayed as local changes in your git working copy and certain operations are blocked.
## Using ServiceWorker locally

View File

@ -59,18 +59,6 @@ Next, install the JavaScript modules needed to build and test Angular:
yarn install
```
## Windows only
In order to create the right symlinks, run **as administrator**:
```shell
./scripts/windows/create-symlinks.sh
```
Before submitting a PR, do not forget to remove them:
```shell
./scripts/windows/remove-symlinks.sh
```
## Building
To build Angular run:

View File

@ -7,14 +7,13 @@ ng_module(
srcs = glob(
[
"*.ts",
"src/common/**/*.ts",
"src/dynamic/**/*.ts",
"src/dynamic/src/*.ts",
],
),
deps = [
"//packages/core",
"//packages/platform-browser",
"//packages/platform-browser-dynamic",
"//packages/upgrade/src/common",
"@npm//zone.js",
],
)

View File

@ -12,7 +12,7 @@
* Entry point for all public APIs of this package. allowing
* Angular 1 and Angular 2+ to run side by side in the same application.
*/
export {VERSION} from './src/common/version';
export {UpgradeAdapter, UpgradeAdapterRef} from './src/dynamic/upgrade_adapter';
export {VERSION} from './src/common/src/version';
export {UpgradeAdapter, UpgradeAdapterRef} from './src/dynamic/src/upgrade_adapter';
// This file only re-exports content of the `src` folder. Keep it that way.

View File

@ -0,0 +1,16 @@
load("//tools:defaults.bzl", "ts_library")
package(default_visibility = [
"//packages/upgrade:__subpackages__",
"//tools/public_api_guard:__subpackages__",
])
ts_library(
name = "common",
srcs = glob([
"src/**/*.ts",
]),
deps = [
"//packages/core",
],
)

View File

@ -0,0 +1,23 @@
load("//tools:defaults.bzl", "ts_library", "ts_web_test_suite")
ts_library(
name = "test_lib",
testonly = True,
srcs = glob(["**/*.ts"]),
deps = [
"//packages/core",
"//packages/core/testing",
"//packages/upgrade/src/common",
"//packages/upgrade/src/common/test/helpers",
],
)
ts_web_test_suite(
name = "test",
static_files = [
"//:angularjs_scripts",
],
deps = [
":test_lib",
],
)

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {PropertyBinding} from '@angular/upgrade/src/common/component_info';
import {PropertyBinding} from '../src/component_info';
{
describe('PropertyBinding', () => {

View File

@ -7,10 +7,10 @@
*/
import {Compiler, Component, ComponentFactory, Injector, NgModule, TestabilityRegistry} from '@angular/core';
import {TestBed} from '@angular/core/testing';
import * as angular from '@angular/upgrade/src/common/angular1';
import {DowngradeComponentAdapter, groupNodesBySelector} from '@angular/upgrade/src/common/downgrade_component_adapter';
import * as angular from '../src/angular1';
import {DowngradeComponentAdapter, groupNodesBySelector} from '../src/downgrade_component_adapter';
import {nodes, withEachNg1Version} from './test_helpers';
import {nodes, withEachNg1Version} from './helpers/common_test_helpers';
withEachNg1Version(() => {
describe('DowngradeComponentAdapter', () => {

View File

@ -7,10 +7,10 @@
*/
import {Injector} from '@angular/core';
import * as angular from '@angular/upgrade/src/common/angular1';
import {$INJECTOR, INJECTOR_KEY, UPGRADE_APP_TYPE_KEY} from '@angular/upgrade/src/common/constants';
import {downgradeInjectable} from '@angular/upgrade/src/common/downgrade_injectable';
import {UpgradeAppType} from '@angular/upgrade/src/common/util';
import * as angular from '../src/angular1';
import {$INJECTOR, INJECTOR_KEY, UPGRADE_APP_TYPE_KEY} from '../src/constants';
import {downgradeInjectable} from '../src/downgrade_injectable';
import {UpgradeAppType} from '../src/util';
describe('downgradeInjectable', () => {
const setupMockInjectors = (downgradedModule = '') => {

View File

@ -0,0 +1,14 @@
load("//tools:defaults.bzl", "ts_library")
package(default_visibility = ["//packages/upgrade:__subpackages__"])
ts_library(
name = "helpers",
srcs = glob([
"*.ts",
]),
deps = [
"//packages/core/testing",
"//packages/upgrade/src/common",
],
)

View File

@ -5,7 +5,7 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {setAngularJSGlobal} from '@angular/upgrade/src/common/angular1';
import {setAngularJSGlobal} from '../../src/angular1';
// Whether the upgrade tests should run against AngularJS minified or not. This can be
// temporarily switched to "false" in order to make it easy to debug AngularJS locally.

View File

@ -9,11 +9,11 @@
import {Compiler, CompilerOptions, Injector, NgModule, NgModuleRef, NgZone, StaticProvider, Testability, Type, resolveForwardRef} from '@angular/core';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {IAngularBootstrapConfig, IAugmentedJQuery, IInjectorService, IModule, IProvideService, IRootScopeService, ITestabilityService, bootstrap, element as angularElement, module as angularModule} from '../common/angular1';
import {$$TESTABILITY, $COMPILE, $INJECTOR, $ROOT_SCOPE, COMPILER_KEY, INJECTOR_KEY, LAZY_MODULE_REF, NG_ZONE_KEY, UPGRADE_APP_TYPE_KEY} from '../common/constants';
import {downgradeComponent} from '../common/downgrade_component';
import {downgradeInjectable} from '../common/downgrade_injectable';
import {Deferred, LazyModuleRef, UpgradeAppType, controllerKey, onError} from '../common/util';
import {IAngularBootstrapConfig, IAugmentedJQuery, IInjectorService, IModule, IProvideService, IRootScopeService, ITestabilityService, bootstrap, element as angularElement, module as angularModule} from '../../common/src/angular1';
import {$$TESTABILITY, $COMPILE, $INJECTOR, $ROOT_SCOPE, COMPILER_KEY, INJECTOR_KEY, LAZY_MODULE_REF, NG_ZONE_KEY, UPGRADE_APP_TYPE_KEY} from '../../common/src/constants';
import {downgradeComponent} from '../../common/src/downgrade_component';
import {downgradeInjectable} from '../../common/src/downgrade_injectable';
import {Deferred, LazyModuleRef, UpgradeAppType, controllerKey, onError} from '../../common/src/util';
import {UpgradeNg1ComponentAdapterBuilder} from './upgrade_ng1_adapter';

View File

@ -8,10 +8,10 @@
import {Directive, DoCheck, ElementRef, EventEmitter, Inject, Injector, OnChanges, OnDestroy, OnInit, SimpleChange, SimpleChanges, Type} from '@angular/core';
import {IAttributes, IDirective, IDirectivePrePost, IInjectorService, ILinkFn, IScope, ITranscludeFunction} from '../common/angular1';
import {$SCOPE} from '../common/constants';
import {IBindingDestination, IControllerInstance, UpgradeHelper} from '../common/upgrade_helper';
import {isFunction, strictEquals} from '../common/util';
import {IAttributes, IDirective, IDirectivePrePost, IInjectorService, ILinkFn, IScope, ITranscludeFunction} from '../../common/src/angular1';
import {$SCOPE} from '../../common/src/constants';
import {IBindingDestination, IControllerInstance, UpgradeHelper} from '../../common/src/upgrade_helper';
import {isFunction, strictEquals} from '../../common/src/util';
const CAMEL_CASE = /([A-Z])/g;

View File

@ -0,0 +1,28 @@
load("//tools:defaults.bzl", "ts_library", "ts_web_test_suite")
ts_library(
name = "test_lib",
testonly = True,
srcs = glob([
"**/*.ts",
]),
deps = [
"//packages/core",
"//packages/core/testing",
"//packages/platform-browser",
"//packages/platform-browser-dynamic",
"//packages/upgrade",
"//packages/upgrade/src/common",
"//packages/upgrade/src/common/test/helpers",
],
)
ts_web_test_suite(
name = "test",
static_files = [
"//:angularjs_scripts",
],
deps = [
":test_lib",
],
)

View File

@ -10,11 +10,13 @@ import {ChangeDetectorRef, Component, EventEmitter, Input, NO_ERRORS_SCHEMA, NgM
import {async, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import * as angular from '@angular/upgrade/src/common/angular1';
import {$EXCEPTION_HANDLER} from '@angular/upgrade/src/common/constants';
import {UpgradeAdapter, UpgradeAdapterRef} from '@angular/upgrade/src/dynamic/upgrade_adapter';
import {$apply, $digest, html, multiTrim, withEachNg1Version} from './test_helpers';
import * as angular from '../../common/src/angular1';
import {$EXCEPTION_HANDLER, $ROOT_SCOPE} from '../../common/src/constants';
import {html, multiTrim, withEachNg1Version} from '../../common/test/helpers/common_test_helpers';
import {UpgradeAdapter, UpgradeAdapterRef} from '../src/upgrade_adapter';
declare global {
export var inject: Function;
@ -3280,3 +3282,13 @@ withEachNg1Version(() => {
});
});
});
function $apply(adapter: UpgradeAdapterRef, exp: angular.Ng1Expression) {
const $rootScope = adapter.ng1Injector.get($ROOT_SCOPE) as angular.IRootScopeService;
$rootScope.$apply(exp);
}
function $digest(adapter: UpgradeAdapterRef) {
const $rootScope = adapter.ng1Injector.get($ROOT_SCOPE) as angular.IRootScopeService;
$rootScope.$digest();
}

View File

@ -6,18 +6,15 @@ exports_files(["package.json"])
ng_module(
name = "static",
# Note: There is Bazel issue where Windows symlinks
# aka. junctions are not traversed by glob.
srcs = glob(
[
"*.ts",
"src/common/**/*.ts",
"src/static/**/*.ts",
"src/*.ts",
],
),
deps = [
"//packages/core",
"//packages/platform-browser",
"//packages/platform-browser-dynamic",
"//packages/upgrade/src/common",
],
)

View File

@ -6,19 +6,13 @@
* found in the LICENSE file at https://angular.io/license
*/
/**
* @module
* @description
* Entry point for all public APIs of this package. allowing
* Angular 1 and Angular 2+ to run side by side in the same application.
*/
export {getAngularJSGlobal, getAngularLib, setAngularJSGlobal, setAngularLib} from './src/common/angular1';
export {downgradeComponent} from './src/common/downgrade_component';
export {downgradeInjectable} from './src/common/downgrade_injectable';
export {VERSION} from './src/common/version';
export {downgradeModule} from './src/static/downgrade_module';
export {UpgradeComponent} from './src/static/upgrade_component';
export {UpgradeModule} from './src/static/upgrade_module';
export {getAngularJSGlobal, getAngularLib, setAngularJSGlobal, setAngularLib} from '../src/common/src/angular1';
export {downgradeComponent} from '../src/common/src/downgrade_component';
export {downgradeInjectable} from '../src/common/src/downgrade_injectable';
export {VERSION} from '../src/common/src/version';
export {downgradeModule} from './src/downgrade_module';
export {UpgradeComponent} from './src/upgrade_component';
export {UpgradeModule} from './src/upgrade_module';
// This file only re-exports content of the `src` folder. Keep it that way.
// This file only re-exports items to appear in the public api. Keep it that way.

View File

@ -1 +0,0 @@
../src

View File

@ -7,7 +7,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {IInjectorService} from '../common/angular1';
import {IInjectorService} from '../../src/common/src/angular1';
// We have to do a little dance to get the ng1 injector into the module injector.
// We store the ng1 injector so that the provider in the module injector can access it

View File

@ -9,9 +9,9 @@
import {Injector, NgModuleFactory, NgModuleRef, StaticProvider} from '@angular/core';
import {platformBrowser} from '@angular/platform-browser';
import {IInjectorService, IProvideService, module as angularModule} from '../common/angular1';
import {$INJECTOR, $PROVIDE, DOWNGRADED_MODULE_COUNT_KEY, INJECTOR_KEY, LAZY_MODULE_REF, UPGRADE_APP_TYPE_KEY, UPGRADE_MODULE_NAME} from '../common/constants';
import {LazyModuleRef, UpgradeAppType, getDowngradedModuleCount, isFunction} from '../common/util';
import {IInjectorService, IProvideService, module as angularModule} from '../../src/common/src/angular1';
import {$INJECTOR, $PROVIDE, DOWNGRADED_MODULE_COUNT_KEY, INJECTOR_KEY, LAZY_MODULE_REF, UPGRADE_APP_TYPE_KEY, UPGRADE_MODULE_NAME} from '../../src/common/src/constants';
import {LazyModuleRef, UpgradeAppType, getDowngradedModuleCount, isFunction} from '../../src/common/src/util';
import {angular1Providers, setTempInjectorRef} from './angular1_providers';
import {NgAdapterInjector} from './util';

View File

@ -8,10 +8,10 @@
import {DoCheck, ElementRef, EventEmitter, Injector, OnChanges, OnDestroy, OnInit, SimpleChanges, ɵlooseIdentical as looseIdentical} from '@angular/core';
import {IAttributes, IAugmentedJQuery, IDirective, IDirectivePrePost, IInjectorService, ILinkFn, IScope, ITranscludeFunction} from '../common/angular1';
import {$SCOPE} from '../common/constants';
import {IBindingDestination, IControllerInstance, UpgradeHelper} from '../common/upgrade_helper';
import {isFunction} from '../common/util';
import {IAttributes, IAugmentedJQuery, IDirective, IDirectivePrePost, IInjectorService, ILinkFn, IScope, ITranscludeFunction} from '../../src/common/src/angular1';
import {$SCOPE} from '../../src/common/src/constants';
import {IBindingDestination, IControllerInstance, UpgradeHelper} from '../../src/common/src/upgrade_helper';
import {isFunction} from '../../src/common/src/util';
const NOT_SUPPORTED: any = 'NOT_SUPPORTED';
const INITIAL_VALUE = {

View File

@ -8,9 +8,9 @@
import {Injector, NgModule, NgZone, Testability} from '@angular/core';
import {IInjectorService, IIntervalService, IProvideService, ITestabilityService, bootstrap, element as angularElement, module as angularModule} from '../common/angular1';
import {$$TESTABILITY, $DELEGATE, $INJECTOR, $INTERVAL, $PROVIDE, INJECTOR_KEY, LAZY_MODULE_REF, UPGRADE_APP_TYPE_KEY, UPGRADE_MODULE_NAME} from '../common/constants';
import {LazyModuleRef, UpgradeAppType, controllerKey} from '../common/util';
import {IInjectorService, IIntervalService, IProvideService, ITestabilityService, bootstrap, element as angularElement, module as angularModule} from '../../src/common/src/angular1';
import {$$TESTABILITY, $DELEGATE, $INJECTOR, $INTERVAL, $PROVIDE, INJECTOR_KEY, LAZY_MODULE_REF, UPGRADE_APP_TYPE_KEY, UPGRADE_MODULE_NAME} from '../../src/common/src/constants';
import {LazyModuleRef, UpgradeAppType, controllerKey} from '../../src/common/src/util';
import {angular1Providers, setTempInjectorRef} from './angular1_providers';
import {NgAdapterInjector} from './util';

View File

@ -3,22 +3,23 @@ load("//tools:defaults.bzl", "ts_library", "ts_web_test_suite")
ts_library(
name = "test_lib",
testonly = True,
srcs = glob(["**/*.ts"]),
srcs = glob([
"**/*.ts",
]),
deps = [
"//packages:types",
"//packages/core",
"//packages/core/testing",
"//packages/platform-browser",
"//packages/platform-browser-dynamic",
"//packages/platform-browser/testing",
"//packages/upgrade",
"//packages/upgrade/src/common",
"//packages/upgrade/src/common/test/helpers",
"//packages/upgrade/static",
"@npm//rxjs",
],
)
ts_web_test_suite(
name = "test_web",
name = "test",
static_files = [
"//:angularjs_scripts",
],

View File

@ -6,8 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
import {IInjectorService, Ng1Token} from '@angular/upgrade/static/src/common/angular1';
import {compileFactory, injectorFactory, parseFactory, rootScopeFactory, setTempInjectorRef} from '@angular/upgrade/static/src/static/angular1_providers';
import {Ng1Token} from '../../src/common/src/angular1';
import {compileFactory, injectorFactory, parseFactory, rootScopeFactory, setTempInjectorRef} from '../src/angular1_providers';
{
describe('upgrade angular1_providers', () => {

View File

@ -6,14 +6,16 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Component, Directive, ElementRef, Injector, Input, NgModule, NgZone, SimpleChange, SimpleChanges, destroyPlatform} from '@angular/core';
import {Component, Directive, ElementRef, Injector, Input, NgModule, NgZone, SimpleChanges, destroyPlatform} from '@angular/core';
import {async} from '@angular/core/testing';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
import * as angular from '@angular/upgrade/static/src/common/angular1';
import {bootstrap, html, withEachNg1Version} from '../test_helpers';
import * as angular from '../../../src/common/src/angular1';
import {html, withEachNg1Version} from '../../../src/common/test/helpers/common_test_helpers';
import {bootstrap} from './static_test_helpers';
withEachNg1Version(() => {
describe('scope/component change-detection', () => {

View File

@ -11,9 +11,10 @@ import {async} from '@angular/core/testing';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
import * as angular from '@angular/upgrade/static/src/common/angular1';
import * as angular from '../../../src/common/src/angular1';
import {bootstrap, html, multiTrim, withEachNg1Version} from '../test_helpers';
import {html, multiTrim, withEachNg1Version} from '../../../src/common/test/helpers/common_test_helpers';
import {bootstrap} from './static_test_helpers';
withEachNg1Version(() => {
describe('content projection', () => {

View File

@ -11,9 +11,10 @@ import {async, fakeAsync, tick} from '@angular/core/testing';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
import * as angular from '@angular/upgrade/static/src/common/angular1';
import * as angular from '../../../src/common/src/angular1';
import {$apply, bootstrap, html, multiTrim, withEachNg1Version} from '../test_helpers';
import {html, multiTrim, withEachNg1Version} from '../../../src/common/test/helpers/common_test_helpers';
import {$apply, bootstrap} from './static_test_helpers';
withEachNg1Version(() => {
describe('downgrade ng2 component', () => {

View File

@ -12,12 +12,12 @@ import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {browserDetection} from '@angular/platform-browser/testing/src/browser_util';
import {UpgradeComponent, downgradeComponent, downgradeModule} from '@angular/upgrade/static';
import * as angular from '@angular/upgrade/static/src/common/angular1';
import {$EXCEPTION_HANDLER, $ROOT_SCOPE, INJECTOR_KEY, LAZY_MODULE_REF} from '@angular/upgrade/static/src/common/constants';
import {LazyModuleRef} from '@angular/upgrade/static/src/common/util';
import {setTempInjectorRef} from '@angular/upgrade/static/src/static/angular1_providers';
import {html, multiTrim, withEachNg1Version} from '../test_helpers';
import * as angular from '../../../src/common/src/angular1';
import {$EXCEPTION_HANDLER, $ROOT_SCOPE, INJECTOR_KEY, LAZY_MODULE_REF} from '../../../src/common/src/constants';
import {LazyModuleRef} from '../../../src/common/src/util';
import {html, multiTrim, withEachNg1Version} from '../../../src/common/test/helpers/common_test_helpers';
import {setTempInjectorRef} from '../../src/angular1_providers';
withEachNg1Version(() => {

View File

@ -11,9 +11,11 @@ import {async} from '@angular/core/testing';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
import * as angular from '@angular/upgrade/static/src/common/angular1';
import {bootstrap, html, multiTrim, withEachNg1Version} from '../test_helpers';
import * as angular from '../../../src/common/src/angular1';
import {html, multiTrim, withEachNg1Version} from '../../../src/common/test/helpers/common_test_helpers';
import {bootstrap} from './static_test_helpers';
withEachNg1Version(() => {
describe('examples', () => {

View File

@ -10,11 +10,13 @@ import {InjectionToken, Injector, NgModule, destroyPlatform} from '@angular/core
import {async} from '@angular/core/testing';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {UpgradeModule, downgradeInjectable, getAngularJSGlobal, setAngularJSGlobal} from '@angular/upgrade/static';
import * as angular from '@angular/upgrade/static/src/common/angular1';
import {$INJECTOR, INJECTOR_KEY} from '@angular/upgrade/static/src/common/constants';
import {bootstrap, html, withEachNg1Version} from '../test_helpers';
import * as angular from '../../../src/common/src/angular1';
import {$INJECTOR, INJECTOR_KEY} from '../../../src/common/src/constants';
import {html, withEachNg1Version} from '../../../src/common/test/helpers/common_test_helpers';
import {UpgradeModule, downgradeInjectable, getAngularJSGlobal, setAngularJSGlobal} from '../../index';
import {bootstrap} from './static_test_helpers';
withEachNg1Version(() => {
describe('injection', () => {

View File

@ -8,11 +8,8 @@
import {NgZone, PlatformRef, Type} from '@angular/core';
import {UpgradeModule} from '@angular/upgrade/static';
import * as angular from '@angular/upgrade/static/src/common/angular1';
import {$EXCEPTION_HANDLER, $ROOT_SCOPE} from '@angular/upgrade/static/src/common/constants';
import {createWithEachNg1VersionFn} from '../common/test_helpers';
export * from '../common/test_helpers';
import * as angular from '../../../src/common/src/angular1';
import {$EXCEPTION_HANDLER, $ROOT_SCOPE} from '../../../src/common/src/constants';
export function bootstrap(
platform: PlatformRef, Ng2Module: Type<{}>, element: Element, ng1Module: angular.IModule) {
@ -36,8 +33,6 @@ export function bootstrap(
});
}
export const withEachNg1Version = createWithEachNg1VersionFn(angular.setAngularJSGlobal);
export function $apply(adapter: UpgradeModule, exp: angular.Ng1Expression) {
const $rootScope = adapter.$injector.get($ROOT_SCOPE) as angular.IRootScopeService;
$rootScope.$apply(exp);

View File

@ -12,9 +12,10 @@ import {fakeAsync, flush, tick} from '@angular/core/testing';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {UpgradeModule} from '@angular/upgrade/static';
import * as angular from '@angular/upgrade/static/src/common/angular1';
import * as angular from '../../../src/common/src/angular1';
import {bootstrap, html, withEachNg1Version} from '../test_helpers';
import {html, withEachNg1Version} from '../../../src/common/test/helpers/common_test_helpers';
import {bootstrap} from './static_test_helpers';
withEachNg1Version(() => {
describe('testability', () => {

View File

@ -6,15 +6,18 @@
* found in the LICENSE file at https://angular.io/license
*/
import {Component, Directive, ElementRef, ErrorHandler, EventEmitter, Inject, Injector, Input, NO_ERRORS_SCHEMA, NgModule, Output, SimpleChanges, destroyPlatform} from '@angular/core';
import {Component, Directive, ElementRef, EventEmitter, Inject, Injector, Input, NO_ERRORS_SCHEMA, NgModule, Output, SimpleChanges, destroyPlatform} from '@angular/core';
import {async, fakeAsync, tick} from '@angular/core/testing';
import {BrowserModule} from '@angular/platform-browser';
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
import * as angular from '@angular/upgrade/static/src/common/angular1';
import {$EXCEPTION_HANDLER, $SCOPE} from '@angular/upgrade/static/src/common/constants';
import {$digest, bootstrap, html, multiTrim, withEachNg1Version} from '../test_helpers';
import * as angular from '../../../src/common/src/angular1';
import {$EXCEPTION_HANDLER, $SCOPE} from '../../../src/common/src/constants';
import {html, multiTrim, withEachNg1Version} from '../../../src/common/test/helpers/common_test_helpers';
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '../../index';
import {$digest, bootstrap} from './static_test_helpers';
withEachNg1Version(() => {
describe('upgrade ng1 component', () => {

View File

@ -1,23 +0,0 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {UpgradeAdapterRef} from '@angular/upgrade';
import * as angular from '@angular/upgrade/src/common/angular1';
import {$ROOT_SCOPE} from '@angular/upgrade/src/common/constants';
export * from '../common/test_helpers';
export function $apply(adapter: UpgradeAdapterRef, exp: angular.Ng1Expression) {
const $rootScope = adapter.ng1Injector.get($ROOT_SCOPE) as angular.IRootScopeService;
$rootScope.$apply(exp);
}
export function $digest(adapter: UpgradeAdapterRef) {
const $rootScope = adapter.ng1Injector.get($ROOT_SCOPE) as angular.IRootScopeService;
$rootScope.$digest();
}

View File

@ -1,2 +0,0 @@
move /Y packages\upgrade\static\src packages\upgrade\static\src.old
mklink /D packages\upgrade\static\src ..\src

View File

@ -1,7 +0,0 @@
#!/usr/bin/env bash
cd `dirname $0`
UPGRADE_STATIC_DIR=./../../packages/upgrade/static
mv ${UPGRADE_STATIC_DIR}/src ${UPGRADE_STATIC_DIR}/src.old
cmd <<< "mklink /d \"..\\..\\packages\\upgrade\\static\\src\" \"..\\src\""

View File

@ -1,7 +0,0 @@
#!/usr/bin/env bash
cd `dirname $0`
UPGRADE_STATIC_DIR=./../../packages/upgrade/static
rm ${UPGRADE_STATIC_DIR}/src
mv ${UPGRADE_STATIC_DIR}/src.old ${UPGRADE_STATIC_DIR}/src

View File

@ -3,8 +3,12 @@ load(":public_api_guard.bzl", "generate_targets")
generate_targets(golden_files = glob(
["*/**/*.d.ts"],
# exclude the following target because we have an explicit target for it bellow, see :core_api
exclude = ["core/core.d.ts"],
# exclude the following target because we have an explicit target for it bellow, see :core_api, etc
exclude = [
"core/core.d.ts",
"upgrade/upgrade.d.ts",
"upgrade/static.d.ts",
],
))
# Explicit target because core is broken down into sub-packages.
@ -25,6 +29,32 @@ ts_api_guardian_test(
],
)
ts_api_guardian_test(
name = "upgrade_api",
actual = "angular/packages/upgrade/upgrade.d.ts",
data = ["//tools/public_api_guard:upgrade/upgrade.d.ts"] + [
"//packages/upgrade",
"//packages/upgrade/src/common",
],
golden = "angular/tools/public_api_guard/upgrade/upgrade.d.ts",
tags = [
"fixme-ivy-aot", # ivy no longer emits generated index file
],
)
ts_api_guardian_test(
name = "upgrade_static_api",
actual = "angular/packages/upgrade/static/index.d.ts",
data = ["//tools/public_api_guard:upgrade/static.d.ts"] + [
"//packages/upgrade/static",
"//packages/upgrade/src/common",
],
golden = "angular/tools/public_api_guard/upgrade/static.d.ts",
tags = [
"fixme-ivy-aot", # ivy no longer emits generated index file
],
)
# explicit target because the d.ts file is nested in the core and not part of typical public d.ts api
ts_api_guardian_test(
name = "ng_global_utils_api",