Data sources provide a uniform way of consuming the webpack compilation statistics, as well as reporting back to them (todo).
As not all teams/organisations will have the same approach, having a uniform way allows for greatly flexibility for this plugin to be used.
Every data source should do the following:
- Create a class extending the
BaseDataSource:- implement
getCompilationStats()in the extending base class- Failure to do so will cause an error to be thrown
- Use
this.validateCompilationStatsto validate the data (ensuring the correct webpack stats properties are there) - Return the stats
- make this the default export in the folder's
index.tsfile
- implement
- Implement a
cli.tswhich follows theCliPrograminterface:- Refer to
commander's Action handler (sub)commands for setting up your command - Use the
execActioncallback as the means to provide the necessary options back to the maincliprogram - Register your CLI to the
cliIndex.tsfile
- Refer to
If a data source requires extending, or a new data source is needed please feel free to raise a PR (more the merrier).
Present data sources:
All data sources are accessible via the root import, as <name>DataSource (i.e. TeamCity is available as TeamCityDataSource):
import { TeamCityDataSource } from 'webpack-bundle-delta';Create an instance of the data source passing it the necessary options, and pass it to the danger command.