How to use @beemo/core - 10 common examples

To help you get started, we’ve selected a few @beemo/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 airbnb / nimbus / packages / config-webpack / src / helpers.ts View on Github external
.forEach(modulePath => {
      const packageName = modulePath.split('/node_modules/')[1];
      const esLessName = packageName.replace(/-es$/, '');
      const esPath = new Path(modulePath, 'es');
      const esmPath = new Path(modulePath, 'esm');

      // airbnb-foo/lib -> airbnb-foo/esm
      // optimal/lib -> optimal/esm
      if (esPath.exists() || esmPath.exists()) {
        const aliasPath = esPath.exists() ? `${packageName}/es` : `${packageName}/esm`;
        const aliased = buildTargets.some(targetFolder => {
          if (new Path(modulePath, targetFolder).exists()) {
            aliases[`${packageName}/${targetFolder}`] = aliasPath;

            return true;
          }

          return false;
        });
github beemojs / beemo / packages / cli / src / CLI.ts View on Github external
args => beemo.scaffold(args, args.generator, args.action, args.name),
);

app.command('*', false, {}, () => {
  console.error(chalk.red(beemo.msg('errors:cliNoCommand')));
});

// Run application
// eslint-disable-next-line no-unused-expressions
app
  .usage(`${binName}  [args..]`)
  .epilogue(
    // prettier-ignore
    chalk.gray([
      beemo.msg('app:cliEpilogue', { manualURL }),
      beemo.msg('app:poweredBy', { version: corePackage.version })
    ].join('\n')),
  )
  .demandCommand(1, chalk.red(beemo.msg('errors:cliNoCommand')))
  .showHelpOnFail(true)
  .help().argv;
github beemojs / beemo / packages / driver-typescript / src / TypeScriptDriver.ts View on Github external
({
          dependencies = {},
          devDependencies = {},
          peerDependencies = {},
          tsconfig = {},
          workspace,
        }) => {
          const pkgPath = new Path(workspace.packagePath);
          const srcPath = pkgPath.append(srcFolder);
          const testsPath = pkgPath.append(testsFolder);
          const references: ts.ProjectReference[] = [];
          const promises: Promise[] = [];

          // Extract and determine references
          Object.keys({ ...dependencies, ...devDependencies, ...peerDependencies }).forEach(
            depName => {
              if (namesToPaths[depName]) {
                references.push({
                  path: pkgPath.relativeTo(namesToPaths[depName]).path(),
                });
              }
            },
          );
github beemojs / beemo / packages / driver-typescript / src / TypeScriptDriver.ts View on Github external
this.tool.getWorkspacePackages({ root: workspaceRoot }).forEach(({ workspace }) => {
      const pkgPath = new Path(workspace.packagePath);
      const srcPath = pkgPath.append(srcFolder);
      const testsPath = pkgPath.append(testsFolder);

      // Reference a package *only* if it has a src folder
      if (srcFolder && srcPath.exists()) {
        config.references!.push({
          path: workspaceRoot.relativeTo(pkgPath).path(),
        });

        // Reference a separate tests folder if it exists
        if (testsFolder && testsPath.exists()) {
          config.references!.push({
            path: workspaceRoot.relativeTo(testsPath).path(),
          });
        }
      }
github milesj / build-tool-config / packages / config / src / configs / eslint.ts View on Github external
import fs from 'fs';
import { Path } from '@beemo/core';
import { ESLintConfig } from '@beemo/driver-eslint';
import { EXTS, EXT_PATTERN, IGNORE_PATHS } from '../constants';
import { BeemoProcess } from '../types';

const { tool } = (process.beemo as unknown) as BeemoProcess;
const { node } = tool.config.settings;
// @ts-ignore
const workspacesEnabled = !!tool.package.workspaces;
let project: Path;

// Lint crashes with an OOM error when using project references,
// so just use a single file that globs everything.
if (workspacesEnabled) {
  project = Path.resolve('tsconfig.eslint.json');

  const include: Path[] = [];

  tool.getWorkspacePaths({ relative: true }).forEach(wsPath => {
    include.push(
      new Path(wsPath, 'src/**/*'),
      new Path(wsPath, 'tests/**/*'),
      new Path(wsPath, 'types/**/*'),
    );
  });

  fs.writeFileSync(
    project.path(),
    JSON.stringify({
      extends: './tsconfig.options.json',
      include: include.map(i => i.path()),
github milesj / build-tool-config / packages / config / src / configs / jest.ts View on Github external
import { Path } from '@beemo/core';
import { JestConfig } from '@beemo/driver-jest';
import { IGNORE_PATHS } from '../constants';
import { BeemoProcess } from '../types';

// Package: Run in root
// Workspaces: Run in root
const { tool } = (process.beemo as unknown) as BeemoProcess;
const { react } = tool.config.settings;
// @ts-ignore
const workspacesEnabled = !!tool.package.workspaces;
const setupFilePath = Path.resolve('./tests/setup.ts');
const setupFilesAfterEnv: string[] = [];
const roots: string[] = [];

if (workspacesEnabled) {
  tool.getWorkspacePaths({ relative: true }).forEach(wsPath => {
    roots.push(`/${wsPath.replace('/*', '')}`);
  });
} else {
  roots.push('');
}

if (setupFilePath.exists()) {
  setupFilesAfterEnv.push(setupFilePath.path());
}

const config: JestConfig = {
github milesj / build-tool-config / packages / config / src / configs / eslint.ts View on Github external
new Path(wsPath, 'src/**/*'),
      new Path(wsPath, 'tests/**/*'),
      new Path(wsPath, 'types/**/*'),
    );
  });

  fs.writeFileSync(
    project.path(),
    JSON.stringify({
      extends: './tsconfig.options.json',
      include: include.map(i => i.path()),
    }),
    'utf8',
  );
} else {
  project = Path.resolve('tsconfig.json');
}

// Package: Run in root
// Workspaces: Run in root
const config: ESLintConfig = {
  root: true,
  parser: '@typescript-eslint/parser',
  extends: ['airbnb', 'prettier', 'prettier/react', 'prettier/@typescript-eslint'],
  plugins: ['react-hooks', 'promise', 'unicorn', 'compat', 'babel'],
  ignore: [...IGNORE_PATHS, '*.min.js', '*.map'],
  env: {
    browser: true,
  },
  globals: {
    __DEV__: 'readable',
  },
github beemojs / beemo / packages / cli / src / CLI.ts View on Github external
/* eslint-disable no-console, @typescript-eslint/no-misused-promises */

import path from 'path';
import chalk from 'chalk';
import yargs from 'yargs';
import Beemo, { StdioType } from '@beemo/core';
// @ts-ignore
import corePackage from '@beemo/core/package.json';
import parseSpecialArgv from './parseSpecialArgv';

// 0 node, 1 beemo, 2 command
const { main, parallel } = parseSpecialArgv(process.argv.slice(2));

// Initialize
const binName = path.basename(process.argv[1]).replace('.js', ''); // Windows has an ext
const beemo = new Beemo(main.slice(1), binName);
const app = yargs(main);
const manualURL = process.env.BEEMO_MANUAL_URL || 'https://milesj.gitbook.io/beemo';

// Bootstrap the module
beemo.bootstrapConfigModule();

// Register global options
beemo.bootstrapCLI(app);

// Add a command for each driver
beemo.getPlugins('driver').forEach(driver => {
  const { command, metadata } = driver;

  app.command(
    driver.name,
    metadata.description || beemo.msg('app:run', { title: metadata.title }),
github milesj / build-tool-config / packages / config / lib / scripts / ConvertChangelog.js View on Github external
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_extra_1 = __importDefault(require("fs-extra"));
const fast_glob_1 = __importDefault(require("fast-glob"));
const semver_1 = __importDefault(require("semver"));
const core_1 = require("@beemo/core");
class ConvertChangelogScript extends core_1.Script {
    blueprint() {
        return {};
    }
    async execute(context) {
        const files = await fast_glob_1.default('**/CHANGELOG.md', {
            absolute: true,
            cwd: context.cwd.path(),
            ignore: ['node_modules'],
        });
        return Promise.all(files.map(filePath => this.convertChangelog(filePath)));
    }
    async convertChangelog(filePath) {
        const data = [];
        let lastVersion = '0.0.0';
        (await fs_extra_1.default.readFile(filePath, 'utf8'))
            .split('\n')
github milesj / build-tool-config / packages / config / lib / index.js View on Github external
workspacePrefixes.forEach(wsPrefix => {
                    context.addArgs([
                        new core_1.Path(wsPrefix, constants_1.DIR_PATTERN, `**/*.${exts}`).path(),
                        new core_1.Path(wsPrefix, '*.{md,json}').path(),
                    ]);
                });
            }

@beemo/core

Manage all dev tool configurations in a single centralized repository.

MIT
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis