@datatruck/cli 0.17.1 → 0.18.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 (104) hide show
  1. package/Action/BackupAction.d.ts +1 -1
  2. package/Action/BackupAction.js +14 -14
  3. package/Action/BackupSessionsAction.d.ts +1 -1
  4. package/Action/CleanCacheAction.d.ts +1 -1
  5. package/Action/CleanCacheAction.js +3 -3
  6. package/Action/ConfigAction.d.ts +1 -1
  7. package/Action/ConfigAction.js +5 -5
  8. package/Action/InitAction.d.ts +1 -1
  9. package/Action/InitAction.js +2 -2
  10. package/Action/PruneAction.d.ts +1 -1
  11. package/Action/PruneAction.js +4 -4
  12. package/Action/RestoreAction.d.ts +1 -1
  13. package/Action/RestoreAction.js +18 -18
  14. package/Action/RestoreSessionsAction.d.ts +1 -1
  15. package/Action/SnapshotsAction.d.ts +1 -1
  16. package/Action/SnapshotsAction.js +4 -4
  17. package/Command/BackupCommand.d.ts +2 -2
  18. package/Command/BackupCommand.js +6 -6
  19. package/Command/BackupSessionsCommand.d.ts +2 -2
  20. package/Command/BackupSessionsCommand.js +9 -9
  21. package/Command/CleanCacheCommand.d.ts +1 -1
  22. package/Command/CleanCacheCommand.js +2 -2
  23. package/Command/CommandAbstract.d.ts +3 -3
  24. package/Command/CommandAbstract.js +2 -2
  25. package/Command/ConfigCommand.d.ts +2 -2
  26. package/Command/ConfigCommand.js +8 -8
  27. package/Command/InitCommand.d.ts +2 -2
  28. package/Command/InitCommand.js +9 -9
  29. package/Command/PruneCommand.d.ts +2 -2
  30. package/Command/PruneCommand.js +10 -10
  31. package/Command/RestoreCommand.d.ts +2 -2
  32. package/Command/RestoreCommand.js +6 -6
  33. package/Command/RestoreSessionsCommand.d.ts +2 -2
  34. package/Command/RestoreSessionsCommand.js +9 -9
  35. package/Command/SnapshotsCommand.d.ts +2 -2
  36. package/Command/SnapshotsCommand.js +9 -9
  37. package/Entity/StateEntityAbstract.d.ts +1 -1
  38. package/Repository/DatatruckRepository.d.ts +1 -2
  39. package/Repository/DatatruckRepository.js +56 -118
  40. package/Repository/GitRepository.js +23 -23
  41. package/Repository/RepositoryAbstract.d.ts +1 -1
  42. package/Repository/RepositoryAbstract.js +2 -2
  43. package/Repository/ResticRepository.d.ts +1 -1
  44. package/Repository/ResticRepository.js +27 -27
  45. package/SessionDriver/ConsoleSessionDriver.d.ts +1 -1
  46. package/SessionDriver/ConsoleSessionDriver.js +10 -10
  47. package/SessionDriver/SqliteSessionDriver.js +12 -12
  48. package/SessionManager/BackupSessionManager.d.ts +2 -2
  49. package/SessionManager/BackupSessionManager.js +1 -1
  50. package/SessionManager/RestoreSessionManager.d.ts +2 -2
  51. package/SessionManager/RestoreSessionManager.js +1 -1
  52. package/Task/GitTask.js +21 -21
  53. package/Task/MariadbTask.d.ts +11 -0
  54. package/Task/MariadbTask.js +240 -58
  55. package/Task/MssqlTask.js +8 -8
  56. package/Task/MysqlDumpTask.d.ts +1 -1
  57. package/Task/MysqlDumpTask.js +13 -13
  58. package/Task/PostgresqlDumpTask.d.ts +1 -1
  59. package/Task/PostgresqlDumpTask.js +4 -4
  60. package/Task/ScriptTask.js +7 -7
  61. package/Task/SqlDumpTaskAbstract.d.ts +1 -1
  62. package/Task/SqlDumpTaskAbstract.js +12 -12
  63. package/Task/TaskAbstract.d.ts +1 -1
  64. package/Task/TaskAbstract.js +2 -2
  65. package/cli.js +10 -10
  66. package/config.schema.json +44 -0
  67. package/package.json +3 -3
  68. package/{util → utils}/DataFormat.d.ts +0 -0
  69. package/{util → utils}/DataFormat.js +0 -0
  70. package/{util/GitUtil.d.ts → utils/Git.d.ts} +8 -8
  71. package/{util/GitUtil.js → utils/Git.js} +8 -8
  72. package/{util → utils}/ObjectVault.d.ts +0 -0
  73. package/{util → utils}/ObjectVault.js +0 -0
  74. package/{util/ResticUtil.d.ts → utils/Restic.d.ts} +3 -3
  75. package/{util/ResticUtil.js → utils/Restic.js} +9 -9
  76. package/{util/cli-util.d.ts → utils/cli.d.ts} +0 -0
  77. package/{util/cli-util.js → utils/cli.js} +0 -0
  78. package/{util/datatruck/config-util.d.ts → utils/datatruck/config.d.ts} +1 -1
  79. package/{util/datatruck/config-util.js → utils/datatruck/config.js} +10 -10
  80. package/{util/datatruck/paths-util.d.ts → utils/datatruck/paths.d.ts} +0 -0
  81. package/{util/datatruck/paths-util.js → utils/datatruck/paths.js} +2 -2
  82. package/{util/datatruck/snapshot-util.d.ts → utils/datatruck/snapshot.d.ts} +1 -1
  83. package/{util/datatruck/snapshot-util.js → utils/datatruck/snapshot.js} +4 -4
  84. package/{util/date-util.d.ts → utils/date.d.ts} +0 -0
  85. package/{util/date-util.js → utils/date.js} +2 -2
  86. package/{util/entity-util.d.ts → utils/entity.d.ts} +0 -0
  87. package/{util/entity-util.js → utils/entity.js} +0 -0
  88. package/{util/fs-util.d.ts → utils/fs.d.ts} +23 -2
  89. package/{util/fs-util.js → utils/fs.js} +83 -24
  90. package/{util/math-util.d.ts → utils/math.d.ts} +0 -0
  91. package/{util/math-util.js → utils/math.js} +0 -0
  92. package/{util/object-util.d.ts → utils/object.d.ts} +0 -0
  93. package/{util/object-util.js → utils/object.js} +0 -0
  94. package/{util/path-util.d.ts → utils/path.d.ts} +0 -0
  95. package/{util/path-util.js → utils/path.js} +0 -0
  96. package/utils/process.d.ts +107 -0
  97. package/{util/process-util.js → utils/process.js} +168 -28
  98. package/{util → utils}/progress.d.ts +0 -0
  99. package/{util → utils}/progress.js +0 -0
  100. package/{util/string-util.d.ts → utils/string.d.ts} +0 -0
  101. package/{util/string-util.js → utils/string.js} +0 -0
  102. package/{util/zip-util.d.ts → utils/zip.d.ts} +0 -0
  103. package/{util/zip-util.js → utils/zip.js} +5 -5
  104. package/util/process-util.d.ts +0 -55
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SqlDumpTaskAbstract = exports.sqlDumpTaskDefinition = void 0;
4
4
  const AppError_1 = require("../Error/AppError");
