Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"presets": ["es2015"],
"presets": ["@babel/env"],
"compact": false,
"comments": false
}
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ npm-debug.log
config.json
dist

sync-config.json
sync-config.json
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Installation
Syncjs is easy to install, just execute the following

```
npm install -g syncjs
npm install -g sync
```

After this you'll have `syncjs` binary available to you.
Expand Down Expand Up @@ -57,6 +57,8 @@ syncjs init
- **Port to connect**: defaults to `22` this usually is what you want
- **Local path**: syncjs will automatically detect this as the root of your project, but if you only want to sync one specific folder, **provide it here as full path**
- **Remote path**: This is where copy of your local folder lives in the remote server. Make sure you type full path here as well.
[11:37] Silas Köhler
- **ignores**: An array of strings for files you want to ignore. You can can define strings for absolute paths or regular expression. Default ignores: /node_modules/, /.git/, /.svn/, /bower_components/, /sync-config.json/


License
Expand All @@ -65,4 +67,4 @@ MIT


## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fserkanyersen%2Fsync.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fserkanyersen%2Fsync?ref=badge_large)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fserkanyersen%2Fsync.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fserkanyersen%2Fsync?ref=badge_large)
37 changes: 19 additions & 18 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
var gulp = require("gulp");
var ts = require("gulp-typescript");
var babel = require("gulp-babel");
var rename = require("gulp-rename");
const { watch, series, src, dest } = require('gulp')
const ts = require("gulp-typescript")
const babel = require("gulp-babel");
const rename = require("gulp-rename");

gulp.task("build", function () {
var tsProject = ts.createProject(__dirname + "/tsconfig.json");
return tsProject.src()
.pipe(tsProject())
.pipe(babel())
.pipe(rename(function (path) {
path.extname = ".js";
}))
.pipe(gulp.dest("./dist"));
});
function buildTask () {
var tsProject = ts.createProject(__dirname + "/tsconfig.json");
return tsProject.src()
.pipe(tsProject())
.pipe(babel())
.pipe(rename(function (path) {
path.extname = ".js";
}))
.pipe(dest("./dist"));
}

gulp.task("watch", function() {
gulp.watch("./src/**/*.ts", ["build"]);
});
function watchTask () {
watch("./src/**/*.ts", buildTask);
}

gulp.task("default", ["build", "watch"])
exports.build = buildTask;
exports.default = series(buildTask, watchTask);
31 changes: 15 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "syncjs",
"version": "2.0.2",
"version": "2.1.1",
"main": "dist/index.js",
"preferGlobal": true,
"scripts": {
Expand All @@ -12,31 +12,30 @@
"syncjs": "bin/syncjs"
},
"dependencies": {
"chalk": "^1.1.3",
"chokidar": "^1.6.1",
"inquirer": "^1.1.2",
"chalk": "^4.1.0",
"chokidar": "^3.4.3",
"inquirer": "^7.3.3",
"jsonplus": "^1.2.1",
"minimist": "^1.2.0",
"observatory": "^1.0.0",
"prompt": "^1.0.0",
"scp2": "^0.5.0",
"upath": "^0.2.0"
"upath": "^2.0.0"
},
"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.",
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"@types/inquirer": "^7.3.1",
"@types/minimist": "^1.1.29",
"@types/node": "^14.14.2",
"babel-cli": "^6.18.0",
"babel-preset-es2015": "^6.18.0",
"babel-runtime": "^6.18.0",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-rename": "^1.2.2",
"gulp-typescript": "^3.1.2",
"typescript": "^2.0.6",
"@types/chalk": "^0.4.31",
"@types/chokidar": "^1.4.29",
"@types/inquirer": "^0.0.30",
"@types/minimist": "^1.1.29",
"@types/node": "^6.0.46"
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
"gulp-rename": "^2.0.0",
"gulp-typescript": "^6.0.0-alpha.1",
"typescript": "^4.0.3"
},
"repository": {
"type": "git",
Expand Down
14 changes: 7 additions & 7 deletions src/classes/CLI.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as chalk from "chalk";
import chalk = require("chalk");
import * as minimist from "minimist";
import inquirer = require("inquirer");

Expand Down Expand Up @@ -30,7 +30,7 @@ export default class CLI {
private lastRun: number;
private timeDiff: number;
private args: minimist.ParsedArgs;
private ui: inquirer.ui.Prompt[] = [];
private ui: any[] = []; // inquirer.ui.Prompt
private activePrompt;
private pauseEvents: Function[] = [];
public paused: boolean;
Expand Down Expand Up @@ -79,7 +79,7 @@ export default class CLI {
/**
* Write something to terminal
*/
write(msg: string | chalk.ChalkChain): boolean {
write(msg: string): boolean {
return process.stdout.write.bind(process.stdout)(msg);
}

Expand All @@ -89,12 +89,12 @@ export default class CLI {
// this.showPrompt();
}

read(question: any, hidden = false): Promise<any> {
let scheme = {
read(question: string, hidden = false): Promise<any> {
let scheme = ["questions", {
type: hidden? "password" : "input",
message: question,
name: "response"
};
name: "response",
}];

// Bad type definition
let promise = <any>inquirer.prompt(scheme);
Expand Down
4 changes: 2 additions & 2 deletions src/classes/InitConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class InitConfig2 {
console.log("Existing config found.");
} catch(e) {}

let questions: inquirer.Questions = [
let questions: inquirer.QuestionCollection = [
{
type: "input",
name: "username",
Expand All @@ -37,7 +37,7 @@ export default class InitConfig2 {
"Password in config",
"Ask password during connection",
"Private key"
]
],
},
{
type: "password",
Expand Down
23 changes: 20 additions & 3 deletions src/classes/Watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,32 @@ export default class Watcher {
private base: string = config.localPath
) {

let defaultIgnores: Array<string | RegExp> = [/node_modules/, /.git/, /.svn/, /bower_components/];
let defaultIgnores: Array<string | RegExp> = [/node_modules/, /.git/, /.svn/, /bower_components/, /sync-config.json/];

let configIgnored: Array<string | RegExp> = [];

// Create regular expressions if possible
if(this.config.ignores) {
configIgnored = this.config.ignores.map(ignoreItem => {
console.log(ignoreItem);
try {
return new RegExp(ignoreItem);
} catch(e) {
return ignoreItem;
}
});
}

this.files = chokidar.watch(base, {
ignored: defaultIgnores.concat(this.config.ignores),
ignored: defaultIgnores.concat(configIgnored),
ignoreInitial: true
});

// Attach events
["all", "add", "change", "unlink", "unlinkDir"].forEach(method => {
this.files.on(method, this.handler(method));
this.files.on(method, this.handler(method).bind(this));
});

}

ready(): Promise<void> {
Expand All @@ -44,7 +59,9 @@ export default class Watcher {
};

private handler(method: string): Function {

return (...args: string[]) => {

let path: string,
event = method;

Expand Down