Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jun 6, 2024
1 parent c357d3d commit 8445781
Show file tree
Hide file tree
Showing 88 changed files with 201 additions and 210 deletions.
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

41 changes: 21 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,30 @@
"cli-framework"
],
"dependencies": {
"@inkjs/ui": "^1.0.0",
"commander": "^10.0.1",
"@inkjs/ui": "^2.0.0",
"commander": "^12.1.0",
"decamelize": "^6.0.0",
"just-flatten-it": "^5.2.0",
"plur": "^5.1.0",
"read-pkg-up": "^9.1.0",
"zod-validation-error": "^1.3.0"
"read-package-up": "^11.0.0",
"zod-validation-error": "^3.3.0"
},
"devDependencies": {
"@sindresorhus/tsconfig": "^3.0.1",
"@types/react": "^18.2.6",
"@types/yargs": "^17.0.24",
"@sindresorhus/tsconfig": "^5.0.0",
"@types/react": "^18.3.3",
"@types/yargs": "^17.0.32",
"@vdemedes/prettier-config": "^2.0.1",
"ava": "^5.2.0",
"ava": "^6.1.3",
"eslint-config-xo-react": "^0.27.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"execa": "^7.1.1",
"ink": "^4.2.0",
"prettier": "^2.8.8",
"react": "^18.2.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.4",
"xo": "^0.54.2",
"zod": "^3.21.4"
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-react-hooks": "^4.6.2",
"execa": "^9.1.0",
"ink": "^5.0.1",
"prettier": "^3.3.1",
"react": "^18.3.1",
"ts-node": "^10.9.2",
"typescript": "^5.4.5",
"xo": "^0.58.0",
"zod": "^3.23.8"
},
"peerDependencies": {
"ink": ">=5.0.0",
Expand All @@ -79,7 +78,9 @@
"prettier": true,
"rules": {
"react/prop-types": "off",
"no-await-in-loop": "off"
"no-await-in-loop": "off",
"unicorn/prevent-abbreviations": "off",
"@typescript-eslint/no-unsafe-assignment": "off"
},
"overrides": [
{
Expand Down
12 changes: 6 additions & 6 deletions source/generate-arguments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const getConfig = (
return value?.startsWith('__pastel_argument_config__')
? (JSON.parse(
value.replace('__pastel_argument_config__', ''),
) as CommandArgumentConfig)
) as CommandArgumentConfig)
: undefined;
};

Expand Down Expand Up @@ -66,7 +66,7 @@ export default function generateArguments(
arrayName = argumentsSchema.description ?? arrayName;
}

const args: Argument[] = [];
const arguments_: Argument[] = [];

if (argumentsSchema instanceof ZodTuple) {
for (let argumentSchema of argumentsSchema._def.items) {
Expand Down Expand Up @@ -116,7 +116,7 @@ export default function generateArguments(
argument.default(defaultValue, defaultValueDescription);
}

args.push(argument);
arguments_.push(argument);
}

const restSchema = argumentsSchema._def.rest;
Expand All @@ -135,7 +135,7 @@ export default function generateArguments(
argument.choices(restSchema._def.values);
}

args.push(argument);
arguments_.push(argument);
}
}

Expand Down Expand Up @@ -164,8 +164,8 @@ export default function generateArguments(
});
}

args.push(argument);
arguments_.push(argument);
}

