-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget.ts
35 lines (28 loc) · 1.16 KB
/
get.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { Command, flags } from '@oclif/command'
import chalk from 'chalk'
import log from '../../helpers/log-messages'
import getAppCurrentData from '../../helpers/get-app-current-data'
import getNextVersion from '../../helpers/get-next-version'
export default class Get extends Command {
static description = 'show the current version of the app'
static flags = {
help: flags.help({ char: 'h' }),
silent: flags.boolean({ char: 's', description: 'return silent' }),
folderPath: flags.string({ char: 'p', description: "the project's main folder" }),
}
async run(): Promise<string | undefined> {
const { flags: flag } = this.parse(Get)
const nextVersion = await getNextVersion()
const currentVersion = getAppCurrentData(flag.folderPath)
let returnText = `The current version is ${chalk.inverse(' ' + currentVersion?.version + ' ')}`
if (Object.keys(nextVersion).includes('name')) {
returnText = `You are in a ${chalk.underline(nextVersion.type)} branch with a version number ${chalk.underline(
nextVersion.name
)}. ${returnText}`
}
if (!flag.silent) {
log(returnText, 'info')
}
return returnText
}
}