Skip to content

oss6/vf-core-service-discovery

Repository files navigation

vf-core-service-discovery logo

Build Codecov David npm license

⚠️ This project is currently in active development; use with caution. Thanks!

Demo: https://youtu.be/gF6YAm6Totg

vf-core-service-discovery is a tool to analyse the usage of vf-core in your project.

Table of contents

Install

Install the package using npm or yarn as follows:

$ npm i vf-core-service-discovery
$ yarn add vf-core-service-discovery

or globally

$ npm i -g vf-core-service-discovery
$ yarn global add vf-core-service-discovery

Basic usage

CLI

The main usage of vf-core-service-discovery is through a CLI. A simple run of the following command will gather the usage of vf-core in the project:

$ vf-core-service-discovery run

An output example:

Module

vf-core-service-discovery can also be used as a module. A use case for this is if you want to have more control on the process.

import ServiceDiscovery from 'vf-core-service-discovery';

async function run() {
  const serviceDiscovery = ServiceDiscovery.getInstance();

  await serviceDiscovery.setup({
    forceRun: false,
    verbose: true,
    logFile: 'test.log',
    loggingEnabled: true,
    profile: false,
  });

  const items = await serviceDiscovery.run(true);

  console.log(items);
}

run();

Features

  • Get package information such as current version, latest version, and component status.
  • Get changelog if current and latest versions are mismatched.
  • For each installed component get the dependent files (for now only .html files).

CLI documentation

Synopsis Description
run Run the service discovery
config [key] [value] Manage the configuration

run

Synopsis: vf-core-service-discovery run [options]

Options

Option Type Default Description
-v, --verbose boolean false Show debug information
-l, --log-file string 'vf-core-service-discovery.log' Log file location
-f, --force boolean false By-pass the cache
-p, --profile boolean false Profile the service discovery
-r, --reporters array ['cli'] The reporters to use (cli, json, html)
-d, --disabled array [] List of disabled steps (from getConfig, getChangelog getDependents)
-o, --only-outdated boolean false Display only outdated components
-m, --format string '' Specifies the formatting for the results
-c, --compare-versions boolean false Shows the visual difference between different component versions
-t, --project-type string autoDetect Defines the project type for use in the dependents discovery phase. Possible values are: html, angular, react, autoDetect
-i, --ignore array [node_modules] Defines the ignored paths for the dependents discovery phase

Custom formatting

If you would like to use your own formatting for displaying the results in the CLI you can specify the --format option. The following tokens are used for displaying specific information for each discovery item:

  • %name: component name
  • %usedVersion: the version installed by your project
  • %latestVersion: the package's latest version
  • %changelog(...): the changelog if applicable (i.e. if used version != latest version)
  • %changelog(...%version...): the version of a changelog item
  • %changelog(...%changes(...)...): the changes of a changelog item
  • %changes(...$change...): the actual change in a changelog item
  • $dependents(...): the dependents
  • $dependents(...$depenent...): the dependent item

Examples

$ vf-core-service-discovery --format "%name (%usedVersion, %latestVersion)"
$ ...
$ vf-box (1.5.6, 1.6.0)
$ vf-card (2.1.4, 2.1.4)
$ vf-core-service-discovery --format "%name\nChangelog\n%changelog(%version\n%changes(> %change)\n)"
$ vf-box
$ Changelog
$ 2.3.0
$ > updates font size for title/heading> makes sure the text is black inside the `--easy` variant.

$ vf-grid
$ Changelog
$ 1.4.0
$ > fixes flexbox fallback grid when there are items on two or more rows> fixes widths on flexbox fallback grid.
$ 1.3.0
$ > makes the layout something that can now use 'extends' within nunjucks

config

Synopsis: vf-core-service-discovery config [key] [value] [options]

Configuration items

Key Value Default Description
cacheExpiry string '8h' Time before the cache expires
lastInvalidation Date null Last time the cache has been invalidated
vfCoreVersion string '' Latest vf-core release version

Options

Option Type Default Description
-v, --verbose boolean false Show debug information
-l, --log-file string 'vf-core-service-discovery.log' Log file location
-r, --reset boolean false Reset configuration to defaults

Module documentation

Check the module documentation here: https://oss6.github.io/vf-core-service-discovery.

What's next

  1. Find dependents in different types of projects (for a start Angular and React).
  2. API documentation using TypeDoc.
  3. Add performance tests.

Contributing

We welcome contributors and maintainers! To contribute please check the contributing page out.