Skip to content

Commit

Permalink
Publish
Browse files Browse the repository at this point in the history
  • Loading branch information
thedrlambda committed Jan 16, 2025
1 parent 407cd18 commit 4de3ecd
Show file tree
Hide file tree
Showing 17 changed files with 493 additions and 306 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
## Fixes and improvements
-

# 4.7.0
## Added features
- `rapids` now also separates on days, and uses more data to provide even better groupings
- `rapids` colored to make important information more easily discernable
- `inspect` and `sim` outputs less clutter and breaks lines better, also supports color
## Fixes and improvements
- Commands print the final choice when passing `x` on the commandline (useful for scripting)
- Fix crashes when there were very few options, which didn't have a short key
- Fix crash on large `rapids` output (~3k requests, increased to ~10k)
- Speed up `rapids post`

# 4.6.0
## Added features
- `rapids` shows traces in intelligent groups, providing better overview in case of many events
Expand Down
15 changes: 8 additions & 7 deletions Execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import cookieParser from "cookie-parser";
import express from "express";
import fs from "fs";
import net from "net";
import { GRAY, NORMAL_COLOR, RED, WHITE, YELLOW } from "./prompt.js";
import { addToExecuteQueue, all, finish, generateString, printWithPrefix, } from "./utils.js";
import { GRAY, INVISIBLE, NORMAL_COLOR, RED, WHITE, YELLOW } from "./prompt.js";
import { addToExecuteQueue, all, finish, generateString, } from "./utils.js";
import { Str } from "@merrymake/utils";
let spacerTimer;
function timedOutput(str, prefix) {
if (spacerTimer !== undefined)
clearTimeout(spacerTimer);
printWithPrefix(str, prefix);
Str.print(str, prefix, INVISIBLE, undefined, true);
spacerTimer = setTimeout(() => console.log(""), 10000);
}
async function prep(folder, runCommand, env, displayFolder) {
Expand All @@ -24,10 +25,10 @@ async function prep(folder, runCommand, env, displayFolder) {
};
const p = spawn(cmd, args, options);
p.stdout.on("data", (data) => {
timedOutput(`${data.toString()}`, `${GRAY}${displayFolder}: ${NORMAL_COLOR}`);
timedOutput(`${data.toString()}`, displayFolder);
});
p.stderr.on("data", (data) => {
timedOutput(`${data.toString()}${NORMAL_COLOR}`, `${GRAY}${displayFolder}: ${RED}`);
timedOutput(`${RED}${data.toString()}${NORMAL_COLOR}`, displayFolder);
});
return p;
}
Expand Down Expand Up @@ -347,7 +348,7 @@ ${NORMAL_COLOR}`);
const riverConfigs = processFolders(this.pathToRoot, event);
const rivers = Object.keys(riverConfigs);
if (rivers.length === 0 && event[0] !== "$") {
timedOutput(`${YELLOW}Warning: No hooks for '${event}'${NORMAL_COLOR}`, `${GRAY}${traceId}: `);
timedOutput(`${YELLOW}Warning: No hooks for '${event}'${NORMAL_COLOR}`, traceId);
}
rivers.forEach((r) => {
const actions = riverConfigs[r];
Expand Down Expand Up @@ -399,7 +400,7 @@ ${NORMAL_COLOR}`);
};
if (conf !== undefined && conf.waitFor !== undefined) {
setTimeout(() => {
timedOutput(`Reply timeout for trace${NORMAL_COLOR}`, `${GRAY}${traceId}: `);
timedOutput(`Reply timeout for trace${NORMAL_COLOR}`, traceId);
}, conf.waitFor);
}
if (conf !== undefined && conf.streaming === true) {
Expand Down
22 changes: 7 additions & 15 deletions Execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import cookieParser from "cookie-parser";
import express, { Request, RequestHandler, Response } from "express";
import fs from "fs";
import net from "net";
import { GRAY, NORMAL_COLOR, RED, WHITE, YELLOW } from "./prompt.js";
import { GRAY, INVISIBLE, NORMAL_COLOR, RED, WHITE, YELLOW } from "./prompt.js";
import {
addToExecuteQueue,
all,
Expand All @@ -20,6 +20,7 @@ import {
printWithPrefix,
} from "./utils.js";
import { PathTo, PathToOrganization, PathToRepository } from "./types.js";
import { Str } from "@merrymake/utils";

interface Envelope {
messageId: string;
Expand Down Expand Up @@ -49,7 +50,7 @@ interface ReplyBody {
let spacerTimer: undefined | NodeJS.Timeout;
function timedOutput(str: string, prefix?: string) {
if (spacerTimer !== undefined) clearTimeout(spacerTimer);
printWithPrefix(str, prefix);
Str.print(str, prefix, INVISIBLE, undefined, true);
spacerTimer = setTimeout(() => console.log(""), 10000);
}

Expand All @@ -69,16 +70,10 @@ async function prep(
};
const p = spawn(cmd, args, options);
p.stdout.on("data", (data: Buffer) => {
timedOutput(
`${data.toString()}`,
`${GRAY}${displayFolder}: ${NORMAL_COLOR}`
);
timedOutput(`${data.toString()}`, displayFolder);
});
p.stderr.on("data", (data: Buffer) => {
timedOutput(
`${data.toString()}${NORMAL_COLOR}`,
`${GRAY}${displayFolder}: ${RED}`
);
timedOutput(`${RED}${data.toString()}${NORMAL_COLOR}`, displayFolder);
});
return p;
} catch (e) {
Expand Down Expand Up @@ -447,7 +442,7 @@ ${NORMAL_COLOR}`);
if (rivers.length === 0 && event[0] !== "$") {
timedOutput(
`${YELLOW}Warning: No hooks for '${event}'${NORMAL_COLOR}`,
`${GRAY}${traceId}: `
traceId
);
}

Expand Down Expand Up @@ -521,10 +516,7 @@ ${NORMAL_COLOR}`);
};
if (conf !== undefined && conf.waitFor !== undefined) {
setTimeout(() => {
timedOutput(
`Reply timeout for trace${NORMAL_COLOR}`,
`${GRAY}${traceId}: `
);
timedOutput(`Reply timeout for trace${NORMAL_COLOR}`, traceId);
}, conf.waitFor);
}
if (conf !== undefined && conf.streaming === true) {
Expand Down
10 changes: 4 additions & 6 deletions executors.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { spawn } from "child_process";
import fs from "fs";
import { stdout } from "process";
import { getArgs } from "./args.js";
import { outputGit, sshReq } from "./utils.js";
import { GRAY, NORMAL_COLOR } from "./prompt.js";
function spawnPromise(str) {
return new Promise((resolve, reject) => {
const [cmd, ...args] = str.split(" ");
Expand Down Expand Up @@ -42,8 +42,6 @@ export function alignCenter(str, width) {
: "".padStart(half, " ").concat(str).padEnd(width, " ");
}
export function printTableHeader(prefix, widths) {
if (getArgs().length > 0)
return "";
const totalWidth = (typeof stdout.getWindowSize !== "function"
? 80
: stdout.getWindowSize()[0]) - prefix.length;
Expand All @@ -53,14 +51,14 @@ export function printTableHeader(prefix, widths) {
3 * (vals.length - 1);
const header = prefix +
Object.keys(widths)
.map((k) => k.trim().padEnd(widths[k] < 0 ? Math.max(rest, -widths[k]) : widths[k]))
.join(" │ ");
.map((k) => k.padEnd(widths[k] < 0 ? Math.max(rest, -widths[k]) : widths[k]))
.join(` ${GRAY}${NORMAL_COLOR} `);
let result = header + "\n";
const divider = prefix +
Object.keys(widths)
.map((k) => "─".repeat(widths[k] < 0 ? Math.max(rest, -widths[k]) : widths[k]))
.join("─┼─");
result += divider;
result += GRAY + divider + NORMAL_COLOR;
return result;
}
// export async function do_help() {
Expand Down
8 changes: 4 additions & 4 deletions executors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import fs from "fs";
import { stdout } from "process";
import { getArgs } from "./args.js";
import { outputGit, sshReq } from "./utils.js";
import { GRAY, NORMAL_COLOR } from "./prompt.js";

function spawnPromise(str: string) {
return new Promise<void>((resolve, reject) => {
Expand Down Expand Up @@ -49,7 +50,6 @@ export function printTableHeader(
prefix: string,
widths: { [key: string]: number }
) {
if (getArgs().length > 0) return "";
const totalWidth =
(typeof stdout.getWindowSize !== "function"
? 80
Expand All @@ -63,9 +63,9 @@ export function printTableHeader(
prefix +
Object.keys(widths)
.map((k) =>
k.trim().padEnd(widths[k] < 0 ? Math.max(rest, -widths[k]) : widths[k])
k.padEnd(widths[k] < 0 ? Math.max(rest, -widths[k]) : widths[k])
)
.join(" │ ");
.join(` ${GRAY}${NORMAL_COLOR} `);
let result = header + "\n";
const divider =
prefix +
Expand All @@ -74,7 +74,7 @@ export function printTableHeader(
"─".repeat(widths[k] < 0 ? Math.max(rest, -widths[k]) : widths[k])
)
.join("─┼─");
result += divider;
result += GRAY + divider + NORMAL_COLOR;
return result;
}

Expand Down
3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { initializeArgs } from "./args.js";
import { index } from "./newCommands/index.js";
import { addKnownHost } from "./newCommands/register.js";
import { CTRL_C, moveToBottom } from "./prompt.js";
import { abort, checkVersion, checkVersionIfOutdated, package_json, setDryrun, } from "./utils.js";
import { abort, checkVersionIfOutdated, package_json, setDryrun, } from "./utils.js";
process.argv.splice(0, 1); // Remove node
process.argv.splice(0, 1); // Remove index
if (process.argv.length > 0 && process.argv[0].endsWith("version")) {
Expand Down Expand Up @@ -49,6 +49,5 @@ if (stdin.isTTY) {
console.log("\x1b[31mAn error occurred, please try again. If the problem persists reach out on http://discord.merrymake.eu \x1b[0m", e);
}
console.log(`\x1b[31mERROR ${eStr.trimEnd()}\x1b[0m`);
checkVersion();
abort();
});
3 changes: 1 addition & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { stdin } from "node:process";
import { initializeArgs } from "./args.js";
import { index } from "./newCommands/index.js";
import { addKnownHost } from "./newCommands/register.js";
import { CTRL_C, exit, moveToBottom } from "./prompt.js";
import { CTRL_C, moveToBottom } from "./prompt.js";
import {
abort,
checkVersion,
Expand Down Expand Up @@ -67,6 +67,5 @@ if (stdin.isTTY) {
);
}
console.log(`\x1b[31mERROR ${eStr.trimEnd()}\x1b[0m`);
checkVersion();
abort();
});
7 changes: 5 additions & 2 deletions mmCommand.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
let command = "$ mm";
let command = "mm";
export function setCommand(mm) {
command = "$ " + mm;
command = mm;
}
export function getCommand() {
return "$ " + command;
}
export function getShortCommand() {
return command;
}
7 changes: 5 additions & 2 deletions mmCommand.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
let command = "$ mm";
let command = "mm";
export function setCommand(mm: string) {
command = "$ " + mm;
command = mm;
}
export function getCommand() {
return "$ " + command;
}
export function getShortCommand() {
return command;
}
Loading

0 comments on commit 4de3ecd

Please sign in to comment.