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

feat: expose version object in releases #4962

Merged
merged 1 commit into from
Jul 27, 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
4 changes: 1 addition & 3 deletions src/cdk/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@
* found in the LICENSE file at https://angular.io/license
*/


// TODO(jelbourn): add version here
export const __TMP__ = 0;
export * from './version';
12 changes: 12 additions & 0 deletions src/cdk/version.ts
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');
1 change: 1 addition & 0 deletions src/lib/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Entry point for all public APIs of Angular Material.
*/

export * from './version';
export * from './core';
export * from './module';

Expand Down
12 changes: 12 additions & 0 deletions src/lib/version.ts
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');
4 changes: 2 additions & 2 deletions tools/package-tools/build-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {join} from 'path';
import {mkdirpSync} from 'fs-extra';
import {copyFiles} from './copy-files';
import {addPureAnnotationsToFile} from './pure-annotations';
import {updatePackageVersion} from './package-versions';
import {replaceVersionPlaceholders} from './version-placeholders';
import {inlinePackageMetadataFiles} from './metadata-inlining';
import {createTypingsReexportFile} from './typings-reexport';
import {createMetadataReexportFile} from './metadata-reexport';
Expand Down Expand Up @@ -36,7 +36,7 @@ export function composeRelease(packageName: string, options: ComposeReleaseOptio
copyFiles(packagesDir, 'README.md', releasePath);
copyFiles(sourcePath, 'package.json', releasePath);

updatePackageVersion(releasePath);
replaceVersionPlaceholders(releasePath);
createTypingsReexportFile(releasePath, './typings/index', packageName);
createMetadataReexportFile(releasePath, './typings/index', packageName);

Expand Down
17 changes: 0 additions & 17 deletions tools/package-tools/package-versions.ts

This file was deleted.

32 changes: 32 additions & 0 deletions tools/package-tools/version-placeholders.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {readFileSync, writeFileSync} from 'fs';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this code exist twice?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. Looks like the old one before the build changes is still there after rebasing.

Copy link
Member Author

@devversion devversion Jul 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (removed it)

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this writeFileSync need 'utf-8'?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

writeFileSync always defaults to UTF-8 as encoding (reference)

});
}