return args;
return arguments_;
}
13 changes: 6 additions & 7 deletions source/generate-command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {render} from 'ink';
import React, {type ComponentType} from 'react';
import {StatusMessage} from '@inkjs/ui';
import {fromZodError} from 'zod-validation-error';
import flatten from 'just-flatten-it';
import {type Command} from './internal-types.js';
import generateOptions from './generate-options.js';
import generateArguments from './generate-arguments.js';
Expand Down Expand Up @@ -40,9 +39,9 @@ const generateCommand = (
const argumentsSchema = pastelCommand.args;

if (argumentsSchema) {
const args = generateArguments(argumentsSchema);
const arguments_ = generateArguments(argumentsSchema);

for (const argument of args) {
for (const argument of arguments_) {
if (argument.variadic) {
hasVariadicArgument = true;
}
Expand Down Expand Up @@ -84,15 +83,15 @@ const generateCommand = (
}
}

let args: unknown[] = [];
let arguments_: unknown[] = [];

if (pastelCommand.args) {
const result = pastelCommand.args.safeParse(
hasVariadicArgument ? flatten(input) : input,
hasVariadicArgument ? input.flat() : input,
);

if (result.success) {
args = result.data ?? [];
arguments_ = result.data ?? [];
} else {
render(
<StatusMessage variant="error">
Expand All @@ -116,7 +115,7 @@ const generateCommand = (
Component: component,
commandProps: {
options: parsedOptions,
args,
args: arguments_,
},
}),
);
Expand Down
6 changes: 2 additions & 4 deletions source/generate-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const getConfig = (
return value?.startsWith('__pastel_option_config__')
? (JSON.parse(
value.replace('__pastel_option_config__', ''),
) as CommandOptionConfig)
) as CommandOptionConfig)
: undefined;
};

Expand Down Expand Up @@ -101,9 +101,7 @@ export default function generateOptions(
const isVariadic =
optionSchema instanceof ZodArray || optionSchema instanceof ZodSet;

if (!valueDescription) {
valueDescription = isVariadic ? plur(name) : name;
}
valueDescription ||= isVariadic ? plur(name) : name;

const rest = isVariadic ? '...' : '';

Expand Down
8 changes: 4 additions & 4 deletions source/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {fileURLToPath} from 'node:url';
import process from 'node:process';
import {Command} from 'commander';
import {readPackageUp} from 'read-pkg-up';
import {readPackageUp} from 'read-package-up';
import generateCommand from './generate-command.js';
import readCommands from './read-commands.js';
import generateCommands from './generate-commands.js';
Expand Down Expand Up @@ -59,9 +59,9 @@ export default class Pastel {
program.name(this.options.name);
}

const pkg = await readPackageUp();
const package_ = await readPackageUp();

const version = this.options.version ?? pkg?.packageJson.version;
const version = this.options.version ?? package_?.packageJson.version;

if (version) {
program.version(version, '-v, --version', 'Show version number');
Expand All @@ -70,7 +70,7 @@ export default class Pastel {
const description =
indexCommand?.description ??
this.options.description ??
pkg?.packageJson.description ??
package_?.packageJson.description ??
'';

program.description(description);
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/all-optional-options/commands/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ export const options = zod
})
.partial();

type Props = {
type Properties = {
readonly options: zod.infer<typeof options>;
};

export default function Index({options}: Props) {
export default function Index({options}: Properties) {
return <Text>Name = {options.name ?? 'empty'}</Text>;
}
4 changes: 2 additions & 2 deletions test/fixtures/array-option/alias/commands/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export const options = zod.object({
),
});

type Props = {
type Properties = {
readonly options: zod.infer<typeof options>;
};

export default function Index({options}: Props) {
export default function Index({options}: Properties) {
return <Text>Tags = {options.tag.join(', ')}</Text>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export const options = zod.object({
),
});

type Props = {
type Properties = {
readonly options: zod.infer<typeof options>;
};

export default function Index({options}: Props) {
export default function Index({options}: Properties) {
return <Text>Tags = {options.tag.join(', ')}</Text>;
}
4 changes: 2 additions & 2 deletions test/fixtures/array-option/default-value/commands/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export const options = zod.object({
tag: zod.array(zod.string()).default(['A', 'B']).describe('Tags'),
});

type Props = {
type Properties = {
readonly options: zod.infer<typeof options>;
};

export default function Index({options}: Props) {
export default function Index({options}: Properties) {
return <Text>Tags = {options.tag.join(', ')}</Text>;
}
4 changes: 2 additions & 2 deletions test/fixtures/array-option/description/commands/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export const options = zod.object({
),
});

type Props = {
type Properties = {
readonly options: zod.infer<typeof options>;
};

export default function Index({options}: Props) {
export default function Index({options}: Properties) {
return <Text>Tags = {options.tag.join(', ')}</Text>;
}
4 changes: 2 additions & 2 deletions test/fixtures/array-option/optional/commands/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export const options = zod.object({
tag: zod.array(zod.string()).optional().describe('Tags'),
});

type Props = {
type Properties = {
readonly options: zod.infer<typeof options>;
};

export default function Index({options}: Props) {
export default function Index({options}: Properties) {
return <Text>Tags = {options.tag?.join(', ')}</Text>;
}
4 changes: 2 additions & 2 deletions test/fixtures/array-option/required/commands/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export const options = zod.object({
tag: zod.array(zod.string()).describe('Tags'),
});

type Props = {
type Properties = {
readonly options: zod.infer<typeof options>;
};

export default function Index({options}: Props) {
export default function Index({options}: Properties) {
return <Text>Tags = {options.tag.join(', ')}</Text>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export const options = zod.object({
),
});

type Props = {
type Properties = {
readonly options: zod.infer<typeof options>;
};

export default function Index({options}: Props) {
export default function Index({options}: Properties) {
return <Text>Tags = {options.tag.join(', ')}</Text>;
}
4 changes: 2 additions & 2 deletions test/fixtures/boolean-option/alias/commands/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export const options = zod.object({
),
});

type Props = {
type Properties = {
readonly options: zod.infer<typeof options>;
};

export default function Index({options}: Props) {
export default function Index({options}: Properties) {
return <Text>Force = {String(options.force)}</Text>;
}
4 changes: 2 additions & 2 deletions test/fixtures/boolean-option/default-value/commands/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export const options = zod.object({
force: zod.boolean().default(true).describe('Force'),
});

type Props = {
type Properties = {
readonly options: zod.infer<typeof options>;
};

export default function Index({options}: Props) {
export default function Index({options}: Properties) {
return <Text>Force = {String(options.force)}</Text>;
}
4 changes: 2 additions & 2 deletions test/fixtures/boolean-option/default/commands/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export const options = zod.object({
force: zod.boolean().describe('Force'),
});

type Props = {
type Properties = {
readonly options: zod.infer<typeof options>;
};

export default function Index({options}: Props) {
export default function Index({options}: Properties) {
return <Text>Force = {String(options.force)}</Text>;
}
4 changes: 2 additions & 2 deletions test/fixtures/boolean-option/description/commands/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export const options = zod.object({
),
});

type Props = {
type Properties = {
readonly options: zod.infer<typeof options>;
};

export default function Index({options}: Props) {
export default function Index({options}: Properties) {
return <Text>Force = {String(options.force)}</Text>;
}
4 changes: 2 additions & 2 deletions test/fixtures/boolean-option/negated/commands/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export const options = zod.object({
force: zod.boolean().default(true).describe("Don't force"),
});

type Props = {
type Properties = {
readonly options: zod.infer<typeof options>;
};

export default function Index({options}: Props) {
export default function Index({options}: Properties) {
return <Text>Force = {String(options.force)}</Text>;
}
4 changes: 2 additions & 2 deletions test/fixtures/camelcase-argument/commands/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import zod from 'zod';

export const args = zod.tuple([zod.string().describe('firstName')]);

type Props = {
type Properties = {
readonly args: zod.infer<typeof args>;
};

export default function Index({args}: Props) {
export default function Index({args}: Properties) {
return <Text>Arguments = {args.join(', ')}</Text>;
}
Loading

0 comments on commit 8445781

Please sign in to comment.