Skip to content

Commit

Permalink
feat: optimize list command log and default option (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
winchesHe committed Apr 8, 2024
1 parent 1652b0c commit 148bb50
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 92 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"lint-staged": "14.0.1",
"tsup": "7.2.0",
"tsx": "4.7.1",
"typescript": "5.2.2"
"typescript": "5.4.4"
},
"engines": {
"pnpm": ">=8.x",
Expand Down
92 changes: 46 additions & 46 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/actions/list-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import {type NextUIComponents, nextUIComponents} from '../../src/constants/compo
import {resolver} from '../../src/constants/path';

interface ListActionOptions {
current?: boolean;
remote?: boolean;
packagePath?: string;
}

export async function listAction(options: ListActionOptions) {
const {current, packagePath = resolver('package.json')} = options;
const {packagePath = resolver('package.json'), remote = false} = options;

let components = nextUIComponents as NextUIComponents;

try {
/** ======================== Get the installed components ======================== */
if (current) {
if (!remote) {
const {currentComponents} = await getPackageInfo(packagePath);

components = currentComponents;
Expand All @@ -32,7 +32,7 @@ export async function listAction(options: ListActionOptions) {
}

/** ======================== Output the components ======================== */
current ? outputComponents(components) : outputComponents(components, 'list');
remote ? outputComponents(components, 'list') : outputComponents(components);
} catch (error) {
Logger.prefix('error', `Error occurred while listing the components: ${error}`);
}
Expand Down
3 changes: 2 additions & 1 deletion src/constants/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export const orderNextUIComponentKeys = ['package', 'version', 'status', 'docs']

export const colorNextUIComponentKeys = ['package', 'version', 'status'];

export type NextUIComponentStatus = 'stable' | 'updated' | 'newPost';
// eslint-disable-next-line @typescript-eslint/ban-types
export type NextUIComponentStatus = 'stable' | 'updated' | 'new' | (string & {});

type NextUIComponent = (typeof nextUIComponents)[0];

Expand Down
Loading

0 comments on commit 148bb50

Please sign in to comment.