How to use @ts-common/azure-js-dev-tools - 10 common examples

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
shouldPack = true;
          } else if (toPack === PackagesToPack.DifferentVersion) {
            let npmPackageVersion: string | undefined;
            try {
              const npmViewResult: NPMViewResult = npm.view({ packageName, ...runOptions, showCommand: false, showOutput: false });
              const distTags: StringMap | undefined = npmViewResult["dist-tags"];
              npmPackageVersion = distTags && distTags["latest"];
            }
            catch (error) {
              // This happens if the package doesn't exist in NPM.
            }

            _logger.logTrace(`Local version: ${localPackageVersion}, NPM version: ${npmPackageVersion}`);
            shouldPack = localPackageVersion !== npmPackageVersion;
          } else if (toPack === PackagesToPack.BranchHasChanges) {
            const packageFolderPathWithSep: string = normalize(packageFolderPath + path.posix.sep);
            shouldPack = !!changedFiles && contains(changedFiles, (changedFilePath: string) => normalize(changedFilePath).startsWith(packageFolderPathWithSep));
          }

          if (!shouldPack) {
            upToDatePackages++;
          } else {
            _logger.log(`Packing package "${packageName}" with version "${localPackageVersion}"...${args.whatif ? " (SKIPPED)" : ""}`);
            if (!args.whatif) {
              try {
                npm.pack(runOptions);
                const packFileName = `${packageName.replace("/", "-").replace("@", "")}-${localPackageVersion}.tgz`
                const packFilePath = path.join(packageFolderPath, packFileName);
                fs.renameSync(packFilePath, path.join(dropFolderPath, packFileName));
                _logger.log(`Filename: ${packFileName}`);
                packedPackages++;
              }
github Azure / azure-sdk-for-js / sdk / core / core-http / .scripts / testDependentProjects.ts View on Github external
async function execAndLog(executable: string, args?: string[], options?: RunOptions): Promise {
  const command: Command = {
    executable,
    args,
  };

  console.log(`\n\nRunning ${commandToString(command)}`);

  const result: RunResult = await run(command, undefined, {
    ...options,
    log: console.log,
    showCommand: true,
    showResult: true,
  });

  console.log(`\Result of "${commandToString(command)}" [Exit code: ${result.exitCode}]:\n` + result.stdout + "\n");

  if (result.exitCode) {
    console.error(`Error while running "${commandToString(command)}": ${result.error}`);
    throw new Error(result.stderr);
  }

  return Promise.resolve(result);
}
github Azure / ms-rest-js / .scripts / testDependentProjects.ts View on Github external
async function execAndLog(executable: string, args?: string[], options?: RunOptions): Promise {
  const command: Command = {
    executable,
    args,
  };

  console.log(`\n\nRunning ${commandToString(command)}`);

  const result: RunResult = await run(command, undefined, {
    ...options,
    log: console.log,
    showCommand: true,
    showResult: true,
  });

  console.log(`\nResult of "${commandToString(command)}" [Exit code: ${result.exitCode}]:\n` + result.stdout + "\n");

  if (result.exitCode) {
    console.error(`Error while running "${commandToString(command)}": ${result.error}`);
    throw new Error(result.stderr);
  }

  return Promise.resolve(result);
}
github Azure / ms-rest-js / .scripts / testDependentProjects.ts View on Github external
async function execAndLog(executable: string, args?: string[], options?: RunOptions): Promise {
  const command: Command = {
    executable,
    args,
  };

  console.log(`\n\nRunning ${commandToString(command)}`);

  const result: RunResult = await run(command, undefined, {
    ...options,
    log: console.log,
    showCommand: true,
    showResult: true,
  });

  console.log(`\nResult of "${commandToString(command)}" [Exit code: ${result.exitCode}]:\n` + result.stdout + "\n");

  if (result.exitCode) {
    console.error(`Error while running "${commandToString(command)}": ${result.error}`);
    throw new Error(result.stderr);
  }

  return Promise.resolve(result);
}
github Azure / azure-sdk-for-js / sdk / core / core-http / .scripts / testDependentProjects.ts View on Github external
async function execAndLog(executable: string, args?: string[], options?: RunOptions): Promise {
  const command: Command = {
    executable,
    args,
  };

  console.log(`\n\nRunning ${commandToString(command)}`);

  const result: RunResult = await run(command, undefined, {
    ...options,
    log: console.log,
    showCommand: true,
    showResult: true,
  });

  console.log(`\Result of "${commandToString(command)}" [Exit code: ${result.exitCode}]:\n` + result.stdout + "\n");

  if (result.exitCode) {
    console.error(`Error while running "${commandToString(command)}": ${result.error}`);
    throw new Error(result.stderr);
  }

  return Promise.resolve(result);
github Azure / ms-rest-js / .scripts / testDependentProjects.ts View on Github external
args,
  };

  console.log(`\n\nRunning ${commandToString(command)}`);

  const result: RunResult = await run(command, undefined, {
    ...options,
    log: console.log,
    showCommand: true,
    showResult: true,
  });

  console.log(`\nResult of "${commandToString(command)}" [Exit code: ${result.exitCode}]:\n` + result.stdout + "\n");

  if (result.exitCode) {
    console.error(`Error while running "${commandToString(command)}": ${result.error}`);
    throw new Error(result.stderr);
  }

  return Promise.resolve(result);
}
github Azure / azure-sdk-for-js / sdk / core / core-http / .scripts / testDependentProjects.ts View on Github external
args,
  };

  console.log(`\n\nRunning ${commandToString(command)}`);

  const result: RunResult = await run(command, undefined, {
    ...options,
    log: console.log,
    showCommand: true,
    showResult: true,
  });

  console.log(`\Result of "${commandToString(command)}" [Exit code: ${result.exitCode}]:\n` + result.stdout + "\n");

  if (result.exitCode) {
    console.error(`Error while running "${commandToString(command)}": ${result.error}`);
    throw new Error(result.stderr);
  }

  return Promise.resolve(result);
}
github Azure / autorest.typescript / test / azure / parameterGrouping.ts View on Github external
it('should reject null required parameters', async function () {
      const error = await assertEx.throwsAsync(testClient.parameterGrouping.postRequired(null));
      assert(error);
      assert.strictEqual(error.message, "parameterGroupingPostRequiredParameters.path cannot be null or undefined.");
    });
