From e628b66cca623bb86e5350d60654cdbb51ae35db Mon Sep 17 00:00:00 2001 From: Victor Savkin Date: Wed, 30 Nov 2016 13:52:08 -0800 Subject: [PATCH] feat(build): record angular version in the dom (#13164) --- modules/@angular/common/index.ts | 8 +++++-- modules/@angular/compiler-cli/index.ts | 8 +++++-- modules/@angular/compiler/index.ts | 6 ++++- modules/@angular/core/index.ts | 5 +++++ modules/@angular/core/src/core.ts | 3 ++- modules/@angular/core/src/version.ts | 22 +++++++++++++++++++ modules/@angular/forms/index.ts | 5 +++++ modules/@angular/http/index.ts | 5 +++++ modules/@angular/language-service/index.ts | 5 +++++ .../platform-browser-dynamic/index.ts | 5 +++++ modules/@angular/platform-browser/index.ts | 6 ++++- .../@angular/platform-browser/src/browser.ts | 11 +++++++++- .../platform-browser/src/platform-browser.ts | 3 +-- modules/@angular/platform-server/index.ts | 6 +++++ .../platform-webworker-dynamic/index.ts | 5 +++++ modules/@angular/platform-webworker/index.ts | 5 +++++ modules/@angular/router/index.ts | 5 +++++ modules/@angular/upgrade/index.ts | 5 +++++ publish-packages.sh | 2 ++ tools/public_api_guard/common/index.d.ts | 3 +++ tools/public_api_guard/core/index.d.ts | 12 ++++++++++ tools/public_api_guard/forms/index.d.ts | 3 +++ tools/public_api_guard/http/index.d.ts | 3 +++ .../platform-browser-dynamic/index.d.ts | 3 +++ .../platform-browser/index.d.ts | 3 +++ .../platform-server/index.d.ts | 3 +++ .../platform-webworker-dynamic/index.d.ts | 3 +++ .../platform-webworker/index.d.ts | 3 +++ tools/public_api_guard/router/index.d.ts | 3 +++ tools/public_api_guard/upgrade/index.d.ts | 3 +++ 30 files changed, 152 insertions(+), 10 deletions(-) create mode 100644 modules/@angular/core/src/version.ts diff --git a/modules/@angular/common/index.ts b/modules/@angular/common/index.ts index 56ec817053..f7ad39771a 100644 --- a/modules/@angular/common/index.ts +++ b/modules/@angular/common/index.ts @@ -14,6 +14,10 @@ export * from './src/location'; export {NgLocalization} from './src/localization'; export {CommonModule} from './src/common_module'; - export {NgClass, NgFor, NgIf, NgPlural, NgPluralCase, NgStyle, NgSwitch, NgSwitchCase, NgSwitchDefault, NgTemplateOutlet} from './src/directives/index'; -export {AsyncPipe, DatePipe, I18nPluralPipe, I18nSelectPipe, JsonPipe, LowerCasePipe, CurrencyPipe, DecimalPipe, PercentPipe, SlicePipe, UpperCasePipe} from './src/pipes/index'; \ No newline at end of file +export {AsyncPipe, DatePipe, I18nPluralPipe, I18nSelectPipe, JsonPipe, LowerCasePipe, CurrencyPipe, DecimalPipe, PercentPipe, SlicePipe, UpperCasePipe} from './src/pipes/index'; +import {Version} from '@angular/core'; +/** + * @stable + */ +export const VERSION = new Version('0.0.0-PLACEHOLDER'); \ No newline at end of file diff --git a/modules/@angular/compiler-cli/index.ts b/modules/@angular/compiler-cli/index.ts index 00a7644eae..89d6383800 100644 --- a/modules/@angular/compiler-cli/index.ts +++ b/modules/@angular/compiler-cli/index.ts @@ -5,10 +5,14 @@ * 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 */ - export {AotCompilerHost, AotCompilerHost as StaticReflectorHost, StaticReflector, StaticSymbol} from '@angular/compiler'; export {CodeGenerator} from './src/codegen'; export {CompilerHost, CompilerHostContext, NodeCompilerHostContext} from './src/compiler_host'; export {Extractor} from './src/extractor'; - export * from '@angular/tsc-wrapped'; + +import {Version} from '@angular/core'; +/** + * @stable + */ +export const VERSION = new Version('0.0.0-PLACEHOLDER'); \ No newline at end of file diff --git a/modules/@angular/compiler/index.ts b/modules/@angular/compiler/index.ts index 215911dedb..a9997670b1 100644 --- a/modules/@angular/compiler/index.ts +++ b/modules/@angular/compiler/index.ts @@ -21,6 +21,11 @@ *

* */ +import {Version} from '@angular/core'; +/** + * @stable + */ +export const VERSION = new Version('0.0.0-PLACEHOLDER'); export * from './src/template_parser/template_ast'; export {TEMPLATE_TRANSFORMS} from './src/template_parser/template_parser'; export {CompilerConfig, RenderTypes} from './src/config'; @@ -58,5 +63,4 @@ export * from './src/style_compiler'; export * from './src/template_parser/template_parser'; export {ViewCompiler} from './src/view_compiler/view_compiler'; export {AnimationParser} from './src/animation/animation_parser'; - // This file only reexports content of the `src` folder. Keep it that way. diff --git a/modules/@angular/core/index.ts b/modules/@angular/core/index.ts index ede0762054..7a625d11dc 100644 --- a/modules/@angular/core/index.ts +++ b/modules/@angular/core/index.ts @@ -12,5 +12,10 @@ * Entry point for all public APIs of the core package. */ export * from './src/core'; +import {Version} from './src/core'; +/** + * @stable + */ +export const VERSION = new Version('0.0.0-PLACEHOLDER'); // This file only reexports content of the `src` folder. Keep it that way. diff --git a/modules/@angular/core/src/core.ts b/modules/@angular/core/src/core.ts index 4806c214a5..726ff833f9 100644 --- a/modules/@angular/core/src/core.ts +++ b/modules/@angular/core/src/core.ts @@ -12,6 +12,7 @@ * Entry point from which you should import all public core APIs. */ export * from './metadata'; +export * from './version'; export * from './util'; export * from './di'; export {createPlatform, assertPlatform, destroyPlatform, getPlatform, PlatformRef, ApplicationRef, enableProdMode, isDevMode, createPlatformFactory, NgProbeToken} from './application_ref'; @@ -34,4 +35,4 @@ export * from './core_private_export'; export * from './animation/metadata'; export {AnimationTransitionEvent} from './animation/animation_transition_event'; export {AnimationPlayer} from './animation/animation_player'; -export {Sanitizer, SecurityContext} from './security'; +export {Sanitizer, SecurityContext} from './security'; \ No newline at end of file diff --git a/modules/@angular/core/src/version.ts b/modules/@angular/core/src/version.ts new file mode 100644 index 0000000000..aaa70b0d84 --- /dev/null +++ b/modules/@angular/core/src/version.ts @@ -0,0 +1,22 @@ +/** + * @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 + */ + +/** + * @whatItDoes Represents the version of Angular + * + * @stable + */ +export class Version { + constructor(public full: string) {} + + get major(): string { return this.full.split('.')[0]; } + + get minor(): string { return this.full.split('.')[1]; } + + get patch(): string { return this.full.split('.')[2]; } +} \ No newline at end of file diff --git a/modules/@angular/forms/index.ts b/modules/@angular/forms/index.ts index 31f3a88598..17b6f31618 100644 --- a/modules/@angular/forms/index.ts +++ b/modules/@angular/forms/index.ts @@ -11,6 +11,11 @@ * @description * Entry point for all public APIs of the forms package. */ +import {Version} from '@angular/core'; +/** + * @stable + */ +export const VERSION = new Version('0.0.0-PLACEHOLDER'); export * from './src/forms'; // This file only reexports content of the `src` folder. Keep it that way. diff --git a/modules/@angular/http/index.ts b/modules/@angular/http/index.ts index 80106781e7..99b254e2d5 100644 --- a/modules/@angular/http/index.ts +++ b/modules/@angular/http/index.ts @@ -11,6 +11,11 @@ * @description * Entry point for all public APIs of the http package. */ +import {Version} from '@angular/core'; +/** + * @stable + */ +export const VERSION = new Version('0.0.0-PLACEHOLDER'); export * from './src/index'; // This file only reexports content of the `src` folder. Keep it that way. diff --git a/modules/@angular/language-service/index.ts b/modules/@angular/language-service/index.ts index 100d4e13e6..6c39696653 100644 --- a/modules/@angular/language-service/index.ts +++ b/modules/@angular/language-service/index.ts @@ -11,10 +11,15 @@ * @description * Entry point for all public APIs of the language service package. */ +import {Version} from '@angular/core'; import * as ts from 'typescript'; import {LanguageServicePlugin} from './src/ts_plugin'; +/** + * @stable + */ +export const VERSION = new Version('0.0.0-PLACEHOLDER'); export {createLanguageService} from './src/language_service'; export {Completion, Completions, Declaration, Declarations, Definition, Diagnostic, Diagnostics, Hover, HoverTextSection, LanguageService, LanguageServiceHost, Location, Span, TemplateSource, TemplateSources} from './src/types'; export {TypeScriptServiceHost, createLanguageServiceFromTypescript} from './src/typescript_host'; diff --git a/modules/@angular/platform-browser-dynamic/index.ts b/modules/@angular/platform-browser-dynamic/index.ts index ced57d28bf..d98ab68d57 100644 --- a/modules/@angular/platform-browser-dynamic/index.ts +++ b/modules/@angular/platform-browser-dynamic/index.ts @@ -11,6 +11,11 @@ * @description * Entry point for all public APIs of the platform-browser-dynamic package. */ +import {Version} from '@angular/core'; +/** + * @stable + */ +export const VERSION = new Version('0.0.0-PLACEHOLDER'); export * from './src/platform-browser-dynamic'; // This file only reexports content of the `src` folder. Keep it that way. diff --git a/modules/@angular/platform-browser/index.ts b/modules/@angular/platform-browser/index.ts index 216edd7af6..ca306a4c22 100644 --- a/modules/@angular/platform-browser/index.ts +++ b/modules/@angular/platform-browser/index.ts @@ -11,6 +11,10 @@ * @description * Entry point for all public APIs of the platform-browser package. */ +import {Version} from '@angular/core'; +/** + * @stable + */ +export const VERSION = new Version('0.0.0-PLACEHOLDER'); export * from './src/platform-browser'; - // This file only reexports content of the `src` folder. Keep it that way. diff --git a/modules/@angular/platform-browser/src/browser.ts b/modules/@angular/platform-browser/src/browser.ts index acc086c79c..518563f2f1 100644 --- a/modules/@angular/platform-browser/src/browser.ts +++ b/modules/@angular/platform-browser/src/browser.ts @@ -7,7 +7,7 @@ */ import {CommonModule, PlatformLocation} from '@angular/common'; -import {ApplicationModule, ErrorHandler, NgModule, Optional, PLATFORM_INITIALIZER, PlatformRef, Provider, RootRenderer, Sanitizer, SkipSelf, Testability, createPlatformFactory, platformCore} from '@angular/core'; +import {ApplicationModule, ErrorHandler, NgModule, Optional, PLATFORM_INITIALIZER, PlatformRef, Provider, RootRenderer, Sanitizer, SkipSelf, Testability, VERSION, createPlatformFactory, platformCore} from '@angular/core'; import {AnimationDriver} from '../src/dom/animation_driver'; import {WebAnimationsDriver} from '../src/dom/web_animations_driver'; @@ -29,6 +29,7 @@ import {DomSanitizer, DomSanitizerImpl} from './security/dom_sanitization_servic export const INTERNAL_BROWSER_PLATFORM_PROVIDERS: Provider[] = [ {provide: PLATFORM_INITIALIZER, useValue: initDomAdapter, multi: true}, + {provide: PLATFORM_INITIALIZER, useValue: recordAngularVersion, multi: true}, {provide: PlatformLocation, useClass: BrowserPlatformLocation} ]; @@ -54,6 +55,14 @@ export function initDomAdapter() { BrowserGetTestability.init(); } +export function recordAngularVersion(): void { + const domAdapter = getDOM(); + const body = domAdapter.getElementsByTagName(domAdapter.defaultDoc(), 'body'); + if (body.length > 0) { + domAdapter.setAttribute(body[0], 'ng-version', VERSION.full); + } +} + export function errorHandler(): ErrorHandler { return new ErrorHandler(); } diff --git a/modules/@angular/platform-browser/src/platform-browser.ts b/modules/@angular/platform-browser/src/platform-browser.ts index 047f01be6b..df5fd4aa2c 100644 --- a/modules/@angular/platform-browser/src/platform-browser.ts +++ b/modules/@angular/platform-browser/src/platform-browser.ts @@ -16,5 +16,4 @@ export {DOCUMENT} from './dom/dom_tokens'; export {EVENT_MANAGER_PLUGINS, EventManager} from './dom/events/event_manager'; export {HAMMER_GESTURE_CONFIG, HammerGestureConfig} from './dom/events/hammer_gestures'; export {DomSanitizer, SafeHtml, SafeResourceUrl, SafeScript, SafeStyle, SafeUrl} from './security/dom_sanitization_service'; - -export * from './private_export'; +export * from './private_export'; \ No newline at end of file diff --git a/modules/@angular/platform-server/index.ts b/modules/@angular/platform-server/index.ts index 405b49a6b5..07e562c628 100644 --- a/modules/@angular/platform-server/index.ts +++ b/modules/@angular/platform-server/index.ts @@ -11,6 +11,12 @@ * @description * Entry point for all public APIs of the platform-server package. */ +import {Version} from '@angular/core'; + +/** + * @stable + */ +export const VERSION = new Version('0.0.0-PLACEHOLDER'); export * from './src/platform-server'; // This file only reexports content of the `src` folder. Keep it that way. diff --git a/modules/@angular/platform-webworker-dynamic/index.ts b/modules/@angular/platform-webworker-dynamic/index.ts index d470e489e3..feb074be1c 100644 --- a/modules/@angular/platform-webworker-dynamic/index.ts +++ b/modules/@angular/platform-webworker-dynamic/index.ts @@ -11,6 +11,11 @@ * @description * Entry point for all public APIs of the platform-browser-dynamic package. */ +import {Version} from '@angular/core'; +/** + * @stable + */ +export const VERSION = new Version('0.0.0-PLACEHOLDER'); export * from './src/platform-webworker-dynamic'; // This file only reexports content of the `src` folder. Keep it that way. diff --git a/modules/@angular/platform-webworker/index.ts b/modules/@angular/platform-webworker/index.ts index 398b8da2bd..01c1060b5d 100644 --- a/modules/@angular/platform-webworker/index.ts +++ b/modules/@angular/platform-webworker/index.ts @@ -11,6 +11,11 @@ * @description * Entry point for all public APIs of the platform-webworker package. */ +import {Version} from '@angular/core'; +/** + * @stable + */ +export const VERSION = new Version('0.0.0-PLACEHOLDER'); export * from './src/platform-webworker'; // This file only reexports content of the `src` folder. Keep it that way. diff --git a/modules/@angular/router/index.ts b/modules/@angular/router/index.ts index ca4239ecf2..6764430ba6 100644 --- a/modules/@angular/router/index.ts +++ b/modules/@angular/router/index.ts @@ -11,6 +11,11 @@ * @description * Entry point for all public APIs of the router package. */ +import {Version} from '@angular/core'; +/** + * @stable + */ +export const VERSION = new Version('0.0.0-ROUTERPLACEHOLDER'); export * from './src/index'; // This file only reexports content of the `src` folder. Keep it that way. diff --git a/modules/@angular/upgrade/index.ts b/modules/@angular/upgrade/index.ts index f051a03df0..fbee42bc66 100644 --- a/modules/@angular/upgrade/index.ts +++ b/modules/@angular/upgrade/index.ts @@ -11,5 +11,10 @@ * @description * Entry point for all public APIs of the upgrade package. */ +import {Version} from '@angular/core'; +/** + * @stable + */ +export const VERSION = new Version('0.0.0-PLACEHOLDER'); export * from './src/upgrade'; // This file only reexports content of the `src` folder. Keep it that way. diff --git a/publish-packages.sh b/publish-packages.sh index aee774e3e9..3c058de443 100755 --- a/publish-packages.sh +++ b/publish-packages.sh @@ -17,6 +17,8 @@ fi echo "====== RENAMING 0.0.0-PLACEHOLDER to 2.0.0-rc.${VERSION} ======" find ./dist/packages-dist/ -type f -name package.json -print0 | xargs -0 sed -i '' "s/0\\.0\\.0-PLACEHOLDER/2.0.0-rc.${VERSION}/g" find ./dist/packages-dist/ -type f -name "*umd.js" -print0 | xargs -0 sed -i '' "s/0\\.0\\.0-PLACEHOLDER/2.0.0-rc.${VERSION}/g" +find ./dist/packages-dist/ -type f -name index.js -print0 | xargs -0 sed -i '' "s/0\\.0\\.0-PLACEHOLDER/2.0.0-rc.${VERSION}/g" + for PACKAGE in \ core \ diff --git a/tools/public_api_guard/common/index.d.ts b/tools/public_api_guard/common/index.d.ts index 8c22cce3cf..b6d34bd589 100644 --- a/tools/public_api_guard/common/index.d.ts +++ b/tools/public_api_guard/common/index.d.ts @@ -227,3 +227,6 @@ export declare class SlicePipe implements PipeTransform { export declare class UpperCasePipe implements PipeTransform { transform(value: string): string; } + +/** @stable */ +export declare const VERSION: Version; diff --git a/tools/public_api_guard/core/index.d.ts b/tools/public_api_guard/core/index.d.ts index 432b6f62e3..b1d8260ebb 100644 --- a/tools/public_api_guard/core/index.d.ts +++ b/tools/public_api_guard/core/index.d.ts @@ -949,6 +949,18 @@ export interface ValueProvider { useValue: any; } +/** @stable */ +export declare class Version { + full: string; + major: string; + minor: string; + patch: string; + constructor(full: string); +} + +/** @stable */ +export declare const VERSION: Version; + /** @stable */ export declare const ViewChild: ViewChildDecorator; diff --git a/tools/public_api_guard/forms/index.d.ts b/tools/public_api_guard/forms/index.d.ts index 28a6536ffa..f76e1b57f8 100644 --- a/tools/public_api_guard/forms/index.d.ts +++ b/tools/public_api_guard/forms/index.d.ts @@ -532,3 +532,6 @@ export declare class Validators { [key: string]: boolean; }; } + +/** @stable */ +export declare const VERSION: Version; diff --git a/tools/public_api_guard/http/index.d.ts b/tools/public_api_guard/http/index.d.ts index 568a34d9c8..8534db90f5 100644 --- a/tools/public_api_guard/http/index.d.ts +++ b/tools/public_api_guard/http/index.d.ts @@ -227,6 +227,9 @@ export declare class URLSearchParams { toString(): string; } +/** @stable */ +export declare const VERSION: Version; + /** @experimental */ export declare class XHRBackend implements ConnectionBackend { constructor(_browserXHR: BrowserXhr, _baseResponseOptions: ResponseOptions, _xsrfStrategy: XSRFStrategy); diff --git a/tools/public_api_guard/platform-browser-dynamic/index.d.ts b/tools/public_api_guard/platform-browser-dynamic/index.d.ts index bf6549b552..e3764d15eb 100644 --- a/tools/public_api_guard/platform-browser-dynamic/index.d.ts +++ b/tools/public_api_guard/platform-browser-dynamic/index.d.ts @@ -3,3 +3,6 @@ export declare const platformBrowserDynamic: (extraProviders?: Provider[]) => Pl /** @experimental */ export declare const RESOURCE_CACHE_PROVIDER: Provider[]; + +/** @stable */ +export declare const VERSION: Version; diff --git a/tools/public_api_guard/platform-browser/index.d.ts b/tools/public_api_guard/platform-browser/index.d.ts index e2557aa4a5..fde5572326 100644 --- a/tools/public_api_guard/platform-browser/index.d.ts +++ b/tools/public_api_guard/platform-browser/index.d.ts @@ -93,3 +93,6 @@ export declare class Title { getTitle(): string; setTitle(newTitle: string): void; } + +/** @stable */ +export declare const VERSION: Version; diff --git a/tools/public_api_guard/platform-server/index.d.ts b/tools/public_api_guard/platform-server/index.d.ts index 1004136d28..525f763bef 100644 --- a/tools/public_api_guard/platform-server/index.d.ts +++ b/tools/public_api_guard/platform-server/index.d.ts @@ -7,3 +7,6 @@ export declare const platformServer: (extraProviders?: Provider[]) => PlatformRe /** @experimental */ export declare class ServerModule { } + +/** @stable */ +export declare const VERSION: Version; diff --git a/tools/public_api_guard/platform-webworker-dynamic/index.d.ts b/tools/public_api_guard/platform-webworker-dynamic/index.d.ts index 5f68576982..1d56465f7c 100644 --- a/tools/public_api_guard/platform-webworker-dynamic/index.d.ts +++ b/tools/public_api_guard/platform-webworker-dynamic/index.d.ts @@ -1,2 +1,5 @@ /** @experimental */ export declare const platformWorkerAppDynamic: (extraProviders?: Provider[]) => PlatformRef; + +/** @stable */ +export declare const VERSION: Version; diff --git a/tools/public_api_guard/platform-webworker/index.d.ts b/tools/public_api_guard/platform-webworker/index.d.ts index 78c75656d1..a9e14b64cc 100644 --- a/tools/public_api_guard/platform-webworker/index.d.ts +++ b/tools/public_api_guard/platform-webworker/index.d.ts @@ -77,6 +77,9 @@ export declare class UiArguments { constructor(method: string, args?: FnArg[]); } +/** @stable */ +export declare const VERSION: Version; + /** @experimental */ export declare const WORKER_APP_LOCATION_PROVIDERS: ({ provide: typeof PlatformLocation; diff --git a/tools/public_api_guard/router/index.d.ts b/tools/public_api_guard/router/index.d.ts index 88d558710c..34c7c24333 100644 --- a/tools/public_api_guard/router/index.d.ts +++ b/tools/public_api_guard/router/index.d.ts @@ -413,3 +413,6 @@ export declare class UrlTree { root: UrlSegmentGroup; toString(): string; } + +/** @stable */ +export declare const VERSION: Version; diff --git a/tools/public_api_guard/upgrade/index.d.ts b/tools/public_api_guard/upgrade/index.d.ts index 33ef4ab993..4834e0e667 100644 --- a/tools/public_api_guard/upgrade/index.d.ts +++ b/tools/public_api_guard/upgrade/index.d.ts @@ -19,3 +19,6 @@ export declare class UpgradeAdapterRef { dispose(): void; ready(fn: (upgradeAdapterRef?: UpgradeAdapterRef) => void): void; } + +/** @stable */ +export declare const VERSION: Version;