-
Notifications
You must be signed in to change notification settings - Fork 6
fix: correctly handle scope packages on win32 #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - master | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: | ||
| - ubuntu-latest | ||
| - macos-latest | ||
| - windows-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 10.20.0 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: pnpm | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Run tests | ||
| run: pnpm test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Repository Guidelines | ||
|
|
||
| ## Project Structure & Module Organization | ||
| - `src/` hosts all TypeScript sources (`index.ts`, `prebundle.ts`, helpers, shared `types.ts`); export public symbols through `src/index.ts`. | ||
| - `dist/` holds `rslib` output and must stay generated-only, while `compiled/` stores bundled dependencies produced by the CLI; never edit either manually. | ||
| - `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. | ||
| - `tests/` contains `@rstest/core` suites plus fixture configs under `tests/fixtures/` used to exercise the CLI. | ||
|
|
||
| ## Build, Test, and Development Commands | ||
| - `pnpm install` respects `pnpm-lock.yaml`; mixing package managers is forbidden to avoid dependency drift. | ||
| - `pnpm dev` runs `rslib build --watch` for tight feedback while hacking on `src/`. | ||
| - `pnpm build` generates production artifacts and doubles as a pre-publish smoke test; run it before every PR or release. | ||
| - `pnpm test` triggers `pnpm build && rstest`, which runs the CLI integration suite. | ||
| - `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. | ||
| - `pnpm bump` wraps `npx bumpp` for releases; only call after `dist/` and configs are committed. | ||
|
|
||
| ## Coding Style & Naming Conventions | ||
| - The repo is pure ESM (`type: module`), so keep relative imports with explicit `.js` extensions that mirror emitted files. | ||
| - Apply `Prettier` defaults (2-space indent, single quotes, trailing commas) before committing; configure your editor to format on save. | ||
| - Prefer `camelCase` for functions, `PascalCase` for types/interfaces, and SCREAMING_SNAKE_CASE for constants stored in `constant.ts`. | ||
| - Keep modules focused; common utilities belong in `helper.ts`, and shared configuration goes through `src/types.ts` for better type inference. | ||
|
|
||
| ## Testing Guidelines | ||
| - 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/`. | ||
| - Prefer end-to-end checks that run `bin.js --config <fixture>` so the CLI path stays covered across platforms. | ||
| - When adding manual validation steps (e.g., testing new dependencies), document the exact `pnpm prebundle ...` invocation and observed artifacts in the PR description. | ||
|
|
||
| ## Commit & Pull Request Guidelines | ||
| - Follow Conventional Commits mirroring existing history (`feat:`, `fix(deps):`, `chore:`); add scopes like `feat(cli):` when touching a specific module. | ||
| - Each PR should describe the motivation, list the commands you ran (`pnpm build`, `pnpm prebundle commander`, etc.), and reference related issues. | ||
| - Separate mechanical refactors from behavior changes to keep diffs reviewable, and ensure CI or manual checks are linked before requesting review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,28 @@ | ||
| #!/usr/bin/env node | ||
| import cac from 'cac'; | ||
| import { createRequire } from 'node:module'; | ||
| import { run } from './dist/index.js'; | ||
|
|
||
| run(); | ||
| const require = createRequire(import.meta.url); | ||
| const pkg = require('./package.json'); | ||
|
|
||
| const cli = cac('prebundle'); | ||
|
|
||
| cli | ||
| .command('[...packages]', 'Prebundle configured dependencies') | ||
| .option('--config <path>', 'Path to a custom config file') | ||
| .action(async (packages = [], options) => { | ||
| try { | ||
| await run({ | ||
| config: options.config, | ||
| packages, | ||
| }); | ||
| } catch (error) { | ||
| console.error(error); | ||
| process.exitCode = 1; | ||
| } | ||
| }); | ||
|
|
||
| cli.help(); | ||
| cli.version(pkg.version); | ||
| cli.parse(); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use
importhereUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that means we need to either use import attributes (node 20 required, not friendly to node 18 users), or a build process to replace the version from bin. 🤔 i think require is somehow acceptable here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get 👌