Skip to content

Commit

Permalink
fix: npm delivery issue and add latest version tips
Browse files Browse the repository at this point in the history
  • Loading branch information
ShenQingchuan committed Sep 19, 2022
1 parent 15cda49 commit c02e1e2
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -47,6 +47,7 @@
"inquirer-file-tree-selection-prompt": "^2.0.4",
"jsonc-parser": "^3.2.0",
"lodash": "^4.17.21",
"node-fetch": "^3.2.10",
"ora": "^6.1.2",
"semver": "^7.3.7",
"semver-truncate": "^3.0.0"
Expand Down
41 changes: 41 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/index.ts
Expand Up @@ -106,7 +106,7 @@ function guardErrsMapNotEmpty(rawErrsMap: RawErrsMap) {
try {
await ensureTscVersion()
const cli = cac('tsc-err-dirs')
showAppHeader(cli)
showAppHeader()

const parsedEnvArgs = cli.parse()
const rootDirArg = parsedEnvArgs.args[0]
Expand Down
24 changes: 19 additions & 5 deletions src/show-console-print.ts
@@ -1,21 +1,35 @@
import chalk from 'chalk'
import fetch from 'node-fetch'
import packageJSON from '../package.json'
import type { CAC } from 'cac'

export function showAppHeader(cli: CAC) {
const version = packageJSON.version
export function showAppHeader() {
const localVersion = packageJSON.version
console.log(
`\n${chalk.bold.blue(`
_____ _____ ____ _
|_ _|__ ___| ____|_ __ _ __| _ \\(_)_ __ ___
| |/ __|/ __| _| | '__| '__| | | | | '__/ __|
| |\\__ \\ (__| |___| | | | | |_| | | | \\__ \\
|_||___/\\___|_____|_| |_| |____/|_|_| |___/ ${chalk.cyanBright(
`[version: v${packageJSON.version}]`
`[version: v${localVersion}]`
)}
`)}`
)
cli.version(version)

// Tips for latest version check
fetch('https://registry.npmjs.org/-/package/@slackoff/tsc-err-dirs/dist-tags')
.then((resp) => resp.json())
.then((respJson: any) => {
const respJsonLatest = respJson.latest
if (respJsonLatest && respJsonLatest !== localVersion) {
console.log(
`\n💡 Latest version is ${chalk.bold.yellow(
String(respJsonLatest)
)},\n` +
` we recommend you to update by \`npm i -g @slackoff/tsc-err-dirs@latest\``
)
}
})
}
export function showFirstTscCompilePathInfo({
cmd,
Expand Down

0 comments on commit c02e1e2

Please sign in to comment.