@prosopo/datasets-fs 1.0.1 → 2.0.0
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/README.md +17 -5
- package/dist/cjs/cli/cli.cjs +8 -5
- package/dist/cli/cli.d.ts +2 -2
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +18 -13
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/cliCommand.d.ts +3 -3
- package/dist/cli/cliCommand.d.ts.map +1 -1
- package/dist/cli/cliCommand.js +6 -6
- package/dist/cli/cliCommand.js.map +1 -1
- package/dist/cli/cliCommandComposite.d.ts +3 -3
- package/dist/cli/cliCommandComposite.d.ts.map +1 -1
- package/dist/cli/cliCommandComposite.js +1 -1
- package/dist/cli/cliCommandComposite.js.map +1 -1
- package/dist/cli.js +11 -11
- package/dist/cli.js.map +1 -1
- package/dist/commands/flatten.d.ts +2 -2
- package/dist/commands/flatten.d.ts.map +1 -1
- package/dist/commands/flatten.js +22 -22
- package/dist/commands/flatten.js.map +1 -1
- package/dist/commands/generate.d.ts +3 -3
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +32 -28
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/generateV1.d.ts +2 -2
- package/dist/commands/generateV1.d.ts.map +1 -1
- package/dist/commands/generateV1.js +27 -25
- package/dist/commands/generateV1.js.map +1 -1
- package/dist/commands/generateV2.d.ts +6 -6
- package/dist/commands/generateV2.d.ts.map +1 -1
- package/dist/commands/generateV2.js +34 -28
- package/dist/commands/generateV2.js.map +1 -1
- package/dist/commands/get.d.ts +2 -2
- package/dist/commands/get.d.ts.map +1 -1
- package/dist/commands/get.js +11 -11
- package/dist/commands/get.js.map +1 -1
- package/dist/commands/labels.d.ts +2 -2
- package/dist/commands/labels.d.ts.map +1 -1
- package/dist/commands/labels.js +14 -11
- package/dist/commands/labels.js.map +1 -1
- package/dist/commands/relocate.d.ts +2 -2
- package/dist/commands/relocate.d.ts.map +1 -1
- package/dist/commands/relocate.js +19 -17
- package/dist/commands/relocate.js.map +1 -1
- package/dist/commands/resize.d.ts +2 -2
- package/dist/commands/resize.d.ts.map +1 -1
- package/dist/commands/resize.js +26 -24
- package/dist/commands/resize.js.map +1 -1
- package/dist/dummy.js +5 -5
- package/dist/dummy.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/tests/data/flat_resized/labels.json +11 -1
- package/dist/tests/lodash.test.js +10 -7
- package/dist/tests/lodash.test.js.map +1 -1
- package/dist/tests/mocked.test.js +51 -45
- package/dist/tests/mocked.test.js.map +1 -1
- package/dist/tests/utils.d.ts +1 -1
- package/dist/tests/utils.d.ts.map +1 -1
- package/dist/tests/utils.js +11 -11
- package/dist/tests/utils.js.map +1 -1
- package/dist/utils/input.d.ts +2 -2
- package/dist/utils/input.d.ts.map +1 -1
- package/dist/utils/input.js +10 -10
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/inputOutput.d.ts +2 -2
- package/dist/utils/inputOutput.d.ts.map +1 -1
- package/dist/utils/inputOutput.js +3 -3
- package/dist/utils/inputOutput.js.map +1 -1
- package/dist/utils/output.d.ts +2 -2
- package/dist/utils/output.d.ts.map +1 -1
- package/dist/utils/output.js +14 -14
- package/dist/utils/output.js.map +1 -1
- package/package.json +63 -68
- package/vite.cjs.config.ts +3 -3
- package/vite.test.config.ts +12 -12
- package/typedoc.config.js +0 -19
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import { afterAll, beforeAll, describe, test } from
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
describe(
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { blake2b } from "@noble/hashes/blake2b";
|
|
4
|
+
import { u8aToHex } from "@polkadot/util/u8a";
|
|
5
|
+
import { getRootDir, getTestResultsDir } from "@prosopo/config";
|
|
6
|
+
import { CaptchasContainerSchema, DataSchema } from "@prosopo/types";
|
|
7
|
+
import sharp from "sharp";
|
|
8
|
+
import { afterAll, beforeAll, describe, test } from "vitest";
|
|
9
|
+
import { Flatten } from "../commands/flatten.js";
|
|
10
|
+
import { GenerateV1 } from "../commands/generateV1.js";
|
|
11
|
+
import { GenerateV2 } from "../commands/generateV2.js";
|
|
12
|
+
import { Labels } from "../commands/labels.js";
|
|
13
|
+
import { Relocate } from "../commands/relocate.js";
|
|
14
|
+
import { Resize } from "../commands/resize.js";
|
|
15
|
+
import { captchasEqFs, fsEq, fsWalk, restoreRepoDir, substituteRepoDir, } from "./utils.js";
|
|
16
|
+
describe("dataset commands", () => {
|
|
17
17
|
const pkgDir = path.relative(getRootDir(), __dirname);
|
|
18
|
-
const pkgInternalPath = pkgDir.replace(`${__dirname}/`,
|
|
18
|
+
const pkgInternalPath = pkgDir.replace(`${__dirname}/`, "");
|
|
19
19
|
const testResultsDir = `${getTestResultsDir()}/${pkgInternalPath}`;
|
|
20
20
|
beforeAll(() => {
|
|
21
21
|
substituteRepoDir();
|
|
@@ -27,11 +27,11 @@ describe('dataset commands', () => {
|
|
|
27
27
|
fs.rmdirSync(`${testResultsDir}`, { recursive: true });
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
test(
|
|
30
|
+
test("labels", async () => {
|
|
31
31
|
const input = `${__dirname}/data/flat_resized/data.json`;
|
|
32
32
|
const output = `${testResultsDir}/labels.json`;
|
|
33
33
|
const labels = new Labels();
|
|
34
|
-
labels.logger.setLogLevel(
|
|
34
|
+
labels.logger.setLogLevel("error");
|
|
35
35
|
await labels.exec({
|
|
36
36
|
input,
|
|
37
37
|
output,
|
|
@@ -45,7 +45,7 @@ describe('dataset commands', () => {
|
|
|
45
45
|
throw new Error(`expected ${categories} but found ${foundLabels}`);
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
-
test(
|
|
48
|
+
test("generate v2", async () => {
|
|
49
49
|
const input = `${__dirname}/data/flat_resized/data.json`;
|
|
50
50
|
const output = `${testResultsDir}/captchas_v2.json`;
|
|
51
51
|
const minIncorrect = 1;
|
|
@@ -53,7 +53,7 @@ describe('dataset commands', () => {
|
|
|
53
53
|
const minLabelled = 2;
|
|
54
54
|
const maxLabelled = 7;
|
|
55
55
|
const generate = new GenerateV2();
|
|
56
|
-
generate.logger.setLogLevel(
|
|
56
|
+
generate.logger.setLogLevel("error");
|
|
57
57
|
await generate.exec({
|
|
58
58
|
labelled: input,
|
|
59
59
|
unlabelled: input,
|
|
@@ -68,7 +68,7 @@ describe('dataset commands', () => {
|
|
|
68
68
|
allowDuplicates: true,
|
|
69
69
|
});
|
|
70
70
|
if (!captchasEqFs(output, `${__dirname}/data/flat_resized/captchas_v2.json`)) {
|
|
71
|
-
throw new Error(
|
|
71
|
+
throw new Error("captchas not equal");
|
|
72
72
|
}
|
|
73
73
|
const content = fs.readFileSync(output).toString();
|
|
74
74
|
const captchasJson = JSON.parse(content.toString());
|
|
@@ -78,7 +78,7 @@ describe('dataset commands', () => {
|
|
|
78
78
|
const unlabelled = captcha.unlabelled;
|
|
79
79
|
if (solutions === undefined || unlabelled === undefined) {
|
|
80
80
|
console.log(captcha);
|
|
81
|
-
throw new Error(
|
|
81
|
+
throw new Error("solutions or unlabelled array is undefined");
|
|
82
82
|
}
|
|
83
83
|
for (const solution of solutions) {
|
|
84
84
|
if (unlabelled.includes(solution)) {
|
|
@@ -106,11 +106,11 @@ describe('dataset commands', () => {
|
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
|
-
test(
|
|
109
|
+
test("generate v1", async () => {
|
|
110
110
|
const input = `${__dirname}/data/flat_resized/data.json`;
|
|
111
111
|
const output = `${testResultsDir}/captchas_v1.json`;
|
|
112
112
|
const generate = new GenerateV1();
|
|
113
|
-
generate.logger.setLogLevel(
|
|
113
|
+
generate.logger.setLogLevel("error");
|
|
114
114
|
await generate.exec({
|
|
115
115
|
labelled: input,
|
|
116
116
|
unlabelled: input,
|
|
@@ -124,14 +124,14 @@ describe('dataset commands', () => {
|
|
|
124
124
|
allowDuplicates: true,
|
|
125
125
|
});
|
|
126
126
|
if (!captchasEqFs(output, `${__dirname}/data/flat_resized/captchas_v1.json`)) {
|
|
127
|
-
throw new Error(
|
|
127
|
+
throw new Error("captchas not equal");
|
|
128
128
|
}
|
|
129
129
|
});
|
|
130
|
-
test(
|
|
130
|
+
test("resizes data", async () => {
|
|
131
131
|
const input = `${__dirname}/data/flat/data.json`;
|
|
132
132
|
const output = `${testResultsDir}/flat_resized`;
|
|
133
133
|
const resize = new Resize();
|
|
134
|
-
resize.logger.setLogLevel(
|
|
134
|
+
resize.logger.setLogLevel("error");
|
|
135
135
|
await resize.exec({
|
|
136
136
|
input,
|
|
137
137
|
output,
|
|
@@ -142,7 +142,9 @@ describe('dataset commands', () => {
|
|
|
142
142
|
const expected = `${__dirname}/data/flat_resized`;
|
|
143
143
|
fsEq(output, expected);
|
|
144
144
|
for (const pth of fsWalk(output)) {
|
|
145
|
-
if (!pth.endsWith(
|
|
145
|
+
if (!pth.endsWith(".jpg") &&
|
|
146
|
+
!pth.endsWith(".jpeg") &&
|
|
147
|
+
!pth.endsWith(".png")) {
|
|
146
148
|
continue;
|
|
147
149
|
}
|
|
148
150
|
const image = sharp(pth);
|
|
@@ -152,26 +154,26 @@ describe('dataset commands', () => {
|
|
|
152
154
|
}
|
|
153
155
|
}
|
|
154
156
|
});
|
|
155
|
-
test(
|
|
157
|
+
test("relocates data", async () => {
|
|
156
158
|
const input = `${__dirname}/data/flat_resized/data.json`;
|
|
157
159
|
const output = `${testResultsDir}/relocated_data.json`;
|
|
158
160
|
const relocate = new Relocate();
|
|
159
|
-
relocate.logger.setLogLevel(
|
|
161
|
+
relocate.logger.setLogLevel("error");
|
|
160
162
|
await relocate.exec({
|
|
161
163
|
input,
|
|
162
164
|
output,
|
|
163
165
|
overwrite: true,
|
|
164
|
-
to:
|
|
165
|
-
from:
|
|
166
|
+
to: "newwebsite.com",
|
|
167
|
+
from: "${repo}",
|
|
166
168
|
});
|
|
167
169
|
const expected = `${__dirname}/data/flat_resized/relocated_data.json`;
|
|
168
170
|
fsEq(output, expected);
|
|
169
171
|
});
|
|
170
|
-
test(
|
|
172
|
+
test("flattens hierarchical data", async () => {
|
|
171
173
|
const input = `${__dirname}/data/hierarchical`;
|
|
172
174
|
const output = `${testResultsDir}/flat`;
|
|
173
175
|
const flatten = new Flatten();
|
|
174
|
-
flatten.logger.setLogLevel(
|
|
176
|
+
flatten.logger.setLogLevel("error");
|
|
175
177
|
await flatten.exec({
|
|
176
178
|
input,
|
|
177
179
|
output,
|
|
@@ -184,20 +186,22 @@ describe('dataset commands', () => {
|
|
|
184
186
|
const data = DataSchema.parse(dataJson);
|
|
185
187
|
let hierCount = 0;
|
|
186
188
|
for (const pth of fsWalk(input)) {
|
|
187
|
-
if (!pth.endsWith(
|
|
189
|
+
if (!pth.endsWith(".jpg") &&
|
|
190
|
+
!pth.endsWith(".jpeg") &&
|
|
191
|
+
!pth.endsWith(".png")) {
|
|
188
192
|
continue;
|
|
189
193
|
}
|
|
190
194
|
hierCount++;
|
|
191
|
-
const category = pth.split(
|
|
195
|
+
const category = pth.split("/").slice(-2)[0];
|
|
192
196
|
const content = fs.readFileSync(pth);
|
|
193
|
-
let name =
|
|
197
|
+
let name = "";
|
|
194
198
|
for (const pth2 of fsWalk(output)) {
|
|
195
199
|
if (!fs.statSync(pth2).isFile()) {
|
|
196
200
|
continue;
|
|
197
201
|
}
|
|
198
202
|
const content2 = fs.readFileSync(pth2);
|
|
199
203
|
if (content.equals(content2)) {
|
|
200
|
-
const str = pth2.split(
|
|
204
|
+
const str = pth2.split("/").slice(-1)[0];
|
|
201
205
|
if (str === undefined) {
|
|
202
206
|
throw new Error(`unable to parse ${pth2}`);
|
|
203
207
|
}
|
|
@@ -209,7 +213,7 @@ describe('dataset commands', () => {
|
|
|
209
213
|
throw new Error(`unable to find image ${pth} in output`);
|
|
210
214
|
}
|
|
211
215
|
const item = data.items.find((item) => {
|
|
212
|
-
const name2 = item.data.split(
|
|
216
|
+
const name2 = item.data.split("/").slice(-1)[0];
|
|
213
217
|
if (name2 !== name) {
|
|
214
218
|
return false;
|
|
215
219
|
}
|
|
@@ -218,14 +222,14 @@ describe('dataset commands', () => {
|
|
|
218
222
|
if (item === undefined) {
|
|
219
223
|
throw new Error(`unable to find image ${pth} in data.json`);
|
|
220
224
|
}
|
|
221
|
-
if (item.label
|
|
225
|
+
if (item.label !== category) {
|
|
222
226
|
throw new Error(`expected ${category} but found ${item.label}`);
|
|
223
227
|
}
|
|
224
|
-
if (item.type !==
|
|
228
|
+
if (item.type !== "image") {
|
|
225
229
|
throw new Error(`expected image type but found ${item.type}`);
|
|
226
230
|
}
|
|
227
|
-
if (item.hash !== name.split(
|
|
228
|
-
throw new Error(`expected ${name.split(
|
|
231
|
+
if (item.hash !== name.split(".")[0]) {
|
|
232
|
+
throw new Error(`expected ${name.split(".")[0]} hash but found ${item.hash}`);
|
|
229
233
|
}
|
|
230
234
|
const hash = u8aToHex(blake2b(content));
|
|
231
235
|
if (item.hash !== hash) {
|
|
@@ -234,7 +238,9 @@ describe('dataset commands', () => {
|
|
|
234
238
|
}
|
|
235
239
|
let flatCount = 0;
|
|
236
240
|
for (const pth of fsWalk(output)) {
|
|
237
|
-
if (!pth.endsWith(
|
|
241
|
+
if (!pth.endsWith(".jpg") &&
|
|
242
|
+
!pth.endsWith(".jpeg") &&
|
|
243
|
+
!pth.endsWith(".png")) {
|
|
238
244
|
continue;
|
|
239
245
|
}
|
|
240
246
|
flatCount++;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mocked.test.js","sourceRoot":"","sources":["../../src/tests/mocked.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mocked.test.js","sourceRoot":"","sources":["../../src/tests/mocked.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAchE,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EACN,YAAY,EACZ,IAAI,EACJ,MAAM,EACN,cAAc,EACd,iBAAiB,GACjB,MAAM,YAAY,CAAC;AAEpB,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IACjC,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,SAAS,CAAC,CAAC;IACtD,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,SAAS,GAAG,EAAE,EAAE,CAAC,CAAC;IAC5D,MAAM,cAAc,GAAG,GAAG,iBAAiB,EAAE,IAAI,e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I,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;gBACrC,MAAM,IAAI,KAAK,CACd,YAAY,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,mBAAmB,IAAI,CAAC,IAAI,EAAE,CAC5D,CAAC;aACF;YAED,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;YACxC,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;gBACvB,MAAM,IAAI,KAAK,CAAC,YAAY,IAAI,mBAAmB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;aAChE;SACD;QAGD,IAAI,SAAS,GAAG,CAAC,CAAC;QAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE;YACjC,IACC,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;gBACrB,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC;gBACtB,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,EACpB;gBACD,SAAS;aACT;YACD,SAAS,EAAE,CAAC;SACZ;QAGD,IAAI,SAAS,KAAK,SAAS,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,YAAY,SAAS,qBAAqB,SAAS,EAAE,CAAC,CAAC;SACvE;IACF,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/dist/tests/utils.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/tests/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/tests/utils.ts"],"names":[],"mappings":"AAcA,OAAO,EACN,KAAK,iBAAiB,EAGtB,MAAM,gBAAgB,CAAC;AAIxB,wBAAiB,MAAM,CACtB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;IACT,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB,GACC,SAAS,CAAC,MAAM,CAAC,CAcnB;AAGD,eAAO,MAAM,IAAI,SAAU,MAAM,QAAQ,MAAM,YAiC9C,CAAC;AAEF,eAAO,MAAM,YAAY,QAAS,MAAM;;;;;;;CAOvC,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAS,MAAM;;;;;;;;;;;;;;;;CAK3C,CAAC;AAEF,eAAO,MAAM,YAAY,SAAU,MAAM,QAAQ,MAAM,YAItD,CAAC;AAEF,eAAO,MAAM,UAAU,UACf,iBAAiB,UAChB,iBAAiB,YAoBzB,CAAC;AAEF,eAAO,MAAM,iBAAiB,YAe7B,CAAC;AAEF,eAAO,MAAM,cAAc,YAS1B,CAAC"}
|
package/dist/tests/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { CaptchasContainerSchema, DataSchema, } from "@prosopo/types";
|
|
3
|
+
import { at } from "@prosopo/util";
|
|
4
4
|
export function* fsWalk(pth, options) {
|
|
5
5
|
const isDir = fs.existsSync(pth) && fs.statSync(pth).isDirectory();
|
|
6
6
|
let subpaths = isDir ? fs.readdirSync(pth) : [];
|
|
@@ -45,7 +45,7 @@ export const fsEq = (pth1, pth2) => {
|
|
|
45
45
|
};
|
|
46
46
|
export const readDataJson = (pth) => {
|
|
47
47
|
let content = fs.readFileSync(pth).toString();
|
|
48
|
-
content = content.replaceAll(
|
|
48
|
+
content = content.replaceAll("${repo}", `${__dirname}/../../../..`);
|
|
49
49
|
const dataJson = JSON.parse(content.toString());
|
|
50
50
|
const data = DataSchema.parse(dataJson);
|
|
51
51
|
return data;
|
|
@@ -80,22 +80,22 @@ export const captchasEq = (first, second) => {
|
|
|
80
80
|
return true;
|
|
81
81
|
};
|
|
82
82
|
export const substituteRepoDir = () => {
|
|
83
|
-
for (const pth of fsWalk(__dirname
|
|
84
|
-
if (!pth.endsWith(
|
|
83
|
+
for (const pth of fsWalk(`${__dirname}/data`)) {
|
|
84
|
+
if (!pth.endsWith(".json")) {
|
|
85
85
|
continue;
|
|
86
86
|
}
|
|
87
|
-
fs.copyFileSync(pth, pth
|
|
87
|
+
fs.copyFileSync(pth, `${pth}.bak`);
|
|
88
88
|
let content = fs.readFileSync(pth).toString();
|
|
89
|
-
content = content.replaceAll(
|
|
89
|
+
content = content.replaceAll("${repo}", `${__dirname}/../../../..`);
|
|
90
90
|
fs.writeFileSync(pth, content);
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
export const restoreRepoDir = () => {
|
|
94
|
-
for (const pth of fsWalk(__dirname
|
|
95
|
-
if (!pth.endsWith(
|
|
94
|
+
for (const pth of fsWalk(`${__dirname}/data`)) {
|
|
95
|
+
if (!pth.endsWith(".json")) {
|
|
96
96
|
continue;
|
|
97
97
|
}
|
|
98
|
-
fs.renameSync(pth
|
|
98
|
+
fs.renameSync(`${pth}.bak`, pth);
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
//# sourceMappingURL=utils.js.map
|
package/dist/tests/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/tests/utils.ts"],"names":[],"mappings":"
|
|
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,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QAC3C,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;YACpD,OAAO,KAAK,CAAC;SACb;KACD;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;QAC9C,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAC3B,SAAS;SACT;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;KAC/B;AACF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IAElC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,GAAG,SAAS,OAAO,CAAC,EAAE;QAC9C,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAC3B,SAAS;SACT;QAED,EAAE,CAAC,UAAU,CAAC,GAAG,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC;KACjC;AACF,CAAC,CAAC"}
|
package/dist/utils/input.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/utils/input.ts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/utils/input.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
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
5
|
export const InputArgsSchema = z.object({
|
|
6
6
|
input: z.string(),
|
|
7
7
|
});
|
|
8
8
|
export class InputCliCommand extends CliCommand {
|
|
9
9
|
getArgSchema() {
|
|
10
|
-
throw new ProsopoError(
|
|
10
|
+
throw new ProsopoError("DEVELOPER.METHOD_NOT_IMPLEMENTED");
|
|
11
11
|
}
|
|
12
12
|
getDescription() {
|
|
13
|
-
throw new ProsopoError(
|
|
13
|
+
throw new ProsopoError("DEVELOPER.METHOD_NOT_IMPLEMENTED");
|
|
14
14
|
}
|
|
15
15
|
getOptions() {
|
|
16
16
|
return {
|
|
17
17
|
input: {
|
|
18
18
|
string: true,
|
|
19
|
-
alias:
|
|
19
|
+
alias: "in",
|
|
20
20
|
demand: true,
|
|
21
|
-
description:
|
|
21
|
+
description: "The input path",
|
|
22
22
|
},
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
async _check(args) {
|
|
26
|
-
this.logger.debug(
|
|
26
|
+
this.logger.debug("input _check");
|
|
27
27
|
await super._check(args);
|
|
28
28
|
if (!fs.existsSync(args.input)) {
|
|
29
29
|
throw new ProsopoDatasetError(new Error(`input path does not exist: ${args.input}`), {
|
|
30
|
-
translationKey:
|
|
30
|
+
translationKey: "FS.FILE_NOT_FOUND",
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
}
|
package/dist/utils/input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/utils/input.ts"],"names":[],"mappings":"
|
|
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;YAC/B,MAAM,IAAI,mBAAmB,CAC5B,IAAI,KAAK,CAAC,8BAA8B,IAAI,CAAC,KAAK,EAAE,CAAC,EACrD;gBACC,cAAc,EAAE,mBAAmB;aACnC,CACD,CAAC;SACF;IACF,CAAC;CACD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as z from
|
|
2
|
-
import { CliCommandComposite } from
|
|
1
|
+
import type * as z from "zod";
|
|
2
|
+
import { CliCommandComposite } from "../cli/cliCommandComposite.js";
|
|
3
3
|
export declare const InputOutputArgsSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
4
4
|
input: z.ZodString;
|
|
5
5
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputOutput.d.ts","sourceRoot":"","sources":["../../src/utils/inputOutput.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,CAAC,MAAM,KAAK,
|
|
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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CliCommandComposite } from
|
|
2
|
-
import { InputArgsSchema, InputCliCommand } from
|
|
3
|
-
import { OutputArgsSchema, OutputCliCommand } from
|
|
1
|
+
import { CliCommandComposite } from "../cli/cliCommandComposite.js";
|
|
2
|
+
import { InputArgsSchema, InputCliCommand } from "./input.js";
|
|
3
|
+
import { OutputArgsSchema, OutputCliCommand } from "./output.js";
|
|
4
4
|
export const InputOutputArgsSchema = InputArgsSchema.merge(OutputArgsSchema);
|
|
5
5
|
export class InputOutputCliCommand extends CliCommandComposite {
|
|
6
6
|
constructor() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputOutput.js","sourceRoot":"","sources":["../../src/utils/inputOutput.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,
|
|
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"}
|
package/dist/utils/output.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="yargs" />
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { type infer as zInfer } from "zod";
|
|
3
|
+
import { CliCommand } from "../cli/cliCommand.js";
|
|
4
4
|
export declare const OutputArgsSchema: import("zod").ZodObject<{
|
|
5
5
|
output: import("zod").ZodString;
|
|
6
6
|
overwrite: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":";
|
|
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"}
|
package/dist/utils/output.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var _OutputCliCommand_outputExists;
|
|
2
2
|
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
|
-
import
|
|
4
|
-
import { ProsopoEnvError, ProsopoError } from
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
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
8
|
export const OutputArgsSchema = object({
|
|
9
9
|
output: string(),
|
|
10
10
|
overwrite: boolean().optional(),
|
|
@@ -18,42 +18,42 @@ export class OutputCliCommand extends CliCommand {
|
|
|
18
18
|
return __classPrivateFieldGet(this, _OutputCliCommand_outputExists, "f");
|
|
19
19
|
}
|
|
20
20
|
getArgSchema() {
|
|
21
|
-
throw new ProsopoError(
|
|
21
|
+
throw new ProsopoError("DEVELOPER.METHOD_NOT_IMPLEMENTED");
|
|
22
22
|
}
|
|
23
23
|
getDescription() {
|
|
24
|
-
throw new ProsopoError(
|
|
24
|
+
throw new ProsopoError("DEVELOPER.METHOD_NOT_IMPLEMENTED");
|
|
25
25
|
}
|
|
26
26
|
getOptions() {
|
|
27
27
|
return lodash().merge(super.getOptions(), {
|
|
28
28
|
output: {
|
|
29
|
-
alias:
|
|
29
|
+
alias: "out",
|
|
30
30
|
string: true,
|
|
31
31
|
demand: true,
|
|
32
|
-
description:
|
|
32
|
+
description: "The output path",
|
|
33
33
|
},
|
|
34
34
|
overwrite: {
|
|
35
35
|
boolean: true,
|
|
36
|
-
description:
|
|
36
|
+
description: "Overwrite files in the output path if they already exist",
|
|
37
37
|
},
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
async _check(args) {
|
|
41
|
-
this.logger.debug(
|
|
41
|
+
this.logger.debug("Output _check");
|
|
42
42
|
await super._check(args);
|
|
43
43
|
__classPrivateFieldSet(this, _OutputCliCommand_outputExists, fs.existsSync(args.output), "f");
|
|
44
44
|
if (this.outputExists()) {
|
|
45
45
|
if (!args.overwrite) {
|
|
46
46
|
throw new ProsopoEnvError(new Error(`output path already exists: ${args.output}`), {
|
|
47
|
-
translationKey:
|
|
47
|
+
translationKey: "FS.FILE_ALREADY_EXISTS",
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
async _run(args) {
|
|
53
|
-
this.logger.debug(
|
|
53
|
+
this.logger.debug("Output run");
|
|
54
54
|
await super._run(args);
|
|
55
55
|
if (args.overwrite && this.outputExists()) {
|
|
56
|
-
this.logger.info(
|
|
56
|
+
this.logger.info("cleaning output directory...");
|
|
57
57
|
fs.rmSync(args.output, { recursive: true });
|
|
58
58
|
}
|
|
59
59
|
}
|
package/dist/utils/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":";;
|
|
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,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;IACtC,MAAM,EAAE,MAAM,EAAE;IAChB,SAAS,EAAE,OAAO,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAC;AAIH,MAAM,OAAO,gBAEX,SAAQ,UAAa;IAFvB;;QAGC,yCAAgB,KAAK,EAAC;IAwDvB,CAAC;IAtDO,YAAY;QAClB,OAAO,uBAAA,IAAI,sCAAc,CAAC;IAC3B,CAAC;IAEe,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,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE;YACzC,MAAM,EAAE;gBACP,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,IAAI;gBACZ,MAAM,EAAE,IAAI;gBACZ,WAAW,EAAE,iBAAiB;aAC9B;YACD,SAAS,EAAE;gBACV,OAAO,EAAE,IAAI;gBACb,WAAW,EAAE,0DAA0D;aACvE;SACD,CAAC,CAAC;I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