Skip to content

Commit

Permalink
refactor(cli): rename files
Browse files Browse the repository at this point in the history
  • Loading branch information
juanrgm committed Dec 13, 2023
1 parent 38a3b2e commit 8e384fb
Show file tree
Hide file tree
Showing 31 changed files with 175 additions and 168 deletions.
31 changes: 0 additions & 31 deletions packages/cli/src/Config/Config.ts

This file was deleted.

26 changes: 0 additions & 26 deletions packages/cli/src/Config/PackageConfig.ts

This file was deleted.

29 changes: 0 additions & 29 deletions packages/cli/src/Config/PackageRepositoryConfig.ts

This file was deleted.

14 changes: 0 additions & 14 deletions packages/cli/src/Config/PrunePolicyConfig.ts

This file was deleted.

8 changes: 5 additions & 3 deletions packages/cli/src/actions/BackupAction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import type { Config } from "../Config/Config";
import { PackageConfig } from "../Config/PackageConfig";
import { RepositoryConfig } from "../Config/RepositoryConfig";
import { PreSnapshot } from "../repositories/RepositoryAbstract";
import { DataFormat } from "../utils/DataFormat";
import { renderError, renderObject, renderResult } from "../utils/cli";
Expand All @@ -9,6 +6,11 @@ import {
findRepositoryOrFail,
resolvePackages,
} from "../utils/datatruck/config";
import type {
Config,
PackageConfig,
RepositoryConfig,
} from "../utils/datatruck/config-type";
import { createRepo } from "../utils/datatruck/repository";
import { createTask } from "../utils/datatruck/task";
import { duration } from "../utils/date";
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/actions/ConfigAction.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { Config } from "../Config/Config";
import { RepositoryConfig } from "../Config/RepositoryConfig";
import { GlobalOptions } from "../commands/CommandAbstract";
import { configSchema } from "../config.schema";
import { findRepositoryOrFail } from "../utils/datatruck/config";
import type { Config, RepositoryConfig } from "../utils/datatruck/config-type";
import { AppError } from "../utils/datatruck/error";
import { findFile, parseFile, parseFileExtensions } from "../utils/fs";
import { IfRequireKeys } from "../utils/ts";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/actions/CopyAction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { Config } from "../Config/Config";
import { Snapshot } from "../repositories/RepositoryAbstract";
import { DataFormat } from "../utils/DataFormat";
import { renderError, renderObject, renderResult } from "../utils/cli";
Expand All @@ -7,6 +6,7 @@ import {
filterRepository,
findRepositoryOrFail,
} from "../utils/datatruck/config";
import type { Config } from "../utils/datatruck/config-type";
import { createRepo } from "../utils/datatruck/repository";
import { groupAndFilter } from "../utils/datatruck/snapshot";
import { duration } from "../utils/date";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/actions/InitAction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Config } from "../Config/Config";
import { filterRepository } from "../utils/datatruck/config";
import type { Config } from "../utils/datatruck/config-type";
import { createRepo } from "../utils/datatruck/repository";
import { IfRequireKeys } from "../utils/ts";

Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/actions/PruneAction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Config } from "../Config/Config";
import { RepositoryConfig } from "../Config/RepositoryConfig";
import type { Config, RepositoryConfig } from "../utils/datatruck/config-type";
import { createRepo } from "../utils/datatruck/repository";
import { groupAndFilter } from "../utils/datatruck/snapshot";
import { KeepObject, createFilterByLastOptions } from "../utils/date";
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/actions/RestoreAction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { Config } from "../Config/Config";
import { PackageConfig } from "../Config/PackageConfig";
import { Snapshot } from "../repositories/RepositoryAbstract";
import { TaskAbstract } from "../tasks/TaskAbstract";
import { DataFormat } from "../utils/DataFormat";
Expand All @@ -9,6 +7,7 @@ import {
findRepositoryOrFail,
resolvePackage,
} from "../utils/datatruck/config";
import type { Config, PackageConfig } from "../utils/datatruck/config-type";
import { createRepo } from "../utils/datatruck/repository";
import { createTask } from "../utils/datatruck/task";
import { duration } from "../utils/date";
Expand Down
6 changes: 4 additions & 2 deletions packages/cli/src/actions/SnapshotsAction.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { Config } from "../Config/Config";
import { RepositoryConfigEnabledAction } from "../Config/RepositoryConfig";
import { Snapshot } from "../repositories/RepositoryAbstract";
import { filterRepository } from "../utils/datatruck/config";
import type {
Config,
RepositoryConfigEnabledAction,
} from "../utils/datatruck/config-type";
import { createRepo } from "../utils/datatruck/repository";
import { groupAndFilter } from "../utils/datatruck/snapshot";
import { IfRequireKeys } from "../utils/ts";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/BackupCommand.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RepositoryConfig } from "../Config/RepositoryConfig";
import { BackupAction } from "../actions/BackupAction";
import { ConfigAction } from "../actions/ConfigAction";
import type { RepositoryConfig } from "../utils/datatruck/config-type";
import { parseStringList } from "../utils/string";
import { If } from "../utils/ts";
import { CommandAbstract } from "./CommandAbstract";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/CommandAbstract.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Config } from "../Config/Config";
import { DataFormatType } from "../utils/DataFormat";
import { OptionsConfig, parseOptions } from "../utils/cli";
import type { Config } from "../utils/datatruck/config-type";
import { ProgressMode } from "../utils/progress";
import { Streams, createStreams } from "../utils/stream";
import { If, SimilarObject } from "../utils/ts";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/ConfigCommand.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RepositoryConfig } from "../Config/RepositoryConfig";
import { ConfigAction } from "../actions/ConfigAction";
import { DataFormat } from "../utils/DataFormat";
import { filterPackages } from "../utils/datatruck/config";
import type { RepositoryConfig } from "../utils/datatruck/config-type";
import { parseStringList } from "../utils/string";
import { If } from "../utils/ts";
import { CommandAbstract } from "./CommandAbstract";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/InitCommand.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { RepositoryConfig } from "../Config/RepositoryConfig";
import { ConfigAction } from "../actions/ConfigAction";
import { InitAction } from "../actions/InitAction";
import { DataFormat } from "../utils/DataFormat";
import { renderError, renderResult } from "../utils/cli";
import type { RepositoryConfig } from "../utils/datatruck/config-type";
import { parseStringList } from "../utils/string";
import { If } from "../utils/ts";
import { CommandAbstract } from "./CommandAbstract";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/PruneCommand.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { RepositoryConfig } from "../Config/RepositoryConfig";
import { ConfigAction } from "../actions/ConfigAction";
import { PruneAction } from "../actions/PruneAction";
import { SnapshotGroupByType } from "../actions/SnapshotsAction";
import { DataFormat } from "../utils/DataFormat";
import { confirm } from "../utils/cli";
import type { RepositoryConfig } from "../utils/datatruck/config-type";
import { KeepObject } from "../utils/date";
import { parseStringList } from "../utils/string";
import { If } from "../utils/ts";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/RestoreCommand.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RepositoryConfig } from "../Config/RepositoryConfig";
import { ConfigAction } from "../actions/ConfigAction";
import { RestoreAction } from "../actions/RestoreAction";
import type { RepositoryConfig } from "../utils/datatruck/config-type";
import { parseStringList } from "../utils/string";
import { If } from "../utils/ts";
import { CommandAbstract } from "./CommandAbstract";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/SnapshotsCommand.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { RepositoryConfig } from "../Config/RepositoryConfig";
import { ConfigAction } from "../actions/ConfigAction";
import { SnapshotsAction } from "../actions/SnapshotsAction";
import { DataFormat } from "../utils/DataFormat";
import { formatBytes } from "../utils/bytes";
import type { RepositoryConfig } from "../utils/datatruck/config-type";
import { parseStringList } from "../utils/string";
import { If } from "../utils/ts";
import { CommandAbstract } from "./CommandAbstract";
Expand Down
20 changes: 13 additions & 7 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
export type { Config } from "./Config/Config";
export type { PackageConfig } from "./Config/PackageConfig";
export type { PackageRepositoryConfig } from "./Config/PackageRepositoryConfig";
export type { PrunePolicyConfig } from "./Config/PrunePolicyConfig";

