Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"yaml": "https://esm.sh/yaml@2.6.1",
"semver": "https://esm.sh/semver@7.6.3",
"boxen": "https://esm.sh/boxen@8.0.1",
"chalk": "https://esm.sh/chalk@5.3.0",
"dayjs": "https://esm.sh/dayjs@1.11.13",
"dayjs/plugin/advancedFormat": "https://esm.sh/dayjs@1.11.13/plugin/advancedFormat.js",
"dayjs/plugin/duration": "https://esm.sh/dayjs@1.11.13/plugin/duration.js",
Expand Down
302 changes: 107 additions & 195 deletions deno.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"async-retry": "^1.3.3",
"axios": "^1.8.4",
"boxen": "^8.0.1",
"chalk": "^5.3.0",
"chrono-node": "^2.7.6",
"cli-progress": "^3.12.0",
"cli-table3": "0.6.5",
Expand All @@ -24,7 +23,6 @@
"dayjs": "^1.11.13",
"dotenv": "^16.4.5",
"ink": "^5.2.0",
"ink-confirm-input": "^2.0.0",
"ink-link": "^4.1.0",
"ink-spinner": "^5.0.0",
"ink-testing-library": "^4.0.0",
Expand Down Expand Up @@ -53,5 +51,8 @@
"peerDependencies": {
"typescript": "^5.6.2"
},
"resolutions": {
"chalk": "^5.6.2"
},
"version": "0.21.6"
}
8 changes: 4 additions & 4 deletions src/checkVersion.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import boxen from "boxen";
import chalk from "chalk";
import { cyan, gray, yellow } from "jsr:@std/fmt/colors";
import { execSync } from "node:child_process";
import * as console from "node:console";
import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
Expand Down Expand Up @@ -122,11 +122,11 @@ export async function checkVersion() {

if (isPatchUpdate && !latestIsPrerelease) {
console.log(
chalk.cyan(`Automatically upgrading ${version} → ${latestVersion}`),
cyan(`Automatically upgrading ${version} → ${latestVersion}`),
);
try {
execSync("sf upgrade", { stdio: "inherit" });
console.log(chalk.gray("\n☁️☁️☁️\n"));
console.log(gray("\n☁️☁️☁️\n"));

// Re-run the original command
const args = process.argv.slice(2);
Expand All @@ -146,7 +146,7 @@ Latest version: ${latestVersion}
Run 'sf upgrade' to update to the latest version
`;
console.log(
boxen(chalk.yellow(message), {
boxen(yellow(message), {
padding: 1,
borderColor: "yellow",
borderStyle: "round",
Expand Down
4 changes: 2 additions & 2 deletions src/lib/app-banner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import boxen from "boxen";
import chalk from "chalk";
import { yellow } from "jsr:@std/fmt/colors";
import * as console from "node:console";

type AppBanner = {
Expand All @@ -18,7 +18,7 @@ export const getAppBanner = async () => {
const message = `${data.content}`;

console.log(
boxen(chalk.yellow(message), {
boxen(yellow(message), {
padding: 1,
borderColor: "yellow",
borderStyle: "round",
Expand Down
6 changes: 3 additions & 3 deletions src/lib/buy/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type Command, Option } from "@commander-js/extra-typings";
import chalk from "chalk";
import { yellow } from "jsr:@std/fmt/colors";
import { parseDate } from "chrono-node";
import { Box, render, Text, useApp } from "ink";
import Spinner from "ink-spinner";
Expand Down Expand Up @@ -82,7 +82,7 @@ export function _registerBuy(program: Command) {
const { duration, end } = command.opts();
if ((!duration && !end) || (!!duration && !!end)) {
console.error(
chalk.yellow("Specify either --duration or --end, but not both"),
yellow("Specify either --duration or --end, but not both"),
);
command.help();
process.exit(1);
Expand Down Expand Up @@ -113,7 +113,7 @@ export function _registerBuy(program: Command) {
const { type, zone, cluster, colocate } = command.opts();
if (!type && !zone && !cluster && !colocate) {
console.error(
chalk.yellow("Must specify either --type, --zone or --colocate"),
yellow("Must specify either --type, --zone or --colocate"),
);
command.help();
process.exit(1);
Expand Down
8 changes: 4 additions & 4 deletions src/lib/dev.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import process from "node:process";
import * as console from "node:console";
import { confirm } from "@inquirer/prompts";
import chalk from "chalk";
import { gray, green, white, yellow } from "jsr:@std/fmt/colors";
import type { Command } from "@commander-js/extra-typings";
import dayjs from "npm:dayjs@1.11.13";
import utc from "npm:dayjs@1.11.13/plugin/utc.js";
Expand Down Expand Up @@ -33,7 +33,7 @@ export function registerDev(program: Command) {
const unixEpochSecondsNow = dayjs().unix();
console.log(unixEpochSecondsNow);
console.log(
chalk.green(dayjs().utc().format("dddd, MMMM D, YYYY h:mm:ss A")),
green(dayjs().utc().format("dddd, MMMM D, YYYY h:mm:ss A")),
);

// process.exit(0);
Expand Down Expand Up @@ -115,7 +115,7 @@ function registerEpoch(program: Command) {
const date = epochToDate(Number.parseInt(epochTimestamp));
console.log(
`${colorDiffedEpochs[i]} | ${
chalk.yellow(
yellow(
dayjs(date).format("hh:mm A MM-DD-YYYY"),
)
} Local`,
Expand Down Expand Up @@ -162,7 +162,7 @@ function colorDiffEpochs(epochStrings: string[]): string[] {
const rest = num.slice(prefix.length);

// return the string with appropriate coloring (gray for common prefix, white for the rest)
return chalk.gray(prefix) + chalk.white(rest);
return gray(prefix) + white(rest);
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/scale/update.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
type Procurement,
} from "./utils.ts";
import console from "node:console";
import chalk from "chalk";
import { yellow } from "jsr:@std/fmt/colors";

export async function updateProcurement({
procurementId,
Expand Down Expand Up @@ -375,7 +375,7 @@ $ sf scale update <procurement_id...> -p 1.50
.action((id, options) => {
if (Object.keys(options).length === 0) {
console.error(
chalk.yellow(
yellow(
"No options provided. Please provide at least one option.\n",
),
);
Expand Down
68 changes: 34 additions & 34 deletions src/lib/tokens.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Command } from "@commander-js/extra-typings";
import { confirm, input, select } from "@inquirer/prompts";
import chalk from "chalk";
import { gray, green, magenta, red, white } from "jsr:@std/fmt/colors";
import Table from "cli-table3";
import dayjs from "dayjs";
import * as console from "node:console";
Expand Down Expand Up @@ -95,12 +95,12 @@ async function createTokenAction() {

// collect name & description
const name = await input({
message: `Name your token ${chalk.gray("(optional, ↵ to skip)")}:`,
message: `Name your token ${gray("(optional, ↵ to skip)")}:`,
default: "",
});
const description = await input({
message: `Description for your token ${
chalk.gray(
gray(
"(optional, ↵ to skip)",
)
}:`,
Expand Down Expand Up @@ -137,32 +137,32 @@ async function createTokenAction() {

// display token to user
const data = await response.json();
loadingSpinner.succeed(chalk.gray("Access token created 🎉"));
loadingSpinner.succeed(gray("Access token created 🎉"));
// @ts-ignore: Deno has narrower types for fetch responses, but we know this code works atm.
console.log(`${chalk.green(data.token)}\n`);
console.log(`${green(data.token)}\n`);

// tell them they will set this in the Authorization header
console.log(
`${chalk.gray(`Pass this in the 'Authorization' header of API requests:`)}`,
`${gray(`Pass this in the 'Authorization' header of API requests:`)}`,
);
console.log(
[
chalk.gray("{ "),
chalk.white("Authorization"),
chalk.gray(": "),
chalk.green('"Bearer '),
chalk.magenta("<token>"),
chalk.green('"'),
chalk.gray(" }"),
gray("{ "),
white("Authorization"),
gray(": "),
green('"Bearer '),
magenta("<token>"),
green('"'),
gray(" }"),
].join(""),
);
console.log("\n");

// give them a sample curl
const pingUrl = await getApiUrl("ping");
console.log(`${chalk.gray("Here is a sample curl to get your started:")}`);
console.log(`${gray("Here is a sample curl to get your started:")}`);
console.log(
chalk.white(
white(
// @ts-ignore: Deno has narrower types for fetch responses, but we know this code works atm.
`curl --request GET --url ${pingUrl} --header 'Authorization: Bearer ${data.token}'`,
),
Expand All @@ -175,10 +175,10 @@ async function createTokenAction() {
const table = new Table({
colWidths: [20, 30],
});
table.push(["View All Tokens", chalk.magenta(`${base} tokens list`)]);
table.push(["Delete a Token", chalk.magenta(`${base} tokens delete`)]);
table.push(["View All Tokens", magenta(`${base} tokens list`)]);
table.push(["Delete a Token", magenta(`${base} tokens delete`)]);

console.log(`${chalk.gray("And other commands you can try:")}`);
console.log(`${gray("And other commands you can try:")}`);
console.log(table.toString());

process.exit(0);
Expand Down Expand Up @@ -223,7 +223,7 @@ async function listTokensAction() {
// show empty table if no tokens
if (tokens.length === 0) {
const table = new Table({
head: [chalk.gray("Access Tokens")],
head: [gray("Access Tokens")],
colWidths: [50],
});
table.push([
Expand All @@ -234,8 +234,8 @@ async function listTokensAction() {
// prompt user that they can generate one
const base = getCommandBase();
console.log(
`${chalk.gray("Generate your first token with: ")}${
chalk.magenta(
`${gray("Generate your first token with: ")}${
magenta(
`${base} tokens create`,
)
}`,
Expand All @@ -247,19 +247,19 @@ async function listTokensAction() {
// display table
const tokensTable = new Table({
head: [
chalk.gray("Token ID"),
chalk.gray("Name"),
// chalk.gray("Last active"),
chalk.gray("Expires"),
gray("Token ID"),
gray("Name"),
// gray("Last active"),
gray("Expires"),
],
colWidths: [40, 15, 25, 25],
});
for (const token of tokens) {
tokensTable.push([
chalk.gray(token.id),
token.name ? token.name : chalk.gray("(empty)"),
// chalk.green(formatDate(token.last_active_at)),
chalk.white(formatDate(token.expires_at)),
gray(token.id),
token.name ? token.name : gray("(empty)"),
// green(formatDate(token.last_active_at)),
white(formatDate(token.expires_at)),
]);
}
console.log(tokensTable.toString());
Expand Down Expand Up @@ -287,13 +287,13 @@ async function deleteTokenAction({

if (yes) {
await deleteTokenById(id);
console.log(`${chalk.green("✓")} Token deleted successfully`);
console.log(`${green("✓")} Token deleted successfully`);
process.exit(0);
}

const deleteTokenConfirmed = await confirm({
message: `Are you sure you want to delete this token? ${
chalk.gray(
gray(
"(it will stop working immediately.)",
)
}`,
Expand All @@ -303,8 +303,8 @@ async function deleteTokenAction({
process.exit(0);
} else {
const verySureConfirmed = await confirm({
message: `${chalk.red("Very sure?")} ${
chalk.gray(
message: `${red("Very sure?")} ${
gray(
"(just double-checking)",
)
}`,
Expand Down Expand Up @@ -348,7 +348,7 @@ async function deleteTokenById(id: string) {
}

loadingSpinner.stop();
console.log(chalk.gray("Token deleted. 🧼"));
console.log(gray("Token deleted. 🧼"));

process.exit(0);
}