-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8da0ce6
commit 4a21e81
Showing
4 changed files
with
173 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,32 @@ | ||
name: Publish to npm | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: "20" | ||
registry-url: "https://registry.npmjs.org" | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Lint and Test | ||
run: npm test | ||
|
||
- name: Publish to npm | ||
run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.SHEKHARDTU_NPM_TOKEN }} |
This file contains 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,21 @@ | ||
# MIT License | ||
|
||
Copyright (c) 2024 create-browser-extension-cli | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains 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,119 @@ | ||
# 🚀 create-browser-extension-cli | ||
|
||
A simple CLI tool to quickly scaffold boilerplate for Chrome and Firefox extensions, similar to `create-react-app`. Get a head start with an un-opinionated project structure and prebuilt templates for cross-browser support. | ||
|
||
## ✨ Features | ||
|
||
- ⚡ Generate boilerplate code for **Chrome** and **Firefox** extensions | ||
- 🔄 **Hot Module Replacement (HMR)** for Chrome extensions, ensuring smooth development | ||
- 🖥️ Single codebase for **multiple browsers** | ||
- 📦 Preconfigured **Webpack** setup for both development and production environments | ||
- 🛠️ Extendable and flexible project structure | ||
|
||
## 📥 Installation | ||
|
||
To install the CLI globally, run: | ||
|
||
```sh | ||
npm install -g create-browser-extension-cli | ||
``` | ||
|
||
## 🛠️ Usage | ||
|
||
To create a new browser extension project, run the following command: | ||
|
||
```sh | ||
create-browser-extension <project-name> | ||
``` | ||
|
||
You will be prompted to choose the browsers you wish to support (Chrome, Firefox, or both). | ||
|
||
### Example | ||
|
||
```sh | ||
create-browser-extension my-extension | ||
``` | ||
|
||
This will generate a project in the `my-extension` folder. | ||
|
||
## 🗂️ Project Structure | ||
|
||
Once generated, your project will have the following structure: | ||
|
||
```bash | ||
<project-name>/ | ||
├── config/ | ||
│ ├── manifest-chrome.json # Chrome-specific manifest file | ||
│ └── manifest-firefox.json # Firefox-specific manifest file | ||
├── src/ | ||
│ ├── background.js # Background script for the extension | ||
│ └── popup/ | ||
│ └── popup.js # Popup script | ||
├── webpack/ | ||
│ ├── webpack.common.js # Shared Webpack configuration | ||
│ ├── webpack.dev.js # Development-specific Webpack configuration | ||
│ └── webpack.prod.js # Production-specific Webpack configuration | ||
├── package.json | ||
└── README.md # Project documentation | ||
``` | ||
|
||
## 📜 Available Scripts | ||
|
||
The following scripts are preconfigured in the generated `package.json`: | ||
|
||
- **`dev:chrome`**: Starts the development server with HMR for Chrome 🔄 | ||
- **`build:chrome`**: Builds the extension for Chrome 🏗️ | ||
- **`build:firefox`**: Builds the extension for Firefox 🦊 | ||
|
||
### Running Scripts | ||
|
||
To run the available scripts, navigate to your project directory and use `npm run` followed by the script name. For example, to start the development server for Chrome: | ||
|
||
```bash | ||
cd my-extension | ||
npm run dev:chrome | ||
``` | ||
|
||
## 🛠️ Development | ||
|
||
During development, you can use the following command to start the development server with **Hot Module Replacement (HMR)** for Chrome: | ||
|
||
```bash | ||
npm run dev:chrome | ||
``` | ||
|
||
This uses the configuration from `webpack/webpack.dev.js` to enable rapid development by automatically reloading code changes without manually refreshing the extension. | ||
|
||
## 🏗️ Building | ||
|
||
To create production-ready builds, use the following commands: | ||
|
||
- Build for **Chrome**: | ||
|
||
```bash | ||
npm run build:chrome | ||
``` | ||
|
||
- Build for **Firefox**: | ||
|
||
```bash | ||
npm run build:firefox | ||
``` | ||
|
||
These commands will use the configuration from `webpack/webpack.prod.js` to create optimized builds for the respective browsers. | ||
|
||
## 🌐 Browser Compatibility | ||
|
||
The CLI supports both **Chrome** and **Firefox**, and the generated project structure allows you to share a common codebase for both browsers. You can still customize specific features by modifying the respective `manifest-chrome.json` and `manifest-firefox.json` files. | ||
|
||
## 🤝 Contributing | ||
|
||
Contributions are welcome! If you'd like to improve this CLI or fix any issues, feel free to submit a pull request or open an issue. Let's build together! 💪 | ||
|
||
## 📄 License | ||
|
||
This project is licensed under the **MIT License**. See the [LICENSE](./LICENSE) file for more details. | ||
|
||
--- | ||
|
||
Happy coding! 🚀🎉 |
This file contains 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