@datatruck/cli 0.36.8 → 0.38.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 (74) hide show
  1. package/config.schema.json +168 -108
  2. package/lib/actions/BackupAction.d.ts +61 -20
  3. package/lib/actions/BackupAction.js +43 -17
  4. package/lib/actions/CleanCacheAction.d.ts +6 -7
  5. package/lib/actions/CleanCacheAction.js +2 -1
  6. package/lib/actions/ConfigAction.d.ts +3 -5
  7. package/lib/actions/ConfigAction.js +0 -1
  8. package/lib/actions/CopyAction.d.ts +43 -12
  9. package/lib/actions/CopyAction.js +31 -4
  10. package/lib/actions/ExportAction.d.ts +94 -0
  11. package/lib/actions/ExportAction.js +236 -0
  12. package/lib/actions/InitAction.d.ts +17 -7
  13. package/lib/actions/InitAction.js +9 -1
  14. package/lib/actions/PruneAction.d.ts +76 -17
  15. package/lib/actions/PruneAction.js +62 -2
  16. package/lib/actions/RestoreAction.d.ts +61 -22
  17. package/lib/actions/RestoreAction.js +46 -58
  18. package/lib/actions/SnapshotsAction.d.ts +80 -21
  19. package/lib/actions/SnapshotsAction.js +82 -1
  20. package/lib/cli.d.ts +0 -3
  21. package/lib/cli.js +31 -56
  22. package/lib/commands/BackupCommand.d.ts +121 -13
  23. package/lib/commands/BackupCommand.js +29 -54
  24. package/lib/commands/CleanCacheCommand.d.ts +10 -3
  25. package/lib/commands/CleanCacheCommand.js +14 -6
  26. package/lib/commands/CommandAbstract.d.ts +11 -10
  27. package/lib/commands/CommandAbstract.js +6 -9
  28. package/lib/commands/ConfigCommand.d.ts +72 -9
  29. package/lib/commands/ConfigCommand.js +36 -28
  30. package/lib/commands/CopyCommand.d.ts +103 -10
  31. package/lib/commands/CopyCommand.js +25 -44
  32. package/lib/commands/ExportCommand.d.ts +143 -0
  33. package/lib/commands/ExportCommand.js +50 -0
  34. package/lib/commands/InitCommand.d.ts +43 -7
  35. package/lib/commands/InitCommand.js +22 -19
  36. package/lib/commands/PruneCommand.d.ts +237 -17
  37. package/lib/commands/PruneCommand.js +27 -99
  38. package/lib/commands/RestoreCommand.d.ts +127 -13
  39. package/lib/commands/RestoreCommand.js +27 -53
  40. package/lib/commands/RunCommand.d.ts +29 -0
  41. package/lib/commands/RunCommand.js +44 -0
  42. package/lib/commands/SnapshotsCommand.d.ts +240 -23
  43. package/lib/commands/SnapshotsCommand.js +23 -101
  44. package/lib/commands/StartServerCommand.d.ts +10 -3
  45. package/lib/commands/StartServerCommand.js +23 -15
  46. package/lib/repositories/DatatruckRepository.js +1 -1
  47. package/lib/tasks/MssqlTask.js +1 -1
  48. package/lib/tasks/MysqlDumpTask.js +1 -1
  49. package/lib/tasks/SqlDumpTaskAbstract.js +2 -2
  50. package/lib/utils/cli.d.ts +1 -18
  51. package/lib/utils/cli.js +9 -49
  52. package/lib/utils/datatruck/command.d.ts +8 -5
  53. package/lib/utils/datatruck/command.js +8 -4
  54. package/lib/utils/datatruck/config-type.d.ts +4 -0
  55. package/lib/utils/datatruck/cron-server.d.ts +8 -39
  56. package/lib/utils/datatruck/cron-server.js +35 -57
  57. package/lib/utils/datatruck/job.d.ts +41 -0
  58. package/lib/utils/datatruck/job.js +82 -0
  59. package/lib/utils/datatruck/report-list.js +1 -1
  60. package/lib/utils/datatruck/repository.d.ts +1 -0
  61. package/lib/utils/datatruck/repository.js +8 -1
  62. package/lib/utils/list.d.ts +5 -0
  63. package/lib/utils/list.js +9 -0
  64. package/lib/utils/math.js +1 -1
  65. package/lib/utils/object.d.ts +5 -0
  66. package/lib/utils/object.js +10 -1
  67. package/lib/utils/options.d.ts +24 -0
  68. package/lib/utils/options.js +94 -0
  69. package/lib/utils/progress.js +1 -1
  70. package/lib/utils/restic.js +1 -1
  71. package/lib/utils/string.d.ts +2 -1
  72. package/lib/utils/string.js +5 -1
  73. package/lib/utils/watcher.js +1 -1
  74. package/package.json +4 -4
