How to use the @ts-common/azure-js-dev-tools.NPMScope function in @ts-common/azure-js-dev-tools

To help you get started, we’ve selected a few @ts-common/azure-js-dev-tools 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 Azure / azure-sdk-for-js / gulpfile.ts View on Github external
_logger.logTrace(changedFilePath);
        }
      }
    }
  }

  const packageFolderRoot: string = path.resolve(__dirname, "sdk");
  _logger.logTrace(`INFO: Searching for package folders in ${packageFolderRoot}`);
  const packageFolderPaths: string[] | undefined = getPackageFolderPaths(packageFolderRoot);
  if (!packageFolderPaths) {
    _logger.logTrace(`INFO: The folder ${packageFolderPaths} doesn't exist.`);
  } else {
    for (const packageFolderPath of packageFolderPaths) {
      _logger.logTrace(`INFO: Processing ${packageFolderPath}`);

      const npm = new NPMScope({ executionFolderPath: packageFolderPath });
      const packageJsonFilePath: string = joinPath(packageFolderPath, "package.json");
      const packageJson: { [propertyName: string]: any } = require(packageJsonFilePath);
      const packageName: string = packageJson.name;

      if (packagesToIgnore.indexOf(packageName) !== -1) {
        _logger.log(`INFO: Skipping package ${packageName}`);
        ++skippedPackages;
      } else if (!args.package || args.package === packageName || endsWith(packageName, `-${args.package}`)) {
        const localPackageVersion: string = packageJson.version;
        if (!localPackageVersion) {
          _logger.log(`ERROR: "${packageJsonFilePath}" doesn't have a version specified.`);
          errorPackages++;
        }
        else {
          let shouldPack: boolean = false;
github Azure / azure-sdk-for-js / .scripts / gulp.ts View on Github external
if (!include) {
        include = /.*/;
    }

    const jsonPackageInfos = await getPackageInformationFromPackageJsons(azureSdkForJsRoot);

    for (const packageInfo of jsonPackageInfos) {
        _logger.log(`Analyzing ${packageInfo.name} package`);
        const config = getPackageConfig(azureSdkForJsRoot, packageInfo, include, exclude);
        if (!config) {
            _logger.log(`Skipping ${packageInfo.name} package`);
            continue;
        }

        const nodeName = packageInfo.name!.replace("@", "").replace("/", "-");
        const npm = new NPMScope({});
        const npmViewResult: NPMViewResult = npm.view({ packageName: nodeName });

        if (!npmViewResult.version) {
            continue;
        }

        config.content["version"] = npmViewResult.version!.replace("-preview", "");
        fs.writeFileSync(config.path, JSON.stringify(config.content, undefined, "  ") + "\n");
        _logger.log("Saved");
    }
}