5
5
  const DefinitionEnum_1 = require("../JsonSchema/DefinitionEnum");
6
- const cli_util_1 = require("../util/cli-util");
7
- const config_util_1 = require("../util/datatruck/config-util");
8
- const fs_util_1 = require("../util/fs-util");
9
- const math_util_1 = require("../util/math-util");
6
+ const cli_1 = require("../utils/cli");
7
+ const config_1 = require("../utils/datatruck/config");
8
+ const fs_1 = require("../utils/fs");
9
+ const math_1 = require("../utils/math");
10
10
  const TaskAbstract_1 = require("./TaskAbstract");
11
11
  const assert_1 = require("assert");
12
12
  const promises_1 = require("fs/promises");
@@ -114,7 +114,7 @@ class SqlDumpTaskAbstract extends TaskAbstract_1.TaskAbstract {
114
114
  return true;
115
115
  });
116
116
  (0, assert_1.ok)(typeof outputPath === "string");
117
- if (!(await (0, fs_util_1.checkDir)(outputPath)))
117
+ if (!(await (0, fs_1.checkDir)(outputPath)))
118
118
  await (0, promises_1.mkdir)(outputPath, { recursive: true });
119
119
  if (!this.config.oneFileByTable) {
120
120
  const outPath = (0, path_1.join)(outputPath, serializeSqlFile({ database: this.config.database }));
@@ -144,7 +144,7 @@ class SqlDumpTaskAbstract extends TaskAbstract_1.TaskAbstract {
144
144
  absolute: {
145
145
  total: tableNames.length,
146
146
  current: current,
147
- percent: (0, math_util_1.progressPercent)(tableNames.length, current),
147
+ percent: (0, math_1.progressPercent)(tableNames.length, current),
148
148
  },
149
149
  });
