create-vextro 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Lasantha Lakmal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # ๐Ÿ”Œ Vextro โ€“ Vite-Powered Chrome Extension Starter
2
+
3
+ **Vextro** is a modern boilerplate for building Chrome extensions using:
4
+
5
+ - ๐Ÿ› ๏ธ [Vite](https://vitejs.dev/)
6
+ - โš›๏ธ [React + TypeScript](https://reactjs.org/)
7
+ - ๐Ÿ’… [Tailwind CSS](https://tailwindcss.com/)
8
+ - ๐Ÿงฉ [Manifest V3](https://developer.chrome.com/docs/extensions/mv3/intro/)
9
+ - ๐Ÿงช [CRXJS Plugin for Vite](https://crxjs.dev/)
10
+
11
+ ---
12
+
13
+ ## ๐Ÿš€ Quick Start
14
+
15
+ ```bash
16
+ npm create vextro@latest my-extension
17
+ cd my-extension
18
+ npm install
19
+ npm run dev
20
+ ````
21
+
22
+ Then load `dist/` as an **unpacked extension** in `chrome://extensions`.
23
+
24
+ ---
25
+
26
+ ## ๐Ÿ“ Folder Structure
27
+
28
+ ```
29
+ my-extension/
30
+ โ”œโ”€โ”€ public/ # Static files (if needed)
31
+ โ”œโ”€โ”€ src/
32
+ โ”‚ โ”œโ”€โ”€ background/ # Background script logic
33
+ โ”‚ โ”œโ”€โ”€ content/ # Content scripts
34
+ โ”‚ โ”œโ”€โ”€ options/ # Options UI
35
+ โ”‚ โ”œโ”€โ”€ popup/ # Popup UI (React + Tailwind)
36
+ โ”‚ โ”œโ”€โ”€ styles.css # Tailwind CSS entry
37
+ โ”‚ โ”œโ”€โ”€ manifest.ts # Manifest V3 (TS export)
38
+ โ”‚ โ””โ”€โ”€ utils/ # Shared logic/utilities
39
+ โ”œโ”€โ”€ vite.config.ts # Vite + CRX plugin config
40
+ โ””โ”€โ”€ tsconfig.json
41
+ ```
42
+
43
+ ---
44
+
45
+ ## ๐Ÿ“ฆ Features
46
+
47
+ * ๐ŸŒ **Vite dev server** with HMR for `popup` and `options`
48
+ * ๐Ÿง  **React + TypeScript** scaffolding
49
+ * ๐ŸŽจ **TailwindCSS** preconfigured
50
+ * โšก **CRXJS plugin** handles manifest, HMR, and multi-page output
51
+
52
+ ---
53
+
54
+ ## ๐Ÿ› ๏ธ Development Commands
55
+
56
+ | Command | Description |
57
+ | --------------- | ---------------------------------- |
58
+ | `npm run dev` | Launch Vite in watch mode |
59
+ | `npm run build` | Create production build in `dist/` |
60
+ | `npm run lint` | Run ESLint (if configured) |
61
+
62
+ ---
63
+
64
+ ## ๐Ÿ“– Usage Notes
65
+
66
+ * `popup/index.tsx` mounts to `#root` in `popup.html`
67
+ * CRX plugin watches `manifest.ts` and builds all declared entries
68
+ * You can add additional HTML entry points if needed via `vite.config.ts`
69
+
70
+ ---
71
+
72
+ ## ๐Ÿ“„ License
73
+
74
+ MIT ยฉ \[Lasantha]
package/bin/cli.js ADDED
@@ -0,0 +1,124 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execSync } from "child_process";
4
+ import fs from "fs-extra";
5
+ import path from "path";
6
+ import { fileURLToPath } from "url";
7
+ import inquirer from "inquirer";
8
+ import chalk from "chalk";
9
+
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = path.dirname(__filename);
12
+ const templateDir = path.resolve(__dirname, "../extension-structure");
13
+
14
+ const run = async () => {
15
+ console.log(chalk.cyanBright("\n๐Ÿš€ Create Extensify Chrome Extension"));
16
+
17
+ // Prompt for project name
18
+ const { projectName } = await inquirer.prompt([
19
+ {
20
+ name: "projectName",
21
+ message: "Enter your extension project name:",
22
+ default: "my-extension",
23
+ },
24
+ ]);
25
+
26
+ const projectDir = path.resolve(process.cwd(), projectName);
27
+
28
+ if (fs.existsSync(projectDir)) {
29
+ console.log(chalk.red(`โŒ Folder "${projectName}" already exists.`));
30
+ process.exit(1);
31
+ }
32
+
33
+ // 1. Scaffold base Vite + React + TS project
34
+ console.log(chalk.yellow("โš™๏ธ Creating base Vite + React + TS project..."));
35
+ execSync(`npm create vite@latest ${projectName} -- --template react-ts`, {
36
+ stdio: "inherit",
37
+ });
38
+
39
+ // 2. Install dependencies
40
+ process.chdir(projectDir);
41
+ console.log(chalk.yellow("๐Ÿ“ฆ Installing dependencies..."));
42
+ execSync("npm install", { stdio: "inherit" });
43
+
44
+ // 2.5 Remove default Vite template files
45
+ console.log(chalk.yellow("๐Ÿงน Removing default Vite template files..."));
46
+
47
+ const filesToRemove = [
48
+ "src/App.tsx",
49
+ "src/main.tsx",
50
+ "src/index.css",
51
+ "src/App.css",
52
+ "src/assets",
53
+ 'index.html'
54
+ ];
55
+
56
+ for (const file of filesToRemove) {
57
+ const fullPath = path.join(projectDir, file);
58
+ if (await fs.pathExists(fullPath)) {
59
+ await fs.remove(fullPath);
60
+ }
61
+ }
62
+
63
+ // 2.6 Clean up default public folder
64
+ console.log(chalk.yellow('๐Ÿงน Cleaning default public folder...'));
65
+
66
+ const publicPath = path.join(projectDir, 'public');
67
+ if (await fs.pathExists(publicPath)) {
68
+ await fs.emptyDir(publicPath);
69
+ }
70
+
71
+ // 3. Copy src and public folders
72
+ console.log(chalk.yellow("๐Ÿ“ Copying extension structure into project..."));
73
+
74
+ await fs.copy(path.join(templateDir, "src"), path.join(projectDir, "src"));
75
+ await fs.copy(
76
+ path.join(templateDir, "public"),
77
+ path.join(projectDir, "public")
78
+ );
79
+
80
+ // 4. Copy root files (vite.config.ts, tsconfig.json, package.json)
81
+ console.log(chalk.yellow("๐Ÿ“ Overriding config files..."));
82
+
83
+ const rootFiles = ["vite.config.ts"];
84
+ for (const file of rootFiles) {
85
+ const from = path.join(templateDir, file);
86
+ const to = path.join(projectDir, file);
87
+ if (await fs.pathExists(from)) {
88
+ await fs.copy(from, to, { overwrite: true });
89
+ }
90
+ }
91
+
92
+ // 5. Replace project name in manifest.ts and package.json
93
+ await injectProjectName(projectDir, projectName);
94
+
95
+ // 6. Install additional dev dependencies
96
+ console.log(chalk.yellow("๐Ÿ“ฆ Installing dev dependencies..."));
97
+ execSync(
98
+ "npm install --save-dev @types/chrome @types/node @crxjs/vite-plugin tailwindcss @tailwindcss/vite",
99
+ { stdio: "inherit" }
100
+ );
101
+
102
+ // โœ… Done
103
+ console.log(chalk.green("\nโœ… Vextro project created successfully!"));
104
+ console.log(chalk.cyan(`\n๐Ÿ‘‰ cd ${projectName} && npm run dev\n`));
105
+ };
106
+
107
+ const injectProjectName = async (targetDir, projectName) => {
108
+ const manifestPath = path.join(targetDir, "src", "manifest.ts");
109
+ const pkgPath = path.join(targetDir, "package.json");
110
+
111
+ if (await fs.pathExists(manifestPath)) {
112
+ let manifest = await fs.readFile(manifestPath, "utf-8");
113
+ manifest = manifest.replace(/__EXT_NAME__/g, projectName);
114
+ await fs.writeFile(manifestPath, manifest, "utf-8");
115
+ }
116
+
117
+ if (await fs.pathExists(pkgPath)) {
118
+ let pkg = await fs.readFile(pkgPath, "utf-8");
119
+ pkg = pkg.replace(/"__EXT_NAME__"/g, `"${projectName}"`);
120
+ await fs.writeFile(pkgPath, pkg, "utf-8");
121
+ }
122
+ };
123
+
124
+ run();
@@ -0,0 +1,2 @@
1
+ // background script
2
+ console.log('Background script loaded.');
@@ -0,0 +1,2 @@
1
+ // content script
2
+ console.log('Content script injected.');
@@ -0,0 +1,28 @@
1
+ import { defineManifest } from '@crxjs/vite-plugin';
2
+
3
+ export default defineManifest({
4
+ manifest_version: 3,
5
+ name: "__EXT_NAME__",
6
+ description: "A modern Chrome extension powered by Extensify.",
7
+ version: "1.0.0",
8
+ icons: {
9
+ "16": "icons/icon16.png",
10
+ "48": "icons/icon48.png",
11
+ "128": "icons/icon128.png"
12
+ },
13
+ permissions: ["storage", "tabs", "scripting"],
14
+ action: {
15
+ default_popup: "src/popup/popup.html"
16
+ },
17
+ background: {
18
+ service_worker: "src/background/background.ts",
19
+ type: "module"
20
+ },
21
+ content_scripts: [
22
+ {
23
+ matches: ["<all_urls>"],
24
+ js: ["src/content/content.ts"]
25
+ }
26
+ ],
27
+ options_page: "src/options/options.html"
28
+ });
@@ -0,0 +1,49 @@
1
+ // src/options/App.tsx
2
+ import { useState } from 'react';
3
+
4
+ export default function App() {
5
+ const [configName, setConfigName] = useState('');
6
+ const [configs, setConfigs] = useState<string[]>(['Default']);
7
+
8
+ const addConfig = () => {
9
+ if (configName.trim()) {
10
+ setConfigs([...configs, configName.trim()]);
11
+ setConfigName('');
12
+ }
13
+ };
14
+
15
+ return (
16
+ <div className="min-h-screen bg-gray-100 p-6 text-gray-900">
17
+ <h1 className="text-2xl font-bold mb-4">Vextro Extension Options</h1>
18
+
19
+ <div className="mb-6">
20
+ <label className="block mb-1 font-medium">New Config Name:</label>
21
+ <input
22
+ type="text"
23
+ value={configName}
24
+ onChange={(e) => setConfigName(e.target.value)}
25
+ className="w-full p-2 border border-gray-300 rounded"
26
+ placeholder="e.g., MyCustomConfig"
27
+ />
28
+ <button
29
+ onClick={addConfig}
30
+ className="mt-2 bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded"
31
+ >
32
+ Add Config
33
+ </button>
34
+ </div>
35
+
36
+ <div>
37
+ <h2 className="text-lg font-semibold mb-2">Available Configs:</h2>
38
+ <ul className="bg-white rounded shadow p-4 space-y-2">
39
+ {configs.map((cfg, idx) => (
40
+ <li key={idx} className="flex justify-between items-center">
41
+ <span>{cfg}</span>
42
+ <button className="text-sm text-red-600 hover:underline">Delete</button>
43
+ </li>
44
+ ))}
45
+ </ul>
46
+ </div>
47
+ </div>
48
+ );
49
+ }
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom/client';
3
+ import App from './App';
4
+
5
+ ReactDOM.createRoot(document.getElementById('root')!).render(
6
+ <React.StrictMode>
7
+ <App />
8
+ </React.StrictMode>
9
+ );
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link href="/src/styles.css" rel="stylesheet">
6
+ <title>Extensify Options</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="./index.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,72 @@
1
+ import { useState } from 'react';
2
+
3
+ export default function App() {
4
+ const [activeTab, setActiveTab] = useState<'load' | 'generate'>('load');
5
+
6
+ const openOptionsPage = () => {
7
+ chrome.runtime.openOptionsPage();
8
+ };
9
+
10
+ return (
11
+ <div className="w-[320px] min-h-[280px] p-4 bg-gray-900 text-white font-sans">
12
+ {/* Brand Header */}
13
+ <div className="flex items-center justify-between mb-4">
14
+ <div className="flex items-center gap-2">
15
+ <img src="/icon.png" alt="Vextro Logo" className="w-6 h-6" />
16
+ <h1 className="text-lg font-semibold">Vextro</h1>
17
+ </div>
18
+ <button
19
+ onClick={openOptionsPage}
20
+ className="text-sm text-blue-400 hover:underline"
21
+ >
22
+ Options
23
+ </button>
24
+ </div>
25
+
26
+ {/* Tab Buttons */}
27
+ <div className="flex justify-around mb-4">
28
+ <button
29
+ className={`px-4 py-1 rounded-md ${
30
+ activeTab === 'load' ? 'bg-blue-500' : 'bg-gray-700'
31
+ }`}
32
+ onClick={() => setActiveTab('load')}
33
+ >
34
+ Load Config
35
+ </button>
36
+ <button
37
+ className={`px-4 py-1 rounded-md ${
38
+ activeTab === 'generate' ? 'bg-blue-500' : 'bg-gray-700'
39
+ }`}
40
+ onClick={() => setActiveTab('generate')}
41
+ >
42
+ Generate
43
+ </button>
44
+ </div>
45
+
46
+ {/* Tab Content */}
47
+ <div className="bg-gray-800 p-3 rounded-md">
48
+ {activeTab === 'load' ? (
49
+ <div>
50
+ <label className="block text-sm mb-2">Select Config</label>
51
+ <select className="w-full p-2 bg-gray-700 rounded text-white">
52
+ <option>Default</option>
53
+ <option>Custom 1</option>
54
+ </select>
55
+ </div>
56
+ ) : (
57
+ <div>
58
+ <label className="block text-sm mb-2">Generate New Config</label>
59
+ <input
60
+ type="text"
61
+ placeholder="Enter key name"
62
+ className="w-full p-2 bg-gray-700 rounded text-white"
63
+ />
64
+ <button className="mt-3 w-full bg-green-600 hover:bg-green-700 py-2 rounded">
65
+ Generate
66
+ </button>
67
+ </div>
68
+ )}
69
+ </div>
70
+ </div>
71
+ );
72
+ }
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom/client';
3
+ import App from './App';
4
+
5
+ ReactDOM.createRoot(document.getElementById('root')!).render(
6
+ <React.StrictMode>
7
+ <App />
8
+ </React.StrictMode>
9
+ );
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link href="/src/styles.css" rel="stylesheet">
6
+ <title>Extensify Popup</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="./index.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1 @@
1
+ @import "tailwindcss";
@@ -0,0 +1,5 @@
1
+ // API client (optional demo)
2
+ export const fetchAPI = async (prompt: string): Promise<string> => {
3
+ // Placeholder logic
4
+ return `Echo: ${prompt}`;
5
+ };
@@ -0,0 +1,28 @@
1
+ import path from 'path';
2
+ import { defineConfig } from 'vite';
3
+ import react from '@vitejs/plugin-react';
4
+ import { crx } from '@crxjs/vite-plugin';
5
+ import manifest from './src/manifest';
6
+ import tailwindcss from '@tailwindcss/vite'
7
+
8
+ export default defineConfig({
9
+ plugins: [
10
+ react(),
11
+ crx({ manifest }),
12
+ tailwindcss()
13
+ ],
14
+ build: {
15
+ outDir: 'dist',
16
+ rollupOptions: {
17
+ input: {
18
+ popup: path.resolve(__dirname, 'src/popup/popup.html'),
19
+ options: path.resolve(__dirname, 'src/options/options.html')
20
+ },
21
+ output: {
22
+ assetFileNames: 'assets/[name].[ext]',
23
+ chunkFileNames: 'assets/[name].js',
24
+ entryFileNames: 'assets/[name].js'
25
+ }
26
+ }
27
+ }
28
+ });
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "create-vextro",
3
+ "version": "0.0.2",
4
+ "description": "Scaffold modern Chrome extensions with Vite + React + Tailwind",
5
+ "bin": {
6
+ "create-vextro": "bin/cli.js"
7
+ },
8
+ "type": "module",
9
+ "files": [
10
+ "bin",
11
+ "extension-structure/"
12
+ ],
13
+ "keywords": [
14
+ "vite",
15
+ "chrome-extension",
16
+ "vite-plugin",
17
+ "react",
18
+ "tailwind",
19
+ "crxjs",
20
+ "manifest-v3",
21
+ "scaffold"
22
+ ],
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/lasalasa/vextro"
26
+ },
27
+ "author": "Lasantha <lasanthaslakmal@gmail.com>",
28
+ "license": "MIT",
29
+ "bugs": {
30
+ "url": "https://github.com/lasalasa/vextro/issues"
31
+ },
32
+ "homepage": "https://github.com/lasalasa/vextro#readme",
33
+ "dependencies": {
34
+ "chalk": "^5.3.0",
35
+ "fs-extra": "^11.2.0",
36
+ "inquirer": "^9.2.8"
37
+ },
38
+ "engines": {
39
+ "node": ">=16"
40
+ }
41
+ }