Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: use version placeholder in packages #4065

Merged
merged 1 commit into from
Apr 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@angular/material",
"version": "2.0.0-beta.3",
"version": "0.0.0-PLACEHOLDER",
"description": "Angular Material",
"main": "./bundles/material.umd.js",
"module": "./@angular/material.es5.js",
Expand Down
2 changes: 1 addition & 1 deletion src/material-examples/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@angular/material-examples",
"version": "2.0.0-beta.3",
"version": "0.0.0-PLACEHOLDER",
"description": "Angular Material Examples",
"main": "./bundles/material-examples.umd.js",
"module": "./@angular/material-examples.es5.js",
Expand Down
16 changes: 15 additions & 1 deletion tools/gulp/util/package-build.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {join, basename, dirname} from 'path';
import {DIST_BUNDLES, DIST_ROOT, SOURCE_ROOT, PROJECT_ROOT, LICENSE_BANNER} from '../constants';
import {createRollupBundle} from './rollup-helper';
import {inlineMetadataResources} from './inline-resources';
import {transpileFile} from './ts-compiler';
Expand All @@ -8,6 +7,9 @@ import {sync as glob} from 'glob';
import {
writeFileSync, copySync, mkdirpSync, readFileSync
} from 'fs-extra';
import {
DIST_BUNDLES, DIST_ROOT, SOURCE_ROOT, PROJECT_ROOT, LICENSE_BANNER, MATERIAL_VERSION
} from '../constants';

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

updatePackageVersion(releasePath);
createTypingFile(releasePath, packageName);
createMetadataFile(releasePath, packageName);
}
Expand Down Expand Up @@ -81,6 +84,17 @@ function copyFiles(fromPath: string, fileGlob: string, outDir: string) {
});
}

/** Updates the `package.json` file of the specified package. Replaces the version placeholder. */
function updatePackageVersion(packageDir: string) {
let packagePath = join(packageDir, 'package.json');
let packageConfig = require(packagePath);

// Replace the `0.0.0-PLACEHOLDER` version name with the version of the root package.json file.
packageConfig.version = packageConfig.version.replace('0.0.0-PLACEHOLDER', MATERIAL_VERSION);

writeFileSync(packagePath, JSON.stringify(packageConfig, null, 2));
}

/** Create a typing file that links to the bundled definitions of NGC. */
function createTypingFile(outputDir: string, entryName: string) {
writeFileSync(join(outputDir, `${entryName}.d.ts`),
Expand Down