Skip to content

Commit 5176c73

Browse files
committed
deploy
Signed-off-by: Diógenes Fernandes <[email protected]> deploy Signed-off-by: Diógenes Fernandes <[email protected]>
1 parent bf8278b commit 5176c73

File tree

2 files changed

+12
-27
lines changed

2 files changed

+12
-27
lines changed

search/worker/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

search/worker/scripts/feed-data-r2.js

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
// This script is used to retrieve data generated by `go run generate.go` at backend folder.
22
// It will generate registry data that will be used by this script to feed into wrangler dev folder, mimicking a R2 bucket.
33
// This script expects data will be at /tmp/registry.
4-
import { createRequire } from "module";
5-
const require = createRequire(import.meta.url);
64
const fs = require('fs');
75
const path = require('path');
86
const { exec } = require('node:child_process');
97

10-
const BATCH_SIZE = 10
11-
const DIR_PATH = '/tmp/registry';
8+
const directoryPath = '/tmp/registry';
129

13-
const putObject = (directoryPath) => (filename) => {
14-
return new Promise((resolve) => {
15-
const realFilePath = path.join(directoryPath, filename);
10+
fs.readdir(directoryPath, { recursive: true }, (err, files) => {
11+
if (err) {
12+
console.error('Error reading directory:', err);
13+
return;
14+
}
15+
16+
files.forEach(fileName => {
17+
const realFilePath = path.join(directoryPath, fileName);
1618
const r2Name = realFilePath.replace(directoryPath, "");
1719

1820
const cmd = `npx wrangler r2 object put registry-ui-api${r2Name} --file ${realFilePath} --local`
@@ -21,23 +23,6 @@ const putObject = (directoryPath) => (filename) => {
2123
console.log(stdout);
2224
console.error(stderr);
2325
});
24-
resolve();
25-
});
26-
}
2726

28-
const run = async () => {
29-
fs.readdir(DIR_PATH, { recursive: true }, async (err, files) => {
30-
if (err) {
31-
console.error('Error reading directory:', err);
32-
return;
33-
}
34-
35-
let i = 1;
36-
while (files.length) {
37-
await Promise.all(files.splice(0, BATCH_SIZE).map(putObject(DIR_PATH)));
38-
i++;
39-
}
4027
});
41-
}
42-
43-
await run()
28+
});

0 commit comments

Comments
 (0)