@stacksjs/dtsx 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -31
- package/dist/cli.js +154 -85522
- package/dist/config.d.ts +2 -0
- package/dist/index.js +1 -65068
- package/dist/utils.d.ts +2 -0
- package/package.json +5 -7
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<p align="center"><img src="https://github.com/stacksjs/
|
|
1
|
+
<p align="center"><img src="https://github.com/stacksjs/dtsx/blob/main/.github/art/cover.png?raw=true" alt="Social Card of this repo"></p>
|
|
2
2
|
|
|
3
3
|
[![npm version][npm-version-src]][npm-version-href]
|
|
4
4
|
[![GitHub Actions][github-actions-src]][github-actions-href]
|
|
@@ -10,9 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
- Fast .d.ts generation _(via isolatedDeclaration)_
|
|
12
12
|
- Highly configurable
|
|
13
|
+
- Lightweight library
|
|
13
14
|
- Cross-platform binary
|
|
14
|
-
- Dependency-free
|
|
15
|
-
- Bun-powered
|
|
16
15
|
|
|
17
16
|
## Install
|
|
18
17
|
|
|
@@ -20,43 +19,48 @@
|
|
|
20
19
|
bun install -d @stacksjs/dtsx
|
|
21
20
|
```
|
|
22
21
|
|
|
23
|
-
_@
|
|
22
|
+
_@npmjs.com, please allow us to use the `dtsx` package name 🙏_
|
|
24
23
|
|
|
25
24
|
<!-- _Alternatively, you can install:_
|
|
26
25
|
|
|
27
26
|
```bash
|
|
28
|
-
brew install
|
|
29
|
-
pkgx install
|
|
27
|
+
brew install dtsx # wip
|
|
28
|
+
pkgx install dtsx # wip
|
|
30
29
|
``` -->
|
|
31
30
|
|
|
32
31
|
## Get Started
|
|
33
32
|
|
|
34
|
-
There are two ways of using this
|
|
33
|
+
There are two ways of using this ".d.ts generation" tool: _as a library or as a CLI._
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
## Library
|
|
37
36
|
|
|
38
|
-
Given the npm package is installed
|
|
37
|
+
Given the npm package is installed, you can use the `generate` function to generate TypeScript declaration files from your project.
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
import { generate } from 'dts-generation'
|
|
39
|
+
### Usage
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
```ts
|
|
42
|
+
import type { DtsGenerationOptions } from '@stacksjs/dtsx'
|
|
43
|
+
import { generate } from '@stacksjs/dtsx'
|
|
44
|
+
|
|
45
|
+
const options: DtsGenerationOptions = {
|
|
46
|
+
cwd: './', // default: process.cwd()
|
|
47
|
+
root: './src', // default: './src'
|
|
48
|
+
entrypoints: ['**/*.ts'], // default: ['**/*.ts']
|
|
49
|
+
outdir: './dist', // default: './dist'
|
|
50
|
+
keepComments: true, // default: true
|
|
51
|
+
clean: true, // default: false
|
|
52
|
+
}
|
|
47
53
|
|
|
48
|
-
|
|
49
|
-
dts-generation ...
|
|
50
|
-
dts-generation --help
|
|
51
|
-
dts-generation --version
|
|
54
|
+
await generate(options)
|
|
52
55
|
```
|
|
53
56
|
|
|
54
|
-
|
|
57
|
+
_Available options:_
|
|
55
58
|
|
|
56
|
-
|
|
59
|
+
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.
|
|
57
60
|
|
|
58
61
|
```ts
|
|
59
62
|
// dts.config.ts (or dts.config.js)
|
|
63
|
+
|
|
60
64
|
export default {
|
|
61
65
|
cwd: './',
|
|
62
66
|
root: './src',
|
|
@@ -67,13 +71,51 @@ export default {
|
|
|
67
71
|
}
|
|
68
72
|
```
|
|
69
73
|
|
|
70
|
-
|
|
74
|
+
_You may also run:_
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
./dtsx generate
|
|
78
|
+
|
|
79
|
+
# if the package is installed, you can also run:
|
|
80
|
+
# bunx dtsx generate
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## CLI
|
|
84
|
+
|
|
85
|
+
The `dtsx` CLI provides a simple way to generate TypeScript declaration files from your project. Here's how to use it:
|
|
86
|
+
|
|
87
|
+
### Usage
|
|
88
|
+
|
|
89
|
+
Generate declaration files using the default options:
|
|
71
90
|
|
|
72
91
|
```bash
|
|
73
|
-
|
|
92
|
+
dtsx generate
|
|
74
93
|
```
|
|
75
94
|
|
|
76
|
-
|
|
95
|
+
_Or use custom options:_
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Generate declarations for specific entry points:
|
|
99
|
+
dtsx generate --entrypoints src/index.ts,src/utils.ts --outdir dist/types
|
|
100
|
+
|
|
101
|
+
# Generate declarations with custom configuration:
|
|
102
|
+
dtsx generate --root ./lib --outdir ./types --clean
|
|
103
|
+
|
|
104
|
+
dtsx --help
|
|
105
|
+
dtsx --version
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
_Available options:_
|
|
109
|
+
|
|
110
|
+
- `--cwd <path>`: Set the current working directory _(default: current directory)_
|
|
111
|
+
- `--root <path>`: Specify the root directory of the project _(default: './src')_
|
|
112
|
+
- `--entrypoints <files>`: Define entry point files _(comma-separated, default: '**/*.ts')_
|
|
113
|
+
- `--outdir <path>`: Set the output directory for generated .d.ts files _(default: './dist')_
|
|
114
|
+
- `--keep-comments`: Keep comments in generated .d.ts files _(default: true)_
|
|
115
|
+
- `--clean`: Clean output directory before generation _(default: false)_
|
|
116
|
+
- `--tsconfig <path>`: Specify the path to tsconfig.json _(default: 'tsconfig.json')_
|
|
117
|
+
|
|
118
|
+
To learn more, head over to the [documentation](https://dtsx.stacksjs.org/).
|
|
77
119
|
|
|
78
120
|
## Testing
|
|
79
121
|
|
|
@@ -119,15 +161,15 @@ We would like to extend our thanks to the following sponsors for funding Stacks
|
|
|
119
161
|
|
|
120
162
|
## License
|
|
121
163
|
|
|
122
|
-
The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/
|
|
164
|
+
The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/dtsx/tree/main/LICENSE.md) for more information.
|
|
123
165
|
|
|
124
166
|
Made with 💙
|
|
125
167
|
|
|
126
168
|
<!-- Badges -->
|
|
127
|
-
[npm-version-src]: https://img.shields.io/npm/v/@stacksjs/
|
|
128
|
-
[npm-version-href]: https://npmjs.com/package/@stacksjs/
|
|
129
|
-
[github-actions-src]: https://img.shields.io/github/actions/workflow/status/stacksjs/
|
|
130
|
-
[github-actions-href]: https://github.com/stacksjs/
|
|
169
|
+
[npm-version-src]: https://img.shields.io/npm/v/@stacksjs/dtsx?style=flat-square
|
|
170
|
+
[npm-version-href]: https://npmjs.com/package/@stacksjs/dtsx
|
|
171
|
+
[github-actions-src]: https://img.shields.io/github/actions/workflow/status/stacksjs/dtsx/ci.yml?style=flat-square&branch=main
|
|
172
|
+
[github-actions-href]: https://github.com/stacksjs/dtsx/actions?query=workflow%3Aci
|
|
131
173
|
|
|
132
|
-
<!-- [codecov-src]: https://img.shields.io/codecov/c/gh/stacksjs/
|
|
133
|
-
[codecov-href]: https://codecov.io/gh/stacksjs/
|
|
174
|
+
<!-- [codecov-src]: https://img.shields.io/codecov/c/gh/stacksjs/dtsx/main?style=flat-square
|
|
175
|
+
[codecov-href]: https://codecov.io/gh/stacksjs/dtsx -->
|