@datatruck/cli 0.34.0 → 0.34.2

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 (51) hide show
  1. package/config.schema.json +337 -72
  2. package/lib/actions/BackupAction.d.ts +4 -4
  3. package/lib/actions/BackupAction.js +2 -2
  4. package/lib/actions/CopyAction.d.ts +3 -3
  5. package/lib/actions/CopyAction.js +2 -2
  6. package/lib/actions/RestoreAction.d.ts +4 -4
  7. package/lib/actions/RestoreAction.js +2 -2
  8. package/lib/commands/CleanCacheCommand.js +2 -2
  9. package/lib/commands/CommandAbstract.d.ts +4 -4
  10. package/lib/commands/CommandAbstract.js +1 -1
  11. package/lib/commands/ConfigCommand.js +2 -2
  12. package/lib/commands/InitCommand.js +2 -2
  13. package/lib/commands/PruneCommand.js +2 -2
  14. package/lib/commands/SnapshotsCommand.js +2 -2
  15. package/lib/repositories/GitRepository.js +6 -6
  16. package/lib/repositories/ResticRepository.d.ts +1 -1
  17. package/lib/repositories/ResticRepository.js +10 -10
  18. package/lib/tasks/GitTask.js +33 -50
  19. package/lib/tasks/MariadbTask.js +43 -56
  20. package/lib/tasks/MssqlTask.js +5 -11
  21. package/lib/tasks/MysqlDumpTask.js +4 -4
  22. package/lib/tasks/PostgresqlDumpTask.d.ts +1 -1
  23. package/lib/tasks/PostgresqlDumpTask.js +9 -32
  24. package/lib/tasks/SqlDumpTaskAbstract.d.ts +1 -2
  25. package/lib/tasks/SqlDumpTaskAbstract.js +1 -1
  26. package/lib/utils/async-process.d.ts +66 -0
  27. package/lib/utils/async-process.js +242 -0
  28. package/lib/utils/async.d.ts +3 -5
  29. package/lib/utils/async.js +2 -2
  30. package/lib/utils/{DataFormat.d.ts → data-format.d.ts} +4 -4
  31. package/lib/utils/{DataFormat.js → data-format.js} +1 -1
  32. package/lib/utils/datatruck/command.d.ts +2 -2
  33. package/lib/utils/datatruck/config-type.d.ts +1 -1
  34. package/lib/utils/datatruck/cron-server.js +2 -2
  35. package/lib/utils/fs.d.ts +1 -2
  36. package/lib/utils/fs.js +3 -10
  37. package/lib/utils/{Git.d.ts → git.d.ts} +9 -7
  38. package/lib/utils/{Git.js → git.js} +30 -29
  39. package/lib/utils/list.d.ts +4 -4
  40. package/lib/utils/list.js +1 -1
  41. package/lib/utils/mysql.d.ts +8 -10
  42. package/lib/utils/mysql.js +60 -79
  43. package/lib/utils/process.d.ts +3 -92
  44. package/lib/utils/process.js +7 -311
  45. package/lib/utils/{Restic.d.ts → restic.d.ts} +10 -9
  46. package/lib/utils/{Restic.js → restic.js} +72 -82
  47. package/lib/utils/spawnSteps.js +9 -10
  48. package/lib/utils/stream.d.ts +8 -2
  49. package/lib/utils/stream.js +10 -3
  50. package/lib/utils/tar.js +29 -49
  51. package/package.json +2 -2
@@ -1,10 +1,10 @@
1
1
  import { PreSnapshot } from "../repositories/RepositoryAbstract";
2
- import { DataFormat } from "../utils/DataFormat";
2
+ import { DataFormat } from "../utils/data-format";
3
3
  import type { Config, PackageConfig, RepositoryConfig } from "../utils/datatruck/config-type";
4
4
  import { ReportListTaskContext } from "../utils/datatruck/report-list";
5
5
  import { Listr3TaskResultEnd } from "../utils/list";
6
6
  import { Progress, ProgressMode } from "../utils/progress";
7
- import { Streams } from "../utils/stream";
7
+ import { StdStreams } from "../utils/stream";
8
8
  import { IfRequireKeys } from "../utils/ts";
