Skip to content

Conversation

@truehazker
Copy link
Owner

@truehazker truehazker commented Jan 4, 2026

Summary by CodeRabbit

  • Chores
    • Package now ships template assets and includes automation to create and restore them during publish/install.
    • Installation will automatically restore templates into the project.
    • Added ignore rule so generated template archive is not committed.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 4, 2026

📝 Walkthrough

Walkthrough

Adds a zip/unzip packaging workflow: a prepare script zips templates into templates.zip before publishing, templates.zip is included in the package (while templates/ remains gitignored), and a postinstall script extracts templates.zip back to templates/ after installation.

Changes

Cohort / File(s) Summary
Repo ignore
./.gitignore
Added templates.zip to ignore list with a comment indicating it is a generated archive.
Package manifest
./package.json
Updated files to include templates.zip and scripts/postinstall.ts; added prepare and postinstall scripts; added dependency adm-zip and devDependency @types/adm-zip.
Prepare script
scripts/prepare.ts
New script that zips the templates directory into templates.zip, removing any existing archive, validating inputs/outputs, and exiting non-zero on failure.
Postinstall script
scripts/postinstall.ts
New script that runs after install to extract templates.zip into templates/, checks for existing templates/, verifies archive presence and extraction, and exits with descriptive errors on failure.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Dev as Developer
    participant Publish as npm publish
    participant Prepare as prepare.ts
    participant FS as File System
    participant Registry as npm Registry
    participant Install as npm install
    participant Postinstall as postinstall.ts
    note over Prepare,FS `#DDEBF7`: Archive creation phase
    Dev->>Publish: npm publish
    Publish->>Prepare: run prepare script
    Prepare->>FS: check `templates/` exists
    FS-->>Prepare: found
    Prepare->>FS: remove old `templates.zip` (if any)
    Prepare->>FS: create `templates.zip` (AdmZip)
    FS-->>Prepare: `templates.zip` created
    Publish->>Registry: upload package (includes `templates.zip`)
    note over Postinstall,FS `#E8F5E9`: Restore-on-install phase
    Install->>Registry: fetch package
    Registry-->>Install: package (contains `templates.zip`)
    Install->>Postinstall: run postinstall script
    Postinstall->>FS: check `templates/` (skip if exists)
    Postinstall->>FS: validate `templates.zip` present
    FS-->>Postinstall: `templates.zip` found
    Postinstall->>FS: extract `templates.zip` → `templates/`
    FS-->>Postinstall: extraction verified
    Postinstall-->>Install: success
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 I zipped the meadow, tucked seeds tight,
Shipped the bundle off in the night.
On install I hop, unzip with glee,
Templates restored — hooray for me!
Packaging snug, the workflow’s right.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title is related to the changeset as it addresses distribution packaging, but it uses emoji and is somewhat misleading—the actual changes involve zipping templates to preserve .gitignore rules, not directly fixing .gitignore inclusion. Revise the title to accurately describe the main change, such as 'zip templates directory to preserve .gitignore rules in package' or 'preserve .gitignore files in distributed templates'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
scripts/postinstall.ts (1)

14-17: Consider adding a log message for clarity.

The early exit when templates already exist is correct behavior for source repos or re-installations. However, a brief log message could help developers understand why the script exits early.

🔎 Suggested enhancement
 // Skip if templates folder already exists (source repo or already extracted)
 if (existsSync(templatesPath)) {
+  console.log('✓ Templates folder already exists, skipping extraction');
   process.exit(0);
 }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bb8d359 and 61f4904.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • .gitignore
  • package.json
  • scripts/postinstall.ts
  • scripts/prepare.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,jsx}: Use bun <file> instead of node <file> or ts-node <file>
Bun automatically loads .env files, so don't use the dotenv package
Use Bun.serve() with built-in WebSocket, HTTPS, and route support instead of express
Use bun:sqlite for SQLite instead of better-sqlite3
Use Bun.redis for Redis instead of ioredis
Use Bun.sql for Postgres instead of pg or postgres.js
Use built-in WebSocket instead of ws package
Prefer Bun.file over node:fs readFile/writeFile for file operations
Use Bun.$ template literals for shell commands instead of execa

Files:

  • scripts/postinstall.ts
  • scripts/prepare.ts
**/*.{ts,tsx,css,html}

📄 CodeRabbit inference engine (CLAUDE.md)

Use bun build <file.html|file.ts|file.css> instead of webpack or esbuild

Files:

  • scripts/postinstall.ts
  • scripts/prepare.ts
**/*.{html,ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Use HTML imports with Bun.serve() and don't use vite for frontend bundling

Files:

  • scripts/postinstall.ts
  • scripts/prepare.ts
**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Use bun --hot <file.ts> to run TypeScript files with hot module reloading enabled

Files:

  • scripts/postinstall.ts
  • scripts/prepare.ts
package.json

📄 CodeRabbit inference engine (CLAUDE.md)

package.json: Use bun install instead of npm install, yarn install, or pnpm install
Use bun run <script> instead of npm run <script>, yarn run <script>, or pnpm run <script>

Files:

  • package.json
🧠 Learnings (1)
📚 Learning: 2026-01-03T07:00:32.832Z
Learnt from: truehazker
Repo: truehazker/create-elysiajs PR: 2
File: templates/backend:1-1
Timestamp: 2026-01-03T07:00:32.832Z
Learning: In git diffs, symlinks (mode 120000) appear as added files containing the link target (e.g., +monorepo/apps/backend). Do not flag symlinks as placeholder files or accidental commits. This applies broadly; when reviewing files like templates/backend, verify whether it is a symlink and treat accordingly.

Applied to files:

  • package.json
🔇 Additional comments (6)
.gitignore (1)

9-10: LGTM! Correctly ignores the generated archive.

The comment clearly documents why templates.zip is ignored, and the placement in the output section is appropriate.

scripts/prepare.ts (1)

1-39: LGTM! Clean implementation with proper error handling.

The prepare script correctly:

  • Validates prerequisites (templates folder exists)
  • Cleans up existing archives before creating new ones
  • Verifies the archive was created successfully
  • Provides clear error messages

The workflow of adding folder contents to the zip root (line 28) correctly pairs with the postinstall extraction logic.

scripts/postinstall.ts (1)

25-36: LGTM! Robust extraction logic with good error handling.

The extraction logic properly verifies success and provides helpful error messages including the GitHub issues link for troubleshooting.

package.json (3)

41-41: LGTM! Files array correctly configured for the zip workflow.

The files array properly includes:

  • templates.zip: the packaged templates for distribution
  • scripts/postinstall.ts: needed to extract templates after installation
  • Excludes scripts/prepare.ts: correct, as it's only needed during development

45-46: LGTM! Scripts correctly implement the prepare/postinstall workflow.

The scripts follow Bun best practices by using bun run and will execute at the appropriate lifecycle stages:

  • prepare: runs before publishing to create the archive
  • postinstall: runs after installation to restore templates

57-57: adm-zip version 0.5.16 is the latest available release with no known security vulnerabilities.

Version 0.5.16 is the current latest version (published August 30, 2024). The only historical CVE (CVE-2018-1002204) affected versions prior to 0.4.9 and has been resolved. No further action required.

Likely an incorrect or invalid review comment.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
scripts/prepare.ts (1)

2-4: Consider using Bun-native file APIs instead of node:fs.

Per coding guidelines, prefer Bun.file over node:fs for file operations. While the guideline specifically mentions readFile/writeFile, Bun provides native alternatives for the operations used here:

  • existsSync(path)await Bun.file(path).exists()
  • unlinkSync(path)await Bun.$\rm ${path}`` or filesystem APIs

However, since the current approach works and is well-supported in Bun, this is a minor optimization for consistency with Bun conventions.

🔎 Potential refactor using Bun-native APIs
-import { existsSync, unlinkSync } from 'node:fs';
 import { join } from 'node:path';
 import AdmZip from 'adm-zip';

Then update the usage:

 // Templates folder must exist
-if (!existsSync(templatesPath)) {
+if (!(await Bun.file(templatesPath).exists())) {
   console.error('ERROR: templates folder not found. Cannot create archive.');
   process.exit(1);
 }
 
 try {
   // Remove existing zip if it exists
-  if (existsSync(zipPath)) {
-    unlinkSync(zipPath);
+  if (await Bun.file(zipPath).exists()) {
+    await Bun.$`rm ${zipPath}`;
   }

Note: This would require making the script async or wrapping in an async IIFE.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 61f4904 and 83bf92a.

📒 Files selected for processing (3)
  • package.json
  • scripts/postinstall.ts
  • scripts/prepare.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • scripts/postinstall.ts
  • package.json
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,jsx}: Use bun <file> instead of node <file> or ts-node <file>
Bun automatically loads .env files, so don't use the dotenv package
Use Bun.serve() with built-in WebSocket, HTTPS, and route support instead of express
Use bun:sqlite for SQLite instead of better-sqlite3
Use Bun.redis for Redis instead of ioredis
Use Bun.sql for Postgres instead of pg or postgres.js
Use built-in WebSocket instead of ws package
Prefer Bun.file over node:fs readFile/writeFile for file operations
Use Bun.$ template literals for shell commands instead of execa

Files:

  • scripts/prepare.ts
**/*.{ts,tsx,css,html}

📄 CodeRabbit inference engine (CLAUDE.md)

Use bun build <file.html|file.ts|file.css> instead of webpack or esbuild

Files:

  • scripts/prepare.ts
**/*.{html,ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Use HTML imports with Bun.serve() and don't use vite for frontend bundling

Files:

  • scripts/prepare.ts
**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Use bun --hot <file.ts> to run TypeScript files with hot module reloading enabled

Files:

  • scripts/prepare.ts
🔇 Additional comments (2)
scripts/prepare.ts (2)

26-29: Zip creation preserves directory structure correctly.

The use of addLocalFolder() ensures the templates directory contents are properly archived. This approach correctly preserves .gitignore files, which is the stated goal of this PR.


20-42: No action required. The code is already using adm-zip@0.5.16, which is the latest version available (released 2024-08-30).

@truehazker truehazker merged commit c2d4b2a into develop Jan 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant