mirror of
https://github.com/nasa/openmct.git
synced 2024-12-20 13:43:09 +00:00
[Build] Modify version info injection to fix sourcemaps (#1708)
* [Build] Preserve comments instead of adding header ...to avoid disrupting sourcemaps. Fixes #1707 [Build] Remove extraneous horizontal rule from header [Build] Remove obsolete header-handling ...as this is handled by the replace task after fix for #1707 [Build] Move version headers into start.frag ...so that UMD boilerplate does not wrap it. [Build] Handle version info entirely in start.frag [Build] Replace build variables in start.frag explicitly [Build] Inject build info dynamically [Build] Test MCT.specifyBuildInfo [Build] Mark BUILD_CONSTANTS as global for jshint [Build] Give names to version line items [Build] Fix specifyBuildInfo test case * [Build] Update fix to sourcemaps for code review feedback https://github.com/nasa/openmct/pull/1708 [Build] Move build info registration to plugin https://github.com/nasa/openmct/pull/1708#discussion_r138999027 [Build] Use build info plugin ...instead of specifyBuildInfo [Build] Revert changes to MCT, per code review
This commit is contained in:
parent
e66f818996
commit
a3a55d3b48
28
gulpfile.js
28
gulpfile.js
@ -46,9 +46,22 @@ var gulp = require('gulp'),
|
|||||||
name: 'bower_components/almond/almond.js',
|
name: 'bower_components/almond/almond.js',
|
||||||
include: paths.main.replace('.js', ''),
|
include: paths.main.replace('.js', ''),
|
||||||
wrap: {
|
wrap: {
|
||||||
startFile: "src/start.frag",
|
start: (function () {
|
||||||
|
var buildVariables = {
|
||||||
|
version: project.version,
|
||||||
|
timestamp: moment.utc(Date.now()).format(),
|
||||||
|
revision: fs.existsSync('.git') ? git.long() : 'Unknown',
|
||||||
|
branch: fs.existsSync('.git') ? git.branch() : 'Unknown'
|
||||||
|
};
|
||||||
|
return fs.readFileSync("src/start.frag", 'utf-8')
|
||||||
|
.replace(/@@(\w+)/g, function (match, key) {
|
||||||
|
return buildVariables[key];
|
||||||
|
});;
|
||||||
|
}()),
|
||||||
endFile: "src/end.frag"
|
endFile: "src/end.frag"
|
||||||
},
|
},
|
||||||
|
optimize: 'uglify2',
|
||||||
|
uglify2: { output: { comments: /@preserve/ } },
|
||||||
mainConfigFile: paths.main,
|
mainConfigFile: paths.main,
|
||||||
wrapShim: true
|
wrapShim: true
|
||||||
},
|
},
|
||||||
@ -58,14 +71,6 @@ var gulp = require('gulp'),
|
|||||||
},
|
},
|
||||||
sass: {
|
sass: {
|
||||||
sourceComments: true
|
sourceComments: true
|
||||||
},
|
|
||||||
replace: {
|
|
||||||
variables: {
|
|
||||||
version: project.version,
|
|
||||||
timestamp: moment.utc(Date.now()).format(),
|
|
||||||
revision: fs.existsSync('.git') ? git.long() : 'Unknown',
|
|
||||||
branch: fs.existsSync('.git') ? git.branch() : 'Unknown'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -76,16 +81,11 @@ if (process.env.NODE_ENV === 'development') {
|
|||||||
|
|
||||||
gulp.task('scripts', function () {
|
gulp.task('scripts', function () {
|
||||||
var requirejsOptimize = require('gulp-requirejs-optimize');
|
var requirejsOptimize = require('gulp-requirejs-optimize');
|
||||||
var replace = require('gulp-replace-task');
|
|
||||||
var header = require('gulp-header');
|
|
||||||
var comment = fs.readFileSync('src/about.frag');
|
|
||||||
|
|
||||||
return gulp.src(paths.main)
|
return gulp.src(paths.main)
|
||||||
.pipe(sourcemaps.init())
|
.pipe(sourcemaps.init())
|
||||||
.pipe(requirejsOptimize(options.requirejsOptimize))
|
.pipe(requirejsOptimize(options.requirejsOptimize))
|
||||||
.pipe(sourcemaps.write('.'))
|
.pipe(sourcemaps.write('.'))
|
||||||
.pipe(replace(options.replace))
|
|
||||||
.pipe(header(comment, options.replace.variables))
|
|
||||||
.pipe(gulp.dest(paths.dist));
|
.pipe(gulp.dest(paths.dist));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
11
openmct.js
11
openmct.js
@ -19,7 +19,7 @@
|
|||||||
* this source code distribution or the Licensing information page available
|
* this source code distribution or the Licensing information page available
|
||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
/*global requirejs*/
|
/*global requirejs,BUILD_CONSTANTS*/
|
||||||
|
|
||||||
requirejs.config({
|
requirejs.config({
|
||||||
"paths": {
|
"paths": {
|
||||||
@ -91,12 +91,17 @@ requirejs.config({
|
|||||||
define([
|
define([
|
||||||
'./platform/framework/src/Main',
|
'./platform/framework/src/Main',
|
||||||
'./src/defaultRegistry',
|
'./src/defaultRegistry',
|
||||||
'./src/MCT'
|
'./src/MCT',
|
||||||
], function (Main, defaultRegistry, MCT) {
|
'./src/plugins/buildInfo/plugin'
|
||||||
|
], function (Main, defaultRegistry, MCT, buildInfo) {
|
||||||
var openmct = new MCT();
|
var openmct = new MCT();
|
||||||
|
|
||||||
openmct.legacyRegistry = defaultRegistry;
|
openmct.legacyRegistry = defaultRegistry;
|
||||||
|
|
||||||
|
if (typeof BUILD_CONSTANTS !== 'undefined') {
|
||||||
|
openmct.install(buildInfo(BUILD_CONSTANTS));
|
||||||
|
}
|
||||||
|
|
||||||
openmct.on('start', function () {
|
openmct.on('start', function () {
|
||||||
return new Main().run(defaultRegistry);
|
return new Main().run(defaultRegistry);
|
||||||
});
|
});
|
||||||
|
@ -22,12 +22,10 @@
|
|||||||
"git-rev-sync": "^1.4.0",
|
"git-rev-sync": "^1.4.0",
|
||||||
"glob": ">= 3.0.0",
|
"glob": ">= 3.0.0",
|
||||||
"gulp": "^3.9.1",
|
"gulp": "^3.9.1",
|
||||||
"gulp-header": "^1.8.8",
|
|
||||||
"gulp-jscs": "^3.0.2",
|
"gulp-jscs": "^3.0.2",
|
||||||
"gulp-jshint": "^2.0.0",
|
"gulp-jshint": "^2.0.0",
|
||||||
"gulp-jshint-html-reporter": "^0.1.3",
|
"gulp-jshint-html-reporter": "^0.1.3",
|
||||||
"gulp-rename": "^1.2.2",
|
"gulp-rename": "^1.2.2",
|
||||||
"gulp-replace-task": "^0.11.0",
|
|
||||||
"gulp-requirejs-optimize": "^0.3.1",
|
"gulp-requirejs-optimize": "^0.3.1",
|
||||||
"gulp-sass": "^2.2.0",
|
"gulp-sass": "^2.2.0",
|
||||||
"gulp-sourcemaps": "^1.6.0",
|
"gulp-sourcemaps": "^1.6.0",
|
||||||
|
@ -94,31 +94,6 @@ define([
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"extensions": {
|
"extensions": {
|
||||||
"versions": [
|
|
||||||
{
|
|
||||||
"name": "Version",
|
|
||||||
"value": "@@version",
|
|
||||||
"priority": 999
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Built",
|
|
||||||
"value": "@@timestamp",
|
|
||||||
"description": "The date on which this version of the client was built.",
|
|
||||||
"priority": 990
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Revision",
|
|
||||||
"value": "@@revision",
|
|
||||||
"description": "A unique revision identifier for the client sources.",
|
|
||||||
"priority": 995
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Branch",
|
|
||||||
"value": "@@branch",
|
|
||||||
"description": "The name of the branch that was used during the build.",
|
|
||||||
"priority": 994
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"components": [
|
"components": [
|
||||||
{
|
{
|
||||||
"provides": "objectService",
|
"provides": "objectService",
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
/**
|
|
||||||
* Open MCT https://nasa.github.io/openmct/
|
|
||||||
* Version: ${version}
|
|
||||||
* Built: ${timestamp}
|
|
||||||
* Revision: ${revision}
|
|
||||||
* Branch: ${branch}
|
|
||||||
*/
|
|
45
src/plugins/buildInfo/plugin.js
Normal file
45
src/plugins/buildInfo/plugin.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT Web includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
define([
|
||||||
|
], function (
|
||||||
|
) {
|
||||||
|
return function (buildInfo) {
|
||||||
|
return function (openmct) {
|
||||||
|
var aliases = { timestamp: "Built" };
|
||||||
|
var descriptions = {
|
||||||
|
timestamp: "The date on which this version of Open MCT was built.",
|
||||||
|
revision: "A unique revision identifier for the client sources.",
|
||||||
|
branch: "The name of the branch that was used during the build."
|
||||||
|
};
|
||||||
|
|
||||||
|
Object.keys(buildInfo).forEach(function (key) {
|
||||||
|
openmct.legacyExtension("versions", {
|
||||||
|
key: key,
|
||||||
|
name: aliases[key] || (key.charAt(0).toUpperCase() + key.substring(1)),
|
||||||
|
value: buildInfo[key],
|
||||||
|
description: descriptions[key]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
50
src/plugins/buildInfo/pluginSpec.js
Normal file
50
src/plugins/buildInfo/pluginSpec.js
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2014-2017, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
define([
|
||||||
|
'./plugin'
|
||||||
|
], function (plugin) {
|
||||||
|
describe("The buildInfo plugin", function () {
|
||||||
|
var mockmct;
|
||||||
|
var testInfo;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
mockmct = jasmine.createSpyObj('openmct', ['legacyExtension']);
|
||||||
|
testInfo = { foo: 123, bar: "baz" };
|
||||||
|
plugin(testInfo)(mockmct);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("registers versions extensions", function () {
|
||||||
|
Object.keys(testInfo).forEach(function (key) {
|
||||||
|
expect(mockmct.legacyExtension).toHaveBeenCalledWith(
|
||||||
|
"versions",
|
||||||
|
{
|
||||||
|
key: key,
|
||||||
|
name: jasmine.any(String),
|
||||||
|
value: testInfo[key],
|
||||||
|
description: undefined
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -18,6 +18,14 @@
|
|||||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
* this source code distribution or the Licensing information page available
|
* this source code distribution or the Licensing information page available
|
||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
|
*
|
||||||
|
* Open MCT https://nasa.github.io/openmct/
|
||||||
|
* Version: @@version
|
||||||
|
* Built: @@timestamp
|
||||||
|
* Revision: @@revision
|
||||||
|
* Branch: @@branch
|
||||||
|
*
|
||||||
|
* @preserve
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
@ -29,3 +37,9 @@
|
|||||||
root.openmct = factory();
|
root.openmct = factory();
|
||||||
}
|
}
|
||||||
}(this, function() {
|
}(this, function() {
|
||||||
|
var BUILD_CONSTANTS = {
|
||||||
|
version: "@@version",
|
||||||
|
timestamp: "@@timestamp",
|
||||||
|
revision: "@@revision",
|
||||||
|
branch: "@@branch"
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user