Skip to content

Commit

Permalink
fix(cli): specify 2.x version ranges for dependencies (#3993)
Browse files Browse the repository at this point in the history
[sc-28222]
  • Loading branch information
rexxars committed Dec 21, 2022
1 parent 0dba94b commit a7e00a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
@@ -1,10 +1,8 @@
import path from 'path'
import chalk from 'chalk'
import fse from 'fs-extra'
import {union, difference} from 'lodash'
import debug from '../../debug'
import versionRanges from '../../versionRanges'
import resolveLatestVersions from '../../util/resolveLatestVersions'
import {createPackageManifest, createSanityManifest} from './createManifest'
import templates from './templates'

Expand All @@ -30,20 +28,7 @@ export default async (opts, context) => {
spinner.succeed()

// Merge global and template-specific plugins and dependencies
const allModules = Object.assign({}, versionRanges.core, template.dependencies || {})
const modules = union(Object.keys(versionRanges.core), Object.keys(template.dependencies || {}))

// Resolve latest versions of Sanity-dependencies
spinner = output.spinner('Resolving latest module versions').start()
const firstParty = modules.filter(isFirstParty)
const thirdParty = difference(modules, firstParty)
const firstPartyVersions = await resolveLatestVersions(firstParty, {asRange: true})
const thirdPartyVersions = thirdParty.reduce((acc, dep) => {
acc[dep] = allModules[dep]
return acc
}, {})
const dependencies = Object.assign({}, firstPartyVersions, thirdPartyVersions)
spinner.succeed()
const dependencies = Object.assign({}, versionRanges.core, template.dependencies || {})

// Now create a package manifest (`package.json`) with the merged dependencies
spinner = output.spinner('Creating default project files').start()
Expand Down Expand Up @@ -97,7 +82,3 @@ export default async (opts, context) => {
}
}
}

function isFirstParty(pkg) {
return pkg.indexOf('@sanity/') === 0
}
14 changes: 7 additions & 7 deletions packages/@sanity/cli/src/versionRanges.js
@@ -1,13 +1,13 @@
export default {
// Dependencies for a default Sanity installation
core: {
'@sanity/base': 'latest',
'@sanity/core': 'latest',
'@sanity/default-layout': 'latest',
'@sanity/default-login': 'latest',
'@sanity/desk-tool': 'latest',
'@sanity/eslint-config-studio': 'latest',
'@sanity/vision': 'latest',
'@sanity/base': '^2.0.0',
'@sanity/core': '^2.0.0',
'@sanity/default-layout': '^2.0.0',
'@sanity/default-login': '^2.0.0',
'@sanity/desk-tool': '^2.0.0',
'@sanity/eslint-config-studio': '^2.0.0',
'@sanity/vision': '^2.0.0',
eslint: '^8.6.0',
'prop-types': '^15.7',
react: '^17.0',
Expand Down

0 comments on commit a7e00a0

Please sign in to comment.