@vrn-deco/boilerplate-protocol v1.3.2
@vrn-deco/boilerplate-protocol
English | 中文
This package is mainly for type definitions and interface definitions, which are used to standardize related implementation packages.
Specification
@vrn-deco/boilerplate-protocol v1 defines manifest, preset, boi-package related types and function interfaces,see src/types.ts
Manifest
The Manifest type is defined and exported in the package
+--------------------------------+
| @vrn-deco/boilerplate-protocol |
+--------------------------------+
|
v
+--------------------------------+ +-------------------+
| manifest package | --> | external services |
+--------------------------------+ +-------------------+
^
|
+--------------------------------+
| boi-packages... |
+--------------------------------+manifest-package should implement:
Gather information about
boi-packagesthat need to be listedOrganized into data conforming to the
ManifestinterfaceProvide a way to obtain this data for external service calls
Presets
The package defines and exports the PresetRunner functional interface and the PresetOptions type
+-----------------+ +-------------------+
| | --> | API call |
| | +-------------------+
+--------------------------------+ | |
| @vrn-deco/boilerplate-protocol | --> | preset-packages |
+--------------------------------+ | |
| | +-------------------+
| | --> | command line call |
+-----------------+ +-------------------+preset-package should implement:
A function
runnerimplementing thePresetRunnerinterfaceParse and validate
PresetOptionsread configuration files in
boi-packageImplement your own preset processing logic
initHandler,installHandler,cleanHandler- When a custom script exists in the configuration file of
boi-package, execute the custom script to override the original process
runnersupports API calls and command line calls
Boilerplate packages
The package defines and exports the VRNBoilerplateConfig type, which, like vrn-boilerplate.schema.json, is used to describe the field types in the boi-package configuration file vrn-boilerplate.json
+--------------------------------+ +-----------------+
| @vrn-deco/boilerplate-protocol | | preset-packages |
+--------------------------------+ +-----------------+
| |
| |
v v
+--------------------------------+ +-----------------+ +-------------------+
| vrn-boilerplate.json | --> | | --> | API call |
+--------------------------------+ | boi-packages | +-------------------+
| | +-------------------+
| | --> | command line call |
+-----------------+ +-------------------+preset-package should implement:
- Create configuration file
vrn-boilerplate.jsonbased onvrn-boilerplate.schema.json - Store
boilerplaterelated files - Install your own
boilerplateusing thepreset-packagespecified invrn-boilerplate.json- Returns a wrapper function
wrapRunnerofpreset-package -> runner - This wrapper function references itself as
boiPackageDir
- Returns a wrapper function
wrapRunnersupports API calls and command line calls
Install
$ npm install @vrn-deco/boilerplate-protocol@^1.0.0Please use the constrained version when installing to avoid breaking changes introduced by subsequent major versions
e.g. ^1.0.0 or ~1.0.0
Usage
types:
import type {
Manifest,
Lang,
Boilerplate,
VRNBoilerplateConfig,
CustomScript,
CustomScriptType,
PresetRunner,
PresetOptions,
} from '@vrn-deco/boilerplate-protocol'verify vrn-boilerplate.json:
import fs from 'fs'
import path from 'path'
import { verifyVRNBoilerplateConfig } from '@vrn-deco/boilerplate-protocol'
const boiConfig = path.resolve('xxx', 'vrn-boilerplate.json')
const isValid = verifyVRNBoilerplateConfig(
JSON.parse(fs.readFileSync(boiConfig, { encoding: 'utf-8' })),
boiConfig,
)