Skip to content

Commit 1307be8

Browse files
🎉 Initial Commit
0 parents  commit 1307be8

File tree

14 files changed

+1319
-0
lines changed

14 files changed

+1319
-0
lines changed

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# dependencies (bun install)
2+
node_modules
3+
4+
# output
5+
out
6+
dist
7+
*.tgz
8+
9+
# code coverage
10+
coverage
11+
*.lcov
12+
13+
# logs
14+
logs
15+
_.log
16+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
17+
18+
# dotenv environment variable files
19+
.env
20+
.env.development.local
21+
.env.test.local
22+
.env.production.local
23+
.env.local
24+
25+
# caches
26+
.eslintcache
27+
.cache
28+
*.tsbuildinfo
29+
30+
# IntelliJ based IDEs
31+
.idea
32+
33+
# Finder (MacOS) folder config
34+
.DS_Store

CONTRIBUTING.md

Lines changed: 300 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,300 @@
1+
# Contributing to id-ts
2+
3+
Thank you for considering contributing to id-ts! 🎉 We welcome contributions from everyone, whether you're fixing a bug, adding a feature, improving documentation, or just asking questions.
4+
5+
## 📋 Table of Contents
6+
7+
- [Code of Conduct](#code-of-conduct)
8+
- [How to Contribute](#how-to-contribute)
9+
- [Development Setup](#development-setup)
10+
- [Pull Request Process](#pull-request-process)
11+
- [Coding Standards](#coding-standards)
12+
- [Testing Guidelines](#testing-guidelines)
13+
- [Documentation Guidelines](#documentation-guidelines)
14+
- [Issue Guidelines](#issue-guidelines)
15+
- [Contributors](#contributors)
16+
17+
## 🤝 Code of Conduct
18+
19+
This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code:
20+
21+
- **Be respectful**: Treat everyone with respect, regardless of their background, identity, or experience level
22+
- **Be inclusive**: Welcome newcomers and help them get involved
23+
- **Be constructive**: Provide helpful feedback and suggestions
24+
- **Be patient**: Remember that everyone is learning and growing
25+
- **Be collaborative**: Work together towards common goals
26+
27+
## 🚀 How to Contribute
28+
29+
### Ways to Contribute
30+
31+
1. **Report bugs** - Help us identify and fix issues
32+
2. **Suggest features** - Share ideas for new functionality
33+
3. **Fix bugs** - Submit bug fixes with tests
34+
4. **Add features** - Implement new functionality
35+
5. **Improve documentation** - Make our docs clearer and more helpful
36+
6. **Write tests** - Improve test coverage
37+
7. **Code reviews** - Review pull requests from other contributors
38+
39+
### Getting Started
40+
41+
1. **Fork the repository** on GitHub
42+
2. **Clone your fork** locally
43+
3. **Create a feature branch** for your changes
44+
4. **Make your changes** following our guidelines
45+
5. **Test your changes** thoroughly
46+
6. **Submit a pull request**
47+
48+
## 🛠️ Development Setup
49+
50+
### Prerequisites
51+
52+
- [Node.js](https://nodejs.org/) 18+ or [Bun](https://bun.sh/)
53+
- [Git](https://git-scm.com/)
54+
- TypeScript 5+ knowledge
55+
56+
### Local Setup
57+
58+
```bash
59+
# 1. Fork the repository on GitHub, then clone your fork
60+
git clone https://github.com/YOUR_USERNAME/id-ts.git
61+
cd id-ts
62+
63+
# 2. Install dependencies
64+
bun install
65+
66+
# 3. Run tests to make sure everything works
67+
bun test
68+
69+
# 4. Start development!
70+
```
71+
72+
### Project Structure
73+
74+
```
75+
id-ts/
76+
├── src/ # Source code
77+
│ ├── id-helper.ts # Main IdHelper class
78+
│ ├── types.ts # Type definitions
79+
│ ├── index.ts # Public API exports
80+
│ └── validators/ # Optional validation schemas
81+
│ └── zod.ts # Zod integration
82+
├── tests/ # Test files
83+
│ ├── id-helper.test.ts
84+
│ └── validators/
85+
├── dist/ # Built files (generated)
86+
├── docs/ # Documentation
87+
└── package.json
88+
```
89+
90+
### Available Scripts
91+
92+
```bash
93+
# Run tests
94+
bun test # Run all tests
95+
bun test:ui # Run tests with UI
96+
bun test:run # Run tests once (CI mode)
97+
98+
# Build
99+
bun run build # Build the package
100+
101+
# Development
102+
bun run dev # Watch mode (if available)
103+
```
104+
105+
## 🔄 Pull Request Process
106+
107+
### Before Submitting
108+
109+
1. **Ensure tests pass**: `bun test`
110+
2. **Add tests** for new features or bug fixes
111+
3. **Update documentation** if needed
112+
4. **Follow coding standards** (see below)
113+
5. **Write clear commit messages**
114+
115+
### Commit Message Format
116+
117+
We use conventional commits for clear history:
118+
119+
```
120+
type(scope): description
121+
122+
[optional body]
123+
124+
[optional footer]
125+
```
126+
127+
**Types:**
128+
129+
- `feat`: New feature
130+
- `fix`: Bug fix
131+
- `docs`: Documentation changes
132+
- `test`: Adding or updating tests
133+
- `refactor`: Code refactoring
134+
- `perf`: Performance improvements
135+
- `chore`: Maintenance tasks
136+
137+
**Examples:**
138+
139+
```
140+
feat: add custom separator support for ID generation
141+
142+
fix(validation): handle edge case in zod schema validation
143+
144+
docs: update README with new API examples
145+
146+
test: add comprehensive tests for custom alphabets
147+
```
148+
149+
### Pull Request Template
150+
151+
When creating a PR, please include:
152+
153+
1. **Description**: What changes you made and why
154+
2. **Type of change**: Bug fix, new feature, documentation, etc.
155+
3. **Testing**: How you tested your changes
156+
4. **Screenshots**: If applicable (UI changes)
157+
5. **Breaking changes**: If any, with migration guide
158+
159+
## 📏 Coding Standards
160+
161+
### TypeScript Standards
162+
163+
- **Use TypeScript strictly**: Enable strict mode, no `any` types
164+
- **Prefer explicit types**: When type inference isn't clear
165+
- **Use generic types**: For reusable components
166+
- **Document complex types**: Add JSDoc for complex type definitions
167+
168+
### Code Style
169+
170+
- **Use Prettier**: Code formatting is handled automatically
171+
- **Use meaningful names**: Variables, functions, and classes should be self-documenting
172+
- **Keep functions small**: One responsibility per function
173+
- **Use async/await**: Instead of Promise chains where possible
174+
175+
### File Organization
176+
177+
- **One export per file**: For main functionality
178+
- **Group related functionality**: Keep related code together
179+
- **Use barrel exports**: Re-export from index files
180+
- **Consistent naming**: Use kebab-case for files, PascalCase for classes
181+
182+
## 🧪 Testing Guidelines
183+
184+
### Testing Requirements
185+
186+
All contributions should include appropriate tests:
187+
188+
- **Unit tests**: For individual functions/methods
189+
- **Integration tests**: For component interactions
190+
- **Type tests**: For TypeScript type safety
191+
- **Edge cases**: Test boundary conditions
192+
193+
### Test Structure
194+
195+
```typescript
196+
import { describe, it, expect } from "vitest";
197+
import { IdHelper } from "../src";
198+
199+
describe("IdHelper", () => {
200+
it("should describe what it tests", () => {
201+
// Arrange
202+
const idHelper = new IdHelper("test");
203+
204+
// Act
205+
const result = idHelper.generate();
206+
207+
// Assert
208+
expect(result).toMatch(/^test_[a-zA-Z0-9]{10}$/);
209+
});
210+
});
211+
```
212+
213+
### Test Coverage
214+
215+
- Aim for **90%+ coverage** on new code
216+
- Test **happy paths** and **error cases**
217+
- Include **regression tests** for bug fixes
218+
- Test **TypeScript types** where applicable
219+
220+
## 📚 Documentation Guidelines
221+
222+
### Code Documentation
223+
224+
- **JSDoc comments** for public APIs
225+
- **Inline comments** for complex logic
226+
- **README updates** for new features
227+
- **Type documentation** for complex generics
228+
229+
### Documentation Style
230+
231+
````typescript
232+
/**
233+
* Generates a prefixed ID with customizable options.
234+
*
235+
* @returns A type-safe string in format `${prefix}${separator}${id}`
236+
* @example
237+
* ```typescript
238+
* const userIds = new IdHelper('user');
239+
* const id = userIds.generate(); // "user_abc123xyz"
240+
* ```
241+
*/
242+
public generate(): GeneratedID<P, SeparatorOrDefault<S>> {
243+
// Implementation
244+
}
245+
````
246+
247+
## 🐛 Issue Guidelines
248+
249+
### Bug Reports
250+
251+
When reporting bugs, please include:
252+
253+
1. **Clear title**: Describe the issue briefly
254+
2. **Expected behavior**: What should happen
255+
3. **Actual behavior**: What actually happens
256+
4. **Steps to reproduce**: Clear, numbered steps
257+
5. **Environment**: Node.js/Bun version, OS, etc.
258+
6. **Code example**: Minimal reproduction case
259+
260+
### Feature Requests
261+
262+
For new features, please provide:
263+
264+
1. **Problem description**: What problem does this solve?
265+
2. **Proposed solution**: How should it work?
266+
3. **Alternatives considered**: Other ways to solve this
267+
4. **Implementation ideas**: Technical approach (if any)
268+
5. **Breaking changes**: Would this break existing code?
269+
270+
## 📞 Getting Help
271+
272+
If you need help:
273+
274+
1. **Check existing issues** - Your question might already be answered
275+
2. **Read the documentation** - The README has extensive examples
276+
3. **Create a discussion** - For general questions
277+
4. **Join our community** - [Discord/Slack link if applicable]
278+
279+
## 🔄 Release Process
280+
281+
_For maintainers:_
282+
283+
1. Update version in `package.json`
284+
2. Update `CHANGELOG.md`
285+
3. Create git tag: `git tag v1.0.0`
286+
4. Push tag: `git push origin --tags`
287+
5. GitHub Actions will handle npm publishing
288+
289+
## ❤️ Recognition
290+
291+
We appreciate all contributions, no matter how small! Contributors will be:
292+
293+
- **Listed in this file**
294+
- **Mentioned in release notes**
295+
- **Given credit in commit history**
296+
- **Thanked publicly** (if desired)
297+
298+
---
299+
300+
Thank you for contributing to id-ts! Together, we can make type-safe ID generation better for everyone. 🚀

0 commit comments

Comments
 (0)