Skip to content

Commit

Permalink
feat: validate git version after install
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #3
  • Loading branch information
jlegrone committed Aug 8, 2017
1 parent 2db4478 commit ac783ee
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 4 deletions.
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
"commitmsg": "validate-commit-msg",
"remove-config": "sed -i.backup '/jlegrone.gitconfig/d' ~/.gitconfig",
"add-config": "git config --global --add include.path $PWD/src/jlegrone.gitconfig",
"postinstall": "npm run remove-config && npm run add-config",
"postinstall": "npm run remove-config && npm run add-config && npm run validate-git-version",
"preuninstall": "npm run remove-config",
"semantic-release": "semantic-release pre && npm publish --access public && semantic-release post"
"semantic-release": "semantic-release pre && npm publish --access public && semantic-release post",
"validate-git-version": "node scripts/validate-git-version"
},
"config": {
"commitizen": {
Expand Down Expand Up @@ -56,7 +57,11 @@
"commitizen": "^2.9.6",
"cz-customizable": "^5.0.0",
"husky": "^0.14.3",
"validate-commit-msg": "^2.12.2",
"semantic-release": "^6.3.6"
"semantic-release": "^6.3.6",
"validate-commit-msg": "^2.12.2"
},
"dependencies": {
"chalk": "^2.1.0",
"validate-git-version": "^1.0.0"
}
}
15 changes: 15 additions & 0 deletions scripts/validate-git-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const validateGitVersion = require('validate-git-version')
const { blue, yellow } = require('chalk')
const { name: moduleName } = require('../package')

const minimumVersion = '2.6.0'

validateGitVersion(
`^${minimumVersion}`,
(currentVersion) => console.log(yellow(
`⚠️ Git version ${currentVersion} is not compatible with ${moduleName}. Please upgrade to git ${minimumVersion} or later.`
)),
(currentVersion) => console.log(blue(
`🎉 Git version ${currentVersion} is compatible with ${moduleName}.`
))
)
44 changes: 44 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ ansi-styles@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"

ansi-styles@^3.1.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.0.tgz#c159b8d5be0f9e5a6f346dab94f16ce022161b88"
dependencies:
color-convert "^1.9.0"

ansi@^0.3.0, ansi@~0.3.0:
version "0.3.1"
resolved "https://registry.yarnpkg.com/ansi/-/ansi-0.3.1.tgz#0c42d4fb17160d5a9af1e484bace1c66922c1b21"
Expand Down Expand Up @@ -238,6 +244,14 @@ chalk@1.1.3, chalk@^1.0.0, chalk@^1.1.1:
strip-ansi "^3.0.0"
supports-color "^2.0.0"

chalk@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e"
dependencies:
ansi-styles "^3.1.0"
escape-string-regexp "^1.0.5"
supports-color "^4.0.0"

ci-info@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.0.0.tgz#dc5285f2b4e251821683681c381c3388f46ec534"
Expand All @@ -260,6 +274,16 @@ code-point-at@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"

color-convert@^1.9.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.0.tgz#1accf97dd739b983bf994d56fec8f95853641b7a"
dependencies:
color-name "^1.1.1"

color-name@^1.1.1:
version "1.1.3"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"

colors@1.0.x:
version "1.0.3"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b"
Expand Down Expand Up @@ -808,6 +832,10 @@ has-ansi@^2.0.0:
dependencies:
ansi-regex "^2.0.0"

has-flag@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51"

has-unicode@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9"
Expand Down Expand Up @@ -1804,6 +1832,10 @@ semver-regex@1.0.0:
version "4.3.6"
resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.6.tgz#300bc6e0e86374f7ba61068b5b1ecd57fc6532da"

semver@^5.4.1:
version "5.4.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e"

semver@~5.0.1:
version "5.0.3"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.0.3.tgz#77466de589cd5d3c95f138aa78bc569a3cb5d27a"
Expand Down Expand Up @@ -1949,6 +1981,12 @@ supports-color@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"

supports-color@^4.0.0:
version "4.2.1"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.2.1.tgz#65a4bb2631e90e02420dba5554c375a4754bb836"
dependencies:
has-flag "^2.0.0"

temp@0.8.3:
version "0.8.3"
resolved "https://registry.yarnpkg.com/temp/-/temp-0.8.3.tgz#e0c6bc4d26b903124410e4fed81103014dfc1f59"
Expand Down Expand Up @@ -2042,6 +2080,12 @@ validate-commit-msg@^2.12.2:
findup "0.1.5"
semver-regex "1.0.0"

validate-git-version@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/validate-git-version/-/validate-git-version-1.0.0.tgz#cb85594002ba628793cc915a4399b5e9dd6520df"
dependencies:
semver "^5.4.1"

validate-npm-package-license@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc"
Expand Down

0 comments on commit ac783ee

Please sign in to comment.