Skip to content
Open
Show file tree
Hide file tree
Changes from 11 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
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Binary file modified icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 84 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
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 () => {
// 1. Récupérer le module openFolder pour obtenir le dossier actif
const openFolder = acode.require("openFolder");

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;
}

// 2. Récupérer le module select pour afficher le menu de choix
const select = acode.require("select");
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);
Comment thread
Degrace15 marked this conversation as resolved.
Outdated
if (!choice) return; // L'utilisateur a annulé

try {
// 3. Récupérer proprement le module fsOperation requis par Acode
const fsOperation = acode.require("fsOperation");
const fs = fsOperation(currentFolder.url);
Comment thread
Degrace15 marked this conversation as resolved.

if (choice === "html") {
await fs.createFile("index.html", `<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mon Projet HTML</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Projet HTML5 initialisé ! 🚀</h1>
<script src="script.js"></script>
</body>
</html>`);
await fs.createFile("style.css", `/* Styles du projet */\nbody {\n font-family: sans-serif;\n background-color: #f0f0f0;\n}`);
await fs.createFile("script.js", `// Code JavaScript\nconsole.log("Le script est chargé !");`);

window.toast("Structure HTML5 créée avec succès ! ✔️");
}

else if (choice === "php") {
await fs.createFile("index.php", `<?php\n// Template PHP\necho "<h1>Hello depuis PHP ! 🐘</h1>";\n?>`);
window.toast("Template PHP créé avec succès ! ✔️");
}

else if (choice === "js") {
await fs.createFile("index.js", `// Template JavaScript\nconsole.log("Hello Node.js / JS !");`);
window.toast("Template JS créé avec succès ! ✔️");
}

// 4. Récupérer le module fileList et rafraîchir proprement l'affichage
const fileList = acode.require("fileList");
if (fileList && typeof fileList.refresh === "function") {
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);
29 changes: 16 additions & 13 deletions plugin.json
Original file line number Diff line number Diff line change
@@ -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"
]
}