From 9f54d76ef5e84ca5304d3ea70165842b3a0ad06a Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Fri, 22 Mar 2019 09:42:52 +0000 Subject: [PATCH] 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 --- .codefresh/codefresh.yml | 2 -- aio/README.md | 10 ------ docs/DEVELOPER.md | 12 ------- packages/upgrade/BUILD.bazel | 5 ++- packages/upgrade/public_api.ts | 4 +-- packages/upgrade/src/common/BUILD.bazel | 16 +++++++++ .../upgrade/src/common/{ => src}/angular1.ts | 0 .../src/common/{ => src}/component_info.ts | 0 .../upgrade/src/common/{ => src}/constants.ts | 0 .../common/{ => src}/downgrade_component.ts | 0 .../{ => src}/downgrade_component_adapter.ts | 0 .../common/{ => src}/downgrade_injectable.ts | 0 .../src/common/{ => src}/upgrade_helper.ts | 0 packages/upgrade/src/common/{ => src}/util.ts | 0 .../upgrade/src/common/{ => src}/version.ts | 0 packages/upgrade/src/common/test/BUILD.bazel | 23 +++++++++++++ .../common/test}/component_info_spec.ts | 2 +- .../test}/downgrade_component_adapter_spec.ts | 6 ++-- .../common/test}/downgrade_injectable_spec.ts | 8 ++--- .../src/common/test/helpers/BUILD.bazel | 14 ++++++++ .../test/helpers/common_test_helpers.ts} | 2 +- .../src/dynamic/{ => src}/upgrade_adapter.ts | 10 +++--- .../dynamic/{ => src}/upgrade_ng1_adapter.ts | 8 ++--- packages/upgrade/src/dynamic/test/BUILD.bazel | 28 +++++++++++++++ .../dynamic/test}/upgrade_spec.ts | 20 ++++++++--- packages/upgrade/static/BUILD.bazel | 7 ++-- packages/upgrade/static/public_api.ts | 22 +++++------- packages/upgrade/static/src | 1 - .../src}/angular1_providers.ts | 2 +- .../static => static/src}/downgrade_module.ts | 6 ++-- .../src}/upgrade_component.ts | 8 ++--- .../static => static/src}/upgrade_module.ts | 6 ++-- .../{src/static => static/src}/util.ts | 0 .../upgrade/{ => static}/test/BUILD.bazel | 11 +++--- .../test}/angular1_providers_spec.ts | 4 +-- .../integration/change_detection_spec.ts | 8 +++-- .../integration/content_projection_spec.ts | 5 +-- .../integration/downgrade_component_spec.ts | 5 +-- .../integration/downgrade_module_spec.ts | 10 +++--- .../test}/integration/examples_spec.ts | 6 ++-- .../test}/integration/injection_spec.ts | 10 +++--- .../test/integration/static_test_helpers.ts} | 9 ++--- .../test}/integration/testability_spec.ts | 5 +-- .../integration/upgrade_component_spec.ts | 13 ++++--- packages/upgrade/test/dynamic/test_helpers.ts | 23 ------------- scripts/windows/create-symlinks.cmd | 2 -- scripts/windows/create-symlinks.sh | 7 ---- scripts/windows/remove-symlinks.sh | 7 ---- tools/public_api_guard/BUILD.bazel | 34 +++++++++++++++++-- 49 files changed, 219 insertions(+), 162 deletions(-) create mode 100644 packages/upgrade/src/common/BUILD.bazel rename packages/upgrade/src/common/{ => src}/angular1.ts (100%) rename packages/upgrade/src/common/{ => src}/component_info.ts (100%) rename packages/upgrade/src/common/{ => src}/constants.ts (100%) rename packages/upgrade/src/common/{ => src}/downgrade_component.ts (100%) rename packages/upgrade/src/common/{ => src}/downgrade_component_adapter.ts (100%) rename packages/upgrade/src/common/{ => src}/downgrade_injectable.ts (100%) rename packages/upgrade/src/common/{ => src}/upgrade_helper.ts (100%) rename packages/upgrade/src/common/{ => src}/util.ts (100%) rename packages/upgrade/src/common/{ => src}/version.ts (100%) create mode 100644 packages/upgrade/src/common/test/BUILD.bazel rename packages/upgrade/{test/common => src/common/test}/component_info_spec.ts (94%) rename packages/upgrade/{test/common => src/common/test}/downgrade_component_adapter_spec.ts (96%) rename packages/upgrade/{test/common => src/common/test}/downgrade_injectable_spec.ts (86%) create mode 100644 packages/upgrade/src/common/test/helpers/BUILD.bazel rename packages/upgrade/{test/common/test_helpers.ts => src/common/test/helpers/common_test_helpers.ts} (98%) rename packages/upgrade/src/dynamic/{ => src}/upgrade_adapter.ts (98%) rename packages/upgrade/src/dynamic/{ => src}/upgrade_ng1_adapter.ts (97%) create mode 100644 packages/upgrade/src/dynamic/test/BUILD.bazel rename packages/upgrade/{test/dynamic => src/dynamic/test}/upgrade_spec.ts (99%) delete mode 120000 packages/upgrade/static/src rename packages/upgrade/{src/static => static/src}/angular1_providers.ts (96%) rename packages/upgrade/{src/static => static/src}/downgrade_module.ts (98%) rename packages/upgrade/{src/static => static/src}/upgrade_component.ts (98%) rename packages/upgrade/{src/static => static/src}/upgrade_module.ts (98%) rename packages/upgrade/{src/static => static/src}/util.ts (100%) rename packages/upgrade/{ => static}/test/BUILD.bazel (75%) rename packages/upgrade/{test/static => static/test}/angular1_providers_spec.ts (93%) rename packages/upgrade/{test/static => static/test}/integration/change_detection_spec.ts (95%) rename packages/upgrade/{test/static => static/test}/integration/content_projection_spec.ts (96%) rename packages/upgrade/{test/static => static/test}/integration/downgrade_component_spec.ts (99%) rename packages/upgrade/{test/static => static/test}/integration/downgrade_module_spec.ts (99%) rename packages/upgrade/{test/static => static/test}/integration/examples_spec.ts (93%) rename packages/upgrade/{test/static => static/test}/integration/injection_spec.ts (93%) rename packages/upgrade/{test/static/test_helpers.ts => static/test/integration/static_test_helpers.ts} (82%) rename packages/upgrade/{test/static => static/test}/integration/testability_spec.ts (95%) rename packages/upgrade/{test/static => static/test}/integration/upgrade_component_spec.ts (99%) delete mode 100644 packages/upgrade/test/dynamic/test_helpers.ts delete mode 100644 scripts/windows/create-symlinks.cmd delete mode 100644 scripts/windows/create-symlinks.sh delete mode 100644 scripts/windows/remove-symlinks.sh diff --git a/.codefresh/codefresh.yml b/.codefresh/codefresh.yml index 9454a339fc..e24284c7db 100644 --- a/.codefresh/codefresh.yml +++ b/.codefresh/codefresh.yml @@ -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 diff --git a/aio/README.md b/aio/README.md index 18af4b96aa..3a8a75235a 100644 --- a/aio/README.md +++ b/aio/README.md @@ -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 diff --git a/docs/DEVELOPER.md b/docs/DEVELOPER.md index a816a03297..054953f460 100644 --- a/docs/DEVELOPER.md +++ b/docs/DEVELOPER.md @@ -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: diff --git a/packages/upgrade/BUILD.bazel b/packages/upgrade/BUILD.bazel index d1fa38ce0e..d2af3caad7 100644 --- a/packages/upgrade/BUILD.bazel +++ b/packages/upgrade/BUILD.bazel @@ -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", ], ) diff --git a/packages/upgrade/public_api.ts b/packages/upgrade/public_api.ts index 0d6125fe1d..a44fb32690 100644 --- a/packages/upgrade/public_api.ts +++ b/packages/upgrade/public_api.ts @@ -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. diff --git a/packages/upgrade/src/common/BUILD.bazel b/packages/upgrade/src/common/BUILD.bazel new file mode 100644 index 0000000000..54a9b1dcdd --- /dev/null +++ b/packages/upgrade/src/common/BUILD.bazel @@ -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", + ], +) diff --git a/packages/upgrade/src/common/angular1.ts b/packages/upgrade/src/common/src/angular1.ts similarity index 100% rename from packages/upgrade/src/common/angular1.ts rename to packages/upgrade/src/common/src/angular1.ts diff --git a/packages/upgrade/src/common/component_info.ts b/packages/upgrade/src/common/src/component_info.ts similarity index 100% rename from packages/upgrade/src/common/component_info.ts rename to packages/upgrade/src/common/src/component_info.ts diff --git a/packages/upgrade/src/common/constants.ts b/packages/upgrade/src/common/src/constants.ts similarity index 100% rename from packages/upgrade/src/common/constants.ts rename to packages/upgrade/src/common/src/constants.ts diff --git a/packages/upgrade/src/common/downgrade_component.ts b/packages/upgrade/src/common/src/downgrade_component.ts similarity index 100% rename from packages/upgrade/src/common/downgrade_component.ts rename to packages/upgrade/src/common/src/downgrade_component.ts diff --git a/packages/upgrade/src/common/downgrade_component_adapter.ts b/packages/upgrade/src/common/src/downgrade_component_adapter.ts similarity index 100% rename from packages/upgrade/src/common/downgrade_component_adapter.ts rename to packages/upgrade/src/common/src/downgrade_component_adapter.ts diff --git a/packages/upgrade/src/common/downgrade_injectable.ts b/packages/upgrade/src/common/src/downgrade_injectable.ts similarity index 100% rename from packages/upgrade/src/common/downgrade_injectable.ts rename to packages/upgrade/src/common/src/downgrade_injectable.ts diff --git a/packages/upgrade/src/common/upgrade_helper.ts b/packages/upgrade/src/common/src/upgrade_helper.ts similarity index 100% rename from packages/upgrade/src/common/upgrade_helper.ts rename to packages/upgrade/src/common/src/upgrade_helper.ts diff --git a/packages/upgrade/src/common/util.ts b/packages/upgrade/src/common/src/util.ts similarity index 100% rename from packages/upgrade/src/common/util.ts rename to packages/upgrade/src/common/src/util.ts diff --git a/packages/upgrade/src/common/version.ts b/packages/upgrade/src/common/src/version.ts similarity index 100% rename from packages/upgrade/src/common/version.ts rename to packages/upgrade/src/common/src/version.ts diff --git a/packages/upgrade/src/common/test/BUILD.bazel b/packages/upgrade/src/common/test/BUILD.bazel new file mode 100644 index 0000000000..054ff10aad --- /dev/null +++ b/packages/upgrade/src/common/test/BUILD.bazel @@ -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", + ], +) diff --git a/packages/upgrade/test/common/component_info_spec.ts b/packages/upgrade/src/common/test/component_info_spec.ts similarity index 94% rename from packages/upgrade/test/common/component_info_spec.ts rename to packages/upgrade/src/common/test/component_info_spec.ts index 63969b110e..7785b33f12 100644 --- a/packages/upgrade/test/common/component_info_spec.ts +++ b/packages/upgrade/src/common/test/component_info_spec.ts @@ -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', () => { diff --git a/packages/upgrade/test/common/downgrade_component_adapter_spec.ts b/packages/upgrade/src/common/test/downgrade_component_adapter_spec.ts similarity index 96% rename from packages/upgrade/test/common/downgrade_component_adapter_spec.ts rename to packages/upgrade/src/common/test/downgrade_component_adapter_spec.ts index bf5d4cc471..679802de82 100644 --- a/packages/upgrade/test/common/downgrade_component_adapter_spec.ts +++ b/packages/upgrade/src/common/test/downgrade_component_adapter_spec.ts @@ -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', () => { diff --git a/packages/upgrade/test/common/downgrade_injectable_spec.ts b/packages/upgrade/src/common/test/downgrade_injectable_spec.ts similarity index 86% rename from packages/upgrade/test/common/downgrade_injectable_spec.ts rename to packages/upgrade/src/common/test/downgrade_injectable_spec.ts index 193f552c6d..7fbab3e8e6 100644 --- a/packages/upgrade/test/common/downgrade_injectable_spec.ts +++ b/packages/upgrade/src/common/test/downgrade_injectable_spec.ts @@ -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 = '') => { diff --git a/packages/upgrade/src/common/test/helpers/BUILD.bazel b/packages/upgrade/src/common/test/helpers/BUILD.bazel new file mode 100644 index 0000000000..8faa68b144 --- /dev/null +++ b/packages/upgrade/src/common/test/helpers/BUILD.bazel @@ -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", + ], +) diff --git a/packages/upgrade/test/common/test_helpers.ts b/packages/upgrade/src/common/test/helpers/common_test_helpers.ts similarity index 98% rename from packages/upgrade/test/common/test_helpers.ts rename to packages/upgrade/src/common/test/helpers/common_test_helpers.ts index bcf2420578..209d4304bc 100644 --- a/packages/upgrade/test/common/test_helpers.ts +++ b/packages/upgrade/src/common/test/helpers/common_test_helpers.ts @@ -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. diff --git a/packages/upgrade/src/dynamic/upgrade_adapter.ts b/packages/upgrade/src/dynamic/src/upgrade_adapter.ts similarity index 98% rename from packages/upgrade/src/dynamic/upgrade_adapter.ts rename to packages/upgrade/src/dynamic/src/upgrade_adapter.ts index cc6879067a..f1aa2b80e5 100644 --- a/packages/upgrade/src/dynamic/upgrade_adapter.ts +++ b/packages/upgrade/src/dynamic/src/upgrade_adapter.ts @@ -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'; diff --git a/packages/upgrade/src/dynamic/upgrade_ng1_adapter.ts b/packages/upgrade/src/dynamic/src/upgrade_ng1_adapter.ts similarity index 97% rename from packages/upgrade/src/dynamic/upgrade_ng1_adapter.ts rename to packages/upgrade/src/dynamic/src/upgrade_ng1_adapter.ts index 918267bd4a..ac22158b3c 100644 --- a/packages/upgrade/src/dynamic/upgrade_ng1_adapter.ts +++ b/packages/upgrade/src/dynamic/src/upgrade_ng1_adapter.ts @@ -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; diff --git a/packages/upgrade/src/dynamic/test/BUILD.bazel b/packages/upgrade/src/dynamic/test/BUILD.bazel new file mode 100644 index 0000000000..9ffbce997b --- /dev/null +++ b/packages/upgrade/src/dynamic/test/BUILD.bazel @@ -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", + ], +) diff --git a/packages/upgrade/test/dynamic/upgrade_spec.ts b/packages/upgrade/src/dynamic/test/upgrade_spec.ts similarity index 99% rename from packages/upgrade/test/dynamic/upgrade_spec.ts rename to packages/upgrade/src/dynamic/test/upgrade_spec.ts index 32e8626355..e04fd8302c 100644 --- a/packages/upgrade/test/dynamic/upgrade_spec.ts +++ b/packages/upgrade/src/dynamic/test/upgrade_spec.ts @@ -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(); +} \ No newline at end of file diff --git a/packages/upgrade/static/BUILD.bazel b/packages/upgrade/static/BUILD.bazel index 06499506d1..3e71e3a13d 100644 --- a/packages/upgrade/static/BUILD.bazel +++ b/packages/upgrade/static/BUILD.bazel @@ -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", ], ) diff --git a/packages/upgrade/static/public_api.ts b/packages/upgrade/static/public_api.ts index c881be7a53..c0cfaacc61 100644 --- a/packages/upgrade/static/public_api.ts +++ b/packages/upgrade/static/public_api.ts @@ -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. diff --git a/packages/upgrade/static/src b/packages/upgrade/static/src deleted file mode 120000 index 5cd551cf26..0000000000 --- a/packages/upgrade/static/src +++ /dev/null @@ -1 +0,0 @@ -../src \ No newline at end of file diff --git a/packages/upgrade/src/static/angular1_providers.ts b/packages/upgrade/static/src/angular1_providers.ts similarity index 96% rename from packages/upgrade/src/static/angular1_providers.ts rename to packages/upgrade/static/src/angular1_providers.ts index 5970bbbef3..8e2594475f 100644 --- a/packages/upgrade/src/static/angular1_providers.ts +++ b/packages/upgrade/static/src/angular1_providers.ts @@ -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 diff --git a/packages/upgrade/src/static/downgrade_module.ts b/packages/upgrade/static/src/downgrade_module.ts similarity index 98% rename from packages/upgrade/src/static/downgrade_module.ts rename to packages/upgrade/static/src/downgrade_module.ts index 184889287c..cd6bfe9af1 100644 --- a/packages/upgrade/src/static/downgrade_module.ts +++ b/packages/upgrade/static/src/downgrade_module.ts @@ -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'; diff --git a/packages/upgrade/src/static/upgrade_component.ts b/packages/upgrade/static/src/upgrade_component.ts similarity index 98% rename from packages/upgrade/src/static/upgrade_component.ts rename to packages/upgrade/static/src/upgrade_component.ts index ac74c5b4dc..048cef9b42 100644 --- a/packages/upgrade/src/static/upgrade_component.ts +++ b/packages/upgrade/static/src/upgrade_component.ts @@ -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 = { diff --git a/packages/upgrade/src/static/upgrade_module.ts b/packages/upgrade/static/src/upgrade_module.ts similarity index 98% rename from packages/upgrade/src/static/upgrade_module.ts rename to packages/upgrade/static/src/upgrade_module.ts index dd057221bd..46b36eb9d3 100644 --- a/packages/upgrade/src/static/upgrade_module.ts +++ b/packages/upgrade/static/src/upgrade_module.ts @@ -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'; diff --git a/packages/upgrade/src/static/util.ts b/packages/upgrade/static/src/util.ts similarity index 100% rename from packages/upgrade/src/static/util.ts rename to packages/upgrade/static/src/util.ts diff --git a/packages/upgrade/test/BUILD.bazel b/packages/upgrade/static/test/BUILD.bazel similarity index 75% rename from packages/upgrade/test/BUILD.bazel rename to packages/upgrade/static/test/BUILD.bazel index 48cc479d08..b60d96a550 100644 --- a/packages/upgrade/test/BUILD.bazel +++ b/packages/upgrade/static/test/BUILD.bazel @@ -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", ], diff --git a/packages/upgrade/test/static/angular1_providers_spec.ts b/packages/upgrade/static/test/angular1_providers_spec.ts similarity index 93% rename from packages/upgrade/test/static/angular1_providers_spec.ts rename to packages/upgrade/static/test/angular1_providers_spec.ts index 6b44b87143..66151ed706 100644 --- a/packages/upgrade/test/static/angular1_providers_spec.ts +++ b/packages/upgrade/static/test/angular1_providers_spec.ts @@ -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', () => { diff --git a/packages/upgrade/test/static/integration/change_detection_spec.ts b/packages/upgrade/static/test/integration/change_detection_spec.ts similarity index 95% rename from packages/upgrade/test/static/integration/change_detection_spec.ts rename to packages/upgrade/static/test/integration/change_detection_spec.ts index f4008eefcd..6e5e2661a3 100644 --- a/packages/upgrade/test/static/integration/change_detection_spec.ts +++ b/packages/upgrade/static/test/integration/change_detection_spec.ts @@ -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', () => { diff --git a/packages/upgrade/test/static/integration/content_projection_spec.ts b/packages/upgrade/static/test/integration/content_projection_spec.ts similarity index 96% rename from packages/upgrade/test/static/integration/content_projection_spec.ts rename to packages/upgrade/static/test/integration/content_projection_spec.ts index 00b21ad536..026cc9b08d 100644 --- a/packages/upgrade/test/static/integration/content_projection_spec.ts +++ b/packages/upgrade/static/test/integration/content_projection_spec.ts @@ -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', () => { diff --git a/packages/upgrade/test/static/integration/downgrade_component_spec.ts b/packages/upgrade/static/test/integration/downgrade_component_spec.ts similarity index 99% rename from packages/upgrade/test/static/integration/downgrade_component_spec.ts rename to packages/upgrade/static/test/integration/downgrade_component_spec.ts index 1b5ade4d2c..b97433ee9a 100644 --- a/packages/upgrade/test/static/integration/downgrade_component_spec.ts +++ b/packages/upgrade/static/test/integration/downgrade_component_spec.ts @@ -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', () => { diff --git a/packages/upgrade/test/static/integration/downgrade_module_spec.ts b/packages/upgrade/static/test/integration/downgrade_module_spec.ts similarity index 99% rename from packages/upgrade/test/static/integration/downgrade_module_spec.ts rename to packages/upgrade/static/test/integration/downgrade_module_spec.ts index c76ea86066..ecb0959835 100644 --- a/packages/upgrade/test/static/integration/downgrade_module_spec.ts +++ b/packages/upgrade/static/test/integration/downgrade_module_spec.ts @@ -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(() => { diff --git a/packages/upgrade/test/static/integration/examples_spec.ts b/packages/upgrade/static/test/integration/examples_spec.ts similarity index 93% rename from packages/upgrade/test/static/integration/examples_spec.ts rename to packages/upgrade/static/test/integration/examples_spec.ts index f7ec6f52fb..02fee2db87 100644 --- a/packages/upgrade/test/static/integration/examples_spec.ts +++ b/packages/upgrade/static/test/integration/examples_spec.ts @@ -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', () => { diff --git a/packages/upgrade/test/static/integration/injection_spec.ts b/packages/upgrade/static/test/integration/injection_spec.ts similarity index 93% rename from packages/upgrade/test/static/integration/injection_spec.ts rename to packages/upgrade/static/test/integration/injection_spec.ts index 1a427570e9..7213c50bbd 100644 --- a/packages/upgrade/test/static/integration/injection_spec.ts +++ b/packages/upgrade/static/test/integration/injection_spec.ts @@ -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', () => { diff --git a/packages/upgrade/test/static/test_helpers.ts b/packages/upgrade/static/test/integration/static_test_helpers.ts similarity index 82% rename from packages/upgrade/test/static/test_helpers.ts rename to packages/upgrade/static/test/integration/static_test_helpers.ts index 8f32c1f43e..bed5a994b1 100644 --- a/packages/upgrade/test/static/test_helpers.ts +++ b/packages/upgrade/static/test/integration/static_test_helpers.ts @@ -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); diff --git a/packages/upgrade/test/static/integration/testability_spec.ts b/packages/upgrade/static/test/integration/testability_spec.ts similarity index 95% rename from packages/upgrade/test/static/integration/testability_spec.ts rename to packages/upgrade/static/test/integration/testability_spec.ts index 3ceeb0ab9d..f204225216 100644 --- a/packages/upgrade/test/static/integration/testability_spec.ts +++ b/packages/upgrade/static/test/integration/testability_spec.ts @@ -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', () => { diff --git a/packages/upgrade/test/static/integration/upgrade_component_spec.ts b/packages/upgrade/static/test/integration/upgrade_component_spec.ts similarity index 99% rename from packages/upgrade/test/static/integration/upgrade_component_spec.ts rename to packages/upgrade/static/test/integration/upgrade_component_spec.ts index 998873ac74..87e70182c3 100644 --- a/packages/upgrade/test/static/integration/upgrade_component_spec.ts +++ b/packages/upgrade/static/test/integration/upgrade_component_spec.ts @@ -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', () => { diff --git a/packages/upgrade/test/dynamic/test_helpers.ts b/packages/upgrade/test/dynamic/test_helpers.ts deleted file mode 100644 index 7723ecc361..0000000000 --- a/packages/upgrade/test/dynamic/test_helpers.ts +++ /dev/null @@ -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(); -} diff --git a/scripts/windows/create-symlinks.cmd b/scripts/windows/create-symlinks.cmd deleted file mode 100644 index 4b93d90b60..0000000000 --- a/scripts/windows/create-symlinks.cmd +++ /dev/null @@ -1,2 +0,0 @@ -move /Y packages\upgrade\static\src packages\upgrade\static\src.old -mklink /D packages\upgrade\static\src ..\src diff --git a/scripts/windows/create-symlinks.sh b/scripts/windows/create-symlinks.sh deleted file mode 100644 index 09b2b7015c..0000000000 --- a/scripts/windows/create-symlinks.sh +++ /dev/null @@ -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\"" diff --git a/scripts/windows/remove-symlinks.sh b/scripts/windows/remove-symlinks.sh deleted file mode 100644 index 4d8f3d025e..0000000000 --- a/scripts/windows/remove-symlinks.sh +++ /dev/null @@ -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 diff --git a/tools/public_api_guard/BUILD.bazel b/tools/public_api_guard/BUILD.bazel index 2b3b335791..57d7066617 100644 --- a/tools/public_api_guard/BUILD.bazel +++ b/tools/public_api_guard/BUILD.bazel @@ -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",