2
0

validatorRules.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. 'use strict'
  2. const semver = require('semver')
  3. module.exports = {
  4. osx: {
  5. versionCheck: 'sw_vers -productVersion',
  6. versionValidate:
  7. (detectedVersion, expectedVersion) => expectedVersion === detectedVersion.trim()
  8. },
  9. node: {
  10. versionCheck: 'node -v',
  11. versionValidate:
  12. (detectedVersion, expectedVersion) => semver.satisfies(detectedVersion, expectedVersion)
  13. },
  14. npm: {
  15. versionCheck: 'npm -v',
  16. versionValidate:
  17. (detectedVersion, expectedVersion) => semver.satisfies(detectedVersion, expectedVersion)
  18. },
  19. jx: {
  20. versionCheck: 'jx -jxv',
  21. versionValidate:
  22. (result, version) => 'v' + version === result.trim()
  23. },
  24. cordova: {
  25. versionCheck: 'cordova -v',
  26. versionValidate:
  27. (result, version) => version === result.trim()
  28. },
  29. appium: {
  30. versionCheck: 'appium -v',
  31. versionValidate:
  32. (result, version) => version === result.trim()
  33. },
  34. 'ios-deploy': {
  35. versionCheck: 'ios-deploy -V',
  36. versionValidate:
  37. (result, version) => version === result.trim()
  38. },
  39. 'ios-sim': {
  40. versionCheck: 'ios-sim --version',
  41. versionValidate:
  42. (result, version) => version === result.trim()
  43. },
  44. bower: {
  45. versionCheck: 'bower -v',
  46. versionValidate:
  47. (result, version) => semver.satisfies(result, version)
  48. },
  49. 'ios-webkit-debug-proxy': {
  50. versionCheck: 'brew list ios-webkit-debug-proxy --versions',
  51. versionValidate:
  52. (result, version) => result.includes(version)
  53. },
  54. 'ideviceinstaller': {
  55. versionCheck: 'brew list ideviceinstaller --versions',
  56. versionValidate:
  57. (result, version) => result.includes(version)
  58. },
  59. java: {
  60. versionCheck: 'javac -version 2>&1',
  61. versionValidate:
  62. (result, version) => result.includes(version)
  63. },
  64. ant: {
  65. versionCheck: 'ant -version',
  66. versionValidate:
  67. (result, version) => result.includes(version)
  68. },
  69. adb: {
  70. versionCheck: 'adb version',
  71. versionValidate:
  72. (result, version) => result.includes(version)
  73. },
  74. git: {
  75. versionCheck: 'git --version',
  76. versionValidate:
  77. (result, version) => {
  78. // http://stackoverflow.com/questions/82064/a-regex-for-version-number-parsing
  79. const found = result.match(/(\d+\.)?(\d+\.)?(\d+)/i)
  80. return found[0] === version
  81. }
  82. },
  83. windows: {
  84. versionCheck: 'ver',
  85. versionValidate:
  86. (result, version) => result.includes(version)
  87. },
  88. 'gulp-cli': {
  89. versionCheck: 'npm list --depth=0 -g |grep gulp-cli',
  90. versionValidate:
  91. (result, version) => result.includes(version)
  92. },
  93. cocoapods: {
  94. versionCheck: 'pod --version',
  95. versionValidate:
  96. (result, version) => version === result.trim()
  97. },
  98. xcodebuild: {
  99. versionCheck: 'xcodebuild -version',
  100. versionValidate:
  101. (result, version) => result.includes(version)
  102. },
  103. carthage: {
  104. versionCheck: 'carthage version',
  105. versionValidate:
  106. (result, version) => version === result.trim()
  107. },
  108. xcpretty: {
  109. versionCheck: 'xcpretty -v',
  110. versionValidate:
  111. (result, version) => version === result.trim()
  112. },
  113. libimobiledevice: {
  114. versionCheck: 'brew list --versions |grep libimobiledevice',
  115. versionValidate:
  116. (result, version) => result.includes(version)
  117. },
  118. 'deviceconsole': {
  119. versionCheck: 'npm list --depth=0 -g |grep deviceconsole',
  120. versionValidate:
  121. (result, version) => result.includes(version)
  122. },
  123. 'check-engine': {
  124. versionCheck: 'npm list --depth=0 -g |grep check-engine',
  125. versionValidate:
  126. (result, version) => result.includes(version)
  127. },
  128. yarn: {
  129. versionCheck: 'yarn -v',
  130. versionValidate:
  131. (result, version) => semver.satisfies(result, version)
  132. },
  133. nsp: {
  134. versionCheck: 'nsp --version',
  135. versionValidate:
  136. (result, version) => version === result.trim()
  137. }
  138. }