Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
* development:
  build(npm): added release script to package.json
  docs(api): Moved doc to ghpages. Keeping docs folder untill we verify ghpages works
  feat(browser): ES5 and minified js file for use in the browser
  build(dependencies): updated dependencies to newer versions (typedoc and typescript)
  • Loading branch information
Skotiniotis committed May 12, 2017
2 parents fcf1bea + e7e70de commit 183c011
Show file tree
Hide file tree
Showing 49 changed files with 9,487 additions and 10,526 deletions.
9 changes: 8 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ node_js:
before_script:
- npm prune
script:
- npm run test
- npm run release
after_success:
- 'if [ "$TRAVIS_BRANCH" == "master" -a "$TRAVIS_PULL_REQUEST" == "false" ]; then npm run semantic-release; fi'
- 'if [ "$TRAVIS_BRANCH" != "master" ]; then exit 0; fi'
branches:
except:
- /^v\d+\.\d+\.\d+$/
deploy:
provider: pages
skip_clean: true
local_dir: doc
github_token: $GH_TOKEN
on:
branch: master
100 changes: 89 additions & 11 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* <h1> Ion JS in your browser</h1>
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,7 +28,7 @@ module.exports = function(grunt) {
},
},
clean: ['dist/',
'docs/',
// 'docs/', removing for now till we move to ghpages
'coverage-final.json',
'browser/scripts/ion/'
],
Expand Down Expand Up @@ -89,14 +90,22 @@ module.exports = function(grunt) {
* 2. the browser folder for use within a browser
*/
copy: {
main: {
bundle: {
files: [
{ expand: true,
src: ['dist/amd/es5/*.js'],
dest: 'browser/scripts/ion/',
src: ['dist/browser/js/ion-bundle*'],
dest: 'browser/scripts/',
flatten: true
}
]
},
tutorial:{
files: [
{ expand: true,
src: ['browser/**'],
dest: 'docs/',
}
]
}
},
babel: {
Expand All @@ -114,26 +123,95 @@ module.exports = function(grunt) {
}],
},
},
/**
* Two steps here
* 1. Take CommonJS and generates ES5 using Bable (babelify)
* 2. Package the ES5 code to be used in the browser (browserify)
*/
browserify: {
development: {
src: [ "./dist/commonjs/es6/Ion.js" ],
dest: './dist/browser/js/ion-bundle.js',
options: {
browserifyOptions: {
standalone: 'ion', // add `ion` to global JS variable `window` in browsers
debug: true,
},
transform: [["babelify",
{
"presets": ["es2015"],
"plugins" : [["transform-runtime", {"polyfill" : true}]]
}]],
}
},
prod: {
src: [ "./dist/commonjs/es6/Ion.js" ],
dest: './dist/browser/js/ion-bundle.js',
options: {
browserifyOptions: {
standalone: 'ion', // add `ion` to global JS variable `window` in browsers
debug: false,
},
transform: [["babelify",
{
"presets": ["es2015"],
"plugins" : [["transform-runtime", {"polyfill" : true}]]
}]],
}
}
},
uglify: {
options: {
compress: true,
mangle: true,
sourceMap: false
},
target: {
src: './dist/browser/js/ion-bundle.js',
dest: './dist/browser/js/ion-bundle.min.js',
}
}
});

grunt.loadNpmTasks('grunt-babel');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-ts');
grunt.loadNpmTasks('grunt-typedoc');
grunt.loadNpmTasks('remap-istanbul');
grunt.loadNpmTasks('intern');

grunt.registerTask('build', ['clean', 'ts:amd-es6', 'ts:commonjs-es6','babel', 'copy:main']);
grunt.registerTask('test', ['build', 'intern:es6']);
grunt.registerTask('doc', ['test', 'typedoc']);
grunt.registerTask('coverage', ['doc', 'remapIstanbul']);
grunt.registerTask('all', ['coverage']);
// Copy tasks
grunt.registerTask('copy:all', ['copy:bundle', 'copy:tutorial']);

// Build and Translation tasks
grunt.registerTask('build:browser', ['build', 'browserify:prod', 'uglify']); // standalone for browser
grunt.registerTask('trans:browser', ['browserify:prod', 'uglify']); // browserify (assumes 'build' was run)
grunt.registerTask('build:cjs', ['ts:commonjs-es6']);
grunt.registerTask('build:amd', ['ts:amd-es6']);
grunt.registerTask('build', ['clean', 'build:amd', 'build:cjs','trans:browser', 'copy:all']);


// Tests
grunt.registerTask('test', ['build', 'intern:es6']); // build and test
grunt.registerTask('test:run', ['intern:es6']); // run test do not build
grunt.registerTask('test:coverage', ['remapIstanbul']); // depends on `test:run`. Generates html output

// Documentation
grunt.registerTask('nojekyll', 'Write an empty .nojekyll file to allow typedoc html output to be rendered',
function(){
grunt.file.write('docs/.nojekyll', '');
});

grunt.registerTask('doc', ['typedoc']);


// NPM
grunt.registerTask('build:npm', ['ts:commonjs-es6']);
// release target used by Travis
grunt.registerTask('release', ['build', 'test:run', 'test:coverage', 'typedoc', 'nojekyll']);

// default for development
grunt.registerTask('default', ['test']);
};
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<p align="right">
<a title="" href="https://api.travis-ci.org/amzn/ion-js.svg?branch=master">
<img src="https://api.travis-ci.org/amzn/ion-js.svg?branch=master"/>
</a>
<a title="npm-version" href="https://www.npmjs.com/package/ion-js"><img src="https://img.shields.io/npm/v/ion-js.svg"/></a>
<a title="license" href="https://github.com/amzn/ion-js/blob/master/LICENSE"><img src="https://img.shields.io/hexpm/l/plug.svg"/></a>

</p>
<p align="right">
<a title="travis" href="https://travis-ci.org/amzn/ion-js"><img src="https://api.travis-ci.org/amzn/ion-js.svg?branch=master"/></a>
<a title="docs" href="https://amzn.github.io/ion-js/api/index.html"><img src="https://img.shields.io/badge/docs-api-green.svg?style=flat-square"/></a>
<a title="semantic-release" href="https://github.com/amzn/ion-js/releases"><img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square"/></a>
</p>

# About
Expand Down
12 changes: 9 additions & 3 deletions browser/index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
<html>
<head>
<!--<script src="scripts/ion-es5-polyfill.js"></script>-->
<meta charset="UTF-8"/>
<script data-main="scripts/ion-require" src="scripts/require.js"></script>
<script src="scripts/ion-bundle.min.js"></script>
</head>
<body>

<button type="button" onclick="test('END')">Try it</button>
<h1> Ion JS in your browser</h1>
<p>
<button type="button" onclick="var ion = window.ion">Click me first</button> and then open the JS console
on your browser. The global variable <code>ion</code> may be used using the <a href="https://amzn.github.io/ion-js/api/modules/_ion_.html">API</a>.
</p>

<p>
A more complete and user friendly tutorial is forthcoming!
</p>
</body>
</html>
113 changes: 0 additions & 113 deletions browser/scripts/ion-es5-polyfill.js

This file was deleted.

29 changes: 0 additions & 29 deletions browser/scripts/ion-require.js

This file was deleted.

Loading

0 comments on commit 183c011

Please sign in to comment.