package/lib/cli.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.exec = exports.parseArgs = exports.buildArgs = void 0;
6
+ exports.parseArgs = void 0;
7
7
  const ConfigAction_1 = require("./actions/ConfigAction");
8
8
  const globalData_1 = __importDefault(require("./globalData"));
9
9
  const cli_1 = require("./utils/cli");
@@ -11,9 +11,9 @@ const command_1 = require("./utils/datatruck/command");
11
11
  const error_1 = require("./utils/error");
12
12
  const exit_1 = require("./utils/exit");
13
13
  const fs_1 = require("./utils/fs");
14
- const string_1 = require("./utils/string");
14
+ const options_1 = require("./utils/options");
15
15
  const temp_1 = require("./utils/temp");
16
- const chalk_1 = require("chalk");
16
+ const chalk_1 = __importDefault(require("chalk"));
17
17
  const commander_1 = require("commander");
18
18
  const fs_2 = require("fs");
19
19
  const path_1 = require("path");
@@ -26,57 +26,48 @@ function getGlobalOptions() {
26
26
  progress: parseBool(result.progress),
27
27
  };
28
28
  }
29
- function makeCommand(command) {
30
- const programCommand = program.command(command);
31
- const instance = (0, command_1.createCommand)(command, getGlobalOptions(), null);
32
- const options = instance.optionsConfig();
33
- for (const key in options) {
34
- const option = options[key];
35
- const description = `${option.description}${option.defaults ? ` (defaults: ${option.defaults})` : ""}`;
36
- if (option.required) {
37
- programCommand.requiredOption(option.option, description);
38
- }
39
- else {
40
- programCommand.option(option.option, description);
41
- }
42
- }
43
- return programCommand.action(makeCommandAction(command));
44
- }
45
- function makeCommandAction(command) {
29
+ function createCommandAction(Constructor) {
46
30
  return async function (options) {
47
31
  let exitCode = 1;
32
+ let error;
33
+ let errors;
48
34
  const globalOptions = getGlobalOptions();
49
35
  try {
50
- const configAction = new ConfigAction_1.ConfigAction({
51
- path: globalOptions.config,
52
- verbose: !!globalOptions.verbose,
53
- });
54
- const config = await configAction.exec();
36
+ const config = await ConfigAction_1.ConfigAction.fromGlobalOptionsWithPath(globalOptions);
55
37
  if (config.data.tempDir)
56
38
  globalData_1.default.tempDir = (0, path_1.isAbsolute)(config.data.tempDir)
57
39
  ? config.data.tempDir
58
40
  : (0, path_1.join)((0, path_1.dirname)(config.path), config.data.tempDir);
59
- const response = await (0, command_1.createCommand)(command, {
60
- ...globalOptions,
61
- config: config.data,
62
- }, options, {}, globalOptions.config).exec();
41
+ const command = new Constructor({ ...globalOptions }, options, {}, globalOptions.config);
42
+ const response = await command.exec();
43
+ errors = response.errors;
63
44
  exitCode = response.exitCode;
64
45
  }
65
46
  catch (e) {
66
- const error = e;
47
+ error = e;
48
+ }
49
+ if (errors?.length) {
50
+ console.error();
51
+ errors.forEach((error, index) => {
52
+ console.error(chalk_1.default.red(`${index + 1}. ` + error.stack ?? error.message));
53
+ if (errors[index + 1])
54
+ console.error();
55
+ });
56
+ }
57
+ if (error) {
67
58
  if (globalOptions.verbose) {
68
- console.error((0, chalk_1.red)(error.stack));
59
+ console.error(chalk_1.default.red(error.stack));
69
60
  }
70
61
  else {
71
62
  if (error instanceof error_1.AppError) {
72
- console.error((0, chalk_1.red)(error.message));
63
+ console.error(chalk_1.default.red(error.message));
73
64
  }
74
65
  else {
75
- console.error((0, chalk_1.red)(error.stack));
66
+ console.error(chalk_1.default.red(error.stack));
76
67
  }
77
68
  }
78
69
  }
79
- await (0, cli_1.waitForStdDrain)(5000);
70
+ await (0, cli_1.waitForStdDrain)(5_000);
80
71
  process.exit(exitCode);
81
72
  };
82
73
  }
@@ -92,23 +83,12 @@ program.option("-c,--config <path>", "Config path", process.env["DATATRUCK_CONFI
92
83
  program.option("--tty <value>", "TTY mode (auto, true, false)", "auto");
93
84
  program.option("--progress <value>", "Progress type (auto, true, false, interval, interval:[ms])", "auto");
94
85
  program.option("-o,--output-format <format>", "Output format (json, pjson, yaml, table, custom=$, tpl=name)", "table");
95
- makeCommand("startServer").alias("start");
96
- makeCommand("config").alias("c");
97
- makeCommand("init").alias("i");
98
- makeCommand("snapshots").alias("s");
99
- makeCommand("prune").alias("p");
100
- makeCommand("backup").alias("b");
101
- makeCommand("restore").alias("r");
102
- makeCommand("copy").alias("cp");
103
- makeCommand("cleanCache").alias("cc");
104
- function buildArgs(input, options) {
105
- const optionsArray = Object.keys(options).flatMap((name) => [
106
- `--${(0, string_1.snakeCase)(name, "-")}`,
107
- options[name],
108
- ]);
109
- return [input, ...optionsArray];
86
+ const Commands = Object.values(command_1.datatruckCommands)
87
+ .map((Command) => ({ Command, config: Command.config() }))
88
+ .sort((a, b) => a.config.name.localeCompare(b.config.name));
89
+ for (const { Command, config } of Commands) {
90
+ program.addCommand((0, options_1.createCommand)(config, createCommandAction(Command)));
110
91
  }
111
- exports.buildArgs = buildArgs;
112
92
  function parseArgs(args) {
113
93
  program.parse(args);
114
94
  const verbose = getGlobalOptions().verbose;
@@ -117,7 +97,7 @@ function parseArgs(args) {
117
97
  process.stdout.write(cli_1.showCursorCommand);
118
98
  console.info(`\nClosing... (reason: ${eventName})`);
119
99
  if (error instanceof Error)
120
- console.error((0, chalk_1.red)(error.stack));
100
+ console.error(error.stack);
121
101
  }
122
102
  if (!verbose)
123
103
  try {
@@ -133,8 +113,3 @@ function parseArgs(args) {
133
113
  });
134
114
  }
135
115
  exports.parseArgs = parseArgs;
136
- async function exec(input, options) {
137
- const argv = buildArgs(input, options);
138
- return parseArgs(argv);
139
- }
140
- exports.exec = exec;
@@ -1,18 +1,125 @@
1
- import type { RepositoryConfig } from "../utils/datatruck/config-type";
2
- import { If } from "../utils/ts";
1
+ import { InferOptions } from "../utils/options";
3
2
  import { CommandAbstract } from "./CommandAbstract";
4
- export type BackupCommandOptions<TResolved = false> = {
5
- package?: If<TResolved, string[]>;
6
- packageTask?: If<TResolved, string[]>;
7
- repository?: If<TResolved, string[]>;
8
- repositoryType?: If<TResolved, RepositoryConfig["type"][]>;
9
- tag?: If<TResolved, string[]>;
10
- dryRun?: boolean;
11
- date?: string;
12
- prune?: boolean;
3
+ export declare const backupCommandOptions: {
4
+ dryRun: {
5
+ description: string;
6
+ value: "boolean";
7
+ };
8
+ date: {
9
+ description: string;
10
+ };
11
+ prune: {
12
+ description: string;
13
+ value: "boolean";
14
+ };
15
+ repositoryNames: {
16
+ description: string;
17
+ shortFlag: string;
18
+ value: "array";
19
+ };
20
+ repositoryTypes: {
21
+ description: string;
22
+ shortFlag: string;
23
+ value: "array";
24
+ };
25
+ packageNames: {
26
+ description: string;
27
+ shortFlag: string;
28
+ value: "array";
29
+ };
30
+ packageTaskNames: {
31
+ description: string;
32
+ shortFlag: string;
33
+ value: "array";
34
+ };
35
+ tags: {
36
+ description: string;
37
+ shortFlag: string;
38
+ value: "array";
39
+ };
13
40
  };
14
- export declare class BackupCommand extends CommandAbstract<BackupCommandOptions<false>, BackupCommandOptions<true>> {
15
- optionsConfig(): import("../utils/cli").OptionsConfig<BackupCommandOptions<false>, BackupCommandOptions<true>>;
41
+ export type BackupCommandOptions = InferOptions<typeof backupCommandOptions>;
42
+ export declare class BackupCommand extends CommandAbstract<typeof backupCommandOptions> {
43
+ static config(): {
44
+ name: string;
45
+ alias: string;
46
+ options: {
47
+ dryRun: {
48
+ description: string;
49
+ value: "boolean";
50
+ };
51
+ date: {
52
+ description: string;
53
+ };
54
+ prune: {
55
+ description: string;
56
+ value: "boolean";
57
+ };
58
+ repositoryNames: {
59
+ description: string;
60
+ shortFlag: string;
61
+ value: "array";
62
+ };
63
+ repositoryTypes: {
64
+ description: string;
65
+ shortFlag: string;
66
+ value: "array";
67
+ };
68
+ packageNames: {
69
+ description: string;
70
+ shortFlag: string;
71
+ value: "array";
72
+ };
73
+ packageTaskNames: {
74
+ description: string;
75
+ shortFlag: string;
76
+ value: "array";
77
+ };
78
+ tags: {
79
+ description: string;
80
+ shortFlag: string;
81
+ value: "array";
82
+ };
83
+ };
84
+ };
85
+ get optionsConfig(): {
86
+ dryRun: {
87
+ description: string;
88
+ value: "boolean";
89
+ };
90
+ date: {
91
+ description: string;
92
+ };
93
+ prune: {
94
+ description: string;
95
+ value: "boolean";
96
+ };
97
+ repositoryNames: {
98
+ description: string;
99
+ shortFlag: string;
100
+ value: "array";
101
+ };
102
+ repositoryTypes: {
103
+ description: string;
104
+ shortFlag: string;
105
+ value: "array";
106
+ };
107
+ packageNames: {
108
+ description: string;
109
+ shortFlag: string;
110
+ value: "array";
111
+ };
112
+ packageTaskNames: {
113
+ description: string;
114
+ shortFlag: string;
115
+ value: "array";
116
+ };
117
+ tags: {
118
+ description: string;
119
+ shortFlag: string;
120
+ value: "array";
121
+ };
122
+ };
16
123
  exec(): Promise<{
17
124
  result: (import("../utils/list").List3SummaryResult | import("../utils/list").Listr3TaskResult<{
18
125
  snapshot: {
@@ -41,5 +148,6 @@ export declare class BackupCommand extends CommandAbstract<BackupCommandOptions<
41
148
  };
42
149
  } & import("../utils/datatruck/report-list").ReportListTaskContext>)[];
43
150
  exitCode: number;
151
+ errors: Error[];
44
152
  }>;
45
153
  }
@@ -1,76 +1,51 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BackupCommand = void 0;
3
+ exports.BackupCommand = exports.backupCommandOptions = void 0;
4
4
  const BackupAction_1 = require("../actions/BackupAction");
5
5
  const ConfigAction_1 = require("../actions/ConfigAction");
6
- const string_1 = require("../utils/string");
7
6
  const CommandAbstract_1 = require("./CommandAbstract");
7
+ exports.backupCommandOptions = {
8
+ ...BackupAction_1.backupActionOptions,
9
+ };
8
10
  class BackupCommand extends CommandAbstract_1.CommandAbstract {
9
- optionsConfig() {
10
- return this.castOptionsConfig({
11
- dryRun: {
12
- description: "Skip execution",
13
- option: "--dryRun",
14
- },
15
- package: {
16
- description: "Filter by package names",
17
- option: "-p,--package <values>",
18
- parser: string_1.parseStringList,
19
- },
20
- packageTask: {
21
- description: "Filter by package task names",
22
- option: "-pt,--package-task <values>",
23
- parser: string_1.parseStringList,
24
- },
25
- repository: {
26
- description: "Filter by repository names",
27
- option: "-r,--repository <values>",
28
- parser: string_1.parseStringList,
29
- },
30
- repositoryType: {
31
- description: "Filter by repository types",
32
- option: "-rt,--repository-type <values>",
33
- parser: (v) => (0, string_1.parseStringList)(v),
34
- },
35
- tag: {
36
- description: "Filter by tags",
37
- option: "-t,--tag <values>",
38
- parser: string_1.parseStringList,
39
- },
40
- date: {
41
- description: "Date time (ISO)",
42
- option: "--date <value>",
43
- },
44
- prune: {
45
- description: "Prune backups",
46
- option: "--prune",
47
- },
48
- });
11
+ static config() {
12
+ return {
13
+ name: "backup",
14
+ alias: "b",
15
+ options: exports.backupCommandOptions,
16
+ };
17
+ }
18
+ get optionsConfig() {
19
+ return exports.backupCommandOptions;
49
20
  }
50
21
  async exec() {
51
22
  const verbose = this.globalOptions.verbose ?? 0;
52
23
  const config = await ConfigAction_1.ConfigAction.fromGlobalOptions(this.globalOptions);
53
24
  const backup = new BackupAction_1.BackupAction(config, {
54
- packageNames: this.options.package,
55
- packageTaskNames: this.options.packageTask,
56
- repositoryNames: this.options.repository,
57
- repositoryTypes: this.options.repositoryType,
58
- tags: this.options.tag,
25
+ packageNames: this.options.packageNames,
26
+ packageTaskNames: this.options.packageTaskNames,
27
+ repositoryNames: this.options.repositoryNames,
28
+ repositoryTypes: this.options.repositoryTypes,
29
+ tags: this.options.tags,
59
30
  dryRun: this.options.dryRun,
60
- verbose: verbose > 0,
61
31
  date: this.options.date,
62
- tty: this.globalOptions.tty,
32
+ prune: this.options.prune,
33
+ verbose: verbose > 0,
34
+ }, {
63
35
  progress: this.globalOptions.progress,
64
36
  streams: this.streams,
65
- prune: this.options.prune,
37
+ tty: this.globalOptions.tty,
66
38
  });
67
- const result = await backup.exec();
39
+ const data = await backup.exec();
68
40
  if (this.globalOptions.outputFormat)
69
41
  backup
70
- .dataFormat(result, { streams: this.streams, verbose })
42
+ .dataFormat(data.result, {
43
+ verbose,
44
+ streams: this.streams,
45
+ errors: data.errors,
46
+ })
71
47
  .log(this.globalOptions.outputFormat);
72
- const exitCode = result.some((item) => item.error) ? 1 : 0;
73
- return { result, exitCode };
48
+ return data;
74
49
  }
75
50
  }
76
51
  exports.BackupCommand = BackupCommand;
@@ -1,7 +1,14 @@
1
+ import { InferOptions } from "../utils/options";
1
2
  import { CommandAbstract } from "./CommandAbstract";
2
- export type CleanCacheCommandOptions<TResolved = false> = {};
3
- export declare class CleanCacheCommand extends CommandAbstract<CleanCacheCommandOptions<false>, CleanCacheCommandOptions<true>> {
4
- optionsConfig(): import("../utils/cli").OptionsConfig<CleanCacheCommandOptions<false>, CleanCacheCommandOptions<true>>;
3
+ export declare const cleanCacheCommandOptions: {};
4
+ export type CleanCacheCommandOptions = InferOptions<typeof cleanCacheCommandOptions>;
5
+ export declare class CleanCacheCommand extends CommandAbstract<typeof cleanCacheCommandOptions> {
6
+ static config(): {
7
+ name: string;
8
+ alias: string;
9
+ options: {};
10
+ };
11
+ get optionsConfig(): {};
5
12
  exec(): Promise<{
6
13
  exitCode: number;
7
14
  }>;
@@ -1,18 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CleanCacheCommand = void 0;
3
+ exports.CleanCacheCommand = exports.cleanCacheCommandOptions = void 0;
4
4
  const CleanCacheAction_1 = require("../actions/CleanCacheAction");
5
5
  const bytes_1 = require("../utils/bytes");
6
6
  const data_format_1 = require("../utils/data-format");
7
7
  const CommandAbstract_1 = require("./CommandAbstract");
8
+ exports.cleanCacheCommandOptions = {
9
+ ...CleanCacheAction_1.cleanCacheActionOptions,
10
+ };
8
11
  class CleanCacheCommand extends CommandAbstract_1.CommandAbstract {
9
- optionsConfig() {
10
- return this.castOptionsConfig({});
12
+ static config() {
13
+ return {
14
+ name: "cleanCache",
15
+ alias: "cc",
16
+ options: exports.cleanCacheCommandOptions,
17
+ };
18
+ }
19
+ get optionsConfig() {
20
+ return exports.cleanCacheCommandOptions;
11
21
  }
12
22
  async exec() {
13
- const cleanCache = new CleanCacheAction_1.CleanCacheAction({
14
- verbose: !!this.globalOptions.verbose,
15
- });
23
+ const cleanCache = new CleanCacheAction_1.CleanCacheAction({});
16
24
  const result = await cleanCache.exec();
17
25
  const dataFormat = new data_format_1.DataFormat({
18
26
  streams: this.streams,
@@ -1,9 +1,9 @@
1
- import { OptionsConfig } from "../utils/cli";
2
1
  import { DataFormatType } from "../utils/data-format";
3
2
  import type { Config } from "../utils/datatruck/config-type";
3
+ import { CommandConfig, InferOptions, OptionsConfig } from "../utils/options";
4
4
  import { ProgressMode } from "../utils/progress";
5
5
  import { StdStreams } from "../utils/stream";
6
- import { If, SimilarObject } from "../utils/ts";
6
+ import { If } from "../utils/ts";
7
7
  export type GlobalOptions<TResolved = false> = {
8
8
  config: string | Config;
9
9
  outputFormat?: DataFormatType;
@@ -11,20 +11,21 @@ export type GlobalOptions<TResolved = false> = {
11
11
  tty?: If<TResolved, "auto" | boolean, "auto" | "true" | "false">;
12
12
  progress?: If<TResolved, ProgressMode, Exclude<ProgressMode, boolean> | "true" | "false">;
13
13
  };
14
- export type CommandConstructor<TUnresolvedOptions, TOptions extends SimilarObject<TUnresolvedOptions>> = {
15
- new (globalOptions: GlobalOptions<true>, options: TOptions): CommandAbstract<TUnresolvedOptions, TOptions>;
14
+ export type CommandConstructor<T extends OptionsConfig = OptionsConfig> = {
15
+ new (globalOptions: GlobalOptions<true>, options: InferOptions<T>, streams?: Partial<StdStreams>, configPath?: string): CommandAbstract<T>;
16
+ config(): CommandConfig;
16
17
  };
17
- export declare abstract class CommandAbstract<TUnresolvedOptions, TOptions extends SimilarObject<TUnresolvedOptions>> {
18
+ export declare abstract class CommandAbstract<T extends OptionsConfig = OptionsConfig> {
18
19
  readonly globalOptions: GlobalOptions<true>;
19
- readonly inputOptions: TUnresolvedOptions;
20
+ readonly options: InferOptions<T>;
20
21
  readonly configPath?: string | undefined;
21
- readonly options: TOptions;
22
22
  readonly streams: StdStreams;
23
- constructor(globalOptions: GlobalOptions<true>, inputOptions: TUnresolvedOptions, streams?: Partial<StdStreams>, configPath?: string | undefined);
24
- abstract optionsConfig(): OptionsConfig<TUnresolvedOptions, TOptions>;
25
- protected castOptionsConfig(options: OptionsConfig<TUnresolvedOptions, TOptions>): OptionsConfig<TUnresolvedOptions, TOptions>;
23
+ abstract optionsConfig: T;
24
+ static config(): CommandConfig;
25
+ constructor(globalOptions: GlobalOptions<true>, options: InferOptions<T>, streams?: Partial<StdStreams>, configPath?: string | undefined);
26
26
  abstract exec(): Promise<{
27
27
  exitCode: number;
28
28
  result?: any;
29
+ errors?: Error[];
29
30
  }>;
30
31
  }
@@ -1,23 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommandAbstract = void 0;
4
- const cli_1 = require("../utils/cli");
5
4
  const stream_1 = require("../utils/stream");
6
5
  class CommandAbstract {
7
6
  globalOptions;
8
- inputOptions;
9
- configPath;
10
7
  options;
8
+ configPath;
11
9
  streams;
12
- constructor(globalOptions, inputOptions, streams = {}, configPath) {
10
+ static config() {
11
+ throw new Error("Not implemented");
12
+ }
13
+ constructor(globalOptions, options, streams = {}, configPath) {
13
14
  this.globalOptions = globalOptions;
14
- this.inputOptions = inputOptions;
15
+ this.options = options;
15
16
  this.configPath = configPath;
16
- this.options = (0, cli_1.parseOptions)(inputOptions, this.optionsConfig());
17
17
  this.streams = (0, stream_1.createStdStreams)(streams);
18
18
  }
19
- castOptionsConfig(options) {
20
- return options;
21
- }
22
19
  }
23
20
  exports.CommandAbstract = CommandAbstract;
@@ -1,14 +1,77 @@
1
- import type { RepositoryConfig } from "../utils/datatruck/config-type";
2
- import { If } from "../utils/ts";
1
+ import { InferOptions } from "../utils/options";
3
2
  import { CommandAbstract } from "./CommandAbstract";
4
- export type ConfigCommandOptions<TResolved = false> = {
5
- package?: If<TResolved, string[]>;
6
- packageTask?: If<TResolved, string[]>;
7
- repository?: If<TResolved, string[]>;
8
- repositoryType?: If<TResolved, RepositoryConfig["type"][]>;
3
+ export declare const configCommandOptions: {
4
+ packageNames: {
5
+ description: string;
6
+ shortFlag: string;
7
+ value: "array";
8
+ };
9
+ packageTaskNames: {
10
+ description: string;
11
+ shortFlag: string;
12
+ value: "array";
13
+ };
14
+ repositoryNames: {
15
+ description: string;
16
+ shortFlag: string;
17
+ value: "array";
18
+ };
19
+ repositoryTypes: {
20
+ description: string;
21
+ shortFlag: string;
22
+ value: (value: string | undefined, validValues?: ("git" | "restic" | "datatruck")[] | undefined, defaultsValues?: true | ("git" | "restic" | "datatruck")[] | undefined) => ("git" | "restic" | "datatruck")[];
23
+ };
9
24
  };
10
- export declare class ConfigCommand extends CommandAbstract<ConfigCommandOptions<false>, ConfigCommandOptions<true>> {
11
- optionsConfig(): import("../utils/cli").OptionsConfig<ConfigCommandOptions<false>, ConfigCommandOptions<true>>;
25
+ export type ConfigCommandOptions = InferOptions<typeof configCommandOptions>;
26
+ export declare class ConfigCommand extends CommandAbstract<typeof configCommandOptions> {
27
+ static config(): {
28
+ name: string;
29
+ alias: string;
30
+ options: {
31
+ packageNames: {
32
+ description: string;
33
+ shortFlag: string;
34
+ value: "array";
35
+ };
36
+ packageTaskNames: {
37
+ description: string;
38
+ shortFlag: string;
39
+ value: "array";
40
+ };
41
+ repositoryNames: {
42
+ description: string;
43
+ shortFlag: string;
44
+ value: "array";
45
+ };
46
+ repositoryTypes: {
47
+ description: string;
48
+ shortFlag: string;
49
+ value: (value: string | undefined, validValues?: ("git" | "restic" | "datatruck")[] | undefined, defaultsValues?: true | ("git" | "restic" | "datatruck")[] | undefined) => ("git" | "restic" | "datatruck")[];
50
+ };
51
+ };
52
+ };
53
+ get optionsConfig(): {
54
+ packageNames: {
55
+ description: string;
56
+ shortFlag: string;
57
+ value: "array";
58
+ };
59
+ packageTaskNames: {
60
+ description: string;
61
+ shortFlag: string;
62
+ value: "array";
63
+ };
64
+ repositoryNames: {
65
+ description: string;
66
+ shortFlag: string;
67
+ value: "array";
68
+ };
69
+ repositoryTypes: {
70
+ description: string;
71
+ shortFlag: string;
72
+ value: (value: string | undefined, validValues?: ("git" | "restic" | "datatruck")[] | undefined, defaultsValues?: true | ("git" | "restic" | "datatruck")[] | undefined) => ("git" | "restic" | "datatruck")[];
73
+ };
74
+ };
12
75
  exec(): Promise<{
13
76
  result: {
14
77
  path: string;