@slvn/neon 1.0.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.
- package/bin/neon.js +68 -0
- package/index.js +27 -0
- package/package.json +19 -0
- package/readme.md +67 -0
package/bin/neon.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { spawnSync } from "child_process";
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
|
|
8
|
+
const [, , command, projectName] = process.argv;
|
|
9
|
+
const script = fs.readFileSync("./index.js", "utf-8");
|
|
10
|
+
const readme = fs.readFileSync("./readme.md" , "utf-8")
|
|
11
|
+
const cwd = process.cwd();
|
|
12
|
+
|
|
13
|
+
if (command === "create") {
|
|
14
|
+
if (!projectName) {
|
|
15
|
+
console.log("\n Usage : neon create <project name>");
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const projectPath = path.join(cwd, projectName);
|
|
20
|
+
|
|
21
|
+
if (fs.existsSync(projectPath)) {
|
|
22
|
+
console.log(chalk.green("\n Projet existant veuillez le supprimez ou choisir un autre nom de projet"))
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
fs.mkdirSync(projectPath);
|
|
27
|
+
|
|
28
|
+
fs.writeFileSync(
|
|
29
|
+
path.join(projectPath, "int.txt"),
|
|
30
|
+
"Entrez la description de votre site a concevoir"
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
fs.writeFileSync(
|
|
34
|
+
path.join(projectPath, "readme.md"),
|
|
35
|
+
readme
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
fs.writeFileSync(path.join(projectName, "index.js"), script);
|
|
39
|
+
|
|
40
|
+
console.log(chalk.green("\n Projet", projectName, "crée \n"));
|
|
41
|
+
console.log(" Entrez : cd" , chalk.bgBlue(projectName) , "\n")
|
|
42
|
+
console.log(chalk.gray(" Editez la description de votre site dans int.txt ou autre fichier.txt \n"))
|
|
43
|
+
console.log(chalk.green(" Lancez le build avec : neon build int.txt ou le nom de votre fichier.txt \n"))
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (command === "build") {
|
|
47
|
+
if (!projectName) {
|
|
48
|
+
console.log("\n Usage : neon build int.txt");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const intentPath = path.resolve(cwd, projectName);
|
|
52
|
+
const indexJs = path.join(cwd, "index.js");
|
|
53
|
+
|
|
54
|
+
if (!fs.existsSync(intentPath)) {
|
|
55
|
+
console.log(chalk.red("\n Fichier d'intention spécifié introuvable"));
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
if (!fs.existsSync(indexJs)) {
|
|
59
|
+
console.log(chalk.red("Introuvable"));
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
spawnSync("node", [indexJs, intentPath], {
|
|
64
|
+
stdio: "inherit",
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
process.exit(0);
|
|
68
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import fs from "fs/promises";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
|
|
4
|
+
const intent = process.argv[2];
|
|
5
|
+
if(!intent){
|
|
6
|
+
console.log(chalk.red("Fichier spécifié introuvable ou vide"))
|
|
7
|
+
process.exit(1)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async function generateCode(int) {
|
|
11
|
+
try {
|
|
12
|
+
const file = await fs.readFile(int , "utf-8");
|
|
13
|
+
if (file.trim() < 1) console.log(chalk.red("Fichier d'intention vide"))
|
|
14
|
+
console.log(chalk.green(" Requete initiée ..."))
|
|
15
|
+
const res = await fetch(`https://neon-server-45so.onrender.com/api/neon?int=${file}`);
|
|
16
|
+
console.log(chalk.green("\n Donnée recus"))
|
|
17
|
+
const dat = await res.json();
|
|
18
|
+
console.log(chalk.green("\n Ecriture du fichier ..."))
|
|
19
|
+
const data = dat.code;
|
|
20
|
+
await fs.writeFile("index.html", data.replace(/```html/g , "").replace(/```/g , ""), "utf-8");
|
|
21
|
+
console.log("Fichier crée avec succès")
|
|
22
|
+
} catch (e) {
|
|
23
|
+
console.log(chalk.red("Erreur rencontrée lors du processus : ", e));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
generateCode(intent);
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@slvn/neon",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [],
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"bin": {
|
|
14
|
+
"neon": "bin/neon.js"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"chalk": "^5.6.2"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
Voici un exemple complet de README.md pour ton projet Neon :
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# Neon
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Neon est un générateur de code front-end basé sur Node.js, spécialisé dans Tailwind CSS.
|
|
8
|
+
|
|
9
|
+
Il permet aux développeurs de créer rapidement des sites web modernes et cohérents à partir d'une intention utilisateur.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Installez Neon globalement via npm :
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
|
|
20
|
+
npm install -g neon
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
Commandes
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
Créer un projet
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
neon create <nom-du-projet>
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
Cette commande crée un dossier <nom-du-projet> contenant :
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
int.txt : fichier où tu décris l’intention du site
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
readme.md : ce fichier
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
index.js : script qui génère le build
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
Générer le build
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
cd <nom-du-projet>
|
|
49
|
+
|
|
50
|
+
neon build int.txt
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
Exécute index.js avec le fichier d’intention int.txt et génère le code HTML/Tailwind correspondant.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
Exemple
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
neon create mysite
|
|
60
|
+
|
|
61
|
+
cd mysite
|
|
62
|
+
|
|
63
|
+
# Écrire l'intention dans int.txt
|
|
64
|
+
|
|
65
|
+
neon build int.txt
|
|
66
|
+
|
|
67
|
+
|