Skip to content

Commit

Permalink
Add: Add content about the programming interface to the README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
imjuni committed Nov 14, 2023
1 parent 201b2cb commit f8540eb
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 7 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ In addition, `ctix` will auto-generate `barrel` files so that a single `index.d.
- [Installation](#installation)
- [Usage](#usage)
- [How can I exclude unwanted files?](#how-can-i-exclude-unwanted-files)
- [Programming interface](#programming-interface)
- [Requirement](#requirement)
- [Important](#important)
- [More information](#more-information)
Expand Down Expand Up @@ -139,6 +140,18 @@ const Button = () => {
}
```

### Programming interface

When using task runners like Gulp and Just, as well as bundlers like webpack and rollup, you need a programming interface to add ctix.

| function | option | descryption |
| - | - | - |
| building | [TCommandBuildOptions](https://github.com/imjuni/ctix/blob/master/src/configs/interfaces/TCommandBuildOptions.ts) | Execute the `build` command |
| initializing | [TCommandInitOptions](https://github.com/imjuni/ctix/blob/master/src/configs/interfaces/TCommandInitOptions.ts) | Execute the `init` command |
| removing | [TCommandRemoveOptions](https://github.com/imjuni/ctix/blob/master/src/configs/interfaces/TCommandRemoveOptions.ts), [TCommandBuildOptions](https://github.com/imjuni/ctix/blob/master/src/configs/interfaces/TCommandBuildOptions.ts) | Execute the `remove` command |

Check out the [example code](https://github.com/imjuni/ctix/blob/master/doc/PROGRAMMING_INTERFACE.md).

## Requirement

- Node.js 18
Expand Down
7 changes: 0 additions & 7 deletions doc/CHANAGELOG.md

This file was deleted.

62 changes: 62 additions & 0 deletions doc/PROGRAMMING_INTERFACE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Programming interface

When using task runners like Gulp and Just, as well as bundlers like webpack and rollup, you need a programming interface to add ctix.

| function | option | descryption |
| - | - | - |
| building | [TCommandBuildOptions](https://github.com/imjuni/ctix/blob/master/src/configs/interfaces/TCommandBuildOptions.ts) | Execute the `build` command |
| initializing | [TCommandInitOptions](https://github.com/imjuni/ctix/blob/master/src/configs/interfaces/TCommandInitOptions.ts) | Execute the `init` command |
| removing | [TCommandRemoveOptions](https://github.com/imjuni/ctix/blob/master/src/configs/interfaces/TCommandRemoveOptions.ts), [TCommandBuildOptions](https://github.com/imjuni/ctix/blob/master/src/configs/interfaces/TCommandBuildOptions.ts) | Execute the `remove` command |

## CommonJS Example

```js
const fs = require('node:fs');
const ctix = require('ctix');

const handle = async () => {
const options = ctix.parseConfig(await fs.promises.readFile('.ctirc'));
await ctix.building(options);
};

handle();
```

## ESM, TypeScript Example

> esm
```js
import { building, parseConfig, TCommandBuildOptions } from 'ctix';
import fs from 'node:fs';

const handle = async () => {
const options = parseConfig(await fs.promises.readFile('.ctirc'));
await building(options);
};

handle();
```

> TypeScript
```ts
import { building, parseConfig, TCommandBuildOptions } from 'ctix';
import fs from 'node:fs';

const handle = async () => {
const options = parseConfig(await fs.promises.readFile('.ctirc')) as TCommandBuildOptions;
await building(options);
};

handle();
```

## Gulp Example

```js
gulp.task('ctix', async () => {
const options = parseConfig(await fs.promises.readFile('.configs/.ctirc'));
await building(options);
});
```

0 comments on commit f8540eb

Please sign in to comment.