Skip to content

Commit

Permalink
Publish
Browse files Browse the repository at this point in the history
  • Loading branch information
thedrlambda committed Mar 17, 2024
1 parent f84e259 commit 0a1b907
Show file tree
Hide file tree
Showing 10 changed files with 468 additions and 1,963 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
## Fixes and improvements
-

# 3.1.0
## Added features
- Ability to `replay` service runs from `queue`
## Fixes and improvements
- Underscore `_` auto-selects the default option
- Remove some old debugging logging
- Remove the word "keep" from secret envvar selection
- Add option to delete envvar without selecting visibility
- Add short header question to all choices

# 3.0.0
## Breaking changes
- Change order of questions for envvar so secrets can be hidden as *s
Expand Down
Binary file modified dist/windows.zip
Binary file not shown.
31 changes: 13 additions & 18 deletions executors.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.do_delete_org = exports.do_delete_group = exports.do_delete_service = exports.do_event = exports.do_spending = exports.do_remove_auto_approve = exports.do_auto_approve = exports.do_attach_role = exports.do_join = exports.do_post = exports.do_help = exports.do_queue_time = exports.printTableHeader = exports.alignLeft = exports.alignRight = exports.do_cron = exports.do_envvar = exports.do_key = exports.do_inspect = exports.do_build = exports.do_redeploy = exports.do_deploy = exports.generateNewKey = exports.useExistingKey = exports.do_register = exports.addKnownHost = exports.do_duplicate = exports.fetch_template = exports.createService = exports.createServiceGroup = exports.createOrganization = exports.do_clone = exports.do_fetch = void 0;
exports.do_delete_org = exports.do_delete_group = exports.do_delete_service = exports.do_event = exports.do_spending = exports.do_remove_auto_approve = exports.do_auto_approve = exports.do_attach_role = exports.do_join = exports.do_post = exports.do_help = exports.do_queue_time = exports.printTableHeader = exports.alignLeft = exports.alignRight = exports.do_cron = exports.do_envvar = exports.do_key = exports.do_replay = exports.do_build = exports.do_redeploy = exports.do_deploy = exports.generateNewKey = exports.useExistingKey = exports.do_register = exports.addKnownHost = exports.do_duplicate = exports.fetch_template = exports.createService = exports.createServiceGroup = exports.createOrganization = exports.do_clone = exports.do_fetch = void 0;
const fs_1 = __importDefault(require("fs"));
const os_1 = __importDefault(require("os"));
const utils_1 = require("./utils");
Expand Down Expand Up @@ -95,11 +95,8 @@ function createFolderStructure(struct, prefix, org, team) {
fs_1.default.mkdirSync(dir, { recursive: true });
}
if (!fs_1.default.existsSync(dir + "/.git")) {
(0, utils_1.output2)("Here1 " + dir);
yield (0, utils_1.execPromise)(`git init --initial-branch=main`, dir);
(0, utils_1.output2)("Here2 " + dir);
yield (0, utils_1.execPromise)(`git remote add origin ${repo}`, dir);
(0, utils_1.output2)("Here3 " + dir);
fs_1.default.writeFileSync(dir + "/fetch.bat", `@echo off
git fetch
git reset --hard origin/main
Expand All @@ -108,7 +105,8 @@ del fetch.sh
fs_1.default.writeFileSync(dir + "/fetch.sh", `#!/bin/sh
git fetch
git reset --hard origin/main
rm fetch.bat fetch.sh`);
rm fetch.bat fetch.sh`, {});
fs_1.default.chmodSync(dir + "/fetch.sh", "755");
}
else {
yield (0, utils_1.execPromise)(`git remote set-url origin ${repo}`, dir);
Expand Down Expand Up @@ -422,22 +420,18 @@ function do_build() {
});
}
exports.do_build = do_build;
function do_inspect(org, id, river) {
function do_replay(org, id, river) {
return __awaiter(this, void 0, void 0, function* () {
try {
let res = JSON.parse(yield (0, utils_1.sshReq)(`inspect`, id, `--river`, river, `--org`, `${org}`));
let resout = res.output;
delete res.output;
console.log(res);
(0, utils_1.output2)("Output:");
(0, utils_1.output2)(resout);
yield (0, utils_1.sshReq)(`replay`, id, `--river`, river, `--org`, `${org}`);
(0, utils_1.output2)("Replayed event.");
}
catch (e) {
throw e;
}
});
}
exports.do_inspect = do_inspect;
exports.do_replay = do_replay;
function do_key(org, key, name, duration) {
return __awaiter(this, void 0, void 0, function* () {
try {
Expand Down Expand Up @@ -523,7 +517,7 @@ function alignLeft(str, width) {
exports.alignLeft = alignLeft;
function printTableHeader(prefix, widths) {
if ((0, args_1.getArgs)().length > 0)
return;
return "";
let totalWidth = process_1.stdout.getWindowSize()[0] - prefix.length;
let vals = Object.values(widths);
let rest = totalWidth -
Expand All @@ -533,26 +527,27 @@ function printTableHeader(prefix, widths) {
Object.keys(widths)
.map((k) => k.trim().padEnd(widths[k] < 0 ? Math.max(rest, -widths[k]) : widths[k]))
.join(" │ ");
(0, utils_1.output2)(header);
let result = header + "\n";
let divider = prefix +
Object.keys(widths)
.map((k) => "─".repeat(widths[k] < 0 ? Math.max(rest, -widths[k]) : widths[k]))
.join("─┼─");
(0, utils_1.output2)(divider);
result += divider;
return result;
}
exports.printTableHeader = printTableHeader;
function do_queue_time(org, time) {
return __awaiter(this, void 0, void 0, function* () {
try {
let resp = yield (0, utils_1.sshReq)(`queue`, `--org`, org, `--time`, "" + time);
let queue = JSON.parse(resp);
printTableHeader("", {
(0, utils_1.output2)(printTableHeader("", {
Id: 6,
River: 12,
Event: 12,
Status: 7,
"Queue time": 20,
});
}));
queue.forEach((x) => (0, utils_1.output2)(`${x.id}${alignRight(x.r, 12)}${alignLeft(x.e, 12)}${alignLeft(x.s, 7)}${new Date(x.q).toLocaleString()}`));
}
catch (e) {
Expand Down
42 changes: 19 additions & 23 deletions executors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,8 @@ async function createFolderStructure(
fs.mkdirSync(dir, { recursive: true });
}
if (!fs.existsSync(dir + "/.git")) {
output2("Here1 " + dir);
await execPromise(`git init --initial-branch=main`, dir);
output2("Here2 " + dir);
await execPromise(`git remote add origin ${repo}`, dir);
output2("Here3 " + dir);
fs.writeFileSync(
dir + "/fetch.bat",
`@echo off
Expand All @@ -123,8 +120,10 @@ del fetch.sh
`#!/bin/sh
git fetch
git reset --hard origin/main
rm fetch.bat fetch.sh`
rm fetch.bat fetch.sh`,
{}
);
fs.chmodSync(dir + "/fetch.sh", "755");
} else {
await execPromise(`git remote set-url origin ${repo}`, dir);
}
Expand Down Expand Up @@ -444,16 +443,10 @@ export async function do_build() {
}
}

export async function do_inspect(org: string, id: string, river: string) {
export async function do_replay(org: string, id: string, river: string) {
try {
let res = JSON.parse(
await sshReq(`inspect`, id, `--river`, river, `--org`, `${org}`)
);
let resout = res.output;
delete res.output;
console.log(res);
output2("Output:");
output2(resout);
await sshReq(`replay`, id, `--river`, river, `--org`, `${org}`);
output2("Replayed event.");
} catch (e) {
throw e;
}
Expand Down Expand Up @@ -590,7 +583,7 @@ export function printTableHeader(
prefix: string,
widths: { [key: string]: number }
) {
if (getArgs().length > 0) return;
if (getArgs().length > 0) return "";
let totalWidth = stdout.getWindowSize()[0] - prefix.length;
let vals = Object.values(widths);
let rest =
Expand All @@ -604,15 +597,16 @@ export function printTableHeader(
k.trim().padEnd(widths[k] < 0 ? Math.max(rest, -widths[k]) : widths[k])
)
.join(" │ ");
output2(header);
let result = header + "\n";
let divider =
prefix +
Object.keys(widths)
.map((k) =>
"─".repeat(widths[k] < 0 ? Math.max(rest, -widths[k]) : widths[k])
)
.join("─┼─");
output2(divider);
result += divider;
return result;
}

export async function do_queue_time(org: string, time: number) {
Expand All @@ -625,13 +619,15 @@ export async function do_queue_time(org: string, time: number) {
r: string;
s: string;
}[] = JSON.parse(resp);
printTableHeader("", {
Id: 6,
River: 12,
Event: 12,
Status: 7,
"Queue time": 20,
});
output2(
printTableHeader("", {
Id: 6,
River: 12,
Event: 12,
Status: 7,
"Queue time": 20,
})
);
queue.forEach((x) =>
output2(
`${x.id}${alignRight(x.r, 12)}${alignLeft(x.e, 12)}${alignLeft(
Expand Down
Loading

0 comments on commit 0a1b907

Please sign in to comment.