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
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
build:
name: Create artifacts
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./template
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,6 @@ jobs:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- uses: actions/setup-node@v3
with:
node-version: '21'
- name: install dependency
run: yarn
- name: Create chrome artifacts
run: yarn zip
- name: Create Firefox artifacts
run: yarn zip:firefox

- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v5
Expand All @@ -35,7 +20,6 @@ jobs:
with:
draft: true
body: ${{steps.github_release.outputs.changelog}}
files: ./package/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

24 changes: 1 addition & 23 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
/node_modules

# testing
/coverage

# production
/build
/package

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
.history
*.log

# secrets
secrets.*.js
node_modules
30 changes: 10 additions & 20 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
# OS
# OS
.DS_Store

# ignore node dependency directories & lock
# git
.git

# npm
node_modules
yarn.lock
pnpm-lock.yaml
package-lock.json
template/node_modules
template/build

# ignore log files and local
*.log
*.local
.env.local
.env.development.local
.env.test.local
.env.production.local
.history

# ignore compiled files
build
types
coverage

# ignore ide settings
.idea
.vscode
# others
.gitignore
.gitattributes
12 changes: 6 additions & 6 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)
MIT License

Copyright (c) 2025-present, **
Copyright (c) 2025 PaulCoding

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -9,13 +9,13 @@ 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 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.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
52 changes: 15 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,23 @@
# my-crx-app
# gen-ext

