How to use the just-scripts-utils.logger.warn function in just-scripts-utils

To help you get started, we’ve selected a few just-scripts-utils 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 microsoft / just / packages / just-scripts / src / tasks / addPackageTask.ts View on Github external
const installedStacks = findInstalledStacks(rootPath);

    const response = args.stack
      ? { stack: args.stack }
      : await prompts({
        type: 'select',
        name: 'stack',
        message: 'What type of package to add to the repo?',
        choices: installedStacks.map(stack => ({ title: stack.description, value: stack.name }))
      });

    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
    const selectedStack = installedStacks.find(stack => stack.name === response.stack)!;

    if (!selectedStack) {
      logger.warn('Cannot add package if no stack is selected');
      return;
    }

    const packagePath = path.join(rootPath, 'packages', name);
    const templatePath = path.join(selectedStack.path, 'template');

    if (templatePath) {
      applyTemplate(templatePath, packagePath, {
        name
      });

      // Remove some files that aren't relevant for an individual project within a monorepo
      fse.removeSync(path.join(packagePath, '.gitignore'));
      fse.removeSync(path.join(packagePath, '.gitattributes'));
      fse.removeSync(path.join(packagePath, '.vscode'));
github microsoft / just / packages / just-scripts / src / tasks / addPackageTask.ts View on Github external
return async function addPackage() {
    const args = argv();
    const rootPath = findMonoRepoRootPath();

    const name =
      args.name ||
      (await prompts({
        type: 'text',
        name: 'name',
        message: 'What is the name of the package?'
      })).name;

    logger.info(`Creating a package called: ${name}`);

    if (!rootPath) {
      logger.warn('Cannot determine the root path to the mono repo');
      return;
    }

    // TODO: do validation that the path is indeed a monorepo
    const installedStacks = findInstalledStacks(rootPath);

    const response = args.stack
      ? { stack: args.stack }
      : await prompts({
        type: 'select',
        name: 'stack',
        message: 'What type of package to add to the repo?',
        choices: installedStacks.map(stack => ({ title: stack.description, value: stack.name }))
      });

    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
github microsoft / just / packages / just-scripts / src / tasks / addPackageTask.ts View on Github external
return async function addPackage() {
    const args = argv();
    const rootPath = findMonoRepoRootPath();

    const name =
      args.name ||
      (await prompts({
        type: 'text',
        name: 'name',
        message: 'What is the name of the package?'
      })).name;

    logger.info(`Creating a package called: ${name}`);

    if (!rootPath) {
      logger.warn('Cannot determine the root path to the mono repo');
      return;
    }

    // TODO: do validation that the path is indeed a monorepo

    const installedStacks = findInstalledStacks(path.join(rootPath, 'scripts'));

    // TODO: autosuggest just-stack-* packages from npmjs.org
    let response = await prompts({
      type: 'select',
      name: 'stack',
      message: 'What type of package to add to the repo?',
      choices: installedStacks.map(stack => ({ title: stack.description, value: stack.name }))
    });

    const selectedStack = installedStacks.find(stack => stack.name === response.stack)!;
github microsoft / just / packages / create-just / src / commands / initCommand.ts View on Github external
const generator = await getPlopGenerator(stackPath!, paths.projectPath, stackName);

  logger.info(`Running "${stackName}" code generation actions inside: ${paths.projectPath}`);

  await runGenerator(generator, argv);

  logger.info(`Initializing the repo in ${paths.projectPath}`);

  pkg.install(argv.registry, paths.projectPath);

  try {
    execSync('git init', { cwd: paths.projectPath });
    execSync('git add .', { cwd: paths.projectPath });
    execSync('git commit -m "initial commit"', { cwd: paths.projectPath });
  } catch (e) {
    logger.warn('Looks like you may not have git installed or there was some sort of error initializing the git repo');
    logger.info(`
Please make sure you have git installed and then issue the following:

    cd ${paths.projectPath}
    git init
    git add .
    git commit -m "initial commit"

`);
    process.exit(1);
  }

  logger.info('All Set!');

  showNextSteps(argv, stackName, stackPath!);
}
github microsoft / just / packages / just-scripts / src / stack / getStackDiffs.ts View on Github external
export async function getStackDiffs(rootPath: string, resolvedStacks: StackVersions) {
  const oldStacks = readLockFile(rootPath);

  if (!oldStacks) {
    logger.warn('Lock file not available');
    return null;
  }

  const stackDiffs: { [stack: string]: DiffInfo } = {};

  try {
    await Object.keys(oldStacks).reduce(async (currentPromise, stack) => {
      await currentPromise;
      if (oldStacks[stack] !== resolvedStacks[stack]) {
        stackDiffs[stack] = await getSingleStackDiffs(stack, oldStacks[stack], resolvedStacks[stack]);
      }
    }, Promise.resolve());
  } catch (e) {
    logger.error('Cannot figure out upgrades needed for this repo: ', e);
    return null;
  }