0.1.0-beta.6 • Published 3 years ago

vf-core-service-discovery v0.1.0-beta.6

Weekly downloads
12
License
MIT
Repository
-
Last release
3 years ago

Build Codecov David npm license

:warning: 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

SynopsisDescription
runRun the service discovery
config [key] [value]Manage the configuration

run

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

Options

OptionTypeDefaultDescription
-v, --verbosebooleanfalseShow debug information
-l, --log-filestring'vf-core-service-discovery.log'Log file location
-f, --forcebooleanfalseBy-pass the cache
-p, --profilebooleanfalseProfile the service discovery
-r, --reportersarray['cli']The reporters to use (cli, json, html)
-d, --disabledarray[]List of disabled steps (from getConfig, getChangelog getDependents)
-o, --only-outdatedbooleanfalseDisplay only outdated components
-m, --formatstring''Specifies the formatting for the results
-c, --compare-versionsbooleanfalseShows the visual difference between different component versions
-t, --project-typestringautoDetectDefines the project type for use in the dependents discovery phase. Possible values are: html, angular, react, autoDetect
-i, --ignorearray[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

KeyValueDefaultDescription
cacheExpirystring'8h'Time before the cache expires
lastInvalidationDatenullLast time the cache has been invalidated
vfCoreVersionstring''Latest vf-core release version

Options

OptionTypeDefaultDescription
-v, --verbosebooleanfalseShow debug information
-l, --log-filestring'vf-core-service-discovery.log'Log file location
-r, --resetbooleanfalseReset 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.