github Azure / azure-sdk-for-js / sdk / core / core-http / .scripts / checkConstantsVersion.ts View on Github external
function error(text: string): void {
    logger.logError(text);
    exitCode = 1;
  }

  const packageJsonFilePath: string | undefined = findPackageJsonFileSync(__dirname);
  if (!packageJsonFilePath) {
    error("Could not find a package.json file.");
  } else {
    const packageJson: PackageJson = readPackageJsonFileSync(packageJsonFilePath);
    const packageVersion: string | undefined = packageJson.version;
    if (!packageVersion) {
      error(`Could not find a version property in ${packageJsonFilePath}.`);
    } else {
      const repositoryRootFolderPath: string = getParentFolderPath(packageJsonFilePath);
      const constantsTsFilePath: string = joinPath(repositoryRootFolderPath, "lib/util/constants.ts");
      if (!fileExistsSync(constantsTsFilePath)) {
        error(`${constantsTsFilePath} doesn't exist anymore. Where'd it go?`);
      } else {
        const constantsTsFileContents: string = readFileSync(constantsTsFilePath, { encoding: "utf8" });
        const regularExpressionString = `msRestVersion: "(.*)"`;
        const regularExpression = new RegExp(regularExpressionString);
        const match: RegExpMatchArray | null = constantsTsFileContents.match(regularExpression);
        if (!match) {
          error(`${constantsTsFilePath} doesn't contain a match for ${regularExpressionString}.`);
        } else if (match[1] !== packageVersion) {
          error(`Expected ${constantsTsFilePath} to contain an msRestVersion property with the value "${packageVersion}", but it was "${match[1]}" instead.`);
        } else {
          logger.logInfo(`${constantsTsFilePath} contained the correct value for msRestVersion ("${packageVersion}").`);
        }
      }
    }
github Azure / autorest.typescript / .scripts / dependenciesOptions.ts View on Github external
import { ChangeClonedDependenciesToOptions, joinPath, resolvePath, Logger, getDefaultLogger, wrapLogger } from "@ts-common/azure-js-dev-tools";

const repositoryFolderPath: string = resolvePath(__dirname, "..");
const testFolderPath: string = joinPath(repositoryFolderPath, "test");
const multiapiFolderPath: string = joinPath(testFolderPath, "multiapi");
const multiapiPackagesFolderPath: string = joinPath(multiapiFolderPath, "packages");
export const dependenciesOptions: ChangeClonedDependenciesToOptions = {
  packageFolders: [
    {
      path: repositoryFolderPath,
      dependenciesToIgnore: ["autorest"]
    },
    joinPath(testFolderPath, "azuremetadata/generated/Lro"),
    joinPath(testFolderPath, "metadata/generated/BodyComplex"),
    {
      path: joinPath(multiapiPackagesFolderPath, "multiapi-test-2018-02-01"),
      runNPMInstall: false
    },
    {
      path: joinPath(multiapiPackagesFolderPath, "multiapi-test-2017-10-01"),
      runNPMInstall: false