How to use the just-scripts-utils.downloadPackage 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 / stack / getStackDiffs.ts View on Github external
export async function getSingleStackDiffs(stack: string, fromVersion: string, toVersion: string): Promise {
  const packagePaths = await Promise.all([downloadPackage(stack, fromVersion), downloadPackage(stack, toVersion)]);

  // Concentrates on new and modified files only
  const diffInfo: DiffInfo = {
    patches: {},
    fromVersion,
    toVersion
  };

  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
  const fromPath = packagePaths[0]!;
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
  const toPath = packagePaths[1]!;
  const globbedFiles = glob.sync('**/*', { cwd: toPath, nodir: true, dot: true });
  const dmp = new DiffMatchPatch();

  globbedFiles.forEach(file => {
github microsoft / just / packages / create-just / src / commands / initCommand.ts View on Github external
async function getStackPath(pathName: string, registry?: string) {
  if (pathName.match(/^\./)) {
    // relative to initCwd
    return path.join(initCwd, pathName);
  } else if (pathName.match(/^\//)) {
    // absolute path
    return pathName;
  }

  // download it from feed
  return await downloadPackage(pathName, undefined, registry);
}
github microsoft / just / packages / create-just / src / plop.ts View on Github external
plop.setActionType('repo:parent', async (answers, _config, _plop) => {
      const parentPlopPath = (await downloadPackage(generator.parent))!;
      const parentPlopFilePath = path.join(parentPlopPath, 'plopfile.js');
      const parentPlop = nodePlop(parentPlopFilePath, { destBasePath, force: false });

      (parentPlop as any).load(justPlopHelpers);

      const parentGenerator = parentPlop.getGenerator(`repo:${generator.parent}`) as any;
      const results = await parentGenerator.runActions(answers);

      if (results.changes) {
        return results.changes.map(change => change.path).join('\n');
      }
    });
  }
github microsoft / just / packages / just-scripts / src / tasks / upgradeStackTask.ts View on Github external
export async function upgradeStackPackageJsonFile(
  projectPath: string,
  templateInstallationPath?: string
): Promise {
  const packageJson = readPackageJson(projectPath);

  if (packageJson && packageJson.just && packageJson.just.stack) {
    const stack = packageJson.just.stack;
    let stackPath: string | null = null;

    if (!templateInstallationPath) {
      stackPath = await downloadPackage(stack);
    } else {
      stackPath = path.join(templateInstallationPath, stack, 'template');
    }

    if (stackPath) {
      upgradePackageDeps(stackPath, projectPath, packageJson);
    } else {
      logger.error(`Cannot read or retrieve the stack package.json for ${stack}`);
    }
  } else if (packageJson) {
    logger.info(
      `Package ${chalk.cyan(packageJson.name)} does not have a "just" key. Skipping upgrade.`
    );
  } else {
    logger.info(`package.json not found under ${chalk.cyan(projectPath)}. Skipping upgrade.`);
  }