diff --git a/.prettierrc b/.prettierrc index fa9843a..6f71de2 100644 --- a/.prettierrc +++ b/.prettierrc @@ -6,7 +6,7 @@ "useTabs": false, "singleQuote": true, "editorconfig": true, - "bracketSpacing": true, + "bracketSpacing": false, "jsxSingleQuote": false, "bracketSameLine": false, "pluginSearchDirs": false, diff --git a/src/actions/doctor-action.ts b/src/actions/doctor-action.ts index 7480ad3..bd08b12 100644 --- a/src/actions/doctor-action.ts +++ b/src/actions/doctor-action.ts @@ -1,11 +1,11 @@ import chalk from 'chalk'; -import { checkApp, checkRequiredContentInstalled, checkTailwind } from '@helpers/check'; -import { Logger, type PrefixLogType } from '@helpers/logger'; -import { getPackageInfo } from '@helpers/package'; -import { findFiles } from '@helpers/utils'; -import { resolver } from 'src/constants/path'; -import { DOCS_APP_SETUP, DOCS_INSTALLED, DOCS_TAILWINDCSS_SETUP } from 'src/constants/required'; +import {checkApp, checkRequiredContentInstalled, checkTailwind} from '@helpers/check'; +import {Logger, type PrefixLogType} from '@helpers/logger'; +import {getPackageInfo} from '@helpers/package'; +import {findFiles} from '@helpers/utils'; +import {resolver} from 'src/constants/path'; +import {DOCS_APP_SETUP, DOCS_INSTALLED, DOCS_TAILWINDCSS_SETUP} from 'src/constants/required'; interface DoctorActionOptions { packagePath?: string; @@ -27,7 +27,7 @@ export async function doctorAction(options: DoctorActionOptions) { } = options; const tailwindPaths = [tailwindPath].flat(); - const { allDependenciesKeys, currentComponents, isAllComponents } = + const {allDependenciesKeys, currentComponents, isAllComponents} = await getPackageInfo(packagePath); /** ======================== Output when there is no components installed ======================== */ diff --git a/src/actions/env-action.ts b/src/actions/env-action.ts index 0de859f..5b83208 100644 --- a/src/actions/env-action.ts +++ b/src/actions/env-action.ts @@ -1,15 +1,15 @@ -import { outputComponents, outputInfo } from '@helpers/output-info'; -import { getPackageInfo } from '@helpers/package'; -import { resolver } from 'src/constants/path'; +import {outputComponents, outputInfo} from '@helpers/output-info'; +import {getPackageInfo} from '@helpers/package'; +import {resolver} from 'src/constants/path'; interface EnvActionOptions { packagePath?: string; } export async function envAction(options: EnvActionOptions) { - const { packagePath = resolver('package.json') } = options; + const {packagePath = resolver('package.json')} = options; - const { currentComponents } = await getPackageInfo(packagePath); + const {currentComponents} = await getPackageInfo(packagePath); /** ======================== Output the current components ======================== */ outputComponents(currentComponents); diff --git a/src/actions/init-action.ts b/src/actions/init-action.ts index d65167b..458e476 100644 --- a/src/actions/init-action.ts +++ b/src/actions/init-action.ts @@ -1,14 +1,14 @@ -import { rename } from 'fs'; +import {rename} from 'fs'; import chalk from 'chalk'; -import { oraPromise } from 'ora'; +import {oraPromise} from 'ora'; -import { downloadTemplate } from '@helpers/fetch'; -import { Logger } from '@helpers/logger'; +import {downloadTemplate} from '@helpers/fetch'; +import {Logger} from '@helpers/logger'; -import { ROOT } from '../../src/constants/path'; -import { APP_DIR, APP_REPO, PAGES_DIR, PAGES_REPO } from '../../src/constants/templates'; -import { getSelect } from '../../src/prompts'; +import {ROOT} from '../../src/constants/path'; +import {APP_DIR, APP_REPO, PAGES_DIR, PAGES_REPO} from '../../src/constants/templates'; +import {getSelect} from '../../src/prompts'; export interface InitActionOptions { template?: 'app' | 'pages'; @@ -16,7 +16,7 @@ export interface InitActionOptions { } export async function initAction(projectName: string, options: InitActionOptions) { - let { package: packageName, template } = options; + let {package: packageName, template} = options; if (!template) { template = await getSelect('Select a template', [ diff --git a/src/actions/list-action.ts b/src/actions/list-action.ts index 97ff412..8d1b7b3 100644 --- a/src/actions/list-action.ts +++ b/src/actions/list-action.ts @@ -1,9 +1,9 @@ -import { Logger } from '@helpers/logger'; -import { outputComponents } from '@helpers/output-info'; -import { getPackageInfo } from '@helpers/package'; +import {Logger} from '@helpers/logger'; +import {outputComponents} from '@helpers/output-info'; +import {getPackageInfo} from '@helpers/package'; -import { type NextUIComponents, nextUIComponents } from '../../src/constants/component'; -import { resolver } from '../../src/constants/path'; +import {type NextUIComponents, nextUIComponents} from '../../src/constants/component'; +import {resolver} from '../../src/constants/path'; interface ListActionOptions { current?: boolean; @@ -11,14 +11,14 @@ interface ListActionOptions { } export async function listAction(options: ListActionOptions) { - const { current, packagePath = resolver('package.json') } = options; + const {current, packagePath = resolver('package.json')} = options; let components = nextUIComponents as NextUIComponents; try { /** ======================== Get the installed components ======================== */ if (current) { - const { currentComponents } = await getPackageInfo(packagePath); + const {currentComponents} = await getPackageInfo(packagePath); components = currentComponents; } diff --git a/src/constants/path.ts b/src/constants/path.ts index 5a7eb17..4513e47 100644 --- a/src/constants/path.ts +++ b/src/constants/path.ts @@ -1,4 +1,4 @@ -import { resolve } from 'path'; +import {resolve} from 'path'; export const ROOT = process.cwd(); export const resolver = (path: string) => resolve(ROOT, path); diff --git a/src/helpers/check.ts b/src/helpers/check.ts index 8bae392..4f2019f 100644 --- a/src/helpers/check.ts +++ b/src/helpers/check.ts @@ -1,6 +1,6 @@ -import type { SAFE_ANY } from './type'; +import type {SAFE_ANY} from './type'; -import { readFileSync } from 'fs'; +import {readFileSync} from 'fs'; import { FRAMER_MOTION, @@ -12,7 +12,7 @@ import { tailwindRequired } from 'src/constants/required'; -import { getMatchArray, getMatchImport } from './match'; +import {getMatchArray, getMatchImport} from './match'; export type CheckType = 'all' | 'partial'; diff --git a/src/helpers/fetch.ts b/src/helpers/fetch.ts index 8726d87..cc6e9ad 100644 --- a/src/helpers/fetch.ts +++ b/src/helpers/fetch.ts @@ -1,5 +1,5 @@ -import { Readable } from 'stream'; -import { pipeline } from 'stream/promises'; +import {Readable} from 'stream'; +import {pipeline} from 'stream/promises'; import retry from 'async-retry'; import tar from 'tar'; diff --git a/src/helpers/logger.ts b/src/helpers/logger.ts index f9d4508..335120d 100644 --- a/src/helpers/logger.ts +++ b/src/helpers/logger.ts @@ -1,9 +1,9 @@ /* eslint-disable no-console */ -import type { SAFE_ANY } from './type'; +import type {SAFE_ANY} from './type'; import chalk from 'chalk'; -import { default as _gradientString } from 'gradient-string'; +import {default as _gradientString} from 'gradient-string'; export const defaultColors = ['#F54180', '#338EF7'] as const; @@ -38,10 +38,7 @@ export class Logger { console.error(...args.map((item) => chalk.red(item))); } - static gradient( - content: string | number | boolean, - options?: { colors?: tinycolor.ColorInput[] } - ) { + static gradient(content: string | number | boolean, options?: {colors?: tinycolor.ColorInput[]}) { this.log(gradientString(...(options?.colors ?? defaultColors))(String(content))); } diff --git a/src/helpers/output-info.ts b/src/helpers/output-info.ts index 521f83c..d275e64 100644 --- a/src/helpers/output-info.ts +++ b/src/helpers/output-info.ts @@ -1,4 +1,4 @@ -import type { CommandName } from './type'; +import type {CommandName} from './type'; import chalk from 'chalk'; @@ -8,8 +8,8 @@ import { orderNextUIComponentKeys } from 'src/constants/component'; -import { Logger } from './logger'; -import { PasCalCase } from './utils'; +import {Logger} from './logger'; +import {PasCalCase} from './utils'; const rounded = { bl: '╰', diff --git a/src/helpers/package.ts b/src/helpers/package.ts index e553320..8c1bb82 100644 --- a/src/helpers/package.ts +++ b/src/helpers/package.ts @@ -1,9 +1,9 @@ -import { readFileSync } from 'fs'; +import {readFileSync} from 'fs'; -import { type NextUIComponents, nextUIComponents } from 'src/constants/component'; -import { NEXT_UI } from 'src/constants/required'; +import {type NextUIComponents, nextUIComponents} from 'src/constants/component'; +import {NEXT_UI} from 'src/constants/required'; -import { Logger } from './logger'; +import {Logger} from './logger'; /** * Get the package information @@ -20,7 +20,7 @@ export async function getPackageInfo(packagePath: string) { const devDependencies = pkg.devDependencies || {}; const dependencies = pkg.dependencies || {}; - const allDependencies = { ...devDependencies, ...dependencies }; + const allDependencies = {...devDependencies, ...dependencies}; const allDependenciesKeys = new Set(Object.keys(allDependencies)); const currentComponents = (nextUIComponents as unknown as NextUIComponents).filter( diff --git a/src/helpers/utils.ts b/src/helpers/utils.ts index 956d010..431d5bb 100644 --- a/src/helpers/utils.ts +++ b/src/helpers/utils.ts @@ -1,10 +1,10 @@ -import type { PascalCase } from './type'; +import type {PascalCase} from './type'; -import fg, { type Options } from 'fast-glob'; +import fg, {type Options} from 'fast-glob'; -import { ROOT } from 'src/constants/path'; +import {ROOT} from 'src/constants/path'; -import { Logger } from './logger'; +import {Logger} from './logger'; export function getCommandDescAndLog(log: string, desc: string) { Logger.gradient(log); diff --git a/src/index.ts b/src/index.ts index 14e4834..183a8dd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,15 +1,15 @@ import chalk from 'chalk'; -import { Command } from 'commander'; +import {Command} from 'commander'; -import { Logger } from '@helpers/logger'; -import { getCommandDescAndLog } from '@helpers/utils'; +import {Logger} from '@helpers/logger'; +import {getCommandDescAndLog} from '@helpers/utils'; import pkg from '../package.json'; -import { doctorAction } from './actions/doctor-action'; -import { envAction } from './actions/env-action'; -import { initAction } from './actions/init-action'; -import { listAction } from './actions/list-action'; +import {doctorAction} from './actions/doctor-action'; +import {envAction} from './actions/env-action'; +import {initAction} from './actions/init-action'; +import {listAction} from './actions/list-action'; const nextui = new Command(); diff --git a/src/prompts/index.ts b/src/prompts/index.ts index afd9f77..1ad5232 100644 --- a/src/prompts/index.ts +++ b/src/prompts/index.ts @@ -1,7 +1,7 @@ import chalk from 'chalk'; import prompts from 'prompts'; -import { Logger } from '@helpers/logger'; +import {Logger} from '@helpers/logger'; const defaultPromptOptions: prompts.Options = { onCancel: () => { @@ -15,7 +15,7 @@ export async function getInput(message: string, choices?: prompts.Choice[]) { message, name: 'value', type: 'autocomplete', - ...(choices ? { choices } : {}) + ...(choices ? {choices} : {}) }, defaultPromptOptions ); @@ -29,7 +29,7 @@ export async function getSelect(message: string, choices: prompts.Choice[]) { message, name: 'value', type: 'select', - ...(choices ? { choices } : {}) + ...(choices ? {choices} : {}) }, defaultPromptOptions ); diff --git a/tsup.config.ts b/tsup.config.ts index c8c7061..392c3fd 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,8 +1,8 @@ -import { defineConfig } from 'tsup'; +import {defineConfig} from 'tsup'; export default defineConfig((options) => { return { - banner: { js: '#!/usr/bin/env node' }, + banner: {js: '#!/usr/bin/env node'}, clean: true, dts: true, entry: ['src/index.ts'],