Skip to content

Commit

Permalink
feat: warn user when template upgrade a major version
Browse files Browse the repository at this point in the history
  • Loading branch information
Val-istar-Guo committed Jul 25, 2019
1 parent 4b8bc1c commit f8062a6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/commands/upgrade.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Project, Resource, Effect, EffectOptions } from '@/internal'
import { recursiveExecte, logger, checkWorkDir } from '@/utils'
import semver from 'semver'

interface UpgradeOptions {
cwd?: string
Expand Down Expand Up @@ -30,7 +31,14 @@ export default recursiveExecte(async(options: UpgradeOptions): Promise<void> =>
logger.warn(message)
}

const currentVersion = repo.version

await repo.checkout('latest')

if (currentVersion && currentVersion !== 'default' && repo.version && semver.diff(currentVersion, repo.version) === 'major') {
logger.warn(`The template upgrade a major version from ${currentVersion} to ${repo.version}. Please view the template breaking change first.`)
}

const template = await repo.install({ noDeps })
const resource = new Resource('upgrade', project, template)

Expand Down

0 comments on commit f8062a6

Please sign in to comment.