Skip to content

Commit

Permalink
Create distribution folder for generated assets (#281)
Browse files Browse the repository at this point in the history
* Modify build script to write build artifacts to distribution directory
- Deposit other client consumable assets in the distribution directory
- See #280

* Remove unnecessary escape on file match

* Add clean task

* Simplify task structure

* Fix Artifactory deployment path

* Remove asset publishing directory from clean task

* Add npm clean task

* WebStorm configuration change to ignore distribution folder

* Add test-results folder as a clean target
  • Loading branch information
zglueck authored and pdavidc committed Nov 8, 2017
1 parent a25a426 commit d7f8171
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 25 deletions.
10 changes: 3 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,16 @@

.idea/workspace.xml

api-doc/

assetsToPublish/

images.zip
dist/

nasaworldwind-worldwind-*.tgz

node_modules/

npm-debug.log

standalonedata/

test-results/

worldwind.js

worldwind.min.js
4 changes: 3 additions & 1 deletion .idea/WebWorldWind.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 35 additions & 5 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function (grunt) {
dist: {
src: ['src'],
options: {
destination: 'api-doc',
destination: 'dist/api-doc',
configure: 'config.json',
readme: 'README.md',
recurse: true
Expand All @@ -25,7 +25,7 @@ module.exports = function (grunt) {
baseUrl: 'src',
name: '../tools/almond',
include: ['WorldWind'],
out: 'worldwind.min.js',
out: 'dist/worldwind.min.js',
wrap: {
startFile: 'tools/wrap.start',
endFile: 'tools/wrap.end'
Expand All @@ -38,7 +38,7 @@ module.exports = function (grunt) {
name: '../tools/almond',
include: ['WorldWind'],
optimize: 'none',
out: 'worldwind.js',
out: 'dist/worldwind.js',
wrap: {
startFile: 'tools/wrap.start',
endFile: 'tools/wrap.end'
Expand All @@ -62,22 +62,52 @@ module.exports = function (grunt) {
}
},

clean: [
'dist/',
'test-results/'
],

compress: {
main: {
options: {
archive: 'images.zip'
archive: 'dist/images.zip'
},
files: [
{src: ['images/**']}
]
}
},

copy: {
main: {
files: [
// Copy all of the files in the examples folder except the current shim which uses the sources files
{
expand: true,
src: ['images/**', 'examples/**', '!examples/WorldWindShim.js', 'README.md', 'LICENSE.txt'],
dest: 'dist/'
},
// Copy and rename the deployment WorldWindShim which uses the minified library
{
expand: true,
cwd: 'tools',
src: ['WorldWindShim.build.js'],
dest: 'dist/examples/',
rename: function (dest, src) {
return dest + src.replace('WorldWindShim.build', 'WorldWindShim');
}
}
]
}
}
});

grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-karma');

grunt.registerTask('default', ['karma', 'jsdoc', 'requirejs', 'compress']);
grunt.registerTask('default', ['clean', 'karma', 'jsdoc', 'requirejs', 'compress', 'copy']);
};
43 changes: 43 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@nasaworldwind/worldwind",
"version": "0.0.1",
"description": "Web WorldWind",
"main": "worldwind.min.js",
"main": "dist/worldwind.min.js",
"homepage": "https://nasaworldwind.github.io/",
"bugs": {
"url": "https://github.com/NASAWorldWind/WebWorldWind/issues"
Expand All @@ -13,31 +13,28 @@
"NASA Project Manager <[email protected]>",
"ESA Consortium Contact <[email protected]>"
],
"directories": {
"lib": "./src",
"doc": "./api-doc",
"test": "./test",
"example": "./examples"
},
"repository": {
"type": "git",
"url": "https://github.com/NASAWorldWind/WebWorldWind.git"
},
"scripts": {
"build": "grunt",
"clean": "grunt clean",
"test": "grunt karma",
"doc": "grunt jsdoc",
"test:watch": "karma start karma.conf.js"
},
"files": [
"images/",
"images.zip",
"worldwind.js",
"worldwind.min.js"
"dist/images/",
"dist/images.zip",
"dist/worldwind.js",
"dist/worldwind.min.js"
],
"devDependencies": {
"grunt": "^1.0.1",
"grunt-contrib-clean": "^1.1.0",
"grunt-contrib-compress": "^1.4.3",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-requirejs": "^1.0.0",
"grunt-jsdoc": "^2.1.0",
"grunt-karma": "^2.0.0",
Expand Down
11 changes: 11 additions & 0 deletions tools/WorldWindShim.build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* This shim is used to switch between the individual WorldWind source files and the minified single file library for
* the WorldWind module. Switching allows locally developed examples to run from the individual WorldWind source files
* and hosted examples to use the faster to download minified library. A shim is not required for the use of WorldWind.
* The minified library (worldwind.min.js) is recommended for use in deployed applications.
*/
define(['../worldwind.min.js'], function (WorldWind) {
"use strict";

return WorldWind;
});
2 changes: 1 addition & 1 deletion travis/publishToArtifactory.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

mkdir assetsToPublish
NPM_PACKAGE=$(npm pack)
tar -xf $NPM_PACKAGE -C ./assetsToPublish --strip-components 1
tar -xf $NPM_PACKAGE -C ./assetsToPublish --strip-components 2
node travis/publishFolderToArtifactory $ARTIFACTORY_API_KEY ./assetsToPublish /artifactory/web/${TRAVIS_TAG#"v"}

0 comments on commit d7f8171

Please sign in to comment.