find-process
Version:
find process info by port/pid/name etc.
62 lines (52 loc) β’ 1.86 kB
JavaScript
const fs = require('fs')
const { execSync } = require('child_process')
// θ―»ε package.json
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'))
const version = packageJson.version
console.log(`π Checking version: ${version}`)
// ζ£ζ₯ git tag
try {
const gitTags = execSync('git tag --list', { encoding: 'utf8' }).trim().split('\n')
const versionTag = `${version}`
if (gitTags.includes(versionTag)) {
console.log(`β
Git tag ${versionTag} exists`)
} else {
console.error(`β Git tag ${versionTag} not found!`)
console.error('Please create the tag with: git tag ' + versionTag)
process.exit(1)
}
} catch (error) {
console.error('β Failed to check git tags:', error.message)
process.exit(1)
}
// ζ£ζ₯ HISTORY.md ζ―ε¦ε
ε«ε½εηζ¬
try {
const historyContent = fs.readFileSync('HISTORY.md', 'utf8')
const versionPattern = new RegExp(`## ${version.replace(/\./g, '\\.')}`, 'i')
if (versionPattern.test(historyContent)) {
console.log(`β
HISTORY.md contains version ${version}`)
} else {
console.error(`β HISTORY.md does not contain version ${version}!`)
console.error('Please add a changelog entry for this version')
process.exit(1)
}
} catch (error) {
console.error('β Failed to read HISTORY.md:', error.message)
process.exit(1)
}
// ζ£ζ₯ζ―ε¦ζζͺζδΊ€ηζ΄ζΉ
try {
const gitStatus = execSync('git status --porcelain', { encoding: 'utf8' }).trim()
if (gitStatus) {
console.error('β There are uncommitted changes!')
console.error('Please commit all changes before publishing')
process.exit(1)
} else {
console.log('β
No uncommitted changes')
}
} catch (error) {
console.error('β Failed to check git status:', error.message)
process.exit(1)
}
console.log('π All version checks passed!')