@platforma-sdk/block-tools 2.17.8 → 2.18.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/dist/cli.js +8 -8
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +426 -420
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-C07cYptA.mjs → config-BusBoNIz.mjs} +495 -586
- package/dist/config-BusBoNIz.mjs.map +1 -0
- package/dist/config-DG4SQFXv.js +2 -0
- package/dist/config-DG4SQFXv.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -15
- package/dist/index.mjs.map +1 -1
- package/dist/io/storage.d.ts +1 -28
- package/dist/structure/rules/root-package-json.d.ts +1 -0
- package/dist/structure/rules/root-pnpm-workspace.d.ts +1 -0
- package/package.json +2 -3
- package/src/cmd/structure/refresh.ts +2 -2
- package/src/io/folder_reader.test.ts +18 -0
- package/src/io/folder_reader.ts +6 -0
- package/src/io/storage.ts +8 -147
- package/src/structure/__tests__/toolchain.test.ts +24 -14
- package/src/structure/rules/root-catalog-bump.ts +17 -0
- package/src/structure/rules/root-package-json.ts +5 -1
- package/src/structure/rules/root-pnpm-workspace.ts +6 -2
- package/src/structure/rules/shared/toolchain.ts +0 -2
- package/dist/config-C07cYptA.mjs.map +0 -1
- package/dist/config-on5N57rI.js +0 -3
- package/dist/config-on5N57rI.js.map +0 -1
- package/src/io/storage.test.ts +0 -96
package/src/io/storage.test.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { test, expect } from "vitest";
|
|
3
|
-
import { S3Storage, storageByUrl } from "./storage";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import * as fs from "node:fs";
|
|
6
|
-
|
|
7
|
-
test("file url test #1", async () => {
|
|
8
|
-
const url = new URL("file:./local/path", "file://" + path.resolve(".") + "/");
|
|
9
|
-
expect(url.pathname).toEqual(path.resolve("./local/path"));
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test("file url test #2", async () => {
|
|
13
|
-
const url = new URL("http://a/b/c", "file://" + path.resolve(".") + "/");
|
|
14
|
-
expect(url.toString()).toEqual("http://a/b/c");
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test("test local fs read write", async () => {
|
|
18
|
-
const uuid = randomUUID().toString();
|
|
19
|
-
const tmp = path.resolve("tmp");
|
|
20
|
-
const storagePath = path.resolve(tmp, uuid);
|
|
21
|
-
const storage = storageByUrl("file://" + storagePath);
|
|
22
|
-
expect(await storage.getFile("some/deep/file.txt")).toBeUndefined();
|
|
23
|
-
await storage.putFile("some/deep/file.txt", Buffer.from("test1"));
|
|
24
|
-
expect((await storage.getFile("some/deep/file.txt"))?.toString()).toEqual("test1");
|
|
25
|
-
await fs.promises.rm(storagePath, { recursive: true });
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test("test local fs list", async () => {
|
|
29
|
-
const uuid = randomUUID().toString();
|
|
30
|
-
const tmp = path.resolve("tmp");
|
|
31
|
-
const storagePath = path.resolve(tmp, uuid);
|
|
32
|
-
const storage = storageByUrl("file://" + storagePath);
|
|
33
|
-
await storage.putFile("some/deep1/file_1.txt", Buffer.from("test1"));
|
|
34
|
-
await storage.putFile("some/deep1/file_2.txt", Buffer.from("test1"));
|
|
35
|
-
await storage.putFile("some/deep2/file_1.txt", Buffer.from("test1"));
|
|
36
|
-
const result = await storage.listFiles("some");
|
|
37
|
-
result.sort();
|
|
38
|
-
const expected = ["deep2/file_1.txt", "deep1/file_1.txt", "deep1/file_2.txt"];
|
|
39
|
-
expected.sort();
|
|
40
|
-
expect(result).toEqual(expected);
|
|
41
|
-
await storage.deleteFiles("some/deep2/file_1.txt");
|
|
42
|
-
expected.splice(expected.indexOf("some/deep2/file_1.txt"), 1);
|
|
43
|
-
const result1 = await storage.listFiles("some");
|
|
44
|
-
result1.sort();
|
|
45
|
-
expect(result1).toEqual(expected);
|
|
46
|
-
await fs.promises.rm(storagePath, { recursive: true });
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const testS3Address = process.env.TEST_S3_ADDRESS;
|
|
50
|
-
if (testS3Address) {
|
|
51
|
-
test("test s3 read write", async () => {
|
|
52
|
-
const uuid = randomUUID().toString();
|
|
53
|
-
const testS3AddressURL = new URL(testS3Address);
|
|
54
|
-
testS3AddressURL.pathname = `${testS3AddressURL.pathname.replace(/\/$/, "")}/${uuid}`;
|
|
55
|
-
const storage = storageByUrl(testS3AddressURL.toString()) as S3Storage;
|
|
56
|
-
expect(await storage.getFile("some/deep/file.txt")).toBeUndefined();
|
|
57
|
-
await storage.putFile("some/deep/file.txt", Buffer.from("test1"));
|
|
58
|
-
expect((await storage.getFile("some/deep/file.txt"))?.toString()).toEqual("test1");
|
|
59
|
-
await storage.deleteFiles(`some/deep/file.txt`);
|
|
60
|
-
expect(await storage.getFile("some/deep/file.txt")).toBeUndefined();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test("test s3 fs list", async () => {
|
|
64
|
-
const uuid = randomUUID().toString();
|
|
65
|
-
const testS3AddressURL = new URL(testS3Address);
|
|
66
|
-
testS3AddressURL.pathname = `${testS3AddressURL.pathname.replace(/\/$/, "")}/${uuid}`;
|
|
67
|
-
const storage = storageByUrl(testS3AddressURL.toString()) as S3Storage;
|
|
68
|
-
|
|
69
|
-
const nonExistingFolderListing = await storage.listFiles("not_existing_folder");
|
|
70
|
-
expect(nonExistingFolderListing).toEqual([]);
|
|
71
|
-
|
|
72
|
-
await storage.putFile("some/deep1/file_1.txt", Buffer.from("test1"));
|
|
73
|
-
await storage.putFile("some/deep1/file_2.txt", Buffer.from("test1"));
|
|
74
|
-
await storage.putFile("some/deep2/file_1.txt", Buffer.from("test1"));
|
|
75
|
-
const result = await storage.listFiles("some");
|
|
76
|
-
result.sort();
|
|
77
|
-
const expected = ["deep2/file_1.txt", "deep1/file_1.txt", "deep1/file_2.txt"];
|
|
78
|
-
expected.sort();
|
|
79
|
-
expect(result).toEqual(expected);
|
|
80
|
-
await storage.deleteFiles("some/deep2/file_1.txt");
|
|
81
|
-
expected.splice(expected.indexOf("some/deep2/file_1.txt"), 1);
|
|
82
|
-
const result1 = await storage.listFiles("some");
|
|
83
|
-
result1.sort();
|
|
84
|
-
expect(result1).toEqual(expected);
|
|
85
|
-
await storage.client.deleteObjects({
|
|
86
|
-
Bucket: storage.bucket,
|
|
87
|
-
Delete: {
|
|
88
|
-
Objects: [
|
|
89
|
-
{ Key: `${storage.root}/some/deep1/file_1.txt` },
|
|
90
|
-
{ Key: `${storage.root}/some/deep1/file_2.txt` },
|
|
91
|
-
{ Key: `${storage.root}/some/deep2/file_1.txt` },
|
|
92
|
-
],
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
}
|