@prosopo/datasets-fs 0.2.13 → 0.2.15
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/cli/cli.js +0 -1
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/cliCommand.d.ts +1 -1
- package/dist/cli/cliCommand.d.ts.map +1 -1
- package/dist/cli/cliCommand.js +0 -8
- package/dist/cli/cliCommand.js.map +1 -1
- package/dist/cli/cliCommandComposite.d.ts +1 -1
- package/dist/cli/cliCommandComposite.d.ts.map +1 -1
- package/dist/cli/cliCommandComposite.js +0 -2
- package/dist/cli/cliCommandComposite.js.map +1 -1
- package/dist/cli.js +2 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/flatten.d.ts +1 -1
- package/dist/commands/flatten.d.ts.map +1 -1
- package/dist/commands/flatten.js +4 -14
- package/dist/commands/flatten.js.map +1 -1
- package/dist/commands/generate.d.ts +1 -1
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +2 -13
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/generateV1.d.ts +1 -1
- package/dist/commands/generateV1.d.ts.map +1 -1
- package/dist/commands/generateV1.js +7 -28
- package/dist/commands/generateV1.js.map +1 -1
- package/dist/commands/generateV2.d.ts +1 -1
- package/dist/commands/generateV2.d.ts.map +1 -1
- package/dist/commands/generateV2.js +13 -31
- package/dist/commands/generateV2.js.map +1 -1
- package/dist/commands/get.d.ts +1 -1
- package/dist/commands/get.d.ts.map +1 -1
- package/dist/commands/get.js +2 -4
- package/dist/commands/get.js.map +1 -1
- package/dist/commands/labels.d.ts +1 -1
- package/dist/commands/labels.d.ts.map +1 -1
- package/dist/commands/labels.js +1 -1
- package/dist/commands/labels.js.map +1 -1
- package/dist/commands/relocate.d.ts +1 -1
- package/dist/commands/relocate.d.ts.map +1 -1
- package/dist/commands/relocate.js +3 -5
- package/dist/commands/relocate.js.map +1 -1
- package/dist/commands/resize.d.ts +1 -1
- package/dist/commands/resize.d.ts.map +1 -1
- package/dist/commands/resize.js +5 -17
- package/dist/commands/resize.js.map +1 -1
- package/dist/dummy.js +0 -1
- package/dist/dummy.js.map +1 -1
- package/dist/index.js +0 -13
- package/dist/index.js.map +1 -1
- 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/mocked.test.js +1 -30
- package/dist/tests/mocked.test.js.map +1 -1
- package/dist/tests/utils.js +0 -19
- package/dist/tests/utils.js.map +1 -1
- package/dist/utils/input.d.ts +1 -1
- package/dist/utils/input.d.ts.map +1 -1
- package/dist/utils/input.js +1 -2
- package/dist/utils/input.js.map +1 -1
- package/dist/utils/inputOutput.d.ts +1 -1
- package/dist/utils/inputOutput.d.ts.map +1 -1
- package/dist/utils/inputOutput.js.map +1 -1
- package/dist/utils/output.d.ts +6 -6
- package/dist/utils/output.d.ts.map +1 -1
- package/dist/utils/output.js +5 -8
- package/dist/utils/output.js.map +1 -1
- package/package.json +4 -5
- package/src/cli/cliCommand.ts +1 -1
- package/src/cli/cliCommandComposite.ts +1 -1
- package/src/cli.ts +2 -2
- package/src/commands/flatten.ts +4 -3
- package/src/commands/generate.ts +2 -2
- package/src/commands/generateV1.ts +4 -3
- package/src/commands/generateV2.ts +4 -3
- package/src/commands/get.ts +2 -2
- package/src/commands/labels.ts +2 -2
- package/src/commands/relocate.ts +3 -2
- package/src/commands/resize.ts +3 -3
- package/src/tests/lodash.test.ts +40 -0
- package/src/tests/mocked.test.ts +1 -1
- package/src/utils/input.ts +1 -1
- package/src/utils/inputOutput.ts +1 -1
- package/src/utils/output.ts +6 -6
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -8,21 +8,18 @@ import { Resize } from '../commands/resize.js';
|
|
|
8
8
|
import { afterAll, beforeAll, describe, test } from 'vitest';
|
|
9
9
|
import { blake2b } from '@noble/hashes/blake2b';
|
|
10
10
|
import { captchasEqFs, fsEq, fsWalk, restoreRepoDir, substituteRepoDir } from './utils.js';
|
|
11
|
-
import { u8aToHex } from '@polkadot/util';
|
|
11
|
+
import { u8aToHex } from '@polkadot/util/u8a';
|
|
12
12
|
import fs from 'fs';
|
|
13
13
|
import sharp from 'sharp';
|
|
14
14
|
describe('dataset commands', () => {
|
|
15
15
|
beforeAll(() => {
|
|
16
|
-
// substitute the repo path in the data for tests
|
|
17
16
|
substituteRepoDir();
|
|
18
|
-
// remove previous test results
|
|
19
17
|
if (fs.existsSync(`${__dirname}/test_results`)) {
|
|
20
18
|
fs.rmdirSync(`${__dirname}/test_results`, { recursive: true });
|
|
21
19
|
}
|
|
22
20
|
fs.mkdirSync(`${__dirname}/test_results`, { recursive: true });
|
|
23
21
|
});
|
|
24
22
|
afterAll(() => {
|
|
25
|
-
// restore repo path back to placeholder
|
|
26
23
|
restoreRepoDir();
|
|
27
24
|
});
|
|
28
25
|
test('labels', async () => {
|
|
@@ -34,9 +31,7 @@ describe('dataset commands', () => {
|
|
|
34
31
|
input,
|
|
35
32
|
output,
|
|
36
33
|
});
|
|
37
|
-
// make sure the results are the same as the expected results
|
|
38
34
|
fsEq(output, `${__dirname}/data/flat_resized/labels.json`);
|
|
39
|
-
// make sure there's one class per hierarchical directory
|
|
40
35
|
const content = fs.readFileSync(output).toString();
|
|
41
36
|
const labelsJson = JSON.parse(content.toString());
|
|
42
37
|
const foundLabels = labelsJson.labels;
|
|
@@ -67,29 +62,24 @@ describe('dataset commands', () => {
|
|
|
67
62
|
maxLabelled,
|
|
68
63
|
allowDuplicates: true,
|
|
69
64
|
});
|
|
70
|
-
// make sure the results are the same as the expected results
|
|
71
65
|
if (!captchasEqFs(output, `${__dirname}/data/flat_resized/captchas_v2.json`)) {
|
|
72
66
|
throw new Error(`captchas not equal`);
|
|
73
67
|
}
|
|
74
|
-
// test that the solutions array and unlabelled array per captcha never conflict
|
|
75
68
|
const content = fs.readFileSync(output).toString();
|
|
76
69
|
const captchasJson = JSON.parse(content.toString());
|
|
77
70
|
const captchas = CaptchasContainerSchema.parse(captchasJson);
|
|
78
71
|
for (const captcha of captchas.captchas) {
|
|
79
72
|
const solutions = captcha.solution;
|
|
80
73
|
const unlabelled = captcha.unlabelled;
|
|
81
|
-
// both should not be undefined
|
|
82
74
|
if (solutions === undefined || unlabelled === undefined) {
|
|
83
75
|
console.log(captcha);
|
|
84
76
|
throw new Error(`solutions or unlabelled array is undefined`);
|
|
85
77
|
}
|
|
86
78
|
for (const solution of solutions) {
|
|
87
|
-
// solution should not be in unlabelled
|
|
88
79
|
if (unlabelled.includes(solution)) {
|
|
89
80
|
throw new Error(`solution ${solution} is also in unlabelled array`);
|
|
90
81
|
}
|
|
91
82
|
}
|
|
92
|
-
// check the correct, incorrect, labelled and unlabelled distribution
|
|
93
83
|
const nCorrect = solutions.length;
|
|
94
84
|
const nUnlabelled = unlabelled.length;
|
|
95
85
|
const nIncorrect = 9 - nCorrect - nUnlabelled;
|
|
@@ -128,7 +118,6 @@ describe('dataset commands', () => {
|
|
|
128
118
|
maxCorrect: 6,
|
|
129
119
|
allowDuplicates: true,
|
|
130
120
|
});
|
|
131
|
-
// make sure the results are the same as the expected results
|
|
132
121
|
if (!captchasEqFs(output, `${__dirname}/data/flat_resized/captchas_v1.json`)) {
|
|
133
122
|
throw new Error(`captchas not equal`);
|
|
134
123
|
}
|
|
@@ -145,12 +134,9 @@ describe('dataset commands', () => {
|
|
|
145
134
|
square: true,
|
|
146
135
|
size: 128,
|
|
147
136
|
});
|
|
148
|
-
// make sure the results are the same as the expected results
|
|
149
137
|
const expected = `${__dirname}/data/flat_resized`;
|
|
150
138
|
fsEq(output, expected);
|
|
151
|
-
// check data in resized dir is all 128x128
|
|
152
139
|
for (const pth of fsWalk(output)) {
|
|
153
|
-
// if pth is not img, ignore
|
|
154
140
|
if (!pth.endsWith('.jpg') && !pth.endsWith('.jpeg') && !pth.endsWith('.png')) {
|
|
155
141
|
continue;
|
|
156
142
|
}
|
|
@@ -173,7 +159,6 @@ describe('dataset commands', () => {
|
|
|
173
159
|
to: 'newwebsite.com',
|
|
174
160
|
from: '${repo}',
|
|
175
161
|
});
|
|
176
|
-
// make sure the results are the same as the expected results
|
|
177
162
|
const expected = `${__dirname}/data/flat_resized/relocated_data.json`;
|
|
178
163
|
fsEq(output, expected);
|
|
179
164
|
});
|
|
@@ -187,28 +172,21 @@ describe('dataset commands', () => {
|
|
|
187
172
|
output,
|
|
188
173
|
overwrite: true,
|
|
189
174
|
});
|
|
190
|
-
// make sure the results are the same as the expected results
|
|
191
175
|
const expected = `${__dirname}/data/flat`;
|
|
192
176
|
fsEq(output, expected);
|
|
193
|
-
// read data json
|
|
194
177
|
const content = fs.readFileSync(`${output}/data.json`).toString();
|
|
195
178
|
const dataJson = JSON.parse(content.toString());
|
|
196
179
|
const data = DataSchema.parse(dataJson);
|
|
197
|
-
// check each image from the hierarchical data is in the flat data
|
|
198
180
|
let hierCount = 0;
|
|
199
181
|
for (const pth of fsWalk(input)) {
|
|
200
|
-
// if pth is not img, ignore
|
|
201
182
|
if (!pth.endsWith('.jpg') && !pth.endsWith('.jpeg') && !pth.endsWith('.png')) {
|
|
202
183
|
continue;
|
|
203
184
|
}
|
|
204
185
|
hierCount++;
|
|
205
|
-
// get the category
|
|
206
186
|
const category = pth.split('/').slice(-2)[0];
|
|
207
187
|
const content = fs.readFileSync(pth);
|
|
208
|
-
// check the image is in the flat data
|
|
209
188
|
let name = '';
|
|
210
189
|
for (const pth2 of fsWalk(output)) {
|
|
211
|
-
// if pth2 is not file, ignore
|
|
212
190
|
if (!fs.statSync(pth2).isFile()) {
|
|
213
191
|
continue;
|
|
214
192
|
}
|
|
@@ -225,7 +203,6 @@ describe('dataset commands', () => {
|
|
|
225
203
|
if (!name) {
|
|
226
204
|
throw new Error(`unable to find image ${pth} in output`);
|
|
227
205
|
}
|
|
228
|
-
// check the image is in the data json
|
|
229
206
|
const item = data.items.find((item) => {
|
|
230
207
|
const name2 = item.data.split('/').slice(-1)[0];
|
|
231
208
|
if (name2 !== name) {
|
|
@@ -236,25 +213,20 @@ describe('dataset commands', () => {
|
|
|
236
213
|
if (item === undefined) {
|
|
237
214
|
throw new Error(`unable to find image ${pth} in data.json`);
|
|
238
215
|
}
|
|
239
|
-
// correct name, so check category
|
|
240
216
|
if (item.label != category) {
|
|
241
217
|
throw new Error(`expected ${category} but found ${item.label}`);
|
|
242
218
|
}
|
|
243
|
-
// type should be image
|
|
244
219
|
if (item.type !== 'image') {
|
|
245
220
|
throw new Error(`expected image type but found ${item.type}`);
|
|
246
221
|
}
|
|
247
|
-
// file name should be the hash
|
|
248
222
|
if (item.hash !== name.split('.')[0]) {
|
|
249
223
|
throw new Error(`expected ${name.split('.')[0]} hash but found ${item.hash}`);
|
|
250
224
|
}
|
|
251
|
-
// hash should be the hash of the image content
|
|
252
225
|
const hash = u8aToHex(blake2b(content));
|
|
253
226
|
if (item.hash !== hash) {
|
|
254
227
|
throw new Error(`expected ${hash} hash but found ${item.hash}`);
|
|
255
228
|
}
|
|
256
229
|
}
|
|
257
|
-
// count the number of images in the flat data
|
|
258
230
|
let flatCount = 0;
|
|
259
231
|
for (const pth of fsWalk(output)) {
|
|
260
232
|
if (!pth.endsWith('.jpg') && !pth.endsWith('.jpeg') && !pth.endsWith('.png')) {
|
|
@@ -262,7 +234,6 @@ describe('dataset commands', () => {
|
|
|
262
234
|
}
|
|
263
235
|
flatCount++;
|
|
264
236
|
}
|
|
265
|
-
// check same number of images in flat data
|
|
266
237
|
if (hierCount !== flatCount) {
|
|
267
238
|
throw new Error(`expected ${hierCount} images but found ${flatCount}`);
|
|
268
239
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mocked.test.js","sourceRoot":"","sources":["../../src/tests/mocked.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,C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osopo/util';
|
|
3
3
|
import fs from 'fs';
|
|
4
|
-
// recursively list files in a directory
|
|
5
4
|
export function* fsWalk(pth, options) {
|
|
6
|
-
// if path is a directory, recurse
|
|
7
5
|
const isDir = fs.existsSync(pth) && fs.statSync(pth).isDirectory();
|
|
8
6
|
let subpaths = isDir ? fs.readdirSync(pth) : [];
|
|
9
7
|
subpaths = subpaths.map((f) => `${pth}/${f}`);
|
|
@@ -17,33 +15,26 @@ export function* fsWalk(pth, options) {
|
|
|
17
15
|
yield pth;
|
|
18
16
|
}
|
|
19
17
|
}
|
|
20
|
-
// test whether two files/dirs are equal, recursively comparing contents as required
|
|
21
18
|
export const fsEq = (pth1, pth2) => {
|
|
22
19
|
const it1 = fsWalk(pth1);
|
|
23
20
|
const it2 = fsWalk(pth2);
|
|
24
|
-
// drop the root path
|
|
25
21
|
const files1 = [...it1].map((f) => f.slice(pth1.length));
|
|
26
22
|
const files2 = [...it2].map((f) => f.slice(pth2.length));
|
|
27
23
|
if (files1.length !== files2.length) {
|
|
28
24
|
return false;
|
|
29
25
|
}
|
|
30
|
-
// sort files so in same order
|
|
31
26
|
files1.sort();
|
|
32
27
|
files2.sort();
|
|
33
28
|
if (!files1.every((f, i) => f === files2[i])) {
|
|
34
|
-
// the two lists of files are not the same
|
|
35
29
|
return false;
|
|
36
30
|
}
|
|
37
|
-
// compare contents of each file
|
|
38
31
|
for (let i = 0; i < files1.length; i++) {
|
|
39
32
|
const file1 = pth1 + at(files1, i);
|
|
40
33
|
const file2 = pth2 + at(files2, i);
|
|
41
34
|
const stat1 = fs.statSync(file1);
|
|
42
35
|
if (stat1.isDirectory()) {
|
|
43
|
-
// already checked above
|
|
44
36
|
continue;
|
|
45
37
|
}
|
|
46
|
-
// files, so compare contents
|
|
47
38
|
const content1 = fs.readFileSync(file1);
|
|
48
39
|
const content2 = fs.readFileSync(file2);
|
|
49
40
|
if (!content1.equals(content2)) {
|
|
@@ -54,7 +45,6 @@ export const fsEq = (pth1, pth2) => {
|
|
|
54
45
|
};
|
|
55
46
|
export const readDataJson = (pth) => {
|
|
56
47
|
let content = fs.readFileSync(pth).toString();
|
|
57
|
-
// TODO use getPaths() here to find the repo dir
|
|
58
48
|
content = content.replaceAll('${repo}', __dirname + '/../../../..');
|
|
59
49
|
const dataJson = JSON.parse(content.toString());
|
|
60
50
|
const data = DataSchema.parse(dataJson);
|
|
@@ -78,11 +68,9 @@ export const captchasEq = (first, second) => {
|
|
|
78
68
|
for (let i = 0; i < first.captchas.length; i++) {
|
|
79
69
|
const captcha1 = at(first.captchas, i);
|
|
80
70
|
const captcha2 = at(second.captchas, i);
|
|
81
|
-
// salts should not be the same as generated on the fly and not stored!
|
|
82
71
|
if (captcha1.salt === captcha2.salt) {
|
|
83
72
|
return false;
|
|
84
73
|
}
|
|
85
|
-
// everything else should be the same
|
|
86
74
|
const { salt: salt1, ...rest1 } = captcha1;
|
|
87
75
|
const { salt: salt2, ...rest2 } = captcha2;
|
|
88
76
|
if (JSON.stringify(rest1) !== JSON.stringify(rest2)) {
|
|
@@ -92,28 +80,21 @@ export const captchasEq = (first, second) => {
|
|
|
92
80
|
return true;
|
|
93
81
|
};
|
|
94
82
|
export const substituteRepoDir = () => {
|
|
95
|
-
// read all json files in the test data dir
|
|
96
83
|
for (const pth of fsWalk(__dirname + '/data')) {
|
|
97
84
|
if (!pth.endsWith('.json')) {
|
|
98
85
|
continue;
|
|
99
86
|
}
|
|
100
|
-
// make a backup of each file
|
|
101
87
|
fs.copyFileSync(pth, pth + '.bak');
|
|
102
|
-
// replace ${repo} with the path to the repo
|
|
103
88
|
let content = fs.readFileSync(pth).toString();
|
|
104
|
-
// TODO use getPaths() here to find the repo dir
|
|
105
89
|
content = content.replaceAll('${repo}', __dirname + '/../../../..');
|
|
106
|
-
// rewrite the file
|
|
107
90
|
fs.writeFileSync(pth, content);
|
|
108
91
|
}
|
|
109
92
|
};
|
|
110
93
|
export const restoreRepoDir = () => {
|
|
111
|
-
// read all json files in the test data dir
|
|
112
94
|
for (const pth of fsWalk(__dirname + '/data')) {
|
|
113
95
|
if (!pth.endsWith('.json')) {
|
|
114
96
|
continue;
|
|
115
97
|
}
|
|
116
|
-
// restore the backup of each file
|
|
117
98
|
fs.renameSync(pth + '.bak', pth);
|
|
118
99
|
}
|
|
119
100
|
};
|
package/dist/tests/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/tests/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,uBAAuB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACvF,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AAClC,OAAO,EAAE,MAAM,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/tests/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,uBAAuB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACvF,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AAClC,OAAO,EAAE,MAAM,IAAI,CAAA;AAGnB,MAAM,SAAS,CAAC,CAAC,MAAM,CACnB,GAAW,EACX,OAEC;IAGD,MAAM,KAAK,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAA;IAClE,IAAI,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAC/C,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,CAAA;IAC7C,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE;QACtB,MAAM,GAAG,CAAA;KACZ;IACD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC5B,KAA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;SACX;QAED,EAAE,CAAC,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAAC,CAAA;QAElC,IAAI,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAA;QAE7C,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,SAAS,EAAE,SAAS,GAAG,cAAc,CAAC,CAAA;QAEnE,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;KACjC;AACL,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IAE/B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,EAAE;QAC3C,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YACxB,SAAQ;SACX;QAED,EAAE,CAAC,UAAU,CAAC,GAAG,GAAG,MAAM,EAAE,GAAG,CAAC,CAAA;KACnC;AACL,CAAC,CAAA"}
|
package/dist/utils/input.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/utils/input.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/utils/input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAIjD,eAAO,MAAM,eAAe;;;;;;EAE1B,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAEvD,qBAAa,eAAe,CAAC,CAAC,SAAS,OAAO,eAAe,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAC;IAChE,YAAY,IAAI,CAAC;IAGjB,cAAc,IAAI,MAAM;IAGxB,UAAU;;;;;;;;IAWJ,MAAM,CAAC,IAAI,EAAE,SAAS;CAQ/C"}
|
package/dist/utils/input.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
1
2
|
import { CliCommand } from '../cli/cliCommand.js';
|
|
2
3
|
import { ProsopoEnvError } from '@prosopo/common';
|
|
3
|
-
import { z } from 'zod';
|
|
4
4
|
import fs from 'fs';
|
|
5
5
|
export const InputArgsSchema = z.object({
|
|
6
6
|
input: z.string(),
|
|
@@ -25,7 +25,6 @@ export class InputCliCommand extends CliCommand {
|
|
|
25
25
|
async _check(args) {
|
|
26
26
|
this.logger.debug('input _check');
|
|
27
27
|
await super._check(args);
|
|
28
|
-
// input must exist
|
|
29
28
|
if (!fs.existsSync(args.input)) {
|
|
30
29
|
throw new ProsopoEnvError(new Error(`input path does not exist: ${args.input}`), 'FS.FILE_NOT_FOUND');
|
|
31
30
|
}
|
package/dist/utils/input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/utils/input.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../src/utils/input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAA;AAIF,MAAM,OAAO,eAAkD,SAAQ,UAAa;IAChE,YAAY;QACxB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC9C,CAAC;IACe,cAAc;QAC1B,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC9C,CAAC;IACe,UAAU;QACtB,OAAO;YACH,KAAK,EAAE;gBACH,MAAM,EAAE,IAAI;gBACZ,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,IAAI;gBACZ,WAAW,EAAE,gBAAgB;aAChC;SACJ,CAAA;IACL,CAAC;IAEe,KAAK,CAAC,MAAM,CAAC,IAAe;QACxC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;QACjC,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAExB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YAC5B,MAAM,IAAI,eAAe,CAAC,IAAI,KAAK,CAAC,8BAA8B,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,mBAAmB,CAAC,CAAA;SACxG;IACL,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputOutput.d.ts","sourceRoot":"","sources":["../../src/utils/inputOutput.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"inputOutput.d.ts","sourceRoot":"","sources":["../../src/utils/inputOutput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAInE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;EAA0C,CAAA;AAE5E,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAEnE,8BAAsB,qBAAqB,CAAC,CAAC,SAAS,OAAO,qBAAqB,CAAE,SAAQ,mBAAmB,CAAC,CAAC,CAAC;;CAIjH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputOutput.js","sourceRoot":"","sources":["../../src/utils/inputOutput.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"inputOutput.js","sourceRoot":"","sources":["../../src/utils/inputOutput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC7D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEhE,MAAM,CAAC,MAAM,qBAAqB,GAAG,eAAe,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;AAI5E,MAAM,OAAgB,qBAA8D,SAAQ,mBAAsB;IAC9G;QACI,KAAK,CAAC,CAAC,IAAI,eAAe,EAAK,EAAE,IAAI,gBAAgB,EAAK,CAAC,CAAC,CAAA;IAChE,CAAC;CACJ"}
|
package/dist/utils/output.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/// <reference types="yargs" />
|
|
2
2
|
import { CliCommand } from '../cli/cliCommand.js';
|
|
3
|
-
import {
|
|
4
|
-
export declare const OutputArgsSchema:
|
|
5
|
-
output:
|
|
6
|
-
overwrite:
|
|
7
|
-
}, "strip",
|
|
3
|
+
import { infer as zInfer } from 'zod';
|
|
4
|
+
export declare const OutputArgsSchema: import("zod").ZodObject<{
|
|
5
|
+
output: import("zod").ZodString;
|
|
6
|
+
overwrite: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
7
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
8
8
|
output: string;
|
|
9
9
|
overwrite?: boolean | undefined;
|
|
10
10
|
}, {
|
|
11
11
|
output: string;
|
|
12
12
|
overwrite?: boolean | undefined;
|
|
13
13
|
}>;
|
|
14
|
-
export type OutputArgs =
|
|
14
|
+
export type OutputArgs = zInfer<typeof OutputArgsSchema>;
|
|
15
15
|
export declare class OutputCliCommand<T extends typeof OutputArgsSchema> extends CliCommand<T> {
|
|
16
16
|
#private;
|
|
17
17
|
outputExists(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEjD,OAAO,EAA2B,KAAK,IAAI,MAAM,EAAE,MAAM,KAAK,CAAA;AAI9D,eAAO,MAAM,gBAAgB;;;;;;;;;EAG3B,CAAA;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAExD,qBAAa,gBAAgB,CAAC,CAAC,SAAS,OAAO,gBAAgB,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAC;;IAG3E,YAAY;IAIH,YAAY,IAAI,CAAC;IAGjB,cAAc,IAAI,MAAM;IAGxB,UAAU;;;;;;;;;;;;;;IAeJ,MAAM,CAAC,IAAI,EAAE,UAAU;IAkBvB,IAAI,CAAC,IAAI,EAAE,UAAU;CAS9C"}
|
package/dist/utils/output.js
CHANGED
|
@@ -2,12 +2,12 @@ var _OutputCliCommand_outputExists;
|
|
|
2
2
|
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
3
|
import { CliCommand } from '../cli/cliCommand.js';
|
|
4
4
|
import { ProsopoEnvError } from '@prosopo/common';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { boolean, object, string } from 'zod';
|
|
6
|
+
import { lodash } from '@prosopo/util/lodash';
|
|
7
7
|
import fs from 'fs';
|
|
8
|
-
export const OutputArgsSchema =
|
|
9
|
-
output:
|
|
10
|
-
overwrite:
|
|
8
|
+
export const OutputArgsSchema = object({
|
|
9
|
+
output: string(),
|
|
10
|
+
overwrite: boolean().optional(),
|
|
11
11
|
});
|
|
12
12
|
export class OutputCliCommand extends CliCommand {
|
|
13
13
|
constructor() {
|
|
@@ -40,9 +40,7 @@ export class OutputCliCommand extends CliCommand {
|
|
|
40
40
|
async _check(args) {
|
|
41
41
|
this.logger.debug('Output _check');
|
|
42
42
|
await super._check(args);
|
|
43
|
-
// record whether output already exists
|
|
44
43
|
__classPrivateFieldSet(this, _OutputCliCommand_outputExists, fs.existsSync(args.output), "f");
|
|
45
|
-
// output must not exist, unless overwrite is true
|
|
46
44
|
if (this.outputExists()) {
|
|
47
45
|
if (!args.overwrite) {
|
|
48
46
|
throw new ProsopoEnvError(new Error(`output path already exists: ${args.output}`), 'FS.FILE_ALREADY_EXISTS');
|
|
@@ -53,7 +51,6 @@ export class OutputCliCommand extends CliCommand {
|
|
|
53
51
|
this.logger.debug('Output run');
|
|
54
52
|
await super._run(args);
|
|
55
53
|
if (args.overwrite && this.outputExists()) {
|
|
56
|
-
// if overwrite is true, delete the output directory
|
|
57
54
|
this.logger.info('cleaning output directory...');
|
|
58
55
|
fs.rmSync(args.output, { recursive: true });
|
|
59
56
|
}
|
package/dist/utils/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAmB,MAAM,KAAK,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,MAAM,CAAC,MAAM,gBA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AAgB;QACvC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;QAC/B,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACtB,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,YAAY,EAAE,EAAE;YAEvC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAA;YAChD,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;SAC9C;IACL,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/datasets-fs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.15",
|
|
4
4
|
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"private": false,
|
|
@@ -28,12 +28,11 @@
|
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@polkadot/util": "^12.3.2",
|
|
31
|
-
"@prosopo/common": "0.2.
|
|
32
|
-
"@prosopo/types": "0.2.
|
|
33
|
-
"@prosopo/util": "0.2.
|
|
31
|
+
"@prosopo/common": "0.2.15",
|
|
32
|
+
"@prosopo/types": "0.2.15",
|
|
33
|
+
"@prosopo/util": "0.2.15",
|
|
34
34
|
"bcrypt": "^5.1.0",
|
|
35
35
|
"cli-progress": "^3.12.0",
|
|
36
|
-
"es-main": "^1.2.0",
|
|
37
36
|
"fs": "^0.0.1-security",
|
|
38
37
|
"lodash": "^4.17.21",
|
|
39
38
|
"noble-hashes": "^0.3.1",
|
package/src/cli/cliCommand.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { Loggable } from '@prosopo/common'
|
|
2
3
|
import { Options } from 'yargs'
|
|
3
4
|
import { kebabCase } from '@prosopo/util'
|
|
4
|
-
import { z } from 'zod'
|
|
5
5
|
|
|
6
6
|
export abstract class CliCommand<T extends z.ZodTypeAny> extends Loggable {
|
|
7
7
|
// get the options for the CLI
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { CliCommand, CliCommandAny } from './cliCommand.js'
|
|
2
3
|
import { Options } from 'yargs'
|
|
3
|
-
import { z } from 'zod'
|
|
4
4
|
|
|
5
5
|
export abstract class CliCommandComposite<T extends z.ZodTypeAny> extends CliCommand<T> {
|
|
6
6
|
#commands: CliCommandAny[] = []
|
package/src/cli.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { Get } from './commands/get.js'
|
|
|
7
7
|
import { Labels } from './commands/labels.js'
|
|
8
8
|
import { Relocate } from './commands/relocate.js'
|
|
9
9
|
import { Resize } from './commands/resize.js'
|
|
10
|
-
import
|
|
10
|
+
import { isMain } from '@prosopo/util'
|
|
11
11
|
|
|
12
12
|
const main = async () => {
|
|
13
13
|
const commands: CliCommandAny[] = [
|
|
@@ -25,7 +25,7 @@ const main = async () => {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
//if main process
|
|
28
|
-
if (
|
|
28
|
+
if (isMain(import.meta.url)) {
|
|
29
29
|
main()
|
|
30
30
|
.then(() => {
|
|
31
31
|
process.exit(0)
|
package/src/commands/flatten.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { CaptchaItemTypes, Data, DataSchema, LabelledItem } from '@prosopo/types'
|
|
2
3
|
import { InputOutputArgsSchema as InputOutputArgsSchema, InputOutputCliCommand } from '../utils/inputOutput.js'
|
|
3
|
-
import { at
|
|
4
|
+
import { at } from '@prosopo/util'
|
|
4
5
|
import { blake2b } from '@noble/hashes/blake2b'
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
6
|
+
import { lodash } from '@prosopo/util/lodash'
|
|
7
|
+
import { u8aToHex } from '@polkadot/util/u8a'
|
|
7
8
|
import cliProgress from 'cli-progress'
|
|
8
9
|
import fs from 'fs'
|
|
9
10
|
|
package/src/commands/generate.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { DataSchema, Item, LabelledDataSchema, LabelledItem, LabelsContainerSchema } from '@prosopo/types'
|
|
2
3
|
import { OutputArgsSchema, OutputCliCommand } from '../utils/output.js'
|
|
3
4
|
import { ProsopoEnvError } from '@prosopo/common'
|
|
4
|
-
import { lodash, setSeedGlobal } from '@prosopo/util'
|
|
5
|
-
import { z } from 'zod'
|
|
5
|
+
import { lodash, setSeedGlobal } from '@prosopo/util/lodash'
|
|
6
6
|
import fs from 'fs'
|
|
7
7
|
|
|
8
8
|
export const ArgsSchema = OutputArgsSchema.extend({
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { CaptchaTypes, CaptchaWithoutId, Captchas, CaptchasContainerSchema, Item, RawSolution } from '@prosopo/types'
|
|
2
3
|
import { Generate, ArgsSchema as GenerateArgsSchema } from './generate.js'
|
|
3
4
|
import { ProsopoEnvError } from '@prosopo/common'
|
|
4
|
-
import { at, get
|
|
5
|
-
import { blake2AsHex } from '@polkadot/util-crypto'
|
|
6
|
-
import {
|
|
5
|
+
import { at, get } from '@prosopo/util'
|
|
6
|
+
import { blake2AsHex } from '@polkadot/util-crypto/blake2'
|
|
7
|
+
import { lodash } from '@prosopo/util/lodash'
|
|
7
8
|
import bcrypt from 'bcrypt'
|
|
8
9
|
import cliProgress from 'cli-progress'
|
|
9
10
|
import fs from 'fs'
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { CaptchaTypes, CaptchaWithoutId, Captchas, CaptchasContainerSchema, Item, RawSolution } from '@prosopo/types'
|
|
2
3
|
import { Generate, ArgsSchema as GenerateArgsSchema } from './generate.js'
|
|
3
4
|
import { ProsopoEnvError } from '@prosopo/common'
|
|
4
|
-
import { at, get
|
|
5
|
-
import { blake2AsHex } from '@polkadot/util-crypto'
|
|
6
|
-
import {
|
|
5
|
+
import { at, get } from '@prosopo/util'
|
|
6
|
+
import { blake2AsHex } from '@polkadot/util-crypto/blake2'
|
|
7
|
+
import { lodash } from '@prosopo/util/lodash'
|
|
7
8
|
import bcrypt from 'bcrypt'
|
|
8
9
|
import cliProgress from 'cli-progress'
|
|
9
10
|
import fs from 'fs'
|
package/src/commands/get.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { InputArgsSchema, InputCliCommand } from '../utils/input.js'
|
|
2
3
|
import { get } from '@prosopo/util'
|
|
3
|
-
import { lodash } from '@prosopo/util'
|
|
4
|
-
import { z } from 'zod'
|
|
4
|
+
import { lodash } from '@prosopo/util/lodash'
|
|
5
5
|
import cliProgress from 'cli-progress'
|
|
6
6
|
import fs from 'fs'
|
|
7
7
|
|
package/src/commands/labels.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { InputOutputArgsSchema as InputOutputArgsSchema, InputOutputCliCommand } from '../utils/inputOutput.js'
|
|
2
3
|
import { LabelledDataSchema, LabelledItem } from '@prosopo/types'
|
|
3
4
|
import { ProsopoEnvError } from '@prosopo/common'
|
|
4
|
-
import { lodash } from '@prosopo/util'
|
|
5
|
-
import { z } from 'zod'
|
|
5
|
+
import { lodash } from '@prosopo/util/lodash'
|
|
6
6
|
import fs from 'fs'
|
|
7
7
|
|
|
8
8
|
export const ArgsSchema = InputOutputArgsSchema.extend({})
|
package/src/commands/relocate.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { InputOutputArgsSchema as InputOutputArgsSchema, InputOutputCliCommand } from '../utils/inputOutput.js'
|
|
2
|
-
import { get
|
|
3
|
-
import {
|
|
3
|
+
import { get } from '@prosopo/util'
|
|
4
|
+
import { lodash } from '@prosopo/util/lodash'
|
|
4
5
|
import fs from 'fs'
|
|
5
6
|
|
|
6
7
|
export const ArgsSchema = InputOutputArgsSchema.extend({
|
package/src/commands/resize.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import * as z from 'zod'
|
|
1
2
|
import { Data, DataSchema, Item } from '@prosopo/types'
|
|
2
3
|
import { InputOutputArgsSchema as InputOutputArgsSchema, InputOutputCliCommand } from '../utils/inputOutput.js'
|
|
3
4
|
import { ProsopoEnvError } from '@prosopo/common'
|
|
4
5
|
import { blake2b } from '@noble/hashes/blake2b'
|
|
5
|
-
import { lodash } from '@prosopo/util'
|
|
6
|
-
import { u8aToHex } from '@polkadot/util'
|
|
7
|
-
import { z } from 'zod'
|
|
6
|
+
import { lodash } from '@prosopo/util/lodash'
|
|
7
|
+
import { u8aToHex } from '@polkadot/util/u8a'
|
|
8
8
|
import cliProgress from 'cli-progress'
|
|
9
9
|
import fs from 'fs'
|
|
10
10
|
import sharp from 'sharp'
|