Dovenv Documentation β
dovenv is a versatile tool that helps manage and transform your workspace files, directories, and configurations with ease.
This page provides examples and commands to guide you in using dovenv effectively.
- Alias Commands: Create shortcuts for other commands.
- Check Commands: Validate the workspace structure.
- Transform Commands: Process and modify files based on specific inputs.
π Installation β
npm install @dovenv/corepnpm install @dovenv/coreyarn add @dovenv/corebun add @dovenv/coredeno add @dovenv/coreFeatures β
Check β
Check commands validate workspace structure, ensuring required files or directories exist and follow expected patterns.
Configuration β
import {defineConfig} from '@dovenv/core'
import {joinPath, existsFile, existsDir} from '@dovenv/utils'
export default defineConfig({ check: {
packages: {
desc: 'Repo packages structure.',
type: 'dir',
patterns: [
'./packages/*',
'!./packages/{plugin,config,theme}',
'./packages/{plugin,config,theme}/*',
],
validateAll: async ({ paths }) => {
if (paths.length === 0) throw new Error('No packages found');
},
validate: async ({ path }) => {
const files = [joinPath(path, 'README.md')];
const dirs = [joinPath(path, 'src')];
for (const file of files) {
const exists = await existsFile(file);
if (!exists) throw new Error(`File [${file}] must exist`);
}
for (const dir of dirs) {
const exists = await existsDir(dir);
if (!exists) throw new Error(`Directory [${dir}] must exist`);
}
},
},
} })Example Usage β
dovenv check -k packagesThis validates the structure of the packages directory and ensures required files and subdirectories are present.
Transform β
Transform commands allow you to process and modify specific files. For example, adding a watermark or replacing placeholders in templates.
Configuration β
import {defineConfig} from '@dovenv/core'
import {replacePlaceholders} from '@dovenv/utils'
export default defineConfig( { transform : {
readme : {
input : [ 'README.md' ],
fn : async props => {
const mark = props.const?.mark as string
if ( mark === undefined ) throw new Error( 'Missing mark in configuration' )
return props.content + `\n<!--${mark}-->\n`
},
},
pp : {
input : [ '.pigeonposse.yml' ],
fn : async props => {
const ppTemplate = props.const?.template['.pigeonposse.yml'] as string
const content = await replacePlaceholders( {
content : ppTemplate,
params : props.const || {},
} )
return content
},
},
} } )Example Usage β
dovenv transform -k readmeThis command appends a custom ASCII watermark to the README.md file.
Aliases β
Configuration β
import {defineConfig} from '@dovenv/core'
export default defineConfig({
alias: {
deps: {
desc: 'List pacakge dependencies',
cmd: 'pnpm list --depth=0',
},
}
})Example Usage β
dovenv x depsConstants β
Configuration β
import {defineConfig} from '@dovenv/core'
export default defineConfig({
const: {
hello: 'world',
foo: 'bar',
}
})Example Usage β
View all constants β
dovenv const viewView specific constant(s) β
dovenv const view -k helloMore Usage β
Check Specific Key β
dovenv check -k packagesCheck Pattern Key β
dovenv check -k 'package*'Check Multiple Keys β
dovenv check -k 'package*' 'docs'Transform Specific Key β
dovenv transform -k readmeShow Constants β
dovenv constShow Aliases β
Lists aliases of your config file. Use the following to display a specific alias:
dovenv alias -k depsExecute Alias β
Run a specific alias. For example:
dovenv x depsPrint Config File in Terminal β
dovenv config