Skip to content

Commit 69dbbf2

Browse files
author
Matt Mazzola
committed
Add config file with version an type as custom headers for hpm. Add gulp task to auto update based on packge version.
1 parent 236f487 commit 69dbbf2

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎gulpfile.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ gulp.task('lint', 'Lints all files', function (done) {
3838

3939
gulp.task('test', 'Runs all tests', function (done) {
4040
runSequence(
41+
'config',
4142
'compile:spec',
4243
'test:js',
4344
done
@@ -48,13 +49,20 @@ gulp.task('build', 'Runs a full build', function (done) {
4849
runSequence(
4950
'lint',
5051
'clean',
52+
'config',
5153
['compile:ts', 'compile:dts'],
5254
'min:js',
5355
'header',
5456
done
5557
);
5658
});
5759

60+
gulp.task('config', 'Update config version with package version', function () {
61+
return gulp.src(['./src/config.ts'], {base: "./"})
62+
.pipe(replace(/version: '([^']+)'/, `version: '${package.version}'`))
63+
.pipe(gulp.dest('.'));
64+
});
65+
5866
gulp.task('header', 'Add header to distributed files', function () {
5967
return gulp.src(['./dist/*.d.ts'])
6068
.pipe(header(gulpBanner))

‎src/config.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const config = {
2+
version: '2.0.0-beta.6',
3+
type: 'js'
4+
};
5+
6+
export default config;

‎src/factories.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* TODO: Need to find better place for these factory functions or refactor how we handle dependency injection
33
*/
44
import { IHpmFactory, IWpmpFactory, IRouterFactory } from './service';
5+
import config from './config';
56
import * as wpmp from 'window-post-message-proxy';
67
import * as hpm from 'http-post-message';
78
import * as router from 'powerbi-router';
@@ -15,9 +16,8 @@ export {
1516
/**
1617
* TODO: Need to get sdk version and settings from package.json, Generate config file via gulp task?
1718
*/
18-
export const hpmFactory: IHpmFactory = (wpmp, defaultTargetWindow, sdkVersion = '2.0.0', sdkType = 'js', origin = 'sdk') => {
19+
export const hpmFactory: IHpmFactory = (wpmp, defaultTargetWindow, sdkVersion = config.version, sdkType = config.type) => {
1920
return new hpm.HttpPostMessage(wpmp, {
20-
'origin': origin,
2121
'x-sdk-type': sdkType,
2222
'x-sdk-version': sdkVersion
2323
}, defaultTargetWindow);

0 commit comments

Comments
 (0)