Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function parseManifest(rawData, options) {
const parsedManifest = JSON.parse(rawData)
const manifest = validateManifest(parsedManifest)
const reduced = reduceConfig(manifest, options.env, {
studioRootPath: options.basePath || process.cwd()
})
return reduced
}
async function doDatasetImport(options) {
const {outputPath, coreCommands, template, datasetName, context} = options
const manifestPath = path.join(outputPath, 'sanity.json')
const baseManifest = await loadJson(manifestPath)
const manifest = reduceConfig(baseManifest || {}, environment, {
studioRootPath: outputPath
})
const importCmd = coreCommands.find(cmd => cmd.name === 'import' && cmd.group === 'dataset')
return importCmd.action(
{argsWithoutOptions: [template.datasetUrl, datasetName], extOptions: {}},
Object.assign({}, context, {
apiClient: clientWrapper(manifest, manifestPath),
workDir: outputPath,
fromInitCommand: true
})
)
}
}
const command = commandInfo.command
if (command.group && command.group !== 'default') {
cmdArgs.argsWithoutOptions = args.argsWithoutOptions.slice(1)
}
const output = this.handlers.outputter
const {prompt} = this.handlers.prompter
const manifestPath = path.join(options.workDir, 'sanity.json')
debug(`Reading "${manifestPath}"`)
const baseManifest = await loadJson(manifestPath)
const manifest = reduceConfig(baseManifest || {}, environment, {
studioRootPath: options.workDir
})
const apiClient = clientWrapper(manifest, manifestPath)
const context = {
output,
prompt,
apiClient,
yarn,
chalk,
...options,
commandRunner: this
}
if (command.isGroupRoot) {
return context.output.print(generateCommandsDocumentation(this.commandGroups, command.name))