@datatruck/cli 0.32.1 → 0.32.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.
- package/config.schema.json +1224 -1271
- package/{Action → lib/Action}/BackupAction.d.ts +9 -9
- package/{Action → lib/Action}/BackupAction.js +27 -8
- package/{Action → lib/Action}/ConfigAction.d.ts +9 -9
- package/{Action → lib/Action}/ConfigAction.js +4 -2
- package/{Action → lib/Action}/CopyAction.d.ts +5 -5
- package/{Action → lib/Action}/InitAction.d.ts +3 -3
- package/{Action → lib/Action}/PruneAction.d.ts +5 -5
- package/{Action → lib/Action}/RestoreAction.d.ts +5 -5
- package/{Action → lib/Action}/SnapshotsAction.d.ts +5 -5
- package/{Command → lib/Command}/BackupCommand.d.ts +2 -2
- package/{Command → lib/Command}/CommandAbstract.d.ts +4 -4
- package/{Command → lib/Command}/ConfigCommand.d.ts +2 -2
- package/{Command → lib/Command}/InitCommand.d.ts +2 -2
- package/{Command → lib/Command}/PruneCommand.d.ts +2 -2
- package/{Command → lib/Command}/RestoreCommand.d.ts +2 -2
- package/{Command → lib/Command}/SnapshotsCommand.d.ts +2 -2
- package/lib/Config/Config.d.ts +28 -0
- package/lib/Config/PackageConfig.d.ts +24 -0
- package/lib/Config/PackageConfig.js +2 -0
- package/lib/Config/PackageRepositoryConfig.d.ts +15 -0
- package/lib/Config/PackageRepositoryConfig.js +2 -0
- package/lib/Config/PrunePolicyConfig.d.ts +2 -0
- package/lib/Config/PrunePolicyConfig.js +2 -0
- package/lib/Config/RepositoryConfig.d.ts +27 -0
- package/lib/Config/RepositoryConfig.js +2 -0
- package/lib/Config/TaskConfig.d.ts +31 -0
- package/lib/Config/TaskConfig.js +2 -0
- package/{Factory → lib/Factory}/CommandFactory.d.ts +5 -5
- package/lib/Factory/RepositoryFactory.d.ts +3 -0
- package/lib/Factory/TaskFactory.d.ts +3 -0
- package/{Repository → lib/Repository}/DatatruckRepository.d.ts +9 -12
- package/{Repository → lib/Repository}/DatatruckRepository.js +1 -38
- package/lib/Repository/GitRepository.d.ts +28 -0
- package/{Repository → lib/Repository}/GitRepository.js +1 -15
- package/{Repository → lib/Repository}/RepositoryAbstract.d.ts +8 -8
- package/{Repository → lib/Repository}/ResticRepository.d.ts +11 -14
- package/{Repository → lib/Repository}/ResticRepository.js +1 -63
- package/{Task → lib/Task}/GitTask.d.ts +2 -4
- package/{Task → lib/Task}/GitTask.js +1 -42
- package/{Task → lib/Task}/MariadbTask.d.ts +2 -4
- package/{Task → lib/Task}/MariadbTask.js +1 -54
- package/{Task → lib/Task}/MssqlTask.d.ts +2 -4
- package/{Task → lib/Task}/MssqlTask.js +1 -14
- package/{Task → lib/Task}/MysqlDumpTask.d.ts +4 -5
- package/{Task → lib/Task}/MysqlDumpTask.js +1 -11
- package/{Task → lib/Task}/PostgresqlDumpTask.d.ts +5 -7
- package/{Task → lib/Task}/PostgresqlDumpTask.js +1 -5
- package/lib/Task/ScriptTask.d.ts +30 -0
- package/lib/Task/ScriptTask.js +55 -0
- package/{Task → lib/Task}/SqlDumpTaskAbstract.d.ts +5 -7
- package/{Task → lib/Task}/SqlDumpTaskAbstract.js +1 -43
- package/{Task → lib/Task}/TaskAbstract.d.ts +2 -2
- package/lib/cli.d.ts +4 -0
- package/lib/config.schema.d.ts +2 -0
- package/lib/config.schema.js +10 -0
- package/lib/index.d.ts +24 -0
- package/lib/index.js +21 -0
- package/{utils → lib/utils}/DataFormat.d.ts +4 -4
- package/{utils → lib/utils}/Git.d.ts +6 -6
- package/{utils → lib/utils}/Restic.d.ts +14 -14
- package/{utils → lib/utils}/datatruck/config.d.ts +20 -20
- package/lib/utils/datatruck/paths.d.ts +17 -0
- package/{utils → lib/utils}/datatruck/paths.js +3 -3
- package/{utils → lib/utils}/datatruck/repository-server.d.ts +1 -1
- package/{utils → lib/utils}/datatruck/snapshot.d.ts +2 -2
- package/{utils → lib/utils}/date.d.ts +3 -3
- package/{utils → lib/utils}/exit.d.ts +3 -3
- package/{utils → lib/utils}/mysql.d.ts +5 -4
- package/{utils → lib/utils}/mysql.js +2 -2
- package/{utils → lib/utils}/process.d.ts +8 -5
- package/lib/utils/reportSteps.d.ts +26 -0
- package/lib/utils/reportSteps.js +41 -0
- package/lib/utils/spawnSteps.d.ts +36 -0
- package/lib/utils/spawnSteps.js +74 -0
- package/{utils → lib/utils}/string.d.ts +3 -3
- package/{utils → lib/utils}/string.js +3 -3
- package/{utils → lib/utils}/tar.d.ts +0 -8
- package/{utils → lib/utils}/tar.js +1 -18
- package/package.json +39 -25
- package/CHANGELOG.md +0 -569
- package/Config/Config.d.ts +0 -28
- package/Config/Config.js +0 -140
- package/Config/PackageConfig.d.ts +0 -23
- package/Config/PackageConfig.js +0 -51
- package/Config/PackageRepositoryConfig.d.ts +0 -17
- package/Config/PackageRepositoryConfig.js +0 -37
- package/Config/PrunePolicyConfig.d.ts +0 -4
- package/Config/PrunePolicyConfig.js +0 -28
- package/Config/RepositoryConfig.d.ts +0 -24
- package/Config/RepositoryConfig.js +0 -62
- package/Config/TaskConfig.d.ts +0 -27
- package/Config/TaskConfig.js +0 -41
- package/Factory/RepositoryFactory.d.ts +0 -3
- package/Factory/TaskFactory.d.ts +0 -3
- package/JsonSchema/DefinitionEnum.d.ts +0 -26
- package/JsonSchema/DefinitionEnum.js +0 -33
- package/JsonSchema/JsonSchema.d.ts +0 -4
- package/JsonSchema/JsonSchema.js +0 -65
- package/JsonSchema/backup-def.d.ts +0 -30
- package/JsonSchema/backup-def.js +0 -18
- package/JsonSchema/copy-def.d.ts +0 -24
- package/JsonSchema/copy-def.js +0 -15
- package/Repository/GitRepository.d.ts +0 -31
- package/Task/ScriptTask.d.ts +0 -38
- package/Task/ScriptTask.js +0 -163
- package/cli.d.ts +0 -4
- package/index.d.ts +0 -1
- package/utils/datatruck/paths.d.ts +0 -17
- package/utils/path.d.ts +0 -1
- package/utils/path.js +0 -8
- package/utils/schema.d.ts +0 -34
- package/utils/schema.js +0 -36
- package/utils/steps.d.ts +0 -43
- package/utils/steps.js +0 -97
- /package/{Action → lib/Action}/CleanCacheAction.d.ts +0 -0
- /package/{Action → lib/Action}/CleanCacheAction.js +0 -0
- /package/{Action → lib/Action}/CopyAction.js +0 -0
- /package/{Action → lib/Action}/InitAction.js +0 -0
- /package/{Action → lib/Action}/PruneAction.js +0 -0
- /package/{Action → lib/Action}/RestoreAction.js +0 -0
- /package/{Action → lib/Action}/SnapshotsAction.js +0 -0
- /package/{Command → lib/Command}/BackupCommand.js +0 -0
- /package/{Command → lib/Command}/CleanCacheCommand.d.ts +0 -0
- /package/{Command → lib/Command}/CleanCacheCommand.js +0 -0
- /package/{Command → lib/Command}/CommandAbstract.js +0 -0
- /package/{Command → lib/Command}/ConfigCommand.js +0 -0
- /package/{Command → lib/Command}/CopyCommand.d.ts +0 -0
- /package/{Command → lib/Command}/CopyCommand.js +0 -0
- /package/{Command → lib/Command}/InitCommand.js +0 -0
- /package/{Command → lib/Command}/PruneCommand.js +0 -0
- /package/{Command → lib/Command}/RestoreCommand.js +0 -0
- /package/{Command → lib/Command}/SnapshotsCommand.js +0 -0
- /package/{Command → lib/Command}/StartServerCommand.d.ts +0 -0
- /package/{Command → lib/Command}/StartServerCommand.js +0 -0
- /package/{index.js → lib/Config/Config.js} +0 -0
- /package/{Error → lib/Error}/AppError.d.ts +0 -0
- /package/{Error → lib/Error}/AppError.js +0 -0
- /package/{Factory → lib/Factory}/CommandFactory.js +0 -0
- /package/{Factory → lib/Factory}/RepositoryFactory.js +0 -0
- /package/{Factory → lib/Factory}/TaskFactory.js +0 -0
- /package/{Repository → lib/Repository}/RepositoryAbstract.js +0 -0
- /package/{Task → lib/Task}/TaskAbstract.js +0 -0
- /package/{bin.d.ts → lib/bin.d.ts} +0 -0
- /package/{bin.js → lib/bin.js} +0 -0
- /package/{cli.js → lib/cli.js} +0 -0
- /package/{globalData.d.ts → lib/globalData.d.ts} +0 -0
- /package/{globalData.js → lib/globalData.js} +0 -0
- /package/{pkg.d.ts → lib/pkg.d.ts} +0 -0
- /package/{pkg.js → lib/pkg.js} +0 -0
- /package/{utils → lib/utils}/DataFormat.js +0 -0
- /package/{utils → lib/utils}/Git.js +0 -0
- /package/{utils → lib/utils}/Restic.js +0 -0
- /package/{utils → lib/utils}/async.d.ts +0 -0
- /package/{utils → lib/utils}/async.js +0 -0
- /package/{utils → lib/utils}/bytes.d.ts +0 -0
- /package/{utils → lib/utils}/bytes.js +0 -0
- /package/{utils → lib/utils}/cli.d.ts +0 -0
- /package/{utils → lib/utils}/cli.js +0 -0
- /package/{utils → lib/utils}/crypto.d.ts +0 -0
- /package/{utils → lib/utils}/crypto.js +0 -0
- /package/{utils → lib/utils}/datatruck/client.d.ts +0 -0
- /package/{utils → lib/utils}/datatruck/client.js +0 -0
- /package/{utils → lib/utils}/datatruck/config.js +0 -0
- /package/{utils → lib/utils}/datatruck/cron-server.d.ts +0 -0
- /package/{utils → lib/utils}/datatruck/cron-server.js +0 -0
- /package/{utils → lib/utils}/datatruck/repository-server.js +0 -0
- /package/{utils → lib/utils}/datatruck/snapshot.js +0 -0
- /package/{utils → lib/utils}/date.js +0 -0
- /package/{utils → lib/utils}/exit.js +0 -0
- /package/{utils → lib/utils}/fs.d.ts +0 -0
- /package/{utils → lib/utils}/fs.js +0 -0
- /package/{utils → lib/utils}/http.d.ts +0 -0
- /package/{utils → lib/utils}/http.js +0 -0
- /package/{utils → lib/utils}/list.d.ts +0 -0
- /package/{utils → lib/utils}/list.js +0 -0
- /package/{utils → lib/utils}/math.d.ts +0 -0
- /package/{utils → lib/utils}/math.js +0 -0
- /package/{utils → lib/utils}/object.d.ts +0 -0
- /package/{utils → lib/utils}/object.js +0 -0
- /package/{utils → lib/utils}/process.js +0 -0
- /package/{utils → lib/utils}/progress.d.ts +0 -0
- /package/{utils → lib/utils}/progress.js +0 -0
- /package/{utils → lib/utils}/stream.d.ts +0 -0
- /package/{utils → lib/utils}/stream.js +0 -0
- /package/{utils → lib/utils}/temp.d.ts +0 -0
- /package/{utils → lib/utils}/temp.js +0 -0
- /package/{utils → lib/utils}/virtual-fs.d.ts +0 -0
- /package/{utils → lib/utils}/virtual-fs.js +0 -0
package/JsonSchema/copy-def.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export declare const copyCommandOptionsDef: {
|
|
2
|
-
type: "object";
|
|
3
|
-
additionalProperties: false;
|
|
4
|
-
properties: {
|
|
5
|
-
id: {
|
|
6
|
-
type: "string";
|
|
7
|
-
};
|
|
8
|
-
last: {
|
|
9
|
-
type: "integer";
|
|
10
|
-
};
|
|
11
|
-
package: {
|
|
12
|
-
type: "string";
|
|
13
|
-
};
|
|
14
|
-
packageTask: {
|
|
15
|
-
type: "string";
|
|
16
|
-
};
|
|
17
|
-
repository: {
|
|
18
|
-
type: "string";
|
|
19
|
-
};
|
|
20
|
-
repository2: {
|
|
21
|
-
type: "string";
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
};
|
package/JsonSchema/copy-def.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.copyCommandOptionsDef = void 0;
|
|
4
|
-
exports.copyCommandOptionsDef = {
|
|
5
|
-
type: "object",
|
|
6
|
-
additionalProperties: false,
|
|
7
|
-
properties: {
|
|
8
|
-
id: { type: "string" },
|
|
9
|
-
last: { type: "integer" },
|
|
10
|
-
package: { type: "string" },
|
|
11
|
-
packageTask: { type: "string" },
|
|
12
|
-
repository: { type: "string" },
|
|
13
|
-
repository2: { type: "string" },
|
|
14
|
-
},
|
|
15
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { RepositoryAbstract, RepoBackupData, RepoInitData, RepoRestoreData, RepoFetchSnapshotsData, Snapshot, SnapshotTagEnum, SnapshotTagObjectType, RepoPruneData, RepoCopyData } from "./RepositoryAbstract";
|
|
2
|
-
import { JSONSchema7 } from "json-schema";
|
|
3
|
-
export type GitRepositoryConfigType = {
|
|
4
|
-
repo: string;
|
|
5
|
-
branch?: string;
|
|
6
|
-
};
|
|
7
|
-
export type GitPackageRepositoryConfigType = {};
|
|
8
|
-
export declare const gitRepositoryName = "git";
|
|
9
|
-
export declare const gitRepositoryDefinition: JSONSchema7;
|
|
10
|
-
export declare const gitPackageRepositoryDefinition: JSONSchema7;
|
|
11
|
-
export declare class GitRepository extends RepositoryAbstract<GitRepositoryConfigType> {
|
|
12
|
-
static refPrefix: string;
|
|
13
|
-
getSource(): string;
|
|
14
|
-
fetchDiskStats(config: GitRepositoryConfigType): Promise<import("../utils/fs").DiskStats | undefined>;
|
|
15
|
-
static buildSnapshotTagName(tag: Pick<SnapshotTagObjectType, SnapshotTagEnum.PACKAGE | SnapshotTagEnum.ID>): string;
|
|
16
|
-
static buildSnapshotTag(tag: SnapshotTagObjectType): {
|
|
17
|
-
name: string;
|
|
18
|
-
message: string;
|
|
19
|
-
};
|
|
20
|
-
static isSnapshotTag(name: string): boolean;
|
|
21
|
-
static parseSnapshotTag(name: string, message: string): (Omit<SnapshotTagObjectType, "tags"> & {
|
|
22
|
-
tags: string[];
|
|
23
|
-
}) | null;
|
|
24
|
-
static buildBranchName(packageName: string): string;
|
|
25
|
-
init(data: RepoInitData): Promise<void>;
|
|
26
|
-
prune(data: RepoPruneData): Promise<void>;
|
|
27
|
-
fetchSnapshots(data: RepoFetchSnapshotsData): Promise<Snapshot[]>;
|
|
28
|
-
backup(data: RepoBackupData<GitPackageRepositoryConfigType>): Promise<void>;
|
|
29
|
-
copy(data: RepoCopyData<GitRepositoryConfigType>): Promise<void>;
|
|
30
|
-
restore(data: RepoRestoreData<GitPackageRepositoryConfigType>): Promise<void>;
|
|
31
|
-
}
|
package/Task/ScriptTask.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { PackageConfigType } from "../Config/PackageConfig";
|
|
2
|
-
import { PreSnapshot } from "../Repository/RepositoryAbstract";
|
|
3
|
-
import { Step } from "../utils/steps";
|
|
4
|
-
import { TaskBackupData, TaskPrepareRestoreData, TaskRestoreData, TaskAbstract } from "./TaskAbstract";
|
|
5
|
-
import { JSONSchema7 } from "json-schema";
|
|
6
|
-
type NodeVars = {
|
|
7
|
-
dtt: {
|
|
8
|
-
snapshot: PreSnapshot;
|
|
9
|
-
package: PackageConfigType;
|
|
10
|
-
snapshotPath: string;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export type ScriptTaskConfigType = {
|
|
14
|
-
env?: Record<string, string | undefined>;
|
|
15
|
-
backupSteps: Step[];
|
|
16
|
-
restoreSteps: Step[];
|
|
17
|
-
};
|
|
18
|
-
export declare function scriptTaskCode<V extends Record<string, any>>(cb: (vars: NodeVars & V) => void): string;
|
|
19
|
-
export declare enum ScriptTaskDefinitionEnum {
|
|
20
|
-
step = "step",
|
|
21
|
-
processStepConfig = "processStepConfig",
|
|
22
|
-
nodeStepConfig = "nodeStepConfig",
|
|
23
|
-
telegramMessageStepConfig = "telegramMessageStepConfig",
|
|
24
|
-
ntfyStepConfig = "ntfyStepConfig"
|
|
25
|
-
}
|
|
26
|
-
export declare const scriptTaskName = "script";
|
|
27
|
-
export declare const scriptTaskDefinition: JSONSchema7;
|
|
28
|
-
export declare class ScriptTask extends TaskAbstract<ScriptTaskConfigType> {
|
|
29
|
-
protected verbose?: boolean;
|
|
30
|
-
backup(data: TaskBackupData): Promise<{
|
|
31
|
-
snapshotPath: string;
|
|
32
|
-
}>;
|
|
33
|
-
prepareRestore(data: TaskPrepareRestoreData): Promise<{
|
|
34
|
-
snapshotPath: string;
|
|
35
|
-
}>;
|
|
36
|
-
restore(data: TaskRestoreData): Promise<void>;
|
|
37
|
-
}
|
|
38
|
-
export {};
|
package/Task/ScriptTask.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ScriptTask = exports.scriptTaskDefinition = exports.scriptTaskName = exports.ScriptTaskDefinitionEnum = exports.scriptTaskCode = void 0;
|
|
4
|
-
const DefinitionEnum_1 = require("../JsonSchema/DefinitionEnum");
|
|
5
|
-
const steps_1 = require("../utils/steps");
|
|
6
|
-
const temp_1 = require("../utils/temp");
|
|
7
|
-
const TaskAbstract_1 = require("./TaskAbstract");
|
|
8
|
-
function scriptTaskCode(cb) {
|
|
9
|
-
return `(${cb.toString()})(...arguments);`;
|
|
10
|
-
}
|
|
11
|
-
exports.scriptTaskCode = scriptTaskCode;
|
|
12
|
-
var ScriptTaskDefinitionEnum;
|
|
13
|
-
(function (ScriptTaskDefinitionEnum) {
|
|
14
|
-
ScriptTaskDefinitionEnum["step"] = "step";
|
|
15
|
-
ScriptTaskDefinitionEnum["processStepConfig"] = "processStepConfig";
|
|
16
|
-
ScriptTaskDefinitionEnum["nodeStepConfig"] = "nodeStepConfig";
|
|
17
|
-
ScriptTaskDefinitionEnum["telegramMessageStepConfig"] = "telegramMessageStepConfig";
|
|
18
|
-
ScriptTaskDefinitionEnum["ntfyStepConfig"] = "ntfyStepConfig";
|
|
19
|
-
})(ScriptTaskDefinitionEnum || (exports.ScriptTaskDefinitionEnum = ScriptTaskDefinitionEnum = {}));
|
|
20
|
-
const stepTypes = {
|
|
21
|
-
process: ScriptTaskDefinitionEnum.processStepConfig,
|
|
22
|
-
node: ScriptTaskDefinitionEnum.nodeStepConfig,
|
|
23
|
-
"telegram-message": ScriptTaskDefinitionEnum.telegramMessageStepConfig,
|
|
24
|
-
ntfy: ScriptTaskDefinitionEnum.ntfyStepConfig,
|
|
25
|
-
};
|
|
26
|
-
exports.scriptTaskName = "script";
|
|
27
|
-
exports.scriptTaskDefinition = {
|
|
28
|
-
definitions: {
|
|
29
|
-
step: {
|
|
30
|
-
type: "object",
|
|
31
|
-
required: ["type"],
|
|
32
|
-
properties: {
|
|
33
|
-
type: { enum: Object.keys(stepTypes) },
|
|
34
|
-
config: {},
|
|
35
|
-
},
|
|
36
|
-
anyOf: Object.keys(stepTypes).map((name) => ({
|
|
37
|
-
if: {
|
|
38
|
-
type: "object",
|
|
39
|
-
properties: {
|
|
40
|
-
type: { const: name },
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
then: {
|
|
44
|
-
type: "object",
|
|
45
|
-
properties: {
|
|
46
|
-
config: (0, DefinitionEnum_1.makeRef)(DefinitionEnum_1.DefinitionEnum.scriptTask, stepTypes[name]),
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
else: false,
|
|
50
|
-
})),
|
|
51
|
-
},
|
|
52
|
-
processStepConfig: {
|
|
53
|
-
type: "object",
|
|
54
|
-
required: ["command"],
|
|
55
|
-
properties: {
|
|
56
|
-
command: { type: "string" },
|
|
57
|
-
env: {
|
|
58
|
-
type: "object",
|
|
59
|
-
patternProperties: { ".+": { type: "string" } },
|
|
60
|
-
},
|
|
61
|
-
args: (0, DefinitionEnum_1.makeRef)(DefinitionEnum_1.DefinitionEnum.stringListUtil),
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
nodeStepConfig: {
|
|
65
|
-
type: "object",
|
|
66
|
-
required: ["code"],
|
|
67
|
-
properties: {
|
|
68
|
-
code: {
|
|
69
|
-
anyOf: [{ type: "string" }, (0, DefinitionEnum_1.makeRef)(DefinitionEnum_1.DefinitionEnum.stringListUtil)],
|
|
70
|
-
},
|
|
71
|
-
vars: {
|
|
72
|
-
type: "object",
|
|
73
|
-
patternProperties: { ".+": {} },
|
|
74
|
-
},
|
|
75
|
-
env: {
|
|
76
|
-
type: "object",
|
|
77
|
-
patternProperties: { ".+": { type: "string" } },
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
telegramMessageStepConfig: {
|
|
82
|
-
type: "object",
|
|
83
|
-
required: ["bot", "chatId"],
|
|
84
|
-
properties: {
|
|
85
|
-
command: { type: "string" },
|
|
86
|
-
chatId: { type: "integer" },
|
|
87
|
-
text: { type: "string" },
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
ntfyStepConfig: {
|
|
91
|
-
type: "object",
|
|
92
|
-
required: ["token"],
|
|
93
|
-
properties: {
|
|
94
|
-
token: { type: "string" },
|
|
95
|
-
topic: { type: "string" },
|
|
96
|
-
text: { type: "string" },
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
type: "object",
|
|
101
|
-
additionalProperties: false,
|
|
102
|
-
required: ["backupSteps", "restoreSteps"],
|
|
103
|
-
properties: {
|
|
104
|
-
env: {
|
|
105
|
-
type: "object",
|
|
106
|
-
patternProperties: {
|
|
107
|
-
".+": { type: "string" },
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
backupSteps: {
|
|
111
|
-
type: "array",
|
|
112
|
-
items: (0, DefinitionEnum_1.makeRef)(DefinitionEnum_1.DefinitionEnum.scriptTask, ScriptTaskDefinitionEnum.step),
|
|
113
|
-
},
|
|
114
|
-
restoreSteps: {
|
|
115
|
-
type: "array",
|
|
116
|
-
items: (0, DefinitionEnum_1.makeRef)(DefinitionEnum_1.DefinitionEnum.scriptTask, ScriptTaskDefinitionEnum.step),
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
class ScriptTask extends TaskAbstract_1.TaskAbstract {
|
|
121
|
-
verbose;
|
|
122
|
-
async backup(data) {
|
|
123
|
-
const config = this.config;
|
|
124
|
-
const snapshotPath = data.package.path ??
|
|
125
|
-
(await (0, temp_1.mkTmpDir)(exports.scriptTaskName, "task", "backup", "snapshot"));
|
|
126
|
-
await (0, steps_1.runSteps)(config.backupSteps, {
|
|
127
|
-
env: config.env,
|
|
128
|
-
vars: {
|
|
129
|
-
dtt: {
|
|
130
|
-
snapshot: data.snapshot,
|
|
131
|
-
snapshotPath: snapshotPath,
|
|
132
|
-
package: data.package,
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
cwd: snapshotPath,
|
|
136
|
-
verbose: data.options.verbose,
|
|
137
|
-
tempDir: () => (0, temp_1.mkTmpDir)(exports.scriptTaskName, "task", "backup", "nodeStep"),
|
|
138
|
-
});
|
|
139
|
-
return { snapshotPath };
|
|
140
|
-
}
|
|
141
|
-
async prepareRestore(data) {
|
|
142
|
-
return {
|
|
143
|
-
snapshotPath: data.package.restorePath ??
|
|
144
|
-
(await (0, temp_1.mkTmpDir)(exports.scriptTaskName, "task", "restore", "snapshot")),
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
async restore(data) {
|
|
148
|
-
const config = this.config;
|
|
149
|
-
await (0, steps_1.runSteps)(config.restoreSteps, {
|
|
150
|
-
env: config.env,
|
|
151
|
-
vars: {
|
|
152
|
-
dtt: {
|
|
153
|
-
snapshot: data.snapshot,
|
|
154
|
-
snapshotPath: data.snapshotPath,
|
|
155
|
-
package: data.package,
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
verbose: data.options.verbose,
|
|
159
|
-
tempDir: () => (0, temp_1.mkTmpDir)(exports.scriptTaskName, "task", "restore", "nodeStep"),
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
exports.ScriptTask = ScriptTask;
|
package/cli.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { OptionsMapType } from "./Factory/CommandFactory";
|
|
2
|
-
export declare function buildArgs<TCommand extends keyof OptionsMapType>(input: TCommand, options: OptionsMapType[TCommand]): any[];
|
|
3
|
-
export declare function parseArgs(args: string[]): void;
|
|
4
|
-
export declare function exec<TCommand extends keyof OptionsMapType>(input: TCommand, options: OptionsMapType[TCommand]): Promise<void>;
|
package/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { PackageConfigType } from "../../Config/PackageConfig";
|
|
2
|
-
import { PreSnapshot } from "../../Repository/RepositoryAbstract";
|
|
3
|
-
import { Step } from "../steps";
|
|
4
|
-
export type ParsePathsOptions = {
|
|
5
|
-
cwd?: string;
|
|
6
|
-
verbose?: boolean;
|
|
7
|
-
vars?: Record<string, any>;
|
|
8
|
-
tempDir?: () => Promise<string>;
|
|
9
|
-
};
|
|
10
|
-
export declare function parsePaths(values: (string | Step)[], options: ParsePathsOptions): Promise<string[]>;
|
|
11
|
-
export type BackupPathsOptions = {
|
|
12
|
-
package: PackageConfigType;
|
|
13
|
-
snapshot: PreSnapshot;
|
|
14
|
-
path: string;
|
|
15
|
-
verbose?: boolean;
|
|
16
|
-
};
|
|
17
|
-
export declare function parseBackupPaths(paths: (string | Step)[], options: BackupPathsOptions): Promise<string[]>;
|
package/utils/path.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const rootPath: string;
|
package/utils/path.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rootPath = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const fromSrc = __filename.endsWith(".ts");
|
|
6
|
-
exports.rootPath = fromSrc
|
|
7
|
-
? (0, path_1.normalize)(`${__dirname}/../../`)
|
|
8
|
-
: (0, path_1.normalize)(`${__dirname}/../`);
|
package/utils/schema.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { JSONSchema7 } from "json-schema";
|
|
2
|
-
export declare function omitPropertySchema<T extends {
|
|
3
|
-
properties: Record<string, any>;
|
|
4
|
-
}, N extends keyof T["properties"]>(object: T, name: N): Omit<T, "properties"> & {
|
|
5
|
-
properties: Omit<T["properties"], N>;
|
|
6
|
-
};
|
|
7
|
-
type IfSchema<KType extends string, KValue extends string, T extends string, V extends JSONSchema7> = {
|
|
8
|
-
if: {
|
|
9
|
-
type: "object";
|
|
10
|
-
properties: {
|
|
11
|
-
[k in KType]: {
|
|
12
|
-
const: T;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
then: {
|
|
17
|
-
type: "object";
|
|
18
|
-
properties: {
|
|
19
|
-
[k in KValue]: V;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
else: false;
|
|
23
|
-
};
|
|
24
|
-
export declare function createCaseSchema<KType extends string, KValue extends string, V extends {
|
|
25
|
-
[K in KType]: JSONSchema7;
|
|
26
|
-
}>(keys: {
|
|
27
|
-
type: KType;
|
|
28
|
-
value: KValue;
|
|
29
|
-
}, value: V): IfSchema<KType, KValue, string, JSONSchema7>[];
|
|
30
|
-
export declare function createIfSchema<KType extends string, KValue extends string, T extends string, V extends JSONSchema7>(keys: {
|
|
31
|
-
type: KType;
|
|
32
|
-
value: KValue;
|
|
33
|
-
}, type: T, value: V): IfSchema<KType, KValue, T, V>;
|
|
34
|
-
export {};
|
package/utils/schema.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createIfSchema = exports.createCaseSchema = exports.omitPropertySchema = void 0;
|
|
4
|
-
const object_1 = require("./object");
|
|
5
|
-
function omitPropertySchema(object, name) {
|
|
6
|
-
return {
|
|
7
|
-
...object,
|
|
8
|
-
properties: (0, object_1.omitProp)(object.properties, name),
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
exports.omitPropertySchema = omitPropertySchema;
|
|
12
|
-
function createCaseSchema(keys, value) {
|
|
13
|
-
return Object.entries(value).reduce((schemas, [type, value]) => {
|
|
14
|
-
schemas.push(createIfSchema(keys, type, value));
|
|
15
|
-
return schemas;
|
|
16
|
-
}, []);
|
|
17
|
-
}
|
|
18
|
-
exports.createCaseSchema = createCaseSchema;
|
|
19
|
-
function createIfSchema(keys, type, value) {
|
|
20
|
-
return {
|
|
21
|
-
if: {
|
|
22
|
-
type: "object",
|
|
23
|
-
properties: {
|
|
24
|
-
[keys.type]: { const: type },
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
then: {
|
|
28
|
-
type: "object",
|
|
29
|
-
properties: {
|
|
30
|
-
[keys.value]: value,
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
else: false,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
exports.createIfSchema = createIfSchema;
|
package/utils/steps.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
export type StepEnv = Record<string, string>;
|
|
2
|
-
export type ProcessStepConfig = {
|
|
3
|
-
command: string;
|
|
4
|
-
env?: StepEnv;
|
|
5
|
-
args?: string[];
|
|
6
|
-
};
|
|
7
|
-
export type NodeStepConfig = {
|
|
8
|
-
env?: StepEnv;
|
|
9
|
-
vars?: Record<string, any>;
|
|
10
|
-
code: string | string[];
|
|
11
|
-
};
|
|
12
|
-
export type TelegramMessageStepConfig = {
|
|
13
|
-
bot: string;
|
|
14
|
-
chatId: number;
|
|
15
|
-
text?: string;
|
|
16
|
-
};
|
|
17
|
-
export type NtfyStepConfig = {
|
|
18
|
-
token: string;
|
|
19
|
-
topic?: string;
|
|
20
|
-
text?: string;
|
|
21
|
-
};
|
|
22
|
-
export type Step = {
|
|
23
|
-
type: "process";
|
|
24
|
-
config: ProcessStepConfig;
|
|
25
|
-
} | {
|
|
26
|
-
type: "node";
|
|
27
|
-
config: NodeStepConfig;
|
|
28
|
-
} | {
|
|
29
|
-
type: "telegram-message";
|
|
30
|
-
config: TelegramMessageStepConfig;
|
|
31
|
-
} | {
|
|
32
|
-
type: "ntfy";
|
|
33
|
-
config: NtfyStepConfig;
|
|
34
|
-
};
|
|
35
|
-
export type StepOptions = {
|
|
36
|
-
env?: Record<string, string | undefined>;
|
|
37
|
-
vars?: Record<string, any>;
|
|
38
|
-
cwd?: string;
|
|
39
|
-
tempDir?: () => Promise<string>;
|
|
40
|
-
onLine?: (p: string) => any;
|
|
41
|
-
verbose?: boolean;
|
|
42
|
-
};
|
|
43
|
-
export declare function runSteps(input: Step[] | Step, options: StepOptions): Promise<void>;
|
package/utils/steps.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runSteps = void 0;
|
|
4
|
-
const http_1 = require("./http");
|
|
5
|
-
const process_1 = require("./process");
|
|
6
|
-
const string_1 = require("./string");
|
|
7
|
-
const temp_1 = require("./temp");
|
|
8
|
-
const promises_1 = require("fs/promises");
|
|
9
|
-
const path_1 = require("path");
|
|
10
|
-
async function runSteps(input, options) {
|
|
11
|
-
const steps = Array.isArray(input) ? input : [input];
|
|
12
|
-
const vars = options?.vars || {};
|
|
13
|
-
for (const step of steps) {
|
|
14
|
-
if (step.type === "process") {
|
|
15
|
-
await (0, process_1.exec)(step.config.command, (step.config.args || []).map((v) => (0, string_1.render)(v, vars)), {
|
|
16
|
-
cwd: options.cwd,
|
|
17
|
-
env: {
|
|
18
|
-
...process.env,
|
|
19
|
-
...options.env,
|
|
20
|
-
...step.config.env,
|
|
21
|
-
},
|
|
22
|
-
}, {
|
|
23
|
-
log: options.verbose,
|
|
24
|
-
...(options.onLine && {
|
|
25
|
-
stdout: {
|
|
26
|
-
parseLines: "skip-empty",
|
|
27
|
-
onData: (line) => options.onLine(line),
|
|
28
|
-
},
|
|
29
|
-
}),
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
else if (step.type === "node") {
|
|
33
|
-
let tempDir;
|
|
34
|
-
if (options?.tempDir) {
|
|
35
|
-
tempDir = await options.tempDir();
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
tempDir = await (0, temp_1.mkTmpDir)("node-step");
|
|
39
|
-
}
|
|
40
|
-
const scriptPath = (0, path_1.join)(tempDir, "script.js");
|
|
41
|
-
const nodeVars = {
|
|
42
|
-
...step.config.vars,
|
|
43
|
-
...vars,
|
|
44
|
-
};
|
|
45
|
-
const varKeys = Object.keys(nodeVars);
|
|
46
|
-
const varJson = JSON.stringify(nodeVars);
|
|
47
|
-
const code = Array.isArray(step.config.code)
|
|
48
|
-
? [...step.config.code].join(";\n")
|
|
49
|
-
: step.config.code;
|
|
50
|
-
await (0, promises_1.writeFile)(scriptPath, `(async function({ ${varKeys} }) {\n${code};\n})(${varJson});`);
|
|
51
|
-
await (0, process_1.exec)("node", [scriptPath], {
|
|
52
|
-
cwd: options.cwd,
|
|
53
|
-
env: {
|
|
54
|
-
...process.env,
|
|
55
|
-
...options.env,
|
|
56
|
-
...step.config.env,
|
|
57
|
-
},
|
|
58
|
-
}, {
|
|
59
|
-
log: options.verbose,
|
|
60
|
-
...(options.onLine && {
|
|
61
|
-
stdout: {
|
|
62
|
-
parseLines: "skip-empty",
|
|
63
|
-
onData: (line) => options.onLine(line),
|
|
64
|
-
},
|
|
65
|
-
}),
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
else if (step.type === "telegram-message") {
|
|
69
|
-
await (0, http_1.post)(`https://api.telegram.org/bot${step.config.bot}/sendMessage`, JSON.stringify({
|
|
70
|
-
chat_id: step.config.chatId.toString(),
|
|
71
|
-
text: (0, string_1.render)(step.config.text ?? `{dtt.text}`, vars),
|
|
72
|
-
disable_notification: true,
|
|
73
|
-
}), {
|
|
74
|
-
headers: {
|
|
75
|
-
"Content-Type": "application/json",
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
else if (step.type === "ntfy") {
|
|
80
|
-
const topic = [step.config.token, step.config.topic]
|
|
81
|
-
.filter(Boolean)
|
|
82
|
-
.join("-");
|
|
83
|
-
if (topic.length < 32)
|
|
84
|
-
throw new Error(`Topic is less than 32 characters: ${topic}`);
|
|
85
|
-
await (0, http_1.post)(`https://ntfy.sh/${topic}`, (0, string_1.render)(step.config.text ?? `{dtt.text}`, vars), {
|
|
86
|
-
headers: {
|
|
87
|
-
Title: (0, string_1.render)("{dtt.title}", vars),
|
|
88
|
-
Priority: vars.success ? "default" : "high",
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
throw new Error(`Invalid step type: ${step.type}`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
exports.runSteps = runSteps;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{bin.js → lib/bin.js}
RENAMED
|
File without changes
|
/package/{cli.js → lib/cli.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{pkg.js → lib/pkg.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|