@ps-aux/nodebup 0.1.1 → 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.
Files changed (41) hide show
  1. package/README.md +0 -0
  2. package/lib/bup/AggregateBackupController.js +95 -0
  3. package/lib/cli/app.js +55 -0
  4. package/lib/cli/bin.js +2 -8
  5. package/lib/config/Config.js +64 -0
  6. package/lib/config/expandAndCreatePath.js +24 -0
  7. package/lib/config/validateConfigAgainstSchema.js +65 -0
  8. package/lib/config/validateConfigAgainstSchema.spec.js +29 -0
  9. package/lib/ctx/Context.js +23 -16
  10. package/lib/ctx/ContextSymbols.js +14 -0
  11. package/lib/fs/Fs.js +81 -0
  12. package/lib/fs/areDirsSame.js +20 -0
  13. package/lib/fs/areDirsSame.test.js +20 -0
  14. package/lib/fs/fssync/FsSync.spec.js +33 -0
  15. package/lib/fs/fssync/FsSyncer.js +54 -0
  16. package/lib/fs/path/Path.js +59 -0
  17. package/lib/fs/readYaml.js +20 -0
  18. package/lib/globald.d.js +3 -0
  19. package/lib/log/AppLogger.js +28 -0
  20. package/lib/log/ConsoleLogger.js +5 -3
  21. package/lib/log/MinimalLogger.js +10 -4
  22. package/lib/storage/StorageBackendProvider.js +53 -0
  23. package/lib/storage/local-file/LocalFileStorageBackend.js +22 -0
  24. package/lib/storage/restic/ResticClient.js +86 -0
  25. package/lib/storage/restic/ResticClient.spec.js +91 -0
  26. package/lib/storage/restic/ResticClientFactory.js +77 -0
  27. package/lib/storage/restic/ResticController.js +39 -0
  28. package/lib/storage/restic/ResticStorageBackend.js +23 -0
  29. package/lib/storage/types.d.js +5 -0
  30. package/lib/tools/gpg/Gpg.js +28 -0
  31. package/lib/tools/gpg/Gpg.spec.js +14 -0
  32. package/lib/tools/shell/Shell.js +52 -0
  33. package/lib/{shell → tools/shell}/shellCmd.js +4 -2
  34. package/lib/tools/ssh/SshKeyManager.js +36 -0
  35. package/lib/tools/ssh/SshKeyManager.spec.js +14 -0
  36. package/lib/types.js +5 -0
  37. package/package.json +54 -48
  38. package/lib/cli/entrypoint.js +0 -27
  39. package/lib/foo/foo.command.js +0 -16
  40. package/lib/shell/LocalShellCmdExecutor.js +0 -46
  41. package/lib/types.d.js +0 -1
@@ -10,12 +10,14 @@ var _child_process = require("child_process");
10
10
  const shellCmd = (cmd, {
11
11
  returnStdout,
12
12
  cwd,
13
- stdin
13
+ stdin,
14
+ env
14
15
  } = {}) => {
15
16
  const res = (0, _child_process.execSync)(cmd, {
16
17
  cwd,
17
18
  input: stdin,
18
- stdio: [stdin ? undefined : 'inherit', returnStdout ? undefined : 'inherit', 'inherit']
19
+ stdio: [stdin ? undefined : 'inherit', returnStdout ? undefined : 'inherit', 'inherit'],
20
+ env
19
21
  });
20
22
  if (returnStdout) return res.toString().trim();
21
23
  return null;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SshKeyManager = void 0;
7
+
8
+ var _Fs = require("../../fs/Fs");
9
+
10
+ var _Path = require("../../fs/path/Path");
11
+
12
+ var _os = _interopRequireDefault(require("os"));
13
+
14
+ var _inversify = require("inversify");
15
+
16
+ var _dec, _dec2, _dec3, _class;
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
+
22
+ let SshKeyManager = (_dec = (0, _inversify.injectable)(), _dec2 = Reflect.metadata("design:type", Function), _dec3 = Reflect.metadata("design:paramtypes", [typeof _Fs.Fs === "undefined" ? Object : _Fs.Fs]), _dec(_class = _dec2(_class = _dec3(_class = class SshKeyManager {
23
+ constructor(fs) {
24
+ this.fs = fs;
25
+
26
+ _defineProperty(this, "sshDir", void 0);
27
+
28
+ _defineProperty(this, "exportKey", id => {
29
+ return this.fs.readFile(this.sshDir.resolve(id));
30
+ });
31
+
32
+ this.sshDir = _Path.AbsPath.from(_os.default.homedir()).resolve('.ssh');
33
+ }
34
+
35
+ }) || _class) || _class) || _class);
36
+ exports.SshKeyManager = SshKeyManager;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ var _SshKeyManager = require("./SshKeyManager");
4
+
5
+ var _Fs = require("../../fs/Fs");
6
+
7
+ var _AppLogger = require("../../log/AppLogger");
8
+
9
+ // TODO setup ci to make tests work
10
+ it.skip('works', () => {
11
+ const sut = new _SshKeyManager.SshKeyManager(new _Fs.Fs(new _AppLogger.AppLogger()));
12
+ const key = sut.exportKey('id_rsa');
13
+ console.log('key', key);
14
+ });
package/lib/types.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ps-aux/nodebup",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "description": "",
5
5
  "module": "lib/index.js",
6
6
  "main": "lib/index.js",
@@ -8,11 +8,13 @@
8
8
  "build": "rm -rf build && babel --extensions '.ts,.js' src -d lib src",
9
9
  "pub": "npm publish --access public",
10
10
  "test": "jest",
11
- "typecheck": "tsc --noEmit",
11
+ "tc": "tsc --noEmit",
12
12
  "format": "prettier \"**/*.{js,ts,tsx}\" --write",
13
13
  "build-n-run": "npm run build && ",
14
14
  "lint": "eslint '**/*.{js,ts,tsx}' --fix",
15
- "update-deps": "ncu --upgrade"
15
+ "update-deps": "ncu --upgrade",
16
+ "prepare": "husky install",
17
+ "pre-commit": "lint-staged"
16
18
  },
