Skip to content

Commit 0021724

Browse files
committed
chore: update dependencies
1 parent 838b409 commit 0021724

File tree

11 files changed

+1264
-348
lines changed

11 files changed

+1264
-348
lines changed

examples/task/src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ program
3232
.task({
3333
key: "computedFromOtherTaskValues",
3434
label: "Task can also access other persisted task values",
35-
async handler(context) {
35+
handler(context) {
3636
if (context.size > 2000) {
37-
return Promise.resolve("big" as const);
37+
return "big" as const;
3838
}
3939

40-
return Promise.resolve("small" as const);
40+
return "small" as const;
4141
},
4242
})
4343
.task({
@@ -68,7 +68,7 @@ program
6868
.task({
6969
handler(context) {
7070
helpers.message(
71-
`If you don't specify a label, the handler is executed in "live mode" (the output is not hidden by the label and is displayed gradually).`,
71+
'If you don\'t specify a label, the handler is executed in "live mode" (the output is not hidden by the label and is displayed gradually).',
7272
{ label: "Label & console output" },
7373
);
7474

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"release:version": "stack release --tag",
1717
"release:publish": "stack release --publish"
1818
},
19-
"packageManager": "pnpm@9.12.3",
19+
"packageManager": "pnpm@9.13.2",
2020
"engines": {
2121
"node": ">=22.0.0",
2222
"pnpm": ">=9.0.0",
@@ -25,6 +25,6 @@
2525
},
2626
"prettier": "@adbayb/stack/prettier",
2727
"devDependencies": {
28-
"@adbayb/stack": "2.0.0"
28+
"@adbayb/stack": "2.5.0"
2929
}
3030
}

pnpm-lock.yaml

+1,203-283
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

termost/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
"picocolors": "^1.1.1"
5151
},
5252
"devDependencies": {
53-
"@types/node": "22.8.4",
54-
"quickbundle": "2.5.2",
55-
"vitest": "2.1.4"
53+
"@types/node": "22.9.0",
54+
"quickbundle": "2.8.0",
55+
"vitest": "2.1.5"
5656
}
5757
}

termost/src/__snapshots__/index.test.ts.snap

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
exports[`termost > should display \`help\` 1`] = `
44
"
55
USAGE:
6-
[37m[37m[32m[32m@examples/default[32m[37m [...options][37m[39m
6+
[37m[37m[32m[32m@examples/default[32m[37m [options][37m[39m
77

88
DESCRIPTION:
99
Program description placeholder. Program name and version are retrieved from your \`package.json\`. You can override this automatic retrieval by using the \`termost({ name, description, version })\` builder form.
@@ -17,7 +17,7 @@ OPTIONS:
1717
exports[`termost > should display \`help\` 2`] = `
1818
"
1919
USAGE:
20-
[37m[37m[32m[32m@examples/default[32m[37m [...options][37m[39m
20+
[37m[37m[32m[32m@examples/default[32m[37m [options][37m[39m
2121

2222
DESCRIPTION:
2323
Program description placeholder. Program name and version are retrieved from your \`package.json\`. You can override this automatic retrieval by using the \`termost({ name, description, version })\` builder form.
@@ -31,7 +31,7 @@ OPTIONS:
3131
exports[`termost > should display \`help\` given empty command 1`] = `
3232
"
3333
USAGE:
34-
[37m[37m[32m[32m@examples/empty[32m[37m <command> [...options][37m[39m
34+
[37m[37m[32m[32m@examples/empty[32m[37m <command> [options][37m[39m
3535

3636
DESCRIPTION:
3737
Example to showcase empty \`command\` fallback
@@ -48,7 +48,7 @@ OPTIONS:
4848
exports[`termost > should display \`help\` given empty command 2`] = `
4949
"
5050
USAGE:
51-
[37m[37m[32m[32m@examples/empty build[32m[37m [...options][37m[39m
51+
[37m[37m[32m[32m@examples/empty build[32m[37m [options][37m[39m
5252

5353
DESCRIPTION:
5454
Transpile and bundle in production mode
@@ -62,7 +62,7 @@ OPTIONS:
6262
exports[`termost > should display \`help\` given empty command 3`] = `
6363
"
6464
USAGE:
65-
[37m[37m[32m[32m@examples/empty build[32m[37m [...options][37m[39m
65+
[37m[37m[32m[32m@examples/empty build[32m[37m [options][37m[39m
6666

6767
DESCRIPTION:
6868
Transpile and bundle in production mode
@@ -76,7 +76,7 @@ OPTIONS:
7676
exports[`termost > should display \`help\` given empty command 4`] = `
7777
"
7878
USAGE:
79-
[37m[37m[32m[32m@examples/empty watch[32m[37m [...options][37m[39m
79+
[37m[37m[32m[32m@examples/empty watch[32m[37m [options][37m[39m
8080

8181
DESCRIPTION:
8282
Rebuild your assets on any code change
@@ -93,7 +93,7 @@ exports[`termost > should display \`version\` 2`] = `"0.0.0"`;
9393
exports[`termost > should handle \`command\` api 1`] = `
9494
"
9595
USAGE:
96-
[37m[37m[32m[32m@examples/command[32m[37m <command> [...options][37m[39m
96+
[37m[37m[32m[32m@examples/command[32m[37m <command> [options][37m[39m
9797

9898
DESCRIPTION:
9999
Example to showcase the \`command\` API
@@ -177,7 +177,7 @@ exports[`termost > should handle \`command\` api 5`] = `
177177
exports[`termost > should handle \`command\` api 6`] = `
178178
"
179179
USAGE:
180-
[37m[37m[32m[32m@examples/command build[32m[37m [...options][37m[39m
180+
[37m[37m[32m[32m@examples/command build[32m[37m [options][37m[39m
181181

182182
DESCRIPTION:
183183
Transpile and bundle in production mode
@@ -192,7 +192,7 @@ OPTIONS:
192192
exports[`termost > should handle \`command\` api 7`] = `
193193
"
194194
USAGE:
195-
[37m[37m[32m[32m@examples/command watch[32m[37m [...options][37m[39m
195+
[37m[37m[32m[32m@examples/command watch[32m[37m [options][37m[39m
196196

197197
DESCRIPTION:
198198
Rebuild your assets on any code change

termost/src/api/command/command.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ const showHelp = ({
117117
{
118118
color: "green",
119119
},
120-
)} ${hasCommands ? "<command> " : ""}${hasOptions ? "[...options]" : ""}`,
120+
)} ${hasCommands ? "<command> " : ""}${hasOptions ? "[options]" : ""}`,
121121
);
122122

123123
if (description) {

termost/src/api/option/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const createOption =
3939
}
4040
}
4141

42+
// eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
4243
return Promise.resolve({ key, value: value ?? defaultValue });
4344
};
4445
};

termost/src/helpers/process/index.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
import process from "node:process";
22
import { spawn } from "node:child_process";
33

4-
export const exec = async (
5-
command: string,
6-
options: ExecOptions = { hasLiveOutput: false },
7-
) => {
4+
export const exec = async (command: string, options: ExecOptions = {}) => {
5+
const { cwd, hasLiveOutput = false } = options;
6+
87
return new Promise<string>((resolve, reject) => {
98
let stdout = "";
109
let stderr = "";
11-
const [bin, ...args] = command.split(" ") as [string, ...string[]];
10+
const [bin, ...arguments_] = command.split(" ") as [string, ...string[]];
1211

1312
// eslint-disable-next-line sonarjs/os-command
14-
const childProcess = spawn(bin, args, {
15-
cwd: options.cwd,
13+
const childProcess = spawn(bin, arguments_, {
14+
cwd,
1615
env: {
1716
// eslint-disable-next-line n/no-process-env
1817
...process.env,
1918
// @note: make sure to force color display for spawned processes
2019
FORCE_COLOR: "1",
2120
},
2221
shell: true,
23-
stdio: options.hasLiveOutput ? "inherit" : "pipe",
22+
stdio: hasLiveOutput ? "inherit" : "pipe",
2423
});
2524

2625
childProcess.stdout?.on("data", (chunk: string) => {

termost/src/helpers/stdin/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const getArguments = () => {
2929
if (shortFlagMatchResult?.name) {
3030
flushOptimisticOption();
3131

32-
const optionFlags = shortFlagMatchResult.name.split("");
32+
const optionFlags = [...shortFlagMatchResult.name];
3333
const lastIndex = optionFlags.length - 1;
3434

3535
optionFlags.forEach((flag, index) => {

termost/src/helpers/stdout/index.ts

+18-22
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,23 @@ import pico from "picocolors";
1212
*/
1313
export const format = (
1414
message: string,
15-
{
16-
color,
17-
modifiers,
18-
}: {
15+
options: {
1916
color?: Color;
2017
modifiers?: Modifier[];
21-
} = {
22-
color: "white",
23-
modifiers: [],
24-
},
18+
} = {},
2519
) => {
20+
const { color = "white", modifiers = [] } = options;
2621
const transformers: ((input: string) => string)[] = [];
2722

28-
transformers.push(pico[colorMapper[color ?? "white"]]);
23+
transformers.push(pico[colorMapper[color]]);
2924

30-
(modifiers ?? []).forEach((mod: Modifier) => {
31-
if (mod === "uppercase") {
25+
modifiers.forEach((modifier: Modifier) => {
26+
if (modifier === "uppercase") {
3227
message = message.toUpperCase();
33-
} else if (mod === "lowercase") {
28+
} else if (modifier === "lowercase") {
3429
message = message.toLowerCase();
3530
} else {
36-
transformers.push(pico[modifierMapper[mod]]);
31+
transformers.push(pico[modifierMapper[modifier]]);
3732
}
3833
});
3934

@@ -46,29 +41,29 @@ export const format = (
4641
* @param options - The configuration object to define the display type and/or override the default label.
4742
* @param options.label - The label to display.
4843
* @param options.type - The message type.
49-
* @param options.linebreak - Configure line break addition.
50-
* @param options.linebreak.start - Configure line break addition in a start trailing position (by default, true).
51-
* @param options.linebreak.end - Configure line break addition in an end trailing position (by default, false).
44+
* @param options.lineBreakByPosition - Configure line break addition.
45+
* @param options.lineBreakByPosition.start - Configure line break addition in a start trailing position (by default, true).
46+
* @param options.lineBreakByPosition.end - Configure line break addition in an end trailing position (by default, false).
5247
* @example
5348
* message("message to log");
5449
*/
5550
export const message = (
5651
content: Error | string,
5752
{
5853
label: optionLabel,
59-
linebreak: optionLinebreak,
54+
lineBreakByPosition: optionLineBreakByPosition,
6055
type: optionType,
6156
}: {
6257
label?: string | false;
63-
linebreak?: { end: boolean; start: boolean };
58+
lineBreakByPosition?: { end: boolean; start: boolean };
6459
type?: MessageType;
6560
} = {},
6661
) => {
6762
const isTextualContent = typeof content === "string";
6863
const type = optionType ?? (isTextualContent ? "information" : "error");
6964
const { color, defaultLabel, icon, method } = formatPropertiesByType[type];
70-
const linebreakStart = optionLinebreak?.start ?? true;
71-
const linebreakEnd = optionLinebreak?.end ?? false;
65+
const lineBreakStart = optionLineBreakByPosition?.start ?? true;
66+
const lineBreakEnd = optionLineBreakByPosition?.end ?? false;
7267

7368
const getLabel = () => {
7469
if (optionLabel === false) {
@@ -80,7 +75,7 @@ export const message = (
8075

8176
method(
8277
format(
83-
`${linebreakStart ? "\n" : ""}${icon} ${getLabel()}${linebreakEnd ? "\n" : ""}`,
78+
`${lineBreakStart ? "\n" : ""}${icon} ${getLabel()}${lineBreakEnd ? "\n" : ""}`,
8479
{
8580
color,
8681
modifiers: ["bold"],
@@ -99,7 +94,8 @@ const compose = <T>(...fns: ((a: T) => T)[]) => {
9994
);
10095

10196
return fns.reduce<(a: T) => T>(
102-
(prevFn, nextFn) => (value) => prevFn(nextFn(value)),
97+
(previousFunction, nextFunction) => (value) =>
98+
previousFunction(nextFunction(value)),
10399
fns[0],
104100
);
105101
};

termost/src/termost.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ export type Termost<Values extends ObjectLikeConstraint = EmptyObject> = {
3131
* @returns The Command API.
3232
*/
3333
command: <CommandValues extends ObjectLikeConstraint = EmptyObject>(
34-
params: CommandParameters,
34+
parameters: CommandParameters,
3535
) => Termost<CommandValues & Values>;
3636
input: <Key extends keyof Values>(
37-
params: InputParameters<Values, Key>,
37+
parameters: InputParameters<Values, Key>,
3838
) => Termost<Values>;
3939
option: <Key extends keyof Values>(
40-
params: OptionParameters<Values, Key>,
40+
parameters: OptionParameters<Values, Key>,
4141
) => Termost<Values>;
4242
task: <Key extends keyof Values | undefined = undefined>(
43-
params: TaskParameters<Values, Key>,
43+
parameters: TaskParameters<Values, Key>,
4444
) => Termost<Values>;
4545
};
4646

@@ -75,13 +75,13 @@ export const createProgram = <Values extends ObjectLikeConstraint>(
7575
Parameters extends InstructionParameters<ObjectLikeConstraint>,
7676
>(
7777
factory: CreateInstruction<Parameters>,
78-
params: InstructionParameters<Values>,
78+
parameters: InstructionParameters<Values>,
7979
) => {
80-
const instruction = factory(params as Parameters);
80+
const instruction = factory(parameters as Parameters);
8181
const controller = getCommandController<Values>(currentCommandName);
8282

8383
controller.addInstruction(async () => {
84-
const { skip } = params;
84+
const { skip } = parameters;
8585
const context = controller.getContext(rootCommandName);
8686

8787
if (skip?.(context, argv)) return;
@@ -95,28 +95,28 @@ export const createProgram = <Values extends ObjectLikeConstraint>(
9595
};
9696

9797
const program: Termost<Values> = {
98-
command<CommandValues>(params: CommandParameters) {
99-
currentCommandName = createCommand(params, metadata);
98+
command<CommandValues>(parameters: CommandParameters) {
99+
currentCommandName = createCommand(parameters, metadata);
100100
metadata.isEmptyCommand[currentCommandName] = true; // This flag is disabled only for instructions that introduce stdio side effects (`option` instructions are so ignored).
101101

102102
return this as Termost<CommandValues & Values>;
103103
},
104-
input(params) {
105-
createInstruction(createInput, params);
104+
input(parameters) {
105+
createInstruction(createInput, parameters);
106106
metadata.isEmptyCommand[currentCommandName] = false;
107107

108108
return this;
109109
},
110-
option(params) {
110+
option(parameters) {
111111
createInstruction(
112112
createOption(getCommandController(currentCommandName), metadata),
113-
params,
113+
parameters,
114114
);
115115

116116
return this;
117117
},
118-
task(params) {
119-
createInstruction(createTask, params);
118+
task(parameters) {
119+
createInstruction(createTask, parameters);
120120
metadata.isEmptyCommand[currentCommandName] = false;
121121

122122
return this;

0 commit comments

Comments
 (0)