Skip to content

Commit 60ea218

Browse files
devversionjelbourn
authored andcommitted
build: use version placeholder in packages (#4065)
* Introduces a version placeholder (as in angular/angular) that will be replaced with the version string form the root `package.json` file. * This ensures that the different packages are always having the correct version and it also ensures that there is no version-mismatch.
1 parent abd2ac6 commit 60ea218

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular/material",
3-
"version": "2.0.0-beta.3",
3+
"version": "0.0.0-PLACEHOLDER",
44
"description": "Angular Material",
55
"main": "./bundles/material.umd.js",
66
"module": "./@angular/material.es5.js",

src/material-examples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular/material-examples",
3-
"version": "2.0.0-beta.3",
3+
"version": "0.0.0-PLACEHOLDER",
44
"description": "Angular Material Examples",
55
"main": "./bundles/material-examples.umd.js",
66
"module": "./@angular/material-examples.es5.js",

tools/gulp/util/package-build.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {join, basename, dirname} from 'path';
2-
import {DIST_BUNDLES, DIST_ROOT, SOURCE_ROOT, PROJECT_ROOT, LICENSE_BANNER} from '../constants';
32
import {createRollupBundle} from './rollup-helper';
43
import {inlineMetadataResources} from './inline-resources';
54
import {transpileFile} from './ts-compiler';
@@ -8,6 +7,9 @@ import {sync as glob} from 'glob';
87
import {
98
writeFileSync, copySync, mkdirpSync, readFileSync
109
} from 'fs-extra';
10+
import {
11+
DIST_BUNDLES, DIST_ROOT, SOURCE_ROOT, PROJECT_ROOT, LICENSE_BANNER, MATERIAL_VERSION
12+
} from '../constants';
1113

1214
// There are no type definitions available for these imports.
1315
const uglify = require('uglify-js');
@@ -32,6 +34,7 @@ export function composeRelease(packageName: string) {
3234
copyFiles(SOURCE_ROOT, 'README', releasePath);
3335
copyFiles(sourcePath, 'package.json', releasePath);
3436

37+
updatePackageVersion(releasePath);
3538
createTypingFile(releasePath, packageName);
3639
createMetadataFile(releasePath, packageName);
3740
}
@@ -81,6 +84,17 @@ function copyFiles(fromPath: string, fileGlob: string, outDir: string) {
8184
});
8285
}
8386

87+
/** Updates the `package.json` file of the specified package. Replaces the version placeholder. */
88+
function updatePackageVersion(packageDir: string) {
89+
let packagePath = join(packageDir, 'package.json');
90+
let packageConfig = require(packagePath);
91+
92+
// Replace the `0.0.0-PLACEHOLDER` version name with the version of the root package.json file.
93+
packageConfig.version = packageConfig.version.replace('0.0.0-PLACEHOLDER', MATERIAL_VERSION);
94+
95+
writeFileSync(packagePath, JSON.stringify(packageConfig, null, 2));
96+
}
97+
8498
/** Create a typing file that links to the bundled definitions of NGC. */
8599
function createTypingFile(outputDir: string, entryName: string) {
86100
writeFileSync(join(outputDir, `${entryName}.d.ts`),

0 commit comments

Comments
 (0)