diff --git a/packages/docs/pages/apis/cli.mdx b/packages/docs/pages/apis/cli.mdx
index bf3fe32..c54d8e1 100644
--- a/packages/docs/pages/apis/cli.mdx
+++ b/packages/docs/pages/apis/cli.mdx
@@ -31,24 +31,30 @@ You may want to install `@haetae/cli{:ts}` and its `peerDependencies` all at onc
-```bash
-# As dependencies
+<>
+```bash copy filename="dependency"
npx install-peerdeps @haetae/cli
-# As devDependencies
+```
+```bash copy filename="devDependency"
npx install-peerdeps --dev @haetae/cli
```
-```bash
-# As dependencies
+>
+<>
+```bash copy filename="dependency"
npx install-peerdeps --yarn @haetae/cli
-# As devDependencies
+```
+```bash copy filename="devDependency"
npx install-peerdeps --yarn --dev @haetae/cli
```
-```bash
-# As dependencies
+>
+<>
+```bash copy filename="dependency"
npx install-peerdeps --pnpm @haetae/cli
-# As devDependencies
+```
+```bash copy filename="devDependency"
npx install-peerdeps --pnpm --dev @haetae/cli
```
+>
### To manually handle the installation
@@ -59,30 +65,36 @@ First, install `@haetae/cli` itself.
-```bash
-# As dependencies
+<>
+```bash copy filename="dependency"
npm install @haetae/cli
-# As devDependencies
+```
+```bash copy filename="devDependency"
npm install --save-dev @haetae/cli
```
-```bash
-# As dependencies
+>
+<>
+```bash copy filename="dependency"
yarn add @haetae/cli
-# As devDependencies
+```
+```bash copy filename="devDependency"
yarn add --dev @haetae/cli
```
-```bash
-# As dependencies
+>
+<>
+```bash copy filename="dependency"
pnpm add @haetae/cli
-# As devDependencies
+```
+```bash copy filename="devDependency"
pnpm add --save-dev @haetae/cli
```
+>
Then, check out `peerDependencies` and manually handle them.
(e.g. Install them as `dependencies` or set them as `peerDependencies`)
-```bash
+```bash copy filename="Terminal"
# This does not install, but just shows peerDependencies.
npm info @haetae/cli peerDependencies
```
@@ -118,7 +130,7 @@ Let's say you want to create a CLI `your-command{:sh}` and `yc{:sh}` (short for
Note that you should add [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) for nodejs.
-```js
+```js copy
#!/usr/bin/env node
import { run } from '@haetae/cli'
// Or `import { cli: { run } } from 'haetae'`
@@ -128,7 +140,7 @@ run()
**package.json** of `@your/package`
-```json
+```json copy
{
"name": "@your/package",
"files": [
diff --git a/packages/docs/pages/apis/core.mdx b/packages/docs/pages/apis/core.mdx
index 15476a4..56d7b0c 100644
--- a/packages/docs/pages/apis/core.mdx
+++ b/packages/docs/pages/apis/core.mdx
@@ -33,24 +33,30 @@ Just purely installing `@haetae/core{:ts}` itself is enough.
-```bash
-# As dependencies
+<>
+```bash copy filename="dependency"
npm install @haetae/core
-# As devDependencies
+```
+```bash copy filename="devDependency"
npm install --save-dev @haetae/core
```
-```bash
-# As dependencies
+>
+<>
+```bash copy filename="dependency"
yarn add @haetae/core
-# As devDependencies
+```
+```bash copy filename="devDependency"
yarn add --dev @haetae/core
```
-```bash
-# As dependencies
+>
+<>
+```bash copy filename="dependency"
pnpm add @haetae/core
-# As devDependencies
+```
+```bash copy filename="devDependency"
pnpm add --save-dev @haetae/core
```
+>
## API
diff --git a/packages/docs/pages/apis/git.mdx b/packages/docs/pages/apis/git.mdx
index 2d1cc1e..76e4c31 100644
--- a/packages/docs/pages/apis/git.mdx
+++ b/packages/docs/pages/apis/git.mdx
@@ -37,24 +37,30 @@ You may want to install `@haetae/git{:ts}` and its `peerDependencies` all at onc
-```bash
-# As dependencies
+<>
+```bash copy filename="dependency"
npx install-peerdeps @haetae/git
-# As devDependencies
+```
+```bash copy filename="devDependency"
npx install-peerdeps --dev @haetae/git
```
-```bash
-# As dependencies
+>
+<>
+```bash copy filename="dependency"
npx install-peerdeps --yarn @haetae/git
-# As devDependencies
+```
+```bash copy filename="devDependency"
npx install-peerdeps --yarn --dev @haetae/git
```
-```bash
-# As dependencies
+>
+<>
+```bash copy filename="dependency"
npx install-peerdeps --pnpm @haetae/git
-# As devDependencies
+```
+```bash copy filename="devDependency"
npx install-peerdeps --pnpm --dev @haetae/git
```
+>
### To manually handle the installation
@@ -65,30 +71,36 @@ First, install `@haetae/git{:ts}` itself.
-```bash
-# As dependencies
+<>
+```bash copy filename="dependency"
npm install @haetae/git
-# As devDependencies
+```
+```bash copy filename="devDependency"
npm install --save-dev @haetae/git
```
-```bash
-# As dependencies
+>
+<>
+```bash copy filename="dependency"
yarn add @haetae/git
-# As devDependencies
+```
+```bash copy filename="devDependency"
yarn add --dev @haetae/git
```
-```bash
-# As dependencies
+>
+<>
+```bash copy filename="dependency"
pnpm add @haetae/git
-# As devDependencies
+```
+```bash copy filename="devDependency"
pnpm add --save-dev @haetae/git
```
+>
Then, check out `peerDependencies` and manually handle them.
(e.g. Install them as `dependencies` or set them as `peerDependencies`)
-```bash
+```bash copy filename="Terminal"
# This does not install, but just shows peerDependencies.
npm info @haetae/git peerDependencies
```
diff --git a/packages/docs/pages/apis/haetae.mdx b/packages/docs/pages/apis/haetae.mdx
index 0466506..a1075c1 100644
--- a/packages/docs/pages/apis/haetae.mdx
+++ b/packages/docs/pages/apis/haetae.mdx
@@ -36,13 +36,13 @@ Unlike other `@haetae/*{:ts}` packages, `haetae{:ts}` does not have `peerDepende
-```bash
+```bash copy filename="Terminal"
npm install --save-dev haetae
```
-```bash
+```bash copy filename="Terminal"
yarn add --dev haetae
```
-```bash
+```bash copy filename="Terminal"
pnpm add --save-dev haetae
```
@@ -59,7 +59,7 @@ Its source code is _roughly_ like the snippet below.
"'@haetae/git'": './git',
"'@haetae/cli'": './cli',
}}>
-```ts
+```js copy
export * as core from '@haetae/core'
export * as utils from '@haetae/utils'
export * as js from '@haetae/javascript'
@@ -72,7 +72,7 @@ export const pkg = { ... }
So you probably use `haetae` on the config file like this.
-```js filename="haetae.config.js"
+```js copy filename="haetae.config.js"
import { configure, utils, js, git, cli, pkg } from 'haetae'
export default configure({
diff --git a/packages/docs/pages/apis/introduction.mdx b/packages/docs/pages/apis/introduction.mdx
index cd11c16..b30de9d 100644
--- a/packages/docs/pages/apis/introduction.mdx
+++ b/packages/docs/pages/apis/introduction.mdx
@@ -35,7 +35,7 @@ For example, trailing `?{:ts}` means an optional field.
Some APIs depend on common utility types.
-```ts
+```ts copy
type PromiseOr = Promise | T
type RecScalar = string | number | boolean | null | undefined
interface Rec {
@@ -62,7 +62,7 @@ Any functions linked to from here by label satisfy the principles be
To clear the memoization cache, you can call `.clear(){:ts}`.
For example, [`core.getConfig{:ts}`](./core#getconfig) is a memoized function, and `getConfig.clear(){:ts}` would clear its cache.
-```ts
+```js copy
import { getConfig } from '@haetae/core'
// `getConfig` is executed.
@@ -90,7 +90,7 @@ const config5 = await getConfig({ filename: '/foo/haetae.config.js' })
The memoization cache is based on shallow copy.
-```ts
+```js copy
// `config1` and `config2` would have same memory address.
const config1 = await getConfig()
const config2 = await getConfig()
@@ -120,7 +120,7 @@ Any functions linked to from here by label satisfy the princip
Returned file or directory path is always **absolute** path (NOT relative).
-```ts
+```js copy
import { utils } from 'haetae'
const files = await utils.glob(['**/*.test.ts', '**/*.test.tsx'])
@@ -154,7 +154,7 @@ This is a better decision for convenience of usage and development.
For example, let's assume the package version is ***`1.2.3-beta.4`***.
Then the value would be like this.
-```ts
+```js copy
const { pkg } = require('haetae' /* or '@haetae/' */)
pkg.name // 'haetae' or '@haetae/'
@@ -170,7 +170,7 @@ pkg.version.untilPatch // '1.2.3'
`pkg.version.*{:ts}` could be a good choice for `env`.
-```js filename="haetae.config.js"
+```js copy filename="haetae.config.js"
import { configure, pkg, git, utils } from 'haetae'
export default configure({
diff --git a/packages/docs/pages/apis/javascript.mdx b/packages/docs/pages/apis/javascript.mdx
index 4ae2e5b..b1a96b2 100644
--- a/packages/docs/pages/apis/javascript.mdx
+++ b/packages/docs/pages/apis/javascript.mdx
@@ -34,24 +34,30 @@ You may want to install `@haetae/javascript{:ts}` and its `peerDependencies` all
-```bash
-# As dependencies
+<>
+```bash copy filename="dependency"
npx install-peerdeps @haetae/javascript
-# As devDependencies
+```
+```bash copy filename="devDependency"
npx install-peerdeps --dev @haetae/javascript
```
-```bash
-# As dependencies
+>
+<>
+```bash copy filename="dependency"
npx install-peerdeps --yarn @haetae/javascript
-# As devDependencies
+```
+```bash copy filename="devDependency"
npx install-peerdeps --yarn --dev @haetae/javascript
```
-```bash
-# As dependencies
+>
+<>
+```bash copy filename="dependency"
npx install-peerdeps --pnpm @haetae/javascript
-# As devDependencies
+```
+```bash copy filename="devDependency"
npx install-peerdeps --pnpm --dev @haetae/javascript
```
+>
### To manually handle the installation
@@ -62,30 +68,36 @@ First, install `@haetae/javascript{:ts}` itself.
-```bash
-# As dependencies
+<>
+```bash copy filename="dependency"
npm install @haetae/javascript
-# As devDependencies
+```
+```bash copy filename="devDependency"
npm install --save-dev @haetae/javascript
```
-```bash
-# As dependencies
+>
+<>
+```bash copy filename="dependency"
yarn add @haetae/javascript
-# As devDependencies
+```
+```bash copy filename="devDependency"
yarn add --dev @haetae/javascript
```
-```bash
-# As dependencies
+>
+<>
+```bash copy filename="dependency"
pnpm add @haetae/javascript
-# As devDependencies
+```
+```bash copy filename="devDependency"
pnpm add --save-dev @haetae/javascript
```
+>
Then, check out `peerDependencies` and manually handle them.
(e.g. Install them as `dependencies` or set them as `peerDependencies`)
-```bash
+```bash copy filename="Terminal"
# This does not install, but just shows peerDependencies.
npm info @haetae/javascript peerDependencies
```
@@ -139,7 +151,7 @@ It supports npm, yarn classic(v1), yarn berry(v2, v3) and pnpm.
You can get parsed object of any package's version by `version{:ts}`.
For example, let's assume eslint's version is ***`1.2.3-beta.4`***.
-```ts
+```js copy
import * as js from '@haetae/javascript'
const eslintVersion = await js.version('eslint')
@@ -159,7 +171,7 @@ eslintVersion.untilPatch // '1.2.3'
'configure': './haetae#configure',
'.hash': './utils#hash',
}}>
-```js filename="haetae.config.js"
+```js copy filename="haetae.config.js"
import { configure, js, utils } from 'haetae'
export default configure({
@@ -416,7 +428,7 @@ Let's say,
then the result would be like this.
-```ts
+```js copy
const dependencies = ['f.ts', 'b.ts']
await dependsOn({ dependent: 'a.ts', dependencies }) // true
diff --git a/packages/docs/pages/apis/utils.mdx b/packages/docs/pages/apis/utils.mdx
index 6098852..a8ef324 100644
--- a/packages/docs/pages/apis/utils.mdx
+++ b/packages/docs/pages/apis/utils.mdx
@@ -39,24 +39,30 @@ You may want to install `@haetae/utils{:ts}` and its `peerDependencies` all at o
-```bash
-# As dependencies
+<>
+```bash copy filename="dependency"
npx install-peerdeps @haetae/utils
-# As devDependencies
+```
+```bash copy filename="devDependency"
npx install-peerdeps --dev @haetae/utils
```
-```bash
-# As dependencies
+>
+<>
+```bash copy filename="dependency"
npx install-peerdeps --yarn @haetae/utils
-# As devDependencies
+```
+```bash copy filename="devDependency"
npx install-peerdeps --yarn --dev @haetae/utils
```
-```bash
-# As dependencies
+>
+<>
+```bash copy filename="dependency"
npx install-peerdeps --pnpm @haetae/utils
-# As devDependencies
+```
+```bash copy filename="devDependency"
npx install-peerdeps --pnpm --dev @haetae/utils
```
+>
### To manually handle the installation
@@ -67,30 +73,36 @@ First, install `@haetae/utils{:ts}` itself.
-```bash
-# As dependencies
-npm install @haetae/utils
-# As devDependencies
-npm install --save-dev @haetae/utils
-```
-```bash
-# As dependencies
-yarn add @haetae/utils
-# As devDependencies
-yarn add --dev @haetae/utils
-```
-```bash
-# As dependencies
-pnpm add @haetae/utils
-# As devDependencies
-pnpm add --save-dev @haetae/utils
+<>
+```bash copy filename="dependency"
+npm install @haetae/core
+```
+```bash copy filename="devDependency"
+npm install --save-dev @haetae/core
+```
+>
+<>
+```bash copy filename="dependency"
+yarn add @haetae/core
```
+```bash copy filename="devDependency"
+yarn add --dev @haetae/core
+```
+>
+<>
+```bash copy filename="dependency"
+pnpm add @haetae/core
+```
+```bash copy filename="devDependency"
+pnpm add --save-dev @haetae/core
+```
+>
Then, check out `peerDependencies` and manually handle them.
(e.g. Install them as `dependencies` or set them as `peerDependencies`)
-```bash
+```bash copy filename="Terminal"
# This does not install, but just show peerDependencies.
npm info @haetae/utils peerDependencies
```
@@ -738,7 +750,7 @@ export default configure({
If you run `myCommand` for the first time, the result would be like this.
-```fish filename="terminal"
+```fish filename="Terminal"
$ haetae myCommand
changedFiles: [
@@ -772,7 +784,7 @@ And their hashes are recorded in the new *Record Data*.
If we run it again immediately, no file is detected as changed.
The hashes are recorded the same as well.
-```fish filename="terminal"
+```fish filename="Terminal"
$ haetae myCommand
changedFiles: []
@@ -825,8 +837,8 @@ and the named option `renew` is `['c', 'd', 'f', 'g']{:ts}`.
What would be the result if we run the command again?
-```fish filename="terminal"
-$ haetae myCommand
+```fish copy filename="Terminal"
+haetae myCommand
```
It will be partially different relying on `options` and whether the content is changed.
diff --git a/packages/docs/pages/cli.mdx b/packages/docs/pages/cli.mdx
index c062411..02b9654 100644
--- a/packages/docs/pages/cli.mdx
+++ b/packages/docs/pages/cli.mdx
@@ -27,7 +27,7 @@ For example,
'configure': './apis/haetae#configure',
'$': './apis/utils#dollar'
}}>
-```js filename="haetae.config.js"
+```js copy filename="haetae.config.js"
import { $, configure } from 'haetae'
export default configure({
@@ -51,7 +51,7 @@ export default configure({
Then the commands become available from the CLI.
-```fish
+```fish copy
$ haetae myAwesomeCommand
hello world!
@@ -64,7 +64,7 @@ hello world!
⎣ 💾 data: {}
```
-```fish
+```fish copy
$ haetae myAnotherCommand
hi, there!
@@ -87,8 +87,8 @@ If specified, usage help is shown.
#### Usage
-```fish
-$ haetae --help
+```fish copy
+haetae --help
```
#### Conflicts
@@ -108,8 +108,8 @@ If you want to know comprehensive versions, use [`-i, --info{:sh}`](#-i---info).
#### Usage
-```fish
-$ haetae --version
+```fish copy
+haetae --version
```
#### Conflicts
@@ -124,8 +124,8 @@ A config file path.
#### Usage
-```fish
-$ haetae --config path/to/haetae.config.js []
+```fish copy
+haetae --config path/to/haetae.config.js []
```
@@ -151,8 +151,8 @@ This option should not be used with these options.
`env` of the `{:sh}` in the config file is evaluated.
The evaluated value, which is the current `env`, is shown on the shell.
-```fish
-$ haetae --env
+```fish copy
+haetae --env
```
#### Conflicts
@@ -177,8 +177,8 @@ The `{:sh}`'s *Record* for the current `env` is shown.
This means, `env` in the config file is evaluated,
and the command's *Record* matching with the evaluated `env` is searched from the *Store*.
-```fish
-$ haetae --record
+```fish copy
+haetae --record
```
#### Conflicts
@@ -197,8 +197,8 @@ This option should not be used with these options.
(**Type** : `boolean`, **Default**: `false`)
-```fish
-$ haetae --record-data
+```fish copy
+haetae --record-data
```
#### Usage
@@ -207,8 +207,8 @@ The `{:sh}`'s *Record Data* for current `env` is shown.
This means, `env` in the config file is evaluated,
and the command's *Record Data* matching with the evaluated `env` is searched from the *Store*.
-```fish
-$ haetae --record-data
+```fish copy
+haetae --record-data
```
#### Conflicts
@@ -232,8 +232,8 @@ If specified, result of execution is not printed.
#### Usage
-```fish
-$ haetae --silent [] []
+```fish copy
+haetae --silent [] []
```
#### Conflicts
@@ -256,8 +256,8 @@ If specified, a new record is not stored, but the result is printed.
#### Usage
-```fish
-$ haetae --dry-run []
+```fish copy
+haetae --dry-run []
```
#### Conflicts
@@ -283,8 +283,8 @@ If specified, the result (**stdout**, **stderr**) would be expressed in JSON for
You can freely use this option to transform any result into JSON.
-```fish
-$ haetae --json [] []
+```fish copy
+haetae --json [] []
```
For examples,
@@ -322,8 +322,8 @@ This hinders ease of sharing and reporting. That's why the plain text is copied
#### Usage
-```fish
-$ haetae --info
+```fish copy
+haetae --info
```
#### Conflicts
diff --git a/packages/docs/pages/index.mdx b/packages/docs/pages/index.mdx
index 1c11c07..eea60ab 100644
--- a/packages/docs/pages/index.mdx
+++ b/packages/docs/pages/index.mdx
@@ -17,7 +17,7 @@ For now, in this *Getting Started* article, we are starting from an example of i
Let's say you're building a calculator project, named *'my-calculator'*.
-```fish filename="Your Project"
+```fish copy filename="Your Project"
# Entrypoint (index.js) is omitted for brevity
my-calculator
├── package.json
@@ -62,35 +62,42 @@ Literally **any project** is proper.
-```bash filename="Terminal"
+<>
+```bash copy filename="Installation"
npm install --save-dev haetae
+```
-# Execute `haetae`
+```bash copy filename="Execution"
npx haetae --help
# `ht` is shorthand for `haetae`
npx ht --help
```
-
-```bash filename="Terminal"
+>
+<>
+```bash copy filename="Installation"
yarn add --dev haetae
+```
-# Execute `haetae`
+```bash copy filename="Execution"
yarn haetae --help
# `ht` is shorthand for `haetae`
yarn ht --help
```
-
-```bash filename="Terminal"
+>
+<>
+```bash copy filename="Installation"
pnpm add --save-dev haetae
+```
-# Execute `haetae`
+```bash copy filename="Execution"
pnpm haetae --help
# `ht` is shorthand for `haetae`
pnpm ht --help
```
+>
@@ -120,7 +127,7 @@ Its name and execution setting are different depending on whether your project i
If your *`package.json`* is configured as ESM,
name the config file *`haetae.config.js`*.
-```fish filename="Your Project" {2}
+```fish copy filename="Your Project" {2}
my-calculator
├── haetae.config.js # <--- Haetae config file
├── package.json # <--- "type": "module"
@@ -132,7 +139,7 @@ my-calculator
If your *`package.json`* is configured as CJS,
name the config file *`haetae.config.mjs`*.
-```fish filename="Your Project" {2}
+```fish copy filename="Your Project" {2}
my-calculator
├── haetae.config.mjs # <--- Haetae config file
├── package.json # <--- "type": "commonjs" or "type" is omitted
@@ -148,7 +155,7 @@ If your *`package.json`* and *`tsconfig.json`* are configured as ESM,
name the config file *`haetae.config.ts`*.
-```fish filename="Your Project" {2}
+```fish copy filename="Your Project" {2}
my-calculator
├── haetae.config.ts # <--- Haetae config file
├── package.json # <--- "type": "module"
@@ -161,26 +168,26 @@ Next, install [`ts-node`](https://www.npmjs.com/package/ts-node).
It's optional `peerDependencies` of [`@haetae/core{:ts}`](./apis/core), which is an internal dependency of `haetae`.
-```bash filename="Terminal"
+```bash copy filename="Terminal"
npm install --save-dev ts-node
```
-```bash filename="Terminal"
+```bash copy filename="Terminal"
yarn add --dev ts-node
```
-```bash filename="Terminal"
+```bash copy filename="Terminal"
pnpm add --save-dev ts-node
```
Finally, provide an environment variable [`$NODE_OPTIONS`](https://nodejs.org/api/cli.html#node_optionsoptions).
-```bash filename="Terminal"
+```bash copy filename="Terminal"
NODE_OPTIONS='--loader=ts-node/esm' haetae --help
```
Registering scripts in *`package.json`* is a recommended good practice.
-```jsonc filename="package.json"
+```json copy filename="package.json"
{
"scripts": {
"haetae": "cross-env NODE_OPTIONS='--loader=ts-node/esm' haetae",
@@ -198,7 +205,7 @@ But you may want to write the config in TypeScript.
If your *`package.json`* and *`tsconfig.json`* are configured as CJS,
name the config file *`haetae.config.mts`*.
-```fish filename="Your Project" {2}
+```fish copy filename="Your Project" {2}
my-calculator
├── haetae.config.mts # <--- Haetae config file
├── package.json # <--- "type": "commonjs" or "type" is omitted
@@ -211,13 +218,13 @@ Next, install [`ts-node`](https://www.npmjs.com/package/ts-node).
It's optional `peerDependencies` of [`@haetae/core{:ts}`](./apis/core), which is an internal dependency of [`haetae{:ts}`](./apis/haetae).
-```bash filename="Terminal"
+```bash copy filename="Terminal"
npm install --save-dev ts-node
```
-```bash filename="Terminal"
+```bash copy filename="Terminal"
yarn add --dev ts-node
```
-```bash filename="Terminal"
+```bash copy filename="Terminal"
pnpm add --save-dev ts-node
```
@@ -226,7 +233,7 @@ Finally, provide environment variables [`$TS_NODE_COMPILER_OPTIONS`](https://typ
and [`$NODE_OPTIONS`](https://nodejs.org/api/cli.html#node_optionsoptions).
Because your *`tsconfig.json`* is CJS, `$TS_NODE_COMPILER_OPTIONS` makes sure haetae's config file is ESM.
-```bash filename="Terminal"
+```bash copy filename="Terminal"
# Instead of 'node16', you can choose other values like 'nodenext', etc.
TS_NODE_COMPILER_OPTIONS='{"module": "node16", "moduleResolution": "node16"}' \
NODE_OPTIONS='--loader=ts-node/esm' \
@@ -235,7 +242,7 @@ haetae --help
Registering scripts in *`package.json`* is a recommended good practice.
-```jsonc filename="package.json"
+```json copy filename="package.json"
{
"scripts": {
"haetae": "cross-env TS_NODE_COMPILER_OPTIONS='{\"module\": \"node16\", \"moduleResolution\": \"node16\"}' NODE_OPTIONS='--loader=ts-node/esm' haetae",
@@ -247,7 +254,7 @@ Registering scripts in *`package.json`* is a recommended good practice.
Or you can create a dedicated tsconfig for Haetae.
-```fish filename="Your Project" {4}
+```fish copy filename="Your Project" {4}
my-calculator
├── haetae.config.mts # <--- Haetae config file
├── package.json # <--- "type": "commonjs" or "type" is omitted
@@ -260,7 +267,7 @@ my-calculator
Then, provide an environment variable [`$TS_NODE_PROJECT`](https://typestrong.org/ts-node/docs/options/#project)
instead of [`$TS_NODE_COMPILER_OPTIONS`](https://typestrong.org/ts-node/docs/options/#compileroptions).
-```jsonc filename="package.json"
+```json copy filename="package.json"
{
"scripts": {
"haetae": "cross-env TS_NODE_PROJECT=tsconfig.haetae.json NODE_OPTIONS='--loader=ts-node/esm' haetae",
@@ -289,7 +296,7 @@ We can write down the config file like this.
'.changedFiles': './apis/git#changedfiles',
'.dependOn': './apis/javascript#dependon',
}}>
-```js filename="haetae.config.js" showLineNumbers
+```js copy filename="haetae.config.js" showLineNumbers
import { $, configure, git, utils, js } from 'haetae'
export default configure({
@@ -331,7 +338,7 @@ It has other traits and options as well. Check out `execa`'s API docs for more d
-```js
+```js copy
import { $ } from 'haetae'
// The following two lines of code have same effects respectively
@@ -347,7 +354,7 @@ await $`pnpm jest ${affectedTestFiles.join(' ')}`
Then run `haetae` like below.
-```fish filename="Terminal"
+```fish copy filename="Terminal"
haetae myTest
```
(Unless you installed `haetae` globally, you should execute it through package manager (e.g. `pnpm haetae myTest`))
@@ -358,7 +365,7 @@ You can name it whatever you want. And as you might guess, you can define multip
It will print the result like this.
-```fish filename="Terminal"
+```fish copy filename="Terminal"
✔ success Command myTest is successfully executed.
⎡ 🕗 time: 2023 May 28 11:06:06 Asia/Seoul 1(timestamp: 1685239566483)
@@ -402,7 +409,7 @@ Check out the API docs later for more detail.
Note that it cannot parse dynamic imports (`import(){:ts}`).
Dynamic or extra dependencies can be specified as `additionalGraph` option, explained later in this article.
-```fish filename="Your Project" {2}
+```fish copy filename="Your Project" {2}
my-calculator
├── .haetae/store.json # <--- Generated. Haetae store file
├── haetae.config.js
@@ -426,7 +433,7 @@ Let's say we made some changes and added 2 commits.
`0c3b3cc` and `1d17a2f` are new commits after that.
What will happen when we run Haetae again?
-```fish filename="Terminal"
+```fish copy filename="Terminal"
haetae myTest
```
@@ -440,7 +447,7 @@ because [`js.dependOn(){:ts}`](./apis/javascript#dependon) **detects dependency
If you modify `add.test.js`, only the test file itself `add.test.js` will be executed,
as **every file is treated as depending on itself.**
-```fish filename="Terminal"
+```fish copy filename="Terminal"
✔ success Command myTest is successfully executed.
⎡ 🕗 time: 2023 May 28 19:03:25 Asia/Seoul (timestamp: 1685268205443)
@@ -489,7 +496,7 @@ Let's add `env` to the config file to achieve this.
-```js filename="haetae.config.js" {6-8}
+```js copy filename="haetae.config.js" {6-8}
import { configure } from 'haetae'
export default configure({
@@ -538,7 +545,7 @@ For instance, let's change the config to this.
'.majorVersion': './apis/javascript#majorversion',
'.branch': './apis/git#branch',
}}>
-```js filename="haetae.config.js" showLineNumbers
+```js copy filename="haetae.config.js" showLineNumbers
import assert from 'node:assert/strict' // `node:` protocol is optional
import { configure, git, js, utils, pkg } from 'haetae'
import semver from 'semver'
@@ -577,7 +584,7 @@ This is intended design for incremental tasks.
If you just want to evaluate the value `env` function returns, you can use [`-e, --env`](./cli#-e---env) option.
This does not modify the store, but just prints out to the console.
-```fish filename="Terminal"
+```fish copy filename="Terminal"
$ haetae myTest --env
✔ success Current environment is successfully evaluated for the command myTest
@@ -602,7 +609,7 @@ But sometimes, you need to specify some dependencies manually.
For example, let's say you're developing a project communicating with a database.
-```fish filename="Your Project"
+```fish copy filename="Your Project"
your-project
├── haetae.config.js
├── package.json
@@ -635,7 +642,7 @@ Let Haetae think *`logic.js`* depends on *`data.sql`*, by `additionalGraph`.
'.graph': './apis/utils#graph',
'.dependOn': './apis/javascript#dependon',
}}>
-```js filename="haetae.config.js" {10-17,21}
+```js copy filename="haetae.config.js" {10-17,21}
import { $, configure, git, utils, js } from 'haetae'
export default configure({
@@ -681,7 +688,7 @@ you can change the config.
-```js filename="haetae.config.js" {5,}
+```js copy filename="haetae.config.js" {5,}
// Other content is omitted for brevity
const additionalGraph = await utils.graph({
edges: [
@@ -728,7 +735,7 @@ then `env` is a good place.
'configure': './apis/haetae#configure',
'.hash': './apis/utils#hash',
}}>
-```js filename="haetae.config.js" {7}
+```js copy filename="haetae.config.js" {7}
import { configure, utils } from 'haetae'
export default configure({
@@ -751,7 +758,7 @@ You can specify the dependency graph from a chunk of files to another chunk.
-```js filename="haetae.config.js"
+```js copy filename="haetae.config.js"
// Other content is omitted for brevity
const additionalGraph = await utils.graph({
edges: [
@@ -779,7 +786,7 @@ It can be done in a distributed manner.
-```js filename="haetae.config.js" showLineNumbers
+```js copy filename="haetae.config.js" showLineNumbers
// Other content is omitted for brevity
const additionalGraph = await utils.graph({
edges: [
@@ -820,7 +827,7 @@ Haetae does not prevent you from defining it.
-```js filename="haetae.config.js"
+```js copy filename="haetae.config.js"
// Other content is omitted for brevity
const additionalGraph = await utils.graph({
edges: [
@@ -866,7 +873,7 @@ and *'Record Data'* (type: `core.HaetaeRecord.data{:ts}`).
In the previous sections, we've already seen terminal outputs like this.
-```fish filename="Terminal"
+```fish copy filename="Terminal"
$ haetae myTest
✔ success Command myTest is successfully executed.
@@ -885,7 +892,7 @@ This information is logged in the store file (*`.haetae/store.json`*), and calle
The `data` field is called *'Record Data'*.
Let's check them out.
-```fish filename="Terminal"
+```fish copy filename="Terminal"
cat .haetae/store.json
```
@@ -1025,7 +1032,7 @@ Let's see how it works, with a simple example project using *`.env`* as the appl
*`.env`* is a configuration file for environment variables, and NOT related to Haetae's `env` at all.
-```fish filename="Your Project"
+```fish copy filename="Your Project"
your-project
├── .env # <--- dotenv file
├── .gitignore # <--- ignores '.env' file
@@ -1044,7 +1051,7 @@ your-project
*`src/config.js`* reads the file *`.env`*, by a library [dotenv](https://www.npmjs.com/package/dotenv) for example.
-```js filename="src/config.js"
+```js copy filename="src/config.js"
import { config } from 'dotenv'
config()
@@ -1069,7 +1076,7 @@ Let Haetae think *`config.js`* depends on *`.env`*.
'.graph': './apis/utils#graph',
'.dependOn': './apis/javascript#dependon',
}}>
-```js filename="haetae.config.js" {12-13,}
+```js copy filename="haetae.config.js" {12-13,}
import { $, configure, git, utils, js } from 'haetae'
export default configure({
@@ -1120,7 +1127,7 @@ Add these into the config file like this.
'.dependOn': './apis/javascript#dependon',
'.hash': './apis/utils#hash',
}}>
-```js filename="haetae.config.js" {7,9-13,31-33}
+```js copy filename="haetae.config.js" {7,9-13,31-33}
import { $, configure, git, utils, js } from 'haetae'
export default configure({
@@ -1164,7 +1171,7 @@ export default configure({
Now, **we return an object** from `myTest.run{:ts}`.
Let's execute it.
-```fish filename="Terminal" {13}
+```fish copy filename="Terminal" {13}
$ haetae myTest
✔ success Command myTest is successfully executed.
@@ -1192,7 +1199,7 @@ The value we returned from `myTest.run{:ts}` is recorded in the store file, as p
This time, *`.env`* was treated as a changed file, as the key `dotenv` did not exist from `previousRecord`.
-```js filename="haetae.config.js"
+```js copy filename="haetae.config.js"
// Other content is omitted for brevity
if (previousRecord?.data?.dotenv !== dotenvHash) {
changedFiles.push('.env')
@@ -1203,7 +1210,7 @@ Therefore, *`index.test.js`* and *`logic.test.js`*, which transitively depend on
If you run Haetae again immediately,
-```fish filename="Terminal" {12}
+```fish copy filename="Terminal" {12}
haetae myTest
```
@@ -1223,7 +1230,7 @@ We can enhance the workflow further.
'.graph': './apis/utils#graph',
'.dependOn': './apis/javascript#dependon',
}}>
-```js filename="haetae.config.js" {9-10,28}
+```js copy filename="haetae.config.js" {9-10,28}
import { $, configure, git, utils, js } from 'haetae'
export default configure({
@@ -1263,7 +1270,7 @@ We return nothing here.
We do not calculate hash by ourselves.
But this has the same effect as what we've done in the previous section.
-```fish filename="Terminal" {13-16}
+```fish copy filename="Terminal" {13-16}
$ haetae myTest
✔ success Command myTest is successfully executed.
@@ -1320,7 +1327,7 @@ Then we can modify the config file like this.
'.graph': './apis/utils#graph',
'.dependOn': './apis/javascript#dependon',
}}>
-```js filename="haetae.config.js" {9-14,20} showLineNumbers
+```js copy filename="haetae.config.js" {9-14,20} showLineNumbers
import { $, configure, git, utils, js } from 'haetae'
export default configure({
@@ -1404,7 +1411,7 @@ Otherwise, a file would be treated as changed every time the dynamic argument ch
-```js filename="haetae.config.js" {9-13,19} showLineNumbers
+```js copy filename="haetae.config.js" {9-13,19} showLineNumbers
// Other content is omitted for brevity
const changedFilesByHash = await utils.changedFiles(
[`.env.${process.env.ENV}`] // <--- Anti-pattern
@@ -1428,7 +1435,7 @@ for the return value of `env` and `run` of every command.
-```js filename="haetae.config.js" {4-6, 9}
+```js copy filename="haetae.config.js" {4-6, 9}
import { configure } from 'haetae'
export default configure({
@@ -1445,7 +1452,7 @@ export default configure({
-```fish filename="Terminal" {9}
+```fish copy filename="Terminal" {9}
$ haetae myGreeting
✔ success Command myGreeting is successfully executed.
@@ -1468,7 +1475,7 @@ You don't have to duplicate the code in every command's `env`.
'configure': './apis/haetae#configure',
'.hash': './apis/utils#hash',
}}>
-```js filename="haetae.config.js" {5-9}
+```js copy filename="haetae.config.js" {5-9}
import * as url from 'node:url'
import { configure, utils } from 'haetae'
@@ -1490,7 +1497,7 @@ export default configure({
```
-```fish filename="Terminal" {7}
+```fish copy filename="Terminal" {7}
$ haetae myGreeting --env
✔ success Current environment is successfully evaluated for the command myGreeting
@@ -1513,7 +1520,7 @@ When hashing multiple files, a [single-depth sorted Merkle Tree](./apis/utils#ha
'.hash': './apis/utils#hash',
'.deps': './apis/javascript#deps',
}}>
-```js filename="haetae.config.js" {4}
+```js copy filename="haetae.config.js" {4}
// Other content is omitted for brevity
haetaeConfig: await utils.hash(
// More strict than [url.fileURLToPath(import.meta.url)]
@@ -1531,7 +1538,7 @@ A dependency graph between *Root Env*, *Root Run*, *Command*'s *Run* and *Comman
-```js filename="haetae.config.js"
+```js copy filename="haetae.config.js"
import assert from 'node:assert/strict'
import { configure } from 'haetae'
@@ -1669,7 +1676,7 @@ The `store` object is accessible from everywhere as well.
-```js filename="haetae.config.ts" {5,6,8,9,20-22}
+```js copy filename="haetae.config.ts" {5,6,8,9,20-22}
import { configure } from 'haetae'
export default configure({