-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add React 19 support, shared components, utilities, and CLI tooling #1
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
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,159 @@ | ||
| # nextjs-htk CLI | ||
|
|
||
| The `@hacktoolkit/nextjs-htk` package includes a CLI tool to help standardize project setup and maintain consistency across all nextjs-htk projects. | ||
|
|
||
| ## Installation | ||
|
|
||
| The CLI is automatically available when you install `@hacktoolkit/nextjs-htk`: | ||
|
|
||
| ```bash | ||
| npm install @hacktoolkit/nextjs-htk | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Initialize a new project | ||
|
|
||
| Copy all standard files (Makefile, scripts, etc.) to your project: | ||
|
|
||
| ```bash | ||
| npx @hacktoolkit/nextjs-htk init | ||
| ``` | ||
|
|
||
| Or if you have the package installed locally: | ||
|
|
||
| ```bash | ||
| npm exec htk init | ||
| ``` | ||
|
|
||
| ### Sync existing project | ||
|
|
||
| Update your project with the latest templates from nextjs-htk: | ||
|
|
||
| ```bash | ||
| npx @hacktoolkit/nextjs-htk sync | ||
| ``` | ||
|
|
||
| ### Sync specific files | ||
|
|
||
| Sync only the Makefile: | ||
|
|
||
| ```bash | ||
| npx @hacktoolkit/nextjs-htk sync:makefile | ||
| ``` | ||
|
|
||
| Sync only the scripts directory: | ||
|
|
||
| ```bash | ||
| npx @hacktoolkit/nextjs-htk sync:scripts | ||
| ``` | ||
|
|
||
| ### Force overwrite | ||
|
|
||
| By default, the CLI will not overwrite existing files. Use `--force` or `-f` to overwrite: | ||
|
|
||
| ```bash | ||
| npx @hacktoolkit/nextjs-htk init --force | ||
| npx @hacktoolkit/nextjs-htk sync:makefile -f | ||
| ``` | ||
|
|
||
| ### Help | ||
|
|
||
| Show all available commands: | ||
|
|
||
| ```bash | ||
| npx @hacktoolkit/nextjs-htk help | ||
| ``` | ||
|
|
||
| ## What files are synced? | ||
|
|
||
| ### Makefile | ||
| Standard Makefile with common targets: | ||
| - `make help` - Show all available targets | ||
| - `make install` - Install dependencies | ||
| - `make dev` - Start development server | ||
| - `make build` - Build for production | ||
| - `make deploy` - Build and deploy to GitHub Pages | ||
| - `make clean` - Clean build artifacts | ||
|
|
||
| ### Scripts | ||
| - `src/scripts/generate_sitemap.ts` - Generate sitemap.xml during build | ||
|
|
||
| ## Using shared utilities | ||
|
|
||
| The package also exports utilities you can use in your code: | ||
|
|
||
| ```typescript | ||
| import { generateSitemap } from '@hacktoolkit/nextjs-htk/utils' | ||
| import type { SitemapConfig } from '@hacktoolkit/nextjs-htk/utils' | ||
|
|
||
| const config: SitemapConfig = { | ||
|
jontsai marked this conversation as resolved.
|
||
| siteUrl: 'https://example.com', | ||
| pages: [ | ||
| { name: 'Home', path: '/' }, | ||
| { name: 'About', path: '/about/' } | ||
| ] | ||
| } | ||
|
|
||
| const sitemap = generateSitemap(config) | ||
| ``` | ||
|
|
||
| ## Adding to package.json scripts | ||
|
|
||
| You can add convenience scripts to your `package.json`: | ||
|
|
||
| ```json | ||
| { | ||
| "scripts": { | ||
| "htk:init": "htk init", | ||
| "htk:sync": "htk sync", | ||
| "htk:sync:makefile": "htk sync:makefile" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Then run with: | ||
|
|
||
| ```bash | ||
| npm run htk:init | ||
| npm run htk:sync | ||
| ``` | ||
|
|
||
| ## Integration with build process | ||
|
|
||
| The sitemap generation script integrates with your Next.js build: | ||
|
|
||
| 1. Make sure your `htk.config.ts` is properly configured | ||
| 2. Add the sitemap generation to your build script in `package.json`: | ||
|
|
||
| ```json | ||
| { | ||
| "scripts": { | ||
| "build": "next build && tsx src/scripts/generate_sitemap.ts" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| 3. The sitemap will be automatically generated in your build directory | ||
|
|
||
| ## Examples | ||
|
|
||
| ### First time setup | ||
|
|
||
| ```bash | ||
| cd my-nextjs-htk-project | ||
| npm install @hacktoolkit/nextjs-htk | ||
| npx @hacktoolkit/nextjs-htk init | ||
| ``` | ||
|
|
||
| ### Update to latest templates | ||
|
|
||
| ```bash | ||
| npx @hacktoolkit/nextjs-htk sync --force | ||
| ``` | ||
|
|
||
| ### Just update the Makefile | ||
|
|
||
| ```bash | ||
| npx @hacktoolkit/nextjs-htk sync:makefile --force | ||
| ``` | ||
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.
Uh oh!
There was an error while loading. Please reload this page.