psf-cli 0.2.1 → 0.3.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/package.json CHANGED
@@ -1,20 +1,20 @@
1
- {
2
- "name": "psf-cli",
3
- "version": "0.2.1",
4
- "main": "cli.js",
5
- "bin": {
6
- "psf": "src/cli.js"
7
- },
8
- "type": "module",
9
- "scripts": {
10
- "test": "echo \"Error: no test specified\" && exit 1"
11
- },
12
- "keywords": [],
13
- "author": "",
14
- "license": "ISC",
15
- "description": "",
16
- "dependencies": {
17
- "chalk": "^5.6.2",
18
- "commander": "^14.0.2"
19
- }
20
- }
1
+ {
2
+ "name": "psf-cli",
3
+ "version": "0.3.0",
4
+ "main": "cli.js",
5
+ "bin": {
6
+ "psf": "src/cli.js"
7
+ },
8
+ "type": "module",
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ },
12
+ "keywords": [],
13
+ "author": "",
14
+ "license": "ISC",
15
+ "description": "",
16
+ "dependencies": {
17
+ "chalk": "^5.6.2",
18
+ "commander": "^14.0.2"
19
+ }
20
+ }
package/src/cli.js CHANGED
@@ -28,6 +28,37 @@ program
28
28
  program.option("-t, --template <string>", "template type", "node");
29
29
  program.option("-d, --dir <path>", "Output directory", process.cwd());
30
30
 
31
+ program
32
+ .command("info <template>")
33
+ .description("Show templates details")
34
+ .action(async (template) => {
35
+ try {
36
+ switch (template) {
37
+ case "node":
38
+ console.log(
39
+ `Template: ${template}\nStructure:\n- src/index.js\n- .gitignore\n- package.json\n- README.md`,
40
+ );
41
+ break;
42
+ default:
43
+ throw new Error(
44
+ chalk.red(
45
+ `Invalid template: "${template}". Available templates: node`,
46
+ ),
47
+ );
48
+ }
49
+ } catch (err) {
50
+ console.log(err);
51
+ }
52
+ });
53
+
54
+ // List command
55
+ program
56
+ .command("list")
57
+ .description("Templates list")
58
+ .action(() => {
59
+ console.log(chalk.blue("Avaible templates:\n- node\n"));
60
+ });
61
+
31
62
  // Init command
32
63
  program
33
64
  .command("init <projectName>")
@@ -43,7 +74,9 @@ program
43
74
  break;
44
75
  default:
45
76
  throw new Error(
46
- `Invalid template: "${opts.template}". Available templates: node`,
77
+ chalk.red(
78
+ `Invalid template: "${opts.template}". Available templates: node`,
79
+ ),
47
80
  );
48
81
  }
49
82
  } catch (err) {
@@ -1,3 +1,6 @@
1
- export default async function gitignoreCreator() {
1
+ import fs from "fs/promises";
2
+ import path from "path";
3
+
4
+ export default async function gitignoreCreator(pathFolder) {
2
5
  await fs.writeFile(path.join(pathFolder, ".gitignore"), "node_modules\n");
3
6
  }
@@ -1,6 +1,6 @@
1
1
  import fs from "fs/promises";
2
- import packageJsonCreator from "./packageJsonCreator";
3
- import gitignoreCreator from "./gitignoreCreator";
2
+ import packageJsonCreator from "./packageJsonCreator/index.js";
3
+ import gitignoreCreator from "./gitignoreCreator/index.js";
4
4
  import path from "path";
5
5
 
6
6
  // Creating a Node Project
@@ -20,8 +20,8 @@ async function folderCreator(dir, projectName) {
20
20
  path.join(pathFolder, "README.md"),
21
21
  "# New Node Project",
22
22
  );
23
- packageJsonCreator();
24
- gitignoreCreator();
23
+ packageJsonCreator(pathFolder, projectName);
24
+ gitignoreCreator(pathFolder);
25
25
  } catch (err) {
26
26
  console.error("Error creating folder:", err);
27
27
  }
@@ -1,6 +1,7 @@
1
1
  import fs from "fs/promises";
2
+ import path from "path";
2
3
 
3
- export default async function packageJsonCreator(projectName) {
4
+ export default async function packageJsonCreator(pathFolder, projectName) {
4
5
  const packageJson = {
5
6
  name: projectName,
6
7
  version: "1.0.0",