Skip to content

Commit 3d3f345

Browse files
committed
fix: correctly handle scope packages on win32
1 parent 2dc9218 commit 3d3f345

File tree

10 files changed

+568
-23
lines changed

10 files changed

+568
-23
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
pull_request:
9+
10+
jobs:
11+
test:
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os:
17+
- ubuntu-latest
18+
- macos-latest
19+
- windows-latest
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Setup pnpm
26+
uses: pnpm/action-setup@v4
27+
with:
28+
version: 10.20.0
29+
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: 20
34+
cache: pnpm
35+
36+
- name: Install dependencies
37+
run: pnpm install --frozen-lockfile
38+
39+
- name: Run tests
40+
run: pnpm test

AGENTS.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
- `src/` hosts all TypeScript sources (`index.ts`, `prebundle.ts`, helpers, shared `types.ts`); export public symbols through `src/index.ts`.
5+
- `dist/` holds `rslib` output and must stay generated-only, while `compiled/` stores bundled dependencies produced by the CLI; never edit either manually.
6+
- `bin.js` is the CAC-based CLI entry; root configs (`prebundle.config.ts`, `rslib.config.ts`, `tsconfig.json`) govern build targets and should evolve together.
7+
- `tests/` contains `@rstest/core` suites plus fixture configs under `tests/fixtures/` used to exercise the CLI.
8+
9+
## Build, Test, and Development Commands
10+
- `pnpm install` respects `pnpm-lock.yaml`; mixing package managers is forbidden to avoid dependency drift.
11+
- `pnpm dev` runs `rslib build --watch` for tight feedback while hacking on `src/`.
12+
- `pnpm build` generates production artifacts and doubles as a pre-publish smoke test; run it before every PR or release.
13+
- `pnpm test` triggers `pnpm build && rstest`, which runs the CLI integration suite.
14+
- `pnpm prebundle [pkg1 pkg2 ...] --config path/to/config` executes the CLI for all configured dependencies or a filtered subset; use `--config` to point at custom fixtures.
15+
- `pnpm bump` wraps `npx bumpp` for releases; only call after `dist/` and configs are committed.
16+
17+
## Coding Style & Naming Conventions
18+
- The repo is pure ESM (`type: module`), so keep relative imports with explicit `.js` extensions that mirror emitted files.
19+
- Apply `Prettier` defaults (2-space indent, single quotes, trailing commas) before committing; configure your editor to format on save.
20+
- Prefer `camelCase` for functions, `PascalCase` for types/interfaces, and SCREAMING_SNAKE_CASE for constants stored in `constant.ts`.
21+
- Keep modules focused; common utilities belong in `helper.ts`, and shared configuration goes through `src/types.ts` for better type inference.
22+
23+
## Testing Guidelines
24+
- Automated coverage uses `@rstest/core` in `tests/prebundle.test.ts` to snapshot bundled output and execute the emitted modules; add new cases there or create additional suites under `tests/`.
25+
- Prefer end-to-end checks that run `bin.js --config <fixture>` so the CLI path stays covered across platforms.
26+
- When adding manual validation steps (e.g., testing new dependencies), document the exact `pnpm prebundle ...` invocation and observed artifacts in the PR description.
27+
28+
## Commit & Pull Request Guidelines
29+
- Follow Conventional Commits mirroring existing history (`feat:`, `fix(deps):`, `chore:`); add scopes like `feat(cli):` when touching a specific module.
30+
- Each PR should describe the motivation, list the commands you ran (`pnpm build`, `pnpm prebundle commander`, etc.), and reference related issues.
31+
- Separate mechanical refactors from behavior changes to keep diffs reviewable, and ensure CI or manual checks are linked before requesting review.

bin.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
#!/usr/bin/env node
2+
import cac from 'cac';
3+
import { createRequire } from 'node:module';
24
import { run } from './dist/index.js';
35

4-
run();
6+
const require = createRequire(import.meta.url);
7+
const pkg = require('./package.json');
8+
9+
const cli = cac('prebundle');
10+
11+
cli
12+
.command('[...packages]', 'Prebundle configured dependencies')
13+
.option('--config <path>', 'Path to a custom config file')
14+
.action(async (packages = [], options) => {
15+
try {
16+
await run({
17+
config: options.config,
18+
packages,
19+
});
20+
} catch (error) {
21+
console.error(error);
22+
process.exitCode = 1;
23+
}
24+
});
25+
26+
cli.help();
27+
cli.version(pkg.version);
28+
cli.parse();

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,24 @@
2020
"dev": "rslib build --watch",
2121
"prebundle": "node ./bin.js",
2222
"prepare": "npm run build",
23-
"bump": "npx bumpp"
23+
"bump": "npx bumpp",
24+
"test": "pnpm build && rstest"
2425
},
2526
"dependencies": {
27+
"cac": "^6.7.14",
2628
"@vercel/ncc": "0.38.4",
2729
"prettier": "^3.6.2",
2830
"rollup": "^4.52.5",
2931
"rollup-plugin-dts": "^6.2.3",
3032
"terser": "^5.44.0"
3133
},
3234
"devDependencies": {
35+
"@astrojs/sitemap": "^3.6.0",
3336
"@rslib/core": "0.17.0",
37+
"@rstest/core": "^0.6.5",
3438
"@types/fs-extra": "^11.0.4",
3539
"@types/node": "22.18.13",
40+
"chalk": "^5.6.2",
3641
"fast-glob": "^3.3.3",
3742
"fs-extra": "^11.3.2",
3843
"rslog": "^1.3.0",

0 commit comments

Comments
 (0)