@dovenv/core
- API documentation โ
Classes โ
Dovenv โ
Instance Dovenv
.
This is the "dovenv" class that builds the command line interface.
It is similar to the cli tool but for use in js
|ts
projects.
Provides tools for managing configurations, constants, and path transformations etc. Supports custom configurations and predefined commands. Features:
- Validate files or directories with custom rules.
- Manage workspace constants efficiently.
- Transform paths with configurable patterns.
- Extend or override default behaviors with custom configurations.
---.
See โ
https://dovenv.pigeonposse.com/guide/core
Example โ
// Create an instance with custom configurations
const dovenv = new Dovenv({
config: {
check: {
pkg: { include: ['src/**'], ... }
},
}
});
// Run a predefined action
await dovenv.run(['check', '-k', 'pkg']);
Constructors โ
new Dovenv() โ
new Dovenv(params?: Params): Dovenv
Creates a new Dovenv
instance.
Parameters โ
Parameter | Type | Description |
---|---|---|
params ? | Params | Optional initialization parameters. |
Returns โ
Methods โ
run() โ
run(args: string[]): Promise<void>
Runs the build process with the given arguments.
Parameters โ
Parameter | Type | Default value | Description |
---|---|---|---|
args | string [] | [] | Arguments to pass to the run process. |
Returns โ
Promise
<void
>
Example โ
const dovenv = new Dovenv({
config: {
check: {
pkg: {...}
},
...
}
})
await dovenv.run(['check', '-k', 'pkg'])
Properties โ
Property | Type | Description |
---|---|---|
config | undefined | Config | Configuration object for commands and options of the Dovenv instance. |
dovenvConfigPath | undefined | string | Contains Dovenv config path. This property is used for user information purposes only. If the "config" option is added via the class constructor, this option will be undefined. In this case you can change its value, but this may alter the behavior of the class. Do so at your own risk. |
Functions โ
createCLI() โ
function createCLI(opts?: CreateCliParams): Promise<Argv<{}>>
Parameters โ
Parameter | Type |
---|---|
opts ? | CreateCliParams |
Returns โ
Promise
<Argv
<{}>>
defineConfig() โ
function defineConfig(...config: (Config | Config[])[]): Config
Defines and returns the given configuration object.
Parameters โ
Parameter | Type | Description |
---|---|---|
...config | (Config | Config [])[] | The configuration object to define. |
Returns โ
- The defined configuration object.
See โ
https://dovenv.pigeonposse.com/guide/core
Examples โ
// Example 1: A single configuration object
export default defineConfig(config1);
// Example 2: Multiple configurations as arguments
export default defineConfig(config1, config2);
// Example 3: An array of configurations
export default defineConfig([config1, config2]);
getCommandUtils() โ
function getCommandUtils(data?: {
pkg: Record<string, unknown>;
wsDir: string;
}): Promise<CommandSuper>
Retrieves command utilities for the given workspace directory. If a package.json object is not provided, it reads and parses it from the workspace directory.
Parameters โ
Parameter | Type | Description |
---|---|---|
data ? | object | Data. |
data.pkg ? | Record <string , unknown > | Optional package.json content as an object. |
data.wsDir ? | string | The workspace directory path. Default process.cwd() |
Returns โ
Promise
<CommandSuper
>
- A promise that resolves to the command utilities.
Example โ
const utils = await getCommandUtils();
console.log(utils);
run() โ
function run(args: string[]): Promise<void>
Runs the build process with the given arguments.
Parameters โ
Parameter | Type | Description |
---|---|---|
args | string [] | Arguments to pass to the build process. |
Returns โ
Promise
<void
>
Example โ
import { run } from '@dovenv/core'
await run(['-c', 'my/config.js', 'check'])
Type Aliases โ
CommandUtils โ
type CommandUtils: CommandSuper;
Config โ
type Config: {
alias: AliasesConfig;
check: CheckConfig;
const: ConstConfig;
custom: CustomConfig;
desc: string;
name: string;
transform: TransformConfig;
};
Type declaration โ
Name | Type | Description |
---|---|---|
alias ? | AliasesConfig | Configuration for the aliases . |
check ? | CheckConfig | Configuration for the check command. |
const ? | ConstConfig | Configuration for set the constants used in templates. |
custom ? | CustomConfig | Configuration for create custom commands. |
desc ? | string | Description of the project. |
name ? | string | Name of the project. |
transform ? | TransformConfig | Configuration for the transform command. |
Params โ
type Params: {
config: Config;
};
Type declaration โ
Name | Type | Description |
---|---|---|
config ? | Config | Configuration for dovenv. See https://dovenv.pigeonposse.com/guide/core/api#config |