Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const { ConsoleReporter } = require('@carbon/cli-reporter');
const { logger } = require('@carbon/cli-tools');
const packageJson = require('../package.json');
// Initialize our reporter for the console. Used for logging messages
const reporter = new ConsoleReporter();
/**
* @typedef Option
* @param {string} flags - specify the flags for the option
* @param {string} description - the description to show for the option
* @param {any} defaults - the default value for the option
*/
/**
* @typedef Command
* @param {string} name - the name of the command
* @param {string} description - the description to show for the command
* @param {Option[]} options - available options for the command
* @param {Function} action - the function to call when the command is run
*/
/* eslint-disable no-console */
'use strict';
const { createClient } = require('@carbon/npm');
const { ConsoleReporter } = require('@carbon/cli-reporter');
const { clearConsole, createLogger, spawn } = require('@carbon/cli-tools');
const fs = require('fs-extra');
const npmWhich = require('npm-which')(__dirname);
const path = require('path');
const util = require('util');
const logger = createLogger('@carbon/cli-plugin-create');
const reporter = new ConsoleReporter();
const which = util.promisify(npmWhich);
/**
* Create a toolkit project with the given name and options.
*/
async function create(name, options, api, env) {
const { CLI_ENV, cwd } = env;
// We support a couple of options for our `create` command, some only exist
// during development (like link and linkCli).
const { link, linkCli, npmClient, plugins = [], presets = [], skip } = options;
const root = path.join(cwd, name);
logger.trace('Creating project:', name, 'at:', root);
if (await fs.exists(root)) {