@prosopo/datasets-fs 2.1.5 → 2.1.6
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/dist/cjs/cli/cli.cjs +58 -0
- package/dist/cjs/index.cjs +4 -0
- package/dist/cli/cli.d.ts +9 -0
- package/dist/cli/cli.d.ts.map +1 -0
- package/dist/cli/cli.js +58 -0
- package/dist/cli/cli.js.map +1 -0
- package/dist/cli/cliCommand.d.ts +17 -0
- package/dist/cli/cliCommand.d.ts.map +1 -0
- package/dist/cli/cliCommand.js +28 -0
- package/dist/cli/cliCommand.js.map +1 -0
- package/dist/cli/cliCommandComposite.d.ts +14 -0
- package/dist/cli/cliCommandComposite.d.ts.map +1 -0
- package/dist/cli/cliCommandComposite.js +32 -0
- package/dist/cli/cliCommandComposite.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +34 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/flatten.d.ts +59 -0
- package/dist/commands/flatten.d.ts.map +1 -0
- package/dist/commands/flatten.js +96 -0
- package/dist/commands/flatten.js.map +1 -0
- package/dist/commands/generate.d.ts +115 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +150 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/generateV1.d.ts +179 -0
- package/dist/commands/generateV1.d.ts.map +1 -0
- package/dist/commands/generateV1.js +169 -0
- package/dist/commands/generateV1.js.map +1 -0
- package/dist/commands/generateV2.d.ts +189 -0
- package/dist/commands/generateV2.d.ts.map +1 -0
- package/dist/commands/generateV2.js +200 -0
- package/dist/commands/generateV2.js.map +1 -0
- package/dist/commands/get.d.ts +35 -0
- package/dist/commands/get.d.ts.map +1 -0
- package/dist/commands/get.js +79 -0
- package/dist/commands/get.js.map +1 -0
- package/dist/commands/labels.d.ts +47 -0
- package/dist/commands/labels.d.ts.map +1 -0
- package/dist/commands/labels.js +48 -0
- package/dist/commands/labels.js.map +1 -0
- package/dist/commands/relocate.d.ts +71 -0
- package/dist/commands/relocate.d.ts.map +1 -0
- package/dist/commands/relocate.js +75 -0
- package/dist/commands/relocate.js.map +1 -0
- package/dist/commands/resize.d.ts +69 -0
- package/dist/commands/resize.d.ts.map +1 -0
- package/dist/commands/resize.js +112 -0
- package/dist/commands/resize.js.map +1 -0
- package/dist/dummy.d.ts +2 -0
- package/dist/dummy.d.ts.map +1 -0
- package/dist/dummy.js +28 -0
- package/dist/dummy.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/tests/data/flat_resized/labels.json +13 -0
- package/dist/tests/data/flat_resized/relocated_data.json +364 -0
- package/dist/tests/lodash.test.d.ts +2 -0
- package/dist/tests/lodash.test.d.ts.map +1 -0
- package/dist/tests/lodash.test.js +26 -0
- package/dist/tests/lodash.test.js.map +1 -0
- package/dist/tests/lodash.unit.test.d.ts +2 -0
- package/dist/tests/lodash.unit.test.d.ts.map +1 -0
- package/dist/tests/lodash.unit.test.js +29 -0
- package/dist/tests/lodash.unit.test.js.map +1 -0
- package/dist/tests/mocked.test.d.ts +2 -0
- package/dist/tests/mocked.test.d.ts.map +1 -0
- package/dist/tests/mocked.test.js +247 -0
- package/dist/tests/mocked.test.js.map +1 -0
- package/dist/tests/mocked.unit.test.d.ts +2 -0
- package/dist/tests/mocked.unit.test.d.ts.map +1 -0
- package/dist/tests/mocked.unit.test.js +253 -0
- package/dist/tests/mocked.unit.test.js.map +1 -0
- package/dist/tests/utils.d.ts +35 -0
- package/dist/tests/utils.d.ts.map +1 -0
- package/dist/tests/utils.js +101 -0
- package/dist/tests/utils.js.map +1 -0
- package/dist/utils/input.d.ts +24 -0
- package/dist/utils/input.d.ts.map +1 -0
- package/dist/utils/input.js +35 -0
- package/dist/utils/input.js.map +1 -0
- package/dist/utils/inputOutput.d.ts +21 -0
- package/dist/utils/inputOutput.d.ts.map +1 -0
- package/dist/utils/inputOutput.js +10 -0
- package/dist/utils/inputOutput.js.map +1 -0
- package/dist/utils/output.d.ts +36 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +62 -0
- package/dist/utils/output.js.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { CaptchasContainerSchema, DataSchema, } from "@prosopo/types";
|
|
3
|
+
import { at } from "@prosopo/util";
|
|
4
|
+
export function* fsWalk(pth, options) {
|
|
5
|
+
const isDir = fs.existsSync(pth) && fs.statSync(pth).isDirectory();
|
|
6
|
+
let subpaths = isDir ? fs.readdirSync(pth) : [];
|
|
7
|
+
subpaths = subpaths.map((f) => `${pth}/${f}`);
|
|
8
|
+
if (!options?.filesFirst) {
|
|
9
|
+
yield pth;
|
|
10
|
+
}
|
|
11
|
+
for (const subpath of subpaths) {
|
|
12
|
+
yield* fsWalk(subpath, options);
|
|
13
|
+
}
|
|
14
|
+
if (options?.filesFirst) {
|
|
15
|
+
yield pth;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export const fsEq = (pth1, pth2) => {
|
|
19
|
+
const it1 = fsWalk(pth1);
|
|
20
|
+
const it2 = fsWalk(pth2);
|
|
21
|
+
const files1 = [...it1].map((f) => f.slice(pth1.length));
|
|
22
|
+
const files2 = [...it2].map((f) => f.slice(pth2.length));
|
|
23
|
+
if (files1.length !== files2.length) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
files1.sort();
|
|
27
|
+
files2.sort();
|
|
28
|
+
if (!files1.every((f, i) => f === files2[i])) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
for (let i = 0; i < files1.length; i++) {
|
|
32
|
+
const file1 = pth1 + at(files1, i);
|
|
33
|
+
const file2 = pth2 + at(files2, i);
|
|
34
|
+
const stat1 = fs.statSync(file1);
|
|
35
|
+
if (stat1.isDirectory()) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const content1 = fs.readFileSync(file1);
|
|
39
|
+
const content2 = fs.readFileSync(file2);
|
|
40
|
+
if (!content1.equals(content2)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
};
|
|
46
|
+
export const readDataJson = (pth) => {
|
|
47
|
+
let content = fs.readFileSync(pth).toString();
|
|
48
|
+
content = content.replaceAll("${repo}", `${__dirname}/../../../..`);
|
|
49
|
+
const dataJson = JSON.parse(content.toString());
|
|
50
|
+
const data = DataSchema.parse(dataJson);
|
|
51
|
+
return data;
|
|
52
|
+
};
|
|
53
|
+
export const readCaptchasJson = (pth) => {
|
|
54
|
+
const content = fs.readFileSync(pth).toString();
|
|
55
|
+
const dataJson = JSON.parse(content);
|
|
56
|
+
const captchas = CaptchasContainerSchema.parse(dataJson);
|
|
57
|
+
return captchas;
|
|
58
|
+
};
|
|
59
|
+
export const captchasEqFs = (pth1, pth2) => {
|
|
60
|
+
const data1 = readCaptchasJson(pth1);
|
|
61
|
+
const data2 = readCaptchasJson(pth2);
|
|
62
|
+
return captchasEq(data1, data2);
|
|
63
|
+
};
|
|
64
|
+
export const captchasEq = (first, second) => {
|
|
65
|
+
if (first.captchas.length !== second.captchas.length) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
for (let i = 0; i < first.captchas.length; i++) {
|
|
69
|
+
const captcha1 = at(first.captchas, i);
|
|
70
|
+
const captcha2 = at(second.captchas, i);
|
|
71
|
+
if (captcha1.salt === captcha2.salt) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
const { salt: salt1, ...rest1 } = captcha1;
|
|
75
|
+
const { salt: salt2, ...rest2 } = captcha2;
|
|
76
|
+
if (JSON.stringify(rest1) !== JSON.stringify(rest2)) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
};
|
|
82
|
+
export const substituteRepoDir = () => {
|
|
83
|
+
for (const pth of fsWalk(`${__dirname}/data`)) {
|
|
84
|
+
if (!pth.endsWith(".json")) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
fs.copyFileSync(pth, `${pth}.bak`);
|
|
88
|
+
let content = fs.readFileSync(pth).toString();
|
|
89
|
+
content = content.replaceAll("${repo}", `${__dirname}/../../../..`);
|
|
90
|
+
fs.writeFileSync(pth, content);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
export const restoreRepoDir = () => {
|
|
94
|
+
for (const pth of fsWalk(`${__dirname}/data`)) {
|
|
95
|
+
if (!pth.endsWith(".json")) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
fs.renameSync(`${pth}.bak`, pth);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/tests/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAczB,OAAO,EAEN,uBAAuB,EACvB,UAAU,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAGnC,MAAM,SAAS,CAAC,CAAC,MAAM,CACtB,GAAW,EACX,OAEC;IAGD,MAAM,KAAK,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IACnE,IAAI,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAChD,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9C,IAAI,CAAC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;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAErC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,GAAG,SAAS,OAAO,CAAC,EAAE,CAAC;QAC/C,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,SAAS;QACV,CAAC;QAED,EAAE,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC;QAEnC,IAAI,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;QAE9C,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,SAAS,EAAE,GAAG,SAAS,cAAc,CAAC,CAAC;QAEpE,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC;AACF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IAElC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,GAAG,SAAS,OAAO,CAAC,EAAE,CAAC;QAC/C,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,SAAS;QACV,CAAC;QAED,EAAE,CAAC,UAAU,CAAC,GAAG,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC;IAClC,CAAC;AACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { CliCommand } from "../cli/cliCommand.js";
|
|
3
|
+
export declare const InputArgsSchema: z.ZodObject<{
|
|
4
|
+
input: z.ZodString;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
input: string;
|
|
7
|
+
}, {
|
|
8
|
+
input: string;
|
|
9
|
+
}>;
|
|
10
|
+
export type InputArgs = z.infer<typeof InputArgsSchema>;
|
|
11
|
+
export declare class InputCliCommand<T extends typeof InputArgsSchema> extends CliCommand<T> {
|
|
12
|
+
getArgSchema(): T;
|
|
13
|
+
getDescription(): string;
|
|
14
|
+
getOptions(): {
|
|
15
|
+
input: {
|
|
16
|
+
string: boolean;
|
|
17
|
+
alias: string;
|
|
18
|
+
demand: boolean;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
_check(args: InputArgs): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/utils/input.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,eAAO,MAAM,eAAe;;;;;;EAE1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,qBAAa,eAAe,CAC3B,CAAC,SAAS,OAAO,eAAe,CAC/B,SAAQ,UAAU,CAAC,CAAC,CAAC;IACN,YAAY,IAAI,CAAC;IAGjB,cAAc,IAAI,MAAM;IAGxB,UAAU;;;;;;;;IAWJ,MAAM,CAAC,IAAI,EAAE,SAAS;CAa5C"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { ProsopoDatasetError, ProsopoError } from "@prosopo/common";
|
|
3
|
+
import * as z from "zod";
|
|
4
|
+
import { CliCommand } from "../cli/cliCommand.js";
|
|
5
|
+
export const InputArgsSchema = z.object({
|
|
6
|
+
input: z.string(),
|
|
7
|
+
});
|
|
8
|
+
export class InputCliCommand extends CliCommand {
|
|
9
|
+
getArgSchema() {
|
|
10
|
+
throw new ProsopoError("DEVELOPER.METHOD_NOT_IMPLEMENTED");
|
|
11
|
+
}
|
|
12
|
+
getDescription() {
|
|
13
|
+
throw new ProsopoError("DEVELOPER.METHOD_NOT_IMPLEMENTED");
|
|
14
|
+
}
|
|
15
|
+
getOptions() {
|
|
16
|
+
return {
|
|
17
|
+
input: {
|
|
18
|
+
string: true,
|
|
19
|
+
alias: "in",
|
|
20
|
+
demand: true,
|
|
21
|
+
description: "The input path",
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async _check(args) {
|
|
26
|
+
this.logger.debug("input _check");
|
|
27
|
+
await super._check(args);
|
|
28
|
+
if (!fs.existsSync(args.input)) {
|
|
29
|
+
throw new ProsopoDatasetError(new Error(`input path does not exist: ${args.input}`), {
|
|
30
|
+
translationKey: "FS.FILE_NOT_FOUND",
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/utils/input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAcpE,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;CACjB,CAAC,CAAC;AAIH,MAAM,OAAO,eAEX,SAAQ,UAAa;IACN,YAAY;QAC3B,MAAM,IAAI,YAAY,CAAC,kCAAkC,CAAC,CAAC;IAC5D,CAAC;IACe,cAAc;QAC7B,MAAM,IAAI,YAAY,CAAC,kCAAkC,CAAC,CAAC;IAC5D,CAAC;IACe,UAAU;QACzB,OAAO;YACN,KAAK,EAAE;gBACN,MAAM,EAAE,IAAI;gBACZ,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,IAAI;gBACZ,WAAW,EAAE,gBAAgB;aAC7B;SACD,CAAC;IACH,CAAC;IAEe,KAAK,CAAC,MAAM,CAAC,IAAe;QAC3C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAClC,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEzB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,mBAAmB,CAC5B,IAAI,KAAK,CAAC,8BAA8B,IAAI,CAAC,KAAK,EAAE,CAAC,EACrD;gBACC,cAAc,EAAE,mBAAmB;aACnC,CACD,CAAC;QACH,CAAC;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type * as z from "zod";
|
|
2
|
+
import { CliCommandComposite } from "../cli/cliCommandComposite.js";
|
|
3
|
+
export declare const InputOutputArgsSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
4
|
+
input: z.ZodString;
|
|
5
|
+
}, {
|
|
6
|
+
output: z.ZodString;
|
|
7
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
}>, "strip", z.ZodTypeAny, {
|
|
9
|
+
input: string;
|
|
10
|
+
output: string;
|
|
11
|
+
overwrite?: boolean | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
input: string;
|
|
14
|
+
output: string;
|
|
15
|
+
overwrite?: boolean | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
export type InputOutputArgs = z.infer<typeof InputOutputArgsSchema>;
|
|
18
|
+
export declare abstract class InputOutputCliCommand<T extends typeof InputOutputArgsSchema> extends CliCommandComposite<T> {
|
|
19
|
+
constructor();
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=inputOutput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputOutput.d.ts","sourceRoot":"","sources":["../../src/utils/inputOutput.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,KAAK,CAAC,MAAM,KAAK,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAIpE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;EAA0C,CAAC;AAE7E,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,8BAAsB,qBAAqB,CAC1C,CAAC,SAAS,OAAO,qBAAqB,CACrC,SAAQ,mBAAmB,CAAC,CAAC,CAAC;;CAI/B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CliCommandComposite } from "../cli/cliCommandComposite.js";
|
|
2
|
+
import { InputArgsSchema, InputCliCommand } from "./input.js";
|
|
3
|
+
import { OutputArgsSchema, OutputCliCommand } from "./output.js";
|
|
4
|
+
export const InputOutputArgsSchema = InputArgsSchema.merge(OutputArgsSchema);
|
|
5
|
+
export class InputOutputCliCommand extends CliCommandComposite {
|
|
6
|
+
constructor() {
|
|
7
|
+
super([new InputCliCommand(), new OutputCliCommand()]);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=inputOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputOutput.js","sourceRoot":"","sources":["../../src/utils/inputOutput.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEjE,MAAM,CAAC,MAAM,qBAAqB,GAAG,eAAe,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;AAI7E,MAAM,OAAgB,qBAEpB,SAAQ,mBAAsB;IAC/B;QACC,KAAK,CAAC,CAAC,IAAI,eAAe,EAAK,EAAE,IAAI,gBAAgB,EAAK,CAAC,CAAC,CAAC;IAC9D,CAAC;CACD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type infer as zInfer } from "zod";
|
|
2
|
+
import { CliCommand } from "../cli/cliCommand.js";
|
|
3
|
+
export declare const OutputArgsSchema: import("zod").ZodObject<{
|
|
4
|
+
output: import("zod").ZodString;
|
|
5
|
+
overwrite: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
6
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
7
|
+
output: string;
|
|
8
|
+
overwrite?: boolean | undefined;
|
|
9
|
+
}, {
|
|
10
|
+
output: string;
|
|
11
|
+
overwrite?: boolean | undefined;
|
|
12
|
+
}>;
|
|
13
|
+
export type OutputArgs = zInfer<typeof OutputArgsSchema>;
|
|
14
|
+
export declare class OutputCliCommand<T extends typeof OutputArgsSchema> extends CliCommand<T> {
|
|
15
|
+
#private;
|
|
16
|
+
outputExists(): boolean;
|
|
17
|
+
getArgSchema(): T;
|
|
18
|
+
getDescription(): string;
|
|
19
|
+
getOptions(): {
|
|
20
|
+
[key: string]: import("yargs").Options;
|
|
21
|
+
} & {
|
|
22
|
+
output: {
|
|
23
|
+
alias: string;
|
|
24
|
+
string: boolean;
|
|
25
|
+
demand: boolean;
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
overwrite: {
|
|
29
|
+
boolean: boolean;
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
_check(args: OutputArgs): Promise<void>;
|
|
34
|
+
_run(args: OutputArgs): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAGA,OAAO,EAA2B,KAAK,KAAK,IAAI,MAAM,EAAE,MAAM,KAAK,CAAC;AAcpE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,eAAO,MAAM,gBAAgB;;;;;;;;;EAG3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEzD,qBAAa,gBAAgB,CAC5B,CAAC,SAAS,OAAO,gBAAgB,CAChC,SAAQ,UAAU,CAAC,CAAC,CAAC;;IAGf,YAAY;IAIH,YAAY,IAAI,CAAC;IAGjB,cAAc,IAAI,MAAM;IAGxB,UAAU;;;;;;;;;;;;;;IAeJ,MAAM,CAAC,IAAI,EAAE,UAAU;IAoBvB,IAAI,CAAC,IAAI,EAAE,UAAU;CAS3C"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var _OutputCliCommand_outputExists;
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import { ProsopoEnvError, ProsopoError } from "@prosopo/common";
|
|
5
|
+
import { lodash } from "@prosopo/util/lodash";
|
|
6
|
+
import { boolean, object, string } from "zod";
|
|
7
|
+
import { CliCommand } from "../cli/cliCommand.js";
|
|
8
|
+
export const OutputArgsSchema = object({
|
|
9
|
+
output: string(),
|
|
10
|
+
overwrite: boolean().optional(),
|
|
11
|
+
});
|
|
12
|
+
export class OutputCliCommand extends CliCommand {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
_OutputCliCommand_outputExists.set(this, false);
|
|
16
|
+
}
|
|
17
|
+
outputExists() {
|
|
18
|
+
return __classPrivateFieldGet(this, _OutputCliCommand_outputExists, "f");
|
|
19
|
+
}
|
|
20
|
+
getArgSchema() {
|
|
21
|
+
throw new ProsopoError("DEVELOPER.METHOD_NOT_IMPLEMENTED");
|
|
22
|
+
}
|
|
23
|
+
getDescription() {
|
|
24
|
+
throw new ProsopoError("DEVELOPER.METHOD_NOT_IMPLEMENTED");
|
|
25
|
+
}
|
|
26
|
+
getOptions() {
|
|
27
|
+
return lodash().merge(super.getOptions(), {
|
|
28
|
+
output: {
|
|
29
|
+
alias: "out",
|
|
30
|
+
string: true,
|
|
31
|
+
demand: true,
|
|
32
|
+
description: "The output path",
|
|
33
|
+
},
|
|
34
|
+
overwrite: {
|
|
35
|
+
boolean: true,
|
|
36
|
+
description: "Overwrite files in the output path if they already exist",
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async _check(args) {
|
|
41
|
+
this.logger.debug("Output _check");
|
|
42
|
+
await super._check(args);
|
|
43
|
+
__classPrivateFieldSet(this, _OutputCliCommand_outputExists, fs.existsSync(args.output), "f");
|
|
44
|
+
if (this.outputExists()) {
|
|
45
|
+
if (!args.overwrite) {
|
|
46
|
+
throw new ProsopoEnvError(new Error(`output path already exists: ${args.output}`), {
|
|
47
|
+
translationKey: "FS.FILE_ALREADY_EXISTS",
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async _run(args) {
|
|
53
|
+
this.logger.debug("Output run");
|
|
54
|
+
await super._run(args);
|
|
55
|
+
if (args.overwrite && this.outputExists()) {
|
|
56
|
+
this.logger.info("cleaning output directory...");
|
|
57
|
+
fs.rmSync(args.output, { recursive: true });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
_OutputCliCommand_outputExists = new WeakMap();
|
|
62
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAwB,MAAM,KAAK,CAAC;AAcpE,OA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AAC,EACvD;oBACC,cAAc,EAAE,wBAAwB;iBACxC,CACD,CAAC;YACH,CAAC;QACF,CAAC;IACF,CAAC;IAEe,KAAK,CAAC,IAAI,CAAC,IAAgB;QAC1C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAChC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;YAE3C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;YACjD,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7C,CAAC;IACF,CAAC;CACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/datasets-fs",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.6",
|
|
4
4
|
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"private": false,
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"@noble/hashes": "1.5.0",
|
|
29
29
|
"@polkadot/util": "12.6.2",
|
|
30
30
|
"@polkadot/util-crypto": "12.6.2",
|
|
31
|
-
"@prosopo/common": "2.1.
|
|
32
|
-
"@prosopo/types": "2.1.
|
|
33
|
-
"@prosopo/util": "2.1.
|
|
31
|
+
"@prosopo/common": "2.1.6",
|
|
32
|
+
"@prosopo/types": "2.1.6",
|
|
33
|
+
"@prosopo/util": "2.1.6",
|
|
34
34
|
"bcrypt": "5.1.1",
|
|
35
35
|
"cli-progress": "3.12.0",
|
|
36
36
|
"sharp": "0.33.5",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"zod": "3.23.8"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@prosopo/config": "2.1.
|
|
41
|
+
"@prosopo/config": "2.1.6",
|
|
42
42
|
"@types/bcrypt": "5.0.2",
|
|
43
43
|
"@types/cli-progress": "3.11.6",
|
|
44
44
|
"@vitest/coverage-v8": "2.1.1",
|