From 4b880b19593e65aaa582b417d4cc4e99eaef13f5 Mon Sep 17 00:00:00 2001 From: m0nch1 Date: Wed, 17 Apr 2024 00:07:06 +0900 Subject: [PATCH 1/4] fix: examples --- examples/prompt.ts | 6 ++++-- examples/spinner.ts | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/prompt.ts b/examples/prompt.ts index 1764f1ed..c8887cda 100755 --- a/examples/prompt.ts +++ b/examples/prompt.ts @@ -1,4 +1,5 @@ import { consola } from "./utils"; +import { spinner } from "../src/utils/prompt"; async function main() { const name = await consola.prompt("What is your name?", { @@ -31,9 +32,10 @@ async function main() { initial: ["eslint", "prettier"], }); - consola.start("Creating project..."); + const s = spinner(); + s.start("Creating project..."); await new Promise((resolve) => setTimeout(resolve, 1000)); - consola.success("Project created!"); + s.stop("Project created!"); } main(); diff --git a/examples/spinner.ts b/examples/spinner.ts index d75ccc88..eb229498 100755 --- a/examples/spinner.ts +++ b/examples/spinner.ts @@ -1,9 +1,10 @@ -import { consola } from "./utils"; +import { spinner } from "../src/utils/prompt"; async function main() { - consola.start("Creating project..."); + const s = spinner(); + s.start("Creating project..."); await new Promise((resolve) => setTimeout(resolve, 1000)); - consola.success("Project created!"); + s.stop("Project created!"); } main(); From 7c731bf292927bb07540423aa8ffa6c566f19a2f Mon Sep 17 00:00:00 2001 From: m0nch1 Date: Wed, 17 Apr 2024 23:41:22 +0900 Subject: [PATCH 2/4] fix: export spinner from utils prompt --- README.md | 1 + examples/prompt.ts | 2 +- src/utils.ts | 1 + src/utils/prompt.ts | 2 -- 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fcd86c2d..d7d3e989 100644 --- a/README.md +++ b/README.md @@ -308,6 +308,7 @@ import { colors, getColor, colorize, + spinner, } from "consola/utils"; // CommonJS diff --git a/examples/prompt.ts b/examples/prompt.ts index c8887cda..fa2d97d8 100755 --- a/examples/prompt.ts +++ b/examples/prompt.ts @@ -1,5 +1,5 @@ -import { consola } from "./utils"; import { spinner } from "../src/utils/prompt"; +import { consola } from "./utils"; async function main() { const name = await consola.prompt("What is your name?", { diff --git a/src/utils.ts b/src/utils.ts index 582caca0..59bed74c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -7,3 +7,4 @@ export { leftAlign, align, } from "./utils/string"; +export { spinner } from "./utils/prompt"; diff --git a/src/utils/prompt.ts b/src/utils/prompt.ts index bb708d0d..60f37cb6 100644 --- a/src/utils/prompt.ts +++ b/src/utils/prompt.ts @@ -23,8 +23,6 @@ import { cursor, erase } from "sisteransi"; import { colors as color } from "./color"; -export { isCancel } from "@clack/core"; - const unicode = isUnicodeSupported(); /** * Checks if the environment supports Unicode and selects symbols accordingly. From 23f861120f9b77b236c271e30ae83f242fa48a58 Mon Sep 17 00:00:00 2001 From: m0nch1 Date: Thu, 18 Apr 2024 12:37:51 +0900 Subject: [PATCH 3/4] refactor --- examples/prompt.ts | 8 ++++---- examples/spinner.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/prompt.ts b/examples/prompt.ts index fa2d97d8..d1997c07 100755 --- a/examples/prompt.ts +++ b/examples/prompt.ts @@ -1,4 +1,4 @@ -import { spinner } from "../src/utils/prompt"; +import { spinner } from "../src/utils"; import { consola } from "./utils"; async function main() { @@ -32,10 +32,10 @@ async function main() { initial: ["eslint", "prettier"], }); - const s = spinner(); - s.start("Creating project..."); + const spin = spinner(); + spin.start("Creating project..."); await new Promise((resolve) => setTimeout(resolve, 1000)); - s.stop("Project created!"); + spin.stop("Project created!"); } main(); diff --git a/examples/spinner.ts b/examples/spinner.ts index eb229498..292f917b 100755 --- a/examples/spinner.ts +++ b/examples/spinner.ts @@ -1,10 +1,10 @@ -import { spinner } from "../src/utils/prompt"; +import { spinner } from "../src/utils"; async function main() { - const s = spinner(); - s.start("Creating project..."); + const spin = spinner(); + spin.start("Creating project..."); await new Promise((resolve) => setTimeout(resolve, 1000)); - s.stop("Project created!"); + spin.stop("Project created!"); } main(); From 64010a3bf96ecfdb5a35281fcbd24d4d41c87d8e Mon Sep 17 00:00:00 2001 From: m0nch1 Date: Thu, 18 Apr 2024 12:38:05 +0900 Subject: [PATCH 4/4] fix:come back export isCancel --- package.json | 6 ++++-- pnpm-lock.yaml | 3 ++- src/utils/prompt.ts | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 28b1b0ec..d212e4b8 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,6 @@ "test": "pnpm lint && pnpm vitest run --coverage" }, "devDependencies": { - "@clack/core": "^0.3.4", "@types/node": "^20.14.2", "@vitest/coverage-v8": "^1.6.0", "changelogen": "^0.5.5", @@ -100,5 +99,8 @@ "engines": { "node": "^14.18.0 || >=16.10.0" }, - "packageManager": "pnpm@9.3.0" + "packageManager": "pnpm@9.3.0", + "dependencies": { + "@clack/core": "^0.3.4" + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6445ecf2..298d4f34 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,10 +7,11 @@ settings: importers: .: - devDependencies: + dependencies: '@clack/core': specifier: ^0.3.4 version: 0.3.4 + devDependencies: '@types/node': specifier: ^20.14.2 version: 20.14.2 diff --git a/src/utils/prompt.ts b/src/utils/prompt.ts index 60f37cb6..bb708d0d 100644 --- a/src/utils/prompt.ts +++ b/src/utils/prompt.ts @@ -23,6 +23,8 @@ import { cursor, erase } from "sisteransi"; import { colors as color } from "./color"; +export { isCancel } from "@clack/core"; + const unicode = isUnicodeSupported(); /** * Checks if the environment supports Unicode and selects symbols accordingly.