diff --git a/.gitignore b/.gitignore index 4c2c6ce8a0..16b1dbfdac 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ closed-lib # Node dependencies node_modules +# Build documentation +docs diff --git a/Procfile b/Procfile new file mode 100644 index 0000000000..aa6094edfe --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: node app.js --port $PORT --include example/localstorage \ No newline at end of file diff --git a/build-docs.sh b/build-docs.sh new file mode 100755 index 0000000000..dd62c5ec41 --- /dev/null +++ b/build-docs.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +#***************************************************************************** +#* 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. +#***************************************************************************** + +# Script to build and deploy docs to github pages. + +OUTPUT_DIRECTORY="docs" +REPOSITORY_URL="git@github.com:nasa/openmctweb.git" + +BUILD_SHA=`git rev-parse head` + +# A remote will be created for the git repository we are pushing to. +# Don't worry, as this entire directory will get trashed inbetween builds. +REMOTE_NAME="documentation" +WEBSITE_BRANCH="gh-pages" + +# Clean output directory, JSDOC will recreate +if [ -d $OUTPUT_DIRECTORY ]; then + rm -rf $OUTPUT_DIRECTORY || exit 1 +fi + +npm run-script jsdoc +cd $OUTPUT_DIRECTORY || exit 1 + +echo "git init" +git init + +# Configure github for CircleCI user. +git config user.email "buildbot@circleci.com" +git config user.name "BuildBot" + +echo "git remote add $REMOTE_NAME $REPOSITORY_URL" +git remote add $REMOTE_NAME $REPOSITORY_URL +echo "git add ." +git add . +echo "git commit -m \"Generate docs from build $BUILD_SHA\"" +git commit -m "Generate docs from build $BUILD_SHA" + +echo "git push $REMOTE_NAME HEAD:$WEBSITE_BRANCH -f" +git push $REMOTE_NAME HEAD:$WEBSITE_BRANCH -f + +echo "Documentation pushed to gh-pages branch." diff --git a/bundles.json b/bundles.json index f69e127eec..0b97f1abab 100644 --- a/bundles.json +++ b/bundles.json @@ -20,6 +20,7 @@ "platform/forms", "platform/persistence/queue", "platform/policy", + "platform/entanglement", "example/imagery", "example/persistence", diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000000..b8f367a604 --- /dev/null +++ b/circle.yml @@ -0,0 +1,6 @@ +deployment: + production: + branch: master + commands: + - ./build-docs.sh + - git push git@heroku.com:openmctweb-demo.git $CIRCLE_SHA1:refs/heads/master diff --git a/example/localstorage/bundle.json b/example/localstorage/bundle.json new file mode 100644 index 0000000000..b164f9aaa9 --- /dev/null +++ b/example/localstorage/bundle.json @@ -0,0 +1,18 @@ +{ + "extensions": { + "components": [ + { + "provides": "persistenceService", + "type": "provider", + "implementation": "LocalStoragePersistenceProvider.js", + "depends": [ "$q", "PERSISTENCE_SPACE" ] + } + ], + "constants": [ + { + "key": "PERSISTENCE_SPACE", + "value": "mct" + } + ] + } +} \ No newline at end of file diff --git a/example/localstorage/src/LocalStoragePersistenceProvider.js b/example/localstorage/src/LocalStoragePersistenceProvider.js new file mode 100644 index 0000000000..8a367ca333 --- /dev/null +++ b/example/localstorage/src/LocalStoragePersistenceProvider.js @@ -0,0 +1,86 @@ +/***************************************************************************** + * 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 define,localStorage*/ +/** + * Stubbed implementation of a persistence provider, + * to permit objects to be created, saved, etc. + */ +define( + [], + function () { + 'use strict'; + + function BrowserPersistenceProvider($q, SPACE) { + var spaces = SPACE ? [SPACE] : [], + promises = { + as: function (value) { + return $q.when(value); + } + }, + provider; + + function setValue(key, value) { + localStorage[key] = JSON.stringify(value); + } + + function getValue(key) { + if (localStorage[key]) { + return JSON.parse(localStorage[key]); + } + return {}; + } + + provider = { + listSpaces: function () { + return promises.as(spaces); + }, + listObjects: function (space) { + var space_obj = getValue(space); + return promises.as(Object.keys(space_obj)); + }, + createObject: function (space, key, value) { + var space_obj = getValue(space); + space_obj[key] = value; + setValue(space, space_obj); + return promises.as(true); + }, + readObject: function (space, key) { + var space_obj = getValue(space); + return promises.as(space_obj[key]); + }, + deleteObject: function (space, key, value) { + var space_obj = getValue(space); + delete space_obj[key]; + return promises.as(true); + } + }; + + provider.updateObject = provider.createObject; + + return provider; + + } + + return BrowserPersistenceProvider; + } +); diff --git a/jsdoc.json b/jsdoc.json new file mode 100644 index 0000000000..ed0fddcf31 --- /dev/null +++ b/jsdoc.json @@ -0,0 +1,10 @@ +{ + "source": { + "include": [ + "example/", + "platform/" + ], + "includePattern": "(example|platform)/.+\\.js$", + "excludePattern": ".+\\Spec\\.js$|lib/.+" + } +} \ No newline at end of file diff --git a/karma.conf.js b/karma.conf.js new file mode 100644 index 0000000000..47aa3f059b --- /dev/null +++ b/karma.conf.js @@ -0,0 +1,79 @@ +/***************************************************************************** + * 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 module*/ +module.exports = function(config) { + config.set({ + + // Base path that will be used to resolve all file patterns. + basePath: '', + + // Frameworks to use + // Available frameworks: https://npmjs.org/browse/keyword/karma-adapter + frameworks: ['jasmine', 'requirejs'], + + // List of files / patterns to load in the browser. + // By default, files are also included in a script tag. + files: [ + '**/moment*', + {pattern: 'example/**/*.js', included: false}, + {pattern: 'platform/**/*.js', included: false}, + {pattern: 'warp/**/*.js', included: false}, + 'test-main.js' + ], + + // List of files to exclude. + exclude: [ + 'platform/framework/src/Main.js' + ], + + // Preprocess matching files before serving them to the browser. + // https://npmjs.org/browse/keyword/karma-preprocessor + preprocessors: {}, + + // Test results reporter to use + // Possible values: 'dots', 'progress' + // Available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ['progress'], + + // Web server port. + port: 9876, + + // Wnable / disable colors in the output (reporters and logs). + colors: true, + + logLevel: config.LOG_INFO, + + // Rerun tests when any file changes. + autoWatch: true, + + // Specify browsers to run tests in. + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + browsers: [ + 'Chrome' + ], + + // Continuous Integration mode. + // If true, Karma captures browsers, runs the tests and exits. + singleRun: false + }); +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000000..1216935f21 --- /dev/null +++ b/package.json @@ -0,0 +1,33 @@ +{ + "name": "open-mct-web", + "version": "0.7.2", + "description": "The OpenMCTWeb core platform", + "dependencies": { + "express": "^4.13.1", + "minimist": "^1.1.1" + }, + "devDependencies": { + "jasmine-core": "^2.3.0", + "jsdoc": "^3.3.2", + "jshint": "^2.7.0", + "karma": "^0.12.31", + "karma-chrome-launcher": "^0.1.8", + "karma-cli": "0.0.4", + "karma-jasmine": "^0.1.5", + "karma-phantomjs-launcher": "^0.1.4", + "karma-requirejs": "^0.2.2", + "requirejs": "^2.1.17" + }, + "scripts": { + "start": "node app.js", + "test": "karma start --single-run", + "jshint": "jshint platform example || exit 0", + "jsdoc": "jsdoc -c jsdoc.json -r -d docs" + }, + "repository": { + "type": "git", + "url": "https://github.com/nasa/openmctweb.git" + }, + "author": "", + "license": "Apache-2.0" +} diff --git a/platform/core/src/objects/DomainObject.js b/platform/core/src/objects/DomainObject.js index 7bc31666de..e3a10160a5 100644 --- a/platform/core/src/objects/DomainObject.js +++ b/platform/core/src/objects/DomainObject.js @@ -35,7 +35,7 @@ define( * * @param {string} id the object's unique identifier * @param {object} model the "JSONifiable" state of the object - * @param {Object.|function} capabilities all * capabilities to be exposed by this object * @constructor */ diff --git a/platform/framework/src/resolve/BundleResolver.js b/platform/framework/src/resolve/BundleResolver.js index d26ee60271..5c8216da94 100644 --- a/platform/framework/src/resolve/BundleResolver.js +++ b/platform/framework/src/resolve/BundleResolver.js @@ -45,7 +45,7 @@ define( * into one large object containing resolved extensions from * all bundles (in the same form.) * - * @param {Object.[]} resolvedBundles + * @param {Object.|Array} resolvedBundles * @returns {Object.} */ function mergeResolvedBundles(resolvedBundles) { diff --git a/test-main.js b/test-main.js new file mode 100644 index 0000000000..46740a93b2 --- /dev/null +++ b/test-main.js @@ -0,0 +1,55 @@ +/***************************************************************************** + * 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,window*/ +var allTestFiles = []; +var TEST_REGEXP = /(Spec)\.js$/; + +var pathToModule = function(path) { + return path.replace(/^\/base\//, '').replace(/\.js$/, ''); +}; + +Object.keys(window.__karma__.files).forEach(function(file) { + if (TEST_REGEXP.test(file)) { + // Normalize paths to RequireJS module names. + allTestFiles.push(pathToModule(file)); + } +}); + +// Force es6-promise to load. +allTestFiles.unshift('es6-promise'); + +require.config({ + // Karma serves files from the basePath defined in karma.conf.js + baseUrl: '/base', + + paths: { + 'es6-promise': 'platform/framework/lib/es6-promise-2.0.0.min', + 'moment-duration-format': 'warp/clock/lib/moment-duration-format' + }, + + // dynamically load all test files + deps: allTestFiles, + + // we have to kickoff jasmine, as it is asynchronous + callback: window.__karma__.start +});