bdy 1.17.13-dev → 1.17.14-dev
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/distTs/package.json
CHANGED
|
@@ -12,8 +12,9 @@ const snapshots_1 = require("../../visualTest/snapshots");
|
|
|
12
12
|
const context_1 = require("../../visualTest/context");
|
|
13
13
|
const node_fs_1 = require("node:fs");
|
|
14
14
|
const node_path_1 = __importDefault(require("node:path"));
|
|
15
|
-
const fflate_1 = require("fflate");
|
|
16
15
|
const ci_info_1 = require("@buddy-works/ci-info");
|
|
16
|
+
const tar_stream_1 = __importDefault(require("tar-stream"));
|
|
17
|
+
const node_zlib_1 = require("node:zlib");
|
|
17
18
|
const commandVtStorybook = (0, utils_1.newCommand)('storybook', texts_1.DESC_COMMAND_VT_STORYBOOK);
|
|
18
19
|
commandVtStorybook.action(async () => {
|
|
19
20
|
if (!(0, validation_1.checkToken)()) {
|
|
@@ -34,8 +35,8 @@ commandVtStorybook.action(async () => {
|
|
|
34
35
|
});
|
|
35
36
|
(0, context_1.setCiAndCommitInfo)(ciAndGitInfo);
|
|
36
37
|
output_1.default.normal((0, ci_info_1.formattedCiInfo)(ciAndGitInfo));
|
|
37
|
-
const compressedStorybookDirectory = await createCompressedStorybookDirectory(currentDirectoryFiles);
|
|
38
38
|
try {
|
|
39
|
+
const compressedStorybookDirectory = await createCompressedStorybookDirectory(currentDirectoryFiles);
|
|
39
40
|
const { message } = await (0, requests_1.sendStorybook)(storybookSnapshots, compressedStorybookDirectory);
|
|
40
41
|
output_1.default.exitSuccess(message);
|
|
41
42
|
}
|
|
@@ -59,34 +60,42 @@ async function createCompressedStorybookDirectory(files) {
|
|
|
59
60
|
const cwd = process.cwd();
|
|
60
61
|
const chunks = [];
|
|
61
62
|
return new Promise((resolve, reject) => {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
if (data) {
|
|
68
|
-
chunks.push(data);
|
|
69
|
-
}
|
|
70
|
-
if (final) {
|
|
71
|
-
resolve(Buffer.concat(chunks));
|
|
72
|
-
}
|
|
63
|
+
const compressStream = (0, node_zlib_1.createBrotliCompress)({
|
|
64
|
+
params: {
|
|
65
|
+
[node_zlib_1.constants.BROTLI_PARAM_QUALITY]: 6,
|
|
66
|
+
},
|
|
73
67
|
});
|
|
68
|
+
compressStream.on('data', (chunk) => {
|
|
69
|
+
chunks.push(chunk);
|
|
70
|
+
});
|
|
71
|
+
compressStream.on('end', () => {
|
|
72
|
+
resolve(Buffer.concat(chunks));
|
|
73
|
+
});
|
|
74
|
+
compressStream.on('error', reject);
|
|
75
|
+
const packStream = tar_stream_1.default.pack();
|
|
76
|
+
packStream.pipe(compressStream);
|
|
77
|
+
let filesProcessed = 0;
|
|
74
78
|
for (const file of files) {
|
|
75
79
|
const filePath = node_path_1.default.join(cwd, file);
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
80
|
+
const stats = (0, node_fs_1.statSync)(filePath);
|
|
81
|
+
const entry = packStream.entry({
|
|
82
|
+
name: file,
|
|
83
|
+
size: stats.size,
|
|
84
|
+
}, (error) => {
|
|
85
|
+
if (error) {
|
|
86
|
+
reject(error);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
filesProcessed += 1;
|
|
90
|
+
if (filesProcessed === files.length) {
|
|
91
|
+
packStream.finalize();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
87
94
|
});
|
|
95
|
+
const fileStream = (0, node_fs_1.createReadStream)(filePath);
|
|
96
|
+
fileStream.pipe(entry);
|
|
97
|
+
fileStream.on('error', reject);
|
|
88
98
|
}
|
|
89
|
-
zipper.end();
|
|
90
99
|
});
|
|
91
100
|
}
|
|
92
101
|
function isStorybookDirectory(files) {
|
|
@@ -205,8 +205,8 @@ async function sendStorybook(snapshots, compressedStorybookDirectory) {
|
|
|
205
205
|
};
|
|
206
206
|
const files = [
|
|
207
207
|
{
|
|
208
|
-
id: 'storybook-static.
|
|
209
|
-
body: new Blob([compressedStorybookDirectory
|
|
208
|
+
id: 'storybook-static.tar.br',
|
|
209
|
+
body: new Blob([new Uint8Array(compressedStorybookDirectory)]),
|
|
210
210
|
},
|
|
211
211
|
];
|
|
212
212
|
const formData = createFormData(info, files);
|