@datatruck/cli 0.11.4 → 0.11.7
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/Repository/ResticRepository.js +28 -2
- package/config.schema.json +18 -2
- package/package.json +1 -1
- package/util/ResticUtil.d.ts +4 -2
- package/util/ResticUtil.js +6 -3
- package/util/fs-util.d.ts +4 -0
- package/util/fs-util.js +10 -1
|
@@ -13,6 +13,7 @@ const string_util_1 = require("../util/string-util");
|
|
|
13
13
|
const RepositoryAbstract_1 = require("./RepositoryAbstract");
|
|
14
14
|
const assert_1 = require("assert");
|
|
15
15
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
16
|
+
const promises_1 = require("fs/promises");
|
|
16
17
|
const micromatch_1 = require("micromatch");
|
|
17
18
|
const path_1 = require("path");
|
|
18
19
|
exports.resticRepositoryName = "restic";
|
|
@@ -54,7 +55,19 @@ exports.resticRepositoryDefinition = {
|
|
|
54
55
|
},
|
|
55
56
|
host: { type: "string" },
|
|
56
57
|
username: { type: "string" },
|
|
57
|
-
|
|
58
|
+
password: {
|
|
59
|
+
anyOf: [
|
|
60
|
+
{ type: "string" },
|
|
61
|
+
{
|
|
62
|
+
type: "object",
|
|
63
|
+
additionalProperties: false,
|
|
64
|
+
required: ["path"],
|
|
65
|
+
properties: {
|
|
66
|
+
path: { type: "string" },
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
58
71
|
port: { type: "integer" },
|
|
59
72
|
path: { type: "string" },
|
|
60
73
|
},
|
|
@@ -174,7 +187,20 @@ class ResticRepository extends RepositoryAbstract_1.RepositoryAbstract {
|
|
|
174
187
|
const sourcePath = data.targetPath ?? data.package.path;
|
|
175
188
|
(0, assert_1.ok)(sourcePath);
|
|
176
189
|
let gitignorePath;
|
|
177
|
-
if (pkg.include
|
|
190
|
+
if (!pkg.include && pkg.exclude) {
|
|
191
|
+
const exclude = await (0, paths_util_1.parsePaths)(pkg.exclude, {
|
|
192
|
+
cwd: sourcePath,
|
|
193
|
+
verbose: data.options.verbose,
|
|
194
|
+
});
|
|
195
|
+
await data.onProgress({
|
|
196
|
+
step: "Writing excluded paths list...",
|
|
197
|
+
});
|
|
198
|
+
const tmpDir = await (0, fs_util_1.mkTmpDir)("restic-exclude");
|
|
199
|
+
const ignoredContents = (0, fs_util_1.fastglobToGitIgnore)(exclude, sourcePath).join("\n");
|
|
200
|
+
gitignorePath = (0, path_1.join)(tmpDir, "ignored.txt");
|
|
201
|
+
await (0, promises_1.writeFile)(gitignorePath, ignoredContents);
|
|
202
|
+
}
|
|
203
|
+
else if (pkg.include || pkg.exclude) {
|
|
178
204
|
const include = await (0, paths_util_1.parsePaths)(pkg.include ?? ["**"], {
|
|
179
205
|
cwd: sourcePath,
|
|
180
206
|
verbose: data.options.verbose,
|
package/config.schema.json
CHANGED
|
@@ -565,8 +565,24 @@
|
|
|
565
565
|
"username": {
|
|
566
566
|
"type": "string"
|
|
567
567
|
},
|
|
568
|
-
"
|
|
569
|
-
"
|
|
568
|
+
"password": {
|
|
569
|
+
"anyOf": [
|
|
570
|
+
{
|
|
571
|
+
"type": "string"
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
"type": "object",
|
|
575
|
+
"additionalProperties": false,
|
|
576
|
+
"required": [
|
|
577
|
+
"path"
|
|
578
|
+
],
|
|
579
|
+
"properties": {
|
|
580
|
+
"path": {
|
|
581
|
+
"type": "string"
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
]
|
|
570
586
|
},
|
|
571
587
|
"port": {
|
|
572
588
|
"type": "integer"
|
package/package.json
CHANGED
package/util/ResticUtil.d.ts
CHANGED
|
@@ -3,9 +3,11 @@ import { UriType } from "./string-util";
|
|
|
3
3
|
export declare type RepositoryType = {
|
|
4
4
|
name?: string;
|
|
5
5
|
env?: Record<string, string>;
|
|
6
|
-
|
|
6
|
+
password?: string | {
|
|
7
|
+
path: string;
|
|
8
|
+
};
|
|
7
9
|
backend: "local" | "rest" | "sftp" | "s3" | "azure" | "gs" | "rclone";
|
|
8
|
-
} & UriType
|
|
10
|
+
} & Omit<UriType, "password">;
|
|
9
11
|
export declare type BackupStreamType = {
|
|
10
12
|
message_type: "status";
|
|
11
13
|
seconds_elapsed: number;
|
package/util/ResticUtil.js
CHANGED
|
@@ -16,12 +16,15 @@ class ResticUtil {
|
|
|
16
16
|
throw new Error(`Invalid path at "${input.name}" repository: ${input.path}`);
|
|
17
17
|
return (0, path_1.resolve)(input.path);
|
|
18
18
|
}
|
|
19
|
-
if (input.
|
|
19
|
+
if (input.password) {
|
|
20
20
|
input = {
|
|
21
21
|
...input,
|
|
22
|
-
password:
|
|
22
|
+
password: typeof input.password === "string"
|
|
23
|
+
? input.password
|
|
24
|
+
: (await (0, promises_1.readFile)(input.password.path)).toString(),
|
|
23
25
|
};
|
|
24
|
-
|
|
26
|
+
}
|
|
27
|
+
return `${input.backend}:${(0, string_util_1.formatUri)({ ...input, password: input.password }, hidePassword)}`;
|
|
25
28
|
}
|
|
26
29
|
async exec(args, settings, options) {
|
|
27
30
|
return await (0, process_util_1.exec)("restic", args, {
|
package/util/fs-util.d.ts
CHANGED
|
@@ -29,6 +29,10 @@ export declare function checkFile(path: string): Promise<boolean>;
|
|
|
29
29
|
export declare function checkDir(path: string): Promise<boolean>;
|
|
30
30
|
export declare function readDir(path: string): Promise<string[]>;
|
|
31
31
|
export declare function forEachFile(dirPath: string, cb: (path: string, dir: boolean) => void, includeDir?: boolean): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* @experimental
|
|
34
|
+
*/
|
|
35
|
+
export declare function fastglobToGitIgnore(patterns: string[], baseDir: string): string[];
|
|
32
36
|
export declare function writeGitIgnoreList(options: {
|
|
33
37
|
paths: NodeJS.ReadableStream | string[];
|
|
34
38
|
}): Promise<string>;
|
package/util/fs-util.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.cpy = exports.updateFileStats = exports.copyFileWithStreams = exports.writePathLists = exports.writeGitIgnoreList = exports.forEachFile = exports.readDir = exports.checkDir = exports.checkFile = exports.readPartialFile = exports.mkTmpDir = exports.tmpDir = exports.sessionTmpDir = exports.parentTmpDir = exports.existsFile = exports.findFile = exports.parsePackageFile = exports.parseFile = exports.parseFileExtensions = exports.readdirIfExists = exports.writeJSONFile = exports.existsDir = exports.ensureEmptyDir = exports.mkdirIfNotExists = exports.isDirEmpty = exports.isLocalDir = exports.isWSLSystem = void 0;
|
|
6
|
+
exports.cpy = exports.updateFileStats = exports.copyFileWithStreams = exports.writePathLists = exports.writeGitIgnoreList = exports.fastglobToGitIgnore = exports.forEachFile = exports.readDir = exports.checkDir = exports.checkFile = exports.readPartialFile = exports.mkTmpDir = exports.tmpDir = exports.sessionTmpDir = exports.parentTmpDir = exports.existsFile = exports.findFile = exports.parsePackageFile = exports.parseFile = exports.parseFileExtensions = exports.readdirIfExists = exports.writeJSONFile = exports.existsDir = exports.ensureEmptyDir = exports.mkdirIfNotExists = exports.isDirEmpty = exports.isLocalDir = exports.isWSLSystem = void 0;
|
|
7
7
|
const globalData_1 = __importDefault(require("../globalData"));
|
|
8
8
|
const path_util_1 = require("./path-util");
|
|
9
9
|
const async_1 = require("async");
|
|
@@ -213,6 +213,15 @@ async function forEachFile(dirPath, cb, includeDir) {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
exports.forEachFile = forEachFile;
|
|
216
|
+
/**
|
|
217
|
+
* @experimental
|
|
218
|
+
*/
|
|
219
|
+
function fastglobToGitIgnore(patterns, baseDir) {
|
|
220
|
+
// https://github.com/mrmlnc/fast-glob#readme
|
|
221
|
+
// https://git-scm.com/docs/gitignore
|
|
222
|
+
return patterns.map((p) => `${baseDir}/${p}`);
|
|
223
|
+
}
|
|
224
|
+
exports.fastglobToGitIgnore = fastglobToGitIgnore;
|
|
216
225
|
async function writeGitIgnoreList(options) {
|
|
217
226
|
const tempDir = await mkTmpDir("gitignore-list");
|
|
218
227
|
const path = (0, path_1.join)(tempDir, `.gitignore`);
|