Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: warn user when template upgrade a major version #85

Merged
merged 1 commit into from
Jul 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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