diff --git a/README.md b/README.md new file mode 100644 index 0000000..86b699e --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# Project Creator Plugin for Acode + +A lightweight and efficient plugin for the Acode editor that allows you to instantly generate boilerplate project structures for web development (HTML5, PHP, and JavaScript) directly inside your active workspace. + +## Features + +- **HTML5 Template:** Instantly creates an `index.html` structure (pre-linked with style and script), a starter `style.css`, and a `script.js` file. +- **PHP Template:** Generates a clean starter `index.php` file. +- **JavaScript Template:** Generates a basic `index.js` file for quick scripting or Node.js environments. +- **Native UI Integration:** Uses Acode's official built-in modules for a seamless prompt and file refresh experience. + +## How to Use + +1. Open a folder in Acode's file manager (required so the plugin knows where to create the files). +2. Open the Command Palette in Acode (`Ctrl+Shift+P` or via the sidebar menu). +3. Search for and select **"Open Project Creator"**. +4. Choose the template you want to generate from the popup selection list. +5. The files will be created instantly and your file tree will automatically refresh! + +## Project Structure Created + +### HTML5 Option +```text +your-folder/ +├── index.html +├── style.css +└── script.js diff --git a/icon.png b/icon.png index 2d5d3c6..1150298 100644 Binary files a/icon.png and b/icon.png differ diff --git a/main.js b/main.js new file mode 100644 index 0000000..e74d74b --- /dev/null +++ b/main.js @@ -0,0 +1,95 @@ +import plugin from "./plugin.json"; + +function init(baseUrl, $page, cache) { + const commands = acode.require("commands"); + + commands.addCommand({ + name: "project-creator", + description: "Open Project Creator", + exec: async () => { + try { + const openFolder = acode.require("openFolder"); + const select = acode.require("select"); + const fsOperation = acode.require("fsOperation"); + const fileList = acode.require("fileList"); + + const currentFolder = openFolder.target; + + if (!currentFolder || !currentFolder.url) { + acode.alert( + "Erreur", + "Veuillez d'abord ouvrir ou sélectionner un dossier dans le gestionnaire de fichiers d'Acode." + ); + return; + } + + const options = [ + ["html", "Template Web HTML5 (index.html, style.css, script.js)"], + ["php", "Template PHP (index.php)"], + ["js", "Template JavaScript (index.js)"] + ]; + + const choice = await select("Créer un modèle de projet", options); + if (!choice) return; + + const fs = fsOperation(currentFolder.url); + + if (choice === "html") { + await fs.createFile("index.html", ` + + + + + Mon Projet HTML + + + +

Projet HTML5 initialisé ! 🚀

+ + +`); + + await fs.createFile("style.css", `/* Styles du projet */ +body { + font-family: sans-serif; + background-color: #f0f0f0; +}`); + + await fs.createFile("script.js", `// Code JavaScript +console.log("Le script est chargé !");`); + + window.toast("Structure HTML5 créée avec succès ! ✔️"); + } else if (choice === "php") { + await fs.createFile("index.php", `Hello depuis PHP ! 🐘"; +?>`); + + window.toast("Template PHP créé avec succès ! ✔️"); + } else if (choice === "js") { + await fs.createFile("index.js", `// Template JavaScript +console.log("Hello Node.js / JS !");`); + + window.toast("Template JS créé avec succès ! ✔️"); + } + + if (fileList?.refresh) { + fileList.refresh(); + } + } catch (error) { + acode.alert( + "Erreur de création", + "Impossible de générer les fichiers : " + error.message + ); + } + } + }); +} + +function unmount() { + const commands = acode.require("commands"); + commands.removeCommand("project-creator"); +} + +acode.setPluginInit(plugin.id, init); +acode.setPluginUnmount(plugin.id, unmount); diff --git a/plugin.json b/plugin.json index 8f2903e..6afa598 100644 --- a/plugin.json +++ b/plugin.json @@ -1,19 +1,22 @@ { - "$schema": "https://acode.app/schema/plugin/v0.1.0.json", - "id": "acode.plugin", - "name": "Plugin", - "main": "main.js", + "$schema": "https://raw.githubusercontent.com/Acode-Foundation/acode-plugin/main/schema.json", + "id": "com.Degrace15.projectcreator", + "name": "Project Creator", "version": "1.0.0", - "repository": "https://github.com/Acode-Foundation/acode-plugin.git", - "icon": "icon.png", "minVersionCode": 290, + "description": "Quickly generate boilerplate project templates for HTML, PHP, and JavaScript.", + "author": "KIMINOU Degrace", + "icon": "icon.png", + "main": "main.js", + "readme": "README.md", "license": "MIT", - "keywords": [], "price": 0, - "permissions": [], - "author": { - "name": "", - "email": "", - "github": "" - } + "keywords": [ + "template", + "boilerplate", + "html", + "php", + "javascript", + "creator" + ] }