diff --git a/.vscode/tasks.json b/.vscode/tasks.json index b4437d0..a637823 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,19 +1,44 @@ -{ - "version": "0.1.0", +// Available variables which can be used inside of strings. +// ${workspaceRoot}: the root folder of the team +// ${file}: the current opened file +// ${fileBasename}: the current opened file's basename +// ${fileDirname}: the current opened file's dirname +// ${fileExtname}: the current opened file's extension +// ${cwd}: the current working directory of the spawned process - // The command is tsc. Assumes that tsc has been installed using npm install -g typescript - "command": "tsc", +// { +// "version": "0.1.0", - // The command is a shell script - "isShellCommand": true, +// // The command is tsc. Assumes that tsc has been installed using npm install -g typescript +// "command": "tsc", + +// // The command is a shell script +// "isShellCommand": true, - // Show the output window only if unrecognized errors occur. - "showOutput": "silent", +// // Show the output window only if unrecognized errors occur. +// "showOutput": "silent", - // Tell the tsc compiler to use the tsconfig.json from the open folder. - "args": ["-p", "."], +// // Tell the tsc compiler to use the tsconfig.json from the open folder. +// "args": ["-p", "."], - // use the standard tsc problem matcher to find compile problems - // in the output. - "problemMatcher": "$tsc" -} +// // use the standard tsc problem matcher to find compile problems +// // in the output. +// "problemMatcher": "$tsc" +// } + +{ + "version": "0.1.0", + "command": "gulp", + "isShellCommand": true, + "tasks": [ + { + "taskName": "default", + // Make this the default build command. + "isBuildCommand": true, + // Show the output window only if unrecognized errors occur. + "showOutput": "silent", + // Use the standard less compilation problem matcher. + "problemMatcher": "$tsc" + } + ] +} \ No newline at end of file diff --git a/bin/syncjs b/bin/syncjs index ef06531..74e6c50 100755 --- a/bin/syncjs +++ b/bin/syncjs @@ -1,5 +1,5 @@ #!/usr/bin/env node var path = require('path'); -var Sync = require(path.resolve(__dirname, '../dist/src/index.js')).default; +var Sync = require(path.resolve(__dirname, '../dist/index.js')).default; new Sync(); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..71a00d1 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,16 @@ +var gulp = require('gulp'); +var ts = require('gulp-typescript'); +var babel = require('gulp-babel'); + +var tsProject = ts.createProject('./tsconfig.json', { + typescript: require('typescript') +}); + +gulp.task('default', function() { + return gulp.src(['src/**/*.ts', 'typings/**/*.ts']) + .pipe(ts(tsProject)) + .pipe(babel({ + presets: ['es2015'] + })) + .pipe(gulp.dest('dist')); +}); \ No newline at end of file diff --git a/package.json b/package.json index 3b75ccf..8c4d562 100644 --- a/package.json +++ b/package.json @@ -1,24 +1,27 @@ { "name": "sync.js", "version": "2.0.0", - "main": "dist/src/index.js", + "main": "dist/index.js", "preferGlobal": true, "scripts": { - "postinstall": "./node_modules/.bin/tsc" + "postinstall": "./node_modules/.bin/gulp" }, "bin": { "syncjs": "bin/syncjs" }, "dependencies": { + "babel-preset-es2015": "^6.3.13", "chalk": "^1.1.1", "chokidar": "^1.2.0", - "es6-promise": "^3.0.2", + "gulp": "^3.9.0", + "gulp-babel": "^6.1.1", + "gulp-typescript": "^2.10.0", "jsonplus": "^1.2.1", "minimist": "^1.2.0", "moment": "latest", "readline-sync": "^1.2.21", "scp2": "^0.2.2", - "typescript": "^1.7.*", + "typescript": "^1.8.0-dev.20151222", "upath": "^0.1.6" }, "description": "sync.js let's you keep your remote files in sync with your local copy. Whenever you make a change on your local project, sync.js uploads the changed files to remote server using `scp` command.", diff --git a/src/classes/CLI.ts b/src/classes/CLI.ts index 579bd65..b9ce368 100644 --- a/src/classes/CLI.ts +++ b/src/classes/CLI.ts @@ -1,7 +1,6 @@ import * as chalk from "chalk"; import * as readline from "readline"; import * as minimist from "minimist"; -var readlineSync = require("readline-sync"); export enum EXIT_CODE { /** @@ -25,11 +24,6 @@ export enum EXIT_CODE { INVALID_ARGUMENT = 128 } -interface ReadLineOptions { - follow?: string; - hideEchoBack?: boolean -} - export default class CLI { private rline: readline.ReadLine; @@ -43,6 +37,17 @@ export default class CLI { constructor() { // Parse arguments this.args = minimist(process.argv.slice(2)); + + try { + this.rline = readline.createInterface({ + input: process.stdin, + output: process.stdout + }); + } catch (e) { + this.write("You need to upgrade your nodejs\n"); + this.write("http://slopjong.de/2012/10/31/how-to-install-the-latest-nodejs-in-ubuntu/\n"); + process.exit(EXIT_CODE.RUNTIME_FAILURE); + } } /** @@ -85,8 +90,7 @@ export default class CLI { read(question: string, password = false): Promise { return new Promise((resolve) => { - let answer = readlineSync.question(question, { hideEchoBack: password }); - resolve(answer); + this.rline.question(question, resolve); }); } diff --git a/src/index.ts b/src/index.ts index a130015..db8febd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,4 @@ import Sync from "./classes/Sync"; -import "es6-promise"; // Main Export export default Sync; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index bbc4a66..8cf6204 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "module": "commonjs", - "target": "es5", + "target": "es6", "experimentalDecorators": true, "emitDecoratorMetadata": true, "inlineSourceMap": true, diff --git a/tsd.json b/tsd.json index 0ddf0d8..6a68bd8 100644 --- a/tsd.json +++ b/tsd.json @@ -17,9 +17,6 @@ "node/node.d.ts": { "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff" }, - "es6-promise/es6-promise.d.ts": { - "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff" - }, "moment/moment.d.ts": { "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff" }, diff --git a/typings/es6-promise/es6-promise.d.ts b/typings/es6-promise/es6-promise.d.ts deleted file mode 100644 index daf7134..0000000 --- a/typings/es6-promise/es6-promise.d.ts +++ /dev/null @@ -1,73 +0,0 @@ -// Type definitions for es6-promise -// Project: https://github.com/jakearchibald/ES6-Promise -// Definitions by: François de Campredon , vvakame -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -interface Thenable { - then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable; - then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Thenable; -} - -declare class Promise implements Thenable { - /** - * If you call resolve in the body of the callback passed to the constructor, - * your promise is fulfilled with result object passed to resolve. - * If you call reject your promise is rejected with the object passed to reject. - * For consistency and debugging (eg stack traces), obj should be an instanceof Error. - * Any errors thrown in the constructor callback will be implicitly passed to reject(). - */ - constructor(callback: (resolve : (value?: R | Thenable) => void, reject: (error?: any) => void) => void); - - /** - * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. - * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. - * Both callbacks have a single parameter , the fulfillment value or rejection reason. - * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. - * If an error is thrown in the callback, the returned promise rejects with that error. - * - * @param onFulfilled called when/if "promise" resolves - * @param onRejected called when/if "promise" rejects - */ - then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Promise; - then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Promise; - - /** - * Sugar for promise.then(undefined, onRejected) - * - * @param onRejected called when/if "promise" rejects - */ - catch(onRejected?: (error: any) => U | Thenable): Promise; -} - -declare module Promise { - /** - * Make a new promise from the thenable. - * A thenable is promise-like in as far as it has a "then" method. - */ - function resolve(value?: R | Thenable): Promise; - - /** - * Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error - */ - function reject(error: any): Promise; - - /** - * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. - * the array passed to all can be a mixture of promise-like objects and other objects. - * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. - */ - function all(promises: (R | Thenable)[]): Promise; - - /** - * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. - */ - function race(promises: (R | Thenable)[]): Promise; -} - -declare module 'es6-promise' { - var foo: typeof Promise; // Temp variable to reference Promise in local context - module rsvp { - export var Promise: typeof foo; - } - export = rsvp; -} diff --git a/typings/tsd.d.ts b/typings/tsd.d.ts index 5c85b09..d24a0b6 100644 --- a/typings/tsd.d.ts +++ b/typings/tsd.d.ts @@ -2,7 +2,6 @@ /// /// /// -/// /// /// ///