> a chrome/firefox extension tools built with Vite + React-js, and Manifest v3
[![npm version](https://img.shields.io/npm/v/gen-ext/latest.svg)](https://www.npmjs.com/package/gen-ext)
[![React](https://img.shields.io/badge/React-%2320232a.svg?logo=react&logoColor=%2361DAFB)](https://react.dev/)
[![JavaScript](https://img.shields.io/badge/JavaScript-F7DF1E?logo=javascript&logoColor=000)](https://developer.mozilla.org/en-US/docs/Web/JavaScript)
[![Vite](https://badges.aleen42.com/src/vitejs.svg)](https://vitejs.dev/)
[![Firefox](https://img.shields.io/badge/Firefox-FF7139?logo=Firefox&logoColor=white)](https://www.mozilla.org/firefox/)
[![Google Chrome](https://img.shields.io/badge/Google%20Chrome-4285F4?logo=GoogleChrome&logoColor=white)](https://www.google.com/chrome/)

## Installing
A **React-Javascript** instance of [create-chrome-ext](https://github.com/guocaoyi/create-chrome-ext), optimized for **Firefox** extension development.

1. Check if your `Node.js` version is >= **14**.
2. Change or configurate the name of your extension on `src/manifest`.
3. Run `yarn` to install the dependencies.
## Installation

## Developing
```sh
npm install -g gen-ext

run the command

```shell
$ cd my-crx-app

$ yarn dev
```

### Chrome Extension Developer Mode

1. set your Chrome browser 'Developer mode' up
2. click 'Load unpacked', and select `my-crx-app/build` folder

### Firefox Extension Developer Mode

1. Build your project firstly by running `yarn build:firefox`
2. Open Firefox and go to `about:debugging#/runtime/this-firefox`
3. Click on 'Load Temporary Add-on' and select `my-crx-app/build` folder


## Packing

After the development of your extension run the command

```shell
$ yarn zip # for chrome
or
$ yarn zip:firefox # for firefox
# Run the generator
gen-ext
```

---
## License

Generated by [create-chrome-ext](https://github.com/guocaoyi/create-chrome-ext)
[MIT](LICENSE)
74 changes: 74 additions & 0 deletions generate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env node

import fs from "fs-extra";
import ignore from "ignore";
import inquirer from "inquirer";
import { fileURLToPath } from "node:url";
import path from "path";

async function generateProject() {
const answers = await inquirer.prompt([
{ name: "name", message: "Project name:", default: "my-crx-app" },
{ name: "version", message: "Version:", default: "0.0.0" },
{ name: "description", message: "Description:", default: "" },
{ name: "author", message: "Author:", default: "" },
]);

const templateDir = path.resolve(
fileURLToPath(import.meta.url),
"..",
"template"
);

const outputDir = path.join(process.cwd(), answers.name);

// await fs.copy(templateDir, outputDir);
// console.log(`Copied template to ${outputDir}`);

// Load .gitignore rules
const gitignorePath = path.join(templateDir, ".gitignore");
let ig = ignore();
if (fs.existsSync(gitignorePath)) {
const gitignoreContent = fs.readFileSync(gitignorePath, "utf8");
ig = ignore().add(gitignoreContent);
}

// Copy template with .gitignore filtering
await fs.copy(templateDir, outputDir, {
filter: (src) => {
const relativePath = path.relative(templateDir, src);
return relativePath === "" || !ig.ignores(relativePath);
},
});

// Update package.json
const packageJsonPath = path.join(outputDir, "package.json");
let packageJson = await fs.readFile(packageJsonPath, "utf-8");

const pkg = JSON.parse(packageJson, "utf-8");
pkg.name = answers.name;
pkg.displayName = answers.name;
pkg.version = answers.version;
pkg.description = answers.description;
pkg.author = answers.author;

await fs.writeFile(packageJsonPath, JSON.stringify(pkg, null, 2));

// Update README.md
const readmePath = path.join(outputDir, "README.md");
let readmeContent = await fs.readFile(readmePath, "utf8");
readmeContent = readmeContent.replace(/my-crx-app/g, answers.name);
await fs.writeFile(readmePath, readmeContent);

console.log(`
Suggest you next step:
1. cd ${path.relative(process.cwd(), outputDir)}
2. Run yarn install
3. Open chrome://extensions/ in your browser
4. Check the box for Developer mode in the top right.
5. Click the Load unpacked extension button.
6. Select the build/ directory that was created.
`);
}

generateProject().catch(console.error);
Empty file added index.js
Empty file.
55 changes: 9 additions & 46 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,15 @@
{
"name": "my-crx-app",
"displayName": "my-crx-app",
"version": "0.0.0",
"author": "**",
"description": "",
"type": "module",
"name": "gen-ext",
"version": "1.0.0",
"main": "generate.js",
"license": "MIT",
"keywords": [
"chrome-extension",
"firefox-extension",
"react",
"vite",
"create-chrome-ext"
],
"engines": {
"node": ">=14.18.0"
},
"scripts": {
"dev": "vite",
"build": "vite build",
"build:firefox": "BROWSER=firefox vite build",
"preview": "vite preview",
"fmt": "prettier --write '**/*.{jsx,js,json,css,scss,md}'",
"zip": "yarn build && node src/zip.js",
"zip:firefox": "export BROWSER=firefox && yarn build && node src/zip.js"
"bin": {
"gen-ext": "./generate.js"
},
"type": "module",
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@crxjs/vite-plugin": "^2.0.0-beta.19",
"@eslint/js": "^9.20.0",
"@types/chrome": "^0.0.304",
"@types/react": "^18.2.28",
"@types/react-dom": "^18.2.13",
"@vitejs/plugin-react": "^4.1.0",
"autoprefixer": "^10.4.20",
"eslint": "^9.20.1",
"eslint-plugin-react": "^7.37.4",
"glob": "^10.3.10",
"globals": "^15.15.0",
"gulp": "^4.0.2",
"gulp-zip": "^6.0.0",
"postcss": "^8.5.2",
"prettier": "^3.0.3",
"tailwindcss": "3",
"vite": "^4.4.11",
"vite-plugin-svgr": "^4.3.0"
"fs-extra": "^11.3.0",
"ignore": "^7.0.3",
"inquirer": "^12.4.2"
}
}
File renamed without changes.
34 changes: 34 additions & 0 deletions template/.github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build

on:
pull_request:
branches:
- '*'
push:
branches:
- main

jobs:
build:
name: Create artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- uses: actions/setup-node@v3
with:
node-version: '21'
- name: install dependency
run: yarn
- name: Create chrome artifacts
run: yarn zip
- name: Create Firefox artifacts
run: yarn zip:firefox
- uses: actions/upload-artifact@v4
with:
name: extensions
path: |
package/*
Loading
Loading