9
9
  export type BackupActionOptions = {
10
10
  repositoryNames?: string[];
@@ -17,7 +17,7 @@ export type BackupActionOptions = {
17
17
  date?: string;
18
18
  tty?: "auto" | boolean;
19
19
  progress?: ProgressMode;
20
- streams?: Streams;
20
+ streams?: StdStreams;
21
21
  prune?: boolean;
22
22
  };
23
23
  type Context = {
@@ -75,7 +75,7 @@ export declare class BackupAction<TRequired extends boolean = true> {
75
75
  bytes: number;
76
76
  }>;
77
77
  dataFormat(result: Listr3TaskResultEnd<Context>[], options?: {
78
- streams?: Streams;
78
+ streams?: StdStreams;
79
79
  verbose?: number;
80
80
  }): DataFormat;
81
81
  exec(): Promise<(import("../utils/list").List3SummaryResult | import("../utils/list").Listr3TaskResult<Context>)[]>;
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BackupAction = void 0;
7
- const DataFormat_1 = require("../utils/DataFormat");
8
7
  const bytes_1 = require("../utils/bytes");
9
8
  const cli_1 = require("../utils/cli");
9
+ const data_format_1 = require("../utils/data-format");
10
10
  const config_1 = require("../utils/datatruck/config");
11
11
  const report_list_1 = require("../utils/datatruck/report-list");
12
12
  const repository_1 = require("../utils/datatruck/repository");
@@ -132,7 +132,7 @@ class BackupAction {
132
132
  }),
133
133
  });
134
134
  };
