Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,25 @@ jobs:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1

- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
node-version: 20
cache: npm
bun-version: 1.3.14

- name: Install dependencies
run: npm ci
run: bun install --frozen-lockfile

- name: Run ESLint
run: npm run lint
run: bun run lint

- name: Run Prettier check
run: npm run format:check
run: bun run format:check

- name: Run unit tests
run: npm test
run: bun test

- name: Verify version sync
run: npm run release:check
run: bun run release:check

- name: Smoke test CLI help
run: node bin/pkgmap.js --help
run: bun bin/pkgmap.js --help
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# macOS
.DS_Store
.claude
.arsy

# pkgmap export output
pkgmap-export.json
Expand All @@ -9,6 +10,7 @@ pkgmap-export.json
logs
*.log
npm-debug.log*
bun-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: test lint fmt fmt-check verify

test: ; npm test
lint: ; npm run lint
fmt: ; npm run format
fmt-check: ; npm run format:check
verify: ; npm run format:check && npm run lint && npm test
test: ; bun test
lint: ; bun run lint
fmt: ; bun run format
fmt-check: ; bun run format:check
verify: ; bun run format:check && bun run lint && bun test
19 changes: 7 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,9 @@ Warnings: 1

## Prerequisites

- **Node.js >= 20** for the supported runtime baseline
- **npm** bundled with Node.js
- **Bun >= 1.1** for the supported runtime baseline

> If Node.js is not installed yet, get it from [nodejs.org](https://nodejs.org) or use a version manager like [nvm](https://github.com/nvm-sh/nvm).
> Install Bun from [bun.sh](https://bun.sh). Node.js is only required for the `node-versions` command and Node-specific package managers.

---

Expand All @@ -160,28 +159,24 @@ brew tap mulhamna/tap
brew install pkgmap
```

### Via npm / pnpm / yarn / volta / bun
### Via Bun

```bash
npm install -g @mulham28/pkgmap
pnpm add -g @mulham28/pkgmap
yarn global add @mulham28/pkgmap
volta install @mulham28/pkgmap
bun add -g @mulham28/pkgmap
bun add --global @mulham28/pkgmap
```

### Manual install

```bash
git clone https://github.com/mulhamna/pkgmap.git
cd pkgmap
npm install
npm link
bun install
bun link

pkgmap
```

> Tip for macOS/Linux: if `npm link` fails with a permission error, use `nvm` or fix your npm global prefix instead of relying on sudo.
> Tip for macOS/Linux: if `bun link` fails with a permission error, fix your Bun global bin configuration instead of relying on sudo.
>
> Tip for Windows: run PowerShell or CMD as Administrator before `npm link`.

Expand Down
2 changes: 1 addition & 1 deletion bin/pkgmap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env node
#!/usr/bin/env bun
import { program } from 'commander'
import { run } from '../src/index.js'
import { runAudit } from '../src/audit.js'
Expand Down
213 changes: 213 additions & 0 deletions bun.lock

Large diffs are not rendered by default.

30 changes: 11 additions & 19 deletions claude.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pkgmap/
"type": "module",
"description": "One command to see everything installed on your machine",
"engines": {
"node": ">=20.0.0"
"bun": ">=1.1.0"
},
"bin": {
"pkgmap": "bin/pkgmap.js"
Expand All @@ -68,8 +68,8 @@ pkgmap/
"lint": "eslint src/",
"format": "prettier --write src/",
"format:check": "prettier --check src/",
"release:check": "node scripts/sync-version-check.mjs",
"start": "node bin/pkgmap.js"
"release:check": "bun scripts/sync-version-check.mjs",
"start": "bun bin/pkgmap.js"
}
}
```
Expand Down Expand Up @@ -127,16 +127,8 @@ Setiap scanner harus handle kondisi berikut:

### 1. Package manager tidak terinstall
```js
// Cek dulu apakah binary tersedia sebelum eksekusi
import { execSync } from 'child_process'

function isAvailable(cmd) {
try {
execSync(`which ${cmd}`, { stdio: 'ignore' })
return true
} catch {
return false
}
return Boolean(Bun.which(cmd))
}
```
Kalau tidak tersedia → return `null`, orchestrator akan skip dan tampilkan warning ringan.
Expand All @@ -147,7 +139,7 @@ Kalau tidak tersedia → return `null`, orchestrator akan skip dan tampilkan war
- Beberapa scanner (brew, gem) mungkin tidak tersedia di Windows — skip gracefully

### 3. Permission error
- Wrap semua `execSync` / `exec` dalam try-catch
- Wrap semua `Bun.spawnSync` dalam try-catch
- Kalau error karena permission → tampilkan pesan: `⚠ <manager>: permission denied. Try running with sudo.`

### 4. Slow scanner (brew, cargo)
Expand Down Expand Up @@ -214,7 +206,7 @@ const results = await Promise.allSettled(scanners.map(s => s()))
## bin/pkgmap.js

```js
#!/usr/bin/env node
#!/usr/bin/env bun
import { program } from 'commander'
import { run } from '../src/index.js'
import { APP_VERSION } from '../src/version.js'
Expand All @@ -241,10 +233,10 @@ git clone https://github.com/<username>/pkgmap.git
cd pkgmap

# Install dependencies
npm install
bun install

# Link secara lokal biar bisa dipanggil sebagai CLI
npm link
bun link

# Jalankan
pkgmap
Expand All @@ -256,14 +248,14 @@ pkgmap

```bash
# Pastikan sudah login
npm login
bunx npm login

# Publish
npm publish --access public
bunx npm publish --access public
```

Setelah publish ke npm, otomatis bisa diinstall via:
- `npm install -g @mulham28/pkgmap`
- `bun add --global @mulham28/pkgmap`
- `pnpm add -g @mulham28/pkgmap`
- `yarn global add @mulham28/pkgmap`
- `volta install @mulham28/pkgmap`
Expand Down
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default [
ecmaVersion: 2022,
sourceType: 'module',
globals: {
Bun: 'readonly',
console: 'readonly',
process: 'readonly',
URL: 'readonly',
Expand Down
13 changes: 7 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ if [ "$(uname)" = "Darwin" ] && command -v brew >/dev/null 2>&1; then
exit 0
fi

# Fallback: npm ecosystem (npm, pnpm, yarn, bun)
if command -v npm >/dev/null 2>&1; then
# Bun is the supported runtime and installer.
if command -v bun >/dev/null 2>&1; then
bun add --global "$PACKAGE"
elif command -v npm >/dev/null 2>&1; then
echo "Warning: Bun is recommended; falling back to npm."
npm install -g "$PACKAGE"
elif command -v pnpm >/dev/null 2>&1; then
pnpm add -g "$PACKAGE"
elif command -v yarn >/dev/null 2>&1; then
yarn global add "$PACKAGE"
elif command -v bun >/dev/null 2>&1; then
bun add -g "$PACKAGE"
else
echo ""
echo "Error: no supported package manager found."
echo "Install Node.js from https://nodejs.org, then run:"
echo " npm install -g $PACKAGE"
echo "Install Bun from https://bun.sh, then run:"
echo " bun add --global $PACKAGE"
exit 1
fi

Expand Down
Loading