@slvn/neon 1.0.2 → 1.0.4
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 +34 -27
- package/package.json +2 -2
- package/readme.md +0 -4
package/bin/neon.js
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { spawnSync } from "child_process";
|
|
6
6
|
import chalk from "chalk";
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
import { createRequire } from 'module'; // NOUVEAU: Pour utiliser require.resolve dans un module ESM
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
+
// Utilitaires ESM pour retrouver les chemins
|
|
11
|
+
const require = createRequire(import.meta.url); // Initialise require() pour le scope actuel
|
|
12
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
+
const __dirname = path.dirname(__filename);
|
|
14
|
+
const packageRoot = path.join(__dirname, '..');
|
|
15
|
+
|
|
16
|
+
// --- Lecture des Fichiers du Package ---
|
|
17
|
+
|
|
18
|
+
// Récupère le chemin absolu des fichiers du package (essentiel pour 'build')
|
|
19
|
+
const scriptPath = require.resolve('@slvn/neon/index.js'); // Utilisation de require.resolve (plus stable pour les packages)
|
|
20
|
+
const readmePath = path.join(packageRoot, 'readme.md');
|
|
10
21
|
|
|
11
22
|
const [, , command, projectName] = process.argv;
|
|
12
|
-
const
|
|
13
|
-
const readme = fs.readFileSync(readmePath , "utf-8") // Utilisation du chemin absolu
|
|
23
|
+
const readme = fs.readFileSync(readmePath , "utf-8")
|
|
14
24
|
const cwd = process.cwd();
|
|
15
25
|
|
|
16
|
-
// ---
|
|
17
|
-
|
|
26
|
+
// --- Logique 'CREATE' (Ne copie plus index.js) ---
|
|
18
27
|
|
|
19
28
|
if (command === "create") {
|
|
20
29
|
if (!projectName) {
|
|
@@ -25,7 +34,7 @@ if (command === "create") {
|
|
|
25
34
|
const projectPath = path.join(cwd, projectName);
|
|
26
35
|
|
|
27
36
|
if (fs.existsSync(projectPath)) {
|
|
28
|
-
console.log(chalk.
|
|
37
|
+
console.log(chalk.red("\n Projet existant. Veuillez le supprimez ou choisir un autre nom de projet"))
|
|
29
38
|
process.exit(1);
|
|
30
39
|
}
|
|
31
40
|
|
|
@@ -33,7 +42,7 @@ if (command === "create") {
|
|
|
33
42
|
|
|
34
43
|
fs.writeFileSync(
|
|
35
44
|
path.join(projectPath, "int.txt"),
|
|
36
|
-
"Entrez la description de votre site
|
|
45
|
+
"Entrez la description de votre site à concevoir"
|
|
37
46
|
);
|
|
38
47
|
|
|
39
48
|
fs.writeFileSync(
|
|
@@ -41,38 +50,36 @@ if (command === "create") {
|
|
|
41
50
|
readme
|
|
42
51
|
);
|
|
43
52
|
|
|
44
|
-
//
|
|
45
|
-
// qui est censé être projectPath. Je le corrige pour être sûr.
|
|
46
|
-
fs.writeFileSync(path.join(projectPath, "index.js"), script);
|
|
53
|
+
// *REMARQUE: index.js n'est plus créé ici.*
|
|
47
54
|
|
|
48
|
-
console.log(chalk.green("\n Projet", projectName, "
|
|
55
|
+
console.log(chalk.green("\n Projet", projectName, "créé \n"));
|
|
49
56
|
console.log(" Entrez : cd" , chalk.bgBlue(projectName) , "\n")
|
|
50
|
-
console.log(chalk.gray("
|
|
51
|
-
console.log(chalk.green(" Lancez le build avec : neon build
|
|
57
|
+
console.log(chalk.gray(" Éditez la description de votre site dans int.txt ou autre fichier.txt \n"))
|
|
58
|
+
console.log(chalk.green(" Lancez le build avec : neon build <nom_du_fichier_txt> \n"))
|
|
52
59
|
}
|
|
53
60
|
|
|
61
|
+
// --- Logique 'BUILD' (Exécute index.js depuis le package) ---
|
|
62
|
+
|
|
54
63
|
if (command === "build") {
|
|
55
64
|
if (!projectName) {
|
|
56
|
-
console.log("\n Usage : neon build
|
|
57
|
-
|
|
58
|
-
process.exit(1);
|
|
65
|
+
console.log("\n Usage : neon build <nom_du_fichier_txt>");
|
|
66
|
+
process.exit(1);
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
const intentPath = path.resolve(cwd, projectName);
|
|
62
|
-
|
|
63
|
-
const indexJs =
|
|
64
|
-
|
|
70
|
+
// indexJs est désormais le chemin du index.js qui se trouve DANS VOTRE PACKAGE
|
|
71
|
+
const indexJs = scriptPath;
|
|
65
72
|
|
|
66
73
|
if (!fs.existsSync(intentPath)) {
|
|
67
|
-
console.log(chalk.red("\n Fichier d'intention spécifié introuvable"));
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
if (!fs.existsSync(indexJs)) {
|
|
71
|
-
console.log(chalk.red("Fichier 'index.js' introuvable dans le répertoire courant."));
|
|
74
|
+
console.log(chalk.red("\n Fichier d'intention spécifié introuvable."));
|
|
72
75
|
process.exit(1);
|
|
73
76
|
}
|
|
77
|
+
|
|
78
|
+
// Le test pour indexJs n'est plus nécessaire car il vient du package.
|
|
79
|
+
// Sauf si vous voulez vérifier qu'il est bien lisible (ce qui devrait toujours être le cas).
|
|
74
80
|
|
|
75
|
-
|
|
81
|
+
// Arguments passés à votre index.js : [Chemin du index.js du package, Chemin du fichier d'intention]
|
|
82
|
+
spawnSync("node", [indexJs, intentPath], {
|
|
76
83
|
stdio: "inherit",
|
|
77
84
|
});
|
|
78
85
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slvn/neon",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"bin": {
|
|
14
|
-
"neon": "bin/neon.js"
|
|
14
|
+
"neon": "./bin/neon.js"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"chalk": "^5.6.2"
|
package/readme.md
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
Voici un exemple complet de README.md pour ton projet Neon :
|
|
2
|
-
|
|
3
|
-
|
|
4
1
|
# Neon
|
|
5
2
|
|
|
6
|
-
|
|
7
3
|
Neon est un générateur de code front-end basé sur Node.js, spécialisé dans Tailwind CSS.
|
|
8
4
|
|
|
9
5
|
Il permet aux développeurs de créer rapidement des sites web modernes et cohérents à partir d'une intention utilisateur.
|