Skip to content

Commit 1310a30

Browse files
committed
chore: wip
1 parent ae68c4e commit 1310a30

File tree

1 file changed

+192
-0
lines changed

1 file changed

+192
-0
lines changed

packages/dtsx/README.md

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
<p align="center"><img src="https://github.com/stacksjs/dtsx/blob/main/.github/art/cover.jpg?raw=true" alt="Social Card of this repo"></p>
2+
3+
[![npm version][npm-version-src]][npm-version-href]
4+
[![GitHub Actions][github-actions-src]][github-actions-href]
5+
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
6+
<!-- [![npm downloads][npm-downloads-src]][npm-downloads-href] -->
7+
<!-- [![Codecov][codecov-src]][codecov-href] -->
8+
9+
# dtsx
10+
11+
> A library that helps you generate TypeScript declaration files from your project. Given we do not know the user's input ever, we need to never hardcode based results based from our examples, always create a dynamic solution.
12+
13+
## Features
14+
15+
- ⚡ Extremely fast .d.ts generation
16+
- ⚙️ Highly configurable
17+
- 🪶 Lightweight library
18+
- 🤖 Cross-platform binary
19+
20+
## Install
21+
22+
```bash
23+
bun install -d @stacksjs/dtsx
24+
```
25+
26+
_@npmjs.com, please allow us to use the `dtsx` package name 🙏_
27+
28+
<!-- _Alternatively, you can install:_
29+
30+
```bash
31+
brew install dtsx # wip
32+
pkgx install dtsx # wip
33+
``` -->
34+
35+
## Get Started
36+
37+
There are two ways of using this ".d.ts generation" tool: _as a library or as a CLI._
38+
39+
_But before you get started, please ensure you enabled `isolatedDeclarations` in your `tsconfig.json` file._
40+
41+
```json
42+
{
43+
"compilerOptions": {
44+
"isolatedDeclarations": true
45+
}
46+
}
47+
```
48+
49+
## Library
50+
51+
Given the npm package is installed, you can use the `generate` function to generate TypeScript declaration files from your project.
52+
53+
### Usage
54+
55+
```ts
56+
import type { DtsGenerationOptions } from '@stacksjs/dtsx'
57+
import { generate } from '@stacksjs/dtsx'
58+
59+
const options: DtsGenerationOptions = {
60+
cwd: './', // default: process.cwd()
61+
root: './src', // default: './src'
62+
entrypoints: ['**/*.ts'], // default: ['**/*.ts']
63+
outdir: './dist', // default: './dist'
64+
clean: true, // default: false
65+
verbose: true, // default: false
66+
keepComments: true, // default: true
67+
}
68+
69+
await generate(options)
70+
```
71+
72+
_Available options:_
73+
74+
Library usage can also be configured using a `dts.config.ts` _(or `dts.config.js`)_ file which is automatically loaded when running the `./dtsx` _(or `bunx dtsx`)_ command. It is also loaded when the `generate` function is called, unless custom options are provided.
75+
76+
```ts
77+
// dts.config.ts (or dts.config.js)
78+
79+
export default {
80+
cwd: './',
81+
root: './src',
82+
entrypoints: ['**/*.ts'],
83+
outdir: './dist',
84+
keepComments: true,
85+
clean: true,
86+
verbose: true,
87+
}
88+
```
89+
90+
_You may also run:_
91+
92+
```bash
93+
./dtsx generate
94+
95+
# if the package is installed, you can also run:
96+
# bunx dtsx generate
97+
```
98+
99+
## CLI
100+
101+
The `dtsx` CLI provides a simple way to generate TypeScript declaration files from your project. Here's how to use it:
102+
103+
### Usage
104+
105+
Generate declaration files using the default options:
106+
107+
```bash
108+
dtsx generate
109+
```
110+
111+
_Or use custom options:_
112+
113+
```bash
114+
# Generate declarations for specific entry points:
115+
dtsx generate --entrypoints src/index.ts,src/utils.ts --outdir dist/types
116+
117+
# Generate declarations with custom configuration:
118+
dtsx generate --root ./lib --outdir ./types --clean
119+
120+
dtsx --help
121+
dtsx --version
122+
```
123+
124+
_Available options:_
125+
126+
- `--cwd <path>`: Set the current working directory _(default: current directory)_
127+
- `--root <path>`: Specify the root directory of the project _(default: './src')_
128+
- `--entrypoints <files>`: Define entry point files _(comma-separated, default: '**/*.ts')_
129+
- `--outdir <path>`: Set the output directory for generated .d.ts files _(default: './dist')_
130+
- `--keep-comments`: Keep comments in generated .d.ts files _(default: true)_
131+
- `--clean`: Clean output directory before generation _(default: false)_
132+
- `--tsconfig <path>`: Specify the path to tsconfig.json _(default: 'tsconfig.json')_
133+
- `--verbose`: Enable verbose output _(default: false)_
134+
135+
To learn more, head over to the [documentation](https://dtsx.stacksjs.org/).
136+
137+
## Testing
138+
139+
```bash
140+
bun test
141+
```
142+
143+
## Changelog
144+
145+
Please see our [releases](https://github.com/stacksjs/stacks/releases) page for more information on what has changed recently.
146+
147+
## Contributing
148+
149+
Please review the [Contributing Guide](https://github.com/stacksjs/contributing) for details.
150+
151+
## Community
152+
153+
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
154+
155+
[Discussions on GitHub](https://github.com/stacksjs/stacks/discussions)
156+
157+
For casual chit-chat with others using this package:
158+
159+
[Join the Stacks Discord Server](https://discord.gg/stacksjs)
160+
161+
## Postcardware
162+
163+
“Software that is free, but hopes for a postcard.” We love receiving postcards from around the world showing where `dtsx` is being used! We showcase them on our website too.
164+
165+
Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States 🌎
166+
167+
## Sponsors
168+
169+
We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.
170+
171+
- [JetBrains](https://www.jetbrains.com/)
172+
- [The Solana Foundation](https://solana.com/)
173+
174+
## Credits
175+
176+
- [Chris Breuer](https://github.com/chrisbbreuer)
177+
- [All Contributors](../../contributors)
178+
179+
## License
180+
181+
The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/dtsx/tree/main/LICENSE.md) for more information.
182+
183+
Made with 💙
184+
185+
<!-- Badges -->
186+
[npm-version-src]: https://img.shields.io/npm/v/@stacksjs/dtsx?style=flat-square
187+
[npm-version-href]: https://npmjs.com/package/@stacksjs/dtsx
188+
[github-actions-src]: https://img.shields.io/github/actions/workflow/status/stacksjs/dtsx/ci.yml?style=flat-square&branch=main
189+
[github-actions-href]: https://github.com/stacksjs/dtsx/actions?query=workflow%3Aci
190+
191+
<!-- [codecov-src]: https://img.shields.io/codecov/c/gh/stacksjs/dtsx/main?style=flat-square
192+
[codecov-href]: https://codecov.io/gh/stacksjs/dtsx -->

0 commit comments

Comments
 (0)