Skip to content

Commit d4643a6

Browse files
committed
More docs
1 parent 3487a03 commit d4643a6

File tree

2 files changed

+97
-4
lines changed

2 files changed

+97
-4
lines changed

CLAUDE.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
## Commands
44

5-
- Build: `npm run build`
6-
- Lint: `eslint src --ext .ts,.tsx`
5+
- Build: `npm run build` (builds both ESM and CJS modules)
6+
- Clean: `npm run clean`
7+
- Lint: `npm run lint` or `eslint src --ext .ts,.tsx`
78
- Test all: `npm test`
89
- Test single: `vitest src/path/to/file.test.ts`
910
- Test watch mode: `npm run test:watch`
@@ -12,15 +13,16 @@
1213

1314
## Code Style
1415

15-
- **Formatting**: Use Prettier with 4-space indentation and 120 character line width
16+
- **Formatting**: 4-space indentation, 120 character line width
1617
- **Imports**: Use relative imports with file extension omitted
1718
- **Types**: Explicit return types required; prefer specific types over `any`
1819
- **Naming**:
1920
- camelCase for variables, functions, methods
2021
- PascalCase for classes, interfaces, types
2122
- Avoid prefixing interfaces with 'I'
22-
- **Error Handling**: Use utility functions (`assert`, `defined`, `panic`) for validation and error cases
23+
- **Error Handling**: Use utility functions (`assert`, `defined`, `panic`) for validation
2324
- **Tests**: Co-locate tests with source files using `.test.ts` extension
2425
- **Documentation**: Use JSDoc comments for exported functions and classes
26+
- **Module System**: Supports both ESM and CommonJS via dual-format publishing
2527

2628
Write exhaustive tests with high coverage (aim for 95%+). Use branded types for string subtypes to enforce type safety.

RELEASE.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Release Process
2+
3+
This document explains how to release new versions of `@glideapps/ts-necessities` to NPM.
4+
5+
## GitHub Actions Workflows
6+
7+
The repository uses two main GitHub Actions workflows:
8+
9+
1. **CI Workflow** (`ci.yml`)
10+
- Runs on every push to `main` and on pull requests
11+
- Runs on Node.js 20.x and 22.x
12+
- Performs build, lint, and test operations
13+
- Verifies dual module compatibility (CJS and ESM)
14+
15+
2. **Publish Workflow** (`publish.yml`)
16+
- Triggers automatically when a GitHub release is created
17+
- Builds, tests, and publishes the package to NPM
18+
- Verifies that the package version matches the GitHub release tag
19+
- Uses the `NPM_TOKEN` secret for authentication
20+
21+
## Making a Release
22+
23+
### Prerequisites
24+
25+
- Ensure you have write access to the GitHub repository
26+
- Make sure the `NPM_TOKEN` secret is set up in the repository settings
27+
- Go to Settings → Secrets and variables → Actions
28+
- The token should have permission to publish to the `@glideapps` organization
29+
30+
### Steps to Release
31+
32+
1. **Update Package Version**
33+
- Update the `version` field in `package.json`
34+
- Commit and push the change to `main`
35+
36+
2. **Create a GitHub Release**
37+
- Go to the repository on GitHub
38+
- Navigate to Releases → "Create a new release"
39+
- Create a new tag (e.g., `v2.4.0` - must match the version in `package.json`)
40+
- Add a title and description for the release
41+
- Click "Publish release"
42+
43+
3. **Automatic Publishing**
44+
- The `publish.yml` workflow will automatically trigger
45+
- It will verify the version matches the tag
46+
- If tests pass, it will publish to NPM
47+
48+
4. **Verify the Release**
49+
- Check the Actions tab to ensure the workflow completed successfully
50+
- Verify the package is available on NPM with the new version
51+
52+
## Dual Module Format
53+
54+
The package is published in both CommonJS and ESM formats:
55+
56+
- `dist/index.js` - CommonJS module
57+
- `dist/index.mjs` - ESM module
58+
- `dist/index.d.ts` - TypeScript declarations
59+
60+
The `package.json` is configured with:
61+
```json
62+
{
63+
"main": "dist/index.js",
64+
"module": "dist/index.mjs",
65+
"types": "dist/index.d.ts",
66+
"exports": {
67+
".": {
68+
"types": "./dist/index.d.ts",
69+
"import": "./dist/index.mjs",
70+
"require": "./dist/index.js",
71+
"default": "./dist/index.js"
72+
}
73+
}
74+
}
75+
```
76+
77+
This configuration ensures that:
78+
- Node.js projects using CommonJS will use `dist/index.js`
79+
- Projects using ESM will use `dist/index.mjs`
80+
- TypeScript tools will find the type definitions
81+
82+
## Troubleshooting
83+
84+
- **Workflow Failures**: Check the GitHub Actions logs for detailed error messages
85+
- **Version Mismatch**: Ensure the tag name (without the 'v' prefix) matches the version in `package.json`
86+
- **Publishing Issues**: Verify the `NPM_TOKEN` is valid and has publish permissions
87+
- **Module Format Issues**: Use the dual module compatibility test to verify both formats work correctly
88+
89+
## NPM Package Page
90+
91+
The package is published at: https://www.npmjs.com/package/@glideapps/ts-necessities

0 commit comments

Comments
 (0)