Skip to content

Commit 4da3fd3

Browse files
authored
initial ci file (#7)
1 parent 4fbc810 commit 4da3fd3

File tree

6 files changed

+105
-74
lines changed

6 files changed

+105
-74
lines changed

.github/workflows/ci.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
test:
15+
name: Node ${{ matrix.node-version }}
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
node-version: [20, 22]
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Setup Node.js ${{ matrix.node-version }}
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: ${{ matrix.node-version }}
30+
cache: 'npm'
31+
32+
- name: Install dependencies
33+
run: npm ci
34+
35+
- name: Type check
36+
run: npm run typecheck
37+
38+
- name: Lint
39+
run: npm run lint
40+
41+
- name: Format check
42+
run: npm run format
43+
44+
- name: Run unit tests
45+
run: npm run test:cov
46+
47+
- name: Build
48+
run: npm run build:ci
49+
50+
- name: Run integration tests
51+
run: npm run test:integration:ci
52+
53+
- name: Upload coverage
54+
if: matrix.node-version == 22
55+
uses: codecov/codecov-action@v4
56+
with:
57+
files: ./coverage/coverage-final.json
58+
fail_ci_if_error: false

CHANGELOG.md

Lines changed: 19 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,80 +2,48 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
## [0.3.1] - 2025-12-09
5+
## [0.3.2] - 2025-12-10
66

77
### Changed
88

9-
- **Build Process Simplification**: Removed wrapper script complexity in favor of direct SWC compilation
10-
- **Postbuild Script**: Replaced `insert-shebang.sh` with lightweight `add-shebang.js` Node script
11-
- **CJS Package Generation**: Now generated inline in build script instead of via wrapper
12-
- **README**: Updated "How It Works" section to reflect simplified build architecture
13-
14-
### Technical Details
15-
16-
**Build Process (Simplified):**
9+
- **CI**: Main-only triggers, concurrency cancellation, Node 20/22 matrix, unit tests run with coverage
10+
- **Tests**: Unit and integration suites split into separate Vitest configs
11+
- **Build**: CI builds once (`build:ci`) before running integration tests; Codecov upload is best-effort
1712

18-
1. Prebuild: format:fix → lint → typecheck → clean
19-
2. Compile: SWC compiles source to both `build/esm/src/` and `build/cjs/src/`
20-
3. Path Resolution: `tsc-alias` transforms `@/` imports to relative paths
21-
4. Executables: `add-shebang.js` adds shebangs and sets executable permissions
22-
5. CJS Marker: `package.json` with `"type":"commonjs"` created in `build/cjs/`
13+
## [0.3.1] - 2025-12-09
2314

24-
**Entry Points:**
15+
### Changed
2516

26-
- ESM: `build/esm/src/cli.js` (executable)
27-
- CJS: `build/cjs/src/cli.js` (executable)
17+
- **Build**: Simplified to direct SWC outputs plus a lightweight `add-shebang.js` script
18+
- **Docs**: README "How It Works" refreshed for the new build shape
19+
- **CI**: Added GitHub Actions on Node 20/22
2820

2921
## [0.3.0] - 2025-12-09
3022

3123
### Added
3224

33-
- **Dual Build System**: Project compiles to both ESM (`build/esm/`) and CommonJS (`build/cjs/`) with proper module format markers
34-
- **Path Aliases**: TypeScript path aliases (`@/*`) work throughout codebase and resolve to relative paths in output
35-
- **Build Validation**: Code quality checks (format, lint, typecheck) run automatically in prebuild step
36-
- **Source Maps**: Both ESM and CJS builds include source maps for debugging
37-
- **ESM dirname Utility**: New `getDirname()` utility for ES module-compatible directory resolution
38-
- **Comprehensive Tests**: 27 total tests (9 unit + 18 integration) with 100% code coverage
39-
- **Integration Test Suite**: Dedicated `tests/integration/` with build output and module format validation
40-
- **JSDoc Comments**: All functions documented for IDE support and clarity
41-
- **Improved README**: Comprehensive documentation with features, usage, and architecture explanation
25+
- **Dual Outputs**: ESM and CJS builds with source maps and path alias resolution
26+
- **Tests**: 27 total (unit + integration) plus coverage; integration suite validates build outputs
27+
- **Docs**: README expanded; JSDoc coverage improved
4228

4329
### Changed
4430

45-
- **Tooling Migration**: Replaced ESLint + Prettier with Biome for unified linting/formatting
46-
- **Node Version**: Updated from 16+ to 20+ for stable ESM support without flags
47-
- **Build Scripts**: Restructured with separate SWC configurations for ESM and CJS
48-
- **CLI Implementation**: Enhanced with better error handling and version management
49-
- **Testing Framework**: Upgraded from Vite test to dedicated Vitest with coverage
50-
- **Project Structure**: Added utilities folder and proper test file organization
31+
- **Tooling**: ESLint/Prettier replaced by Biome; Vitest adopted with coverage
32+
- **Runtime**: Node requirement raised to 20+ for stable ESM; build scripts split per format
5133

5234
### Removed
5335

54-
- ESLint configuration and plugins
55-
- Prettier configuration
56-
- Old single build configuration (`.swcrc`)
57-
- Unreachable Node version check code
36+
- Legacy lint/format configs and the single `.swcrc`
37+
- Unreachable Node version guard
5838

5939
### Fixed
6040

61-
- Test file exclusion from production builds
62-
- Path alias transformation for both module formats
63-
- Vitest configuration to prevent test discovery in build directory
64-
- CJS module format declaration
41+
- Test files excluded from builds; aliases resolved correctly; build dir no longer scanned by tests
6542

6643
### Dependencies Updated
6744

68-
- TypeScript: 4.9.5 → 5.9.3
69-
- SWC: 1.3.35 → 1.15.3
70-
- Commander: 10.0.0 → 14.0.2
71-
- Vitest: 0.28.5 → 4.0.15
72-
- Biome: 2.3.8 (new)
73-
- tsc-alias: 1.8.16 (new)
74-
- @vitest/coverage-v8: 4.0.15 (new)
45+
- TypeScript, SWC, Commander, Vitest, Biome, tsc-alias, @vitest/coverage-v8
7546

7647
### Breaking Changes
7748

78-
- Requires Node.js 20+ (was 16+)
79-
- Dual ESM/CJS structure replaces single build output
80-
- Package exports field specifies import/require conditions
81-
- CLI now uses Biome instead of ESLint/Prettier
49+
- Requires Node 20+ and dual ESM/CJS outputs; exports now specify import/require conditions

package-lock.json

Lines changed: 4 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hello-cli",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"description": "A basic CLI written in TypeScript meant to be used as an example or project starter",
55
"type": "module",
66
"bin": "./build/esm/src/cli.js",
@@ -31,9 +31,10 @@
3131
},
3232
"scripts": {
3333
"prebuild": "npm run format:fix && npm run lint && npm run typecheck && rm -rf ./build",
34-
"build:esm": "swc src --config-file .swcrc-esm -d build/esm --ignore '**/*.test.ts' && tsc-alias -p tsconfig.json --outDir build/esm --resolve-full-paths",
35-
"build:cjs": "swc src --config-file .swcrc-cjs -d build/cjs --ignore '**/*.test.ts' && tsc-alias -p tsconfig.json --outDir build/cjs --resolve-full-paths && echo '{\"type\":\"commonjs\"}' > build/cjs/package.json",
34+
"build:esm": "swc src --config-file .swcrc-esm -d build/esm --ignore '**/*.test.ts' && tsc-alias -p tsconfig.json --outDir build/esm --resolve-full-paths || exit 1",
35+
"build:cjs": "swc src --config-file .swcrc-cjs -d build/cjs --ignore '**/*.test.ts' && tsc-alias -p tsconfig.json --outDir build/cjs --resolve-full-paths && echo '{\"type\":\"commonjs\"}' > build/cjs/package.json || exit 1",
3636
"build": "npm run build:esm && npm run build:cjs && node ./add-shebang.js",
37+
"build:ci": "rm -rf ./build && npm run build:esm && npm run build:cjs && node ./add-shebang.js",
3738
"build:debug": "swc --config-file .swcrc-esm -s true -D src -d build/esm",
3839
"typecheck": "tsc --noEmit",
3940
"prepublishOnly": "npm run typecheck && npm run lint && npm test && npm run build",
@@ -43,7 +44,8 @@
4344
"lint": "biome lint ./src",
4445
"lint:fix": "biome lint --write ./src",
4546
"test": "vitest run",
46-
"test:integration": "npm run build && vitest run tests/integration",
47+
"test:integration": "npm run build && vitest run --config vitest.config.integration.ts",
48+
"test:integration:ci": "vitest run --config vitest.config.integration.ts",
4749
"test:all": "npm test && npm run test:integration",
4850
"test:cov": "vitest run --coverage"
4951
},

vitest.config.integration.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { fileURLToPath } from "node:url";
2+
import { dirname, resolve } from "node:path";
3+
import { defineConfig } from "vitest/config";
4+
5+
const __dirname = dirname(fileURLToPath(import.meta.url));
6+
7+
export default defineConfig({
8+
test: {
9+
exclude: ["**/node_modules/**", "**/build/**"],
10+
include: ["tests/integration/**/*.{test,spec}.{js,ts}"],
11+
},
12+
resolve: {
13+
alias: {
14+
"@": resolve(__dirname, "./src"),
15+
},
16+
},
17+
});

vitest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
77
export default defineConfig({
88
test: {
99
exclude: ["**/node_modules/**", "**/build/**"],
10+
include: ["src/**/*.{test,spec}.{js,ts}"],
1011
coverage: {
1112
reporter: ["text", "json", "html"],
1213
},

0 commit comments

Comments
 (0)