Skip to content

Commit

Permalink
Merge pull request #104 from rolldone/working
Browse files Browse the repository at this point in the history
Working
  • Loading branch information
rolldone authored Mar 25, 2022
2 parents a496217 + e3462e4 commit 6f4dedb
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 18 deletions.
33 changes: 29 additions & 4 deletions src/app/devsync/compute/Uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default class Uploader {
});
stream.on('data', (dd: any) => {
if (_consoleAction != "basic") return;
if (this._consoleCache.length >= 5000) {
if (this._consoleCache.length >= 2000) {
this._consoleCache.shift();
};
this._consoleCache.push(dd);
Expand All @@ -108,6 +108,7 @@ export default class Uploader {
})

}
let _localRecordText = "";
var _keypress = (key: string, data: any) => {
let isStop = false;
for (var a = 1; a <= 9; a++) {
Expand All @@ -129,7 +130,14 @@ export default class Uploader {
switch (data.sequence) {
case '\u0003':
return;
case '\r':
if (_localRecordText.includes("clear")) {
this._consoleCache = [];
}
_localRecordText = "";
break;
}
_localRecordText += data.sequence;
}
process.stdin.on("keypress", _keypress)
} catch (ex) {
Expand Down Expand Up @@ -163,6 +171,7 @@ export default class Uploader {
}
}
let timesCloseClick = 0;
let _localRecordText = "";
let _keypress = (key: string, data: any) => {
let isStop = false;
for (var a = 1; a <= 9; a++) {
Expand Down Expand Up @@ -204,7 +213,14 @@ export default class Uploader {
switch (data.sequence) {
case '\u0003':
return;
case '\r':
if (_localRecordText.includes("clear")) {
_consoleCaches[index] = [];
}
_localRecordText = "";
break;
}
_localRecordText += data.sequence;
}
process.stdin.on("keypress", _keypress)

Expand Down Expand Up @@ -259,7 +275,7 @@ export default class Uploader {
if (_consoleAction != index) return;
// console.log('data',_consoleAction,' and ',index);

if (_consoleCaches[index].length >= 5000) {
if (_consoleCaches[index].length >= 2000) {
_consoleCaches[index].shift();
};
_consoleCaches[index].push(dd);
Expand All @@ -269,7 +285,7 @@ export default class Uploader {
stream.stderr.on('data', (data: any) => {
// console.log('data',_consoleAction,' and ',index);
if (_consoleAction != index) return;
if (_consoleCaches[index].length >= 5000) {
if (_consoleCaches[index].length >= 2000) {
_consoleCaches[index].shift();
};
_consoleCaches[index].push(data);
Expand Down Expand Up @@ -349,7 +365,7 @@ export default class Uploader {
return;
}
if (_consoleAction != index) return;
if (_consoleCaches[index].length >= 5000) {
if (_consoleCaches[index].length >= 2000) {
_consoleCaches[index].shift();
};
_consoleCaches[index].push(data);
Expand Down Expand Up @@ -382,6 +398,7 @@ export default class Uploader {
});

let timesCloseClick = 0;
let _localRecordText = "";
let _keypress = (key: string, data: any) => {
let isStop = false;
for (var a = 1; a <= 9; a++) {
Expand Down Expand Up @@ -418,6 +435,7 @@ export default class Uploader {
if (isStop == true) {
return;
}

switch (data.sequence) {
case '\u0003':
// theClient.write("exit\r");
Expand All @@ -427,7 +445,14 @@ export default class Uploader {
case '\u001b[B':
theClient.write(data.sequence);
return;
case '\r':
if (_localRecordText.includes("clear")) {
_consoleCaches[index] = [];
}
_localRecordText = "";
break;
}
_localRecordText += data.sequence;
theClient.write(data.sequence);
}
process.stdin.on("keypress", _keypress)
Expand Down
30 changes: 24 additions & 6 deletions src/app/devsync/services/DevSyncService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,11 @@ const DevSyncService = BaseService.extend<DevSyncServiceInterface>({
// this.uploader._consoleAction = "watch";
this.uploader.startConsole(false);
for (var i = 0; i < total_tab; i++) {
this.uploader.startConsoles(i, cache_command[i], false);
if (this.uploader.getConsoleMode(i) == "local") {
this.uploader.startLocalConsoles(i, cache_command[i], false);
} else if (this.uploader.getConsoleMode(i) == "remote") {
this.uploader.startConsoles(i, cache_command[i], false);
}
}
this._actionMode = "devsync";
this.watcher.actionMode = this._actionMode;
Expand All @@ -441,12 +445,25 @@ const DevSyncService = BaseService.extend<DevSyncServiceInterface>({
case '\u001b2':
console.clear();
this._readLine.close();
process.stdin.removeListener('keypress', remoteFuncKeypress);
process.stdout.write(chalk.green('Console | ') + 'Start Console' + '\r');
for (var i = 0; i < total_tab; i++) {
this.uploader.startConsoles(i, cache_command[i], false);
if (this.uploader.getConsoleMode(i) == "local") {
this.uploader.startLocalConsoles(i, cache_command[i], false);
} else if (this.uploader.getConsoleMode(i) == "remote") {
this.uploader.startConsoles(i, cache_command[i], false);
}
}
setTimeout(() => {
this.uploader.startConsole(true, () => { });
this.uploader.startConsole(true, (action: string, props: any) => {
switch (action) {
case 'switch':
remoteFuncKeypress(null, props);
break;
case 'exit':
break;
}
});
this._actionMode = "console";
this.watcher.actionMode = this._actionMode;
}, 1000);
Expand All @@ -466,11 +483,12 @@ const DevSyncService = BaseService.extend<DevSyncServiceInterface>({
process.stdin.removeListener('keypress', remoteFuncKeypress);
process.stdout.write(chalk.green('Console | ') + 'Start Console' + '\r');
this.uploader.startConsole(false);
// console.log('adalah :: ', index, " :: ", this.uploader.getConsoleMode(index), " position :: ", consolePosition);
for (var ib = 0; ib < total_tab; ib++) {
if (ib != index) {
if (this.uploader.getConsoleMode(ib) == "local") {
this.uploader.startLocalConsoles(ib, cache_command[ib], false);
} else {
} else if (this.uploader.getConsoleMode(ib) == "remote") {
this.uploader.startConsoles(ib, cache_command[ib], false);
}
}
Expand Down Expand Up @@ -530,7 +548,7 @@ const DevSyncService = BaseService.extend<DevSyncServiceInterface>({
if (cache_command[inin] != null) {
if (this.uploader.getConsoleMode(inin) == "local") {
excuteLocalCommand('local', inin);
} else {
} else if (this.uploader.getConsoleMode(inin) == "remote") {
excuteLocalCommand('remote', inin);
}
break;
Expand All @@ -542,7 +560,7 @@ const DevSyncService = BaseService.extend<DevSyncServiceInterface>({
for (var i = 0; i < total_tab; i++) {
if (this.uploader.getConsoleMode(inin) == "local") {
this.uploader.startLocalConsoles(i, cache_command[i], false);
} else {
} else if (this.uploader.getConsoleMode(inin) == "remote") {
this.uploader.startConsoles(i, cache_command[i], false);
}
}
Expand Down
20 changes: 12 additions & 8 deletions src/app/devsync2/services/DevRsyncService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import BaseService from "@root/base/BaseService";
import { MasterDataInterface } from "@root/bootstrap/StartMasterData";
import Config, { ConfigInterface } from "../compute/Config";
import { CliInterface } from "./CliService";
import inquirer from "inquirer";
import inquirer from "inquirer";
import Watcher from "../compute/Watcher";
import { Uploader } from "../compute/Uploader";
import path from 'path';
Expand Down Expand Up @@ -533,7 +533,7 @@ const DevRsyncService = BaseService.extend<DevRsyncServiceInterface>({
for (var i = 0; i < total_tab; i++) {
if (this.uploader.getConsoleMode(i) == "local") {
this.uploader.startLocalConsoles(i, cache_command[i], false);
} else {
} else if (this.uploader.getConsoleMode(i) == "remote") {
this.uploader.startConsoles(i, cache_command[i], false);
}
}
Expand All @@ -559,7 +559,7 @@ const DevRsyncService = BaseService.extend<DevRsyncServiceInterface>({
for (var i = 0; i < total_tab; i++) {
if (this.uploader.getConsoleMode(i) == "local") {
this.uploader.startLocalConsoles(i, cache_command[i], false);
} else {
} else if (this.uploader.getConsoleMode(i) == "remote") {
this.uploader.startConsoles(i, cache_command[i], false);
}
}
Expand Down Expand Up @@ -591,11 +591,12 @@ const DevRsyncService = BaseService.extend<DevRsyncServiceInterface>({
process.stdin.removeListener('keypress', remoteFuncKeypress);
process.stdout.write(chalk.green('Console | ') + 'Start Console' + '\r');
this.uploader.startConsole(false);
// console.log('adalah :: ', this.uploader.getConsoleMode(index));
for (var ib = 0; ib < total_tab; ib++) {
if (ib != index) {
if (this.uploader.getConsoleMode(ib) == "local") {
this.uploader.startLocalConsoles(ib, cache_command[ib], false);
} else {
} else if (this.uploader.getConsoleMode(ib) == "remote") {
this.uploader.startConsoles(ib, cache_command[ib], false);
}
}
Expand Down Expand Up @@ -655,7 +656,7 @@ const DevRsyncService = BaseService.extend<DevRsyncServiceInterface>({
if (cache_command[inin] != null) {
if (this.uploader.getConsoleMode(inin) == "local") {
excuteLocalCommand('local', inin);
} else {
} else if (this.uploader.getConsoleMode(inin) == "remote") {
excuteLocalCommand('remote', inin);
}
break;
Expand All @@ -667,7 +668,7 @@ const DevRsyncService = BaseService.extend<DevRsyncServiceInterface>({
for (var i = 0; i < total_tab; i++) {
if (this.uploader.getConsoleMode(inin) == "local") {
this.uploader.startLocalConsoles(i, cache_command[i], false);
} else {
} else if (this.uploader.getConsoleMode(inin) == "remote") {
this.uploader.startConsoles(i, cache_command[i], false);
}
}
Expand Down Expand Up @@ -758,8 +759,11 @@ const DevRsyncService = BaseService.extend<DevRsyncServiceInterface>({

// process.stdin.off('keypress', remoteFuncKeypress);
this.task.done();
// console.clear();
this.construct(this._cli);
console.clear();
process.stdout.write(chalk.green('Remote | ') + 'Restarting...' + '\r');
setTimeout(() => {
this.construct(this._cli);
}, 3000);
}
var closeRemote = () => {
if (this._currentConf.devsync.script.remote.on_stop != "" && this._currentConf.devsync.script.remote.on_stop != null) {
Expand Down

0 comments on commit 6f4dedb

Please sign in to comment.