diff --git a/packages/cli/src/Config/Config.ts b/packages/cli/src/Config/Config.ts deleted file mode 100644 index 9fcd32c..0000000 --- a/packages/cli/src/Config/Config.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { DataFormatType } from "../utils/DataFormat"; -import { DatatruckCronServerOptions } from "../utils/datatruck/cron-server"; -import { DatatruckRepositoryServerOptions } from "../utils/datatruck/repository-server"; -import { ReportStep } from "../utils/reportSteps"; -import { SpawnStep } from "../utils/spawnSteps"; -import { PackageConfig } from "./PackageConfig"; -import { PrunePolicyConfig } from "./PrunePolicyConfig"; -import { RepositoryConfig } from "./RepositoryConfig"; - -export type Config = { - $schema?: string; - tempDir?: string; - minFreeDiskSpace?: string | number; - repositories: RepositoryConfig[]; - packages: PackageConfig[]; - server?: DatatruckServerOptions; - reports?: ReportConfig[]; - prunePolicy?: PrunePolicyConfig; -}; - -export type DatatruckServerOptions = { - log?: boolean; - repository?: DatatruckRepositoryServerOptions; - cron?: DatatruckCronServerOptions; -}; - -export type ReportConfig = { - when?: "success" | "error"; - format?: Exclude; - run: SpawnStep | ReportStep; -}; diff --git a/packages/cli/src/Config/PackageConfig.ts b/packages/cli/src/Config/PackageConfig.ts deleted file mode 100644 index 89acceb..0000000 --- a/packages/cli/src/Config/PackageConfig.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { SpawnStep } from "../utils/spawnSteps"; -import { PackageRepositoryConfig } from "./PackageRepositoryConfig"; -import { PrunePolicyConfig } from "./PrunePolicyConfig"; -import type { TaskConfig } from "./TaskConfig"; - -export type Meta = { - [name: string]: any; -}; - -export type PackageConfig = { - name: string; - enabled?: boolean; - task?: TaskConfig; - path?: string; - restorePath?: string; - meta?: Meta; - restorePermissions?: { - uid: string | number; - gid: string | number; - }; - include?: (string | SpawnStep)[]; - exclude?: (string | SpawnStep)[]; - repositoryNames?: string[]; - prunePolicy?: PrunePolicyConfig; - repositoryConfigs?: PackageRepositoryConfig[]; -}; diff --git a/packages/cli/src/Config/PackageRepositoryConfig.ts b/packages/cli/src/Config/PackageRepositoryConfig.ts deleted file mode 100644 index d57bf16..0000000 --- a/packages/cli/src/Config/PackageRepositoryConfig.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { - DatatruckPackageRepositoryConfig, - datatruckRepositoryName, -} from "../repositories/DatatruckRepository"; -import { - GitPackageRepositoryConfig, - gitRepositoryName, -} from "../repositories/GitRepository"; -import { - ResticPackageRepositoryConfig, - resticRepositoryName, -} from "../repositories/ResticRepository"; - -export type PackageRepositoryConfig = { - names?: string[]; -} & ( - | { - type: typeof resticRepositoryName; - config: ResticPackageRepositoryConfig; - } - | { - type: typeof datatruckRepositoryName; - config: DatatruckPackageRepositoryConfig; - } - | { - type: typeof gitRepositoryName; - config: GitPackageRepositoryConfig; - } -); diff --git a/packages/cli/src/Config/PrunePolicyConfig.ts b/packages/cli/src/Config/PrunePolicyConfig.ts deleted file mode 100644 index abe2a38..0000000 --- a/packages/cli/src/Config/PrunePolicyConfig.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { PruneActionsOptions } from "../actions/PruneAction"; - -export type PrunePolicyConfig = Pick< - PruneActionsOptions, - | "keepDaily" - | "keepHourly" - | "keepMinutely" - | "keepLast" - | "keepMonthly" - | "keepWeekly" - | "keepYearly" - | "groupBy" - | "tags" ->; diff --git a/packages/cli/src/actions/BackupAction.ts b/packages/cli/src/actions/BackupAction.ts index 85bc8b5..ffdc564 100644 --- a/packages/cli/src/actions/BackupAction.ts +++ b/packages/cli/src/actions/BackupAction.ts @@ -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"; @@ -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"; diff --git a/packages/cli/src/actions/ConfigAction.ts b/packages/cli/src/actions/ConfigAction.ts index fd854e1..81655ee 100644 --- a/packages/cli/src/actions/ConfigAction.ts +++ b/packages/cli/src/actions/ConfigAction.ts @@ -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"; diff --git a/packages/cli/src/actions/CopyAction.ts b/packages/cli/src/actions/CopyAction.ts index 5a5b481..c028c85 100644 --- a/packages/cli/src/actions/CopyAction.ts +++ b/packages/cli/src/actions/CopyAction.ts @@ -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"; @@ -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"; diff --git a/packages/cli/src/actions/InitAction.ts b/packages/cli/src/actions/InitAction.ts index f2b79e9..34ea1cb 100644 --- a/packages/cli/src/actions/InitAction.ts +++ b/packages/cli/src/actions/InitAction.ts @@ -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"; diff --git a/packages/cli/src/actions/PruneAction.ts b/packages/cli/src/actions/PruneAction.ts index fd963bf..33d066e 100644 --- a/packages/cli/src/actions/PruneAction.ts +++ b/packages/cli/src/actions/PruneAction.ts @@ -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"; diff --git a/packages/cli/src/actions/RestoreAction.ts b/packages/cli/src/actions/RestoreAction.ts index dc2205c..d2d246c 100644 --- a/packages/cli/src/actions/RestoreAction.ts +++ b/packages/cli/src/actions/RestoreAction.ts @@ -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"; @@ -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"; diff --git a/packages/cli/src/actions/SnapshotsAction.ts b/packages/cli/src/actions/SnapshotsAction.ts index f7f453b..d09e206 100644 --- a/packages/cli/src/actions/SnapshotsAction.ts +++ b/packages/cli/src/actions/SnapshotsAction.ts @@ -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"; diff --git a/packages/cli/src/commands/BackupCommand.ts b/packages/cli/src/commands/BackupCommand.ts index 2bb44bd..3847cf7 100644 --- a/packages/cli/src/commands/BackupCommand.ts +++ b/packages/cli/src/commands/BackupCommand.ts @@ -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"; diff --git a/packages/cli/src/commands/CommandAbstract.ts b/packages/cli/src/commands/CommandAbstract.ts index f22ae6a..7d537d2 100644 --- a/packages/cli/src/commands/CommandAbstract.ts +++ b/packages/cli/src/commands/CommandAbstract.ts @@ -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"; diff --git a/packages/cli/src/commands/ConfigCommand.ts b/packages/cli/src/commands/ConfigCommand.ts index e1336ce..19c9d2c 100644 --- a/packages/cli/src/commands/ConfigCommand.ts +++ b/packages/cli/src/commands/ConfigCommand.ts @@ -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"; diff --git a/packages/cli/src/commands/InitCommand.ts b/packages/cli/src/commands/InitCommand.ts index dbfba07..466a58e 100644 --- a/packages/cli/src/commands/InitCommand.ts +++ b/packages/cli/src/commands/InitCommand.ts @@ -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"; diff --git a/packages/cli/src/commands/PruneCommand.ts b/packages/cli/src/commands/PruneCommand.ts index 4df9e92..97bd6cc 100644 --- a/packages/cli/src/commands/PruneCommand.ts +++ b/packages/cli/src/commands/PruneCommand.ts @@ -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"; diff --git a/packages/cli/src/commands/RestoreCommand.ts b/packages/cli/src/commands/RestoreCommand.ts index 250bbd3..52f1199 100644 --- a/packages/cli/src/commands/RestoreCommand.ts +++ b/packages/cli/src/commands/RestoreCommand.ts @@ -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"; diff --git a/packages/cli/src/commands/SnapshotsCommand.ts b/packages/cli/src/commands/SnapshotsCommand.ts index ae112fd..6ea428e 100644 --- a/packages/cli/src/commands/SnapshotsCommand.ts +++ b/packages/cli/src/commands/SnapshotsCommand.ts @@ -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"; diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 30d12b0..d35bbac 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -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"; diff --git a/packages/cli/src/repositories/RepositoryAbstract.ts b/packages/cli/src/repositories/RepositoryAbstract.ts index dee3c77..1e8b602 100644 --- a/packages/cli/src/repositories/RepositoryAbstract.ts +++ b/packages/cli/src/repositories/RepositoryAbstract.ts @@ -1,5 +1,3 @@ -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"; @@ -7,6 +5,10 @@ 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"; diff --git a/packages/cli/src/tasks/ScriptTask.ts b/packages/cli/src/tasks/ScriptTask.ts index ae65cf0..4f6ffb7 100644 --- a/packages/cli/src/tasks/ScriptTask.ts +++ b/packages/cli/src/tasks/ScriptTask.ts @@ -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"; diff --git a/packages/cli/src/tasks/TaskAbstract.ts b/packages/cli/src/tasks/TaskAbstract.ts index b4fef58..7546a2c 100644 --- a/packages/cli/src/tasks/TaskAbstract.ts +++ b/packages/cli/src/tasks/TaskAbstract.ts @@ -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 = { diff --git a/packages/cli/src/Config/RepositoryConfig.ts b/packages/cli/src/utils/datatruck/config-repository-type.ts similarity index 61% rename from packages/cli/src/Config/RepositoryConfig.ts rename to packages/cli/src/utils/datatruck/config-repository-type.ts index 0cd2b2f..78ebf33 100644 --- a/packages/cli/src/Config/RepositoryConfig.ts +++ b/packages/cli/src/utils/datatruck/config-repository-type.ts @@ -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; @@ -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[]; diff --git a/packages/cli/src/Config/TaskConfig.ts b/packages/cli/src/utils/datatruck/config-task-type.ts similarity index 64% rename from packages/cli/src/Config/TaskConfig.ts rename to packages/cli/src/utils/datatruck/config-task-type.ts index ca9161c..4f0c45d 100644 --- a/packages/cli/src/Config/TaskConfig.ts +++ b/packages/cli/src/utils/datatruck/config-task-type.ts @@ -1,12 +1,18 @@ -import { GitTaskConfig, gitTaskName } from "../tasks/GitTask"; -import { MariadbTaskConfig, mariadbTaskName } from "../tasks/MariadbTask"; -import { MssqlTaskConfig, mssqlTaskName } from "../tasks/MssqlTask"; -import { MysqlDumpTaskConfig, mysqlDumpTaskName } from "../tasks/MysqlDumpTask"; -import { +import type { GitTaskConfig, gitTaskName } from "../../tasks/GitTask"; +import type { + MariadbTaskConfig, + mariadbTaskName, +} from "../../tasks/MariadbTask"; +import type { MssqlTaskConfig, mssqlTaskName } from "../../tasks/MssqlTask"; +import type { + MysqlDumpTaskConfig, + mysqlDumpTaskName, +} from "../../tasks/MysqlDumpTask"; +import type { PostgresqlDumpTaskConfig, postgresqlDumpTaskName, -} from "../tasks/PostgresqlDumpTask"; -import { ScriptTaskConfig, scriptTaskName } from "../tasks/ScriptTask"; +} from "../../tasks/PostgresqlDumpTask"; +import type { ScriptTaskConfig, scriptTaskName } from "../../tasks/ScriptTask"; export type GitTaskConfigItem = { name: typeof gitTaskName; diff --git a/packages/cli/src/utils/datatruck/config-type.ts b/packages/cli/src/utils/datatruck/config-type.ts new file mode 100644 index 0000000..52ecb66 --- /dev/null +++ b/packages/cli/src/utils/datatruck/config-type.ts @@ -0,0 +1,72 @@ +import type { PruneActionsOptions } from "../../actions/PruneAction"; +import type { DataFormatType } from "../DataFormat"; +import type { ReportStep } from "../reportSteps"; +import type { SpawnStep } from "../spawnSteps"; +import type { + PackageRepositoryConfig, + RepositoryConfigEnabledAction, + RepositoryConfig, +} from "./config-repository-type"; +import type { TaskConfig } from "./config-task-type"; +import type { DatatruckCronServerOptions } from "./cron-server"; +import type { DatatruckRepositoryServerOptions } from "./repository-server"; + +export { RepositoryConfig, RepositoryConfigEnabledAction, TaskConfig }; + +export type Config = { + $schema?: string; + tempDir?: string; + minFreeDiskSpace?: string | number; + repositories: RepositoryConfig[]; + packages: PackageConfig[]; + server?: DatatruckServerOptions; + reports?: DatatruckReportConfig[]; + prunePolicy?: DatatruckPolicyConfig; +}; + +export type DatatruckServerOptions = { + log?: boolean; + repository?: DatatruckRepositoryServerOptions; + cron?: DatatruckCronServerOptions; +}; + +export type DatatruckReportConfig = { + when?: "success" | "error"; + format?: Exclude; + run: SpawnStep | ReportStep; +}; + +export type DatatruckPolicyConfig = Pick< + PruneActionsOptions, + | "keepDaily" + | "keepHourly" + | "keepMinutely" + | "keepLast" + | "keepMonthly" + | "keepWeekly" + | "keepYearly" + | "groupBy" + | "tags" +>; + +export type PackageConfigMeta = { + [name: string]: any; +}; + +export type PackageConfig = { + name: string; + enabled?: boolean; + task?: TaskConfig; + path?: string; + restorePath?: string; + meta?: PackageConfigMeta; + restorePermissions?: { + uid: string | number; + gid: string | number; + }; + include?: (string | SpawnStep)[]; + exclude?: (string | SpawnStep)[]; + repositoryNames?: string[]; + prunePolicy?: DatatruckPolicyConfig; + repositoryConfigs?: PackageRepositoryConfig[]; +}; diff --git a/packages/cli/src/utils/datatruck/config.ts b/packages/cli/src/utils/datatruck/config.ts index f1518f3..a29651c 100644 --- a/packages/cli/src/utils/datatruck/config.ts +++ b/packages/cli/src/utils/datatruck/config.ts @@ -1,11 +1,11 @@ -import { Config } from "../../Config/Config"; -import type { PackageConfig } from "../../Config/PackageConfig"; -import { - RepositoryConfigEnabledAction, - RepositoryConfig, -} from "../../Config/RepositoryConfig"; import { checkMatch, makePathPatterns, render } from "../string"; import { tmpDir } from "../temp"; +import type { Config } from "./config-type"; +import type { + PackageConfig, + RepositoryConfigEnabledAction, + RepositoryConfig, +} from "./config-type"; import { AppError } from "./error"; import { isMatch } from "micromatch"; diff --git a/packages/cli/src/utils/datatruck/paths.ts b/packages/cli/src/utils/datatruck/paths.ts index ad81abf..2e0d5a2 100644 --- a/packages/cli/src/utils/datatruck/paths.ts +++ b/packages/cli/src/utils/datatruck/paths.ts @@ -1,6 +1,6 @@ -import { PackageConfig } from "../../Config/PackageConfig"; import { PreSnapshot } from "../../repositories/RepositoryAbstract"; import { SpawnStep, runSpawnSteps } from "../spawnSteps"; +import type { PackageConfig } from "./config-type"; export type ParsePathsOptions = { cwd?: string; diff --git a/packages/cli/src/utils/datatruck/repository.ts b/packages/cli/src/utils/datatruck/repository.ts index 1136a30..b3f6973 100644 --- a/packages/cli/src/utils/datatruck/repository.ts +++ b/packages/cli/src/utils/datatruck/repository.ts @@ -1,4 +1,3 @@ -import type { RepositoryConfig } from "../../Config/RepositoryConfig"; import { DatatruckRepository, datatruckRepositoryName, @@ -12,6 +11,7 @@ import { ResticRepository, resticRepositoryName, } from "../../repositories/ResticRepository"; +import type { RepositoryConfig } from "./config-type"; import { AppError } from "./error"; export function createRepo( diff --git a/packages/cli/src/utils/datatruck/task.ts b/packages/cli/src/utils/datatruck/task.ts index f774b6c..6301951 100644 --- a/packages/cli/src/utils/datatruck/task.ts +++ b/packages/cli/src/utils/datatruck/task.ts @@ -1,4 +1,3 @@ -import { TaskConfig } from "../../Config/TaskConfig"; import { GitTask, gitTaskName } from "../../tasks/GitTask"; import { MariadbTask, mariadbTaskName } from "../../tasks/MariadbTask"; import { MssqlTask, mssqlTaskName } from "../../tasks/MssqlTask"; @@ -9,6 +8,7 @@ import { } from "../../tasks/PostgresqlDumpTask"; import { ScriptTask, scriptTaskName } from "../../tasks/ScriptTask"; import type { TaskAbstract } from "../../tasks/TaskAbstract"; +import type { TaskConfig } from "./config-type"; import { AppError } from "./error"; export function createTask(task: TaskConfig): TaskAbstract { diff --git a/packages/cli/test/util.ts b/packages/cli/test/util.ts index 5be6c51..3eda64c 100644 --- a/packages/cli/test/util.ts +++ b/packages/cli/test/util.ts @@ -1,5 +1,7 @@ -import { Config } from "../src/Config/Config"; -import { RepositoryConfig } from "../src/Config/RepositoryConfig"; +import type { + Config, + RepositoryConfig, +} from "../src/utils/datatruck/config-type"; import { createDatatruckRepositoryServer } from "../src/utils/datatruck/repository-server"; import { writeJSONFile } from "../src/utils/fs"; import { mkTmpDir } from "../src/utils/temp"; diff --git a/packages/cli/test/utils/datatruck/config.test.ts b/packages/cli/test/utils/datatruck/config.test.ts index 7ad0e55..9d00337 100644 --- a/packages/cli/test/utils/datatruck/config.test.ts +++ b/packages/cli/test/utils/datatruck/config.test.ts @@ -1,4 +1,3 @@ -import { Config } from "../../../src/Config/Config"; import { filterPackages, findRepositoryOrFail, @@ -8,6 +7,7 @@ import { resolveDatabaseName, params, } from "../../../src/utils/datatruck/config"; +import type { Config } from "../../../src/utils/datatruck/config-type"; import { describe, expect, it } from "vitest"; describe("filterPackages", () => {