Add version getter to ReDoc runtime

This commit is contained in:
Roman Hotsiy 2016-05-20 20:36:10 +03:00
parent c80f13738f
commit 6f8ea60da7
2 changed files with 15 additions and 2 deletions

View File

@ -73,7 +73,7 @@ gulp.task('concatDeps', function() {
.pipe(gulp.dest('.'))
});
gulp.task('bundle', ['inlineTemplates'], function bundle(cb) {
gulp.task('bundle', ['injectVersionFile', 'inlineTemplates'], function bundle(cb) {
fs.existsSync('dist') || fs.mkdirSync('dist');
var builder = new Builder('./', 'system.config.js');
@ -122,3 +122,9 @@ gulp.task('concatPrism', function() {
.pipe(concat(path.join(paths.tmp, 'prismjs-bundle.js')))
.pipe(gulp.dest('.'))
});
// needs inlineTemplates run before to create .tmp/lib folder
gulp.task('injectVersionFile', ['inlineTemplates'], function() {
var version = require('../../package.json').version;
fs.writeFileSync(path.join(paths.tmp, 'lib/version.json'), JSON.stringify(version));
})

View File

@ -5,6 +5,8 @@ import { bootstrap } from '@angular/platform-browser-dynamic';
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
import { RedocComponent, BaseComponent } from '../base';
import detectScollParent from 'scrollparent';
import { ApiInfo } from '../ApiInfo/api-info';
import { ApiLogo } from '../ApiLogo/api-logo';
import { MethodsList } from '../MethodsList/methods-list';
@ -13,8 +15,9 @@ import { SideMenu } from '../SideMenu/side-menu';
import { StickySidebar } from '../../shared/components/index';
import SchemaManager from '../../utils/SchemaManager';
import { OptionsService, RedocEventsService } from '../../services/index';
import redocVersion from '../../version.json!json';
import detectScollParent from 'scrollparent';
import './redoc-initial-styles.css!css';
var dom = new BrowserDomAdapter();
@ -118,6 +121,10 @@ export class Redoc extends BaseComponent {
redocEl.innerHTML = erroHtml;
}
static get version() {
return redocVersion;
}
static destroy() {
let el = dom.query('redoc');
let elClone;