added travis + tests
This commit is contained in:
parent
2dec60ce56
commit
e28670de17
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,3 +1,6 @@
|
||||
node_modules/
|
||||
.settings/
|
||||
.idea/
|
||||
.idea/
|
||||
|
||||
ts/*.js
|
||||
ts/*.js.map
|
||||
|
16
.travis.yml
16
.travis.yml
@ -1,19 +1,19 @@
|
||||
language: node_js
|
||||
before_install:
|
||||
- nvm install stable
|
||||
- node -v
|
||||
- npm -v
|
||||
- npm install -g gulp
|
||||
- npm install gulp
|
||||
- npm install gulp-typescript
|
||||
- nvm install stable
|
||||
- node -v
|
||||
- npm -v
|
||||
- npm install -g gulp
|
||||
- npm install gulp
|
||||
- npm install gulp-typescript
|
||||
deploy:
|
||||
provider: npm
|
||||
email: npm@smart-coordination.com
|
||||
api_key:
|
||||
secure: y7l1JyBDihAYxbqfuPAUXJfY+PC7RSSCkAtXtBIjPA6wytSBnz55te/Vdy8RFgVty6O/k4hHzrhgUJMSoWKmPuGQ5bMBgkyV9OI5PPp4uEUyy5UdcJZv3cZYpGGDRjLjCHP4pF7AHdRcDUMEiE5ZrDtmUH1SBLoRswieO0TKsiMr3u45yR6rHFoPnnw1YlatoAPpiuP3SLnCrIjQeSOS7y9SL6PpakiquJNtpseVOr60sp39L6vLAeqJ7xTjjNJk23LF/60lfiKtM7QFg9qqE7cxFUWJs7Zmgfg4/hGcU9XRfDfZQgSNntcdFczPejO5juv2KOb1tzH7EhXrWlcF1yd70RBdJbcOn7O6ctHjMCGrCSn6IQPzcNWNErFELfMLsjVQUxbfHSc0iA1JxcYWeXUivrStwVOa9ufuG2KZCQZyEjra3zPdCu9yrE30c/mTace7eJXPYTsNn2tmxvTnFoTWmeQ0xL9Iyz9zceADpxjYJoJ8r4XMDWxWga5G9OPaqCINHxjKhOX0C36YEjYTaeNMNHv6F6BPLdKwQ9SmklMtcyC312nJsXwKy+KYJSoY6WqMef9Zk3ez0o09W0UkSr0qiQkyYCoNm8b1L7VrYuccPH24GE0fn8QMWmeE5TBThYbEIdt6NBoYCDeocflUm5KBrImFGo1peeYS1aQnpoQ=
|
||||
secure: XAtA2XHAr96ILKpm1VnB/Nff9hiQv3FUa/NDfGZgvJKimuF/TwU2+kXyAag/LlEQGckZ9/IDx0PTIe8x4wOvg2VyKceYktGt6G5/MHeAXwzkkM253k2CKweVtBgnpZ2doTZXeeV/h7hHuEWZbWRXIVCgM6/inaaNe4cMRGCWqwb1xmw6D8VkLpNo6PiB37gR4GfMokasgVHZEVMg2evWKk0moREGW9XKqoE6PS9TPHPHerdqFqfbmeOq3nNgHrJZkNsAJ3PPESWCe/NGEBwtYDKrPI3QlouvXmxScI9/p2VCQmdFoUxKMDsVzBdRMrCx+XxoS8x81HxubZSpnvzUlzGtznZi7e6OyAlI7xXELIO551AH4V/pNWWUPATX+7vXVDGh7aAZYme/fejisjO5Tk9aqRvohh2jCDml3ED6alHHfI0oX5UvBpOE+XwGTIJ8qpf9RrLP5DC27JWE3fqY/WoqIZX7phoKeKYLl+R7Iln/dfvepbMBgcesnBf4PuMh3Qm2l2G1bElJ/hniV1dgggwjcg50nA0Ee9sCnORPxxjdDIMwJw//NJSe+Aq5Fm1ure9oNiBYOeF0bLVQyfGIC8J8coy1xdqv2klKnGHjMMN44bjNlmDp00SaRpbdDuavyocosQVpzfA+hY2QtGV5TXFv6TLgcMYwf8gNyVNkSGE=
|
||||
on:
|
||||
tags: true
|
||||
repo: pushrocks/gulp-bootstrap
|
||||
repo: pushrocks/smartcli
|
||||
notifications:
|
||||
slack:
|
||||
secure: f5Uss0z9RPl/QcA/DroB8loyE93aOYI6bqCkrsiUscmZtlv/TVQtT4dxqGA6uvcG6iTQDBi3Ul88dQxWkRm4IqbhY35/iMaV2dHW4FVYMAh8GQMbsfL2sALCcufxD9blw47awv3iFcwhV1EeyesscjgL0JIjduk96v/7G/6QIO2838M1lzlgtj+kRUkim8qkaEs1je3gRrhMUIjLuAdscMXyUKYFMjWo9ACSjVUl30R/ZNemb18itIja6i92GotreBgcfEMczvy58ovDC7xdJUsY8LjMI01DwY+WPRnI0tAhsuI8moBwwcdM4e3bAjKjucQRjO33O5bMWRZ6QCiYd0DnCEFyCPQLJ4GSy/tkD00n8ijLHAOSV3AH1zNbdK1EAdSPQXDvlI36KJn/2hyQLoitGHVUPr76ujJWP82ypO2tgIp3XQU0dJVCxDuHnwJO2+hjdI+gCPqxNTpjeujHx3UdkTGNRjuuf9dlZ/D08fApjYxy2fxItTqo3QjP/nrqvBXUOPP8yPHpjIT4H2t5Pr4SJjBGI6X4qhKyFj6s9rA/Xu1rL+45zu1C3uC3z+u3T9UwrbzJ/cZM6r6UQvQmUvIfBNaMlg4I/diQCDIPL+Rhop2nylY3IcHmJnk2itn7kOqj1tohCpFEml5pRuSZy4udWywkdtyBAsHWFLF7oiQ=
|
||||
|
74
index.js
74
index.js
@ -1,11 +1,69 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
var path, through;
|
||||
through = require("through2");
|
||||
path = require("path");
|
||||
module.exports = function (jadeTemplate, mojo) {
|
||||
if (mojo === void 0) { mojo = undefined; }
|
||||
return through.obj(function (file, enc, cb) {
|
||||
//run callback function to signal end of plugin process.
|
||||
return cb(null, file);
|
||||
var path = require("path");
|
||||
var beautylog = require("beautylog");
|
||||
var cliff = require("cliff");
|
||||
var inquirer = require("inquirer");
|
||||
var argv = require('yargs').argv;
|
||||
//define the smartcli object
|
||||
var smartcli = {};
|
||||
//add plugins from above for direct use
|
||||
smartcli.inquirer = inquirer;
|
||||
smartcli.cliff = cliff;
|
||||
smartcli.argv = argv;
|
||||
/**
|
||||
* returns the current working directory
|
||||
* @returns {string}
|
||||
*/
|
||||
smartcli.getCwd = function () {
|
||||
return process.cwd();
|
||||
};
|
||||
/**
|
||||
* executes callback with answer to question as argument
|
||||
* @param questionString the question you want to ask the user
|
||||
* @param cb the function to execute with answer as param
|
||||
* @returns {null}
|
||||
*/
|
||||
smartcli.getAnswer = function (questionString, cb) {
|
||||
if (typeof questionString != 'string') {
|
||||
beautylog.error('no question specified');
|
||||
return null;
|
||||
}
|
||||
//make inquirer compatible question object
|
||||
var question = {
|
||||
type: "input",
|
||||
name: "userFeedback",
|
||||
message: questionString,
|
||||
validate: function (value) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
inquirer.prompt([question], function (answers) {
|
||||
var answer = answers.userFeedback;
|
||||
cb(answer);
|
||||
});
|
||||
};
|
||||
/**
|
||||
*
|
||||
* @param questionString
|
||||
* @param choiceOptions
|
||||
* @param cb
|
||||
* @returns {null}
|
||||
*/
|
||||
smartcli.getChoice = function (questionString, choiceOptions, cb) {
|
||||
if (!Array.isArray(choiceOptions)) {
|
||||
return null;
|
||||
}
|
||||
//make inquirer compatible question object
|
||||
var question = {
|
||||
type: "list",
|
||||
name: "userFeedback",
|
||||
message: questionString,
|
||||
choices: choiceOptions,
|
||||
filter: function (val) { return val.toLowerCase(); }
|
||||
};
|
||||
inquirer.prompt(question, function (answers) {
|
||||
var answer = answers.userFeedback;
|
||||
cb(answer);
|
||||
});
|
||||
};
|
||||
module.exports = smartcli;
|
||||
|
@ -24,7 +24,12 @@
|
||||
"url": "https://github.com/pushrocks/smartcli/issues"
|
||||
},
|
||||
"homepage": "https://github.com/pushrocks/smartcli",
|
||||
"dependencies": {},
|
||||
"dependencies": {
|
||||
"beautylog": "0.0.12",
|
||||
"cliff": "^0.1.10",
|
||||
"inquirer": "^0.10.1",
|
||||
"yargs": "^3.26.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp": "3.9.0",
|
||||
"gulp-typescript": "2.9.2"
|
||||
|
18
test.js
Normal file
18
test.js
Normal file
@ -0,0 +1,18 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
var smartcli = require("./index.js");
|
||||
var getAnswerTest = function () {
|
||||
smartcli.getAnswer('How do you feel?', function (answer) {
|
||||
console.log('The answer is: ' + answer);
|
||||
getChoiceTest();
|
||||
});
|
||||
};
|
||||
var getChoiceTest = function () {
|
||||
smartcli.getChoice('What to you like best?', ['Cars', 'Planes', 'Boats'], function (answer) {
|
||||
console.log('The answer is: ' + answer);
|
||||
getCwdTest();
|
||||
});
|
||||
};
|
||||
var getCwdTest = function () {
|
||||
console.log('The current directory is: ' + smartcli.getCwd());
|
||||
};
|
||||
getAnswerTest();
|
@ -1,2 +0,0 @@
|
||||
nvm use v0.12.7
|
||||
gulp
|
@ -11,6 +11,15 @@ gulp.task('compileTS', function() {
|
||||
return stream;
|
||||
});
|
||||
|
||||
gulp.task('default',['compileTS'], function() {
|
||||
gulp.task('compileTestTS', function() {
|
||||
var stream = gulp.src('../test.ts')
|
||||
.pipe(gulpTypescript({
|
||||
out: "test.js"
|
||||
}))
|
||||
.pipe(gulp.dest("../../"));
|
||||
return stream;
|
||||
});
|
||||
|
||||
gulp.task('default',['compileTS','compileTestTS'], function() {
|
||||
console.log('Typescript compiled');
|
||||
});
|
83
ts/index.ts
83
ts/index.ts
@ -1,14 +1,81 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
var path, through;
|
||||
|
||||
through = require("through2");
|
||||
path = require("path");
|
||||
var path = require("path");
|
||||
var beautylog = require("beautylog");
|
||||
var cliff = require("cliff");
|
||||
var inquirer = require("inquirer");
|
||||
var argv = require('yargs').argv;
|
||||
|
||||
module.exports = (jadeTemplate,mojo = undefined) => {
|
||||
//define the smartcli object
|
||||
var smartcli:any = {};
|
||||
|
||||
return through.obj((file, enc, cb) => {
|
||||
|
||||
//run callback function to signal end of plugin process.
|
||||
return cb(null, file);
|
||||
//add plugins from above for direct use
|
||||
smartcli.inquirer = inquirer;
|
||||
smartcli.cliff = cliff;
|
||||
smartcli.argv = argv;
|
||||
|
||||
/**
|
||||
* returns the current working directory
|
||||
* @returns {string}
|
||||
*/
|
||||
smartcli.getCwd = function () {
|
||||
return process.cwd();
|
||||
};
|
||||
|
||||
/**
|
||||
* executes callback with answer to question as argument
|
||||
* @param questionString the question you want to ask the user
|
||||
* @param cb the function to execute with answer as param
|
||||
* @returns {null}
|
||||
*/
|
||||
smartcli.getAnswer = function(questionString:string, cb) {
|
||||
if (typeof questionString != 'string') {
|
||||
beautylog.error('no question specified');
|
||||
return null;
|
||||
}
|
||||
//make inquirer compatible question object
|
||||
var question = {
|
||||
type: "input",
|
||||
name: "userFeedback",
|
||||
message: questionString,
|
||||
validate: function( value ) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
inquirer.prompt([question],function(answers){
|
||||
var answer = answers.userFeedback;
|
||||
cb(answer);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param questionString
|
||||
* @param choiceOptions
|
||||
* @param cb
|
||||
* @returns {null}
|
||||
*/
|
||||
smartcli.getChoice = function(questionString:string, choiceOptions:string[], cb) {
|
||||
if(!Array.isArray(choiceOptions)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//make inquirer compatible question object
|
||||
var question = {
|
||||
type: "list",
|
||||
name: "userFeedback",
|
||||
message: questionString,
|
||||
choices: choiceOptions,
|
||||
filter: function( val ) { return val.toLowerCase(); }
|
||||
};
|
||||
|
||||
inquirer.prompt(question,function(answers){
|
||||
var answer = answers.userFeedback;
|
||||
cb(answer);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
module.exports = smartcli;
|
||||
|
22
ts/test.ts
Normal file
22
ts/test.ts
Normal file
@ -0,0 +1,22 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
var smartcli = require("./index.js");
|
||||
|
||||
var getAnswerTest = function() {
|
||||
smartcli.getAnswer('How do you feel?',function(answer){
|
||||
console.log('The answer is: ' + answer);
|
||||
getChoiceTest();
|
||||
});
|
||||
};
|
||||
|
||||
var getChoiceTest = function() {
|
||||
smartcli.getChoice('What to you like best?',['Cars','Planes','Boats'],function(answer){
|
||||
console.log('The answer is: ' + answer);
|
||||
getCwdTest();
|
||||
});
|
||||
};
|
||||
|
||||
var getCwdTest = function(){
|
||||
console.log('The current directory is: ' + smartcli.getCwd());
|
||||
};
|
||||
|
||||
getAnswerTest();
|
Loading…
Reference in New Issue
Block a user