export type { RepositoryConfig } from "./Config/RepositoryConfig";
export type {
Config,
PackageConfig,
PackageConfigMeta,
DatatruckPolicyConfig,
DatatruckReportConfig,
DatatruckServerOptions,
} from "./utils/datatruck/config-type";
export type {
PackageRepositoryConfig,
RepositoryConfig,
} from "./utils/datatruck/config-repository-type";
export type { TaskConfig } from "./utils/datatruck/config-task-type";
export { type ResticRepositoryConfig } from "./repositories/ResticRepository";
export { type DatatruckRepositoryConfig } from "./repositories/DatatruckRepository";
export { type GitRepositoryConfig } from "./repositories/GitRepository";

export type { TaskConfig } from "./Config/TaskConfig";
export { type GitTaskConfig } from "./tasks/GitTask";
export { type MariadbTaskConfig } from "./tasks/MariadbTask";
export { type MssqlTaskConfig } from "./tasks/MssqlTask";
Expand Down
6 changes: 4 additions & 2 deletions packages/cli/src/repositories/RepositoryAbstract.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import type { PackageConfig } from "../Config/PackageConfig";
import type { RepositoryConfig } from "../Config/RepositoryConfig";
import type { BackupActionOptions } from "../actions/BackupAction";
import type { InitActionOptions } from "../actions/InitAction";
import type { RestoreActionOptions } from "../actions/RestoreAction";
import type {
ExtendedSnapshot,
SnapshotsActionOptions,
} from "../actions/SnapshotsAction";
import type {
PackageConfig,
RepositoryConfig,
} from "../utils/datatruck/config-type";
import { ensureFreeDiskSpace, type DiskStats } from "../utils/fs";
import type { Progress } from "../utils/progress";

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/tasks/ScriptTask.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PackageConfig } from "../Config/PackageConfig";
import { PreSnapshot } from "../repositories/RepositoryAbstract";
import type { PackageConfig } from "../utils/datatruck/config-type";
import { ProcessEnv } from "../utils/process";
import { SpawnStep, runSpawnSteps } from "../utils/spawnSteps";
import { mkTmpDir } from "../utils/temp";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/tasks/TaskAbstract.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PackageConfig } from "../Config/PackageConfig";
import { BackupActionOptions } from "../actions/BackupAction";
import { RestoreActionOptions } from "../actions/RestoreAction";
import { PreSnapshot } from "../repositories/RepositoryAbstract";
import type { PackageConfig } from "../utils/datatruck/config-type";
import { Progress } from "../utils/progress";

