@slvn/neon 1.0.0 → 1.0.2

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 (2) hide show
  1. package/bin/neon.js +60 -48
  2. package/package.json +1 -1
package/bin/neon.js CHANGED
@@ -1,68 +1,80 @@
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
7
 
8
+ const scriptPath = require.resolve('@slvn/neon/index.js');
9
+ const readmePath = require.resolve('@slvn/neon/readme.md');
10
+
8
11
  const [, , command, projectName] = process.argv;
9
- const script = fs.readFileSync("./index.js", "utf-8");
10
- const readme = fs.readFileSync("./readme.md" , "utf-8")
12
+ const script = fs.readFileSync(scriptPath, "utf-8"); // Utilisation du chemin absolu
13
+ const readme = fs.readFileSync(readmePath , "utf-8") // Utilisation du chemin absolu
11
14
  const cwd = process.cwd();
12
15
 
16
+ // --- FIN DES CORRECTIONS POUR LES CHEMINS ---
17
+
18
+
13
19
  if (command === "create") {
14
- if (!projectName) {
15
- console.log("\n Usage : neon create <project name>");
16
- process.exit(1);
17
- }
20
+ if (!projectName) {
21
+ console.log("\n Usage : neon create <project name>");
22
+ process.exit(1);
23
+ }
18
24
 
19
- const projectPath = path.join(cwd, projectName);
25
+ const projectPath = path.join(cwd, projectName);
20
26
 
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
- }
27
+ if (fs.existsSync(projectPath)) {
28
+ console.log(chalk.green("\n Projet existant veuillez le supprimez ou choisir un autre nom de projet"))
29
+ process.exit(1);
30
+ }
25
31
 
26
- fs.mkdirSync(projectPath);
32
+ fs.mkdirSync(projectPath);
27
33
 
28
- fs.writeFileSync(
29
- path.join(projectPath, "int.txt"),
30
- "Entrez la description de votre site a concevoir"
31
- );
34
+ fs.writeFileSync(
35
+ path.join(projectPath, "int.txt"),
36
+ "Entrez la description de votre site a concevoir"
37
+ );
32
38
 
33
- fs.writeFileSync(
34
- path.join(projectPath, "readme.md"),
35
- readme
36
- );
39
+ fs.writeFileSync(
40
+ path.join(projectPath, "readme.md"),
41
+ readme
42
+ );
37
43
 
38
- fs.writeFileSync(path.join(projectName, "index.js"), script);
44
+ // Attention: le fichier est écrit dans le dossier du projet (projectName),
45
+ // qui est censé être projectPath. Je le corrige pour être sûr.
46
+ fs.writeFileSync(path.join(projectPath, "index.js"), script);
39
47
 
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"))
48
+ console.log(chalk.green("\n Projet", projectName, "crée \n"));
49
+ console.log(" Entrez : cd" , chalk.bgBlue(projectName) , "\n")
50
+ console.log(chalk.gray(" Editez la description de votre site dans int.txt ou autre fichier.txt \n"))
51
+ console.log(chalk.green(" Lancez le build avec : neon build int.txt ou le nom de votre fichier.txt \n"))
44
52
  }
45
53
 
46
54
  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
- }
55
+ if (!projectName) {
56
+ console.log("\n Usage : neon build int.txt");
57
+ // Sortie nécessaire si projectName est manquant pour 'build'
58
+ process.exit(1);
59
+ }
60
+
61
+ const intentPath = path.resolve(cwd, projectName);
62
+
63
+ const indexJs = path.join(cwd, "index.js");
64
+
65
+
66
+ 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."));
72
+ process.exit(1);
73
+ }
74
+
75
+ spawnSync("node", [indexJs, intentPath], {
76
+ stdio: "inherit",
77
+ });
78
+
79
+ process.exit(0);
80
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slvn/neon",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {