Skip to content

📝 docs: clarify NATIVEWIND token export for bun install#2225

Merged
andrew-bierman merged 2 commits into
developmentfrom
docs/nativewind-token-setup
Apr 18, 2026
Merged

📝 docs: clarify NATIVEWIND token export for bun install#2225
andrew-bierman merged 2 commits into
developmentfrom
docs/nativewind-token-setup

Conversation

@andrew-bierman
Copy link
Copy Markdown
Collaborator

Summary

  • Bun reads bunfig.toml at startup, so the preinstall hook cannot inject PACKRAT_NATIVEWIND_UI_GITHUB_TOKEN into the parent install process. The prior docs + configure-deps.ts implied the opposite, leading to silent 401s on @packrat-ai/nativewindui.
  • CLAUDE.md — rewrote Private Package Auth with the three working export patterns (inline, one-liner, persistent in shell rc) plus troubleshooting for verifying the var is set.
  • .github/scripts/configure-deps.ts — no longer pretends to set the var on the parent process; detects a missing token and prints the exact fix command. CI path and missing-gh path preserved.

The fix for users

export PACKRAT_NATIVEWIND_UI_GITHUB_TOKEN=$(gh auth token)
bun install

Test plan

  • bun run configure:deps with var set → prints success
  • bun run configure:deps without var → prints actionable error with exact commands
  • bun install --dry-run with export succeeds; without it fails 401 (confirms root cause)
  • Biome lint passes on the changed script

Bun reads bunfig.toml at startup, so env vars set inside the preinstall
hook never reach the parent install process. The previous docs and
configure-deps script implied the hook handled auth automatically, which
caused silent 401s on `@packrat-ai/nativewindui`.

- CLAUDE.md: rewrite Private Package Auth with accurate export patterns
  and troubleshooting for the "token set?" check.
- configure-deps.ts: stop pretending to inject the var into the parent
  process; detect a missing token and print the exact fix command.
Copilot AI review requested due to automatic review settings April 18, 2026 16:34
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 18, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dcc4e8c6-3197-4f09-83f9-7f640015628e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/nativewind-token-setup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added documentation Improvements or additions to documentation ci/cd labels Apr 18, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates internal docs and the preinstall dependency-check script to reflect Bun’s bunfig.toml env var resolution behavior (token must be exported before bun install starts), preventing silent 401s when installing @packrat-ai/nativewindui.

Changes:

  • Rewrite Private Package Auth docs with working token export patterns and troubleshooting.
  • Update .github/scripts/configure-deps.ts to stop attempting to set env vars during preinstall and instead fail fast with actionable instructions.
  • Preserve CI behavior by requiring PACKRAT_NATIVEWIND_UI_GITHUB_TOKEN to be present.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
CLAUDE.md Clarifies required token export timing/patterns for Bun + GitHub Packages and adds troubleshooting.
.github/scripts/configure-deps.ts Converts preinstall script to an early missing-token detector with fix instructions rather than env injection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +58 to +61
console.error('1. Install GitHub CLI: https://cli.github.com');
console.error('2. Authenticate: gh auth login');
console.error('3. Add packages scope: gh auth refresh -h github.com -s read:packages');
console.error(`4. Then export ${TOKEN_VAR}=$(gh auth token) and re-run bun install.`);
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

The local error path when gh is missing/not authenticated only suggests installing/authing gh, but doesn’t mention the supported fallback of setting PACKRAT_NATIVEWIND_UI_GITHUB_TOKEN directly (e.g., a PAT with read:packages). This is a regression from the previous behavior and also contradicts the PR description (“missing-gh path preserved”). Consider updating the message to include the manual env-var option so non-gh environments aren’t blocked.

Suggested change
console.error('1. Install GitHub CLI: https://cli.github.com');
console.error('2. Authenticate: gh auth login');
console.error('3. Add packages scope: gh auth refresh -h github.com -s read:packages');
console.error(`4. Then export ${TOKEN_VAR}=$(gh auth token) and re-run bun install.`);
console.error('You can fix this in either of these ways:\n');
console.error('1. Use GitHub CLI');
console.error(' - Install GitHub CLI: https://cli.github.com');
console.error(' - Authenticate: gh auth login');
console.error(' - Add packages scope: gh auth refresh -h github.com -s read:packages');
console.error(` - Then export ${TOKEN_VAR}=$(gh auth token) and re-run bun install.\n`);
console.error('2. Set the token manually');
console.error(` - Export ${TOKEN_VAR} directly in your shell before running bun install`);
console.error(' - For example, use a GitHub PAT with the read:packages scope');

Copilot uses AI. Check for mistakes.
Comment thread CLAUDE.md Outdated
### Troubleshooting

- **401 on `@packrat-ai/nativewindui`**: `PACKRAT_NATIVEWIND_UI_GITHUB_TOKEN` isn't exported in the parent shell, or the token lacks `read:packages`. Confirm with `echo ${PACKRAT_NATIVEWIND_UI_GITHUB_TOKEN:+set}` — it must print `set`.
- The `preinstall` hook (`bun run configure:deps`) only *validates* auth. It cannot inject env vars into the parent `bun install` process.
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

The troubleshooting note says the preinstall hook “only validates auth”, but the updated configure-deps.ts no longer validates that the token works—it only checks that the env var is present (and checks gh auth status only when the var is missing). Consider rewording this bullet to match the current behavior, or add an explicit validation step if that’s still desired.

Suggested change
- The `preinstall` hook (`bun run configure:deps`) only *validates* auth. It cannot inject env vars into the parent `bun install` process.
- The `preinstall` hook (`bun run configure:deps`) only checks for auth configuration (for example, that `PACKRAT_NATIVEWIND_UI_GITHUB_TOKEN` is set, or `gh` auth is available when the env var is missing). It cannot inject env vars into the parent `bun install` process.

Copilot uses AI. Check for mistakes.
const ghStatus = await $`gh auth status`.quiet().nothrow();
async function configureDeps() {
if (process.env[TOKEN_VAR]) {
console.log(`✓ ${TOKEN_VAR} is set — bun install will authenticate to GitHub Packages`);
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

The success message asserts that bun install will authenticate, but this script doesn’t actually validate the token against GitHub Packages—only that the env var is non-empty. Consider softening the wording (e.g., “token is set”) or adding a lightweight validation if you want the message to be strictly accurate.

Suggested change
console.log(`✓ ${TOKEN_VAR} is set — bun install will authenticate to GitHub Packages`);
console.log(`✓ ${TOKEN_VAR} is set — bun install can use it to authenticate to GitHub Packages`);

Copilot uses AI. Check for mistakes.
Bun auto-loads .env.local before `bun install`, so the token can live
alongside other secrets. Demoted the shell-export approach to an
alternative path.
@andrew-bierman andrew-bierman merged commit 3105e69 into development Apr 18, 2026
7 checks passed
@andrew-bierman andrew-bierman deleted the docs/nativewind-token-setup branch April 18, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/cd documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants