How to use the consola.start function in consola

To help you get started, we’ve selected a few consola 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 Cretezy / Noderize / packages / create / src / run.js View on Github external
log.warn(`No path given!`);
		process.exit(1);
		return;
	}

	// Get absolute path
	const path = resolve(await fs.realpath(process.cwd()), name);

	// Check if exist
	if (await fs.exists(path)) {
		log.warn(`Path exists!`);
		process.exit(1);
		return;
	}

	log.start(`Copying...`);

	// Copy from template
	try {
		await fs.copy(resolve(__dirname, "..", "template"), path);
	} catch (error) {
		error(`Error copying.`, error);
		process.exit(1);
		return;
	}

	log.info(`Setting up...`);

	// Set the "name" field in package.json
	try {
		const childPackagePath = resolve(path, "package.json");
		// Read
github universal-vue / uvue / packages / @uvue / vue-cli-plugin-ssr / uvue / CodeFixer.js View on Github external
async fixMissingDependencies(api) {
    if (!this.options.silent) consola.start('Checking missing dependencies...');

    const hasDependency = name => {
      const packageJson = require(api.resolve('package.json'));
      return packageJson.dependencies[name] ? true : false;
    };

    const isYarn = () => {
      return fs.existsSync(api.resolve('yarn.lock'));
    };

    // Missing Apollo deps
    if (api.hasPlugin('apollo') && !hasDependency('isomorphic-fetch')) {
      if (!this.options.silent) consola.info('Installing isomorphic-fetch for Apollo...');

      if (isYarn()) {
        await execa('yarn', ['add', 'isomorphic-fetch'], {
github universal-vue / uvue / packages / @uvue / vue-cli-plugin-ssr / uvue / CodeFixer.js View on Github external
// PWA
    if (api.hasPlugin('pwa')) {
      await fixPlugin('PWA', ['code:register-service-worker'], 'fixPwa');
    }

    // Apollo
    if (api.hasPlugin('apollo')) {
      await fixPlugin('Apollo', ['code:createApolloClient'], 'fixApollo');
    }

    // TypeScript
    await this.fixTsConfig(api);

    // Main
    {
      if (!this.options.silent) consola.start(`Checking main file...`);

      if (fs.existsSync(mainPath + '.ts')) {
        mainPath += '.ts';
      } else {
        mainPath += '.js';
      }

      const code = await fs.readFile(mainPath, 'utf-8');
      let result = this.fixNewVue(code);
      result = this.fixPluginVueOption(result, 'router');

      if (api.hasPlugin('vuex')) {
        result = this.fixPluginVueOption(result, 'store');
      }

      if (api.hasPlugin('i18n')) {
github universal-vue / uvue / packages / @uvue / devtools / cli / utils.js View on Github external
};

  const wait = time => new Promise(resolve => setTimeout(resolve, time));

  if (!scenario.steps) {
    scenario.steps = [
      {
        path: '/',
      },
    ];
  }

  const repeat = scenario.repeat || 1;

  for (let i = 0; i < repeat; i++) {
    consola.start(`Run ${i + 1}/${repeat}`);

    for (const stepIndex in scenario.steps) {
      const step = scenario.steps[stepIndex];

      await httpBenchmark(autocannonConfig, step.path);

      if (step.wait) {
        await wait(step.wait);
      }
    }
  }
};
github universal-vue / uvue / packages / @uvue / devtools / cli / benchmark.js View on Github external
async argv => {
    consola.start('Starting benchmark...');

    const startPath = require.resolve('@uvue/server/start');

    const server = execa('node', [startPath, ...buildServerArgs(argv)], {
      stdio: 'inherit',
    });

    await executeScenario(argv.scenario, argv);

    server.kill('SIGINT');
  },
];
github universal-vue / uvue / packages / @uvue / devtools / cli / ndb.js View on Github external
argv => {
    consola.start('Starting server with ndb...');

    let args = ['node', require.resolve('@vue/cli-service/bin/vue-cli-service'), 'ssr:serve'];
    if (argv.prod) {
      args = ['node', require.resolve('@uvue/server/start')];
    }

    const ndbPath = require.resolve('ndb/ndb');
    return execa(ndbPath, [...args, ...buildServerArgs(argv)]);
  },
];
github universal-vue / uvue / packages / @uvue / devtools / cli / bubbleprof.js View on Github external
argv => {
    consola.start('Starting Node Clinic: BubbleProf...');

    const ClinicBubbleprof = require('@nearform/bubbleprof');
    const bubbleprof = new ClinicBubbleprof();
    return clinicRun(argv, bubbleprof);
  },
];
github universal-vue / uvue / packages / @uvue / devtools / cli / doctor.js View on Github external
argv => {
    consola.start('Starting Node Clinic: Doctor...');

    const ClinicDoctor = require('@nearform/doctor');
    const doctor = new ClinicDoctor();
    return clinicRun(argv, doctor);
  },
];
github yuanqing / vdx / src / create-command.js View on Github external
return async function () {
    consola.start(isStdin ? 'stdin' : inputFile)
    await mkdirp(path.resolve(outputFile, '..'))
    try {
      await new Promise(async function (resolve) {
        if (hasFilters) {
          await mkdirp(path.resolve(temporaryFile, '..'))
        }
        const flagCommand = createFFmpegCommand(
          ffmpegBinaryPath,
          inputFile,
          hasFilters ? temporaryFile : outputFile,
          ffmpegOptions.flags
        )
        const childProcess = runCommand(flagCommand, isDebug)
        if (isStdin) {
          childProcess.on('exit', function () {
            resolve()
github universal-vue / uvue / packages / @uvue / vue-cli-plugin-ssr / uvue / CodeFixer.js View on Github external
async fixTsConfig(api) {
    const filepath = api.resolve('tsconfig.json');

    if (api.hasPlugin('typescript') && fs.existsSync(filepath)) {
      if (!this.options.silent) consola.start('Checking tsconfig...');

      try {
        const tsConfig = JSON.parse((await fs.readFile(filepath, 'utf-8')) || '{}');
        tsConfig.compilerOptions = tsConfig.compilerOptions || {};
        tsConfig.compilerOptions.types = tsConfig.compilerOptions.types || [];

        if (!tsConfig.compilerOptions.types.includes('@uvue/core')) {
          tsConfig.compilerOptions.types.push('@uvue/core');
          await fs.writeFile(filepath, JSON.stringify(tsConfig, null, '  '));
        }

        if (!this.options.silent) consola.success('Types OK');
      } catch (err) {
        if (!this.options.silent) consola.error('Unable to check or fix tsconfig.json');
      }
    }