Skip to content

Commit

Permalink
feat: 添加文件链接
Browse files Browse the repository at this point in the history
  • Loading branch information
Plumbiu committed Sep 8, 2023
1 parent 8e6d271 commit 27f41c5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .changeset/dry-starfishes-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@truth-cli/shared': patch
'@truth-cli/core': patch
'truth-cli': patch
---

新增显示本地连接
7 changes: 4 additions & 3 deletions packages/core/src/relations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'node:fs'
import path from 'node:path'
import type { Relation, Relations } from '@truth-cli/shared'

export function useReadFile(p: string) {
Expand All @@ -20,7 +21,7 @@ export function genRelations() {
homepage,
} = useReadFile('package.json')
const relations: Relations = {
__root__: { name: name ?? '__root__', version, dependencies, devDependencies, homepage },
__root__: { name: name ?? '__root__', path: path.resolve('package.json'), version, dependencies, devDependencies, homepage },
__extra__: {},
}
if (name)
Expand All @@ -31,11 +32,11 @@ export function genRelations() {
const pkgPath = `${p}/${dirs[i]}`
if (dirs[i] === '.bin' || !fs.lstatSync(pkgPath).isDirectory())
continue
const filePath = `${pkgPath}/package.json`
const filePath = path.resolve(`${pkgPath}/package.json`)
if (fs.existsSync(filePath)) {
const pkg = useReadFile(filePath)
const { name, version, dependencies, devDependencies, homepage } = pkg
const add: Relation = { name, version, homepage, dependencies, devDependencies }
const add: Relation = { name, version, path: filePath, homepage, dependencies, devDependencies }
if (relations[name]) {
if (
relations[name].version === version
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface Tree {
export interface Relation {
name?: string
version?: string
path?: string
dependencies?: Record<string, string>
devDependencies?: Record<string, string>
homepage?: string
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/components/Drawer/Json/Info.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ defineProps<{
</div>
<div v-else>
<span class="key">{{ key }}</span>
<a v-if="key === 'homepage'" :href="String(value)" target="_blank" style="padding-left: 8px;">{{ value }}</a>
<a v-if="key === 'homepage' || key === 'path'" :href="String(value)" target="_blank" style="padding-left: 8px;">{{ value }}</a>
<span v-else class="value">{{ value }}</span>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ a {
background-color: var(--el-color-primary-light-9);
}
.key {
color: var(--el-color-primary-dark-2);
font-weight: bold;
}
.value {
padding-left: 8px;
Expand Down

1 comment on commit 27f41c5

@vercel
Copy link

@vercel vercel bot commented on 27f41c5 Sep 8, 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.