Generic Commit; Most likely a fix or small feature
This commit is contained in:
104
README.md
104
README.md
@@ -11,20 +11,8 @@ npm install
|
|||||||
npm run build
|
npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Push to Git
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git init
|
|
||||||
git add .
|
|
||||||
git commit -m "Initial commit: shared types package"
|
|
||||||
git remote add origin <your-git-repo-url>
|
|
||||||
git push -u origin main
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage in Other Projects
|
## Usage in Other Projects
|
||||||
|
|
||||||
### Option 1: Install from Git (HTTPS)
|
|
||||||
|
|
||||||
Add to your project's `package.json`:
|
Add to your project's `package.json`:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
@@ -41,58 +29,6 @@ Or install via command:
|
|||||||
npm install git+https://github.com/your-org/shared-types.git
|
npm install git+https://github.com/your-org/shared-types.git
|
||||||
```
|
```
|
||||||
|
|
||||||
### Option 2: Install from Git (SSH)
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"dependencies": {
|
|
||||||
"@your-org/shared-types": "git+ssh://git@github.com:your-org/shared-types.git"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Option 3: Install specific branch or tag
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"dependencies": {
|
|
||||||
"@your-org/shared-types": "git+https://github.com/your-org/shared-types.git#v1.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Or for a branch:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"dependencies": {
|
|
||||||
"@your-org/shared-types": "git+https://github.com/your-org/shared-types.git#develop"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Using the Types
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
import { User, ApiResponse, Status } from '@your-org/shared-types';
|
|
||||||
|
|
||||||
const user: User = {
|
|
||||||
id: '123',
|
|
||||||
email: 'user@example.com',
|
|
||||||
name: 'John Doe',
|
|
||||||
createdAt: new Date(),
|
|
||||||
updatedAt: new Date()
|
|
||||||
};
|
|
||||||
|
|
||||||
const response: ApiResponse<User> = {
|
|
||||||
success: true,
|
|
||||||
data: user,
|
|
||||||
message: 'User retrieved successfully'
|
|
||||||
};
|
|
||||||
|
|
||||||
const status = Status.Active;
|
|
||||||
```
|
|
||||||
|
|
||||||
## Updating the Package
|
## Updating the Package
|
||||||
|
|
||||||
When you make changes to the types:
|
When you make changes to the types:
|
||||||
@@ -100,42 +36,4 @@ When you make changes to the types:
|
|||||||
1. Update the version in `package.json`
|
1. Update the version in `package.json`
|
||||||
2. Build the package: `npm run build`
|
2. Build the package: `npm run build`
|
||||||
3. Commit and push changes
|
3. Commit and push changes
|
||||||
4. Update consuming applications: `npm update @your-org/shared-types`
|
4. Update consuming applications: `npm update @dpu/types`
|
||||||
|
|
||||||
## Development Workflow
|
|
||||||
|
|
||||||
### Adding New Types
|
|
||||||
|
|
||||||
1. Create new `.ts` files in the `src/` directory
|
|
||||||
2. Export types from `src/index.ts`
|
|
||||||
3. Build and test: `npm run build`
|
|
||||||
4. Commit changes and push
|
|
||||||
|
|
||||||
### Versioning
|
|
||||||
|
|
||||||
Follow semantic versioning:
|
|
||||||
- **MAJOR**: Breaking changes
|
|
||||||
- **MINOR**: New features, backward compatible
|
|
||||||
- **PATCH**: Bug fixes, backward compatible
|
|
||||||
|
|
||||||
### Best Practices
|
|
||||||
|
|
||||||
- Keep types focused and modular
|
|
||||||
- Use clear, descriptive names
|
|
||||||
- Document complex types with JSDoc comments
|
|
||||||
- Avoid coupling to specific implementations
|
|
||||||
- Export everything through `index.ts`
|
|
||||||
|
|
||||||
## Structure
|
|
||||||
|
|
||||||
```
|
|
||||||
shared-types/
|
|
||||||
├── src/
|
|
||||||
│ ├── index.ts # Main export file
|
|
||||||
│ └── types.ts # Type definitions
|
|
||||||
├── dist/ # Compiled output (generated)
|
|
||||||
├── package.json
|
|
||||||
├── tsconfig.json
|
|
||||||
├── .gitignore
|
|
||||||
└── README.md
|
|
||||||
```
|
|
||||||
|
|||||||
Reference in New Issue
Block a user