How to use the @sanity/util/lib/readLocalManifest function in @sanity/util

To help you get started, we’ve selected a few @sanity/util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sanity-io / sanity / packages / @sanity / cli / src / commands / upgrade / upgradeDependencies.js View on Github external
context.output.print(`${chalk.green('✔')} ${specified} Sanity modules are at latest versions`)
    return
  }

  // Forcefully remove non-symlinked module paths to force upgrade
  await Promise.all(
    needsUpdate.map(mod =>
      deleteIfNotSymlink(
        path.join(context.workDir, 'node_modules', mod.name.replace(/\//g, path.sep))
      )
    )
  )

  // Replace versions in `package.json`
  const versionPrefix = saveExact ? '' : '^'
  const oldManifest = await readLocalManifest(workDir)
  const newManifest = needsUpdate.reduce((target, mod) => {
    if (oldManifest.dependencies && oldManifest.dependencies[mod.name]) {
      target.dependencies[mod.name] =
        mod.latest === 'unknown' ? oldManifest.dependencies[mod.name] : versionPrefix + mod.latest
    }

    if (oldManifest.devDependencies && oldManifest.devDependencies[mod.name]) {
      target.devDependencies[mod.name] =
        mod.latest === 'unknown'
          ? oldManifest.devDependencies[mod.name]
          : versionPrefix + mod.latest
    }

    return target
  }, oldManifest)
github sanity-io / sanity / packages / @sanity / core / src / commands / uninstall / uninstallCommand.js View on Github external
async function removeFromSanityManifest(workDir, pluginName) {
  const manifest = await readLocalManifest(workDir, 'sanity.json')
  manifest.plugins = without(manifest.plugins || [], pluginName)
  return fse.writeJson(path.join(workDir, 'sanity.json'), manifest, {spaces: 2})
}