17
19
  "keywords": [],
18
20
  "author": "",
@@ -25,58 +27,62 @@
25
27
  },
26
28
  "typings": "src/types.d.ts",
27
29
  "devDependencies": {
28
- "@babel/cli": "^7.8.4",
29
- "@babel/core": "^7.8.7",
30
- "@babel/node": "^7.8.7",
31
- "@babel/plugin-proposal-class-properties": "^7.8.3",
32
- "@babel/plugin-proposal-object-rest-spread": "^7.8.3",
33
- "@babel/plugin-proposal-optional-chaining": "^7.8.3",
34
- "@babel/preset-env": "^7.8.7",
35
- "@babel/preset-typescript": "^7.8.3",
36
- "@types/jest": "^25.1.4",
37
- "@types/jest-when": "^2.7.0",
38
- "@types/node": "^13.9.0",
39
- "@types/ramda": "^0.26.43",
40
- "@typescript-eslint/eslint-plugin": "^2.23.0",
41
- "@typescript-eslint/parser": "^2.23.0",
42
- "babel-eslint": "^10.1.0",
43
- "babel-jest": "^25.1.0",
44
- "babel-plugin-module-resolver": "^4.0.0",
45
- "eslint": "^6.8.0",
46
- "eslint-config-standard": "^14.1.0",
47
- "eslint-plugin-import": "^2.20.1",
48
- "eslint-plugin-node": "^11.0.0",
49
- "eslint-plugin-prettier": "^3.1.2",
50
- "eslint-plugin-promise": "^4.2.1",
51
- "eslint-plugin-standard": "^4.0.1",
52
- "husky": "^4.2.3",
53
- "jest": "^25.1.0",
54
- "jest-when": "^2.7.0",
55
- "lint-staged": "^10.0.8",
56
- "npm-check-updates": "^4.0.4",
57
- "prettier": "^1.19.1",
58
- "typescript": "^3.8.3"
59
- },
60
- "husky": {
61
- "hooks": {
62
- "pre-commit": "lint-staged"
63
- }
30
+ "@babel/cli": "^7.16.0",
31
+ "@babel/core": "^7.16.5",
32
+ "@babel/eslint-parser": "^7.16.5",
33
+ "@babel/node": "^7.16.5",
34
+ "@babel/plugin-proposal-class-properties": "^7.16.5",
35
+ "@babel/plugin-proposal-decorators": "^7.16.5",
36
+ "@babel/plugin-proposal-object-rest-spread": "^7.16.5",
37
+ "@babel/plugin-proposal-optional-chaining": "^7.16.5",
38
+ "@babel/preset-env": "^7.16.5",
39
+ "@babel/preset-typescript": "^7.16.5",
40
+ "@ps-aux/cibs": "^0.6.3",
41
+ "@types/jest": "^27.0.3",
42
+ "@types/jest-when": "^2.7.4",
43
+ "@types/node": "^17.0.5",
44
+ "@types/ramda": "^0.27.62",
45
+ "@typescript-eslint/eslint-plugin": "^5.8.1",
46
+ "@typescript-eslint/parser": "^5.8.1",
47
+ "babel-plugin-module-resolver": "^4.1.0",
48
+ "babel-plugin-transform-typescript-metadata": "^0.3.2",
49
+ "dir-compare": "^4.0.0",
50
+ "eslint": "^8.5.0",
51
+ "eslint-config-standard": "^16.0.3",
52
+ "eslint-plugin-import": "^2.25.3",
53
+ "eslint-plugin-node": "^11.1.0",
54
+ "eslint-plugin-prettier": "^4.0.0",
55
+ "eslint-plugin-promise": "^6.0.0",
56
+ "eslint-plugin-standard": "^5.0.0",
57
+ "husky": "^7.0.4",
58
+ "jest": "^27.4.5",
59
+ "jest-extended": "^1.2.0",
60
+ "jest-when": "^3.5.0",
61
+ "lint-staged": "^12.1.4",
62
+ "npm-check-updates": "^12.0.5",
63
+ "prettier": "^2.5.1",
64
+ "ts-jest": "^27.1.2",
65
+ "typescript": "^4.5.4"
64
66
  },
