@ps-aux/nodebup 0.2.2 → 0.3.0
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/lib/bup/AggregateBackupController.js +30 -19
- package/lib/config/Config.js +6 -0
- package/lib/fs/Fs.js +1 -1
- package/lib/fs/fssync/FsSync.spec.js +2 -6
- package/lib/log/ConsoleLogger.js +5 -3
- package/lib/storage/restic/ResticClient.spec.js +5 -10
- package/lib/tools/ssh/SshKeyManager.js +1 -1
- package/package.json +3 -2
@@ -21,6 +21,8 @@ var _ContextSymbols = require("../ctx/ContextSymbols");
|
|
21
21
|
|
22
22
|
var _AppLogger = require("../log/AppLogger");
|
23
23
|
|
24
|
+
var _Path = require("../fs/path/Path");
|
25
|
+
|
24
26
|
var _StorageBackendProvider = require("../storage/StorageBackendProvider");
|
25
27
|
|
26
28
|
var _dec, _dec2, _dec3, _dec4, _class;
|
@@ -39,31 +41,44 @@ let AggregateBackupController = (_dec = (0, _inversify.injectable)(), _dec2 = fu
|
|
39
41
|
this.storageBackendProvider = storageBackendProvider;
|
40
42
|
this.cfg = cfg;
|
41
43
|
|
42
|
-
_defineProperty(this, "backup", async (
|
44
|
+
_defineProperty(this, "backup", async (aggrName, storage) => {
|
43
45
|
const aggrDir = this.cfg.pwd.resolve('.aggr');
|
44
|
-
this.
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
const aggr = this.cfg.aggregates.find(a => a.name === aggrName);
|
47
|
+
if (!aggr) throw new Error(`No backup aggregate with name '${aggrName}'`);
|
48
|
+
const {
|
49
|
+
file,
|
50
|
+
sshKey,
|
51
|
+
gpgKey
|
52
|
+
} = aggr.sources;
|
53
|
+
|
54
|
+
try {
|
55
|
+
this.fs.ensureDir(aggrDir);
|
56
|
+
file.forEach(f => this.runFileTask(f, aggrDir));
|
57
|
+
sshKey.forEach(k => this.runSshKeyTask(k, aggrDir));
|
58
|
+
gpgKey.forEach(k => this.runGpgKeyTask(k, aggrDir));
|
59
|
+
this.storageBackendProvider.provide(storage).store(aggrDir);
|
60
|
+
} finally {
|
61
|
+
this.log.debug();
|
62
|
+
this.fs.rmDir(aggrDir);
|
49
63
|
}
|
50
|
-
|
51
|
-
this.storageBackendProvider.provide(storage).store(aggrDir);
|
52
|
-
this.fs.rmDir(aggrDir);
|
53
64
|
});
|
54
65
|
|
55
|
-
_defineProperty(this, "runGpgKeyTask", t => {
|
66
|
+
_defineProperty(this, "runGpgKeyTask", (t, dir) => {
|
56
67
|
this.log.info('Running GPG key task', t);
|
57
68
|
const key = this.gpg.exportKey(t.id);
|
58
|
-
|
59
|
-
|
69
|
+
|
70
|
+
const to = t.to || _Path.RelativePath.from(`keys/gpg/${t.id}.asc`);
|
71
|
+
|
72
|
+
this.fs.writeFile(dir.resolve(to), key);
|
60
73
|
});
|
61
74
|
|
62
|
-
_defineProperty(this, "runSshKeyTask", t => {
|
75
|
+
_defineProperty(this, "runSshKeyTask", (t, dir) => {
|
63
76
|
this.log.info('Running SSH key task', t);
|
64
77
|
const key = this.ssh.exportKey(t.id);
|
65
|
-
|
66
|
-
|
78
|
+
|
79
|
+
const to = t.to || _Path.RelativePath.from(`keys/ssh/${t.id}`);
|
80
|
+
|
81
|
+
this.fs.writeFile(dir.resolve(to), key);
|
67
82
|
});
|
68
83
|
|
69
84
|
_defineProperty(this, "runFileTask", (f, dir) => {
|
@@ -74,10 +89,6 @@ let AggregateBackupController = (_dec = (0, _inversify.injectable)(), _dec2 = fu
|
|
74
89
|
} = f;
|
75
90
|
this.fsSyncer.sync(from, dir.resolve(to));
|
76
91
|
});
|
77
|
-
|
78
|
-
_defineProperty(this, "storagePath", path => {
|
79
|
-
throw new Error('Unspported');
|
80
|
-
});
|
81
92
|
}
|
82
93
|
|
83
94
|
}) || _class) || _class) || _class) || _class);
|
package/lib/config/Config.js
CHANGED
@@ -27,6 +27,12 @@ const expandPaths = (cfg, exp, cwd) => {
|
|
27
27
|
f.from = exp(f.from);
|
28
28
|
f.to = _Path.RelativePath.from(f.to);
|
29
29
|
});
|
30
|
+
a.sources.sshKey.forEach(f => {
|
31
|
+
if (f.to) f.to = _Path.RelativePath.from(f.to);
|
32
|
+
});
|
33
|
+
a.sources.gpgKey.forEach(f => {
|
34
|
+
if (f.to) f.to = _Path.RelativePath.from(f.to);
|
35
|
+
});
|
30
36
|
});
|
31
37
|
};
|
32
38
|
|
package/lib/fs/Fs.js
CHANGED
@@ -37,7 +37,7 @@ let Fs = (_dec = (0, _inversify.injectable)(), _dec2 = Reflect.metadata("design:
|
|
37
37
|
_defineProperty(this, "isDir", path => _fs.default.lstatSync(path.str()).isDirectory());
|
38
38
|
|
39
39
|
_defineProperty(this, "rmDir", path => {
|
40
|
-
_fs.default.
|
40
|
+
_fs.default.rmSync(path.str(), {
|
41
41
|
recursive: true
|
42
42
|
});
|
43
43
|
});
|
@@ -6,8 +6,6 @@ var _Shell = require("../../tools/shell/Shell");
|
|
6
6
|
|
7
7
|
var _test = require("../../../test");
|
8
8
|
|
9
|
-
var _fs = _interopRequireDefault(require("fs"));
|
10
|
-
|
11
9
|
var _areDirsSame = require("../areDirsSame");
|
12
10
|
|
13
11
|
var _Fs = require("../Fs");
|
@@ -16,7 +14,7 @@ var _Path = require("../path/Path");
|
|
16
14
|
|
17
15
|
var _AppLogger = require("../../log/AppLogger");
|
18
16
|
|
19
|
-
|
17
|
+
var _testHelper = require("../../../test/testHelper");
|
20
18
|
|
21
19
|
describe('FsSync', () => {
|
22
20
|
const from = _Path.AbsPath.from((0, _test.testDir)('fs/fssync/src'));
|
@@ -30,8 +28,6 @@ describe('FsSync', () => {
|
|
30
28
|
expect((0, _areDirsSame.areDirsSame)(from, to)).toBe(true);
|
31
29
|
});
|
32
30
|
afterAll(() => {
|
33
|
-
|
34
|
-
recursive: true
|
35
|
-
});
|
31
|
+
(0, _testHelper.cleanDir)(to.str());
|
36
32
|
});
|
37
33
|
});
|
package/lib/log/ConsoleLogger.js
CHANGED
@@ -11,15 +11,17 @@ class ConsoleLogger {
|
|
11
11
|
constructor() {
|
12
12
|
_defineProperty(this, "enabled", true);
|
13
13
|
|
14
|
+
_defineProperty(this, "print", (...args) => console.log(...args.map(a => a.toString())));
|
15
|
+
|
14
16
|
_defineProperty(this, "debug", (...args) => {
|
15
|
-
if (this.enabled)
|
17
|
+
if (this.enabled) this.print(args);
|
16
18
|
});
|
17
19
|
|
18
20
|
_defineProperty(this, "info", (...args) => {
|
19
|
-
if (this.enabled)
|
21
|
+
if (this.enabled) this.print(args);
|
20
22
|
});
|
21
23
|
|
22
|
-
_defineProperty(this, "error",
|
24
|
+
_defineProperty(this, "error", this.print);
|
23
25
|
|
24
26
|
_defineProperty(this, "setEnabled", enabled => {
|
25
27
|
this.enabled = enabled;
|
@@ -16,6 +16,8 @@ var _Path = require("../../fs/path/Path");
|
|
16
16
|
|
17
17
|
var _dirCompare = require("dir-compare");
|
18
18
|
|
19
|
+
var _testHelper = require("../../../test/testHelper");
|
20
|
+
|
19
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
20
22
|
|
21
23
|
const getBackblazeConfig = () => {
|
@@ -43,13 +45,8 @@ describe('ResticClient', () => {
|
|
43
45
|
}
|
44
46
|
}, new _Shell.Shell(l), l);
|
45
47
|
afterAll(() => {
|
46
|
-
|
47
|
-
|
48
|
-
});
|
49
|
-
|
50
|
-
_fs.default.rmdirSync(restoreDir, {
|
51
|
-
recursive: true
|
52
|
-
});
|
48
|
+
(0, _testHelper.cleanDir)(repoDir);
|
49
|
+
(0, _testHelper.cleanDir)(restoreDir);
|
53
50
|
});
|
54
51
|
it('create repo', () => {
|
55
52
|
sut.prepareRepo();
|
@@ -81,9 +78,7 @@ describe('ResticClient', () => {
|
|
81
78
|
backblaze: b2Cfg
|
82
79
|
}, new _Shell.Shell(l), l);
|
83
80
|
afterAll(() => {
|
84
|
-
|
85
|
-
recursive: true
|
86
|
-
});
|
81
|
+
(0, _testHelper.cleanDir)(restoreDir);
|
87
82
|
});
|
88
83
|
it('push adn restore data', () => {
|
89
84
|
// sut.prepareRepo(repoUrl, password)
|
@@ -26,7 +26,7 @@ let SshKeyManager = (_dec = (0, _inversify.injectable)(), _dec2 = Reflect.metada
|
|
26
26
|
_defineProperty(this, "sshDir", void 0);
|
27
27
|
|
28
28
|
_defineProperty(this, "exportKey", id => {
|
29
|
-
return this.fs.readFile(this.sshDir);
|
29
|
+
return this.fs.readFile(this.sshDir.resolve(id));
|
30
30
|
});
|
31
31
|
|
32
32
|
this.sshDir = _Path.AbsPath.from(_os.default.homedir()).resolve('.ssh');
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ps-aux/nodebup",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.3.0",
|
4
4
|
"description": "",
|
5
5
|
"module": "lib/index.js",
|
6
6
|
"main": "lib/index.js",
|
@@ -37,6 +37,7 @@
|
|
37
37
|
"@babel/plugin-proposal-optional-chaining": "^7.16.5",
|
38
38
|
"@babel/preset-env": "^7.16.5",
|
39
39
|
"@babel/preset-typescript": "^7.16.5",
|
40
|
+
"@ps-aux/cibs": "^0.6.3",
|
40
41
|
"@types/jest": "^27.0.3",
|
41
42
|
"@types/jest-when": "^2.7.4",
|
42
43
|
"@types/node": "^17.0.5",
|
@@ -71,7 +72,7 @@
|
|
71
72
|
},
|
72
73
|
"dependencies": {
|
73
74
|
"@hapi/joi": "^17.1.1",
|
74
|
-
"@ps-aux/nclif": "^0.0.6-alpha.
|
75
|
+
"@ps-aux/nclif": "^0.0.6-alpha.3",
|
75
76
|
"@types/hapi__joi": "^17.1.8",
|
76
77
|
"axios": "^0.24.0",
|
77
78
|
"handlebars": "^4.7.7",
|