Skip to content

Commit c9c4611

Browse files
committed
chore: add stacks docs and cursor rules
1 parent 7ff10b0 commit c9c4611

13 files changed

+458
-85
lines changed

.cursor/rules/code-style.mdc

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
description: Code Style & Structure specifics
3+
globs:
4+
---
5+
## Code Style & Structure
6+
7+
- Write concise, technical TypeScript code with accurate examples in the docblock
8+
- If Bun native modules are available, use them
9+
- Use functional and declarative programming patterns; avoid classes unless needed
10+
- Prefer iteration and modularization over code duplication
11+
- Use descriptive variable names with auxiliary verbs (e.g., `isLoading`, `hasError`)
12+
- Use proper jsdoc comments for functions, types, interfaces, and ensure examples are accurate

.cursor/rules/documentation.mdc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
description: Documentation specific rules
3+
globs: docs/**/*.md
4+
---
5+
## Documentation
6+
7+
- Write documentation for all functions, types, interfaces, and ensure examples are accurate
8+
- The `./docs` directory is where the vitepress markdown documentation is stored
9+
- Make sure to update the docs markdown files

.cursor/rules/error-handling.mdc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
description: Error Handling and Validation specifics
3+
globs:
4+
---
5+
## Error Handling and Validation
6+
7+
- Prioritize error handling: handle errors and edge cases early
8+
- Use early returns and guard clauses
9+
- Implement proper error logging and user-friendly messages
10+
- Use error boundaries for unexpected errors
11+
- when `neverthrow` is available, ensure errors are typed

.cursor/rules/key-conventions.mdc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
description: Key code conventions
3+
globs:
4+
---
5+
## Key Conventions
6+
7+
- If there are two equally valid implementations, the browser version should be preferred
8+
- Aim for 100% test coverage
9+
- Avoid usage of `any`
10+
- Reuse eslint-ignore comments where present, unless not needed
11+
- ensure we log everything properly, including for debug reasons

.cursor/rules/project-structure.mdc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
description: Project structure information
3+
globs:
4+
---
5+
## Project Structure
6+
7+
- the `./src` directory is the source code
8+
- the `./test` directory is the test code
9+
- the `./bin` directory is the command-line code
10+
- you can also call the CLI via `./clarity ...`
11+
- the `./docs` directory is the documentation

