This repository has been archived by the owner on Apr 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configured grunt build system, bower to get font, and scaling.
- Loading branch information
Max Waterman
committed
Sep 27, 2013
1 parent
74cf0c1
commit 62f34ae
Showing
18 changed files
with
1,598 additions
and
789 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"directory": "app/lib", | ||
"json": "bower.json" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,237 @@ | ||
module.exports = function (grunt) { | ||
|
||
grunt.loadNpmTasks('grunt-tizen'); | ||
grunt.loadNpmTasks('grunt-contrib-clean'); | ||
grunt.loadNpmTasks('grunt-contrib-uglify'); | ||
grunt.loadNpmTasks('grunt-contrib-copy'); | ||
grunt.loadNpmTasks('grunt-contrib-cssmin'); | ||
grunt.loadNpmTasks('grunt-contrib-htmlmin'); | ||
grunt.loadNpmTasks('grunt-contrib-imagemin'); | ||
grunt.loadTasks('tools/grunt-tasks'); | ||
|
||
grunt.initConfig({ | ||
packageInfo: grunt.file.readJSON('package.json'), | ||
chromeInfo: grunt.file.readJSON('data/manifest.json'), | ||
|
||
clean: ['build'], | ||
|
||
tizen_configuration: { | ||
// location on the device to install the tizen-app.sh script to | ||
// (default: '/tmp') | ||
tizenAppScriptDir: '/home/developer/', | ||
|
||
// path to the config.xml file for the Tizen wgt file | ||
// (default: 'config.xml') | ||
configFile: 'data/config.xml', | ||
|
||
// path to the sdb command (default: process.env.SDB or 'sdb') | ||
sdbCmd: 'sdb' | ||
}, | ||
|
||
// minify JS | ||
uglify: { | ||
dist: { | ||
files: { | ||
'build/app/js/getMessage.js': ['app/js/getMessage.js'], | ||
'build/app/js/license.js': ['app/js/license.js'], | ||
'build/app/js/mancala.js': ['app/js/mancala.js'], | ||
'build/app/js/scaleBody.js': ['app/js/scaleBody.js'], | ||
'build/app/js/sound.js': ['app/js/sound.js'] | ||
} | ||
} | ||
}, | ||
|
||
// minify CSS | ||
cssmin: { | ||
dist: { | ||
files: { | ||
'build/app/css/mancala.css': ['app/css/mancala.css'], | ||
'build/app/css/license.css': ['app/css/license.css'] | ||
} | ||
} | ||
}, | ||
|
||
copy: { | ||
common: { | ||
files: [ | ||
{ expand: true, cwd: '.', src: ['app/lib/**'], dest: 'build/' }, | ||
{ expand: true, cwd: '.', src: ['app/audio/**'], dest: 'build/' }, | ||
{ expand: true, cwd: '.', src: ['LICENSE'], dest: 'build/app/' }, | ||
{ expand: true, cwd: '.', src: ['README.txt'], dest: 'build/app/' }, | ||
{ expand: true, cwd: '.', src: ['app/_locales/**'], dest: 'build/' } | ||
] | ||
}, | ||
wgt: { | ||
files: [ | ||
{ expand: true, cwd: 'build/app/', src: ['**'], dest: 'build/wgt/' }, | ||
{ expand: true, cwd: 'data/', src: ['config.xml'], dest: 'build/wgt/' }, | ||
{ expand: true, cwd: '.', src: ['icon_128.png'], dest: 'build/wgt/' } | ||
] | ||
}, | ||
crx: { | ||
files: [ | ||
{ expand: true, cwd: 'build/app/', src: ['**'], dest: 'build/crx/' }, | ||
{ expand: true, cwd: '.', src: ['manifest.json'], dest: 'build/crx/' }, | ||
{ expand: true, cwd: '.', src: ['icon*.png'], dest: 'build/crx/' } | ||
] | ||
}, | ||
sdk: { | ||
files: [ | ||
{ expand: true, cwd: 'build/app/', src: ['**'], dest: 'build/sdk/' }, | ||
{ expand: true, cwd: '.', src: ['app/css/*.css'], dest: 'build/sdk/css/' }, | ||
{ expand: true, cwd: '.', src: ['app/js/*.js'], dest: 'build/sdk/js/' }, | ||
{ expand: true, cwd: '.', src: ['app/*.html'], dest: 'build/sdk/' }, | ||
{ expand: true, cwd: 'data/', src: ['config.xml'], dest: 'build/sdk/' }, | ||
{ expand: true, cwd: '.', src: ['icon*.png'], dest: 'build/sdk/' } | ||
] | ||
} | ||
}, | ||
|
||
htmlmin: { | ||
dist: { | ||
files: [ | ||
{ expand: true, cwd: '.', src: ['app/*.html'], dest: 'build/' }, | ||
{ expand: true, cwd: '.', src: ['app/html/*.html'], dest: 'build/' } | ||
], | ||
options: { | ||
removeComments: true, | ||
collapseWhitespace: true, | ||
removeCommentsFromCDATA: false, | ||
removeCDATASectionsFromCDATA: false, | ||
removeEmptyAttributes: true, | ||
removeEmptyElements: false | ||
} | ||
} | ||
}, | ||
|
||
imagemin: { | ||
dist: { | ||
options: { | ||
optimizationLevel: 3, | ||
progressive: true | ||
}, | ||
files: [ | ||
{ expand: true, cwd: '.', src: ['app/images/**'], dest: 'build/' } | ||
] | ||
} | ||
}, | ||
|
||
// make wgt package in build/ directory | ||
package: { | ||
wgt: { | ||
appName: '<%= packageInfo.name %>', | ||
version: '<%= packageInfo.version %>', | ||
files: 'build/wgt/**', | ||
stripPrefix: 'build/wgt/', | ||
outDir: 'build', | ||
suffix: '.wgt', | ||
addGitCommitId: false | ||
}, | ||
sdk: { | ||
appName: '<%= packageInfo.name %>', | ||
version: '<%= packageInfo.version %>', | ||
files: 'build/sdk/**', | ||
stripPrefix: 'build/sdk/', | ||
outDir: 'build', | ||
suffix: '.wgt', | ||
} | ||
}, | ||
|
||
simple_server: { | ||
port: 30303, | ||
dir: 'build/app/' | ||
}, | ||
|
||
tizen: { | ||
push: { | ||
action: 'push', | ||
localFiles: { | ||
pattern: 'build/*.wgt', | ||
filter: 'latest' | ||
}, | ||
remoteDir: '/home/developer/' | ||
}, | ||
|
||
install: { | ||
action: 'install', | ||
remoteFiles: { | ||
pattern: '/home/developer/Mancala*.wgt', | ||
filter: 'latest' | ||
} | ||
}, | ||
|
||
uninstall: { | ||
action: 'uninstall' | ||
}, | ||
|
||
start: { | ||
action: 'start', | ||
stopOnFailure: true | ||
}, | ||
|
||
stop: { | ||
action: 'stop', | ||
stopOnFailure: false | ||
}, | ||
|
||
debug: { | ||
action: 'debug', | ||
browserCmd: 'google-chrome %URL%', | ||
localPort: 9090, | ||
stopOnFailure: true | ||
} | ||
} | ||
}); | ||
|
||
grunt.registerTask('dist', [ | ||
'clean', | ||
'imagemin:dist', | ||
'uglify:dist', | ||
'cssmin:dist', | ||
'htmlmin:dist', | ||
'copy:common' | ||
]); | ||
|
||
grunt.registerTask('crx', ['dist', 'copy:crx']); | ||
grunt.registerTask('wgt', ['dist', 'copy:wgt', 'package:wgt']); | ||
|
||
grunt.registerTask('sdk', [ | ||
'clean', | ||
'imagemin:dist', | ||
'copy:common', | ||
'copy:sdk', | ||
'package:sdk' | ||
]); | ||
|
||
grunt.registerTask('perf', [ | ||
'dist', | ||
'uglify:perf', | ||
'inline', | ||
'copy:wgt', | ||
'package:wgt' | ||
]); | ||
|
||
grunt.registerTask('install', [ | ||
'tizen:push', | ||
'tizen:stop', | ||
'tizen:uninstall', | ||
'tizen:install', | ||
'tizen:start' | ||
]); | ||
|
||
grunt.registerTask('wait', function () { | ||
var done = this.async(); | ||
setTimeout(function () { | ||
done(); | ||
}, 10000); | ||
}); | ||
|
||
grunt.registerTask('restart', ['tizen:stop', 'tizen:start']); | ||
|
||
grunt.registerTask('server', ['dist', 'simple_server']); | ||
|
||
grunt.registerTask('wgt-install', ['wgt', 'install']); | ||
grunt.registerTask('sdk-install', ['sdk', 'install']); | ||
|
||
grunt.registerTask('default', 'wgt'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# INITIAL SET UP | ||
|
||
To run the build, you'll need to install some node modules. | ||
Run the following in the top-level directory of the project: | ||
|
||
npm install | ||
|
||
grunt requires that you install grunt-cli globally | ||
to be able to use grunt from the command line. To install | ||
grunt-cli do: | ||
|
||
npm install -g grunt-cli | ||
|
||
You should then install the client-side dependencies into app/lib/: | ||
|
||
npm install -g bower | ||
bower install | ||
|
||
Note that if you want to install the application to a Tizen device | ||
as a wgt file, you will also need to install the sdb tool first. | ||
This is available for various platforms from | ||
http://download.tizen.org/tools/latest-release/. | ||
|
||
Configure your package manager to use the appropriate repo from the | ||
ones available and install sdb, e.g. for Fedora 17: | ||
|
||
$ REPO=http://download.tizen.org/tools/latest-release/Fedora_17/tools.repo | ||
$ sudo yum-config-manager --add-repo $REPO | ||
$ sudo yum install sdb | ||
|
||
# WHERE'S THE APP? | ||
|
||
There are a few options for running the application: | ||
|
||
* Open app/index.html in a browser (there's no requirement to | ||
run a build before you can run the app). | ||
|
||
* Serve the app from a standard web server. First, run: | ||
|
||
grunt dist | ||
|
||
Then copy the content of the build/app/ directory to a web folder | ||
for your server (e.g. an Apache htdocs directory). | ||
|
||
* Run the app using the built-in local server: | ||
|
||
grunt server | ||
|
||
This builds the dist version of the app and runs it on a server | ||
accessible at http://localhost:30303/. This is useful for testing the | ||
app in a mobile device: just navigate to the server hosting | ||
the app, using the phone's browser. | ||
|
||
* Install/reinstall to an attached Tizen device via sdb by running: | ||
|
||
grunt wgt-install | ||
|
||
This installs an optimised version of the app (minified HTML, | ||
minified and concatenated CSS and JS). | ||
|
||
* Install an SDK-specific version of the app (no minification or | ||
concatenation) with: | ||
|
||
grunt sdk-install | ||
|
||
* Build the files for the Chrome extension with: | ||
|
||
grunt crx | ||
|
||
then load the build/crx directory as an unpacked extension in Chrome | ||
developer mode. (The build can't currently make full .crx packages.) | ||
|
||
# PACKAGING | ||
|
||
To sign the app, grunt needs to know the location of your Tizen SDK | ||
Profile xml file. This is set to default to : | ||
|
||
test:$HOME/tizen-sdk/tools/ide/sample/profiles.xml | ||
|
||
which is the default location according to the Tizen CLI SDK instructions | ||
for generating the certificates. | ||
|
||
<https://developer.tizen.org/help/index.jsp?topic=%2Forg.tizen.web.appprogramming%2Fhtml%2Fide_sdk_tools%2Fcommand_line_interface.htm> | ||
|
||
You can override this path using the TIZENSDKPROFILE environment | ||
variable. For example, if you moved the sdk from ~/tizen-sdk to | ||
~/apps/tizen-sdk : | ||
|
||
export TIZENSDKPROFILE=test:$HOME/apps/tizen-sdk/tools/ide/sample/profiles.xml | ||
|
||
The application can be packaged into a wgt (zip) file using the grunt | ||
command: | ||
|
||
grunt wgt | ||
|
||
This will generate a package in the build/ directory. | ||
|
||
It can also be packaged into an SDK wgt file (with uncompressed JS, | ||
CSS, and HTML) using: | ||
|
||
grunt sdk | ||
|
||
Note that in both cases, the files comprising the packages are | ||
first copied into the build/wgt and build/sdk directories respectively. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.