Skip to content

Commit b6c4e5d

Browse files
committed
feat: Modernize library with TypeScript with CI/CD
Complete modernization of the prefer configuration library from CoffeeScript to TypeScript with modern tooling and automated CI/CD pipeline. - Added documentation - Converted all source files from CoffeeScript to TypeScript - Converted all test files to TypeScript - Maintained 100% test coverage throughout migration - Provides comprehensive type exports - Moved from CSON to JSON5 - Implemented async/await replacing Q promises - Maintains compatibility with all previous APIs
1 parent 9372d38 commit b6c4e5d

64 files changed

Lines changed: 7082 additions & 3797 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"extends": [
4+
"eslint:recommended",
5+
"plugin:@typescript-eslint/recommended"
6+
],
7+
"plugins": ["@typescript-eslint", "eslint-plugin-tsdoc"],
8+
"parserOptions": {
9+
"ecmaVersion": 2020,
10+
"sourceType": "module",
11+
"project": "./tsconfig.json"
12+
},
13+
"rules": {
14+
"@typescript-eslint/no-explicit-any": "error",
15+
"@typescript-eslint/explicit-function-return-type": "off",
16+
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
17+
"@typescript-eslint/no-var-requires": "off",
18+
"tsdoc/syntax": "warn"
19+
},
20+
"env": {
21+
"node": true,
22+
"es6": true,
23+
"mocha": true
24+
}
25+
}

.github/CONTRIBUTING.md

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# Contributing to Prefer
2+
3+
Thank you for your interest in contributing to Prefer! This document provides guidelines and instructions for contributing.
4+
5+
## Development Setup
6+
7+
### Prerequisites
8+
9+
- Node.js 14.0.0 or higher
10+
- npm 7.0.0 or higher
11+
12+
### Getting Started
13+
14+
1. Fork the repository
15+
2. Clone your fork:
16+
```bash
17+
git clone https://github.com/YOUR_USERNAME/prefer.git
18+
cd prefer
19+
```
20+
21+
3. Install dependencies:
22+
```bash
23+
npm install
24+
```
25+
26+
4. Create a branch for your changes:
27+
```bash
28+
git checkout -b feature/your-feature-name
29+
```
30+
31+
## Development Workflow
32+
33+
### Building
34+
35+
```bash
36+
npm run build
37+
```
38+
39+
### Running Tests
40+
41+
```bash
42+
# Run all tests
43+
npm test
44+
45+
# Run tests in watch mode
46+
npm run test:watch
47+
48+
# Run tests with coverage
49+
npm run test:coverage
50+
```
51+
52+
### Linting and Formatting
53+
54+
```bash
55+
# Run ESLint
56+
npm run lint
57+
58+
# Fix ESLint issues
59+
npm run lint:fix
60+
61+
# Check TypeScript types
62+
npm run typecheck
63+
64+
# Format code with Prettier
65+
npm run format
66+
67+
# Check formatting
68+
npm run format:check
69+
```
70+
71+
### Clean Build Artifacts
72+
73+
```bash
74+
npm run clean
75+
```
76+
77+
## Code Quality Standards
78+
79+
### TypeScript
80+
81+
- Use strict TypeScript mode
82+
- No `any` types (use `unknown` if necessary)
83+
- Provide proper type definitions for all public APIs
84+
- Use interfaces for object shapes
85+
86+
### Testing
87+
88+
- Maintain 100% test coverage
89+
- Write tests before implementing features (TDD)
90+
- Test both success and error cases
91+
- Use descriptive test names
92+
93+
### Code Style
94+
95+
- Follow the existing code style
96+
- Use Prettier for formatting
97+
- Follow ESLint rules
98+
- Write clear, self-documenting code
99+
- Add comments for complex logic
100+
101+
## Pull Request Process
102+
103+
1. **Update tests**: Ensure all tests pass and add new tests for your changes
104+
2. **Update documentation**: Update README.md and other docs as needed
105+
3. **Run quality checks**:
106+
```bash
107+
npm run lint
108+
npm run typecheck
109+
npm test
110+
```
111+
112+
4. **Commit your changes**:
113+
```bash
114+
git add .
115+
git commit -m "feat: add new feature"
116+
```
117+
118+
5. **Push to your fork**:
119+
```bash
120+
git push origin feature/your-feature-name
121+
```
122+
123+
6. **Create a Pull Request** on GitHub
124+
125+
### Commit Message Format
126+
127+
We follow conventional commits:
128+
129+
- `feat:` - New feature
130+
- `fix:` - Bug fix
131+
- `docs:` - Documentation changes
132+
- `test:` - Test changes
133+
- `refactor:` - Code refactoring
134+
- `chore:` - Build process or auxiliary tool changes
135+
136+
Example:
137+
```
138+
feat: add JSON5 support for configuration files
139+
140+
- Added JSON5Formatter class
141+
- Updated tests
142+
- Updated documentation
143+
```
144+
145+
## CI/CD Pipeline
146+
147+
All pull requests automatically run through our CI pipeline:
148+
149+
1. **Linting** - ESLint checks
150+
2. **Type Checking** - TypeScript compilation
151+
3. **Testing** - Full test suite on Node 14, 16, 18, 20
152+
4. **Build** - Verify build succeeds
153+
154+
## Release Process
155+
156+
Releases are automated through GitHub Actions:
157+
158+
1. Update version in `package.json`
159+
2. Update `CHANGELOG.md`
160+
3. Create a GitHub release with a tag (e.g., `v0.6.0`)
161+
4. GitHub Actions will automatically publish to NPM
162+
163+
## Questions?
164+
165+
Feel free to open an issue for any questions or concerns!

