Compare commits

...

20 Commits

Author SHA1 Message Date
5bc30dbf2a [Build] Make build dependencies non-dev
...to allow usage in a postinstall hook.

This is a pretty good red flag for not using postinstall hooks.
2015-12-23 16:43:42 -08:00
71bd77caf4 [Build] Remove HTML template concatentation 2015-12-23 16:35:04 -08:00
f275177aa6 Update Maven version referenced in developer guide 2015-12-10 14:47:35 -08:00
05908aa877 Add missing build dependency 2015-12-10 14:43:55 -08:00
9b5c62d2d5 Add license headers 2015-12-10 14:22:24 -08:00
297e6b00e1 Exclude target from code style checks 2015-12-10 14:20:10 -08:00
848af50d4e Update specs for mct-form, mct-toolbar
...to reflect explicit declaration of controller
dependencies.
2015-12-10 14:14:41 -08:00
97e93c3104 Update phantomjs maven plugin 2015-12-10 14:08:11 -08:00
731cdb343a Use included templates from Maven build 2015-12-10 14:01:41 -08:00
d9664d4574 Adhere to strict DI for form directives 2015-12-10 13:59:50 -08:00
5a0e949b62 Compile templates into index.html 2015-12-10 13:55:45 -08:00
28a6eabfb6 Include compiled main.js in build 2015-12-10 12:46:23 -08:00
6e43342157 Trigger require build from maven 2015-12-10 12:43:59 -08:00
6ce4c013d7 Fix failing tests 2015-12-10 12:32:36 -08:00
1272fb8509 Add a conventional main.js 2015-12-10 12:24:37 -08:00
e84c88b8c0 Add globby dependency 2015-12-10 12:17:55 -08:00
3a8911e542 Trigger npm from maven build 2015-12-10 12:14:00 -08:00
2a57b83cb0 Make index compatible with built and unbuilt sources 2015-12-10 11:58:33 -08:00
29ecb68b9b Permit minification 2015-12-10 11:38:39 -08:00
5b0af8773b [Optimization] First working requirejs build 2015-12-10 10:37:22 -08:00
15 changed files with 185 additions and 33 deletions

58
build.js Normal file
View File

@ -0,0 +1,58 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global require*/
var requirejs = require("requirejs"),
globby = require("globby"),
fs = require("fs"),
bundles = fs.readFileSync("bundles.json", 'utf8'),
scripts = [],
templates = [],
contents,
index = fs.readFileSync("index.html", 'utf8');
function trimJsExtension(filename) {
return filename.replace(/\.js$/, "");
}
JSON.parse(bundles).forEach(function (bundle) {
scripts = scripts.concat(globby.sync(bundle + "/src/**/*.js"));
});
requirejs.optimize({
baseUrl: ".",
name: "main",
out: "target/main.js",
paths: {
'es6-promise': 'platform/framework/lib/es6-promise-2.0.0.min',
'moment': 'platform/telemetry/lib/moment.min',
'moment-duration-format': 'platform/features/clock/lib/moment-duration-format',
'uuid': 'platform/core/lib/uuid'
},
shim: {
'moment-duration-format': {
deps: [ 'moment' ]
}
},
include: scripts.map(trimJsExtension),
exclude: globby.sync("platform/framework/lib/**/*.js").map(trimJsExtension)
});

View File

@ -2245,7 +2245,7 @@ options. The sources can be deployed in the same directory structure used during
development. A few utilities are included to support development processes.
## Command-line Build
Open MCT Web includes a script for building via command line using Maven 3.0.4
Open MCT Web includes a script for building via command line using Maven 3.3.9
https://maven.apache.org/ .
Invoking mvn clean install will:

View File

@ -27,12 +27,12 @@
<title></title>
<script type="text/javascript"
src="platform/framework/lib/require.js"
data-main="platform/framework/src/Main.js">
data-main="main.js">
</script>
<link rel="icon" type="image/png" href="platform/commonUI/general/res/images/favicons/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="platform/commonUI/general/res/images/favicons/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="platform/commonUI/general/res/images/favicons/favicon-16x16.png" sizes="16x16">
<link rel="shortcut icon" href="platform/commonUI/general/res/images/favicons/favicon.ico">
<link rel="icon" type="image/png" href="platform/commonUI/general/res/images/favicons/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="platform/commonUI/general/res/images/favicons/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="platform/commonUI/general/res/images/favicons/favicon-16x16.png" sizes="16x16">
<link rel="shortcut icon" href="platform/commonUI/general/res/images/favicons/favicon.ico">
</head>
<body class="user-environ" ng-view>

37
main.js Normal file
View File

