Skip to content

Commit

Permalink
fix(cli, pastel-cli): fix formatting in cli and pastel-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
F-Kublin committed Oct 10, 2024
1 parent 1e50a2a commit b6180df
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 89 deletions.
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@
"node": ">=20"
},
"packageManager": "npm@10.8.2",
"workspaces": [
"packages/*",
"tooling/*"
],
"workspaces": ["packages/*", "tooling/*"],
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commander/handler.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const handler = (
str: string,
options: { first?: true | undefined; separator: string }
options: { first?: true | undefined; separator: string },
) => {
const limit = options.first ? 1 : undefined;
const output = str
.split(options.separator, limit)
.reduce(
(acc: Record<string, number>, curr, index) => ((acc[curr] = index), acc),
{}
{},
);
console.log(output);
};
Expand Down
106 changes: 51 additions & 55 deletions packages/pastel-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,57 +1,53 @@
{
"name": "pastel-cli",
"version": "0.0.0",
"license": "MIT",
"bin": "dist/cli.js",
"type": "module",
"engines": {
"node": ">=16"
},
"scripts": {
"build": "tsc",
"dev": "tsc --watch",
"test": "prettier --check . && xo && ava",
"cli": "tsx source/cli.tsx"
},
"files": [
"dist"
],
"dependencies": {
"ink": "^4.1.0",
"pastel": "^2.0.0",
"react": "^18.2.0",
"zod": "^3.21.4"
},
"devDependencies": {
"@sindresorhus/tsconfig": "^3.0.1",
"@types/react": "^18.0.32",
"@vdemedes/prettier-config": "^2.0.1",
"ava": "^5.2.0",
"chalk": "^5.2.0",
"eslint-config-xo-react": "^0.27.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"ink-testing-library": "^3.0.0",
"prettier": "^2.8.7",
"ts-node": "^10.9.1",
"typescript": "^5.0.3",
"xo": "^0.54.2"
},
"ava": {
"extensions": {
"ts": "module",
"tsx": "module"
},
"nodeArguments": [
"--loader=ts-node/esm"
]
},
"xo": {
"extends": "xo-react",
"prettier": true,
"rules": {
"react/prop-types": "off"
}
},
"prettier": "@vdemedes/prettier-config"
"name": "pastel-cli",
"version": "0.0.0",
"license": "MIT",
"bin": "dist/cli.js",
"type": "module",
"engines": {
"node": ">=16"
},
"scripts": {
"build": "tsc",
"dev": "tsc --watch",
"test": "prettier --check . && xo && ava",
"cli": "tsx source/cli.tsx"
},
"files": ["dist"],
"dependencies": {
"ink": "^4.1.0",
"pastel": "^2.0.0",
"react": "^18.2.0",
"zod": "^3.21.4"
},
"devDependencies": {
"@sindresorhus/tsconfig": "^3.0.1",
"@types/react": "^18.0.32",
"@vdemedes/prettier-config": "^2.0.1",
"ava": "^5.2.0",
"chalk": "^5.2.0",
"eslint-config-xo-react": "^0.27.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"ink-testing-library": "^3.0.0",
"prettier": "^2.8.7",
"ts-node": "^10.9.1",
"typescript": "^5.0.3",
"xo": "^0.54.2"
},
"ava": {
"extensions": {
"ts": "module",
"tsx": "module"
},
"nodeArguments": ["--loader=ts-node/esm"]
},
"xo": {
"extends": "xo-react",
"prettier": true,
"rules": {
"react/prop-types": "off"
}
},
"prettier": "@vdemedes/prettier-config"
}
4 changes: 2 additions & 2 deletions packages/pastel-cli/source/cli.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env node
import Pastel from 'pastel';
import Pastel from "pastel";

const app = new Pastel({
importMeta: import.meta,
importMeta: import.meta,
});

await app.run();
22 changes: 11 additions & 11 deletions packages/pastel-cli/source/commands/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React from 'react';
import {Text} from 'ink';
import zod from 'zod';
import { Text } from "ink";
import React from "react";
import zod from "zod";

export const options = zod.object({
name: zod.string().default('Stranger').describe('Name'),
name: zod.string().default("Stranger").describe("Name"),
});

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

export default function Index({options}: Props) {
return (
<Text>
Hello, <Text color="green">{options.name}</Text>
</Text>
);
export default function Index({ options }: Props) {
return (
<Text>
Hello, <Text color="green">{options.name}</Text>
</Text>
);
}
16 changes: 8 additions & 8 deletions packages/pastel-cli/test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import chalk from 'chalk';
import test from 'ava';
import {render} from 'ink-testing-library';
import Index from './source/commands/index.js';
import test from "ava";
import chalk from "chalk";
import { render } from "ink-testing-library";
import React from "react";
import Index from "./source/commands/index.js";

test('greet user', t => {
const {lastFrame} = render(<Index options={{name: 'Jane'}} />);
test("greet user", (t) => {
const { lastFrame } = render(<Index options={{ name: "Jane" }} />);

t.is(lastFrame(), `Hello, ${chalk.green('Jane')}`);
t.is(lastFrame(), `Hello, ${chalk.green("Jane")}`);
});
14 changes: 7 additions & 7 deletions packages/pastel-cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"extends": "@sindresorhus/tsconfig",
"compilerOptions": {
"moduleResolution": "node16",
"module": "Node16",
"outDir": "dist"
},
"include": ["source"]
"extends": "@sindresorhus/tsconfig",
"compilerOptions": {
"moduleResolution": "node16",
"module": "Node16",
"outDir": "dist"
},
"include": ["source"]
}

0 comments on commit b6180df

Please sign in to comment.