├── .yo-rc.json ├── .gitattributes ├── .gitignore ├── _plugin ├── templates │ └── _ZZZ.txt └── index.js ├── .editorconfig ├── .travis.yml ├── .jshintrc ├── _plugin_packagejson ├── templates │ └── _package.json └── index.js ├── NOTICE ├── _plugin_tests ├── templates │ ├── _tests.js │ └── _plugin.xml └── index.js ├── package.json ├── _testbed └── index.js ├── _testbed_platform └── index.js ├── _plugin_platform └── index.js ├── _testbed_add_test_plugin └── index.js ├── _testbed_add_plugin └── index.js ├── _testbed_testframework ├── index.js └── templates │ └── csp-incl.js ├── README.md ├── app └── index.js └── LICENSE /.yo-rc.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | *~ 3 | -------------------------------------------------------------------------------- /_plugin/templates/_ZZZ.txt: -------------------------------------------------------------------------------- 1 | This file is just existing for ignoring. 2 | 3 | Plugman will not copy last file of the folder in the plugin if the plugin folder locates sibling of cordova app folder. 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '0.10' 4 | before_install: 5 | - currentfolder=${PWD##*/} 6 | - if [ "$currentfolder" != 'generator-cordova-plugin-devbed' ]; then cd .. && eval "mv $currentfolder generator-cordova-plugin-devbed" && cd generator-cordova-plugin-devbed; fi 7 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "esnext": true, 4 | "bitwise": true, 5 | "camelcase": true, 6 | "curly": true, 7 | "eqeqeq": true, 8 | "immed": true, 9 | "indent": 2, 10 | "latedef": true, 11 | "newcap": true, 12 | "noarg": true, 13 | "quotmark": "single", 14 | "undef": true, 15 | "unused": true, 16 | "strict": true 17 | } 18 | -------------------------------------------------------------------------------- /_plugin_packagejson/templates/_package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= pluginName %>", 3 | "version": "<%= pluginVersion %>", 4 | "description": "", 5 | "cordova": { 6 | "id": "<%= packageID %>", 7 | "platforms": [<% for( var i = 0; i < pluginPlatforms.length; i++ ) { %><% if( 0 < i ){ %>,<% } %> 8 | "<%= pluginPlatforms[i] %>" 9 | <% } %>] 10 | }, 11 | "keywords": [ 12 | "ecosystem:cordova"<% for( var i = 0; i < pluginPlatforms.length; i++ ) { %>, 13 | "cordova-<%= pluginPlatforms[i] %>"<% } %> 14 | ], 15 | "author": "" 16 | } -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | NOTICES FOR generator-generator 3 | -------------------------------------------------------------------------------- 4 | 5 | generator-generator 6 | https://github.com/yeoman/generator-generator 7 | 8 | MIT © Pascal Hartig phartig@rdrei.net and other contributors 9 | 10 | 11 | -------------------------------------------------------------------------------- 12 | NOTICES FOR csp-incl.js 13 | -------------------------------------------------------------------------------- 14 | 15 | csp-incl.js is copied from cordova-mobile-spec 16 | https://github.com/apache/cordova-mobile-spec/ 17 | 18 | Apache Cordova 19 | Copyright 2012 The Apache Software Foundation 20 | 21 | This product includes software developed at 22 | The Apache Software Foundation (http://www.apache.org/). 23 | -------------------------------------------------------------------------------- /_plugin_tests/templates/_tests.js: -------------------------------------------------------------------------------- 1 | 2 | exports.defineAutoTests = function() { 3 | describe('<%= pluginName %> object existance check', function() { 4 | 5 | it("<%= pluginID %>", function () { 6 | expect( <%= pluginID %>).toBeDefined(); 7 | }); 8 | 9 | it("<%= pluginID %>.coolMethod", function() { 10 | expect( <%= pluginID %>.coolMethod ).toBeDefined(); 11 | }); 12 | }); 13 | 14 | describe('coolMethod call test', function() { 15 | 16 | var value; 17 | var callbacks; 18 | 19 | beforeEach(function(done) { 20 | callbacks = { 21 | win: function(arg){ 22 | value = arg; 23 | done(); 24 | }, 25 | fail: function(err){ 26 | console.log("callbacks.fail"); 27 | done(); 28 | } 29 | }; 30 | 31 | spyOn(callbacks, 'win').and.callThrough(); 32 | spyOn(callbacks, 'fail').and.callThrough(); 33 | 34 | <%= pluginID %>.coolMethod("test", callbacks.win, callbacks.fail); 35 | }); 36 | 37 | it("to have been called", function() { 38 | expect(callbacks.win).toHaveBeenCalled(); 39 | }); 40 | 41 | it("check return value", function() { 42 | expect(value).toBe("test"); 43 | }); 44 | 45 | }); 46 | }; 47 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generator-cordova-plugin-devbed", 3 | "version": "0.3.0", 4 | "description": "Yeoman generator for Cordova plugin, it also provides plugin testbed", 5 | "license": "Apache-2.0", 6 | "main": "app/index.js", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/sony/generator-cordova-plugin-devbed.git" 10 | }, 11 | "bugs": { 12 | "url": "https://github.com/sony/generator-cordova-plugin-devbed/issues" 13 | }, 14 | "author": { 15 | "name": "SEKI Yasuharu", 16 | "email": "Yasuharu.Seki@jp.sony.com" 17 | }, 18 | "engines": { 19 | "node": ">=0.10.0" 20 | }, 21 | "scripts": { 22 | "test": "mocha" 23 | }, 24 | "files": [ 25 | "app", 26 | "_plugin", "_plugin_packagejson", "_plugin_platform", "_plugin_tests", 27 | "_testbed", "_testbed_add_plugin", "_testbed_add_test_plugin", 28 | "_testbed_platform", "_testbed_testframework" 29 | ], 30 | "keywords": [ 31 | "yeoman-generator", 32 | "Cordova", 33 | "plugin" 34 | ], 35 | "dependencies": { 36 | "yeoman-generator": "^0.20.3", 37 | "chalk": "^1.1.1", 38 | "yosay": "^1.0.5", 39 | "cordova-lib": "^6.2.0", 40 | "xml2js": "^0.4.12", 41 | "q": "^1.4.1" 42 | }, 43 | "devDependencies": { 44 | "mocha": "*" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /_plugin_tests/templates/_plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 26 | <%= pluginName %> Tests 27 | Apache 2.0 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /_plugin_tests/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var assert = require('assert'); 3 | var yeoman = require('yeoman-generator'); 4 | 5 | //============================================================================ 6 | // Yeoman generator implementation 7 | // 8 | module.exports = yeoman.generators.Base.extend({ 9 | 10 | constructor: function (args, options, config) { 11 | yeoman.generators.Base.apply(this, arguments); 12 | this.props = options; 13 | }, 14 | 15 | //========================================================================== 16 | // Create test plugin 17 | //-------------------------------------------------------------------------- 18 | /// CWD changed to plugin directory 19 | /// 20 | plugin_changedir: function() { 21 | assert(this.props.pluginName, 'pluginName is required'); 22 | process.chdir(this.props.pluginName); 23 | }, 24 | 25 | //-------------------------------------------------------------------------- 26 | // Run plugman: create plugin 27 | // 28 | plugin_create_tests: function() { 29 | assert(this.props.pluginName, 'pluginName is required'); 30 | assert(this.props.pluginID, 'pluginID is required'); 31 | assert(this.props.pluginVersion, 'pluginVersion is required'); 32 | 33 | var done = this.async(); 34 | 35 | this.log('*** Start creating plugin tests ***'); 36 | 37 | this.template('_plugin.xml', 'tests/plugin.xml', this.props); 38 | this.template('_tests.js', 'tests/tests.js', this.props); 39 | 40 | this.fs.commit(function(){ done(); }); 41 | }, 42 | 43 | plugin_back_to_root: function() { 44 | process.chdir('..'); 45 | }, 46 | 47 | // finalize this generator 48 | finalize: function() { 49 | if( this.props.done ){ this.props.done(); } 50 | }, 51 | 52 | }); 53 | -------------------------------------------------------------------------------- /_testbed/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var assert = require('assert'); 3 | var yeoman = require('yeoman-generator'); 4 | var cordova_lib = require('cordova-lib'); 5 | var cordova = cordova_lib.cordova; 6 | 7 | //============================================================================ 8 | // Yeoman generator implementation 9 | // 10 | module.exports = yeoman.generators.Base.extend({ 11 | 12 | constructor: function (args, options, config) { 13 | yeoman.generators.Base.apply(this, arguments); 14 | this.props = options; 15 | }, 16 | 17 | //========================================================================== 18 | // Create dev bed 19 | //-------------------------------------------------------------------------- 20 | // Create the simple app with cordova command 21 | // 22 | cordova_create: function() { 23 | assert(this.props.testbedName, 'testbedName is required'); 24 | assert(this.props.domainName, 'domainName is required'); 25 | 26 | var done = this.async(); 27 | var testbedID = this._makeReverseDomain( this.props.domainName, this.props.testbedName ); 28 | 29 | // Create TestBed application 30 | this.log('*** Start creating plugin test bed ***'); 31 | cordova.raw.create( this.props.testbedName, // @dir 32 | testbedID, // @id 33 | this.props.testbedName, // @name 34 | {} ) // @cfg 35 | .done( function(){ 36 | done(); 37 | } ); 38 | }, 39 | 40 | // finalize this generator 41 | finalize: function() { 42 | if( this.props.done ){ this.props.done(); } 43 | }, 44 | 45 | _makeReverseDomain: function( domain, name ){ 46 | var aryDomain = domain.split('.'); 47 | aryDomain.reverse(); 48 | return aryDomain.join('.') + '.' + name; 49 | }, 50 | 51 | }); 52 | -------------------------------------------------------------------------------- /_testbed_platform/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var assert = require('assert'); 3 | var yeoman = require('yeoman-generator'); 4 | var cordova_lib = require('cordova-lib'); 5 | var cordova = cordova_lib.cordova; 6 | 7 | //============================================================================ 8 | // Yeoman generator implementation 9 | // 10 | module.exports = yeoman.generators.Base.extend({ 11 | 12 | constructor: function (args, options, config) { 13 | yeoman.generators.Base.apply(this, arguments); 14 | this.props = options; 15 | }, 16 | 17 | //========================================================================== 18 | // Add platform into testbed 19 | //-------------------------------------------------------------------------- 20 | /// CWD changed to TestBed directory 21 | /// 22 | cordova_changedir: function() { 23 | assert(this.props.testbedName, 'testbedName is required'); 24 | process.chdir(this.props.testbedName); 25 | }, 26 | 27 | //-------------------------------------------------------------------------- 28 | // Add platform 29 | // 30 | cordova_add_platforms: function() { 31 | this.log('*** Adding platform to plugin test bed ***'); 32 | 33 | var done = this.async(); 34 | this._add_platforms(0, this.props.pluginPlatforms, done); 35 | }, 36 | 37 | _add_platforms: function(idx, platforms, done) { 38 | 39 | if(platforms.length <= idx) { 40 | done(); 41 | return; 42 | } 43 | 44 | var self = this; 45 | cordova.platform('add', platforms[idx], function() { 46 | self._add_platforms(idx+1, platforms, done); 47 | }); 48 | }, 49 | 50 | cordova_back_to_root: function() { 51 | process.chdir('..'); 52 | }, 53 | 54 | // finalize this generator 55 | finalize: function() { 56 | if( this.props.done ){ this.props.done(); } 57 | }, 58 | 59 | }); 60 | -------------------------------------------------------------------------------- /_plugin_platform/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var assert = require('assert'); 3 | var yeoman = require('yeoman-generator'); 4 | var cordova_lib = require('cordova-lib'); 5 | var plugman = cordova_lib.plugman; 6 | 7 | //============================================================================ 8 | // Yeoman generator implementation 9 | // 10 | module.exports = yeoman.generators.Base.extend({ 11 | 12 | constructor: function (args, options, config) { 13 | yeoman.generators.Base.apply(this, arguments); 14 | this.props = options; 15 | }, 16 | 17 | //========================================================================== 18 | // Add platform into plugin 19 | //-------------------------------------------------------------------------- 20 | /// CWD changed to plugin directory 21 | /// 22 | plugin_changedir: function() { 23 | assert(this.props.pluginName, 'pluginName is required'); 24 | process.chdir(this.props.pluginName); 25 | }, 26 | 27 | //------------------------------------------------------------------------- 28 | // Run plugman: add platform 29 | // 30 | plugin_add_platforms: function() { 31 | this.log('*** Adding platform to plugin ***'); 32 | 33 | var done = this.async(); 34 | this._add_platforms(0, this.props.pluginPlatforms, done); 35 | }, 36 | 37 | _add_platforms: function(idx, platforms, done) { 38 | 39 | if(platforms.length <= idx) { 40 | done(); 41 | return; 42 | } 43 | 44 | var self = this; 45 | plugman.platform({ operation: 'add', platform_name: platforms[idx] }, function() { 46 | self._add_platforms(idx+1, platforms, done); 47 | }); 48 | }, 49 | 50 | plugin_back_to_root: function() { 51 | process.chdir('..'); 52 | }, 53 | 54 | // finalize this generator 55 | finalize: function() { 56 | if( this.props.done ){ this.props.done(); } 57 | }, 58 | 59 | }); 60 | -------------------------------------------------------------------------------- /_testbed_add_test_plugin/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var assert = require('assert'); 3 | var yeoman = require('yeoman-generator'); 4 | var cordova_lib = require('cordova-lib'); 5 | var cordova = cordova_lib.cordova; 6 | 7 | var path = require('path'); 8 | 9 | //============================================================================ 10 | // Yeoman generator implementation 11 | // 12 | module.exports = yeoman.generators.Base.extend({ 13 | 14 | constructor: function (args, options, config) { 15 | yeoman.generators.Base.apply(this, arguments); 16 | this.props = options; 17 | }, 18 | 19 | //========================================================================== 20 | // Add platform into testbed 21 | //-------------------------------------------------------------------------- 22 | /// CWD changed to TestBed directory 23 | /// 24 | cordova_changedir: function() { 25 | assert(this.props.testbedName, 'testbedName is required'); 26 | process.chdir(this.props.testbedName); 27 | }, 28 | 29 | //-------------------------------------------------------------------------- 30 | // Add plugin 31 | // 32 | cordova_add_platform: function() { 33 | assert(this.props.pluginName, 'pluginName is required'); 34 | this.log('*** Adding target test runner plugin to plugin test bed ***'); 35 | 36 | var done = this.async(); 37 | var plugins = [path.join(process.cwd(), '..', this.props.pluginName, 'tests')]; 38 | this._add_plugins(0, plugins, done); 39 | }, 40 | 41 | _add_plugins: function(idx, plugins, done) { 42 | 43 | if(plugins.length <= idx) { 44 | done(); 45 | return; 46 | } 47 | 48 | var self = this; 49 | cordova.plugin('add', plugins[idx], function() { 50 | self._add_plugins(idx+1, plugins, done); 51 | }); 52 | }, 53 | 54 | testbed_back_to_root: function() { 55 | process.chdir('..'); 56 | }, 57 | 58 | // finalize this generator 59 | finalize: function() { 60 | if( this.props.done ){ this.props.done(); } 61 | }, 62 | 63 | }); 64 | -------------------------------------------------------------------------------- /_testbed_add_plugin/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var assert = require('assert'); 3 | var yeoman = require('yeoman-generator'); 4 | var cordova_lib = require('cordova-lib'); 5 | var cordova = cordova_lib.cordova; 6 | 7 | var fs = require('fs'); 8 | var path = require('path'); 9 | 10 | //============================================================================ 11 | // Yeoman generator implementation 12 | // 13 | module.exports = yeoman.generators.Base.extend({ 14 | 15 | constructor: function (args, options, config) { 16 | yeoman.generators.Base.apply(this, arguments); 17 | this.props = options; 18 | }, 19 | 20 | //========================================================================== 21 | // Add platform into testbed 22 | //-------------------------------------------------------------------------- 23 | /// CWD changed to TestBed directory 24 | /// 25 | cordova_changedir: function() { 26 | assert(this.props.testbedName, 'testbedName is required'); 27 | process.chdir(this.props.testbedName); 28 | }, 29 | 30 | //-------------------------------------------------------------------------- 31 | // Add plugin 32 | // 33 | cordova_add_platform: function() { 34 | assert(this.props.pluginName, 'pluginName is required'); 35 | this.log('*** Adding target plugin to plugin test bed ***'); 36 | 37 | var done = this.async(); 38 | var plugins = [path.join(process.cwd(), '..', this.props.pluginName)]; 39 | 40 | this._add_plugins(0, plugins, done); 41 | }, 42 | 43 | _add_plugins: function(idx, plugins, done) { 44 | 45 | if(plugins.length <= idx) { 46 | done(); 47 | return; 48 | } 49 | 50 | var self = this; 51 | cordova.plugin('add', plugins[idx], function() { 52 | self._add_plugins(idx+1, plugins, done); 53 | }); 54 | }, 55 | 56 | testbed_back_to_root: function() { 57 | process.chdir('..'); 58 | }, 59 | 60 | // finalize this generator 61 | finalize: function() { 62 | if( this.props.done ){ this.props.done(); } 63 | }, 64 | 65 | }); 66 | -------------------------------------------------------------------------------- /_plugin_packagejson/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var assert = require('assert'); 3 | var yeoman = require('yeoman-generator'); 4 | var cordova_lib = require('cordova-lib'); 5 | var plugman = cordova_lib.plugman; 6 | 7 | //============================================================================ 8 | // Yeoman generator implementation 9 | // 10 | module.exports = yeoman.generators.Base.extend({ 11 | 12 | constructor: function (args, options, config) { 13 | yeoman.generators.Base.apply(this, arguments); 14 | this.props = options; 15 | }, 16 | 17 | //========================================================================== 18 | // Add package.json into plugin 19 | //-------------------------------------------------------------------------- 20 | /// CWD changed to plugin directory 21 | /// 22 | plugin_changedir: function() { 23 | assert(this.props.pluginName, 'pluginName is required'); 24 | process.chdir(this.props.pluginName); 25 | }, 26 | 27 | //------------------------------------------------------------------------- 28 | // Run plugman: add package.json 29 | // 30 | plugin_add_packagejson: function() { 31 | assert(this.props.pluginName, 'pluginName is required'); 32 | assert(this.props.pluginID, 'pluginID is required'); 33 | assert(this.props.pluginVersion, 'pluginVersion is required'); 34 | 35 | var done = this.async(); 36 | 37 | this.log('*** Adding package.json to plugin ***'); 38 | 39 | this.template('_package.json', 'package.json', this.props); 40 | 41 | this.fs.commit(function(){ done(); }); 42 | /** 43 | * First, I thought I can use plugman for creating package.json. 44 | * But the 'plugman createpackagejson' does not handle async behavior as I expected. 45 | * And they does not carry 'name' property into package.json from plugin.xml. 46 | * I changed my mind to use template 47 | * 48 | var done = this.async(); 49 | plugman.createpackagejson('.', function(){ 50 | console.log("End of adding package.json"); 51 | done(); 52 | }); 53 | */ 54 | }, 55 | 56 | plugin_back_to_root: function() { 57 | process.chdir('..'); 58 | }, 59 | 60 | // finalize this generator 61 | finalize: function() { 62 | if( this.props.done ){ this.props.done(); } 63 | }, 64 | 65 | }); 66 | -------------------------------------------------------------------------------- /_testbed_testframework/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var assert = require('assert'); 3 | var yeoman = require('yeoman-generator'); 4 | var fs = require('fs'); 5 | var xml2js = require('xml2js'); 6 | var cordova_lib = require('cordova-lib'); 7 | var cordova = cordova_lib.cordova; 8 | 9 | //============================================================================ 10 | // Yeoman generator implementation 11 | // 12 | module.exports = yeoman.generators.Base.extend({ 13 | 14 | constructor: function (args, options, config) { 15 | yeoman.generators.Base.apply(this, arguments); 16 | this.props = options; 17 | }, 18 | 19 | //========================================================================== 20 | // Add platform into testbed 21 | //-------------------------------------------------------------------------- 22 | /// CWD changed to TestBed directory 23 | /// 24 | changedir: function() { 25 | assert(this.props.testbedName, 'testbedName is required'); 26 | process.chdir(this.props.testbedName); 27 | }, 28 | 29 | //-------------------------------------------------------------------------- 30 | // Add plugin 31 | // 32 | cordova_add_platform: function() { 33 | assert(this.props.TEST_FRAMEWORK, 'TEST_FRAMEWORK is required'); 34 | this.log('*** Adding test framework for cordova plugin ***'); 35 | 36 | cordova.plugin('add', this.props.TEST_FRAMEWORK); 37 | }, 38 | 39 | modify_config_xml: function() { 40 | var done = this.async(); 41 | var parser = new xml2js.Parser(); 42 | var builder = new xml2js.Builder(); 43 | 44 | var data = fs.readFileSync('config.xml'); 45 | parser.parseString(data, function(err, result) { 46 | 47 | result.widget.content[0].$.src = "cdvtests/index.html"; 48 | var xml = builder.buildObject(result); 49 | fs.writeFileSync('config.xml', xml); 50 | 51 | done(); 52 | }); 53 | }, 54 | 55 | //-------------------------------------------------------------------------- 56 | // Copy some setting files 57 | // 58 | copy_test_framework_config_files: function() { 59 | this.copy('csp-incl.js', 'www/csp-incl.js'); 60 | }, 61 | 62 | back_to_root: function() { 63 | process.chdir('..'); 64 | }, 65 | 66 | // finalize this generator 67 | finalize: function() { 68 | if( this.props.done ){ this.props.done(); } 69 | }, 70 | 71 | }); 72 | -------------------------------------------------------------------------------- /_testbed_testframework/templates/csp-incl.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Licensed to the Apache Software Foundation (ASF) under one 4 | * or more contributor license agreements. See the NOTICE file 5 | * distributed with this work for additional information 6 | * regarding copyright ownership. The ASF licenses this file 7 | * to you under the Apache License, Version 2.0 (the 8 | * "License"); you may not use this file except in compliance 9 | * with the License. You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, 14 | * software distributed under the License is distributed on an 15 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | * KIND, either express or implied. See the License for the 17 | * specific language governing permissions and limitations 18 | * under the License. 19 | * 20 | */ 21 | 22 | var PLAT; 23 | (function getPlatform() { 24 | var platforms = { 25 | amazon_fireos: /cordova-amazon-fireos/, 26 | android: /Android/, 27 | ios: /(iPad)|(iPhone)|(iPod)/, 28 | blackberry10: /(BB10)/, 29 | blackberry: /(PlayBook)|(BlackBerry)/, 30 | // Since Windows Phone 8.1 uses completely different API more similar to Windows 8 31 | // than to Windows phone 8 we need to detect it separately. 32 | windowsphone81: /Windows Phone 8.1/, 33 | windowsphone: /Windows Phone/, 34 | windows: /MSAppHost/, 35 | firefoxos: /Firefox/ 36 | }; 37 | for (var key in platforms) { 38 | if (platforms[key].exec(navigator.userAgent)) { 39 | PLAT = key; 40 | break; 41 | } 42 | } 43 | })(); 44 | 45 | // To disable CSP, define _disableCSP and set to true, prior to the inclusion 46 | // of this file. 47 | if (!window._disableCSP) { 48 | var cspMetaContent = null; 49 | switch (PLAT) { 50 | case 'android': 51 | case 'ios': 52 | case 'windows': 53 | cspMetaContent = 'default-src \'self\' https://ssl.gstatic.com/accessibility/javascript/android/;' + 54 | ' connect-src \'self\' http://cordova-filetransfer.jitsu.com;' + 55 | ' media-src \'self\' http://cordova.apache.org/downloads/;' + 56 | ' frame-src \'self\' http://stealbridgesecret.test/ data: gap:;' + 57 | ' img-src \'self\' data:;' + 58 | ' style-src \'self\' \'unsafe-inline\''; 59 | break; 60 | } 61 | 62 | if (cspMetaContent) { 63 | cspMetaContent = ''; 64 | if (PLAT === 'windows' && MSApp && MSApp.execUnsafeLocalFunction) { 65 | MSApp.execUnsafeLocalFunction(function () { 66 | document.write(cspMetaContent); 67 | }); 68 | } else { 69 | document.write(cspMetaContent); 70 | } 71 | } 72 | } 73 | else { 74 | console.log('CSP injection is disabled.'); 75 | } 76 | 77 | -------------------------------------------------------------------------------- /_plugin/index.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'); 2 | var yeoman = require('yeoman-generator'); 3 | var fs = require('fs'); 4 | var xml2js = require('xml2js'); 5 | var cordova_lib = require('cordova-lib'); 6 | var plugman = cordova_lib.plugman; 7 | 8 | //============================================================================ 9 | // Yeoman generator implementation 10 | // 11 | module.exports = yeoman.generators.Base.extend({ 12 | 13 | constructor: function (args, options, config) { 14 | yeoman.generators.Base.apply(this, arguments); 15 | this.props = options; 16 | }, 17 | 18 | //========================================================================== 19 | // Create plugin 20 | //-------------------------------------------------------------------------- 21 | // Run plugman: create plugin 22 | // 23 | plugin_create: function() { 24 | assert(this.props.pluginName, 'pluginName is required'); 25 | assert(this.props.pluginID, 'pluginID is required'); 26 | assert(this.props.pluginVersion, 'pluginVersion is required'); 27 | 28 | var done = this.async(); 29 | 30 | this.log('*** Start creating plugin ***'); 31 | plugman.create( this.props.pluginName, 32 | this.props.pluginID, 33 | this.props.pluginVersion, 34 | '.', [], 35 | function(err) { 36 | if(err){ console.log(err); } 37 | else { done(); } 38 | }); 39 | }, 40 | 41 | // Modify the plugin.xml created by plugman 42 | modify_plugin_xml: function() { 43 | assert(this.props.pluginName, 'pluginName is required'); 44 | assert(this.props.pluginID, 'pluginID is required'); 45 | 46 | var done = this.async(); 47 | var parser = new xml2js.Parser(); 48 | var builder = new xml2js.Builder(); 49 | 50 | var plugin_name = this.props.pluginName; 51 | var plugin_id = this.props.pluginID; 52 | var plugin_file = this.props.pluginName + '/plugin.xml'; 53 | 54 | var data = fs.readFileSync(plugin_file); 55 | parser.parseString(data, function(err, result) { 56 | 57 | result = this._replace_clobbers( result, plugin_id, plugin_name ); 58 | 59 | var xml = builder.buildObject(result); 60 | fs.writeFileSync(plugin_file, xml); 61 | 62 | done(); 63 | }.bind(this)); 64 | }, 65 | 66 | // Add 'ZZZ' file to plugin folder 67 | // To avoid plugman bug by 'allow recursive folder copy skipping whateve .. was' @ 2016.1.24 68 | // The change implicitly ignore last 1 file/folder in plugin folder if the plugin locates side of cordova app folder. 69 | workaround_for_plugman: function() { 70 | this.template( '_ZZZ.txt', this.props.pluginName + '/ZZZ.txt', this.props); 71 | }, 72 | 73 | // finalize this generator 74 | finalize: function() { 75 | if( this.props.done ){ this.props.done(); } 76 | }, 77 | 78 | // replace value 79 | _replace_clobbers: function( obj, pluginID, pluginName ){ 80 | 81 | // It's not correct way of parsing/replacing 82 | // Strictly speeking, it should check existence and to know 83 | // it's object or array 84 | obj.plugin['js-module'][0].clobbers[0].$.target = pluginID; 85 | 86 | return obj; 87 | }, 88 | 89 | }); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # generator-cordova-plugin-devbed 2 | 3 | > [Yeoman](http://yeoman.io) [cordova](http://cordova.apache.org) plugin generator 4 | 5 | 6 | ## Getting Started 7 | 8 | ### What's cordova plugin devbed? 9 | 10 | Yeoman generator that provides simple cordova plugin and test bed application for the plugin. 11 | 12 | ### Getting started 13 | 14 | To install generator-cordova-plugin-devbed from npm, run: 15 | 16 | ```bash 17 | npm install -g generator-cordova-plugin-devbed 18 | ``` 19 | 20 | Next, initiate the generator: 21 | 22 | ```bash 23 | yo cordova-plugin-devbed 24 | ``` 25 | 26 | - Precondition 27 | - You need to install Android SDK if you want to choice Android as a target 28 | - You should run the generator on Mac OS if you want to choice iOS as a target 29 | 30 | ### Getting To Know This Generator 31 | 32 | - test runner 33 | - The test app includes [cordova-plugin-test-framework](https://github.com/apache/cordova-plugin-test-framework) 34 | - They use Jasmine-2.0.0 35 | 36 | - How the cordova-plugin-devbed generator works 37 | 1. Create plugin itself 38 | - Kicks plugman to create simple cordova plugin 39 | - Modify plugin.xml 40 | - Change value from 'cordova.plugins.' to '' 41 | - As a result, cordova locates the plugin object at the pluginID value (ex: org.cool.plugin) 42 | 1. Add platform into the plugin 43 | - Kick plugman to add platform (ex: android/ios) into the plugin 44 | 1. Add package.json to plugin 45 | - The generator adds package.json and some recommended files into plugin directory. 46 | 1. Add test plugin 47 | - The generator adds the test plugin files for cordova-plugin-test-framework 48 | 1. Create test application 49 | - The generator kicks cordova to create application 50 | 1. Add platform into the application 51 | - Call cordova-lib as 'cordova platform add' 52 | 1. Add the plugin to the test app 53 | - Call as like 'cordova plugin add' 54 | 1. Add test plugin into test app 55 | - cordova-plugin-test-framework requires test plugin to testing target plugin 56 | 1. Add cordova-plugin-test-framework 57 | - 'cordova plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework.git' 58 | - Modify config.xml 59 | - Change value from 'index.html' to 'cdvtests/index.html' 60 | 61 | #### JP 62 | - test runner について 63 | - [cordova-plugin-test-framework](https://github.com/apache/cordova-plugin-test-framework) を採用 64 | - Jasmine-2.0.0 を実行している 65 | 66 | - generator の作業内容 67 | 1. plugin の生成 68 | - plugman により、Cordova plugin のひな形作成 69 | - ひな形のうち、plugin.xml の一部を修正。 70 | - の値を cordova.plugins. から に変更 71 | - JavaScript からアクセスする際の object が plugin ID で示す位置 (ex: org.cool.plugin) に置かれるようになる 72 | 1. plugin に platform を追加 73 | - plugman に対して platform (ex: android/ios) を追加 74 | 1. package.json を追加 75 |  - plugin に対して package.json 等の recommended ファイルを追加 76 | 1. test plugin を追加 77 | - plugin に対して cordova-plugin-test-framework 用の plugin コードを追加する 78 | 1. テスト用アプリケーション生成 79 | - cordova create 相当の作業により、アプリケーションひな形を生成 80 | 1. アプリに platform を追加 81 | - cordova platform add 相当の作業 82 | 1. アプリに plugin を追加 83 | - 先に作成した plugin をアプリに追加 84 | - cordova plugin add 相当 85 | 1. アプリにテスト plugin を追加 86 | - cordova-plugin-test-framework で参照するテスト plugin をアプリに追加 87 | 1. cordova-plugin-test-framework を追加 88 | - cordova plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework.git 相当 89 | - config.xml の一部を修正 90 | - を index.html から cdvtests/index.html に変更 91 | 92 | ## Known problem 93 | - [2015.6.8] Cordova CLI recommend using 'cordova-plugin-cool-coolplugin' style for plugin ID. 94 | - http://cordova.apache.org/announcements/2015/04/21/plugins-release-and-move-to-npm.html 95 | - But current plugman does not accept such style when adding android platform 96 | - package %pluginID%; in base.java, it causes compile error due to the ID includes minus(-) in it. 97 | - Since the generator uses plugman to add platform, I keep the old style id until the problem will be resolved. 98 | 99 | ## Contribution 100 | We're welcome your contribution to our project. 101 | - If you find a bug or mistake, please submit a ticket to the issue 102 | - Of cause publishing Pull Request is welcome 103 | - If you want to add or modify the feature, please submit issue 104 | - Publishing Pull Request without discussing the feature change on the issue would be ignored. 105 | - Please explain the aim of the new feature on the issue and let us discuss the rough architecture to realize the feature. 106 | 107 | ## License 108 | 109 | Copyright 2015 Sony Corporation 110 | 111 | 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 112 | 113 | http://www.apache.org/licenses/LICENSE-2.0 114 | 115 | 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. 116 | 117 | -------------------------------------------------------------------------------- /app/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var assert = require('assert'); 3 | var Q = require('q'); 4 | var yeoman = require('yeoman-generator'); 5 | var chalk = require('chalk'); 6 | var yosay = require('yosay'); 7 | var cordova_lib = require('cordova-lib'); 8 | var plugman = cordova_lib.plugman; 9 | var cordova = cordova_lib.cordova; 10 | 11 | //============================================================================ 12 | // CONFIGURE 13 | // 14 | var TEST_FRAMEWORK = 'http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework.git'; 15 | 16 | //============================================================================ 17 | // Yeoman generator implementation 18 | // 19 | module.exports = yeoman.generators.Base.extend({ 20 | 21 | constructor: function (args, options, config) { 22 | yeoman.generators.Base.apply(this, arguments); 23 | this.props = options; 24 | }, 25 | 26 | initializing: function () { 27 | this.pkg = require('../package.json'); 28 | }, 29 | 30 | //=========================================================================== 31 | // Prompting 32 | //--------------------------------------------------------------------------- 33 | // Input project settings 34 | prompting: function () { 35 | var done = this.async(); 36 | 37 | // Have Yeoman greet the user. 38 | this.log(yosay( 39 | 'Welcome to the cat\'s pajamas ' + chalk.red('CordovaPluginDevbed') + ' generator!' 40 | )); 41 | 42 | var self = this; 43 | self._promptPluginName() 44 | .then( function(){ return self._promptDomainName(); } ) 45 | .then( function(){ return self._promptPluginID(); } ) 46 | .then( function(){ return self._promptPluginVersion(); } ) 47 | .then( function(){ return self._promptPluginPlatforms(); } ) 48 | .then( function(){ 49 | // remaining adjustments 50 | self.props.testbedName = self.props.pluginName + '_TestBed'; 51 | self.props.testbedID = self.props.pluginID + '-testbed'; 52 | self.props.TEST_FRAMEWORK = TEST_FRAMEWORK; 53 | 54 | done(); 55 | }); 56 | }, 57 | 58 | //-------------------------------------------------------------------------- 59 | // pluginName 60 | // 61 | _promptPluginName: function() { 62 | var self = this; 63 | return Q.Promise( function(resolve, reject, notify ){ 64 | var prompts = [{ 65 | type: 'input', 66 | name: 'pluginName', 67 | message: 'Enter the name of the plugin.', 68 | default: 'CoolPlugin' 69 | }]; 70 | 71 | self.prompt(prompts, function (answers) { 72 | self.props.pluginName = answers.pluginName; 73 | resolve(); 74 | }); 75 | }); 76 | }, 77 | 78 | //-------------------------------------------------------------------------- 79 | // domainName 80 | // 81 | _promptDomainName: function() { 82 | var self = this; 83 | return Q.Promise( function(resolve, reject, notify ){ 84 | var prompts = [{ 85 | type: 'input', 86 | name: 'domainName', 87 | message: 'Enter the domain name of your company/organization.', 88 | default: 'cool.org' 89 | }]; 90 | 91 | self.prompt(prompts, function (answers) { 92 | self.props.domainName = answers.domainName; 93 | resolve(); 94 | }); 95 | }); 96 | }, 97 | 98 | //-------------------------------------------------------------------------- 99 | // pluginID 100 | // 101 | _promptPluginID: function() { 102 | var self = this; 103 | return Q.Promise(function (resolve, reject, notify) { 104 | // var org = self._pickOrganizationName( self.props.domainName ).toLowerCase(); 105 | var revDomain = self._createReverseDomain( self.props.domainName ).toLowerCase(); 106 | var name = self.props.pluginName.toLowerCase(); 107 | 108 | var prompts = [{ 109 | type: 'input', 110 | name: 'pluginID', 111 | message: 'Enter an ID for the plugin', 112 | // default: (org && name) ? 'cordova-plugin-' + org + '-' + name : 'cordova-plugin-org-coolplugin', 113 | default: (revDomain && name) ? revDomain + '.' + name : 'org.cool.coolplugin', 114 | }]; 115 | 116 | self.prompt(prompts, function (answers) { 117 | self.props.pluginID = answers.pluginID; 118 | var organization = self._createHyphenizedReverseOrganizationName( self.props.domainName ).toLowerCase(); 119 | self.props.packageID = 'cordova-plugin-' + organization + '-' + name; 120 | resolve(); 121 | }); 122 | }); 123 | }, 124 | 125 | //-------------------------------------------------------------------------- 126 | // pluginVersion 127 | // 128 | _promptPluginVersion: function() { 129 | var self = this; 130 | return Q.Promise(function (resolve, reject, notify) { 131 | var prompts = [{ 132 | type: 'input', 133 | name: 'pluginVersion', 134 | message: 'Enter a version for the plugin. ex: 0.0.1', 135 | default: '0.0.1' 136 | }]; 137 | 138 | self.prompt(prompts, function (answers) { 139 | self.props.pluginVersion = answers.pluginVersion; 140 | resolve(); 141 | }); 142 | }); 143 | }, 144 | 145 | //-------------------------------------------------------------------------- 146 | // pluginPlatforms 147 | // 148 | _promptPluginPlatforms: function() { 149 | var self = this; 150 | return Q.Promise(function (resolve, reject, notify) { 151 | var prompts = [{ 152 | type: 'checkbox', 153 | name: 'pluginPlatforms', 154 | message: 'Enter the platforms the plugin supports. ex: android, ios', 155 | choices: ['android', 'ios'], 156 | default: 'android' 157 | }]; 158 | 159 | self.prompt(prompts, function (answers) { 160 | self.props.pluginPlatforms = answers.pluginPlatforms; 161 | resolve(); 162 | }); 163 | }); 164 | }, 165 | 166 | //========================================================================== 167 | // Run the generator 168 | // 169 | runGenerator: function() { 170 | var self = this; 171 | 172 | //------------------------------------------------------------------------ 173 | // Run plugman: create plugin 174 | // 175 | Q.fcall( function() { 176 | return self._waitForComposeWith( 'cordova-plugin-devbed:_plugin', {options: self.props}); 177 | }).then( function() { 178 | return self._waitForComposeWith( 'cordova-plugin-devbed:_plugin_platform', {options: self.props}); 179 | }).then( function() { 180 | return self._waitForComposeWith( 'cordova-plugin-devbed:_plugin_packagejson', {options: self.props}); 181 | }).then( function() { 182 | return self._waitForComposeWith( 'cordova-plugin-devbed:_plugin_tests', {options: self.props}); 183 | }) 184 | 185 | //------------------------------------------------------------------------ 186 | // Create the simple app with cordova command 187 | // 188 | .then( function() { 189 | return self._waitForComposeWith('cordova-plugin-devbed:_testbed', {options: self.props}); 190 | }).then( function() { 191 | return self._waitForComposeWith('cordova-plugin-devbed:_testbed_platform', {options: self.props}); 192 | }) 193 | 194 | //------------------------------------------------------------------------ 195 | // Add plugin 196 | // 197 | .then( function() { 198 | return self._waitForComposeWith('cordova-plugin-devbed:_testbed_add_plugin', {options: self.props}); 199 | }).then( function() { 200 | return self._waitForComposeWith('cordova-plugin-devbed:_testbed_add_test_plugin', {options: self.props}); 201 | }) 202 | 203 | //------------------------------------------------------------------------ 204 | // Add plugin test framework (org.apache.cordova.test-framework) 205 | // 206 | .then( function() { 207 | return self._waitForComposeWith('cordova-plugin-devbed:_testbed_testframework', {options: self.props}); 208 | }); 209 | }, 210 | 211 | //=========================================================================== 212 | // Utility functions for this generator 213 | //=========================================================================== 214 | //--------------------------------------------------------------------------- 215 | // Deferred object wrapper for composeWith 216 | // 217 | _waitForComposeWith: function( namespace, opt, settings ){ 218 | var df = Q.defer(); 219 | var done = function () { 220 | df.resolve(); 221 | }; 222 | 223 | opt.options = opt.options || {}; 224 | opt.options.done = done; 225 | 226 | this.composeWith(namespace, opt, settings); 227 | 228 | return df.promise; 229 | }, 230 | 231 | //--------------------------------------------------------------------------- 232 | // Pickup the company/organization name from domain name 233 | // 234 | // cool.org -> cool 235 | // dev.plugin.cool.org -> cool-plugin-dev 236 | _createHyphenizedReverseOrganizationName: function( domainName ) { 237 | if(! domainName ) { return 'org'; } // Quick return 238 | var aryDomain = domainName.split('.') 239 | aryDomain.reverse().shift(); 240 | return aryDomain.join('-'); 241 | }, 242 | 243 | // cool.org -> org.cool 244 | // dev.plugin.cool.org -> org.cool.plugin.dev 245 | _createReverseDomain: function( domainName ) { 246 | return domainName ? domainName.split('.').reverse().join('.') : 'org'; 247 | }, 248 | 249 | 250 | }); 251 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | --------------------------------------------------------------------------------