evophp 1.0.27 → 1.0.29

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/installer.js CHANGED
@@ -76,6 +76,25 @@ let [, , command, type, name] = process.argv;
76
76
  process.exit(1);
77
77
  }
78
78
 
79
+ } else if (command === "uninstall" || command === "u") {
80
+ // sample command
81
+ // evophp (u | uninstall) (plugin | theme) <name>
82
+
83
+ if (!name) {
84
+ console.error("Please specify the plugin or theme name.");
85
+ process.exit(1);
86
+ }
87
+
88
+ console.log(`Installing plugin/theme: ${name}...`);
89
+ try {
90
+ const pluginPath = path.resolve(__dirname, "uninstall.js");
91
+ execSync(`node "${pluginPath}" ${type} ${name}`, {
92
+ stdio: "inherit",
93
+ });
94
+ } catch (error) {
95
+ console.error(`Error uninstalling plugin/theme: ${error.message}`);
96
+ process.exit(1);
97
+ }
79
98
  } else if (command === "init") {
80
99
  // sample command
81
100
  // evophp init ?<projectName>
@@ -133,9 +152,11 @@ let [, , command, type, name] = process.argv;
133
152
  console.error(`Unknown command: "${command}".`);
134
153
  console.log(`
135
154
  Usage:
136
- i | install <type> <name> Install a plugin or theme
137
- n | new <type> <name> Create a new plugin or theme
138
- init <name> Initialize a new project
155
+ i | install <type> <name> Install a plugin or theme
156
+ u | uninstall <type> <name> Uninstall a plugin or theme
157
+ n | new <type> <name> Create a new plugin or theme
158
+ d | install-dependencies <name> --save | --save-dev Install dependencies
159
+ init <name> Initialize a new project
139
160
  `);
140
161
  process.exit(1);
141
162
  }
package/new-plugin.js CHANGED
@@ -7,6 +7,9 @@ const axios = require('axios');
7
7
  const helpersPath = path.resolve(__dirname, 'helpers.js');
8
8
  const { readLineAsync, splitPluginName, mergeConfig } = require(helpersPath);
9
9
  const rimraf = require('rimraf');
10
+ const dotenv = require('dotenv');
11
+
12
+ dotenv.config({ path: "./.env.development" });
10
13
 
11
14
  (async () => {
12
15
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evophp",
3
- "version": "1.0.27",
3
+ "version": "1.0.29",
4
4
  "description": "Installer for the Evolution PHP project",
5
5
  "main": "installer.js",
6
6
  "scripts": {
@@ -11,6 +11,7 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "axios": "^1.7.9",
14
+ "dotenv": "^16.4.7",
14
15
  "edit-json-file": "^1.8.0",
15
16
  "rimraf": "^6.0.1"
16
17
  },
@@ -19,6 +20,7 @@
19
20
  "new-plugin.js",
20
21
  "install-plugin.js",
21
22
  "install-dependencies.js",
22
- "helpers.js"
23
+ "helpers.js",
24
+ "uninstall.js"
23
25
  ]
24
26
  }
package/uninstall.js ADDED
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env node
2
+
3
+ const path = require('path');
4
+ const helpersPath = path.resolve(__dirname, 'helpers.js');
5
+ const { readLineAsync } = require(helpersPath);
6
+ const fs = require('fs');
7
+ const rimraf = require('rimraf');
8
+ const editJsonFile = require("edit-json-file");
9
+
10
+ (async () => {
11
+ try {
12
+ let [, , type, name] = process.argv;
13
+
14
+ // Prompt user for type if not provided
15
+ if (!type || !['plugin', 'theme'].includes(type.toLowerCase())) {
16
+ type = await readLineAsync("What are you uninstalling? (plugin/theme): ");
17
+ type = type.toLowerCase();
18
+ if (!['plugin', 'theme'].includes(type)) {
19
+ console.error("Invalid type. Please specify either 'plugin' or 'theme'.");
20
+ process.exit(1);
21
+ }
22
+ }
23
+
24
+ // Prompt user for name if not provided
25
+ if (!name) {
26
+ name = await readLineAsync(
27
+ `Enter the ${type} name (e.g., example${type}): `
28
+ );
29
+ }
30
+
31
+ // Determine installation paths based on type
32
+ let paths;
33
+ if (type === 'plugin') {
34
+ paths = [
35
+ path.join('Public', 'Modules', name), // Main plugin path
36
+ path.join('EvoJsDev', 'Modules', name), // .js plugin path
37
+ ];
38
+ } else if (type === 'theme') {
39
+ paths = [path.join('Public', 'Themes', name)];
40
+ }
41
+
42
+ // Check if any of the paths already exist
43
+ console.log(`Uninstalling ${type} "${name}"...`);
44
+
45
+ for (const pluginPath of paths) {
46
+ if (fs.existsSync(pluginPath)) {
47
+ rimraf.sync(pluginPath);
48
+ }
49
+ }
50
+
51
+
52
+
53
+ // Clone repositories based on type
54
+ if (type === 'plugin') {
55
+ let file = editJsonFile("./config.json");
56
+ file.unset(`modules.${name}`)
57
+ file.save();
58
+ }
59
+
60
+ console.log(`The ${type} "${name}" has been uninstalled successfully.`);
61
+ } catch (error) {
62
+ console.error("An error occurred while uninstalling:", error.message);
63
+ process.exit(1);
64
+ }
65
+ })();