├── .coveralls.yml ├── .editorconfig ├── .gitattributes ├── .gitignore ├── .jshintrc ├── .travis.yml ├── LICENSE ├── README.md ├── app ├── examples.js ├── index.js └── templates │ ├── _Gruntfile.js │ ├── _bower.json │ ├── _package.json │ ├── app │ ├── _index.html │ ├── _index.js │ ├── _main.css │ └── _package.json │ ├── editorconfig │ ├── gitignore │ ├── jshintrc │ ├── linux │ ├── amd64 │ │ └── libudev.so.0.6.1 │ ├── application.desktop │ ├── debPackage.sh │ ├── description-pak │ ├── i386 │ │ └── libudev.so.0.6.1 │ ├── install.sh │ ├── rpmPackage.sh │ └── run.sh │ ├── mac │ ├── _Info.plist.tmp │ ├── background.png │ ├── dmgStyler.applescript │ ├── icon.icns │ └── package.sh │ └── travis.yml ├── download ├── index.js └── templates │ └── _.yo-rc.json ├── package.json └── test ├── prompt-github.js ├── prompt.js ├── test-creation.js └── test-load.js /.coveralls.yml: -------------------------------------------------------------------------------- 1 | repo_token: wgdUspAL7gRfktqDqUl1g4bEHXh3X7jsT 2 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 4 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | node_modules/ 3 | temp/ 4 | .DS_Store 5 | dist/ 6 | test/tmp 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 | "regexp": true, 15 | "undef": true, 16 | "unused": true, 17 | "strict": true, 18 | "trailing": true, 19 | "smarttabs": true, 20 | "white": true 21 | } 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '0.10' 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2013 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # generator-node-webkit 2 | 3 | [](https://gitter.im/Dica-Developer/generator-node-webkit?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 4 | [](https://travis-ci.org/Dica-Developer/generator-node-webkit) 5 | [](https://david-dm.org/Dica-Developer/generator-node-webkit) 6 | [](https://david-dm.org/Dica-Developer/generator-node-webkit#info=devDependencies) 7 | [](http://badge.fury.io/js/generator-node-webkit) 8 | [](https://coveralls.io/r/Dica-Developer/generator-node-webkit) 9 | [](https://www.npmjs.org/package/generator-node-webkit) 10 | [](https://www.npmjs.org/package/generator-node-webkit) 11 | [](http://en.wikipedia.org/wiki/MIT_License) 12 | [](https://github.com/Dica-Developer/generator-node-webkit/issues) 13 | [](https://waffle.io/dica-developer/generator-node-webkit) 14 | 15 | Required software: 16 | 17 | [Node.js](http://nodejs.org/ "nodejs") 18 | 19 | [Yeoman](http://yeoman.io/ "Yeoman") 20 | 21 | 22 | To install generator-node-webkit from npm, run: 23 | 24 | ``` 25 | $ npm install -g generator-node-webkit 26 | ``` 27 | 28 | Finally, initiate the generator: 29 | 30 | ``` 31 | $ yo node-webkit 32 | ``` 33 | 34 | 35 | For further informations, please visit our [Wiki](https://github.com/Dica-Developer/generator-node-webkit/wiki "Wiki") 36 | 37 | ## We would like to thank 38 | 39 | [Jim Buck](https://github.com/JimmyBoh "JimmyBoh") 40 | 41 | [Andy Matthews](https://github.com/commadelimited "commadelimited") 42 | 43 | [Zack Lalanne](https://github.com/zlalanne "zlalanne") 44 | 45 | for helping to make it easy to develop cross platform apps. 46 | 47 | 48 | ## License 49 | 50 | [MIT License](http://en.wikipedia.org/wiki/MIT_License) 51 | -------------------------------------------------------------------------------- /app/examples.js: -------------------------------------------------------------------------------- 1 | var when = require('when'); 2 | var GitHubApi = require('github'); 3 | var request = require('request'); 4 | var fs = require('fs-extra'); 5 | var DecompressZip = require('decompress-zip'); 6 | var url = require('url'); 7 | 8 | var proxy = process.env.http_proxy || process.env.HTTP_PROXY || process.env.https_proxy || process.env.HTTPS_PROXY || null; 9 | var githubOptions = { 10 | version: '3.0.0' 11 | }; 12 | 13 | if (proxy) { 14 | githubOptions.proxy = {}; 15 | githubOptions.proxy.host = url.parse(proxy).hostname; 16 | githubOptions.proxy.port = url.parse(proxy).port; 17 | } 18 | 19 | var github = new GitHubApi(githubOptions); 20 | 21 | function Examples(yeoman) { 22 | this.yeoman = yeoman; 23 | this.entries = []; 24 | } 25 | 26 | Examples.prototype.getExamplesOverview = function () { 27 | var defer = when.defer(); 28 | github.gitdata.getTree({ 29 | 'user': 'zcbenz', 30 | 'repo': 'nw-sample-apps', 31 | 'sha': 'master' 32 | }, 33 | function (err, resp) { 34 | defer.resolve(resp); 35 | } 36 | ); 37 | return defer.promise; 38 | }; 39 | 40 | Examples.prototype.getExampleList = function () { 41 | var _this = this; 42 | var defer = when.defer(); 43 | this.getExamplesOverview() 44 | .then(function (resp) { 45 | var list = []; 46 | resp.tree.forEach(function (treeEntry) { 47 | if ('tree' === treeEntry.type) { 48 | list.push(treeEntry.path); 49 | _this.entries.push(treeEntry); 50 | } 51 | }); 52 | defer.resolve(list); 53 | }); 54 | return defer.promise; 55 | }; 56 | 57 | Examples.prototype.downloadAndInstallExamples = function downloadAndInstallExamples(example) { 58 | this.example = example; 59 | var defer = when.defer(); 60 | 61 | this.downloadExamples() 62 | .then(this.unzipExamples.bind(this)) 63 | .then(this.installExamples.bind(this)) 64 | .then(function () { 65 | defer.resolve(); 66 | }); 67 | 68 | return defer.promise; 69 | }; 70 | 71 | Examples.prototype.downloadExamples = function downloadExamples() { 72 | var defer = when.defer(); 73 | var _this = this; 74 | if (!fs.existsSync('tmp/node-webkit-examples.zip')) { 75 | this.yeoman.log.info('Downloading node-webkit examples'); 76 | 77 | var writeStream = fs.createWriteStream('tmp/node-webkit-examples.zip'); 78 | var req = request('https://github.com/zcbenz/nw-sample-apps/archive/master.zip') 79 | .pipe(writeStream); 80 | req.on('error', function (err) { 81 | _this.yeoman.log.conflict(err); 82 | }); 83 | writeStream.on('finish', function () { 84 | defer.resolve(); 85 | }); 86 | 87 | } else { 88 | this.yeoman.log.ok('Node-webkit examples already downloaded'); 89 | defer.resolve(); 90 | } 91 | return defer.promise; 92 | }; 93 | 94 | Examples.prototype.unzipExamples = function unzipExamples() { 95 | var defer = when.defer(); 96 | var _this = this; 97 | if (fs.existsSync('tmp/node-webkit-examples.zip')) { 98 | this.yeoman.log.info('Unzip examples.'); 99 | var unzipper = new DecompressZip('tmp/node-webkit-examples.zip'); 100 | 101 | unzipper.on('error', function (error) { 102 | _this.yeoman.log.conflict('Error while unzipping "tmp/node-webkit-examples.zip"', error); 103 | defer.reject(error); 104 | }); 105 | 106 | unzipper.on('extract', function () { 107 | _this.yeoman.log.ok('Examples successfully unzipped'); 108 | defer.resolve(); 109 | }); 110 | 111 | unzipper.extract({ 112 | path: 'tmp' 113 | }); 114 | } else { 115 | defer.resolve(); 116 | } 117 | return defer.promise; 118 | }; 119 | 120 | Examples.prototype.installExamples = function installExamples() { 121 | var _this = this; 122 | var defer = when.defer(); 123 | fs.copy('tmp/nw-sample-apps-master/' + this.example, 'app', function (err) { 124 | if (err) { 125 | _this.yeoman.log.conflict('Error while copying example', err); 126 | defer.reject(err); 127 | } 128 | defer.resolve(); 129 | }); 130 | return defer.promise; 131 | }; 132 | 133 | module.exports = Examples; 134 | -------------------------------------------------------------------------------- /app/index.js: -------------------------------------------------------------------------------- 1 | /*global require*/ 2 | 'use strict'; 3 | 4 | var util = require('util'); 5 | var path = require('path'); 6 | var yeoman = require('yeoman-generator'); 7 | var url = require('url'); 8 | var GitHubApi = require('github'); 9 | var _ = require('lodash'); 10 | var readFileAsString = require("html-wiring").readFileAsString; 11 | var welcomeMessage = require('yeoman-welcome'); 12 | 13 | var Examples = require('./examples.js'); 14 | 15 | var NodeWebkitGenerator = module.exports = function NodeWebkitGenerator(args, options) { 16 | yeoman.generators.Base.apply(this, arguments); 17 | 18 | this.on('end', function () { 19 | this.installDependencies({ 20 | skipInstall: options['skip-install'] 21 | }); 22 | }); 23 | 24 | this.pkg = JSON.parse(readFileAsString(path.join(__dirname, '../package.json'))); 25 | this.github = false; 26 | }; 27 | 28 | util.inherits(NodeWebkitGenerator, yeoman.generators.Base); 29 | 30 | NodeWebkitGenerator.prototype.welcome = function welcome() { 31 | if (!this.options['skip-welcome-message']) { 32 | this.log(welcomeMessage); 33 | } 34 | }; 35 | 36 | NodeWebkitGenerator.prototype.askForAppName = function askForAppName() { 37 | var done = this.async(); 38 | var basePath = path.basename(process.env.PWD); 39 | var appName = _.camelCase(basePath); 40 | 41 | var prompts = [{ 42 | name: 'appName', 43 | message: 'What do you want to call your app? Allowed characters ^[a-zA-Z0-9]+$', 44 | default: appName, 45 | validate: function (answer) { 46 | if (!/^[a-zA-Z0-9]+$/.test(answer)) { 47 | return 'The application name should only consist of the following characters a-z, A-Z and 0-9.'; 48 | } 49 | return true; 50 | } 51 | }]; 52 | 53 | this.prompt(prompts, function (props) { 54 | this.appName = props.appName; 55 | done(); 56 | }.bind(this)); 57 | 58 | }; 59 | 60 | NodeWebkitGenerator.prototype.askForDescription = function askForDescription() { 61 | var done = this.async(); 62 | var prompts = [{ 63 | name: 'appDescription', 64 | message: 'A little description for your app?' 65 | }]; 66 | 67 | this.prompt(prompts, function (props) { 68 | this.appDescription = props.appDescription; 69 | done(); 70 | }.bind(this)); 71 | 72 | }; 73 | 74 | NodeWebkitGenerator.prototype.askForGithubName = function askForGithubName() { 75 | var done = this.async(); 76 | var prompts = [{ 77 | name: 'githubUser', 78 | message: 'Would you mind telling me your username on GitHub?', 79 | default: 'someuser' 80 | }]; 81 | 82 | this.prompt(prompts, function (props) { 83 | this.githubUser = props.githubUser; 84 | done(); 85 | }.bind(this)); 86 | }; 87 | 88 | NodeWebkitGenerator.prototype.askForInstallExamples = function askForInstallExamples() { 89 | var done = this.async(); 90 | var prompts = [{ 91 | type: 'confirm', 92 | name: 'installExamples', 93 | message: 'Do you want to install one of the node-webkit examples?', 94 | default: false 95 | }]; 96 | this.prompt(prompts, function (props) { 97 | this.installExamples = props.installExamples; 98 | done(); 99 | }.bind(this)); 100 | 101 | }; 102 | 103 | NodeWebkitGenerator.prototype.getGithubUserInfo = function getGithubUserInfo() { 104 | var done = this.async(); 105 | var _this = this; 106 | var responseClbk = function (err, responseText) { 107 | if (err) { 108 | _this.log.info('Error while fetching github user information.', err); 109 | _this.log.skip('Skip fetching github user information.'); 110 | done(); 111 | } else { 112 | var responseObject = JSON.parse(JSON.stringify(responseText)); 113 | _this.log.ok('Github informations successfully retrieved.'); 114 | _this.github = true; 115 | _this.realname = responseObject.name; 116 | _this.githubUrl = responseObject.html_url; 117 | done(); 118 | } 119 | }; 120 | 121 | if (this.githubUser !== 'someuser') { 122 | var proxy = process.env.http_proxy || process.env.HTTP_PROXY || process.env.https_proxy || process.env.HTTPS_PROXY || null; 123 | var githubOptions = { 124 | version: '3.0.0' 125 | }; 126 | 127 | if (proxy) { 128 | githubOptions.proxy = {}; 129 | githubOptions.proxy.host = url.parse(proxy).hostname; 130 | githubOptions.proxy.port = url.parse(proxy).port; 131 | } 132 | 133 | var github = new GitHubApi(githubOptions); 134 | this.log.info('Get GitHub informations'); 135 | github.user.getFrom({ 136 | user: this.githubUser 137 | }, responseClbk); 138 | } else { 139 | done(); 140 | } 141 | }; 142 | 143 | NodeWebkitGenerator.prototype.getExampleList = function getExampleList() { 144 | var done = this.async(); 145 | if (this.installExamples) { 146 | var prompts = [{ 147 | type: 'list', 148 | name: 'example', 149 | message: 'Which example do you want to install?', 150 | choices: [] 151 | }]; 152 | 153 | this.examplesAPI = new Examples(this); 154 | this.log.info('Getting list of available examples.'); 155 | this.examplesAPI.getExampleList() 156 | .then(function (list) { 157 | prompts[0].choices = list; 158 | 159 | this.prompt(prompts, function (props) { 160 | this.example = props.example; 161 | done(); 162 | }.bind(this)); 163 | }.bind(this)); 164 | } else { 165 | done(); 166 | } 167 | }; 168 | 169 | NodeWebkitGenerator.prototype.nodeWebkitSubgenerator = function createFolder() { 170 | var done = this.async(); 171 | this.invoke("node-webkit:download", {}, function () { 172 | done(); 173 | }); 174 | }; 175 | 176 | NodeWebkitGenerator.prototype.processProjectfiles = function processProjectfiles() { 177 | this.copy('editorconfig', '.editorconfig'); 178 | this.copy('jshintrc', '.jshintrc'); 179 | this.copy('gitignore', '.gitignore'); 180 | this.copy('_bower.json', 'bower.json'); 181 | this.copy('mac/dmgStyler.applescript', 'resources/mac/dmgStyler.applescript'); 182 | this.copy('mac/package.sh', 'resources/mac/package.sh'); 183 | this.copy('mac/background.png', 'resources/mac/background.png'); 184 | this.template('_package.json', 'package.json'); 185 | this.template('_Gruntfile.js', 'Gruntfile.js'); 186 | this.template('mac/_Info.plist.tmp', 'resources/mac/Info.plist.tmp'); 187 | }; 188 | 189 | NodeWebkitGenerator.prototype.processAppFiles = function processAppFiles() { 190 | var done = this.async(); 191 | if (this.installExamples) { 192 | this.examplesAPI.downloadAndInstallExamples(this.example) 193 | .then(function() { 194 | done(); 195 | }); 196 | } else { 197 | this.copy('app/_main.css', 'app/css/main.css'); 198 | this.copy('app/_index.js', 'app/js/index.js'); 199 | this.template('app/_package.json', 'app/package.json'); 200 | this.template('app/_index.html', 'app/views/index.html'); 201 | done(); 202 | } 203 | }; 204 | -------------------------------------------------------------------------------- /app/templates/_Gruntfile.js: -------------------------------------------------------------------------------- 1 | /*jshint camelcase: false*/ 2 | 3 | module.exports = function (grunt) { 4 | 'use strict'; 5 | 6 | // load all grunt tasks 7 | require('time-grunt')(grunt); 8 | require('load-grunt-tasks')(grunt); 9 | 10 | // configurable paths 11 | var config = { 12 | app: 'app', 13 | dist: 'dist', 14 | distMac32: 'dist/macOS', 15 | distMac64: 'dist/macOS', 16 | distLinux32: 'dist/Linux32', 17 | distLinux64: 'dist/Linux64', 18 | distWin: 'dist/Win', 19 | tmp: 'buildTmp', 20 | resources: 'resources' 21 | }; 22 | 23 | grunt.initConfig({ 24 | config: config, 25 | clean: { 26 | dist: { 27 | files: [{ 28 | dot: true, 29 | src: [ 30 | '<%%= config.dist %>/*', 31 | '<%%= config.tmp %>/*' 32 | ] 33 | }] 34 | }, 35 | distMac32: { 36 | files: [{ 37 | dot: true, 38 | src: [ 39 | '<%%= config.distMac32 %>/*', 40 | '<%%= config.tmp %>/*' 41 | ] 42 | }] 43 | }, 44 | distMac64: { 45 | files: [{ 46 | dot: true, 47 | src: [ 48 | '<%%= config.distMac64 %>/*', 49 | '<%%= config.tmp %>/*' 50 | ] 51 | }] 52 | }, 53 | distLinux64: { 54 | files: [{ 55 | dot: true, 56 | src: [ 57 | '<%%= config.distLinux64 %>/*', 58 | '<%%= config.tmp %>/*' 59 | ] 60 | }] 61 | }, 62 | distLinux32: { 63 | files: [{ 64 | dot: true, 65 | src: [ 66 | '<%%= config.distLinux32 %>/*', 67 | '<%%= config.tmp %>/*' 68 | ] 69 | }] 70 | }, 71 | distWin: { 72 | files: [{ 73 | dot: true, 74 | src: [ 75 | '<%%= config.distWin %>/*', 76 | '<%%= config.tmp %>/*' 77 | ] 78 | }] 79 | } 80 | }, 81 | jshint: { 82 | options: { 83 | jshintrc: '.jshintrc' 84 | }, 85 | files: '<%%= config.app %>/js/*.js' 86 | }, 87 | copy: { 88 | appLinux: { 89 | files: [{ 90 | expand: true, 91 | cwd: '<%%= config.app %>', 92 | dest: '<%%= config.distLinux64 %>/app.nw', 93 | src: '**' 94 | }] 95 | }, 96 | appLinux32: { 97 | files: [{ 98 | expand: true, 99 | cwd: '<%%= config.app %>', 100 | dest: '<%%= config.distLinux32 %>/app.nw', 101 | src: '**' 102 | }] 103 | }, 104 | appMacos32: { 105 | files: [{ 106 | expand: true, 107 | cwd: '<%%= config.app %>', 108 | dest: '<%%= config.distMac32 %>/node-webkit.app/Contents/Resources/app.nw', 109 | src: '**' 110 | }, { 111 | expand: true, 112 | cwd: '<%%= config.resources %>/mac/', 113 | dest: '<%%= config.distMac32 %>/node-webkit.app/Contents/', 114 | filter: 'isFile', 115 | src: '*.plist' 116 | }, { 117 | expand: true, 118 | cwd: '<%%= config.resources %>/mac/', 119 | dest: '<%%= config.distMac32 %>/node-webkit.app/Contents/Resources/', 120 | filter: 'isFile', 121 | src: '*.icns' 122 | }, { 123 | expand: true, 124 | cwd: '<%%= config.app %>/../node_modules/', 125 | dest: '<%%= config.distMac32 %>/node-webkit.app/Contents/Resources/app.nw/node_modules/', 126 | src: '**' 127 | }] 128 | }, 129 | appMacos64: { 130 | files: [{ 131 | expand: true, 132 | cwd: '<%%= config.app %>', 133 | dest: '<%%= config.distMac64 %>/node-webkit.app/Contents/Resources/app.nw', 134 | src: '**' 135 | }, { 136 | expand: true, 137 | cwd: '<%%= config.resources %>/mac/', 138 | dest: '<%%= config.distMac64 %>/node-webkit.app/Contents/', 139 | filter: 'isFile', 140 | src: '*.plist' 141 | }, { 142 | expand: true, 143 | cwd: '<%%= config.resources %>/mac/', 144 | dest: '<%%= config.distMac64 %>/node-webkit.app/Contents/Resources/', 145 | filter: 'isFile', 146 | src: '*.icns' 147 | }, { 148 | expand: true, 149 | cwd: '<%%= config.app %>/../node_modules/', 150 | dest: '<%%= config.distMac64 %>/node-webkit.app/Contents/Resources/app.nw/node_modules/', 151 | src: '**' 152 | }] 153 | }, 154 | webkit32: { 155 | files: [{ 156 | expand: true, 157 | cwd: '<%%=config.resources %>/node-webkit/MacOS32', 158 | dest: '<%%= config.distMac32 %>/', 159 | src: '**' 160 | }] 161 | }, 162 | webkit64: { 163 | files: [{ 164 | expand: true, 165 | cwd: '<%%=config.resources %>/node-webkit/MacOS64', 166 | dest: '<%%= config.distMac64 %>/', 167 | src: '**' 168 | }] 169 | }, 170 | copyWinToTmp: { 171 | files: [{ 172 | expand: true, 173 | cwd: '<%%= config.resources %>/node-webkit/Windows/', 174 | dest: '<%%= config.tmp %>/', 175 | src: '**' 176 | }] 177 | } 178 | }, 179 | compress: { 180 | appToTmp: { 181 | options: { 182 | archive: '<%%= config.tmp %>/app.zip' 183 | }, 184 | files: [{ 185 | expand: true, 186 | cwd: '<%%= config.app %>', 187 | src: ['**'] 188 | }] 189 | }, 190 | finalWindowsApp: { 191 | options: { 192 | archive: '<%%= config.distWin %>/<%= appName %>.zip' 193 | }, 194 | files: [{ 195 | expand: true, 196 | cwd: '<%%= config.tmp %>', 197 | src: ['**'] 198 | }] 199 | } 200 | }, 201 | rename: { 202 | macApp32: { 203 | files: [{ 204 | src: '<%%= config.distMac32 %>/node-webkit.app', 205 | dest: '<%%= config.distMac32 %>/<%= appName %>.app' 206 | }] 207 | }, 208 | macApp64: { 209 | files: [{ 210 | src: '<%%= config.distMac64 %>/node-webkit.app', 211 | dest: '<%%= config.distMac64 %>/<%= appName %>.app' 212 | }] 213 | }, 214 | zipToApp: { 215 | files: [{ 216 | src: '<%%= config.tmp %>/app.zip', 217 | dest: '<%%= config.tmp %>/app.nw' 218 | }] 219 | } 220 | } 221 | }); 222 | 223 | grunt.registerTask('chmod32', 'Add lost Permissions.', function () { 224 | var fs = require('fs'), 225 | path = config.distMac32 + '/<%= appName %>.app/Contents/'; 226 | if (fs.existsSync(path + 'Frameworks/node-webkit Helper EH.app/Contents/MacOS/node-webkit Helper EH')) { 227 | fs.chmodSync(path + 'Frameworks/node-webkit Helper EH.app/Contents/MacOS/node-webkit Helper EH', '555'); 228 | } else { 229 | fs.chmodSync(path + 'Frameworks/nwjs Helper EH.app/Contents/MacOS/nwjs Helper EH', '555'); 230 | } 231 | if (fs.existsSync(path + 'Frameworks/node-webkit Helper NP.app/Contents/MacOS/node-webkit Helper NP')) { 232 | fs.chmodSync(path + 'Frameworks/node-webkit Helper NP.app/Contents/MacOS/node-webkit Helper NP', '555'); 233 | } else { 234 | fs.chmodSync(path + 'Frameworks/nwjs Helper NP.app/Contents/MacOS/nwjs Helper NP', '555'); 235 | } 236 | if (fs.existsSync(path + 'Frameworks/node-webkit Helper.app/Contents/MacOS/node-webkit Helper')) { 237 | fs.chmodSync(path + 'Frameworks/node-webkit Helper.app/Contents/MacOS/node-webkit Helper', '555'); 238 | } else { 239 | fs.chmodSync(path + 'Frameworks/nwjs Helper.app/Contents/MacOS/nwjs Helper', '555'); 240 | } 241 | if (fs.existsSync(path + 'MacOS/node-webkit')) { 242 | fs.chmodSync(path + 'MacOS/node-webkit', '555'); 243 | } else { 244 | fs.chmodSync(path + 'MacOS/nwjs', '555'); 245 | } 246 | }); 247 | 248 | grunt.registerTask('chmod64', 'Add lost Permissions.', function () { 249 | var fs = require('fs'), 250 | path = config.distMac64 + '/<%= appName %>.app/Contents/'; 251 | if (fs.existsSync(path + 'Frameworks/node-webkit Helper EH.app/Contents/MacOS/node-webkit Helper EH')) { 252 | fs.chmodSync(path + 'Frameworks/node-webkit Helper EH.app/Contents/MacOS/node-webkit Helper EH', '555'); 253 | } else { 254 | fs.chmodSync(path + 'Frameworks/nwjs Helper EH.app/Contents/MacOS/nwjs Helper EH', '555'); 255 | } 256 | if (fs.existsSync(path + 'Frameworks/node-webkit Helper NP.app/Contents/MacOS/node-webkit Helper NP')) { 257 | fs.chmodSync(path + 'Frameworks/node-webkit Helper NP.app/Contents/MacOS/node-webkit Helper NP', '555'); 258 | } else { 259 | fs.chmodSync(path + 'Frameworks/nwjs Helper NP.app/Contents/MacOS/nwjs Helper NP', '555'); 260 | } 261 | if (fs.existsSync(path + 'Frameworks/node-webkit Helper.app/Contents/MacOS/node-webkit Helper')) { 262 | fs.chmodSync(path + 'Frameworks/node-webkit Helper.app/Contents/MacOS/node-webkit Helper', '555'); 263 | } else { 264 | fs.chmodSync(path + 'Frameworks/nwjs Helper.app/Contents/MacOS/nwjs Helper', '555'); 265 | } 266 | if (fs.existsSync(path + 'MacOS/node-webkit')) { 267 | fs.chmodSync(path + 'MacOS/node-webkit', '555'); 268 | } else { 269 | fs.chmodSync(path + 'MacOS/nwjs', '555'); 270 | } 271 | }); 272 | 273 | grunt.registerTask('createLinuxApp', 'Create linux distribution.', function (version) { 274 | var done = this.async(); 275 | var childProcess = require('child_process'); 276 | var exec = childProcess.exec; 277 | var path = './' + (version === 'Linux64' ? config.distLinux64 : config.distLinux32); 278 | exec('mkdir -p ' + path + '; cp resources/node-webkit/' + version + '/nw.pak ' + path + ' && cp resources/node-webkit/' + version + '/nw ' + path + '/node-webkit && cp resources/node-webkit/' + version + '/icudtl.dat ' + path + '/icudtl.dat', function (error, stdout, stderr) { 279 | var result = true; 280 | if (stdout) { 281 | grunt.log.write(stdout); 282 | } 283 | if (stderr) { 284 | grunt.log.write(stderr); 285 | } 286 | if (error !== null) { 287 | grunt.log.error(error); 288 | result = false; 289 | } 290 | done(result); 291 | }); 292 | }); 293 | 294 | grunt.registerTask('createWindowsApp', 'Create windows distribution.', function () { 295 | var done = this.async(); 296 | var concat = require('concat-files'); 297 | concat([ 298 | 'buildTmp/nw.exe', 299 | 'buildTmp/app.nw' 300 | ], 'buildTmp/<%= appName %>.exe', function () { 301 | var fs = require('fs'); 302 | fs.unlink('buildTmp/app.nw', function (error, stdout, stderr) { 303 | if (stdout) { 304 | grunt.log.write(stdout); 305 | } 306 | if (stderr) { 307 | grunt.log.write(stderr); 308 | } 309 | if (error !== null) { 310 | grunt.log.error(error); 311 | done(false); 312 | } else { 313 | fs.unlink('buildTmp/nw.exe', function (error, stdout, stderr) { 314 | var result = true; 315 | if (stdout) { 316 | grunt.log.write(stdout); 317 | } 318 | if (stderr) { 319 | grunt.log.write(stderr); 320 | } 321 | if (error !== null) { 322 | grunt.log.error(error); 323 | result = false; 324 | } 325 | done(result); 326 | }); 327 | } 328 | }); 329 | }); 330 | }); 331 | 332 | grunt.registerTask('setVersion', 'Set version to all needed files', function (version) { 333 | var config = grunt.config.get(['config']); 334 | var appPath = config.app; 335 | var resourcesPath = config.resources; 336 | var mainPackageJSON = grunt.file.readJSON('package.json'); 337 | var appPackageJSON = grunt.file.readJSON(appPath + '/package.json'); 338 | var infoPlistTmp = grunt.file.read(resourcesPath + '/mac/Info.plist.tmp', { 339 | encoding: 'UTF8' 340 | }); 341 | var infoPlist = grunt.template.process(infoPlistTmp, { 342 | data: { 343 | version: version 344 | } 345 | }); 346 | mainPackageJSON.version = version; 347 | appPackageJSON.version = version; 348 | grunt.file.write('package.json', JSON.stringify(mainPackageJSON, null, 2), { 349 | encoding: 'UTF8' 350 | }); 351 | grunt.file.write(appPath + '/package.json', JSON.stringify(appPackageJSON, null, 2), { 352 | encoding: 'UTF8' 353 | }); 354 | grunt.file.write(resourcesPath + '/mac/Info.plist', infoPlist, { 355 | encoding: 'UTF8' 356 | }); 357 | }); 358 | 359 | grunt.registerTask('createPlistFile', 'set node webkit and app relevant information to a new plist file', function() { 360 | var metadata = grunt.file.readJSON('.yo-rc.json'); 361 | var resourcesPath = config.resources; 362 | var nwExecuteable = 'nwjs'; 363 | if (metadata.nodeWebkitVersion.indexOf('v0.8.') === 0 || metadata.nodeWebkitVersion.indexOf('v0.9.') === 0 || metadata.nodeWebkitVersion.indexOf('v0.10.') === 0 || metadata.nodeWebkitVersion.indexOf('v0.11.') === 0) { 364 | nwExecuteable = 'node-webkit'; 365 | } 366 | var infoPlistTmp = grunt.file.read(resourcesPath + '/mac/Info.plist.tmp', { 367 | encoding: 'UTF8' 368 | }); 369 | var infoPlist = grunt.template.process(infoPlistTmp, { 370 | data: { 371 | nwExecutableName: nwExecuteable 372 | } 373 | }); 374 | grunt.file.write(resourcesPath + '/mac/Info.plist', infoPlist, { 375 | encoding: 'UTF8' 376 | }); 377 | }) 378 | 379 | grunt.registerTask('dist-linux', [ 380 | 'jshint', 381 | 'clean:distLinux64', 382 | 'copy:appLinux', 383 | 'createLinuxApp:Linux64' 384 | ]); 385 | 386 | grunt.registerTask('dist-linux32', [ 387 | 'jshint', 388 | 'clean:distLinux32', 389 | 'copy:appLinux32', 390 | 'createLinuxApp:Linux32' 391 | ]); 392 | 393 | grunt.registerTask('dist-win', [ 394 | 'jshint', 395 | 'clean:distWin', 396 | 'copy:copyWinToTmp', 397 | 'compress:appToTmp', 398 | 'rename:zipToApp', 399 | 'createWindowsApp', 400 | 'compress:finalWindowsApp' 401 | ]); 402 | 403 | grunt.registerTask('dist-mac', [ 404 | 'jshint', 405 | 'clean:distMac64', 406 | 'createPlistFile', 407 | 'copy:webkit64', 408 | 'copy:appMacos64', 409 | 'rename:macApp64', 410 | 'chmod64' 411 | ]); 412 | 413 | grunt.registerTask('dist-mac32', [ 414 | 'jshint', 415 | 'clean:distMac32', 416 | 'createPlistFile', 417 | 'copy:webkit32', 418 | 'copy:appMacos32', 419 | 'rename:macApp32', 420 | 'chmod32' 421 | ]); 422 | 423 | grunt.registerTask('check', [ 424 | 'jshint' 425 | ]); 426 | 427 | grunt.registerTask('dmg', 'Create dmg from previously created app folder in dist.', function () { 428 | var done = this.async(); 429 | var createDmgCommand = 'resources/mac/package.sh "<%= appName %>"'; 430 | require('child_process').exec(createDmgCommand, function (error, stdout, stderr) { 431 | var result = true; 432 | if (stdout) { 433 | grunt.log.write(stdout); 434 | } 435 | if (stderr) { 436 | grunt.log.write(stderr); 437 | } 438 | if (error !== null) { 439 | grunt.log.error(error); 440 | result = false; 441 | } 442 | done(result); 443 | }); 444 | }); 445 | 446 | }; 447 | -------------------------------------------------------------------------------- /app/templates/_bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "package", 3 | "version": "0.0.0", 4 | "dependencies": {} 5 | } 6 | 7 | -------------------------------------------------------------------------------- /app/templates/_package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= appName %>", 3 | "version": "0.0.0", 4 | "description": "<%= description %>", 5 | "keywords": [], 6 | <% if(github) {%> 7 | "homepage": "<%= githubUrl %>/<%= appName %>", 8 | "bugs": "<%= githubUrl %>/<%= appName %>/issues", 9 | "author": { 10 | "name": "<%= realname %>", 11 | "email": "", 12 | "url": "<%= githubUrl %>" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "git://github.com/<%= githubUser %>/<%= appName %>.git" 17 | }, 18 | <% } %> 19 | "dependencies": {}, 20 | "devDependencies": { 21 | "grunt": "~0.4.5", 22 | "grunt-contrib-concat": "~0.5.0", 23 | "grunt-contrib-jshint": "~0.10.0", 24 | "grunt-contrib-rename": "0.0.3", 25 | "grunt-contrib-compress": "^0.10.0", 26 | "grunt-contrib-clean": "~0.6.0", 27 | "grunt-contrib-copy": "~0.5.0", 28 | "load-grunt-tasks": "^0.6.0", 29 | "time-grunt": "^0.4.0", 30 | "concat-files": "~0.1.0" 31 | }, 32 | "engines": { 33 | "node": ">=0.8.0" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/templates/app/_index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |<%= appDescription %>
9 | 10 | -------------------------------------------------------------------------------- /app/templates/app/_index.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dica-Developer/generator-node-webkit/01198fd946fcf9f4d40e6da7fec711274fafee1b/app/templates/app/_index.js -------------------------------------------------------------------------------- /app/templates/app/_main.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dica-Developer/generator-node-webkit/01198fd946fcf9f4d40e6da7fec711274fafee1b/app/templates/app/_main.css -------------------------------------------------------------------------------- /app/templates/app/_package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= appName %>", 3 | "main": "views/index.html", 4 | "version": "0.0.1", 5 | "single-instance": true, 6 | "window": { 7 | "title": "<%= appName %>", 8 | "width": 650, 9 | "height": 650, 10 | "min_width": 650, 11 | "min_height": 650, 12 | "toolbar": false 13 | }, 14 | "chromium-args": "--child-clean-exit" 15 | } 16 | -------------------------------------------------------------------------------- /app/templates/editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 4 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /app/templates/gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | tmp/ 3 | .DS_Store -------------------------------------------------------------------------------- /app/templates/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": 4, 10 | "latedef": true, 11 | "newcap": true, 12 | "noarg": true, 13 | "quotmark": "single", 14 | "regexp": true, 15 | "undef": true, 16 | "unused": true, 17 | "strict": true, 18 | "trailing": true, 19 | "smarttabs": true, 20 | "white": true 21 | } 22 | -------------------------------------------------------------------------------- /app/templates/linux/amd64/libudev.so.0.6.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dica-Developer/generator-node-webkit/01198fd946fcf9f4d40e6da7fec711274fafee1b/app/templates/linux/amd64/libudev.so.0.6.1 -------------------------------------------------------------------------------- /app/templates/linux/application.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Quick Question 3 | GenericName=Communication and Collaboration tool 4 | Comment=Communication and Collaboration tool 5 | Exec=qq 6 | Icon=quickquestion 7 | Terminal=false 8 | Type=Application 9 | StartupNotify=true 10 | Categories=Tool; 11 | X-Ubuntu-Gettext-Domain=tuxtype 12 | -------------------------------------------------------------------------------- /app/templates/linux/debPackage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cp -f resources/linux/description-pak ./ 4 | checkinstall -y --install=no --fstrans=yes -D --pkgname QuickQuestion --pkgrelease 1 --reset-uids --deldoc --delspec \ 5 | --deldesc --maintainer dica-developer@mascha.me --pkgversion $1 --pkgarch amd64 --showinstall=no \ 6 | --pkgsource http://dica-developer.github.io/quickQuestion/ --pkglicense GPLv3 --pkggroup Tool resources/linux/install.sh 7 | rm description-pak 8 | -------------------------------------------------------------------------------- /app/templates/linux/description-pak: -------------------------------------------------------------------------------- 1 | Communication and Collaboration tool -------------------------------------------------------------------------------- /app/templates/linux/i386/libudev.so.0.6.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dica-Developer/generator-node-webkit/01198fd946fcf9f4d40e6da7fec711274fafee1b/app/templates/linux/i386/libudev.so.0.6.1 -------------------------------------------------------------------------------- /app/templates/linux/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | mkdir /usr/lib/quickquestion 4 | cp -r dist/app.nw /usr/lib/quickquestion/ 5 | cp dist/nw.pak /usr/lib/quickquestion/ 6 | cp dist/node-webkit /usr/lib/quickquestion/ 7 | cp dist/qq /usr/bin/ 8 | 9 | cp resources/linux/quick-question.desktop /usr/share/applications/ 10 | cp resources/icons/QQ_Colored.svg /usr/share/pixmaps/ 11 | 12 | -------------------------------------------------------------------------------- /app/templates/linux/rpmPackage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cp -f resources/linux/description-pak ./ 4 | mkdir -p ./SOURCES 5 | tar -cz app/ > ./SOURCES/QuickQuestion-$1.tgz 6 | checkinstall -y --install=no --fstrans=yes -R --pkgname QuickQuestion --pkgrelease 1 --reset-uids --deldoc --delspec \ 7 | --deldesc --maintainer dica-developer@mascha.me --pkgversion $1 --pkgarch amd64 --showinstall=no \ 8 | --pkgsource http://dica-developer.github.io/quickQuestion/ --pkglicense GPLv3 --pkggroup Tool resources/linux/install.sh 9 | mv ~/rpmbuild/RPMS/amd64/QuickQuestion-$1-1.amd64.rpm ./ 10 | rm -r ./SOURCES 11 | rm description-pak 12 | -------------------------------------------------------------------------------- /app/templates/linux/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | /usr/lib/quickquestion/node-webkit /usr/lib/quickquestion/app.nw -------------------------------------------------------------------------------- /app/templates/mac/_Info.plist.tmp: -------------------------------------------------------------------------------- 1 | 2 | 3 |