Skip to content

Commit

Permalink
fix(cli): output version
Browse files Browse the repository at this point in the history
  • Loading branch information
davydkov committed Nov 14, 2023
1 parent 9091817 commit 4e06953
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 33 deletions.
3 changes: 2 additions & 1 deletion packages/likec4/src/language-services/language-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { equals, keys } from 'rambdax'
import * as R from 'remeda'
import type { Logger } from 'vite'
import { createLikeC4Logger } from '../logger'
import pkg from '../../package.json' assert { type: 'json' }

export type LanguageServicesOptions = {
/**
Expand Down Expand Up @@ -107,7 +108,7 @@ export async function mkLanguageServices({
logValidationErrors = true
}: LanguageServicesOptions) {
const logger = createLikeC4Logger('c4:lsp ')

logger.info(`${k.dim('version')} ${pkg.version}`)
lspLogger.silent(true)

const workspace = resolve(workspaceDir)
Expand Down
71 changes: 40 additions & 31 deletions packages/likec4/src/vite/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { InlineConfig, Logger, Alias } from 'vite'
import type { LanguageServices } from '../language-services'
import { mkLanguageServices } from '../language-services'
import { likec4Plugin } from './plugin'
import pkg from '../../package.json' assert { type: 'json' }
//
const _dirname = dirname(fileURLToPath(import.meta.url))

Expand Down Expand Up @@ -52,13 +53,19 @@ export type LikeC4ViteConfig =
export const viteConfig = async (cfg?: LikeC4ViteConfig) => {
const customLogger = createLikeC4Logger('c4:vite')

customLogger.info(`${k.dim('version')} ${pkg.version}`)

const [root, isDev] = getAppRoot()
if (!fs.existsSync(root)) {
customLogger.error(`app root does not exist: ${root}`)
throw new Error(`app root does not exist: ${root}`)
}

customLogger.info(`${k.dim('app root')} ${root}`)
if (isDev) {
customLogger.warn(`${k.dim('dev app root')} ${root}`)
} else {
customLogger.info(`${k.dim('app root')} ${root}`)
}

const languageServices =
cfg?.languageServices ??
Expand Down Expand Up @@ -131,36 +138,38 @@ export const viteConfig = async (cfg?: LikeC4ViteConfig) => {
},
customLogger,
optimizeDeps: {
include: isDev ? [] : [
'react/jsx-dev-runtime',
'react/jsx-runtime',
'react-dom/client',
'react-dom',
'react',
'classnames',
'remeda',
'rambdax',
'jotai',
'react-konva/es/ReactKonvaCore',
'konva/lib/Core',
'konva/lib/shapes/Rect',
'konva/lib/shapes/Text',
'konva/lib/shapes/Path',
'konva/lib/shapes/Circle',
'konva/lib/shapes/Line',
'konva/lib/shapes/Image',
'konva/lib/shapes/Ellipse',
'react-konva',
'konva',
'react-accessible-treeview',
'@radix-ui/react-icons',
'@radix-ui/themes',
'@react-spring/konva',
'@use-gesture/react',
'@likec4/core',
'@likec4/diagrams'
]
},
include: isDev
? []
: [
'react/jsx-dev-runtime',
'react/jsx-runtime',
'react-dom/client',
'react-dom',
'react',
'classnames',
'remeda',
'rambdax',
'jotai',
'react-konva/es/ReactKonvaCore',
'konva/lib/Core',
'konva/lib/shapes/Rect',
'konva/lib/shapes/Text',
'konva/lib/shapes/Path',
'konva/lib/shapes/Circle',
'konva/lib/shapes/Line',
'konva/lib/shapes/Image',
'konva/lib/shapes/Ellipse',
'react-konva',
'konva',
'react-accessible-treeview',
'@radix-ui/react-icons',
'@radix-ui/themes',
'@react-spring/konva',
'@use-gesture/react',
'@likec4/core',
'@likec4/diagrams'
]
},
plugins: [
react({
// plugins: [
Expand Down
3 changes: 2 additions & 1 deletion packages/likec4/src/vite/vite-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { InlineConfig, ViteDevServer } from 'vite'
import { createServer, mergeConfig, searchForWorkspaceRoot } from 'vite'
import type { LikeC4ViteConfig } from './config'
import { viteConfig } from './config'
import k from 'picocolors'

export const viteDev = async (cfg?: LikeC4ViteConfig): Promise<ViteDevServer> => {
const { isDev, ...config } = await viteConfig(cfg)
Expand Down Expand Up @@ -40,7 +41,7 @@ export const viteDev = async (cfg?: LikeC4ViteConfig): Promise<ViteDevServer> =>

if (!config.languageServices.workspace.startsWith(config.root)) {
const pattern = config.languageServices.workspace
server.config.logger.info(`add to watcher: ${pattern}`)
server.config.logger.info(`${k.dim('`add to watcher')} ${pattern}`)
server.watcher.add(pattern)
}

Expand Down

0 comments on commit 4e06953

Please sign in to comment.