150
150
  const outPath = (0, path_1.join)(outputPath, serializeSqlFile({ table: tableName }));
@@ -159,7 +159,7 @@ class SqlDumpTaskAbstract extends TaskAbstract_1.TaskAbstract {
159
159
  absolute: {
160
160
  total: tableNames.length,
161
161
  current: current,
162
- percent: (0, math_util_1.progressPercent)(tableNames.length, current),
162
+ percent: (0, math_1.progressPercent)(tableNames.length, current),
163
163
  },
164
164
  });
165
165
  });
@@ -181,7 +181,7 @@ class SqlDumpTaskAbstract extends TaskAbstract_1.TaskAbstract {
181
181
  this.verbose = data.options.verbose;
182
182
  (0, assert_1.ok)(typeof restorePath === "string");
183
183
  const database = {
184
- name: (0, config_util_1.resolveDatabaseName)(this.config.database, {
184
+ name: (0, config_1.resolveDatabaseName)(this.config.database, {
185
185
  packageName: data.package.name,
186
186
  snapshotId: data.options.snapshotId,
187
187
  snapshotDate: data.snapshot.date,
@@ -190,7 +190,7 @@ class SqlDumpTaskAbstract extends TaskAbstract_1.TaskAbstract {
190
190
  }),
191
191
  };
192
192
  if (this.config.targetDatabase) {
193
- database.name = (0, config_util_1.resolveDatabaseName)(this.config.targetDatabase.name, {
193
+ database.name = (0, config_1.resolveDatabaseName)(this.config.targetDatabase.name, {
194
194
  packageName: data.package.name,
195
195
  snapshotId: data.options.snapshotId,
196
196
  snapshotDate: data.snapshot.date,
@@ -198,7 +198,7 @@ class SqlDumpTaskAbstract extends TaskAbstract_1.TaskAbstract {
198
198
  database: database.name,
199
199
  });
200
200
  }
201
- const items = (await (0, fs_util_1.readDir)(restorePath))
201
+ const items = (await (0, fs_1.readDir)(restorePath))
202
202
  .map(parseSqlFile)
203
203
  .filter((v) => !!v);
204
204
  // Database check
@@ -216,7 +216,7 @@ class SqlDumpTaskAbstract extends TaskAbstract_1.TaskAbstract {
216
216
  }
217
217
  await this.onCreateDatabase(database);
218
218
  if (this.verbose)
219
- (0, cli_util_1.logExec)("readdir", [restorePath]);
219
+ (0, cli_1.logExec)("readdir", [restorePath]);
220
220
  let current = 0;
221
221
  for (const item of items) {
222
222
  const path = (0, path_1.join)(restorePath, item.fileName);
@@ -228,7 +228,7 @@ class SqlDumpTaskAbstract extends TaskAbstract_1.TaskAbstract {
228
228
  absolute: {
229
229
  total: items.length,
230
230
  current: current,
231
- percent: (0, math_util_1.progressPercent)(items.length, current),
231
+ percent: (0, math_1.progressPercent)(items.length, current),
232
232
  },
233
233
  });
234
234
  await this.onImport(path, database.name);
@@ -2,7 +2,7 @@ import { BackupActionOptionsType } from "../Action/BackupAction";
2
2
  import { RestoreActionOptionsType } from "../Action/RestoreAction";
3
3
  import { PackageConfigType } from "../Config/PackageConfig";
4
4
  import { SnapshotType } from "../Repository/RepositoryAbstract";
5
- import { Progress } from "../util/progress";
5
+ import { Progress } from "../utils/progress";
6
6
  export type BackupDataType = {
7
7
  onProgress: (data: Progress) => Promise<void>;
8
8
  options: BackupActionOptionsType;
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TaskAbstract = void 0;
4
- const fs_util_1 = require("../util/fs-util");
4
+ const fs_1 = require("../utils/fs");
5
5
  class TaskAbstract {
6
6
  constructor(config) {
7
7
  this.config = config;
8
8
  this.tmpDirs = [];
9
9
  }
10
10
  async mkTmpDir(prefix, id) {
11
- const dir = await (0, fs_util_1.mkTmpDir)(prefix, id);
11
+ const dir = await (0, fs_1.mkTmpDir)(prefix, id);
12
12
  this.tmpDirs.push(dir);
13
13
  return dir;
14
14
  }
package/cli.js CHANGED
@@ -8,13 +8,13 @@ const ConfigAction_1 = require("./Action/ConfigAction");
8
8
  const AppError_1 = require("./Error/AppError");
9
9
  const CommandFactory_1 = require("./Factory/CommandFactory");
10
10
  const globalData_1 = __importDefault(require("./globalData"));
11
- const cli_util_1 = require("./util/cli-util");
12
- const fs_util_1 = require("./util/fs-util");
13
- const process_util_1 = require("./util/process-util");
14
- const string_util_1 = require("./util/string-util");
11
+ const cli_1 = require("./utils/cli");
12
+ const fs_1 = require("./utils/fs");
13
+ const process_1 = require("./utils/process");
14
+ const string_1 = require("./utils/string");
15
15
  const chalk_1 = require("chalk");
16
16
  const commander_1 = require("commander");
17
- const fs_1 = require("fs");
17
+ const fs_2 = require("fs");
18
18
  const path_1 = require("path");
19
19
  function getGlobalOptions() {
20
20
  return program.opts();
@@ -72,7 +72,7 @@ function makeCommandAction(command) {
72
72
  };
73
73
  }
74
74
  const program = new commander_1.Command();
75
- const { version, description } = (0, fs_util_1.parsePackageFile)();
75
+ const { version, description } = (0, fs_1.parsePackageFile)();
76
76
  const cwd = process.cwd();
77
77
  program.name("datatruck");
78
78
  program.version(version);
@@ -94,7 +94,7 @@ makeCommand(CommandFactory_1.CommandEnum.restoreSessions).alias("rs");
94
94
  makeCommand(CommandFactory_1.CommandEnum.cleanCache).alias("cc");
95
95
  function buildArgs(input, options) {
96
96
  const optionsArray = Object.keys(options).flatMap((name) => [
97
- `--${(0, string_util_1.snakeCase)(name, "-")}`,
97
+ `--${(0, string_1.snakeCase)(name, "-")}`,
98
98
  options[name],
99
99
  ]);
100
100
  return [input, ...optionsArray];
@@ -103,16 +103,16 @@ exports.buildArgs = buildArgs;
103
103
  function parseArgs(args) {
104
104
  program.parse(args);
105
105
  const verbose = getGlobalOptions().verbose;
106
- (0, process_util_1.onExit)((eventName, error) => {
106
+ (0, process_1.onExit)((eventName, error) => {
107
107
  if (eventName !== "exit") {
108
- process.stdout.write(cli_util_1.showCursorCommand);
108
+ process.stdout.write(cli_1.showCursorCommand);
109
109
  console.info(`\nClosing... (reason: ${eventName})`);
110
110
  if (error instanceof Error)
111
111
  console.error((0, chalk_1.red)(error.stack));
112
112
  }
113
113
  if (!verbose)
114
114
  try {
115
- (0, fs_1.rmSync)((0, fs_util_1.sessionTmpDir)(), {
115
+ (0, fs_2.rmSync)((0, fs_1.sessionTmpDir)(), {
116
116
  force: true,
117
117
  recursive: true,
118
118
  maxRetries: 5,
@@ -798,6 +798,50 @@
798
798
  },
799
799
  "excludeDatabases": {
800
800
  "$ref": "#/definitions/stringlist-util"
801
+ },
802
+ "parallel": {
803
+ "anyOf": [
804
+ {
805
+ "type": "integer",
806
+ "minimum": 1
807
+ },
808
+ {
809
+ "enum": [
810
+ "auto"
811
+ ]
812
+ }
813
+ ]
814
+ },
815
+ "compress": {
816
+ "anyOf": [
817
+ {
818
+ "type": "object",
819
+ "additionalProperties": false,
820
+ "properties": {
821
+ "command": {
822
+ "type": "string"
823
+ },
824
+ "args": {
825
+ "$ref": "#/definitions/stringlist-util"
826
+ }
827
+ }
828
+ },
829
+ {
830
+ "type": "object",
831
+ "additionalProperties": false,
832
+ "properties": {
833
+ "type": {
834
+ "enum": [
835
+ "gzip",
836
+ "pigz"
837
+ ]
838
+ },
839
+ "args": {
840
+ "$ref": "#/definitions/stringlist-util"
841
+ }
842
+ }
843
+ }
844
+ ]
801
845
  }
802
846
  }
803
847
  },
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@datatruck/cli",
3
- "version": "0.17.1",
3
+ "version": "0.18.0",
4
4
  "dependencies": {
5
- "ajv": "^8.11.2",
5
+ "ajv": "^8.12.0",
6
6
  "async": "^3.2.4",
7
7
  "chalk": "^4.1.2",
8
8
  "cli-table3": "^0.6.3",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "optionalDependencies": {
19
19
  "ts-node": "^10.9.1",
20
- "yaml": "^2.2.0"
20
+ "yaml": "^2.2.1"
21
21
  },
22
22
  "engine": {
23
23
  "node": ">=16.0.0"
File without changes
File without changes
@@ -1,5 +1,5 @@
1
- import { ExecSettingsInterface } from "./process-util";
2
- export declare class GitUtil {
1
+ import { ExecSettingsInterface } from "./process";
2
+ export declare class Git {
3
3
  readonly options: {
4
4
  dir: string;
5
5
  log?: boolean;
@@ -8,22 +8,22 @@ export declare class GitUtil {
8
8
  dir: string;
9
9
  log?: boolean;
10
10
  });
11
- exec(args: string[], settings?: ExecSettingsInterface, cwd?: boolean): Promise<import("./process-util").ExecResultType>;
11
+ exec(args: string[], settings?: ExecSettingsInterface, cwd?: boolean): Promise<import("./process").ExecResultType>;
12
12
  canBeInit(repo: string): Promise<boolean>;
13
13
  clone(options: {
14
14
  repo: string;
15
15
  branch?: string;
16
16
  orphan?: boolean;
17
- }): Promise<import("./process-util").ExecResultType>;
17
+ }): Promise<import("./process").ExecResultType>;
18
18
  checkout(options: {
19
19
  branchName: string;
20
20
  orphan?: boolean;
21
- }): Promise<import("./process-util").ExecResultType>;
21
+ }): Promise<import("./process").ExecResultType>;
22
22
  checkBranch(options: {
23
23
  name: string;
24
24
  repo?: string;
25
25
  }): Promise<boolean>;
26
- removeAll(): Promise<import("./process-util").ExecResultType>;
26
+ removeAll(): Promise<import("./process").ExecResultType>;
27
27
  haveChanges(): Promise<boolean>;
28
28
  fetchCommitId(tag: string): Promise<string>;
29
29
  getTags(names?: string[]): Promise<{
@@ -31,8 +31,8 @@ export declare class GitUtil {
31
31
  message?: string | undefined;
32
32
  }[]>;
33
33
  addTag(name: string, message?: string): Promise<void>;
34
- pushTags(): Promise<import("./process-util").ExecResultType>;
34
+ pushTags(): Promise<import("./process").ExecResultType>;
35
35
  push(options: {
36
36
  branchName: string;
37
- }): Promise<import("./process-util").ExecResultType>;
37
+ }): Promise<import("./process").ExecResultType>;
38
38
  }
@@ -1,21 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GitUtil = void 0;
4
- const fs_util_1 = require("./fs-util");
5
- const process_util_1 = require("./process-util");
6
- class GitUtil {
3
+ exports.Git = void 0;
4
+ const fs_1 = require("./fs");
5
+ const process_1 = require("./process");
6
+ class Git {
7
7
  constructor(options) {
8
8
  this.options = options;
9
9
  }
10
10
  async exec(args, settings, cwd) {
11
- return await (0, process_util_1.exec)("git", args, { cwd: cwd === false ? undefined : this.options.dir }, {
11
+ return await (0, process_1.exec)("git", args, { cwd: cwd === false ? undefined : this.options.dir }, {
12
12
  log: this.options.log,
13
13
  ...(settings ?? {}),
14
14
  });
15
15
  }
16
16
  async canBeInit(repo) {
17
- return ((0, fs_util_1.isLocalDir)(repo) &&
18
- (!(await (0, fs_util_1.checkDir)(repo)) || !(await (0, fs_util_1.readDir)(repo)).length));
17
+ return ((0, fs_1.isLocalDir)(repo) &&
18
+ (!(await (0, fs_1.checkDir)(repo)) || !(await (0, fs_1.readDir)(repo)).length));
19
19
  }
20
20
  async clone(options) {
21
21
  return await this.exec([
@@ -101,4 +101,4 @@ class GitUtil {
101
101
  ]);
102
102
  }
103
103
  }
104
- exports.GitUtil = GitUtil;
104
+ exports.Git = Git;
File without changes
File without changes
@@ -1,5 +1,5 @@
1
- import { ExecResultType, ExecSettingsInterface } from "./process-util";
2
- import { UriType } from "./string-util";
1
+ import { ExecResultType, ExecSettingsInterface } from "./process";
2
+ import { UriType } from "./string";
3
3
  export type RepositoryType = {
4
4
  name?: string;
5
5
  env?: Record<string, string>;
@@ -36,7 +36,7 @@ export type BackupStreamType = {
36
36
  total_duration: number;
37
37
  snapshot_id: string;
38
38
  };
39
- export declare class ResticUtil {
39
+ export declare class Restic {
40
40
  readonly options: {
41
41
  log?: boolean;
42
42
  env: Record<string, string>;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ResticUtil = void 0;
4
- const fs_util_1 = require("./fs-util");
5
- const process_util_1 = require("./process-util");
6
- const string_util_1 = require("./string-util");
3
+ exports.Restic = void 0;
4
+ const fs_1 = require("./fs");
5
+ const process_1 = require("./process");
6
+ const string_1 = require("./string");
7
7
  const promises_1 = require("fs/promises");
8
8
  const path_1 = require("path");
9
- class ResticUtil {
9
+ class Restic {
10
10
  constructor(options) {
11
11
  this.options = options;
12
12
  }
@@ -24,10 +24,10 @@ class ResticUtil {
24
24
  : (await (0, promises_1.readFile)(input.password.path)).toString(),
25
25
  };
26
26
  }
27
- return `${input.backend}:${(0, string_util_1.formatUri)({ ...input, password: input.password }, hidePassword)}`;
27
+ return `${input.backend}:${(0, string_1.formatUri)({ ...input, password: input.password }, hidePassword)}`;
28
28
  }
29
29
  async exec(args, settings, options) {
30
- return await (0, process_util_1.exec)("restic", args, {
30
+ return await (0, process_1.exec)("restic", args, {
31
31
  stdio: ["ignore", "pipe", "pipe"],
32
32
  env: { ...process.env, ...this.options.env },
33
33
  cwd: options?.cwd,
@@ -185,7 +185,7 @@ class ResticUtil {
185
185
  const progressInterval = options.progressInterval ?? 30000;
186
186
  async function progressRutine() {
187
187
  try {
188
- const total_bytes = await (0, fs_util_1.fastFolderSizeAsync)(options.target);
188
+ const total_bytes = await (0, fs_1.fastFolderSizeAsync)(options.target);
189
189
  options.onStream?.({
190
190
  message_type: "restore-status",
191
191
  total_bytes,
@@ -219,4 +219,4 @@ class ResticUtil {
219
219
  }
220
220
  }
221
221
  }
222
- exports.ResticUtil = ResticUtil;
222
+ exports.Restic = Restic;
File without changes
File without changes
@@ -59,8 +59,8 @@ export declare const params: {
59
59
  action: string;
60
60
  };
61
61
  pkgRestorePath: {
62
- packageName: string;
63
62
  path: string;
63
+ packageName: string;
64
64
  snapshotId: string;
65
65
  temp: string;
66
66
  snapshotDate: string;
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.params = exports.dbNameParams = exports.pkgRestorePathParams = exports.pkgExcludeParams = exports.pkgIncludeParams = exports.pkgPathParams = exports.resolvePackages = exports.resolvePackage = exports.resolveDatabaseName = exports.resolvePackagePath = exports.filterPackages = exports.filterRepository = exports.findRepositoryOrFail = void 0;
4
4
  const AppError_1 = require("../../Error/AppError");
5
- const fs_util_1 = require("../fs-util");
6
- const string_util_1 = require("../string-util");
5
+ const fs_1 = require("../fs");
6
+ const string_1 = require("../string");
7
7
  const micromatch_1 = require("micromatch");
8
8
  function findRepositoryOrFail(config, repositoryName) {
9
9
  const repo = config.repositories.find((v) => v.name === repositoryName);
@@ -21,8 +21,8 @@ function filterRepository(repository, action) {
21
21
  }
22
22
  exports.filterRepository = filterRepository;
23
23
  function filterPackages(config, options) {
24
- const packagePatterns = (0, string_util_1.makePathPatterns)(options.packageNames);
25
- const taskNamePatterns = (0, string_util_1.makePathPatterns)(options.packageTaskNames);
24
+ const packagePatterns = (0, string_1.makePathPatterns)(options.packageNames);
25
+ const taskNamePatterns = (0, string_1.makePathPatterns)(options.packageTaskNames);
26
26
  return config.packages
27
27
  .map((pkg) => {
28
28
  pkg = Object.assign({}, pkg);
@@ -38,7 +38,7 @@ function filterPackages(config, options) {
38
38
  return pkg;
39
39
  })
40
40
  .filter((pkg) => {
41
- if (taskNamePatterns && !(0, string_util_1.checkMatch)(pkg.task?.name, taskNamePatterns))
41
+ if (taskNamePatterns && !(0, string_1.checkMatch)(pkg.task?.name, taskNamePatterns))
42
42
  return false;
43
43
  return ((typeof pkg.enabled !== "boolean" || pkg.enabled) &&
44
44
  !!pkg.repositoryNames?.length &&
@@ -47,16 +47,16 @@ function filterPackages(config, options) {
47
47
  }
48
48
  exports.filterPackages = filterPackages;
49
49
  function resolvePackagePath(value, params) {
50
- return (0, string_util_1.render)(value, {
50
+ return (0, string_1.render)(value, {
51
51
  ...params,
52
52
  ...{
53
- temp: (0, fs_util_1.tmpDir)("pkg"),
53
+ temp: (0, fs_1.tmpDir)("pkg"),
54
54
  },
55
55
  });
56
56
  }
57
57
  exports.resolvePackagePath = resolvePackagePath;
58
58
  function resolveDatabaseName(value, params) {
59
- return (0, string_util_1.render)(value, params);
59
+ return (0, string_1.render)(value, params);
60
60
  }
61
61
  exports.resolveDatabaseName = resolveDatabaseName;
62
62
  function resolvePackage(pkg, params) {
@@ -67,9 +67,9 @@ function resolvePackage(pkg, params) {
67
67
  path: undefined,
68
68
  };
69
69
  if (pkg.include)
70
- pkg.include = pkg.include.map((v) => typeof v === "string" ? (0, string_util_1.render)(v, pkgParams) : v);
70
+ pkg.include = pkg.include.map((v) => typeof v === "string" ? (0, string_1.render)(v, pkgParams) : v);
71
71
  if (pkg.exclude)
72
- pkg.exclude = pkg.exclude.map((v) => typeof v === "string" ? (0, string_util_1.render)(v, pkgParams) : v);
72
+ pkg.exclude = pkg.exclude.map((v) => typeof v === "string" ? (0, string_1.render)(v, pkgParams) : v);
73
73
  if (pkg.path)
74
74
  pkg.path = resolvePackagePath(pkg.path, pkgParams);
75
75
  if (pkg.restorePath)
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parsePaths = void 0;
4
- const process_util_1 = require("../process-util");
4
+ const process_1 = require("../process");
5
5
  async function parsePaths(values, options) {
6
6
  let paths = [];
7
7
  for (const value of values) {
@@ -9,7 +9,7 @@ async function parsePaths(values, options) {
9
9
  paths.push(value);
10
10
  }
11
11
  else if (value.type === "spawn") {
12
- const spawnResult = await (0, process_util_1.exec)(value.command, value.args, { cwd: options.cwd }, { log: options.verbose, stderr: { save: true }, stdout: { save: true } });
12
+ const spawnResult = await (0, process_1.exec)(value.command, value.args, { cwd: options.cwd }, { log: options.verbose, stderr: { save: true }, stdout: { save: true } });
13
13
  const spawnFiles = [spawnResult.stderr, spawnResult.stdout].flatMap((text) => text
14
14
  .split(/\r?\n/)
15
15
  .map((v) => v.trim())
@@ -1,4 +1,4 @@
1
1
  import { SnapshotGroupByType } from "../../Action/SnapshotsAction";
2
2
  import { SnapshotResultType } from "../../Repository/RepositoryAbstract";
3
- import { FilterByLastOptionsType } from "../date-util";
3
+ import { FilterByLastOptionsType } from "../date";
4
4
  export declare function groupAndFilter<TSnapshot extends SnapshotResultType>(snapshots: TSnapshot[], groupByKey?: SnapshotGroupByType[], filter?: FilterByLastOptionsType | ((groupedSnapshots: TSnapshot[]) => FilterByLastOptionsType), reasons?: Record<number, string[]>): TSnapshot[];
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.groupAndFilter = void 0;
4
- const date_util_1 = require("../date-util");
5
- const object_util_1 = require("../object-util");
4
+ const date_1 = require("../date");
5
+ const object_1 = require("../object");
6
6
  function groupAndFilter(snapshots, groupByKey, filter, reasons) {
7
7
  const grouped = groupByKey?.length
8
- ? (0, object_util_1.groupBy)(snapshots, groupByKey)
8
+ ? (0, object_1.groupBy)(snapshots, groupByKey)
9
9
  : { "": snapshots };
10
10
  const result = [];
11
11
  for (const key in grouped) {
@@ -13,7 +13,7 @@ function groupAndFilter(snapshots, groupByKey, filter, reasons) {
13
13
  const groupReasons = reasons
14
14
  ? {}
15
15
  : undefined;
16
- result.push(...(0, date_util_1.filterByLast)(grouped[key], typeof filter === "function" ? filter(grouped[key]) : filter, groupReasons));
16
+ result.push(...(0, date_1.filterByLast)(grouped[key], typeof filter === "function" ? filter(grouped[key]) : filter, groupReasons));
17
17
  if (groupReasons && reasons) {
18
18
  for (const groupItemIndex in groupReasons) {
19
19
  const snapshot = grouped[key][groupItemIndex];
File without changes
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createChron = exports.filterByLast = void 0;
7
- const string_util_1 = require("./string-util");
7
+ const string_1 = require("./string");
8
8
  const dayjs_1 = __importDefault(require("dayjs"));
9
9
  const advancedFormat_1 = __importDefault(require("dayjs/plugin/advancedFormat"));
10
10
  const isoWeek_1 = __importDefault(require("dayjs/plugin/isoWeek"));
@@ -82,7 +82,7 @@ function createChron() {
82
82
  throw new Error(`Chron was not started`);
83
83
  const seconds = (Date.now() - startTime) / 1000;
84
84
  if (formatted)
85
- return (0, string_util_1.formatSeconds)(seconds);
85
+ return (0, string_1.formatSeconds)(seconds);
86
86
  return seconds;
87
87
  },
88
88
  };
File without changes
File without changes
@@ -2,7 +2,9 @@
2
2
  /// <reference types="node" />
3
3
  /// <reference types="node" />
4
4
  /// <reference types="node" />
5
- import { Dirent, Stats } from "fs";
5
+ import { Progress } from "./progress";
6
+ import { Entry, Options } from "fast-glob";
7
+ import { Dirent, ReadStream, Stats } from "fs";
6
8
  import { WriteStream } from "fs";
7
9
  import { Interface } from "readline";
8
10
  export declare const isWSLSystem: boolean;
@@ -51,7 +53,7 @@ export declare function writeGitIgnoreList(options: {
51
53
  paths: NodeJS.ReadableStream | string[];
52
54
  outDir: string;
53
55
  }): Promise<string>;
54
- export declare function waitForClose(stream: WriteStream): Promise<WriteStream>;
56
+ export declare function waitForClose(stream: WriteStream | ReadStream): Promise<void>;
55
57
  export declare function copyFileWithStreams(source: string, target: string): Promise<unknown>;
56
58
  export declare function updateFileStats(path: string, fileInfo: Stats): Promise<void>;
57
59
  export declare function isNotFoundError(error: unknown): boolean;
@@ -97,4 +99,23 @@ export declare function cpy(options: {
97
99
  files: number;
98
100
  dirs: number;
99
101
  }>;
102
+ export declare function createFileScanner(options: {
103
+ glob: Options & {
104
+ include: string[];
105
+ };
106
+ onProgress: (data: Progress) => Promise<void>;
107
+ disableCounting?: boolean;
108
+ disableEndProgress?: boolean;
109
+ }): Promise<{
110
+ total: number;
111
+ current: number;
112
+ progress: (description: string, data: {
113
+ path?: string;
114
+ current: number;
115
+ type?: "start" | "end";
116
+ percent?: number;
117
+ }) => Promise<void>;
118
+ updateProgress: (end?: boolean) => Promise<void>;
119
+ start: (cb?: ((entry: Required<Entry>) => any) | undefined) => Promise<void>;
120
+ }>;
100
121
  export {};