How to use @auto-it/core - 10 common examples

To help you get started, weโ€™ve selected a few @auto-it/core 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 intuit / auto / plugins / npm / src / index.ts View on Github external
await execPromise('npx', [
          'lerna',
          'publish',
          ...tag,
          '--yes',
          // Plugins can add as many commits as they want, lerna will still
          // publish the changed package versions. from-git broke when HEAD
          // didn't contain the tags
          'from-package',
          ...verboseArgs
        ]);
      } else {
        const { private: isPrivate, name } = await loadPackageJson();
        const isScopedPackage = name.match(/@\S+\/\S+/);

        await execPromise(
          'npm',
          !isPrivate && isScopedPackage
            ? ['publish', '--access', 'public', ...tag, ...verboseArgs]
            : ['publish', ...tag, ...verboseArgs]
        );
      }

      await execPromise('git', [
        'push',
        '--follow-tags',
        '--set-upstream',
        'origin',
        branch || auto.baseBranch
      ]);
      auto.logger.verbose.info('Successfully published repo');
    });
github intuit / auto / plugins / maven / src / index.ts View on Github external
const newVersion =
        // After release we bump the version by a patch and add -SNAPSHOT
        // Given that we do not need to increment when versioning, since
        // it has already been done
        version === 'patch'
          ? previousVersion
          : inc(previousVersion, version as ReleaseType);

      if (!newVersion) {
        throw new Error(
          `Could not increment previous version: ${previousVersion}`
        );
      }

      await execPromise('mvn', ['clean']);
      await execPromise('mvn', [
        '-B',
        'release:prepare',
        `-Dtag=v${newVersion}`,
        `-DreleaseVersion=${newVersion}`,
        '-DpushChanges=false'
      ]);
      await execPromise('git', ['checkout', '-b', 'dev-snapshot']);
      await execPromise('git', ['checkout', 'master']);
      await execPromise('git', ['reset', '--hard', 'HEAD~1']);
    });
