diff --git a/esbuild.config.mjs b/esbuild.config.mjs index fdf7d0f..544b5ee 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -1,57 +1,20 @@ -import * as esbuild from "esbuild"; -import { exec } from "child_process"; +import esbuild from "esbuild"; +import { execSync } from "child_process"; -const isServe = process.argv.includes("--serve"); - -// Function to pack the ZIP file -function packZip() { - exec("node ./pack-zip.js", (err, stdout, stderr) => { - if (err) { - console.error("Error packing zip:", err); - return; - } - console.log(stdout.trim()); - }); -} - -// Custom plugin to pack ZIP after build or rebuild -const zipPlugin = { - name: "zip-plugin", - setup(build) { - build.onEnd(() => { - packZip(); - }); - }, -}; - -// Base build configuration -let buildConfig = { +esbuild.build({ entryPoints: ["src/main.js"], bundle: true, + outfile: "dist/main.js", + format: "iife", + platform: "browser", minify: true, - logLevel: "info", - color: true, - outdir: "dist", - plugins: [zipPlugin], -}; + sourcemap: false +}).then(() => { + console.log("Build completed. Creating plugin ZIP..."); -// Main function to handle both serve and production builds -(async function () { - if (isServe) { - console.log("Starting development server..."); - - // Watch and Serve Mode - const ctx = await esbuild.context(buildConfig); - - await ctx.watch(); - const { host, port } = await ctx.serve({ - servedir: ".", - port: 3000, - }); + execSync("node pack-zip.js", { + stdio: "inherit" + }); - } else { - console.log("Building for production..."); - await esbuild.build(buildConfig); - console.log("Production build complete."); - } -})(); + console.log("plugin.zip created successfully."); +}).catch(() => process.exit(1)); diff --git a/icon.png b/icon.png index 2d5d3c6..727925b 100644 Binary files a/icon.png and b/icon.png differ diff --git a/package.json b/package.json index 081be18..d50a16c 100644 --- a/package.json +++ b/package.json @@ -1,22 +1,20 @@ { - "name": "acode-plugin", + "name": "acode-templates", "version": "1.0.0", - "description": "Template for Acode plugin", + "description": "Templates plugin for Acode", "main": "src/main.js", - "repository": "https://github.com/Acode-Foundation/acode-plugin.git", - "author": "Acode Foundation", "license": "MIT", + "scripts": { + "build": "node esbuild.config.mjs" + }, "dependencies": { - "acode-plugin-types": "^1.11.7-patch.2", - "html-tag-js": "^2.4.15" + "acode-plugin-types": "^1.11.7-patch.2" }, "devDependencies": { "esbuild": "^0.25.8", "jszip": "^3.10.1" }, - "scripts": { - "dev": "node esbuild.config.mjs --serve", - "build": "node esbuild.config.mjs" - }, - "browserslist": "cover 100%,not android < 5" + "allowScripts": { + "esbuild@0.25.12": true + } } diff --git a/plugin.json b/plugin.json index 8f2903e..405a08d 100644 --- a/plugin.json +++ b/plugin.json @@ -1,19 +1,32 @@ { "$schema": "https://acode.app/schema/plugin/v0.1.0.json", - "id": "acode.plugin", - "name": "Plugin", - "main": "main.js", - "version": "1.0.0", - "repository": "https://github.com/Acode-Foundation/acode-plugin.git", + "id": "com.degrace.templates", + "name": "Templates", + "main": "dist/main.js", + "version": "1.1.0", + "readme": "readme.md", + "changelogs": "CHANGELOG.md", + "repository": "https://github.com/Degrace15/acode-templates", "icon": "icon.png", "minVersionCode": 290, "license": "MIT", - "keywords": [], "price": 0, - "permissions": [], + "keywords": [ + "template", + "html", + "css", + "php", + "javascript", + "python", + "c", + "cpp", + "java", + "project-generator" + ], "author": { - "name": "", - "email": "", - "github": "" - } + "name": "Hacker2.0", + "email": "kiminoudegrace64@gmail.com", + "github": "Degrace15" + }, + "description": "Create complete project templates for HTML, PHP, JavaScript, Python, C, C++, Java in Acode." } diff --git a/readme.md b/readme.md index c7dad79..090d228 100644 --- a/readme.md +++ b/readme.md @@ -1,21 +1,76 @@ -# Acode plugin +# Templates -Read acode plugin [documentation](https://docs.acode.app/docs/) to develop plugin for acode editor. +A project template generator plugin for Acode. -## Usage +## 🚀 Features -Use this for debug build: +Templates helps you create complete project structures directly inside Acode. -``` -npm run dev -``` +## 📦 Available Templates -and this for production build: +- HTML5 +- PHP +- JavaScript +- Python +- C +- C++ +- Java -``` -npm run build -``` +## ✨ Features in 1.1.0 -## How to parse/bundle scss file ? +- Create complete project templates +- Generate multiple files automatically +- Support for multiple programming languages +- Ready-to-use project structures +- Faster project creation in Acode -You'll need to install one sass esbuild plugin and then just add that in `esbuild.config.mjs` at line 34 +## 📂 Examples + +### HTML Project + +Creates: + +index.html style.css script.js + + +### PHP Project + +Creates: + +index.php config.php + + +### Python Project + +Creates: + +main.py requirements.txt + + +## ⚙️ Installation + +1. Download the plugin ZIP file. +2. Open Acode. +3. Go to Plugins. +4. Install Templates. + +## 🛠 Usage + +1. Open a project folder in Acode. +2. Open the command palette. +3. Run: + +Templates + + +4. Select your project type. + +## 👨💻 Developer + +Author: Hacker2.0 + +GitHub: +https://github.com/Degrace15 + +License: +MIT diff --git a/src/main.js b/src/main.js index 14846f8..baa49a8 100644 --- a/src/main.js +++ b/src/main.js @@ -1,26 +1,248 @@ -import plugin from '../plugin.json'; +import plugin from "../plugin.json"; -class AcodePlugin { +function init(baseUrl, $page, cache) { - async init() { - // plugin initialisation - } + const commands = acode.require("commands"); + const select = acode.require("select"); + const fsOperation = acode.require("fsOperation"); - async destroy() { - // plugin clean up - } -} + commands.addCommand({ + + name: "templates", + description: "Create project templates", + + exec: async () => { + + const templates = [ + ["html", "HTML5 Project"], + ["php", "PHP Project"], + ["javascript", "JavaScript Project"], + ["python", "Python Project"], + ["c", "C Project"], + ["cpp", "C++ Project"], + ["java", "Java Project"] + ]; + + + const choice = await select( + "Choose a template", + templates + ); + + + if (!choice) return; + + + const folder = addedFolder[0]; + + + if (!folder) { + + acode.alert( + "Error", + "Please open a folder in Acode first." + ); + + return; + } + + + try { + + const fs = await fsOperation(folder.url); + + + if (choice === "html") { + + await fs.createFile( + "index.html", +` + +
+