-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expose version object in releases (#4962)
* In releases there will be a constant called `VERSION` that holds the current version of the installed package (material or cdk) * This is similar as for every @angular package like core, forms, compiler.
- Loading branch information
1 parent
b34b440
commit 3bfe7f0
Showing
7 changed files
with
60 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @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 {Version} from '@angular/core'; | ||
|
||
/** Current version of the Angular Component Development Kit. */ | ||
export const VERSION = new Version('0.0.0-PLACEHOLDER'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @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 {Version} from '@angular/core'; | ||
|
||
/** Current version of Angular Material. */ | ||
export const VERSION = new Version('0.0.0-PLACEHOLDER'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {readFileSync, writeFileSync} from 'fs'; | ||
import {buildConfig} from './build-config'; | ||
import {spawnSync} from 'child_process'; | ||
|
||
/** Variable that is set to the string for version placeholders. */ | ||
const versionPlaceholderText = '0.0.0-PLACEHOLDER'; | ||
|
||
/** RegExp that matches version placeholders inside of a file. */ | ||
const versionPlaceholderRegex = new RegExp(versionPlaceholderText); | ||
|
||
/** | ||
* Walks through every file in a directory and replaces the version placeholders with the current | ||
* version of Material. | ||
*/ | ||
export function replaceVersionPlaceholders(packageDir: string) { | ||
// Resolve files that contain version placeholders using Grep since it's super fast and also | ||
// does have a very simple usage. | ||
const files = spawnSync('grep', ['-ril', versionPlaceholderText, packageDir]).stdout | ||
.toString() | ||
.split('\n') | ||
.filter(String); | ||
|
||
// Walk through every file that contains version placeholders and replace those with the current | ||
// version of the root package.json file. | ||
files.forEach(filePath => { | ||
let fileContent = readFileSync(filePath, 'utf-8'); | ||
|
||
fileContent = fileContent.replace(versionPlaceholderRegex, buildConfig.projectVersion); | ||
|
||
writeFileSync(filePath, fileContent); | ||
}); | ||
} |