toolcraft-openapi 0.0.19 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -58,7 +58,7 @@ export type SpinnerOptions = {
|
|
|
58
58
|
message: (message?: string) => void;
|
|
59
59
|
};
|
|
60
60
|
export interface WithSpinnerOptions<T> {
|
|
61
|
-
message: string;
|
|
61
|
+
message: string | (() => string);
|
|
62
62
|
fn: () => Promise<T>;
|
|
63
63
|
stopMessage?: (result: T) => string;
|
|
64
64
|
subtext?: (result: T) => string | undefined;
|
|
@@ -80,6 +80,7 @@ function formatElapsed(ms) {
|
|
|
80
80
|
}
|
|
81
81
|
export async function withSpinner(options) {
|
|
82
82
|
const { message, fn, stopMessage, subtext } = options;
|
|
83
|
+
const readMessage = () => (typeof message === "function" ? message() : message);
|
|
83
84
|
if (resolveOutputFormat() === "json") {
|
|
84
85
|
const result = await fn();
|
|
85
86
|
const sub = subtext ? subtext(result) : undefined;
|
|
@@ -106,9 +107,9 @@ export async function withSpinner(options) {
|
|
|
106
107
|
}
|
|
107
108
|
const s = spinner();
|
|
108
109
|
const start = Date.now();
|
|
109
|
-
s.start(
|
|
110
|
+
s.start(readMessage());
|
|
110
111
|
const timer = setInterval(() => {
|
|
111
|
-
s.message(`${
|
|
112
|
+
s.message(`${readMessage()} [${formatElapsed(Date.now() - start)}]`);
|
|
112
113
|
}, 1000);
|
|
113
114
|
try {
|
|
114
115
|
const result = await fn();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toolcraft-openapi",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@clack/prompts": "^1.0.0",
|
|
33
33
|
"@poe-code/design-system": "^0.0.2",
|
|
34
34
|
"auth-store": "^0.0.1",
|
|
35
|
-
"toolcraft": "^0.0.
|
|
35
|
+
"toolcraft": "^0.0.20",
|
|
36
36
|
"yaml": "^2.8.2"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|