.github/workflows/ci.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master, develop]
6+
pull_request:
7+
branches: [main, master, develop]
8+
9+
jobs:
10+
lint:
11+
name: Lint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '20'
20+
cache: 'npm'
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Run ESLint
26+
run: npm run lint
27+
28+
- name: Run TypeScript type check
29+
run: npm run typecheck
30+
31+
test:
32+
name: Test (Node ${{ matrix.node-version }})
33+
runs-on: ubuntu-latest
34+
strategy:
35+
matrix:
36+
node-version: [16, 18, 20]
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Setup Node.js ${{ matrix.node-version }}
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: ${{ matrix.node-version }}
44+
cache: 'npm'
45+
46+
- name: Install dependencies
47+
run: npm ci
48+
49+
- name: Build
50+
run: npm run build
51+
52+
- name: Run tests
53+
run: npm test
54+
55+
build:
56+
name: Build
57+
runs-on: ubuntu-latest
58+
needs: [lint, test]
59+
steps:
60+
- uses: actions/checkout@v4
61+
62+
- name: Setup Node.js
63+
uses: actions/setup-node@v4
64+
with:
65+
node-version: '20'
66+
cache: 'npm'
67+
68+
- name: Install dependencies
69+
run: npm ci
70+
71+
- name: Build
72+
run: npm run build
73+
74+
- name: Upload build artifacts
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: dist
78+
path: dist/
79+
retention-days: 7

.github/workflows/codeql.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CodeQL Security Analysis
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
schedule:
9+
- cron: '0 0 * * 1' # Weekly on Monday
10+
11+
jobs:
12+
analyze:
13+
name: Analyze
14+
runs-on: ubuntu-latest
15+
permissions:
16+
actions: read
17+
contents: read
18+
security-events: write
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
language: ['javascript']
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Initialize CodeQL
30+
uses: github/codeql-action/init@v3
31+
with:
32+
languages: ${{ matrix.language }}
33+
34+
- name: Autobuild
35+
uses: github/codeql-action/autobuild@v3
36+
37+
- name: Perform CodeQL Analysis
38+
uses: github/codeql-action/analyze@v3

.github/workflows/docs.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
# Allow only one concurrent deployment
15+
concurrency:
16+
group: "pages"
17+
cancel-in-progress: false
18+
19+
jobs:
20+
build:
21+
name: Build Documentation
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: '20'
30+
cache: 'npm'
31+
32+
- name: Install dependencies
33+
run: npm ci
34+
35+
- name: Build library
36+
run: npm run build
37+
38+
- name: Generate documentation
39+
run: npm run docs
40+
41+
- name: Upload artifact
42+
uses: actions/upload-pages-artifact@v3
43+
with:
44+
path: ./docs
45+
46+
deploy:
47+
name: Deploy to GitHub Pages
48+
environment:
49+
name: github-pages
50+
url: ${{ steps.deployment.outputs.page_url }}
51+
runs-on: ubuntu-latest
52+
needs: build
53+
steps:
54+
- name: Deploy to GitHub Pages
55+
id: deployment
56+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)