Skip to content

Commit

Permalink
[core] Warn on deprecated react version (#671)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoerge committed Mar 15, 2018
1 parent 9ea2453 commit 903747c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/@sanity/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"dependencies": {
"@sanity/check": "^0.126.0",
"@sanity/export": "^0.126.2",
"@sanity/generate-help-url": "^0.125.8",
"@sanity/import": "^0.126.2",
"@sanity/mutator": "^0.126.2",
"@sanity/plugin-loader": "^0.126.0",
Expand Down
14 changes: 14 additions & 0 deletions packages/@sanity/core/src/util/checkReactCompatibility.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
const path = require('path')
const semver = require('semver')
const resolveFrom = require('resolve-from')
const generateHelpUrl = require('@sanity/generate-help-url')

const supported = {
react: '^15 || ^16',
'react-dom': '^15 || ^16'
}
const deprecated = {
react: '^15',
'react-dom': '^15'
}

module.exports = workDir => {
const manifest = require(path.join(workDir, 'package.json'))
Expand All @@ -21,6 +26,15 @@ module.exports = workDir => {
? require(manifestPath).version
: dependencies[pkg].replace(/[\D.]/g, '')

if (semver.satisfies(installed, deprecated[pkg])) {
console.warn(
`[WARN] ${pkg} ${
deprecated[pkg]
} is deprecated and will be unsupported as of the next release of Sanity. Please upgrade the ${pkg} package. Read more at ${generateHelpUrl(
'upgrade-react'
)} `
)
}
if (!semver.satisfies(installed, supported[pkg])) {
throw new Error(
`Sanity currently only supports ${pkg}@${supported[pkg]}. Installed version: ${installed}.`
Expand Down

0 comments on commit 903747c

Please sign in to comment.