Skip to content

Commit

Permalink
fix: 🧩 版本号显示不正确
Browse files Browse the repository at this point in the history
  • Loading branch information
Plumbiu committed Aug 13, 2023
1 parent 85972b6 commit 75eb64c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/polite-experts-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@truth-cli/shared': patch
'truth-cli': patch
---

版本号更新获取
6 changes: 3 additions & 3 deletions packages/cli/src/genFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ const relations = genRelations()
*/
export async function genWebFile(options: IOptions) {
const begin = Date.now()
let { dep, isBoth, isBuild: isDev, writePath } = options
let { dep, isBoth, isBuild, writePath } = options
const graph = genGraph()
const tree = genTree(dep)
const versions = genVersions()
if (!writePath)
writePath = isDev ? devDistPath : distPath
writePath = isBuild ? devDistPath : distPath
await writeFile(`${writePath}/relations.json`, JSON.stringify(relations))
await writeFile(`${writePath}/graph.json`, JSON.stringify(graph))
await writeFile(`${writePath}/tree.json`, JSON.stringify(tree))
await writeFile(`${writePath}/versions.json`, JSON.stringify(versions))
if (isBoth) {
const pkgs = genPkgs(dep)
await writeFile('./pkgs.json', JSON.stringify(pkgs))
isDev || logFileWirteFinished(Date.now() - begin, './')
isBuild || logFileWirteFinished(Date.now() - begin, './')
}
}

Expand Down
5 changes: 3 additions & 2 deletions packages/shared/src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
// TODO: 完成各种报错以及其他打印语句
import { fileURLToPath } from 'node:url'
import { resolve } from 'node:path'
import fs from 'node:fs'
import { Chalk } from 'chalk'

const chalk = new Chalk({ level: 3 })
const __dirname = fileURLToPath(new URL('.', import.meta.url))

// TODO: 根据项目根目录的 package.json 文件自动控制版本和描述
// 之前直接 import 会导致 dev 命令失效,暂时没有什么好办法
const v = '0.3.81'
const c = 'A command-line tool for analyzing dependencies under node_moudles'

const { version: v, description: c } = JSON.parse(fs.readFileSync(resolve('./packages/cli/package.json')).toString())
const errorPrefix = chalk.bgRedBright('Error!')
const localPrefix = `➜ ${chalk.whiteBright.bold('Local')}:`
const filePrefix = `➜ ${chalk.whiteBright.bold('File:')}:`
Expand Down

1 comment on commit 75eb64c

@vercel
Copy link

@vercel vercel bot commented on 75eb64c Aug 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.