github intuit / auto / plugins / chrome / src / index.ts View on Github external
auto.hooks.publish.tapPromise(this.name, async () => {
      // publish extension
      await execPromise('webstore', [
        'upload',
        '--extension-id',
        this.options.id,
        '--source',
        this.options.build,
        '--auto-publish'
      ]);

      // push to github
      await execPromise('git', [
        'push',
        '--follow-tags',
        '--set-upstream',
        'origin',
        auto.baseBranch
      ]);
github intuit / auto / plugins / maven / src / index.ts View on Github external
auto.hooks.afterShipIt.tapPromise(this.name, async () => {
      // prepare for next development iteration
      await execPromise('git', ['reset', '--hard', 'dev-snapshot']);
      await execPromise('git', ['branch', '-d', 'dev-snapshot']);
      await execPromise('git', ['push', 'origin', auto.baseBranch]);
    });
  }
github intuit / auto / plugins / npm / src / index.ts View on Github external
auto.logger.verbose.info('Set CI NPM_TOKEN');
      }

      const lastRelease = await auto.git!.getLatestRelease();
      const latestTag =
        (await auto.git?.getLastTagNotInBaseBranch(prereleaseBranch)) ||
        (await getPreviousVersion(auto, prereleaseBranch));

      if (isMonorepo()) {
        auto.logger.verbose.info('Detected monorepo, using lerna');
        const isIndependent = getLernaJson().version === 'independent';
        // It's hard to accurately predict how we should bump independent versions.
        // So we just prerelease most of the time. (independent only)
        const next = isIndependent
          ? 'prerelease'
          : determineNextVersion(
              lastRelease,
              latestTag,
              bump,
              prereleaseBranch
            );

        auto.logger.verbose.info({
          lastRelease,
          latestTag,
          bump,
          prereleaseBranch,
          next
        });

        await execPromise('npx', [
          'lerna',
github intuit / auto / plugins / npm / src / index.ts View on Github external
);
        // Move branch back one commit
        await execPromise('git', ['reset', '--hard', 'HEAD~1']);

        auto.logger.verbose.info('Successfully published next version');

        preReleaseVersions = [
          ...preReleaseVersions,
          ...tags.map(auto.prefixRelease)
        ];
      } else {
        auto.logger.verbose.info('Detected single npm package');

        await execPromise('npm', [
          'version',
          determineNextVersion(lastRelease, latestTag, bump, prereleaseBranch),
          // we do not want to commit the next version. this causes
          // merge conflicts when merged into master
          '--no-git-tag-version',
          ...verboseArgs
        ]);

        const { version } = await loadPackageJson();
        await execPromise('git', ['tag', auto.prefixRelease(version!)]);

        await execPromise('npm', [
          'publish',
          '--tag',
          prereleaseBranch,
          ...verboseArgs
        ]);
github intuit / auto / plugins / npm / src / index.ts View on Github external
apply(auto: Auto) {
    const isVerbose =
      auto.logger.logLevel === 'verbose' ||
      auto.logger.logLevel === 'veryVerbose';
    const verboseArgs = isVerbose ? verbose : [];
    const prereleaseBranches = auto.config?.prereleaseBranches!;
    const branch = getCurrentBranch();
    // if ran from master we publish the prerelease to the first
    // configured prerelease branch
    const prereleaseBranch =
      branch && prereleaseBranches.includes(branch)
        ? branch
        : prereleaseBranches[0];

    auto.hooks.beforeShipIt.tap(this.name, async () => {
      if (!isCi) {
        return;
      }

      auto.checkEnv(this.name, 'NPM_TOKEN');
    });

    auto.hooks.getAuthor.tapPromise(this.name, async () => {
github intuit / auto / plugins / npm / src / index.ts View on Github external
auto.hooks.version.tapPromise(this.name, async version => {
      const isBaseBranch = branch === auto.baseBranch;

      if (isMonorepo()) {
        auto.logger.verbose.info('Detected monorepo, using lerna');
        const isIndependent = getLernaJson().version === 'independent';
        const monorepoBump =
          isIndependent || !isBaseBranch
            ? undefined
            : await bumpLatest(getMonorepoPackage(), version);

        await execPromise('npx', [
          'lerna',
          'version',
          monorepoBump || version,
          !isIndependent && this.forcePublish && '--force-publish',
          '--no-commit-hooks',
          '--yes',
          '--no-push',
          '-m',
          VERSION_COMMIT_MESSAGE,
          ...verboseArgs
        ]);
        auto.logger.verbose.info('Successfully versioned repo');
        return;
      }

      const latestBump = isBaseBranch
github intuit / auto / packages / cli / src / run.ts View on Github external
export async function run(command: string, args: ApiOptions) {
  const auto = new Auto(args);

  switch (command) {
    case 'init':
      await auto.init(args as IInitOptions);
      break;
    case 'create-labels':
      await auto.loadConfig();
      await auto.createLabels(args as ICreateLabelsOptions);
      break;
    case 'label':
      await auto.loadConfig();
      await auto.label(args as ILabelOptions);
      break;
    case 'pr-check':
      await auto.loadConfig();
      await auto.prCheck(args as IPRCheckOptions);
github intuit / auto / plugins / git-tag / src / index.ts View on Github external
auto.hooks.version.tapPromise(this.name, async version => {
      if (!auto.git) {
        return;
      }

      const lastTag = await auto.git.getLatestTagInBranch();
      const newTag = inc(lastTag, version as ReleaseType);
      const branch = getCurrentBranch() || '';

      if (!newTag) {
        return;
      }

      await execPromise('git', ['tag', newTag]);
      await execPromise('git', [
        'push',
        '--follow-tags',
        '--set-upstream',
        'origin',
        branch || auto.baseBranch
      ]);
    });