Skip to content

LLM Resources

@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 โ€‹

ts
// 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() โ€‹
ts
new Dovenv(params?: Params): Dovenv

Creates a new Dovenv instance.

Parameters โ€‹
ParameterTypeDescription
params?ParamsOptional initialization parameters.
Returns โ€‹

Dovenv

Methods โ€‹

run() โ€‹
ts
run(args: string[]): Promise<void>

Runs the build process with the given arguments.

Parameters โ€‹
ParameterTypeDefault valueDescription
argsstring[][]Arguments to pass to the run process.
Returns โ€‹

Promise<void>

Example โ€‹
ts
const dovenv = new Dovenv({
  config: {
    check: {
      pkg: {...}
    },
    ...
  }
})
await dovenv.run(['check', '-k', 'pkg'])

Properties โ€‹

PropertyTypeDescription
configundefined | ConfigConfiguration object for commands and options of the Dovenv instance.
dovenvConfigPathundefined | stringContains 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() โ€‹

ts
function createCLI(opts?: CreateCliParams): Promise<Argv<{}>>

Parameters โ€‹

ParameterType
opts?CreateCliParams

Returns โ€‹

Promise<Argv<{}>>


defineConfig() โ€‹

ts
function defineConfig(...config: (Config | Config[])[]): Config

Defines and returns the given configuration object.

Parameters โ€‹

ParameterTypeDescription
...config(Config | Config[])[]The configuration object to define.

Returns โ€‹

Config

  • The defined configuration object.

See โ€‹

https://dovenv.pigeonposse.com/guide/core


Examples โ€‹

ts
// Example 1: A single configuration object
export default defineConfig(config1);
ts
// Example 2: Multiple configurations as arguments
export default defineConfig(config1, config2);
ts
// Example 3: An array of configurations
export default defineConfig([config1, config2]);

getCommandUtils() โ€‹

ts
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 โ€‹

ParameterTypeDescription
data?objectData.
data.pkg?Record<string, unknown>Optional package.json content as an object.
data.wsDir?stringThe workspace directory path. Default process.cwd()

Returns โ€‹

Promise<CommandSuper>

  • A promise that resolves to the command utilities.

Example โ€‹

ts
const utils = await getCommandUtils();
console.log(utils);

run() โ€‹

ts
function run(args: string[]): Promise<void>

Runs the build process with the given arguments.

Parameters โ€‹

ParameterTypeDescription
argsstring[]Arguments to pass to the build process.

Returns โ€‹

Promise<void>

Example โ€‹

ts
import { run } from '@dovenv/core'

await run(['-c', 'my/config.js', 'check'])

Type Aliases โ€‹

CommandUtils โ€‹

ts
type CommandUtils: CommandSuper;

Config โ€‹

ts
type Config: {
  alias: AliasesConfig;
  check: CheckConfig;
  const: ConstConfig;
  custom: CustomConfig;
  desc: string;
  name: string;
  transform: TransformConfig;
};

Type declaration โ€‹

NameTypeDescription
alias?AliasesConfigConfiguration for the aliases.
check?CheckConfigConfiguration for the check command.
const?ConstConfigConfiguration for set the constants used in templates.
custom?CustomConfigConfiguration for create custom commands.
desc?stringDescription of the project.
name?stringName of the project.
transform?TransformConfigConfiguration for the transform command.

Params โ€‹

ts
type Params: {
  config: Config;
};

Type declaration โ€‹

NameTypeDescription
config?ConfigConfiguration for dovenv. See https://dovenv.pigeonposse.com/guide/core/api#config