diff --git a/docs/src/__registry__/index.ts b/docs/src/__registry__/index.ts index ed60a58..d7c4ba5 100644 --- a/docs/src/__registry__/index.ts +++ b/docs/src/__registry__/index.ts @@ -80,6 +80,7 @@ try { process.exit(1) } + // eslint-disable-next-line adrianub/no-top-level-await await buildRegistry(result.data) } catch (error) { diff --git a/docs/src/components/component-preview/component-preview.ts b/docs/src/components/component-preview/component-preview.ts index aa728bd..406836f 100644 --- a/docs/src/components/component-preview/component-preview.ts +++ b/docs/src/components/component-preview/component-preview.ts @@ -1,10 +1,9 @@ +import type { Style } from '@/registry/registry-styles' import { Index } from '@/__registry__' import { cn } from '@/lib/utils' import { AsyncPipe, NgComponentOutlet } from '@angular/common' import { Component, computed, input } from '@angular/core' -import type { Style } from '@/registry/registry-styles' - @Component({ standalone: true, selector: 'component-preview', diff --git a/docs/src/entrypoints/alpine.ts b/docs/src/entrypoints/alpine.ts index 717aabe..f3d8d4b 100644 --- a/docs/src/entrypoints/alpine.ts +++ b/docs/src/entrypoints/alpine.ts @@ -1,5 +1,5 @@ -import focus from '@alpinejs/focus' import type { Alpine } from 'alpinejs' +import focus from '@alpinejs/focus' export default (Alpine: Alpine): void => { Alpine.plugin(focus) diff --git a/docs/src/pages/r/styles/[style]/[name].json.ts b/docs/src/pages/r/styles/[style]/[name].json.ts index 0a8a63c..05c4078 100644 --- a/docs/src/pages/r/styles/[style]/[name].json.ts +++ b/docs/src/pages/r/styles/[style]/[name].json.ts @@ -1,3 +1,5 @@ +import type { z } from 'astro/zod' + import fs from 'node:fs/promises' import { tmpdir } from 'node:os' import path from 'node:path' @@ -7,7 +9,6 @@ import { registry } from '@/registry' import { styles } from '@/registry/registry-styles' import { type RegistryEntry, registryEntrySchema, type registryItemTypeSchema } from '@/registry/schema' import { Project, ScriptKind } from 'ts-morph' -import type { z } from 'astro/zod' const project = new Project({ compilerOptions: {}, diff --git a/docs/src/pages/r/styles/[style]/index/index.json.ts b/docs/src/pages/r/styles/[style]/index/index.json.ts index ed8e4e5..c253785 100644 --- a/docs/src/pages/r/styles/[style]/index/index.json.ts +++ b/docs/src/pages/r/styles/[style]/index/index.json.ts @@ -1,5 +1,5 @@ -import { type Style, styles } from '@/registry/registry-styles' import type { RegistryEntry } from '@/registry/schema' +import { type Style, styles } from '@/registry/registry-styles' export async function getStaticPaths(): Promise<{ params: { style: string } }[]> { return styles.map(style => ({ diff --git a/docs/src/plugins/rehype-component.ts b/docs/src/plugins/rehype-component.ts index e5d2432..33478b2 100644 --- a/docs/src/plugins/rehype-component.ts +++ b/docs/src/plugins/rehype-component.ts @@ -1,12 +1,13 @@ +import type { UnistNode, UnistTree } from '../../types/unist' + import fs from 'node:fs' import path from 'node:path' import process from 'node:process' import { u } from 'unist-builder' -import { visit } from 'unist-util-visit' +import { visit } from 'unist-util-visit' import { Index } from '../__registry__' import { styles } from '../registry/registry-styles' -import type { UnistNode, UnistTree } from '../../types/unist' function toCamelCase(str: string): string { return str diff --git a/docs/src/plugins/rehype-npm-command.ts b/docs/src/plugins/rehype-npm-command.ts index 252dfe5..22c3167 100644 --- a/docs/src/plugins/rehype-npm-command.ts +++ b/docs/src/plugins/rehype-npm-command.ts @@ -1,6 +1,7 @@ -import { visit } from 'unist-util-visit' import type { UnistNode, UnistTree } from '../../types/unist' +import { visit } from 'unist-util-visit' + export function rehypeNpmCommand() { return (tree: UnistTree) => { visit(tree, (node: UnistNode) => { diff --git a/docs/src/registry/default/ui/accordion.ts b/docs/src/registry/default/ui/accordion.ts index 134caf3..0e49d6f 100644 --- a/docs/src/registry/default/ui/accordion.ts +++ b/docs/src/registry/default/ui/accordion.ts @@ -1,9 +1,10 @@ +import type { ClassValue } from 'clsx' import { cn } from '@/lib/utils' -import { Component, computed, Directive, input } from '@angular/core' +import { Component, computed, Directive, input } from '@angular/core' import { NgIconComponent, provideIcons } from '@ng-icons/core' -import { lucideChevronDown } from '@ng-icons/lucide' +import { lucideChevronDown } from '@ng-icons/lucide' import { RdxAccordionContentDirective, RdxAccordionHeaderDirective, @@ -11,7 +12,6 @@ import { RdxAccordionRootDirective, RdxAccordionTriggerDirective, } from '@radix-ng/primitives/accordion' -import type { ClassValue } from 'clsx' @Directive({ standalone: true, diff --git a/docs/src/registry/index.ts b/docs/src/registry/index.ts index a6293e7..b3e5cc1 100644 --- a/docs/src/registry/index.ts +++ b/docs/src/registry/index.ts @@ -1,10 +1,10 @@ +import type { Registry } from './schema' import { blocks } from './registry-blocks' import { charts } from './registry-charts' import { examples } from './registry-examples' import { lib } from './registry-lib' import { themes } from './registry-themes' import { ui } from './registry-ui' -import type { Registry } from './schema' export const registry: Registry = [ ...ui, diff --git a/docs/src/registry/new-york/ui/accordion.ts b/docs/src/registry/new-york/ui/accordion.ts index 9901e68..4fd7cb6 100644 --- a/docs/src/registry/new-york/ui/accordion.ts +++ b/docs/src/registry/new-york/ui/accordion.ts @@ -1,9 +1,10 @@ +import type { ClassValue } from 'clsx' import { cn } from '@/lib/utils' -import { Component, computed, Directive, input } from '@angular/core' +import { Component, computed, Directive, input } from '@angular/core' import { NgIconComponent, provideIcons } from '@ng-icons/core' -import { lucideChevronDown } from '@ng-icons/lucide' +import { lucideChevronDown } from '@ng-icons/lucide' import { RdxAccordionContentDirective, RdxAccordionHeaderDirective, @@ -11,7 +12,6 @@ import { RdxAccordionRootDirective, RdxAccordionTriggerDirective, } from '@radix-ng/primitives/accordion' -import type { ClassValue } from 'clsx' @Directive({ standalone: true, diff --git a/docs/src/registry/new-york/ui/tabs.ts b/docs/src/registry/new-york/ui/tabs.ts index f774e51..ca3a261 100644 --- a/docs/src/registry/new-york/ui/tabs.ts +++ b/docs/src/registry/new-york/ui/tabs.ts @@ -1,5 +1,6 @@ -import { cn } from '@/lib/utils' +import type { BooleanInput } from '@angular/cdk/coercion' +import { cn } from '@/lib/utils' import { booleanAttribute, computed, Directive, input } from '@angular/core' import { RdxTabsContentDirective, @@ -7,7 +8,6 @@ import { RdxTabsRootDirective, RdxTabsTriggerDirective, } from '@radix-ng/primitives/tabs' -import type { BooleanInput } from '@angular/cdk/coercion' @Directive({ selector: '[ubTabs]', diff --git a/src/commands/add.ts b/src/commands/add.ts index 26a4da2..28305a5 100644 --- a/src/commands/add.ts +++ b/src/commands/add.ts @@ -1,10 +1,11 @@ +import type { AddOptions } from '../schemas/add' import path from 'node:path' -import process from 'node:process' +import process from 'node:process' import * as p from '@clack/prompts' import { Command } from 'commander' -import { z } from 'zod' +import { z } from 'zod' import { preFlightAdd } from '../prefilghts/preflight-add' import { addOptionsSchema } from '../schemas/add' import { addComponents } from '../utils/add-components' @@ -13,9 +14,8 @@ import * as ERRORS from '../utils/errors' import { handleError } from '../utils/handle-error' import { highlighter } from '../utils/highlighter' import { getRegistryIndex } from '../utils/registry' -import { runInit } from './init' -import type { AddOptions } from '../schemas/add' +import { runInit } from './init' export const add = new Command() .name('add') diff --git a/src/commands/diff.ts b/src/commands/diff.ts index 1396062..39229c4 100644 --- a/src/commands/diff.ts +++ b/src/commands/diff.ts @@ -1,21 +1,21 @@ +import type { Change } from 'diff' +import type { z } from 'zod' +import type { Config } from '../utils/get-config' + +import type { registryIndexSchema } from '../utils/registry/schema' import fs, { existsSync } from 'node:fs' import path from 'node:path' import process from 'node:process' - import * as p from '@clack/prompts' + import { Command } from 'commander' import { diffLines } from 'diff' -import type { Change } from 'diff' -import type { z } from 'zod' - import { updateOptionsSchema } from '../schemas/diff' import { getConfig } from '../utils/get-config' import { handleError } from '../utils/handle-error' import { highlighter } from '../utils/highlighter' import { fetchTree, getItemTargetPath, getRegistryBaseColor, getRegistryIndex } from '../utils/registry' import { transform } from '../utils/transformers' -import type { Config } from '../utils/get-config' -import type { registryIndexSchema } from '../utils/registry/schema' export const diff = new Command() .name('diff') diff --git a/src/commands/init.ts b/src/commands/init.ts index 5a45f56..13ea12b 100644 --- a/src/commands/init.ts +++ b/src/commands/init.ts @@ -1,24 +1,24 @@ +import type { InitOptions } from '../schemas/init' +import type { Config } from '../utils/get-config' import fs from 'node:fs/promises' + import path from 'node:path' import process from 'node:process' import * as p from '@clack/prompts' import { Command } from 'commander' - import { preFlightInit } from '../prefilghts/preflight-init' import { initOptionsSchema } from '../schemas/init' import { addComponents } from '../utils/add-components' import { createProject } from '../utils/create-project' import * as ERRORS from '../utils/errors' import { DEFAULT_COMPONENTS, DEFAULT_TAILWIND_CONFIG, DEFAULT_TAILWIND_CSS, DEFAULT_UTILS, getConfig, rawConfigSchema, resolveConfigPaths } from '../utils/get-config' + import { getProjectConfig, getProjectInfo } from '../utils/get-project-info' import { handleError } from '../utils/handle-error' - import { highlighter } from '../utils/highlighter' import { getRegistryBaseColors, getRegistryStyles } from '../utils/registry' import { updateTailwindContent } from '../utils/updaters/update-tailwind-content' -import type { InitOptions } from '../schemas/init' -import type { Config } from '../utils/get-config' async function promptForMinimalConfig(defaultConfig: Config, opts: InitOptions): Promise> { let style = defaultConfig.style diff --git a/src/prefilghts/preflight-add.ts b/src/prefilghts/preflight-add.ts index f352391..2d8099f 100644 --- a/src/prefilghts/preflight-add.ts +++ b/src/prefilghts/preflight-add.ts @@ -1,13 +1,13 @@ +import type { AddOptions } from '../schemas/add' import fs from 'node:fs' import path from 'node:path' + import process from 'node:process' import * as p from '@clack/prompts' - import * as ERRORS from '../utils/errors' import { getConfig } from '../utils/get-config' import { highlighter } from '../utils/highlighter' -import type { AddOptions } from '../schemas/add' export async function preFlightAdd(options: AddOptions): Promise<{ errors: Record, config: any | null }> { const errors: Record = {} diff --git a/src/prefilghts/preflight-init.ts b/src/prefilghts/preflight-init.ts index 58f1043..bb2f2a7 100644 --- a/src/prefilghts/preflight-init.ts +++ b/src/prefilghts/preflight-init.ts @@ -1,16 +1,16 @@ +import type { InitOptions } from '../schemas/init' +import type { ProjectInfo } from '../utils/get-project-info' import fs from 'node:fs' + import path from 'node:path' -import process from 'node:process' +import process from 'node:process' import * as p from '@clack/prompts' - import * as ERRORS from '../utils/errors' + import { getProjectInfo } from '../utils/get-project-info' import { highlighter } from '../utils/highlighter' -import type { InitOptions } from '../schemas/init' -import type { ProjectInfo } from '../utils/get-project-info' - export async function preFlightInit( options: InitOptions, ): Promise<{ errors: Record, projectInfo: ProjectInfo | null }> { @@ -43,8 +43,8 @@ export async function preFlightInit( options.cwd, )}. To start over, remove the ${highlighter.info( - 'components.json', - )} file and run ${highlighter.info('init')} again.`, + 'components.json', + )} file and run ${highlighter.info('init')} again.`, 3, ) process.exit(1) diff --git a/src/utils/add-components.ts b/src/utils/add-components.ts index 7382ec6..3378d2c 100644 --- a/src/utils/add-components.ts +++ b/src/utils/add-components.ts @@ -1,12 +1,12 @@ -import * as p from '@clack/prompts' +import type { Config } from './get-config' +import * as p from '@clack/prompts' import { handleError } from './handle-error' import { registryResolveItemsTree } from './registry' import { updateCssVars } from './updaters/update-css-vars' import { updateDependencies } from './updaters/update-dependencies' import { updateFiles } from './updaters/update-files' import { updateTailwindConfig } from './updaters/update-tailwind-config' -import type { Config } from './get-config' export async function addComponents( components: string[], diff --git a/src/utils/create-project.ts b/src/utils/create-project.ts index d983b06..4e63c2f 100644 --- a/src/utils/create-project.ts +++ b/src/utils/create-project.ts @@ -1,16 +1,16 @@ +import type { InitOptions } from '../schemas/init' import fs from 'node:fs/promises' + import path from 'node:path' import process from 'node:process' - import { installPackage } from '@antfu/install-pkg' -import * as p from '@clack/prompts' +import * as p from '@clack/prompts' import { execa } from 'execa' import { getPackageManager } from './get-package-manager' import { highlighter } from './highlighter' import { loadTsConfig } from './load-tsconfig' -import type { InitOptions } from '../schemas/init' export async function createProject( options: Pick, diff --git a/src/utils/get-project-info.ts b/src/utils/get-project-info.ts index 7bfacba..9b98ff1 100644 --- a/src/utils/get-project-info.ts +++ b/src/utils/get-project-info.ts @@ -1,20 +1,20 @@ +import type { Framework } from './frameworks' +import type { + Config, + RawConfig, +} from './get-config' + import fs from 'node:fs/promises' import path from 'node:path' - import fg from 'fast-glob' + import { loadConfig as loadTsConfig } from 'tsconfig-paths' import { loadConfig } from 'unconfig' - import { FRAMEWORKS } from './frameworks' import { getConfig, resolveConfigPaths, } from './get-config' -import type { Framework } from './frameworks' -import type { - Config, - RawConfig, -} from './get-config' export interface ProjectInfo { framework: Framework diff --git a/src/utils/registry/index.ts b/src/utils/registry/index.ts index 526eb80..b3ee31d 100644 --- a/src/utils/registry/index.ts +++ b/src/utils/registry/index.ts @@ -1,6 +1,10 @@ +import type { Config } from '../../utils/get-config' +import type { + registryItemFileSchema, +} from '../../utils/registry/schema' + import path from 'node:path' import process from 'node:process' - import deepmerge from 'deepmerge' import { HttpsProxyAgent } from 'https-proxy-agent' import fetch from 'node-fetch' @@ -15,10 +19,6 @@ import { stylesSchema, } from '../../utils/registry/schema' import { buildTailwindThemeColorsFromCssVars } from '../../utils/updaters/update-tailwind-config' -import type { Config } from '../../utils/get-config' -import type { - registryItemFileSchema, -} from '../../utils/registry/schema' const REGISTRY_URL = process.env.REGISTRY_URL ?? 'https://ui.adrianub.dev/r' diff --git a/src/utils/transformers/index.ts b/src/utils/transformers/index.ts index 2ef3a5e..6a914f8 100644 --- a/src/utils/transformers/index.ts +++ b/src/utils/transformers/index.ts @@ -1,14 +1,14 @@ +import type { z } from 'zod' +import type { Config } from '../get-config' +import type { registryBaseColorSchema } from '../registry/schema' + import fs from 'node:fs' import { tmpdir } from 'node:os' import path from 'node:path' - import { Project, ScriptKind, type SourceFile } from 'ts-morph' -import type { z } from 'zod' import { transformCssVars } from './transform-css-vars' import { transformImport } from './transform-import' import { transformTwPrefixes } from './transform-tw-prefix' -import type { Config } from '../get-config' -import type { registryBaseColorSchema } from '../registry/schema' export interface TransformOpts { filename: string diff --git a/src/utils/transformers/transform-css-vars.ts b/src/utils/transformers/transform-css-vars.ts index dedb60e..6f05e53 100644 --- a/src/utils/transformers/transform-css-vars.ts +++ b/src/utils/transformers/transform-css-vars.ts @@ -1,8 +1,8 @@ -import { SyntaxKind } from 'ts-morph' - import type { z } from 'zod' + import type { Transformer } from '.' import type { registryBaseColorSchema } from '../registry/schema' +import { SyntaxKind } from 'ts-morph' export const transformCssVars: Transformer = async ({ sourceFile, diff --git a/src/utils/transformers/transform-tw-prefix.ts b/src/utils/transformers/transform-tw-prefix.ts index 3481e22..0d40cd1 100644 --- a/src/utils/transformers/transform-tw-prefix.ts +++ b/src/utils/transformers/transform-tw-prefix.ts @@ -1,7 +1,7 @@ +import type { Transformer } from '.' import { SyntaxKind } from 'ts-morph' -import { splitClassName } from './transform-css-vars' -import type { Transformer } from '.' +import { splitClassName } from './transform-css-vars' export const transformTwPrefixes: Transformer = async ({ sourceFile, diff --git a/src/utils/updaters/update-css-vars.ts b/src/utils/updaters/update-css-vars.ts index 6925571..432045f 100644 --- a/src/utils/updaters/update-css-vars.ts +++ b/src/utils/updaters/update-css-vars.ts @@ -1,16 +1,16 @@ +import type Root from 'postcss/lib/root' +import type Rule from 'postcss/lib/rule' + +import type { z } from 'zod' +import type { Config } from '../get-config' +import type { registryItemCssVarsSchema } from '../registry/schema' import { promises as fs } from 'node:fs' import path from 'node:path' - import * as p from '@clack/prompts' + import postcss from 'postcss' import AtRule from 'postcss/lib/at-rule' -import type Root from 'postcss/lib/root' -import type Rule from 'postcss/lib/rule' -import type { z } from 'zod' - import { highlighter } from '../highlighter' -import type { Config } from '../get-config' -import type { registryItemCssVarsSchema } from '../registry/schema' export async function updateCssVars( cssVars: z.infer | undefined, @@ -231,7 +231,7 @@ function cleanupDefaultNextStylesPlugin(): postcss.Plugin { && node.prop === 'background' // This is only going to run on create project, so all good. && (node.value.startsWith('linear-gradient') - || node.value === 'var(--background)') + || node.value === 'var(--background)') ) }) ?.remove() diff --git a/src/utils/updaters/update-dependencies.ts b/src/utils/updaters/update-dependencies.ts index 92b2340..f4e25d3 100644 --- a/src/utils/updaters/update-dependencies.ts +++ b/src/utils/updaters/update-dependencies.ts @@ -1,9 +1,9 @@ -import { installPackage } from '@antfu/install-pkg' -import * as p from '@clack/prompts' - import type { Config } from '../get-config' import type { RegistryItem } from '../registry/schema' +import { installPackage } from '@antfu/install-pkg' +import * as p from '@clack/prompts' + export async function updateDependencies( dependencies: RegistryItem['dependencies'], config: Config, diff --git a/src/utils/updaters/update-files.ts b/src/utils/updaters/update-files.ts index 84d4026..57e9c6a 100644 --- a/src/utils/updaters/update-files.ts +++ b/src/utils/updaters/update-files.ts @@ -1,6 +1,8 @@ +import type { Config } from '../get-config' +import type { RegistryItem } from '../registry/schema' + import fs from 'node:fs' import path, { basename } from 'node:path' - import * as p from '@clack/prompts' import { highlighter } from '../highlighter' import { getRegistryBaseColor, getRegistryItemFileTargetPath } from '../registry' @@ -8,8 +10,6 @@ import { transform } from '../transformers' import { transformImport } from '../transformers/transform-import' import { transformTwPrefixes } from '../transformers/transform-tw-prefix' import { transformCssVars } from './update-css-vars' -import type { Config } from '../get-config' -import type { RegistryItem } from '../registry/schema' export function resolveTargetDir( config: Config, diff --git a/src/utils/updaters/update-tailwind-config.ts b/src/utils/updaters/update-tailwind-config.ts index e72864d..987ea1e 100644 --- a/src/utils/updaters/update-tailwind-config.ts +++ b/src/utils/updaters/update-tailwind-config.ts @@ -1,31 +1,31 @@ +import type { Config as TailwindConfig } from 'tailwindcss' +import type { + ObjectLiteralExpression, + PropertyAssignment, + SourceFile, + VariableStatement, +} from 'ts-morph' +import type { z } from 'zod' + +import type { Config } from '../get-config' +import type { registryItemTailwindSchema } from '../registry/schema' import { promises as fs } from 'node:fs' import { tmpdir } from 'node:os' -import path from 'node:path' +import path from 'node:path' import * as p from '@clack/prompts' import deepmerge from 'deepmerge' + import objectToString from 'stringify-object' + import { Project, QuoteKind, ScriptKind, SyntaxKind, } from 'ts-morph' - -import type { Config as TailwindConfig } from 'tailwindcss' -import type { - ObjectLiteralExpression, - PropertyAssignment, - SourceFile, - VariableStatement, -} from 'ts-morph' -import type { z } from 'zod' - import { highlighter } from '../highlighter' -import type { Config } from '../get-config' -import type { registryItemTailwindSchema } from '../registry/schema' - export type UpdaterTailwindConfig = Omit & { // We only want string plugins for now. plugins?: string[] diff --git a/src/utils/updaters/update-tailwind-content.ts b/src/utils/updaters/update-tailwind-content.ts index 913b0a4..98545d0 100644 --- a/src/utils/updaters/update-tailwind-content.ts +++ b/src/utils/updaters/update-tailwind-content.ts @@ -1,14 +1,14 @@ +import type { ObjectLiteralExpression } from 'ts-morph' +import type { Config } from '../get-config' import { promises as fs } from 'node:fs' import path from 'node:path' import * as p from '@clack/prompts' import { SyntaxKind } from 'ts-morph' -import type { ObjectLiteralExpression } from 'ts-morph' import { highlighter } from '../highlighter' import { _createSourceFile, _getQuoteChar, } from '../updaters/update-tailwind-config' -import type { Config } from '../get-config' export async function updateTailwindContent( content: string[],