create-vextro 0.0.3 → 0.1.0

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.
Files changed (36) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +94 -24
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.js +514 -0
  5. package/dist/index.js.map +1 -0
  6. package/package.json +71 -41
  7. package/src/templates/chrome/src/background/background.ts +30 -0
  8. package/src/templates/chrome/src/content/content.ts +13 -0
  9. package/src/templates/chrome/src/manifest.ts +28 -0
  10. package/{extension-structure → src/templates/chrome}/vite.config.ts +27 -28
  11. package/src/templates/firefox/src/background/background.ts +29 -0
  12. package/src/templates/firefox/src/content/content.ts +13 -0
  13. package/src/templates/firefox/src/manifest.json +35 -0
  14. package/src/templates/firefox/vite.config.ts +22 -0
  15. package/src/templates/shared/src/options/App.tsx +70 -0
  16. package/{extension-structure → src/templates/shared}/src/options/index.tsx +9 -9
  17. package/src/templates/shared/src/options/options.html +12 -0
  18. package/src/templates/shared/src/popup/App.tsx +61 -0
  19. package/{extension-structure → src/templates/shared}/src/popup/index.tsx +9 -9
  20. package/src/templates/shared/src/popup/popup.html +12 -0
  21. package/src/templates/shared/src/styles.css +1 -0
  22. package/src/templates/shared/src/utils/storage.ts +34 -0
  23. package/bin/cli.js +0 -124
  24. package/extension-structure/src/background/background.ts +0 -2
  25. package/extension-structure/src/content/content.ts +0 -2
  26. package/extension-structure/src/manifest.ts +0 -28
  27. package/extension-structure/src/options/App.tsx +0 -49
  28. package/extension-structure/src/options/options.html +0 -12
  29. package/extension-structure/src/popup/App.tsx +0 -72
  30. package/extension-structure/src/popup/popup.html +0 -12
  31. package/extension-structure/src/styles.css +0 -1
  32. package/extension-structure/src/utils/apiClient.ts +0 -5
  33. /package/{extension-structure → src/templates/shared}/public/icon.png +0 -0
  34. /package/{extension-structure → src/templates/shared}/public/icons/icon128.png +0 -0
  35. /package/{extension-structure → src/templates/shared}/public/icons/icon16.png +0 -0
  36. /package/{extension-structure → src/templates/shared}/public/icons/icon48.png +0 -0
package/bin/cli.js DELETED
@@ -1,124 +0,0 @@
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();
@@ -1,2 +0,0 @@
1
- // background script
2
- console.log('Background script loaded.');
@@ -1,2 +0,0 @@
1
- // content script
2
- console.log('Content script injected.');
@@ -1,28 +0,0 @@
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
- });
@@ -1,49 +0,0 @@
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
- }
@@ -1,12 +0,0 @@
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>
@@ -1,72 +0,0 @@
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
- }
@@ -1,12 +0,0 @@
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>
@@ -1 +0,0 @@
1
- @import "tailwindcss";
@@ -1,5 +0,0 @@
1
- // API client (optional demo)
2
- export const fetchAPI = async (prompt: string): Promise<string> => {
3
- // Placeholder logic
4
- return `Echo: ${prompt}`;
5
- };