Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no-install commitlint --edit "$1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dosu explain to me whether this will run offline as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot explain to me whether this will run offline as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the hook will run offline! The implementation uses npx --no-install commitlint which ensures it only uses locally installed dependencies and won't attempt to download packages from the internet.

How it works offline:

  • When developers run pnpm install, commitlint and its dependencies are installed locally
  • The hook uses npx --no-install which restricts npx to only use already-installed packages
  • If commitlint isn't installed locally, the hook will fail with a clear error rather than trying to download it

Requirements for offline use:

  • Dependencies must be installed first with pnpm install
  • Both @commitlint/cli and @commitlint/config-conventional need to be available locally

This approach ensures the hook works reliably in offline environments, CI systems, or any scenario where internet access might be restricted. The commit accedb8 addresses this specifically.

36 changes: 36 additions & 0 deletions __tests__/commitlint.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import fs from 'fs';
import path from 'path';
import { describe, expect, it } from 'vitest';

describe('commitlint configuration', () => {
it('commitlint config file exists', () => {
const configPath = path.join(process.cwd(), 'commitlint.config.js');
expect(fs.existsSync(configPath)).toBe(true);
});

it('commit-msg hook exists and is executable', () => {
const hookPath = path.join(process.cwd(), '.husky', 'commit-msg');
expect(fs.existsSync(hookPath)).toBe(true);

const stats = fs.statSync(hookPath);
// Check if file is executable (using bitwise AND with octal permission)
expect(stats.mode & parseInt('111', 8)).toBeGreaterThan(0);
});

it('commitlint is in package.json dependencies', () => {
const packagePath = path.join(process.cwd(), 'package.json');
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));

expect(packageJson.devDependencies['@commitlint/cli']).toBeDefined();
expect(
packageJson.devDependencies['@commitlint/config-conventional'],
).toBeDefined();
});

it('commitlint script is in package.json', () => {
const packagePath = path.join(process.cwd(), 'package.json');
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'));

expect(packageJson.scripts.commitlint).toBe('commitlint --edit');
});
});
26 changes: 26 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export default {
extends: ['@commitlint/config-conventional'],
rules: {
// Allow longer commit messages for detailed explanations
'body-max-line-length': [2, 'always', 100],
'header-max-length': [2, 'always', 100],
// Allow these conventional commit types
'type-enum': [
2,
'always',
[
'build', // Changes that affect the build system or external dependencies
'chore', // Maintenance tasks, tooling, housekeeping
'ci', // Changes to CI configuration files and scripts
'docs', // Documentation only changes
'feat', // A new feature
'fix', // A bug fix
'perf', // A code change that improves performance
'refactor', // A code change that neither fixes a bug nor adds a feature
'revert', // Reverts a previous commit
'style', // Changes that do not affect the meaning of the code
'test', // Adding missing tests or correcting existing tests
],
],
},
};
39 changes: 38 additions & 1 deletion docs/openapi-ts/community/contributing/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,46 @@ Your [pull request](https://help.github.com/articles/using-pull-requests) must:

- address a single issue or add a single item of functionality
- contain a clean history of small, incremental, logically separate commits, with no merge commits
- use clear commit messages
- use [Conventional Commits](https://www.conventionalcommits.org/) format for commit messages
- be possible to merge automatically

## Commit Message Format

This project uses [Conventional Commits](https://www.conventionalcommits.org/) to standardize commit messages. The format is:

```
<type>[optional scope]: <description>

[optional body]

[optional footer(s)]
```

### Commit Types

- **feat**: A new feature
- **fix**: A bug fix
- **docs**: Documentation only changes
- **style**: Changes that do not affect the meaning of the code (white-space, formatting, etc)
- **refactor**: A code change that neither fixes a bug nor adds a feature
- **perf**: A code change that improves performance
- **test**: Adding missing tests or correcting existing tests
- **build**: Changes that affect the build system or external dependencies
- **ci**: Changes to CI configuration files and scripts
- **chore**: Maintenance tasks, tooling, housekeeping
- **revert**: Reverts a previous commit

### Examples

```
feat: add support for OpenAPI 3.1 specification
fix: resolve issue with nullable schema generation
docs: update contributing guidelines with conventional commits
refactor: extract schema validation into separate module
```

Commit messages are automatically validated using commitlint when you make a commit.

## Start `@hey-api/openapi-ts`

Run `pnpm --filter @hey-api/openapi-ts dev`.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"scripts": {
"build": "turbo run build --filter=\"!@example/openapi-ts-sample\"",
"changeset": "changeset",
"commitlint": "commitlint --edit",
"example": "sh ./scripts/example.sh",
"format": "prettier --write .",
"lint:fix": "prettier --check --write . && eslint . --fix",
Expand All @@ -44,6 +45,8 @@
"@changesets/get-github-info": "0.6.0",
"@changesets/parse": "0.4.1",
"@changesets/types": "6.1.0",
"@commitlint/cli": "19.6.0",
"@commitlint/config-conventional": "19.6.0",
"@config/vite-base": "workspace:*",
"@eslint/js": "9.32.0",
"@hey-api/custom-client": "workspace:*",
Expand Down
Loading