@slvn/neon 1.0.3 → 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.
Files changed (3) hide show
  1. package/bin/neon.js +28 -28
  2. package/package.json +2 -2
  3. package/readme.md +0 -4
package/bin/neon.js CHANGED
@@ -1,31 +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'; // Ajout nécessaire pour ESM
7
+ import { fileURLToPath } from 'url';
8
+ import { createRequire } from 'module'; // NOUVEAU: Pour utiliser require.resolve dans un module ESM
8
9
 
9
- // --- CORRECTION DES CHEMINS ---
10
-
11
- // 1. Détermine le chemin absolu du répertoire où le script est exécuté (bin)
10
+ // Utilitaires ESM pour retrouver les chemins
11
+ const require = createRequire(import.meta.url); // Initialise require() pour le scope actuel
12
12
  const __filename = fileURLToPath(import.meta.url);
13
13
  const __dirname = path.dirname(__filename);
14
-
15
- // 2. Détermine le chemin absolu de la racine du package (un niveau au-dessus de 'bin')
16
14
  const packageRoot = path.join(__dirname, '..');
17
15
 
18
- // 3. Lit les fichiers internes en utilisant les chemins absolus
19
- const scriptPath = path.join(packageRoot, 'index.js');
20
- const readmePath = path.join(packageRoot, 'readme.md');
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');
21
21
 
22
22
  const [, , command, projectName] = process.argv;
23
- const script = fs.readFileSync(scriptPath, "utf-8");
24
23
  const readme = fs.readFileSync(readmePath , "utf-8")
25
24
  const cwd = process.cwd();
26
25
 
27
- // --- FIN DES CORRECTIONS ---
28
-
26
+ // --- Logique 'CREATE' (Ne copie plus index.js) ---
29
27
 
30
28
  if (command === "create") {
31
29
  if (!projectName) {
@@ -36,7 +34,7 @@ if (command === "create") {
36
34
  const projectPath = path.join(cwd, projectName);
37
35
 
38
36
  if (fs.existsSync(projectPath)) {
39
- console.log(chalk.green("\n Projet existant veuillez le supprimez ou choisir un autre nom de projet"))
37
+ console.log(chalk.red("\n Projet existant. Veuillez le supprimez ou choisir un autre nom de projet"))
40
38
  process.exit(1);
41
39
  }
42
40
 
@@ -44,7 +42,7 @@ if (command === "create") {
44
42
 
45
43
  fs.writeFileSync(
46
44
  path.join(projectPath, "int.txt"),
47
- "Entrez la description de votre site a concevoir"
45
+ "Entrez la description de votre site à concevoir"
48
46
  );
49
47
 
50
48
  fs.writeFileSync(
@@ -52,34 +50,36 @@ if (command === "create") {
52
50
  readme
53
51
  );
54
52
 
55
- // Fichier index.js copié dans le nouveau répertoire de projet
56
- fs.writeFileSync(path.join(projectPath, "index.js"), script);
53
+ // *REMARQUE: index.js n'est plus créé ici.*
57
54
 
58
- console.log(chalk.green("\n Projet", projectName, "crée \n"));
55
+ console.log(chalk.green("\n Projet", projectName, "créé \n"));
59
56
  console.log(" Entrez : cd" , chalk.bgBlue(projectName) , "\n")
60
- console.log(chalk.gray(" Editez la description de votre site dans int.txt ou autre fichier.txt \n"))
61
- console.log(chalk.green(" Lancez le build avec : neon build int.txt ou le nom de votre fichier.txt \n"))
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"))
62
59
  }
63
60
 
61
+ // --- Logique 'BUILD' (Exécute index.js depuis le package) ---
62
+
64
63
  if (command === "build") {
65
64
  if (!projectName) {
66
- console.log("\n Usage : neon build int.txt");
65
+ console.log("\n Usage : neon build <nom_du_fichier_txt>");
67
66
  process.exit(1);
68
67
  }
69
68
 
70
69
  const intentPath = path.resolve(cwd, projectName);
71
- const indexJs = path.join(cwd, "index.js"); // Le index.js de l'utilisateur
70
+ // indexJs est désormais le chemin du index.js qui se trouve DANS VOTRE PACKAGE
71
+ const indexJs = scriptPath;
72
72
 
73
73
  if (!fs.existsSync(intentPath)) {
74
- console.log(chalk.red("\n Fichier d'intention spécifié introuvable"));
75
- process.exit(1);
76
- }
77
- if (!fs.existsSync(indexJs)) {
78
- 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."));
79
75
  process.exit(1);
80
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).
81
80
 
82
- spawnSync("node", [indexJs, intentPath], {
81
+ // Arguments passés à votre index.js : [Chemin du index.js du package, Chemin du fichier d'intention]
82
+ spawnSync("node", [indexJs, intentPath], {
83
83
  stdio: "inherit",
84
84
  });
85
85
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slvn/neon",
3
- "version": "1.0.3",
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.