How to use the bolt.getWorkspaces function in bolt

To help you get started, we’ve selected a few bolt 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 wwselleck / bolt-interactive / src / prompts / commands / add.ts View on Github external
name: "depType",
      type: "list",
      choices: TypeChoices
    }
  ])).depType;

  const packages = packagesInput.split(" ");

  if (scope.kind === ScopeType.PROJECT) {
    await projectAdd({
      deps: packages.map(toDependency),
      type: depType
    });
  } else if (scope.kind === ScopeType.ALL) {
    // bolt ws add isn't implemented yet, do bolt w for each workspace
    const workspaces = await getWorkspaces();
    for (const w of workspaces) {
      await workspaceAdd({
        pkgName: w.name,
        deps: packages.map(toDependency),
        type: depType
      });
    }
  } else if (scope.kind === ScopeType.SELECT) {
    for (const w of scope.workspaces) {
      await workspaceAdd({
        pkgName: w.name,
        deps: packages.map(toDependency),
        type: depType
      });
    }
  }
github skatejs / skatejs / projector.js View on Github external
async function changed() {
  for (const w of await getWorkspaces()) {
    const changes = await getChangesInWorkspace(w);
    if (changes.length) {
      console.log(
        outdent`

          ${w.config.name} ${chalk`{green ${
          w.config.version
        }}`} -> ${chalk`{yellow ${calculateNextVersion(
          w.config.version,
          changes
        )}}`}
            ${changes
              .map(
                d =>
                  `${d.hash} ${chalk`{yellow ${inferReleaseType(
                    d.message
github skatejs / skatejs / projector.js View on Github external
async function clean() {
  parallel(() => require('fs-extra').remove('./site/public'));
  for (const w of await getWorkspaces()) {
    parallel(w.dir, async dir => {
      const fs = require('fs-extra');
      const path = require('path');
      const toRemove = path.relative(process.cwd(), path.join(dir, 'dist'));
      await fs.remove(toRemove);
      return toRemove;
    }).then(console.log);
  }
}
github skatejs / skatejs / projector.js View on Github external
async function release({ packages, type }) {
  need(packages, 'Please specify at least one package.');
  need(type, 'Please specify a release type (or version number).');
  await exec('bolt', ['build']);
  const ws = await getWorkspaces();
  for (const pkg of packages.split(',')) {
    const name = pkg.trim();
    const w = ws.filter(w => w.name === name)[0];
    if (!w) continue;
    const cwd = w.dir;
    await exec('npm', ['--no-git-tag-version', 'version', type], { cwd });
    const ver = require(path.join(cwd, 'package.json')).version;
    const tag = `${name}-${ver}`;
    await exec('git', ['commit', '-am', tag], { cwd });
    await exec('git', ['tag', '-a', tag, '-m', tag], { cwd });
    await exec('npm', ['publish'], { cwd });
  }
  await exec('git', ['push', '--follow-tags']);
}
github wwselleck / bolt-interactive / src / prompts / workspaceSelect.ts View on Github external
export default async function runWorkspacesSelectPrompt(): Promise<
  Workspace[]
> {
  const workspaces = await getWorkspaces();

  const choices = workspaces.map(w => ({
    name: w.name,
    value: w
  }));
  const answers = await inquirer.prompt([
    {
      type: "checkbox-plus",
      name: "workspaces",
      message: "Select workspaces",
      searchable: true,
      async source(_: any, input = "") {
        input = input || "";
        const results = fuzzy
          .filter(input, choices, {
            extract: (c: any) => c.name
github atlassian / extract-react-types / website / loaders / docs-loader / index.js View on Github external
module.exports = async function docsLoader() {
  let docs = {
    packageDocs: {},
    documentation: {}
  };
  const ws = await bolt.getWorkspaces();

  for (let workspace of ws) {
    const readMeExists = fs.existsSync(path.resolve(workspace.dir, 'README.md'));
    if (readMeExists) {
      docs.packageDocs[workspace.name] = await readFile(
        path.join(workspace.dir, 'README.md'),
        'utf-8'
      );
    }
  }

  const staticDocs = await readDir(path.join(__dirname, '..', '..', '..', 'docs'));

  for (let staticDoc of staticDocs) {
    docs.documentation[staticDoc] = await readFile(
      path.join(__dirname, '..', '..', '..', 'docs', staticDoc),
github skatejs / skatejs / projector.js View on Github external
async function build({ pkg }) {
  const ws = await getWorkspaces();
  await Promise.all(
    ws.map(async w => {
      if (pkg && !w.config.name.match(new RegExp(pkg))) {
        return;
      }

      await parallel(w.dir, w.config, async (dir, pkg) => {
        const exec = require('execa');
        const fs = require('fs-extra');
        const path = require('path');
        const indexTs = path.join(dir, 'src', 'index.ts');
        const indexTsx = path.join(dir, 'src', 'index.tsx');
        const tsConfig = path.join(dir, 'tsconfig.json');

        if (!await fs.exists(indexTs) && !await fs.exists(indexTsx)) {
          return;
github wwselleck / bolt-interactive / src / prompts / scopeSelect.ts View on Github external
choices
    }
  ])).scope;

  switch (selectedScopeType) {
    case ScopeType.SELECT: {
      const workspaces = await runWorkspacesSelectPrompt();
      return {
        kind: selectedScopeType,
        workspaces
      };
    }
    case ScopeType.ALL:
      return {
        kind: selectedScopeType,
        workspaces: await getWorkspaces()
      };
    case ScopeType.PROJECT:
      return { kind: selectedScopeType };
  }
}
github skatejs / skatejs / projector.js View on Github external
async function normalize() {
  const corePkg = require(path.join(__dirname, 'package.json'));
  for (const w of await getWorkspaces()) {
    const pkg = Object.keys(w.config)
      .sort()
      .reduce((prev, next) => {
        prev[next] = w.config[next];
        return prev;
      }, {});
    ['author', 'bugs', 'homepage', 'keywords', 'license', 'repository'].forEach(
      key => {
        pkg[key] = corePkg[key];
      }
    );
    await fs.writeFile(
      path.join(w.dir, 'package.json'),
      JSON.stringify(pkg, null, 2)
    );
  }