zeche 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -1
- package/lib/action/ssh.js +41 -6
- package/lib/service/syncService.js +4 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -22,9 +22,27 @@ zeche is a CLI software project handling tool.
|
|
|
22
22
|
|
|
23
23
|
``zeche deploy database <exactly> <from> <to>``
|
|
24
24
|
|
|
25
|
+
### Backup
|
|
26
|
+
|
|
27
|
+
#### List
|
|
28
|
+
``zeche backup list <where>``
|
|
29
|
+
|
|
30
|
+
#### Create file backup
|
|
31
|
+
``zeche backup files <what> <where>``
|
|
32
|
+
|
|
33
|
+
#### Create database backup
|
|
34
|
+
``zeche backup db all <where>``
|
|
35
|
+
|
|
36
|
+
#### Rollback
|
|
37
|
+
``zeche backup rollback <id> <where>``
|
|
38
|
+
|
|
39
|
+
#### rm
|
|
40
|
+
``zeche backup rm <id> <where>``
|
|
41
|
+
|
|
42
|
+
|
|
25
43
|
### Dump
|
|
26
44
|
|
|
27
|
-
``zeche dump <what> <where>``
|
|
45
|
+
``zeche dump <import/export> <what> <where>``
|
|
28
46
|
|
|
29
47
|
### SSH
|
|
30
48
|
|
package/lib/action/ssh.js
CHANGED
|
@@ -16,14 +16,17 @@ module.exports = class Ssh {
|
|
|
16
16
|
|
|
17
17
|
initInterface () {
|
|
18
18
|
this.program
|
|
19
|
-
.command('ssh <environment>')
|
|
19
|
+
.command('ssh <environment> [environment2]')
|
|
20
20
|
.description('Open SSH Shell')
|
|
21
|
-
.action((environment) => {
|
|
21
|
+
.action((environment, environment2) => {
|
|
22
|
+
this.services.hookService.call(`ssh.before`,
|
|
23
|
+
{environment});
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
if (environment === 'init') {
|
|
26
|
+
this.init(environment2);
|
|
27
|
+
} else {
|
|
28
|
+
this.open(environment);
|
|
29
|
+
}
|
|
27
30
|
});
|
|
28
31
|
}
|
|
29
32
|
|
|
@@ -57,6 +60,38 @@ module.exports = class Ssh {
|
|
|
57
60
|
process.stdin.resume();
|
|
58
61
|
return process.exit();
|
|
59
62
|
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
init(environment) {
|
|
66
|
+
console.log('iniinit', environment);
|
|
67
|
+
if (!_.has(this.config, `environments.${environment}`)) {
|
|
68
|
+
this.services.outputService.print(
|
|
69
|
+
`environment ${environment} does not exist in configuration`,
|
|
70
|
+
this.services.outputService.TYPE_ERROR);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const environmentObj = _.get(this.config, `environments.${environment}`);
|
|
75
|
+
|
|
76
|
+
// console.log(environmentObj);
|
|
77
|
+
|
|
78
|
+
if (!_.has(environmentObj, `ssh.key`)) {
|
|
79
|
+
this.services.outputService.print(
|
|
80
|
+
`environment ${environment} has no ssh.key configuration`,
|
|
81
|
+
this.services.outputService.TYPE_ERROR);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
this.services.outputService.print(
|
|
86
|
+
`Password: ${_.get(environmentObj, 'ssh.password')}`,
|
|
87
|
+
this.services.outputService.TYPE_INFO);
|
|
88
|
+
|
|
89
|
+
let commands = [
|
|
90
|
+
`ssh-keygen -t rsa -b 4096 -f ${_.get(environmentObj, 'ssh.key' )} -q -P ""`,
|
|
91
|
+
`cat ${_.get(environmentObj, 'ssh.key' )}.pub | ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no ${_.get(environmentObj, 'ssh.user' )}@${_.get(environmentObj, 'ssh.host' )} "cat >> ~/.ssh/authorized_keys"`
|
|
92
|
+
];
|
|
93
|
+
|
|
94
|
+
this.services.execService.exec(commands);
|
|
60
95
|
|
|
61
96
|
}
|
|
62
97
|
};
|
|
@@ -58,7 +58,7 @@ class SyncService {
|
|
|
58
58
|
localToLocal(source, target) {
|
|
59
59
|
let commands = [
|
|
60
60
|
`mkdir -p ${target}`,
|
|
61
|
-
`rsync -r ${source} ${target}`
|
|
61
|
+
`rsync -r –l ${source} ${target}`
|
|
62
62
|
];
|
|
63
63
|
this.services.execService.exec(commands);
|
|
64
64
|
}
|
|
@@ -70,7 +70,7 @@ class SyncService {
|
|
|
70
70
|
const key = targetEnvironment.ssh.key;
|
|
71
71
|
let commands = [
|
|
72
72
|
SyncService.getSSHCommand(targetEnvironment, `mkdir -p ${target}`),
|
|
73
|
-
`rsync -r -e "ssh -i ${key} ${sshParams}" ${source} ${user}@${host}:${target}`
|
|
73
|
+
`rsync -r –l -e "ssh -i ${key} ${sshParams}" ${source} ${user}@${host}:${target}`
|
|
74
74
|
];
|
|
75
75
|
this.services.execService.exec(commands);
|
|
76
76
|
}
|
|
@@ -89,7 +89,7 @@ class SyncService {
|
|
|
89
89
|
const key = sourceEnvironment.ssh.key;
|
|
90
90
|
let commands = [];
|
|
91
91
|
commands.push(`mkdir -p ${target}`);
|
|
92
|
-
commands.push(`rsync -r -e "ssh -i ${key} ${sshParams}" ${user}@${host}:${source} ${target}`);
|
|
92
|
+
commands.push(`rsync -r –l -e "ssh -i ${key} ${sshParams}" ${user}@${host}:${source} ${target}`);
|
|
93
93
|
|
|
94
94
|
this.services.execService.exec(commands);
|
|
95
95
|
}
|
|
@@ -188,4 +188,4 @@ class SyncService {
|
|
|
188
188
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
module.exports = SyncService;
|
|
191
|
+
module.exports = SyncService;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zeche",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "CLI software project handling tool",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"commander": "^2.15.1",
|
|
25
25
|
"dotenv": "^6.2.0",
|
|
26
26
|
"dotenv-expand": "^4.2.0",
|
|
27
|
-
"lodash": "^4.17.
|
|
27
|
+
"lodash": "^4.17.15",
|
|
28
28
|
"moment": "^2.23.0",
|
|
29
29
|
"opn": "^5.3.0",
|
|
30
30
|
"ora": "^3.0.0"
|