Skip to content

Commit

Permalink
feat(cli): add version update notify
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwangchong committed Sep 17, 2023
1 parent 8223d63 commit 329153e
Show file tree
Hide file tree
Showing 3 changed files with 429 additions and 11 deletions.
6 changes: 4 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,21 @@
"build": "unbuild"
},
"dependencies": {
"chalk": "^4.1.2",
"commander": "^10.0.1",
"inquirer": "^9.2.11",
"log-symbols": "^5.1.0",
"ora": "6.3.1",
"read-pkg": "^7.1.0",
"rimraf": "^5.0.1",
"chalk": "^4.1.2"
"update-notifier": "^6.0.2"
},
"gitHead": "9e62d20cc11b371c2b5ba9b1234d3a5b0648ba90",
"engines": {
"node": ">=14"
},
"devDependencies": {
"@types/inquirer": "^9.0.3"
"@types/inquirer": "^9.0.3",
"@types/update-notifier": "^6.0.5"
}
}
14 changes: 13 additions & 1 deletion packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { resolve } from 'node:path'
import { rimrafSync } from 'rimraf'
import chalk from 'chalk'
import { readPackage } from 'read-pkg'
import updateNotifier from 'update-notifier'
import { createProjectQuestion, createOverrideQuestion } from './question'
import { initialTemplate } from './template'
import { exists } from './utils'
import { exists, dirname } from './utils'

const projectQuestions = async () => {
let finalName: string = ''
Expand All @@ -22,7 +24,17 @@ const projectQuestions = async () => {
return finalName
}

const versionUpateNotifi = async () => {
try {
const pkg = await readPackage({
cwd: resolve(dirname(), '..')
})
updateNotifier({ pkg }).notify()
} catch(_err) { /* empty */ }
}

export default async () => {
await versionUpateNotifi()
const name = await projectQuestions()
const inited = await initialTemplate(name)

Expand Down
Loading

0 comments on commit 329153e

Please sign in to comment.