15.2.1 • Published 2 years ago

hops-info v15.2.1

Weekly downloads
1,540
License
MIT
Repository
github
Last release
2 years ago

hops-info

hops-info is a mixin providing output for hops's command line interface. Besides that, it allows other mixins to define pre-flight checks that are run during application startup.

Installation

$ yarn add hops-info # OR npm install hops-info

CLI

hops-info does not define any commands of its own, but only adds some global CLI flags to control console output. Using the flags -v/--verbose and -q/--quiet once or multiple times, you can de- and increase the log output. Default log level is info, passing a single -q will reduce it to warning while a single -v will bump it to verbose. Passing -qqq will silence all output completely.

Log Levels

{
  error: 0,
  warning: 1,
  info: 2,
  verbose: 3,
}

Additionally, you can pass --color/--no-color flags to manually enable or disable output colors, but you can usually rely on hops-info to determine color support automatically.

$ hops start -v --no-color

Configuration

Render Options

This preset has only a single runtime option which can be passed to the render() options inside the webVitals key (see example above).

NameTypeDefaultRequiredDescription
webVitals.handlerReportHandlerundefinednoA callback to report web vitals metrics API
handler

By default this preset adds no report handler for web vitals metrics. You can add your own handler through this option to report the core web vitals to your analytics provider.

Take a look at these resources for implementation details:

export default render(<MyApp />, {
  webVitals: { handler: console.log },
});

Mixin Hooks API

Caution: Please be aware that the mixin hooks are not part of the SemVer API contract. This means that hook methods and signatures can change even in minor releases. Therefore it's up to you to make sure that all hooks that you are using in your own mixins still adhere to the new implementation after an upgrade of a Hops packages.

getLogger() (callable) core/server

This utility hook defined by hops-info provides other mixins with a fully configured logger instance. This logger has three standard log methods (info, warning and error) that correspond to the lower three log levels described above. Additionally, it supports arbitrary log methods (e.g. request, hint, foo)

const { Mixin } = require('hops-mixin');

module.exports = class FooMixin extends Mixin {
  bar() {
    if (typeof this.getLogger === 'function') {
      const logger = this.getLogger();
      logger.info('this will log an info message');
      logger.warning('this will log a warning message');
      logger.error('this will log an error message');
      logger.baz('this will log a verbose message');
      logger.qux('this will log a verbose message, too');
    }
  }
};

getWebVitalsHandler(): ReportHandler (override) browser

Hook to return a custom ReportHandler.

Beware that handler passed as render option takes precedence.

diagnose(doctor, mode) (parallel) core

By implementing this method, your core mixin can perform pre-flight checks during application startup/build and create warnings & errors. If you need to do something asynchronous at this point, just return a Promise.

The second argument mode lets you create context-sensitive warnings/errors. Its possible values are:

  • 'build-serve'
  • 'develop'
  • 'serve'
  • 'build'
  • 'indeterminate'
const { Mixin } = require('hops-mixin');

module.exports = class FooMixin extends Mixin {
  diagnose(doctor, mode) {
    doctor.diagnoseDuplicatePackages('bar');
    const mathIsBroken = 1 + 1 !== 2;
    const message = 'Math is broken.';

    if (mode === 'develop') doctor.pushWarning(message);
    if (mode === 'serve') doctor.pushError('heavy-math', message);
  }
};

Additionally, you can use the helper methods defined on our semi-private doctor object that is being passed into this hook.

15.2.1

2 years ago

15.2.0

2 years ago

16.0.0-nightly.5

2 years ago

15.1.1

2 years ago

15.1.2

2 years ago

15.1.0

2 years ago

16.0.0-nightly.1

2 years ago

16.0.0-nightly.2

2 years ago

16.0.0-nightly.3

2 years ago

15.0.2

2 years ago

15.0.1

3 years ago

16.0.0-nightly.0

3 years ago

15.0.0

3 years ago

14.5.0

3 years ago

14.4.1

3 years ago

14.4.0

3 years ago

14.3.2

3 years ago

14.3.1

3 years ago

14.3.0

3 years ago

15.0.0-nightly.9

3 years ago

15.0.0-nightly.8

3 years ago

15.0.0-nightly.7

3 years ago

15.0.0-nightly.6

3 years ago

14.2.1

3 years ago

15.0.0-nightly.5

3 years ago

15.0.0-nightly.4

3 years ago

15.0.0-nightly.3

3 years ago

13.4.3

3 years ago

14.2.0

3 years ago

15.0.0-nightly.2

3 years ago

14.1.0

3 years ago

13.4.2

3 years ago

15.0.0-nightly.1

3 years ago

15.0.0-nightly.0

3 years ago

14.0.0

3 years ago

14.0.1

3 years ago

13.4.1

3 years ago

13.4.0

3 years ago

12.5.10

3 years ago

14.0.0-nightly.9

3 years ago

14.0.0-nightly.8

3 years ago

13.3.5

3 years ago

13.3.4

3 years ago

13.3.3

3 years ago

12.5.9

3 years ago

14.0.0-nightly.7

3 years ago

13.3.2

3 years ago

13.3.1

3 years ago

14.0.0-nightly.6

3 years ago

13.3.0

3 years ago

14.0.0-nightly.5

3 years ago

12.5.8

3 years ago

13.2.2

3 years ago

14.0.0-nightly.4

3 years ago

12.5.7

3 years ago

13.2.1

3 years ago

14.0.0-nightly.3

3 years ago

12.5.6

3 years ago

14.0.0-nightly.2

3 years ago

14.0.0-nightly.1

4 years ago

13.2.0

4 years ago

12.5.5

4 years ago

13.1.0

4 years ago

12.5.4

4 years ago

13.0.0

4 years ago

12.5.3

4 years ago

13.0.0-rc.0

4 years ago

12.5.2

4 years ago

13.0.0-alpha.2

4 years ago

13.0.0-alpha.1

4 years ago

12.5.1

4 years ago

13.0.0-alpha.0

4 years ago

12.5.0

4 years ago

12.4.0

4 years ago

12.3.0

4 years ago

12.2.2

4 years ago

12.2.1

4 years ago

12.2.0

4 years ago