@ -0,0 +1,37 @@
/*****************************************************************************
* 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.
*****************************************************************************/
/*global require*/
(function (require, options) {
'use strict';
require.config({
shim: {
"platform/framework/lib/angular.min": {
exports: "angular"
},
"platform/framework/lib/angular-route.min": {
deps: ["platform/framework/lib/angular.min"]
}
}
});
require(["platform/framework/src/Main"]);
}(require));

View File

@ -4,6 +4,8 @@
"description": "The OpenMCTWeb core platform",
"dependencies": {
"express": "^4.13.1",
"globby": "^4.0.0",
"requirejs": "^2.1.17",
"minimist": "^1.1.1"
},
"devDependencies": {
@ -16,13 +18,13 @@
"karma-jasmine": "^0.1.5",
"karma-phantomjs-launcher": "^0.1.4",
"karma-requirejs": "^0.2.2",
"requirejs": "^2.1.17",
"marked": "^0.3.5",
"glob": ">= 3.0.0",
"split": "^1.0.0",
"mkdirp": "^0.5.1",
"nomnoml": "^0.0.3",
"canvas": "^1.2.7",
"strip-html-comments": "^1.0.0",
"markdown-toc": "^0.11.7"
},
"scripts": {
@ -32,7 +34,8 @@
"watch": "karma start",
"jsdoc": "jsdoc -c jsdoc.json -r -d target/docs/api",
"otherdoc": "node docs/gendocs.js --in docs/src --out target/docs",
"docs": "npm run jsdoc ; npm run otherdoc"
"docs": "npm run jsdoc ; npm run otherdoc",
"postinstall": "node build.js"
},
"repository": {
"type": "git",

View File

@ -66,7 +66,7 @@ define(
templateUrl: templatePath,
// Use FormController to populate/respond to changes in scope
controller: FormController,
controller: [ "$scope", FormController ],
// Initial an isolate scope
scope: {

View File

@ -64,7 +64,7 @@ define(
templateUrl: templatePath,
// Use FormController to populate/respond to changes in scope
controller: FormController,
controller: [ "$scope", FormController ],
// Initial an isolate scope
scope: {

View File

@ -44,7 +44,7 @@ define(
// mct-form needs to watch for the form by name
// in order to convey changes in $valid, $dirty, etc
// up to the parent scope.
mctForm.controller(mockScope);
mctForm.controller[1](mockScope);
expect(mockScope.$watch).toHaveBeenCalledWith(
"mctForm",
@ -56,7 +56,7 @@ define(
var someState = { someKey: "some value" };
mockScope.name = "someName";
mctForm.controller(mockScope);
mctForm.controller[1](mockScope);
mockScope.$watch.mostRecentCall.args[1](someState);
@ -65,7 +65,7 @@ define(
it("allows strings to be converted to RegExps", function () {
// This is needed to support ng-pattern in the template
mctForm.controller(mockScope);
mctForm.controller[1](mockScope);
// Should have added getRegExp to the scope,
// to convert strings to regular expressions
@ -78,7 +78,7 @@ define(
regExp;
// Add getRegExp to scope
mctForm.controller(mockScope);
mctForm.controller[1](mockScope);
regExp = mockScope.getRegExp(strRegExp);
// Same object instance each time...
@ -91,7 +91,7 @@ define(
var regExp = /^\d+[a-d]$/;
// Add getRegExp to scope
mctForm.controller(mockScope);
mctForm.controller[1](mockScope);
// Should have added getRegExp to the scope,
// to convert strings to regular expressions
@ -100,11 +100,15 @@ define(
it("passes a non-whitespace regexp when no pattern is defined", function () {
// If no pattern is supplied, ng-pattern should match anything
mctForm.controller(mockScope);
mctForm.controller[1](mockScope);
expect(mockScope.getRegExp()).toEqual(/\S/);
expect(mockScope.getRegExp(undefined)).toEqual(/\S/);
});
it("explicitly declares its controller's dependency", function () {
expect(mctForm.controller[0]).toEqual('$scope');
});
});
}

View File

@ -44,7 +44,7 @@ define(
// mct-form needs to watch for the form by name
// in order to convey changes in $valid, $dirty, etc
// up to the parent scope.
mctToolbar.controller(mockScope);
mctToolbar.controller[1](mockScope);
expect(mockScope.$watch).toHaveBeenCalledWith(
"mctForm",
@ -56,7 +56,7 @@ define(
var someState = { someKey: "some value" };
mockScope.name = "someName";
mctToolbar.controller(mockScope);
mctToolbar.controller[1](mockScope);
mockScope.$watch.mostRecentCall.args[1](someState);
@ -65,7 +65,7 @@ define(
it("allows strings to be converted to RegExps", function () {
// This is needed to support ng-pattern in the template
mctToolbar.controller(mockScope);
mctToolbar.controller[1](mockScope);
// Should have added getRegExp to the scope,
// to convert strings to regular expressions
@ -78,7 +78,7 @@ define(
regExp;
// Add getRegExp to scope
mctToolbar.controller(mockScope);
mctToolbar.controller[1](mockScope);
regExp = mockScope.getRegExp(strRegExp);
// Same object instance each time...
@ -91,7 +91,7 @@ define(
var regExp = /^\d+[a-d]$/;
// Add getRegExp to scope
mctToolbar.controller(mockScope);
mctToolbar.controller[1](mockScope);
// Should have added getRegExp to the scope,
// to convert strings to regular expressions
@ -100,11 +100,15 @@ define(
it("passes a non-whitespace regexp when no pattern is defined", function () {
// If no pattern is supplied, ng-pattern should match anything
mctToolbar.controller(mockScope);
mctToolbar.controller[1](mockScope);
expect(mockScope.getRegExp()).toEqual(/\S/);
expect(mockScope.getRegExp(undefined)).toEqual(/\S/);
});
it("explicitly declares its controller's dependency", function () {
expect(mctToolbar.controller[0]).toEqual('$scope');
});
});
}

View File

@ -90,12 +90,12 @@ define(
}
decorate($log);
app.config(function ($provide) {
$provide.decorator('$log', function ($delegate) {
app.config(['$provide', function ($provide) {
$provide.decorator('$log', ['$delegate', function ($delegate) {
decorate($delegate);
return $delegate;
});
});
}]);
}]);
};
return LogLevel;

View File

@ -59,7 +59,7 @@ define(
$log = this.$log;
$log.info("Bootstrapping application " + (app || {}).name);
angular.element(document).ready(function () {
angular.bootstrap(document, [app.name]);
angular.bootstrap(document, [app.name], { strictDi: true });
});
};

View File

@ -56,7 +56,7 @@ define(
ImplementationLoader.prototype.load = function loadModule(path) {
var require = this.require;
return new Promise(function (fulfill, reject) {
require([path], fulfill, reject);
require([path.replace(/\.js$/, "")], fulfill, reject);
});
};

View File

@ -70,12 +70,16 @@ define(
mockDelegate[m].andCallFake(mockMethods[m]);
});
mockApp.config.andCallFake(function (callback) {
mockApp.config.andCallFake(function (arr) {
var callback = arr[1];
expect(arr[0]).toEqual('$provide');
callback(mockProvide);
});
mockProvide.decorator.andCallFake(function (key, callback) {
mockProvide.decorator.andCallFake(function (key, arr) {
// Only $log should be configured in any case
var callback = arr[1];
expect(arr[0]).toEqual('$delegate');
expect(key).toEqual('$log');
callback(mockDelegate);
});

View File

@ -48,7 +48,7 @@ define(
it("passes script names to require", function () {
loader.load("xyz.js");
expect(required.names).toEqual(["xyz.js"]);
expect(required.names).toEqual(["xyz"]);
});
it("wraps require results in a Promise that can resolve", function () {

46
pom.xml
View File

@ -32,7 +32,6 @@
<resource>
<directory>.</directory>
<includes>
<include>index.html</include>
<include>*.json</include>
<include>**/src/**/*</include>
<include>**/res/**/*</include>
@ -54,6 +53,13 @@
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>target</directory>
<includes>
<include>index.html</include>
<include>main.js</include>
</includes>
</resource>
</webResources>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
@ -84,7 +90,7 @@
<plugin>
<groupId>com.github.klieber</groupId>
<artifactId>phantomjs-maven-plugin</artifactId>
<version>0.2.1</version>
<version>0.7</version>
<executions>
<execution>
<goals>
@ -165,6 +171,7 @@
<exclude>app.js</exclude>
<exclude>node_modules/**/*</exclude>
<exclude>protractor/**/*</exclude>
<exclude>target/**/*</exclude>
</excludes>
</configuration>
<executions>
@ -176,6 +183,41 @@
</executions>
</plugin>
<!-- Run NPM build steps -->
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>0.0.26</version>
<configuration>
<installDirectory>target</installDirectory>
<nodeVersion>v0.12.2</nodeVersion>
<npmVersion>2.7.6</npmVersion>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
</execution>
<execution>
<id>requirejs build/minify</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
</plugin>
<!-- To start this WAR in an embedded Tomcat Servlet Container -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>