65
67
  "lint-staged": {
66
68
  "./**/*.{js,ts,tsx}": [
67
69
  "prettier --write",
68
- "eslint --fix",
69
- "git add"
70
+ "eslint --fix"
70
71
  ]
71
72
  },
72
73
  "dependencies": {
73
74
  "@hapi/joi": "^17.1.1",
74
- "@types/hapi__joi": "^16.0.12",
75
- "axios": "^0.19.2",
76
- "handlebars": "^4.7.3",
77
- "js-yaml": "^3.13.1",
78
- "ramda": "^0.27.0",
79
- "wait-on": "^4.0.1",
80
- "yargs": "^15.3.0"
75
+ "@ps-aux/nclif": "^0.0.6-alpha.3",
76
+ "@types/hapi__joi": "^17.1.8",
77
+ "axios": "^0.24.0",
78
+ "handlebars": "^4.7.7",
79
+ "inversify": "^6.0.1",
80
+ "js-yaml": "^4.1.0",
81
+ "pino": "^7.6.2",
82
+ "ramda": "^0.27.1",
83
+ "reflect-metadata": "^0.1.13",
84
+ "wait-on": "^6.0.0",
85
+ "yaml": "^1.10.2",
86
+ "yargs": "^17.3.1"
81
87
  }
82
88
  }
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _yargs = _interopRequireDefault(require("yargs"));
9
-
10
- var _foo = require("../foo/foo.command");
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- const entrypoint = ctx => {
15
- try {
16
- // eslint-disable-next-line no-unused-expressions
17
- _yargs.default.scriptName('bup').usage('$0 <cmd> [args]').command((0, _foo.fooCmd)()).alias('h', 'help').help() // https://github.com/yargs/yargs/issues/895#issuecomment-392893305
18
- .demandCommand().recommendCommands().strict().argv;
19
- } catch (err) {
20
- console.log(err);
21
- console.error('Error:', err.message);
22
- process.exit(1);
23
- }
24
- };
25
-
26
- var _default = entrypoint;
27
- exports.default = _default;
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.fooCmd = void 0;
7
-
8
- const fooCmd = () => ({
9
- command: 'foo',
10
- describe: 'Do foo',
11
- handler: args => {
12
- console.log('haha'); // throw new Error('Assertion error')
13
- }
14
- });
15
-
16
- exports.fooCmd = fooCmd;
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.LocalShellCmdExecutor = void 0;
7
-
8
- var _MinimalLogger = require("../log/MinimalLogger");
9
-
10
- var _shellCmd = require("./shellCmd");
11
-
12
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
-
14
- class LocalShellCmdExecutor {
15
- constructor(log) {
16
- _defineProperty(this, "log", void 0);
17
-
18
- _defineProperty(this, "exec", cmd => {
19
- this.log.debug(cmd);
20
- (0, _shellCmd.shellCmd)(cmd, {
21
- returnStdout: false
22
- });
23
- });
24
-
25
- _defineProperty(this, "execWithStdIn", (cmd, stdin) => {
26
- this.log.debug(`"${stdin}" > ${cmd}`);
27
- (0, _shellCmd.shellCmd)(cmd, {
28
- stdin,
29
- returnStdout: false
30
- });
31
- });
32
-
33
- _defineProperty(this, "execAndReturnVal", (cmd, ops) => {
34
- this.log.debug(cmd, '[stdout consumed]');
35
- return (0, _shellCmd.shellCmd)(cmd, {
36
- returnStdout: true,
37
- ...ops
38
- });
39
- });
40
-
41
- this.log = log || (0, _MinimalLogger.minimalLogger)();
42
- }
43
-
44
- }
45
-
46
- exports.LocalShellCmdExecutor = LocalShellCmdExecutor;
package/lib/types.d.js DELETED
@@ -1 +0,0 @@
1
- "use strict";