.cursor/rules/readme.mdc

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
---
2+
description: General information based on the latest ./README.md content
3+
globs:
4+
---
5+
Update it if APIs change:
6+
7+
# dtsx
8+
9+
> 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.
10+
11+
## Features
12+
13+
- ⚡ Extremely fast .d.ts generation
14+
- ⚙️ Highly configurable
15+
- 🪶 Lightweight library
16+
- 🤖 Cross-platform binary
17+
18+
## Install
19+
20+
```bash
21+
bun install -d @stacksjs/dtsx
22+
```
23+
24+
<[email protected]>, please allow us to use the `dtsx` package name 🙏_
25+
26+
<!-- _Alternatively, you can install:_
27+
28+
```bash
29+
brew install dtsx # wip
30+
pkgx install dtsx # wip
31+
``` -->
32+
33+
## Get Started
34+
35+
There are two ways of using this ".d.ts generation" tool: _as a library or as a CLI._
36+
37+
_But before you get started, please ensure you enabled `isolatedDeclarations` in your `tsconfig.json` file._
38+
39+
```json
40+
{
41+
"compilerOptions": {
42+
"isolatedDeclarations": true
43+
}
44+
}
45+
```
46+
47+
## Library
48+
49+
Given the npm package is installed, you can use the `generate` function to generate TypeScript declaration files from your project.
50+
51+
### Usage
52+
53+
```ts
54+
import type { DtsGenerationOptions } from '@stacksjs/dtsx'
55+
import { generate } from '@stacksjs/dtsx'
56+
57+
const options: DtsGenerationOptions = {
58+
cwd: './', // default: process.cwd()
59+
root: './src', // default: './src'
60+
entrypoints: ['**/*.ts'], // default: ['**/*.ts']
61+
outdir: './dist', // default: './dist'
62+
clean: true, // default: false
63+
verbose: true, // default: false
64+
// keepComments: true, // coming soon
65+
}
66+
67+
await generate(options)
68+
```
69+
70+
_Available options:_
71+
72+
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.
73+
74+
```ts
75+
// dts.config.ts (or dts.config.js)
76+
77+
export default {
78+
cwd: './',
79+
root: './src',
80+
entrypoints: ['**/*.ts'],
81+
outdir: './dist',
82+
keepComments: true,
83+
clean: true,
84+
verbose: true,
85+
}
86+
```
87+
88+
_You may also run:_
89+
90+
```bash
91+
./dtsx generate
92+
93+
# if the package is installed, you can also run:
94+
# bunx dtsx generate
95+
```
96+
97+
## CLI
98+
99+
The `dtsx` CLI provides a simple way to generate TypeScript declaration files from your project. Here's how to use it:
100+
101+
### Usage
102+
103+
Generate declaration files using the default options:
104+
105+
```bash
106+
dtsx generate
107+
```
108+
109+
_Or use custom options:_
110+
111+
```bash
112+
# Generate declarations for specific entry points:
113+
dtsx generate --entrypoints src/index.ts,src/utils.ts --outdir dist/types
114+
115+
# Generate declarations with custom configuration:
116+
dtsx generate --root ./lib --outdir ./types --clean
117+
118+
dtsx --help
119+
dtsx --version
120+
```
121+
122+
_Available options:_
123+
124+
- `--cwd <path>`: Set the current working directory _(default: current directory)_
125+
- `--root <path>`: Specify the root directory of the project _(default: './src')_
126+
- `--entrypoints <files>`: Define entry point files _(comma-separated, default: '**/*.ts')_
127+
- `--outdir <path>`: Set the output directory for generated .d.ts files _(default: './dist')_
128+
- `--keep-comments`: Keep comments in generated .d.ts files _(default: true)_
129+
- `--clean`: Clean output directory before generation _(default: false)_
130+
- `--tsconfig <path>`: Speci tsconfig.json _(default: 'tsconfig.json')_
131+
- `--verbose`: Enable verbose output _(default: false)_
132+
133+
To learn more, head over to the [documentation](mdc:https:/dtsx.stacksjs.org).

.cursor/rules/syntax-formatting.mdc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
description: Syntax and Formatting specifics
3+
globs:
4+
---
5+
## Syntax and Formatting
6+
7+
- Use the "function" keyword for pure functions
8+
- Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements
9+
- Make sure everything is properly commented

.cursor/rules/testing.mdc

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
description: Testing specifics
3+
globs:
4+
---
5+
## Testing
6+
7+
- Write tests for all functions, types, interfaces, and ensure examples are accurate
8+
- The `./test` directory is where the tests are stored
9+
- Use `bun test` to run the tests
10+
- Use bun native modules for testing from `import { x, y, z } from 'bun:test'`

.cursor/rules/typescript.mdc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
description: TypeScript Usage specifics
3+
globs: docs/**/*.md
4+
---
5+
## TypeScript Usage
6+
7+
- Use TypeScript for all code; prefer interfaces over types
8+
- Avoid enums; use `maps` instead, or `as const`
9+
- Use functional components with TypeScript interfaces

README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
<!-- [![npm downloads][npm-downloads-src]][npm-downloads-href] -->
77
<!-- [![Codecov][codecov-src]][codecov-href] -->
88

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+
913
## Features
1014

1115
- ⚡ Extremely fast .d.ts generation
@@ -19,7 +23,7 @@
1923
bun install -d @stacksjs/dtsx
2024
```
2125

22-
_@npmjs.com, please allow us to use the `dtsx` package name 🙏_
26+
<[email protected]>, please allow us to use the `dtsx` package name 🙏_
2327

2428
<!-- _Alternatively, you can install:_
2529
@@ -156,9 +160,9 @@ For casual chit-chat with others using this package:
156160

157161
## Postcardware
158162

159-
Two things are true: Stacks OSS will always stay open-source, and we do love to receive postcards from wherever Stacks is used! 🌍 _We also publish them on our website. And thank you, Spatie_
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.
160164

161-
Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094
165+
Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States 🌎
162166

163167
## Sponsors
164168

0 commit comments

Comments
 (0)