Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function bootstrapFromUrl(context, url) {
const {output, prompt, yarn, workDir} = context
debug('Bootstrapping from URL: %s', url)
const {name, outputPath, inPluginsPath, dependencies} = await bootstrapFromTemplate(context, url)
if (inPluginsPath) {
const addIt = await prompt.single({
type: 'confirm',
message: 'Enable plugin in current Sanity installation?',
default: true
})
if (addIt) {
await addPluginToManifest(workDir, name.replace(/^sanity-plugin-/, ''))
}
}
if (dependencies) {
const dependencyString = JSON.stringify(dependencies, null, 2)
.split('\n')
.slice(1, -1)
.join('\n')
.replace(/"/g, '')
output.print('\nThe following dependencies are required for this template:')
output.print(`${dependencyString}\n`)
}
if (dependencies && inPluginsPath) {
const addDeps = await prompt.single({
async function installPlugin(plugin, context) {
const {output, workDir, yarn} = context
const isNamespaced = plugin[0] === '@'
let shortName = plugin
let fullName = plugin
if (!isNamespaced) {
const isFullName = plugin.indexOf('sanity-plugin-') === 0
shortName = isFullName ? plugin.substr(14) : plugin
fullName = isFullName ? plugin : `sanity-plugin-${plugin}`
}
await yarn(['add', fullName], context)
await addPluginToManifest(workDir, shortName)
await copyConfiguration(workDir, fullName, shortName, output)
output.print(`Plugin '${fullName}' installed`)
}