Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sekaiking committed Dec 2, 2023
1 parent 093f59a commit fc3d6af
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 29 deletions.
4 changes: 2 additions & 2 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const distFolder = process.env.DIST_FOLDER || "build";

// Main function to orchestrate the build script
async function build() {
for_folder(path.join(".", "apps"), (appFolder) => {
return for_folder(path.join(".", "apps"), (appFolder) => {
const appName = path.basename(appFolder);
create_dist(appName, distFolder);
process_dist(appName, distFolder); //
Expand All @@ -19,7 +19,7 @@ async function build() {
// walk through each app folder
function process_dist(appName, df) {
const config = read_bos_config(appName);
process.stdout.write(`Building ${appName} (${config.appAccount})...\n`);
// process.stdout.write(`Building ${appName} (${config.appAccount})...\n`);
for_rfile(
path.join(".", df, appName),
["js", "jsx", "ts", "tsx"],
Expand Down
43 changes: 25 additions & 18 deletions lib/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,47 @@ const distFolder = process.env.DIST_FOLDER || "build";
// Main function to orchestrate the dev script
async function dev() {
let loading = log.loading(`Building the project for the first time`);
await build().catch((err) => {
let apps = await build().catch((err) => {
loading.error();
log.error(err);
process.exit(1);
});
loading.finish();

log.info(
`Detected apps: \n - ${apps.map((app) => app.split('/')[1]).join(", \n-")}\n`,
);

// Start serving the development JSON
loading = log.loading(`Starting the bos loader server`);
const { io } = serveDevJson(true).catch((err) => {
const { io } = await serveDevJson(true).catch((err) => {
loading.error();
log.error(err);
process.exit(1);
});
loading.finish();

log.log(`\n
┌─────────────────────────────────────────────┐
│ Server is up and running! │
│ │
│ ➜ Local: http://127.0.0.1:4040 │
│ ➜ Socket: ws://127.0.0.1:4040 │
│ │
│ To use the local widgets, please: │
│ 1. Visit https://near.org/flags │
│ 2. Paste the above local server URL. │
│ │
└─────────────────────────────────────────────┘
`);
log.log(`
┌─────────────────────────────────────────────────────────────┐
│ BosLoader Server is Up and Running │
│ │
│ ➜ HTTP server: http://127.0.0.1:4040 │
│ ➜ WebSocket server: ws://127.0.0.1:4040 │
│ │
│ Optionaly, to open local widgets: │
│ 1. Visit either of the following sites: │
│ - https://near.org/flags │
│ - https://everything.dev/flags │
│ 2. Paste the BosLoader local server URL. │
│ │
└─────────────────────────────────────────────────────────────┘
`);

log.info(
[
"Watching for changes in the following folders:",
"./apps",
"./modules",
" - ./apps",
" - ./modules",
"\n",
].join("\n"),
);
Expand Down Expand Up @@ -173,7 +179,7 @@ async function serveDevJson(useSocket = true) {
res.json(devJson);
});

server.listen(4040, "127.0.0.1", () => {});
server.listen(4040, "127.0.0.1", () => { });

if (useSocket) {
io.on("connection", () => {
Expand All @@ -182,6 +188,7 @@ async function serveDevJson(useSocket = true) {
});
}


return { io };
}

Expand Down
9 changes: 9 additions & 0 deletions lib/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ async function run_gateway() {
child.stdout.on("data", (data) => {
if (data.includes("compiled successfully")) {
loading.finish("Gateway started successfully!");
log.log(`
┌─────────────────────────────────────────────────────────────┐
│ Local Gateway Successfully Running │
│ │
│ ➜ Gateway: \u001b[32mhttp://127.0.0.1:5050\u001b[0m │
└─────────────────────────────────────────────────────────────┘
`);


}
});
child.stderr.on("data", (data) => {
Expand Down
18 changes: 9 additions & 9 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ const log = {
];
const delay = 80;

const interval = setInterval(function () {
const interval = setInterval(function() {
// change dots slower than the chars
process.stdout.write(
"\r" +
chars[x++] +
" " +
text +
(enabledots ? dots[x % dots.length] : ""),
chars[x++] +
" " +
text +
(enabledots ? dots[x % dots.length] : ""),
);
x = x % chars.length;
}, delay);
Expand All @@ -139,16 +139,16 @@ const log = {
clearInterval(interval);
process.stdout.write(
"\r\x1b[32m\x1b[1m\u2713\x1b[0m " +
text1 +
" \n",
text1 +
" \n",
);
},
error: (text1 = text) => {
clearInterval(interval);
process.stdout.write(
"\r\x1b[31m\x1b[1m\u2717\x1b[0m " +
text1 +
" \n",
text1 +
" \n",
);
},
};
Expand Down

0 comments on commit fc3d6af

Please sign in to comment.