How to use the @boost/internal.color.pluginName function in @boost/internal

To help you get started, we’ve selected a few @boost/internal 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 milesj / boost / packages / core / src / ConfigLoader.ts View on Github external
Object.values(this.tool.getRegisteredPlugins()).forEach(type => {
      const { contract, singularName, pluralName } = type!;

      this.debug('Generating %s blueprint', color.pluginName(singularName));

      // prettier-ignore
      pluginsBlueprint[pluralName] = array(union>([
        string().notEmpty(),
        shape({ [singularName]: string().notEmpty() }),
        instance(contract, true),
      ], []));
    });
github milesj / boost / packages / plugin / src / Loader.ts View on Github external
createResolver(name: ModuleName): PathResolver {
    const resolver = new PathResolver();
    const { singularName: typeName, projectName } = this.manager;
    const moduleName = name.toLowerCase();
    const modulePattern = MODULE_PART_PATTERN.source;
    const isNotToolOrType = !moduleName.includes(projectName) && !moduleName.includes(typeName);

    this.debug('Resolving possible %s modules', color.pluginName(typeName));

    // @scope/tool-plugin-name
    if (
      moduleName.match(
        new RegExp(`^@${modulePattern}/${projectName}-${typeName}-${modulePattern}$`, 'u'),
      )
    ) {
      this.debug('Found an explicit module with custom scope: %s', color.moduleName(moduleName));

      resolver.lookupNodeModule(moduleName);

      // @tool/plugin-name
    } else if (
      moduleName.match(new RegExp(`^@${projectName}/${typeName}-${modulePattern}$`, 'u'))
    ) {
      this.debug('Found an explicit internal module with scope: %s', color.moduleName(moduleName));
github milesj / boost / packages / core / src / Tool.ts View on Github external
registerPlugin(
    typeName: K,
    contract: AbstractConstructor,
    options: Partial<
      Pick, 'afterBootstrap' | 'beforeBootstrap' | 'scopes'>
    > = {},
  ): this {
    if (this.pluginTypes[typeName]) {
      throw new Error(this.msg('errors:pluginContractExists', { typeName }));
    }

    const name = String(typeName);
    const { afterBootstrap = null, beforeBootstrap = null, scopes = [] } = options;

    this.debug('Registering new plugin type: %s', color.pluginName(name));

    this.plugins[typeName] = new Set();

    this.pluginTypes[typeName] = {
      afterBootstrap,
      beforeBootstrap,
      contract,
      loader: new ModuleLoader(this, name, contract, scopes),
      pluralName: pluralize(name),
      scopes,
      singularName: name,
    };

    return this;
  }
github milesj / boost / packages / plugin / src / Registry.ts View on Github external
registerType(
    typeName: K,
    options: Pick, 'afterBootstrap' | 'beforeBootstrap' | 'validate'>,
  ): this {
    if (this.types[typeName]) {
      throw new RuntimeError('plugin', 'PG_EXISTS_TYPE', [typeName]);
    }

    const name = String(typeName);
    const { afterBootstrap, beforeBootstrap, validate } = options;

    this.debug('Registering new plugin type: %s', color.pluginName(name));

    this.plugins[typeName] = [];

    this.types[typeName] = {
      afterBootstrap,
      beforeBootstrap,
      pluralName: pluralize(name),
      singularName: name,
      validate,
    };

    return this;
  }
github milesj / boost / packages / plugin / src / Manager.ts View on Github external
constructor(projectName: string, typeName: string, options: ManagerOptions) {
    super(options);

    this.projectName = kebabCase(projectName);
    this.singularName = kebabCase(typeName);
    this.pluralName = pluralize(this.singularName);
    this.debug = createDebugger([this.singularName, 'manager']);
    this.loader = new Loader(this);

    this.debug('Creating new plugin type: %s', color.pluginName(typeName));
  }