function create()

in scripts/generate.js [27:65]


function create(name) {
  // Copy the files under ./template to ./custom-series/<name>
  const templatePath = path.join(__dirname, './template');
  const seriesPath = path.join(__dirname, '../custom-series', name);
  if (fs.existsSync(seriesPath)) {
    console.error(chalk.red(`Custom series ${name} already exists`));
    return;
  }

  // Check if the name is in camelCase, ignore if is not
  if (!/^[a-z][a-zA-Z0-9]*$/.test(name)) {
    console.error(
      chalk.red(
        `Custom series name must be in camelCase. For example: mySeries`
      )
    );
    process.exit(1);
  }

  fs.mkdirSync(seriesPath);
  copyDirectory(templatePath, seriesPath);

  // Replace `$CUSTOM_SERIES_NAME$` in all files under seriesPath with <name>
  const kebabCaseName = toKebabCase(name);
  replaceCustomSeriesName(seriesPath, name, kebabCaseName);

  const packageJsonPath = path.join(seriesPath, 'package.json');
  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
  packageJson.name = `@echarts/custom-${kebabCaseName}`;
  fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));

  // Run `npm install`
  console.log(
    chalk.gray(`Installing dependencies for custom series ${name}...`)
  );
  require('child_process').execSync(`npm install`, { cwd: seriesPath });

  console.log(chalk.green(`Custom series ${name} created successfully.\n`));
}