Skip to content

Commit 9f54d76

Browse files
petebacondarwinjasonaden
authored andcommitted
refactor(upgrade): use Bazel packages to avoid symlinks in the source (angular#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 angular#29466
1 parent e5201f9 commit 9f54d76

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+219
-162
lines changed

.codefresh/codefresh.yml

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ steps:
1717
commands:
1818
# Install dependencies
1919
- yarn install --frozen-lockfile --non-interactive --network-timeout 100000 --no-progress
20-
# Create symlinks needed for Windows.
21-
- scripts\windows\create-symlinks.cmd
2220
# Add Bazel CI config
2321
- copy .codefresh\bazel.rc %ProgramData%\bazel.bazelrc
2422
# Run tests

aio/README.md

-10
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@ Here are the most important tasks you might need to use:
4141
- `yarn example-e2e --filter=foo` - limit e2e tests to those containing the word "foo"
4242
- `yarn example-e2e --setup --local` - run e2e tests with the local version of Angular contained in the "dist" folder
4343

44-
## Developing on Windows
45-
The `packages/` directory may contain Linux-specific symlinks, which are not recognized by Windows.
46-
These unresolved links cause the docs generation process to fail because it cannot locate certain files.
47-
48-
> 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!
49-
50-
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.
51-
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`.
52-
53-
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.
5444

5545
## Using ServiceWorker locally
5646

docs/DEVELOPER.md

-12
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,6 @@ Next, install the JavaScript modules needed to build and test Angular:
5959
yarn install
6060
```
6161

62-
## Windows only
63-
64-
In order to create the right symlinks, run **as administrator**:
65-
```shell
66-
./scripts/windows/create-symlinks.sh
67-
```
68-
69-
Before submitting a PR, do not forget to remove them:
70-
```shell
71-
./scripts/windows/remove-symlinks.sh
72-
```
73-
7462
## Building
7563

7664
To build Angular run:

packages/upgrade/BUILD.bazel

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ ng_module(
77
srcs = glob(
88
[
99
"*.ts",
10-
"src/common/**/*.ts",
11-
"src/dynamic/**/*.ts",
10+
"src/dynamic/src/*.ts",
1211
],
1312
),
1413
deps = [
1514
"//packages/core",
16-
"//packages/platform-browser",
1715
"//packages/platform-browser-dynamic",
16+
"//packages/upgrade/src/common",
1817
"@npm//zone.js",
1918
],
2019
)

packages/upgrade/public_api.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Entry point for all public APIs of this package. allowing
1313
* Angular 1 and Angular 2+ to run side by side in the same application.
1414
*/
15-
export {VERSION} from './src/common/version';
16-
export {UpgradeAdapter, UpgradeAdapterRef} from './src/dynamic/upgrade_adapter';
15+
export {VERSION} from './src/common/src/version';
16+
export {UpgradeAdapter, UpgradeAdapterRef} from './src/dynamic/src/upgrade_adapter';
1717

1818
// This file only re-exports content of the `src` folder. Keep it that way.
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
load("//tools:defaults.bzl", "ts_library")
2+
3+
package(default_visibility = [
4+
"//packages/upgrade:__subpackages__",
5+
"//tools/public_api_guard:__subpackages__",
6+
])
7+
8+
ts_library(
9+
name = "common",
10+
srcs = glob([
11+
"src/**/*.ts",
12+
]),
13+
deps = [
14+
"//packages/core",
15+
],
16+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
load("//tools:defaults.bzl", "ts_library", "ts_web_test_suite")
2+
3+
ts_library(
4+
name = "test_lib",
5+
testonly = True,
6+
srcs = glob(["**/*.ts"]),
7+
deps = [
8+
"//packages/core",
9+
"//packages/core/testing",
10+
"//packages/upgrade/src/common",
11+
"//packages/upgrade/src/common/test/helpers",
12+
],
13+
)
14+
15+
ts_web_test_suite(
16+
name = "test",
17+
static_files = [
18+
"//:angularjs_scripts",
19+
],
20+
deps = [
21+
":test_lib",
22+
],
23+
)

packages/upgrade/test/common/component_info_spec.ts renamed to packages/upgrade/src/common/test/component_info_spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {PropertyBinding} from '@angular/upgrade/src/common/component_info';
9+
import {PropertyBinding} from '../src/component_info';
1010

1111
{
1212
describe('PropertyBinding', () => {

packages/upgrade/test/common/downgrade_component_adapter_spec.ts renamed to packages/upgrade/src/common/test/downgrade_component_adapter_spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
*/
88
import {Compiler, Component, ComponentFactory, Injector, NgModule, TestabilityRegistry} from '@angular/core';
99
import {TestBed} from '@angular/core/testing';
10-
import * as angular from '@angular/upgrade/src/common/angular1';
11-
import {DowngradeComponentAdapter, groupNodesBySelector} from '@angular/upgrade/src/common/downgrade_component_adapter';
10+
import * as angular from '../src/angular1';
11+
import {DowngradeComponentAdapter, groupNodesBySelector} from '../src/downgrade_component_adapter';
1212

13-
import {nodes, withEachNg1Version} from './test_helpers';
13+
import {nodes, withEachNg1Version} from './helpers/common_test_helpers';
1414

1515
withEachNg1Version(() => {
1616
describe('DowngradeComponentAdapter', () => {

packages/upgrade/test/common/downgrade_injectable_spec.ts renamed to packages/upgrade/src/common/test/downgrade_injectable_spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
*/
88

99
import {Injector} from '@angular/core';
10-
import * as angular from '@angular/upgrade/src/common/angular1';
11-
import {$INJECTOR, INJECTOR_KEY, UPGRADE_APP_TYPE_KEY} from '@angular/upgrade/src/common/constants';
12-
import {downgradeInjectable} from '@angular/upgrade/src/common/downgrade_injectable';
13-
import {UpgradeAppType} from '@angular/upgrade/src/common/util';
10+
import * as angular from '../src/angular1';
11+
import {$INJECTOR, INJECTOR_KEY, UPGRADE_APP_TYPE_KEY} from '../src/constants';
12+
import {downgradeInjectable} from '../src/downgrade_injectable';
13+
import {UpgradeAppType} from '../src/util';
1414

1515
describe('downgradeInjectable', () => {
1616
const setupMockInjectors = (downgradedModule = '') => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
load("//tools:defaults.bzl", "ts_library")
2+
3+
package(default_visibility = ["//packages/upgrade:__subpackages__"])
4+
5+
ts_library(
6+
name = "helpers",
7+
srcs = glob([
8+
"*.ts",
9+
]),
10+
deps = [
11+
"//packages/core/testing",
12+
"//packages/upgrade/src/common",
13+
],
14+
)

packages/upgrade/test/common/test_helpers.ts renamed to packages/upgrade/src/common/test/helpers/common_test_helpers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import {setAngularJSGlobal} from '@angular/upgrade/src/common/angular1';
8+
import {setAngularJSGlobal} from '../../src/angular1';
99

1010
// Whether the upgrade tests should run against AngularJS minified or not. This can be
1111
// temporarily switched to "false" in order to make it easy to debug AngularJS locally.

packages/upgrade/src/dynamic/upgrade_adapter.ts renamed to packages/upgrade/src/dynamic/src/upgrade_adapter.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
import {Compiler, CompilerOptions, Injector, NgModule, NgModuleRef, NgZone, StaticProvider, Testability, Type, resolveForwardRef} from '@angular/core';
1010
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
1111

12-
import {IAngularBootstrapConfig, IAugmentedJQuery, IInjectorService, IModule, IProvideService, IRootScopeService, ITestabilityService, bootstrap, element as angularElement, module as angularModule} from '../common/angular1';
13-
import {$$TESTABILITY, $COMPILE, $INJECTOR, $ROOT_SCOPE, COMPILER_KEY, INJECTOR_KEY, LAZY_MODULE_REF, NG_ZONE_KEY, UPGRADE_APP_TYPE_KEY} from '../common/constants';
14-
import {downgradeComponent} from '../common/downgrade_component';
15-
import {downgradeInjectable} from '../common/downgrade_injectable';
16-
import {Deferred, LazyModuleRef, UpgradeAppType, controllerKey, onError} from '../common/util';
12+
import {IAngularBootstrapConfig, IAugmentedJQuery, IInjectorService, IModule, IProvideService, IRootScopeService, ITestabilityService, bootstrap, element as angularElement, module as angularModule} from '../../common/src/angular1';
13+
import {$$TESTABILITY, $COMPILE, $INJECTOR, $ROOT_SCOPE, COMPILER_KEY, INJECTOR_KEY, LAZY_MODULE_REF, NG_ZONE_KEY, UPGRADE_APP_TYPE_KEY} from '../../common/src/constants';
14+
import {downgradeComponent} from '../../common/src/downgrade_component';
15+
import {downgradeInjectable} from '../../common/src/downgrade_injectable';
16+
import {Deferred, LazyModuleRef, UpgradeAppType, controllerKey, onError} from '../../common/src/util';
1717

1818
import {UpgradeNg1ComponentAdapterBuilder} from './upgrade_ng1_adapter';
1919

packages/upgrade/src/dynamic/upgrade_ng1_adapter.ts renamed to packages/upgrade/src/dynamic/src/upgrade_ng1_adapter.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
import {Directive, DoCheck, ElementRef, EventEmitter, Inject, Injector, OnChanges, OnDestroy, OnInit, SimpleChange, SimpleChanges, Type} from '@angular/core';
1010

11-
import {IAttributes, IDirective, IDirectivePrePost, IInjectorService, ILinkFn, IScope, ITranscludeFunction} from '../common/angular1';
12-
import {$SCOPE} from '../common/constants';
13-
import {IBindingDestination, IControllerInstance, UpgradeHelper} from '../common/upgrade_helper';
14-
import {isFunction, strictEquals} from '../common/util';
11+
import {IAttributes, IDirective, IDirectivePrePost, IInjectorService, ILinkFn, IScope, ITranscludeFunction} from '../../common/src/angular1';
12+
import {$SCOPE} from '../../common/src/constants';
13+
import {IBindingDestination, IControllerInstance, UpgradeHelper} from '../../common/src/upgrade_helper';
14+
import {isFunction, strictEquals} from '../../common/src/util';
1515

1616

1717
const CAMEL_CASE = /([A-Z])/g;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
load("//tools:defaults.bzl", "ts_library", "ts_web_test_suite")
2+
3+
ts_library(
4+
name = "test_lib",
5+
testonly = True,
6+
srcs = glob([
7+
"**/*.ts",
8+
]),
9+
deps = [
10+
"//packages/core",
11+
"//packages/core/testing",
12+
"//packages/platform-browser",
13+
"//packages/platform-browser-dynamic",
14+
"//packages/upgrade",
15+
"//packages/upgrade/src/common",
16+
"//packages/upgrade/src/common/test/helpers",
17+
],
18+
)
19+
20+
ts_web_test_suite(
21+
name = "test",
22+
static_files = [
23+
"//:angularjs_scripts",
24+
],
25+
deps = [
26+
":test_lib",
27+
],
28+
)

packages/upgrade/test/dynamic/upgrade_spec.ts renamed to packages/upgrade/src/dynamic/test/upgrade_spec.ts

+16-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ import {ChangeDetectorRef, Component, EventEmitter, Input, NO_ERRORS_SCHEMA, NgM
1010
import {async, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
1111
import {BrowserModule} from '@angular/platform-browser';
1212
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
13-
import * as angular from '@angular/upgrade/src/common/angular1';
14-
import {$EXCEPTION_HANDLER} from '@angular/upgrade/src/common/constants';
15-
import {UpgradeAdapter, UpgradeAdapterRef} from '@angular/upgrade/src/dynamic/upgrade_adapter';
1613

17-
import {$apply, $digest, html, multiTrim, withEachNg1Version} from './test_helpers';
14+
import * as angular from '../../common/src/angular1';
15+
import {$EXCEPTION_HANDLER, $ROOT_SCOPE} from '../../common/src/constants';
16+
import {html, multiTrim, withEachNg1Version} from '../../common/test/helpers/common_test_helpers';
17+
18+
import {UpgradeAdapter, UpgradeAdapterRef} from '../src/upgrade_adapter';
19+
1820

1921
declare global {
2022
export var inject: Function;
@@ -3280,3 +3282,13 @@ withEachNg1Version(() => {
32803282
});
32813283
});
32823284
});
3285+
3286+
function $apply(adapter: UpgradeAdapterRef, exp: angular.Ng1Expression) {
3287+
const $rootScope = adapter.ng1Injector.get($ROOT_SCOPE) as angular.IRootScopeService;
3288+
$rootScope.$apply(exp);
3289+
}
3290+
3291+
function $digest(adapter: UpgradeAdapterRef) {
3292+
const $rootScope = adapter.ng1Injector.get($ROOT_SCOPE) as angular.IRootScopeService;
3293+
$rootScope.$digest();
3294+
}

packages/upgrade/static/BUILD.bazel

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@ exports_files(["package.json"])
66

77
ng_module(
88
name = "static",
9-
# Note: There is Bazel issue where Windows symlinks
10-
# aka. junctions are not traversed by glob.
119
srcs = glob(
1210
[
1311
"*.ts",
14-
"src/common/**/*.ts",
15-
"src/static/**/*.ts",
12+
"src/*.ts",
1613
],
1714
),
1815
deps = [
1916
"//packages/core",
2017
"//packages/platform-browser",
21-
"//packages/platform-browser-dynamic",
18+
"//packages/upgrade/src/common",
2219
],
2320
)

packages/upgrade/static/public_api.ts

+8-14
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,13 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
/**
10-
* @module
11-
* @description
12-
* Entry point for all public APIs of this package. allowing
13-
* Angular 1 and Angular 2+ to run side by side in the same application.
14-
*/
15-
export {getAngularJSGlobal, getAngularLib, setAngularJSGlobal, setAngularLib} from './src/common/angular1';
16-
export {downgradeComponent} from './src/common/downgrade_component';
17-
export {downgradeInjectable} from './src/common/downgrade_injectable';
18-
export {VERSION} from './src/common/version';
19-
export {downgradeModule} from './src/static/downgrade_module';
20-
export {UpgradeComponent} from './src/static/upgrade_component';
21-
export {UpgradeModule} from './src/static/upgrade_module';
9+
export {getAngularJSGlobal, getAngularLib, setAngularJSGlobal, setAngularLib} from '../src/common/src/angular1';
10+
export {downgradeComponent} from '../src/common/src/downgrade_component';
11+
export {downgradeInjectable} from '../src/common/src/downgrade_injectable';
12+
export {VERSION} from '../src/common/src/version';
13+
export {downgradeModule} from './src/downgrade_module';
14+
export {UpgradeComponent} from './src/upgrade_component';
15+
export {UpgradeModule} from './src/upgrade_module';
2216

2317

24-
// This file only re-exports content of the `src` folder. Keep it that way.
18+
// This file only re-exports items to appear in the public api. Keep it that way.

packages/upgrade/static/src

-1
This file was deleted.

packages/upgrade/src/static/angular1_providers.ts renamed to packages/upgrade/static/src/angular1_providers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* found in the LICENSE file at https://angular.io/license
88
*/
99

10-
import {IInjectorService} from '../common/angular1';
10+
import {IInjectorService} from '../../src/common/src/angular1';
1111

1212
// We have to do a little dance to get the ng1 injector into the module injector.
1313
// We store the ng1 injector so that the provider in the module injector can access it

packages/upgrade/src/static/downgrade_module.ts renamed to packages/upgrade/static/src/downgrade_module.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
import {Injector, NgModuleFactory, NgModuleRef, StaticProvider} from '@angular/core';
1010
import {platformBrowser} from '@angular/platform-browser';
1111

12-
import {IInjectorService, IProvideService, module as angularModule} from '../common/angular1';
13-
import {$INJECTOR, $PROVIDE, DOWNGRADED_MODULE_COUNT_KEY, INJECTOR_KEY, LAZY_MODULE_REF, UPGRADE_APP_TYPE_KEY, UPGRADE_MODULE_NAME} from '../common/constants';
14-
import {LazyModuleRef, UpgradeAppType, getDowngradedModuleCount, isFunction} from '../common/util';
12+
import {IInjectorService, IProvideService, module as angularModule} from '../../src/common/src/angular1';
13+
import {$INJECTOR, $PROVIDE, DOWNGRADED_MODULE_COUNT_KEY, INJECTOR_KEY, LAZY_MODULE_REF, UPGRADE_APP_TYPE_KEY, UPGRADE_MODULE_NAME} from '../../src/common/src/constants';
14+
import {LazyModuleRef, UpgradeAppType, getDowngradedModuleCount, isFunction} from '../../src/common/src/util';
1515

1616
import {angular1Providers, setTempInjectorRef} from './angular1_providers';
1717
import {NgAdapterInjector} from './util';

packages/upgrade/src/static/upgrade_component.ts renamed to packages/upgrade/static/src/upgrade_component.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
import {DoCheck, ElementRef, EventEmitter, Injector, OnChanges, OnDestroy, OnInit, SimpleChanges, ɵlooseIdentical as looseIdentical} from '@angular/core';
1010

11-
import {IAttributes, IAugmentedJQuery, IDirective, IDirectivePrePost, IInjectorService, ILinkFn, IScope, ITranscludeFunction} from '../common/angular1';
12-
import {$SCOPE} from '../common/constants';
13-
import {IBindingDestination, IControllerInstance, UpgradeHelper} from '../common/upgrade_helper';
14-
import {isFunction} from '../common/util';
11+
import {IAttributes, IAugmentedJQuery, IDirective, IDirectivePrePost, IInjectorService, ILinkFn, IScope, ITranscludeFunction} from '../../src/common/src/angular1';
12+
import {$SCOPE} from '../../src/common/src/constants';
13+
import {IBindingDestination, IControllerInstance, UpgradeHelper} from '../../src/common/src/upgrade_helper';
14+
import {isFunction} from '../../src/common/src/util';
1515

1616
const NOT_SUPPORTED: any = 'NOT_SUPPORTED';
1717
const INITIAL_VALUE = {

packages/upgrade/src/static/upgrade_module.ts renamed to packages/upgrade/static/src/upgrade_module.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
import {Injector, NgModule, NgZone, Testability} from '@angular/core';
1010

11-
import {IInjectorService, IIntervalService, IProvideService, ITestabilityService, bootstrap, element as angularElement, module as angularModule} from '../common/angular1';
12-
import {$$TESTABILITY, $DELEGATE, $INJECTOR, $INTERVAL, $PROVIDE, INJECTOR_KEY, LAZY_MODULE_REF, UPGRADE_APP_TYPE_KEY, UPGRADE_MODULE_NAME} from '../common/constants';
13-
import {LazyModuleRef, UpgradeAppType, controllerKey} from '../common/util';
11+
import {IInjectorService, IIntervalService, IProvideService, ITestabilityService, bootstrap, element as angularElement, module as angularModule} from '../../src/common/src/angular1';
12+
import {$$TESTABILITY, $DELEGATE, $INJECTOR, $INTERVAL, $PROVIDE, INJECTOR_KEY, LAZY_MODULE_REF, UPGRADE_APP_TYPE_KEY, UPGRADE_MODULE_NAME} from '../../src/common/src/constants';
13+
import {LazyModuleRef, UpgradeAppType, controllerKey} from '../../src/common/src/util';
1414

1515
import {angular1Providers, setTempInjectorRef} from './angular1_providers';
1616
import {NgAdapterInjector} from './util';

packages/upgrade/test/BUILD.bazel renamed to packages/upgrade/static/test/BUILD.bazel

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,23 @@ load("//tools:defaults.bzl", "ts_library", "ts_web_test_suite")
33
ts_library(
44
name = "test_lib",
55
testonly = True,
6-
srcs = glob(["**/*.ts"]),
6+
srcs = glob([
7+
"**/*.ts",
8+
]),
79
deps = [
8-
"//packages:types",
910
"//packages/core",
1011
"//packages/core/testing",
1112
"//packages/platform-browser",
1213
"//packages/platform-browser-dynamic",
1314
"//packages/platform-browser/testing",
14-
"//packages/upgrade",
15+
"//packages/upgrade/src/common",
16+
"//packages/upgrade/src/common/test/helpers",
1517
"//packages/upgrade/static",
16-
"@npm//rxjs",
1718
],
1819
)
1920

2021
ts_web_test_suite(
21-
name = "test_web",
22+
name = "test",
2223
static_files = [
2324
"//:angularjs_scripts",
2425
],

0 commit comments

Comments
 (0)