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

fix(cli): specify 2.x version ranges for dependencies #3993

Merged
merged 1 commit into from Dec 21, 2022
Merged
Show file tree
Hide file tree
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
@@ -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