Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'cli' of github.com:milani/appjs into cli

  • Loading branch information...
commit fc82a95b7a20be262d5a05b8d45f3c3413ba53a0 2 parents ce59d1f + f91239d
@Benvie Benvie authored
View
24 bin/appjs
@@ -0,0 +1,24 @@
+#!/usr/bin/env node
+
+var fs = require('fs');
+var path = require('path');
+var nopt = require('nopt');
+var util = require('../cli/util');
+var config = require('../cli/config');
+var command = require('../cli/command');
+
+process.title = "appjs"
+process.on("uncaughtException", util.errorHandler);
+
+util.log('Parsing arguments...','verbose');
+
+var conf = nopt(config.arg_types,config.arg_shorts);
+var argv = conf.argv.remain;
+
+util.log.setLevel(conf.log || 'info');
+
+if( command[argv[0]] ){
+ command[argv.shift()].apply(conf,argv);
+} else {
+ util.log('Nothing to do or invalid command. Use help command.','warn');
+}
View
34 cli/command.js
@@ -0,0 +1,34 @@
+var fs = require('fs')
+ , path = require('path')
+ , mkdir = require('mkdirp')
+ , util = require('./util')
+ , config = require('./config')
+ , exec = require('child_process').exec;
+
+var init = exports.init = function(){
+
+ if( arguments.length > 1 ) {
+ util.abort(config.ERROR.tooMuchArguments);
+ }
+
+ var project_dir = process.cwd();
+
+ if( arguments.length == 1 ) {
+ project_dir = fs.realpathSync(arguments[0]);
+ }
+
+ // TODO create boilerplate
+
+ // TODO create launcher
+
+ util.log('OK',util.log.success);
+
+}
+
+var package = exports.package = function(){
+
+}
+
+var help = exports.help = function(){
+ console.log(config.HELP);
+}
View
43 cli/config.js
@@ -0,0 +1,43 @@
+var path = require('path');
+var util = require('./util');
+
+var logEnum = [];
+
+Object.keys(util.log.LEVELS).forEach(function (level) {
+ logEnum.push(level);
+});
+
+exports.arg_types = {
+ "compile": Boolean,
+ "embed": Boolean,
+ "entry": String,
+ "out": String,
+ "extra": Array,
+ "log" : logEnum
+};
+
+exports.arg_shorts = {
+ c: ["--compile"],
+ e: ["--embed"],
+ t: ["--entry"],
+ p: ["--extra"],
+ o: ["--out"],
+ l: ["--log"]
+};
+
+exports.ERROR = {
+ tooMuchArguments: 'Too much arguments, needs one.'
+};
+
+exports.HELP = "\n\
+Welcome to AppJS!\n\
+\n\
+\n\
+Usage: appjs <command>\n\
+\n\
+where <command> is one of:\n\
+\n\
+ init : To initialize a new project. it creates a boilerplate appjs app for you.\n\
+ \n\
+ package: It creates bundles for you project.\n\
+";
View
116 cli/initialize.js
@@ -0,0 +1,116 @@
+/**
+ * Set the title.
+ */
+
+process.title = 'appjs-initialize';
+
+/**
+ * Necessary modules and variables
+ */
+
+var util = require('../cli/util')
+ , fs = require('fs')
+ , path = require('path')
+ , platform = require('os').platform()
+ , version = require('../package.json').version
+ , arch = require('os').arch()
+ , depsDir = path.join(__dirname,'../build/Release')
+ , env = process.env.NODE_ENV || 'Debug';
+
+/**
+ * Starts installing CEF libraries
+ */
+
+function install(appjs_version) {
+
+ downloadAppJS(appjs_version,function(err){
+
+ if(err) {
+ util.log('Failed to add dependencies','error');
+ throw err;
+ }
+
+ util.log('Done!');
+ });
+
+}
+
+/**
+ * Downloads CEF binary package according to
+ * developer's platform and extracts it to
+ * deps/cef
+ */
+
+function downloadAppJS(version,cb){
+
+ var zlib = require('zlib')
+ , tar = require('tar')
+ , distUrl = 'https://github.com/downloads/milani/appjs'
+ , fileName = 'appjs_' + version + '_' + platform + '_' + arch + '.tar.gz';
+
+ var tarballUrl = distUrl + '/' + fileName
+ , gunzip = zlib.createGunzip()
+ , extracter = tar.Extract({ path: depsDir });
+
+ var errorHandler = function(err,res){
+ if ( err || res.statusCode != 200 ) {
+ cb(err || new Error(res.statusCode + ' status code downloading tarball'));
+ }
+ }
+
+ gunzip.on('error', errorHandler)
+ extracter.on('error', errorHandler)
+ extracter.on('end', function(){
+
+ if(platform == 'win32') {
+
+ try {
+ fs.rmdirSync( path.join(depsDir,'cef') );
+ } catch(e) {};
+
+ fs.rename(path.join(depsDir,fileName.replace('.tar.gz','')), path.join(depsDir,'cef'),cb);
+ } else {
+
+ try {
+ fs.unlinkSync( path.join(depsDir,'cef') );
+ } catch(e) {};
+
+ fs.symlink( path.join(depsDir,fileName.replace('.tar.gz','')), path.join(depsDir,'cef') ,cb);
+ }
+ })
+
+ download(tarballUrl,errorHandler)
+ .pipe(gunzip)
+ .pipe(extracter);
+}
+
+/**
+ * Returns a Request object
+ */
+
+function download(url,onError) {
+ var request = require('request');
+
+ util.log('Downloading necessary appjs files for '+platform+'-'+arch+'...');
+
+ var requestOpts = {
+ uri: url,
+ onResponse: true
+ }
+
+ // basic support for a proxy server
+ var proxyUrl = process.env.http_proxy
+ || process.env.HTTP_PROXY
+ || process.env.npm_config_proxy
+ if (proxyUrl) {
+ util.log('using proxy: ' + proxyUrl,'verbose');
+ requestOpts.proxy = proxyUrl
+ }
+ return request(requestOpts).on('error',onError).on('response',function(res){onError(null,res)});
+}
+
+/**
+ * Start installing appjs.node
+ */
+
+install(version);
View
26 cli/util.js
@@ -1,29 +1,3 @@
-/**
- * (The MIT License)
- *
- * Copyright (c) 2012 Morteza Milani <mrtz.milani@gmail.com> and other
- * AppJS contributors.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * 'Software'), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
-
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- **/
-
var inherits = require('util').inherits;
function MyError(msg) {
View
39 data/README.md
@@ -0,0 +1,39 @@
+# AppJS
+
+AppJS is an SDK to develop desktop applications using node. Or at least
+it is going to be!
+
+The goal is to facilitate native app development using
+tools every developer is familiar with nowadays: HTML/CSS/JS
+
+**Attention:** AppJS is under heavy development. API changes a lot until we bump version to v0.1.0
+
+## Thanks to
+
+* Brandon Benvie
+* Ali Farhadi
+* And all other AppJS contributors
+
+## License
+( The MIT License )
+
+Copyright (c) 2012 Morteza Milani and other AppJS contributors
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
62 data/package.json
@@ -0,0 +1,62 @@
+{
+ "name": "appjs",
+ "description": "AppJS is a SDK on top of nodejs to develop desktop applications using HTML/CSS/JS",
+ "version": "0.0.12",
+ "keywords": [
+ "cef",
+ "webkit",
+ "browser",
+ "canvas",
+ "html5",
+ "desktop",
+ "native",
+ "gtk",
+ "ui",
+ "sdk",
+ "cocoa"
+ ],
+ "homepage": "http://appjs.org",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/milani/appjs"
+ },
+ "author": {
+ "name": "Morteza Milani",
+ "email": "mrtz.milani@gmail.com"
+ },
+ "contributors": [
+ {
+ "name": "Brandon Benvie",
+ "email": "brandon.benvie@gmail.com"
+ }
+ ],
+ "directories": {
+ "bin": "./bin",
+ "doc": "./doc",
+ "lib": "./lib",
+ "test": "./tests"
+ },
+ "main": "./index.js",
+ "engines": {
+ "node": "0.6 || 0.8"
+ },
+ "dependencies": {
+ "mime":"1.2.5",
+ "request":"2.9.x",
+ "tar":">= 0.1.13",
+ "nopt": ">= 1.0.10",
+ "mkdirp": ">= 0.3.0",
+ "diveSync": ">= 0.2.0"
+ },
+ "devDependencies": {},
+ "optionalDependencies": {},
+ "scripts": {
+ "install": "node cli/initialize.js"
+ },
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "https://github.com/milani/appjs/blob/master/LICENSE"
+ }
+ ]
+}
View
5 package.json
@@ -42,7 +42,10 @@
"dependencies": {
"mime":"1.2.5",
"request":"2.9.x",
- "tar":">= 0.1.13"
+ "tar":">= 0.1.13",
+ "nopt": ">= 1.0.10",
+ "mkdirp": ">= 0.3.0",
+ "diveSync": ">= 0.2.0"
},
"devDependencies": {},
"optionalDependencies": {},
Please sign in to comment.
Something went wrong with that request. Please try again.