type TaskCommonData = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
import {
import type {
DatatruckPackageRepositoryConfig,
DatatruckRepositoryConfig,
datatruckRepositoryName,
} from "../repositories/DatatruckRepository";
import {
} from "../../repositories/DatatruckRepository";
import type {
GitPackageRepositoryConfig,
GitRepositoryConfig,
gitRepositoryName,
} from "../repositories/GitRepository";
import {
} from "../../repositories/GitRepository";
import type {
ResticPackageRepositoryConfig,
ResticRepositoryConfig,
resticRepositoryName,
} from "../repositories/ResticRepository";
} from "../../repositories/ResticRepository";

export type RepositoryConfigType = RepositoryConfig["type"];

export type RepositoryConfigEnabledAction =
| "backup"
| "init"
| "prune"
| "restore"
| "snapshots";

export type RepositoryEnabledObject = {
[K in "defaults" | RepositoryConfigEnabledAction]?: boolean;
};
export type PackageRepositoryConfig = {
names?: string[];
} & (
| {
type: typeof resticRepositoryName;
config: ResticPackageRepositoryConfig;
}
| {
type: typeof datatruckRepositoryName;
config: DatatruckPackageRepositoryConfig;
}
| {
type: typeof gitRepositoryName;
config: GitPackageRepositoryConfig;
}
);

export type ResticRepositoryConfigItem = {
type: typeof resticRepositoryName;
Expand All @@ -39,6 +46,17 @@ export type GitRepositoryConfigItem = {
config: GitRepositoryConfig;
};

export type RepositoryConfigEnabledAction =
| "backup"
| "init"
| "prune"
| "restore"
| "snapshots";

export type RepositoryEnabledObject = {
[K in "defaults" | RepositoryConfigEnabledAction]?: boolean;
};

type CommonRepositoryConfig = {
name: string;
mirrorRepoNames?: string[];
Expand Down
Loading

0 comments on commit 8e384fb

Please sign in to comment.