Skip to content

Commit

Permalink
chore(deps): migrate from inquirer to @inquirer/prompts 7.0.0 (#11508)
Browse files Browse the repository at this point in the history
* chore(deps): migrate from inquirer to @inquirer/prompts 5.3.0

* chore(deps): bump @inquirer/prompts from 5.3.0 to 7.0.0
  • Loading branch information
caugner authored Oct 10, 2024
1 parent 70001af commit 98e8f3e
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 186 deletions.
25 changes: 10 additions & 15 deletions build/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import path from "node:path";
import chalk from "chalk";
import cliProgress from "cli-progress";
import caporal from "@caporal/core";
import inquirer from "inquirer";
import { select } from "@inquirer/prompts";

import { Document, slugToFolder, translationsOf } from "../content/index.js";
import {
Expand Down Expand Up @@ -34,7 +34,6 @@ import { ssrDocument } from "./ssr.js";
import { HydrationData } from "../libs/types/hydration.js";

const { program } = caporal;
const { prompt } = inquirer;

export type DocumentBuild = SkippedDocumentBuild | InteractiveDocumentBuild;

Expand Down Expand Up @@ -100,19 +99,15 @@ async function buildDocumentInteractive(
throw e;
}
console.error(e);
const { action } = await prompt<{ action: string }>([
{
type: "list",
message: "What to do?",
name: "action",
choices: [
{ name: "re-run", value: "r" },
{ name: "skip", value: "s" },
{ name: "quit", value: "q" },
],
default: "r",
},
]);
const action = await select({
message: "What to do?",
choices: [
{ name: "re-run", value: "r" },
{ name: "skip", value: "s" },
{ name: "quit", value: "q" },
],
default: "r",
});
if (action === "r") {
return await buildDocumentInteractive(documentPath, interactive, true);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"@codemirror/state": "^6.4.1",
"@codemirror/theme-one-dark": "^6.1.2",
"@fast-csv/parse": "^5.0.0",
"@inquirer/prompts": "^7.0.0",
"@lit/react": "^1.0.6",
"@mdn/bcd-utils-api": "^0.0.7",
"@mdn/browser-compat-data": "^5.6.5",
Expand Down Expand Up @@ -109,7 +110,6 @@
"imagemin-mozjpeg": "^10.0.0",
"imagemin-pngquant": "^10.0.0",
"imagemin-svgo": "^11.0.1",
"inquirer": "^10.0.1",
"is-svg": "^5.1.0",
"js-yaml": "^4.1.0",
"lit": "^3.2.1",
Expand Down
45 changes: 19 additions & 26 deletions tool/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import frontmatter from "front-matter";
import caporal from "@caporal/core";
import chalk from "chalk";
import cliProgress from "cli-progress";
import inquirer from "inquirer";
import { confirm } from "@inquirer/prompts";
import openEditor from "open-editor";
import open from "open";
import log from "loglevel";
Expand Down Expand Up @@ -42,7 +42,6 @@ import {
import { whatsdeployed } from "./whatsdeployed.js";

const { program } = caporal;
const { prompt } = inquirer;

const PORT = parseInt(process.env.SERVER_PORT || "5042");

Expand Down Expand Up @@ -355,14 +354,12 @@ program
)
);
}
const { run } = yes
? { run: true }
: await prompt<{ run: boolean }>({
type: "confirm",
message: "Proceed?",
name: "run",
default: true,
});
const run =
yes ||
(await confirm({
message: "Proceed?",
default: true,
}));
if (run) {
const deletedDocs = await Document.remove(slug, locale, {
recursive,
Expand Down Expand Up @@ -434,14 +431,12 @@ program
.map(([from, to]) => `${chalk.red(from)}${chalk.green(to)}`)
.join("\n")
);
const { run } = yes
? { run: true }
: await prompt<{ run: boolean }>({
type: "confirm",
message: "Proceed?",
name: "run",
default: true,
});
const run =
yes ||
(await confirm({
message: "Proceed?",
default: true,
}));
if (run) {
const moved = await Document.move(oldSlug, newSlug, locale);
console.log(chalk.green(`Moved ${moved.length} documents.`));
Expand Down Expand Up @@ -789,14 +784,12 @@ program
console.log(chalk.green("Found no fixable flaws!"));
return;
}
const { run } = yes
? { run: true }
: await prompt<{ run: boolean }>({
type: "confirm",
message: `Proceed fixing ${flaws} flaws?`,
name: "run",
default: true,
});
const run =
yes ||
(await confirm({
message: `Proceed fixing ${flaws} flaws?`,
default: true,
}));
if (run) {
buildDocument(document, { fixFlaws: true, fixFlawsVerbose: true });
}
Expand Down
Loading

0 comments on commit 98e8f3e

Please sign in to comment.