135
- return new DataFormat_1.DataFormat({
135
+ return new data_format_1.DataFormat({
136
136
  streams: options.streams,
137
137
  json: result,
138
138
  list: () => result
@@ -1,11 +1,11 @@
1
1
  import { RepositoryAbstract, Snapshot } from "../repositories/RepositoryAbstract";
2
- import { DataFormat } from "../utils/DataFormat";
2
+ import { DataFormat } from "../utils/data-format";
3
3
  import type { Config, RepositoryConfig } from "../utils/datatruck/config-type";
4
4
  import { ReportListTaskContext } from "../utils/datatruck/report-list";
5
5
  import { Listr3TaskResultEnd } from "../utils/list";
6
6
  import { StrictMap } from "../utils/object";
7
7
  import { Progress, ProgressMode } from "../utils/progress";
8
- import { Streams } from "../utils/stream";
8
+ import { StdStreams } from "../utils/stream";
9
9
  import { IfRequireKeys } from "../utils/ts";
10
10
  export type CopyActionOptions = {
11
11
  ids?: string[];
@@ -39,7 +39,7 @@ export declare class CopyAction<TRequired extends boolean = true> {
39
39
  readonly options: IfRequireKeys<TRequired, CopyActionOptions>;
40
40
  constructor(config: Config, options: IfRequireKeys<TRequired, CopyActionOptions>);
41
41
  dataFormat(result: Listr3TaskResultEnd<Context>[], options?: {
42
- streams?: Streams;
42
+ streams?: StdStreams;
43
43
  verbose?: number;
44
44
  }): DataFormat;
45
45
  protected fetchSnapshots(repo: RepositoryAbstract<any>): Promise<Snapshot[]>;
@@ -49,9 +49,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
49
49
  };
50
50
  Object.defineProperty(exports, "__esModule", { value: true });
51
51
  exports.CopyAction = void 0;
52
- const DataFormat_1 = require("../utils/DataFormat");
53
52
  const bytes_1 = require("../utils/bytes");
54
53
  const cli_1 = require("../utils/cli");
54
+ const data_format_1 = require("../utils/data-format");
55
55
  const config_1 = require("../utils/datatruck/config");
56
56
  const report_list_1 = require("../utils/datatruck/report-list");
57
57
  const repository_1 = require("../utils/datatruck/repository");
@@ -95,7 +95,7 @@ class CopyAction {
95
95
  }),
96
96
  });
97
97
  };
98
- return new DataFormat_1.DataFormat({
98
+ return new data_format_1.DataFormat({
99
99
  streams: options.streams,
100
100
  json: result,
101
101
  table: {
@@ -1,10 +1,10 @@
1
1
  import { Snapshot } from "../repositories/RepositoryAbstract";
2
2
  import { TaskAbstract } from "../tasks/TaskAbstract";
3
- import { DataFormat } from "../utils/DataFormat";
3
+ import { DataFormat } from "../utils/data-format";
4
4
  import type { Config, PackageConfig } from "../utils/datatruck/config-type";
5
5
  import { Listr3TaskResultEnd } from "../utils/list";
6
6
  import { Progress, ProgressMode } from "../utils/progress";
7
- import { Streams } from "../utils/stream";
7
+ import { StdStreams } from "../utils/stream";
8
8
  import { GargabeCollector } from "../utils/temp";
9
9
  import { IfRequireKeys } from "../utils/ts";
10
10
  export type RestoreActionOptions = {
@@ -19,7 +19,7 @@ export type RestoreActionOptions = {
19
19
  initial?: boolean;
20
20
  tty?: "auto" | boolean;
21
21
  progress?: ProgressMode;
22
- streams?: Streams;
22
+ streams?: StdStreams;
23
23
  };
24
24
  type RestoreSnapshot = Snapshot & {
25
25
  repositoryName: string;
@@ -53,7 +53,7 @@ export declare class RestoreAction<TRequired extends boolean = true> {
53
53
  snapshotPath: string | undefined;
54
54
  }>;
55
55
  dataFormat(result: Listr3TaskResultEnd<Context>[], options?: {
56
- streams?: Streams;
56
+ streams?: StdStreams;
57
57
  verbose?: number;
58
58
  }): DataFormat;
59
59
  exec(): Promise<(import("../utils/list").List3SummaryResult | import("../utils/list").Listr3TaskResult<Context>)[]>;
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.RestoreAction = void 0;
7
- const DataFormat_1 = require("../utils/DataFormat");
8
7
  const cli_1 = require("../utils/cli");
8
+ const data_format_1 = require("../utils/data-format");
9
9
  const config_1 = require("../utils/datatruck/config");
10
10
  const repository_1 = require("../utils/datatruck/repository");
11
11
  const task_1 = require("../utils/datatruck/task");
@@ -117,7 +117,7 @@ class RestoreAction {
117
117
  }),
118
118
  });
119
119
  };
120
- return new DataFormat_1.DataFormat({
120
+ return new data_format_1.DataFormat({
121
121
  streams: options.streams,
122
122
  json: result,
123
123
  table: {
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CleanCacheCommand = void 0;
4
4
  const CleanCacheAction_1 = require("../actions/CleanCacheAction");
5
- const DataFormat_1 = require("../utils/DataFormat");
6
5
  const bytes_1 = require("../utils/bytes");
6
+ const data_format_1 = require("../utils/data-format");
7
7
  const CommandAbstract_1 = require("./CommandAbstract");
8
8
  class CleanCacheCommand extends CommandAbstract_1.CommandAbstract {
9
9
  optionsConfig() {
@@ -14,7 +14,7 @@ class CleanCacheCommand extends CommandAbstract_1.CommandAbstract {
14
14
  verbose: !!this.globalOptions.verbose,
15
15
  });
16
16
  const result = await cleanCache.exec();
17
- const dataFormat = new DataFormat_1.DataFormat({
17
+ const dataFormat = new data_format_1.DataFormat({
18
18
  streams: this.streams,
19
19
  json: result,
20
20
  table: {
@@ -1,8 +1,8 @@
1
- import { DataFormatType } from "../utils/DataFormat";
2
1
  import { OptionsConfig } from "../utils/cli";
2
+ import { DataFormatType } from "../utils/data-format";
3
3
  import type { Config } from "../utils/datatruck/config-type";
4
4
  import { ProgressMode } from "../utils/progress";
5
- import { Streams } from "../utils/stream";
5
+ import { StdStreams } from "../utils/stream";
6
6
  import { If, SimilarObject } from "../utils/ts";
7
7
  export type GlobalOptions<TResolved = false> = {
8
8
  config: string | Config;
@@ -19,8 +19,8 @@ export declare abstract class CommandAbstract<TUnresolvedOptions, TOptions exten
19
19
  readonly inputOptions: TUnresolvedOptions;
20
20
  readonly configPath?: string | undefined;
21
21
  readonly options: TOptions;
22
- readonly streams: Streams;
23
- constructor(globalOptions: GlobalOptions<true>, inputOptions: TUnresolvedOptions, streams?: Partial<Streams>, configPath?: string | undefined);
22
+ readonly streams: StdStreams;
23
+ constructor(globalOptions: GlobalOptions<true>, inputOptions: TUnresolvedOptions, streams?: Partial<StdStreams>, configPath?: string | undefined);
24
24
  abstract optionsConfig(): OptionsConfig<TUnresolvedOptions, TOptions>;
25
25
  protected castOptionsConfig(options: OptionsConfig<TUnresolvedOptions, TOptions>): OptionsConfig<TUnresolvedOptions, TOptions>;
26
26
  abstract exec(): Promise<{
@@ -14,7 +14,7 @@ class CommandAbstract {
14
14
  this.inputOptions = inputOptions;
15
15
  this.configPath = configPath;
16
16
  this.options = (0, cli_1.parseOptions)(inputOptions, this.optionsConfig());
17
- this.streams = (0, stream_1.createStreams)(streams);
17
+ this.streams = (0, stream_1.createStdStreams)(streams);
18
18
  }
19
19
  castOptionsConfig(options) {
20
20
  return options;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConfigCommand = void 0;
4
4
  const ConfigAction_1 = require("../actions/ConfigAction");
5
- const DataFormat_1 = require("../utils/DataFormat");
5
+ const data_format_1 = require("../utils/data-format");
6
6
  const config_1 = require("../utils/datatruck/config");
7
7
  const string_1 = require("../utils/string");
8
8
  const CommandAbstract_1 = require("./CommandAbstract");
@@ -44,7 +44,7 @@ class ConfigCommand extends CommandAbstract_1.CommandAbstract {
44
44
  repositoryNames: pkg.repositoryNames ?? [],
45
45
  taskName: pkg.task?.name,
46
46
  }));
47
- const dataFormat = new DataFormat_1.DataFormat({
47
+ const dataFormat = new data_format_1.DataFormat({
48
48
  streams: this.streams,
49
49
  json: result,
50
50
  table: {
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InitCommand = void 0;
4
4
  const ConfigAction_1 = require("../actions/ConfigAction");
5
5
  const InitAction_1 = require("../actions/InitAction");
6
- const DataFormat_1 = require("../utils/DataFormat");
7
6
  const cli_1 = require("../utils/cli");
7
+ const data_format_1 = require("../utils/data-format");
8
8
  const string_1 = require("../utils/string");
9
9
  const CommandAbstract_1 = require("./CommandAbstract");
10
10
  class InitCommand extends CommandAbstract_1.CommandAbstract {
@@ -31,7 +31,7 @@ class InitCommand extends CommandAbstract_1.CommandAbstract {
31
31
  verbose: verbose > 0,
32
32
  });
33
33
  const result = await init.exec();
34
- const dataFormat = new DataFormat_1.DataFormat({
34
+ const dataFormat = new data_format_1.DataFormat({
35
35
  streams: this.streams,
36
36
  json: result,
37
37
  table: {
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PruneCommand = void 0;
4
4
  const ConfigAction_1 = require("../actions/ConfigAction");
5
5
  const PruneAction_1 = require("../actions/PruneAction");
6
- const DataFormat_1 = require("../utils/DataFormat");
7
6
  const cli_1 = require("../utils/cli");
7
+ const data_format_1 = require("../utils/data-format");
8
8
  const string_1 = require("../utils/string");
9
9
  const CommandAbstract_1 = require("./CommandAbstract");
10
10
  class PruneCommand extends CommandAbstract_1.CommandAbstract {
@@ -122,7 +122,7 @@ class PruneCommand extends CommandAbstract_1.CommandAbstract {
122
122
  returnsAll: this.options.showAll,
123
123
  });
124
124
  const result = await prune.exec();
125
- const dataFormat = new DataFormat_1.DataFormat({
125
+ const dataFormat = new data_format_1.DataFormat({
126
126
  streams: this.streams,
127
127
  json: result,
128
128
  table: {
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SnapshotsCommand = void 0;
4
4
  const ConfigAction_1 = require("../actions/ConfigAction");
5
5
  const SnapshotsAction_1 = require("../actions/SnapshotsAction");
6
- const DataFormat_1 = require("../utils/DataFormat");
7
6
  const bytes_1 = require("../utils/bytes");
7
+ const data_format_1 = require("../utils/data-format");
8
8
  const string_1 = require("../utils/string");
9
9
  const CommandAbstract_1 = require("./CommandAbstract");
10
10
  class SnapshotsCommand extends CommandAbstract_1.CommandAbstract {
@@ -118,7 +118,7 @@ class SnapshotsCommand extends CommandAbstract_1.CommandAbstract {
118
118
  tags: this.options.tag,
119
119
  });
120
120
  const result = await snapshots.exec();
121
- const dataFormat = new DataFormat_1.DataFormat({
121
+ const dataFormat = new data_format_1.DataFormat({
122
122
  streams: this.streams,
123
123
  json: result,
124
124
  table: {
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.GitRepository = exports.gitRepositoryName = void 0;
7
- const Git_1 = require("../utils/Git");
8
7
  const cli_1 = require("../utils/cli");
9
8
  const paths_1 = require("../utils/datatruck/paths");
10
9
  const fs_1 = require("../utils/fs");
10
+ const git_1 = require("../utils/git");
11
11
  const string_1 = require("../utils/string");
12
12
  const temp_1 = require("../utils/temp");
13
13
  const RepositoryAbstract_1 = require("./RepositoryAbstract");
@@ -46,7 +46,7 @@ class GitRepository extends RepositoryAbstract_1.RepositoryAbstract {
46
46
  return `${GitRepository.refPrefix}/${packageName}`;
47
47
  }
48
48
  async init(data) {
49
- const git = new Git_1.Git({
49
+ const git = new git_1.Git({
50
50
  dir: (0, temp_1.tmpDir)(exports.gitRepositoryName, "repository", "init"),
51
51
  log: data.options.verbose,
52
52
  });
@@ -73,7 +73,7 @@ class GitRepository extends RepositoryAbstract_1.RepositoryAbstract {
73
73
  }
74
74
  }
75
75
  async prune(data) {
76
- const git = new Git_1.Git({
76
+ const git = new git_1.Git({
77
77
  dir: await (0, temp_1.mkTmpDir)(exports.gitRepositoryName, "repo", "prune"),
78
78
  log: data.options.verbose,
79
79
  });
@@ -96,7 +96,7 @@ class GitRepository extends RepositoryAbstract_1.RepositoryAbstract {
96
96
  await git.exec(["push", "--delete", "origin", data.snapshot.originalId]);
97
97
  }
98
98
  async fetchSnapshots(data) {
99
- const git = new Git_1.Git({
99
+ const git = new git_1.Git({
100
100
  dir: await (0, temp_1.mkTmpDir)(exports.gitRepositoryName, "repo", "snapshots"),
101
101
  log: data.options.verbose,
102
102
  });
@@ -137,7 +137,7 @@ class GitRepository extends RepositoryAbstract_1.RepositoryAbstract {
137
137
  const path = pkg.path;
138
138
  const tmpPath = await (0, temp_1.mkTmpDir)(exports.gitRepositoryName, "repo", "backup");
139
139
  const branchName = GitRepository.buildBranchName(data.package.name);
140
- const git = new Git_1.Git({
140
+ const git = new git_1.Git({
141
141
  dir: tmpPath,
142
142
  log: data.options.verbose,
143
143
  });
@@ -217,7 +217,7 @@ class GitRepository extends RepositoryAbstract_1.RepositoryAbstract {
217
217
  id: data.snapshot.id,
218
218
  package: data.package.name,
219
219
  });
220
- const git = new Git_1.Git({
220
+ const git = new git_1.Git({
221
221
  dir: restorePath,
222
222
  log: data.options.verbose,
223
223
  });
@@ -1,4 +1,4 @@
1
- import { ResticRepositoryUri } from "../utils/Restic";
1
+ import { ResticRepositoryUri } from "../utils/restic";
2
2
  import { RepositoryAbstract, RepoBackupData, RepoInitData, RepoRestoreData, RepoFetchSnapshotsData, Snapshot, SnapshotTagObject, SnapshotTagEnum, RepoPruneData, RepoCopyData } from "./RepositoryAbstract";
3
3
  export type ResticRepositoryConfig = {
4
4
  password: string | {
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ResticRepository = exports.resticRepositoryName = void 0;
7
- const Restic_1 = require("../utils/Restic");
8
7
  const cli_1 = require("../utils/cli");
9
8
  const error_1 = require("../utils/datatruck/error");
10
9
  const paths_1 = require("../utils/datatruck/paths");
11
10
  const fs_1 = require("../utils/fs");
12
11
  const math_1 = require("../utils/math");
12
+ const restic_1 = require("../utils/restic");
13
13
  const string_1 = require("../utils/string");
14
14
  const temp_1 = require("../utils/temp");
15
15
  const RepositoryAbstract_1 = require("./RepositoryAbstract");
@@ -28,7 +28,7 @@ class ResticRepository extends RepositoryAbstract_1.RepositoryAbstract {
28
28
  ...(typeof this.config.password === "string"
29
29
  ? { RESTIC_PASSWORD: this.config.password }
30
30
  : { RESTIC_PASSWORD_FILE: (0, path_1.resolve)(this.config.password.path) }),
31
- RESTIC_REPOSITORY: await Restic_1.Restic.formatRepository(this.config.repository),
31
+ RESTIC_REPOSITORY: await restic_1.Restic.formatRepository(this.config.repository),
32
32
  });
33
33
  }
34
34
  static buildSnapshotTag(name, value) {
@@ -69,7 +69,7 @@ class ResticRepository extends RepositoryAbstract_1.RepositoryAbstract {
69
69
  return (0, fs_1.fetchDiskStats)(config.repository.path);
70
70
  }
71
71
  async init(data) {
72
- const restic = new Restic_1.Restic({
72
+ const restic = new restic_1.Restic({
73
73
  env: await this.buildEnv(),
74
74
  log: data.options.verbose,
75
75
  });
@@ -79,7 +79,7 @@ class ResticRepository extends RepositoryAbstract_1.RepositoryAbstract {
79
79
  await restic.exec(["init"]);
80
80
  }
81
81
  async fetchSnapshots(data) {
82
- const restic = new Restic_1.Restic({
82
+ const restic = new restic_1.Restic({
83
83
  env: await this.buildEnv(),
84
84
  log: data.options.verbose,
85
85
  });
@@ -115,7 +115,7 @@ class ResticRepository extends RepositoryAbstract_1.RepositoryAbstract {
115
115
  }, []);
116
116
  }
117
117
  async prune(data) {
118
- const restic = new Restic_1.Restic({
118
+ const restic = new restic_1.Restic({
119
119
  env: await this.buildEnv(),
120
120
  log: data.options.verbose,
121
121
  });
@@ -125,7 +125,7 @@ class ResticRepository extends RepositoryAbstract_1.RepositoryAbstract {
125
125
  });
126
126
  }
127
127
  async backup(data) {
128
- const restic = new Restic_1.Restic({
128
+ const restic = new restic_1.Restic({
129
129
  env: await this.buildEnv(),
130
130
  log: data.options.verbose,
131
131
  });
@@ -278,13 +278,13 @@ class ResticRepository extends RepositoryAbstract_1.RepositoryAbstract {
278
278
  });
279
279
  if (!snapshot)
280
280
  throw new error_1.AppError(`Snapshot not found`);
281
- const restic = new Restic_1.Restic({
281
+ const restic = new restic_1.Restic({
282
282
  env: {
283
283
  ...(await this.buildEnv()),
284
284
  ...(typeof config.password === "string"
285
285
  ? { RESTIC_PASSWORD2: config.password }
286
286
  : { RESTIC_PASSWORD_FILE2: (0, path_1.resolve)(config.password.path) }),
287
- RESTIC_REPOSITORY2: await Restic_1.Restic.formatRepository(config.repository),
287
+ RESTIC_REPOSITORY2: await restic_1.Restic.formatRepository(config.repository),
288
288
  },
289
289
  log: data.options.verbose,
290
290
  });
@@ -301,7 +301,7 @@ class ResticRepository extends RepositoryAbstract_1.RepositoryAbstract {
301
301
  }
302
302
  async restore(data) {
303
303
  const restorePath = data.snapshotPath;
304
- const restic = new Restic_1.Restic({
304
+ const restic = new restic_1.Restic({
305
305
  env: await this.buildEnv(),
306
306
  log: data.options.verbose,
307
307
  });
@@ -316,7 +316,7 @@ class ResticRepository extends RepositoryAbstract_1.RepositoryAbstract {
316
316
  await restic.restore({
317
317
  id: snapshot.originalId,
318
318
  target: restorePath,
319
- onStream: async (streamData) => {
319
+ onStream: (streamData) => {
320
320
  if (streamData.message_type === "restore-status") {
321
321
  const current = Math.min(streamData.total_bytes, snapshot.size);
322
322
  data.onProgress({
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GitTask = exports.gitTaskName = void 0;
4
+ const async_process_1 = require("../utils/async-process");
4
5
  const cli_1 = require("../utils/cli");
5
6
  const fs_1 = require("../utils/fs");
6
7
  const math_1 = require("../utils/math");
7
- const process_1 = require("../utils/process");
8
+ const stream_1 = require("../utils/stream");
8
9
  const temp_1 = require("../utils/temp");
9
10
  const TaskAbstract_1 = require("./TaskAbstract");
10
11
  const assert_1 = require("assert");
@@ -12,7 +13,6 @@ const fs_2 = require("fs");
12
13
  const promises_1 = require("fs/promises");
13
14
  const micromatch_1 = require("micromatch");
14
15
  const path_1 = require("path");
15
- const readline_1 = require("readline");
16
16
  exports.gitTaskName = "git";
17
17
  class GitTask extends TaskAbstract_1.TaskAbstract {
18
18
  verbose;
@@ -34,10 +34,9 @@ class GitTask extends TaskAbstract_1.TaskAbstract {
34
34
  description: "Creating bundle",
35
35
  },
36
36
  });
37
- await (0, process_1.exec)(this.command, ["bundle", "create", bundlePath, "--all"], {
37
+ await async_process_1.AsyncProcess.exec(this.command, ["bundle", "create", bundlePath, "--all"], {
38
38
  cwd: path,
39
- }, {
40
- log: this.verbose,
39
+ $log: this.verbose,
41
40
  });
42
41
  // Config
43
42
  if (this.config.includeConfig ?? true) {
@@ -70,48 +69,33 @@ class GitTask extends TaskAbstract_1.TaskAbstract {
70
69
  continue;
71
70
  option.pathsPath = (0, path_1.join)(snapshotPath, `repo.${option.name}-paths.txt`);
72
71
  const stream = (0, fs_2.createWriteStream)(option.pathsPath);
73
- let streamError;
74
- stream.on("error", (e) => (streamError = e));
75
- try {
76
- await (0, process_1.exec)(this.command, [
77
- "-c",
78
- "core.quotepath=off",
79
- "ls-files",
80
- ...option.argv,
81
- "--exclude-standard",
82
- ], {
83
- cwd: data.package.path,
84
- }, {
85
- log: {
86
- exec: this.verbose,
87
- },
88
- onSpawn: (p) => {
89
- const iface = (0, readline_1.createInterface)(p.stdout, stream);
90
- iface.on("close", () => stream.end());
91
- iface.on("line", (path) => {
92
- path = path.trim();
93
- if (!path.length)
94
- return;
95
- let found = false;
96
- if (option.include === true) {
97
- found = true;
98
- }
99
- else if (option.include) {
100
- found = (0, micromatch_1.isMatch)(path, option.include);
101
- }
102
- if (found) {
103
- total++;
104
- stream.write(`${path}\n`);
105
- }
106
- });
107
- },
108
- });
109
- }
110
- finally {
111
- await new Promise((resolve) => stream.end(resolve));
112
- if (streamError)
113
- throw streamError;
114
- }
72
+ const p = new async_process_1.AsyncProcess(this.command, [
73
+ "-c",
74
+ "core.quotepath=off",
75
+ "ls-files",
76
+ ...option.argv,
77
+ "--exclude-standard",
78
+ ], {
79
+ cwd: data.package.path,
80
+ $log: this.verbose,
81
+ });
82
+ await Promise.all([
83
+ p.stdout.parseLines((path) => {
84
+ let found = false;
85
+ if (option.include === true) {
86
+ found = true;
87
+ }
88
+ else if (option.include) {
89
+ found = (0, micromatch_1.isMatch)(path, option.include);
90
+ }
91
+ if (found) {
92
+ total++;
93
+ stream.write(`${path}\n`);
94
+ }
95
+ }),
96
+ p.child.on("close", () => stream.end()),
97
+ (0, stream_1.waitForClose)(stream),
98
+ ]);
115
99
  }
116
100
  // Copy
117
101
  for (const option of lsFilesConfig) {
@@ -176,10 +160,9 @@ class GitTask extends TaskAbstract_1.TaskAbstract {
176
160
  };
177
161
  // Bundle
178
162
  const bundlePath = (0, path_1.join)(snapshotPath, "repo.bundle");
179
- await (0, process_1.exec)(this.command, ["clone", bundlePath, "."], {
163
+ await async_process_1.AsyncProcess.exec(this.command, ["clone", bundlePath, "."], {
180
164
  cwd: restorePath,
181
- }, {
182
- log: this.verbose,
165
+ $log: this.verbose,
183
166
  });
184
167
  await incrementProgress();
185
168
  // Config