evophp 1.0.28 → 1.0.30

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/README.md CHANGED
@@ -1,18 +1,20 @@
1
- # EvoPHP
1
+ # EvoPHP CLI - Comprehensive Guide
2
2
 
3
- EvoPHP is a command-line tool designed to simplify the creation, installation, and management of plugins, themes, and projects using Evolution by Kins Okafor. Whether you are starting a new project or extending functionality with plugins and themes, EvoPHP provides the tools you need to get up and running quickly.
3
+ ## Overview
4
+ EvoPHP CLI is a command-line interface designed to simplify the development and management of projects, plugins, and themes within the EvoPHP ecosystem. With intuitive commands and shorthands, developers can quickly set up projects, manage dependencies, and handle plugin/theme creation and installation with ease.
4
5
 
5
6
  ---
6
7
 
7
8
  ## Table of Contents
8
- 1. [Installation](#installation)
9
- 2. [Getting Started](#getting-started)
10
- - [Initialize a New Project](#initialize-a-new-project)
11
- - [Install a Plugin or Theme](#install-a-plugin-or-theme)
12
- - [Create a New Plugin or Theme](#create-a-new-plugin-or-theme)
13
- 3. [Plugin Development](#plugin-development)
14
- 4. [Troubleshooting](#troubleshooting)
15
- 5. [License](#license)
9
+ - [Installation](#installation)
10
+ - [All Commands](#all-commands)
11
+ - [Initialization](#initialization)
12
+ - [Plugin/Theme Creation](#plugintheme-creation)
13
+ - [Plugin/Theme Installation](#plugintheme-installation)
14
+ - [Plugin/Theme Uninstallation](#plugintheme-uninstallation)
15
+ - [Dependency Management](#dependency-management)
16
+ - [Notes](#notes)
17
+ - [Further Documentation](#further-documentation)
16
18
 
17
19
  ---
18
20
 
@@ -21,7 +23,7 @@ EvoPHP is a command-line tool designed to simplify the creation, installation, a
21
23
  ### Prerequisites
22
24
  Ensure the following are installed on your system:
23
25
  - **Node.js**: Verify by running `node -v` and `npm -v`.
24
- - **Composer** (optional): For managing PHP dependencies.
26
+ - **Composer**: For managing PHP dependencies.
25
27
 
26
28
  ### Install EvoPHP
27
29
  To install EvoPHP globally, run:
@@ -33,102 +35,118 @@ This command makes the `evophp` CLI available system-wide.
33
35
 
34
36
  ---
35
37
 
36
- ## Getting Started
38
+ ## All Commands
37
39
 
38
- ### Initialize a New Project
39
- To create and set up a new project, run:
40
+ ### Initialization
40
41
  ```bash
41
- evophp init <project-name>
42
- ```
43
- Example:
44
- ```bash
45
- evophp init my-project
42
+ evophp init ?<project-name>
46
43
  ```
44
+ - Initialize a new project.
45
+ - Examples:
46
+ ```bash
47
+ evophp init
48
+ evophp init example-project
49
+ ```
47
50
 
48
- This will:
49
- 1. Clone the EvoPHP repository into a folder named `<project-name>`.
50
- 2. Run `node evolution` with the project name as an argument.
51
- 3. Install Composer dependencies (if a `composer.json` file exists).
52
- 4. Install Node.js dependencies using `npm install`.
51
+ ---
53
52
 
54
- After setup, navigate to your project folder:
53
+ ### Plugin/Theme Creation
55
54
  ```bash
56
- cd my-project
55
+ evophp n | new plugin | theme <author>/<name>
57
56
  ```
57
+ - Create a new plugin or theme.
58
+ - Examples:
59
+ - Plugin:
60
+ ```bash
61
+ evophp new plugin example-author/example-plugin
62
+ evophp n plugin example-author/example-plugin
63
+ ```
64
+ - Theme:
65
+ ```bash
66
+ evophp new theme example-author/example-theme
67
+ evophp n theme example-author/example-theme
68
+ ```
69
+
70
+ ---
58
71
 
59
- To start your project:
72
+ ### Plugin/Theme Installation
60
73
  ```bash
61
- npm run start
74
+ evophp i | install plugin | theme <author>/<name>
62
75
  ```
76
+ - Install a plugin or theme.
77
+ - Examples:
78
+ - Plugin:
79
+ ```bash
80
+ evophp install plugin example-author/example-plugin
81
+ evophp i plugin example-author/example-plugin
82
+ ```
83
+ - Theme:
84
+ ```bash
85
+ evophp install theme example-author/example-theme
86
+ evophp i theme example-author/example-theme
87
+ ```
63
88
 
64
89
  ---
65
90
 
66
- ### Install a Plugin or Theme
67
- To install a plugin or theme, use the following command:
91
+ ### Plugin/Theme Uninstallation
68
92
  ```bash
69
- evophp install <plugin|theme> <author/repository-name>
93
+ evophp u | uninstall plugin | theme <plugin-name>
70
94
  ```
71
- Example:
72
- ```bash
73
- evophp install plugin kinsokafor/eEdu
74
- ```
75
-
76
- The command will fetch the specified plugin or theme and set it up for use.
95
+ - Uninstall a plugin or theme.
96
+ - Examples:
97
+ - Plugin:
98
+ ```bash
99
+ evophp uninstall plugin example-plugin
100
+ evophp u plugin example-plugin
101
+ ```
102
+ - Theme:
103
+ ```bash
104
+ evophp uninstall theme example-theme
105
+ evophp u theme example-theme
106
+ ```
77
107
 
78
108
  ---
79
109
 
80
- ### Create a New Plugin or Theme
81
- To create a new plugin or theme, use:
110
+ ### Dependency Management
82
111
  ```bash
83
- evophp new <plugin|theme> <author/repository-name>
112
+ evophp d | install-dependencies <plugin-name>
84
113
  ```
85
- Example:
114
+ - Install npm production dependencies.
115
+ - Examples:
116
+ ```bash
117
+ evophp install-dependencies example-plugin
118
+ evophp d example-plugin
119
+ ```
120
+
121
+ #### Development Dependencies
86
122
  ```bash
87
- evophp new plugin kinsokafor/MyAwesomePlugin
123
+ evophp d | install-dependencies <plugin-name> --dev | --save-dev
88
124
  ```
89
-
90
- You will be prompted to provide additional details like:
91
- - The entry URI.
92
- - A unique 3-character plugin prefix.
93
-
94
- ---
95
-
96
- ## Plugin Development
97
-
98
- ### Creating a Plugin
99
- To create your own plugin:
100
- 1. Use the [EvoPlugin GitHub template](https://github.com/kinsokafor/EvoPlugin) and click "Use this template."
101
- 2. Name your repository (e.g., `ExamplePlugin`).
102
- 3. Use the [EvoPlugin.js GitHub template](https://github.com/kinsokafor/EvoPlugin.js) for the JavaScript counterpart. Name it similarly, adding `.js` to the end (e.g., `ExamplePlugin.js`).
103
-
104
- ### Installing Your Plugin
105
- To install your new plugin:
125
+ - Install npm development dependencies.
126
+ - Examples:
127
+ ```bash
128
+ evophp install-dependencies example-plugin --dev
129
+ evophp d example-plugin --dev
130
+ ```
131
+
132
+ #### Composer Dependencies
106
133
  ```bash
107
- npm run --i plugin
134
+ evophp d | install-dependencies <plugin-name> --composer
108
135
  ```
109
- You will be prompted for:
110
- - Plugin name (e.g., `kinsokafor/ExamplePlugin`).
111
- - Entry URI (e.g., `example-plugin`).
112
- - Unique 3-character plugin prefix (e.g., `ex1`).
136
+ - Install composer dependencies.
137
+ - Examples:
138
+ ```bash
139
+ evophp install-dependencies example-plugin --composer
140
+ evophp d example-plugin --composer
141
+ ```
113
142
 
114
143
  ---
115
144
 
116
- ## Troubleshooting
117
-
118
- - **Permission Issues**: On Linux/macOS, use `sudo` for commands requiring elevated permissions.
119
- - **Node.js Installation**: Verify installation using `node -v` and `npm -v`.
120
- - **Versioning Conflicts**: If updating, increment the version in `package.json`.
121
-
122
- ---
123
-
124
- ## License
125
-
126
- This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
145
+ ## Notes
146
+ - `<author>` must be a valid GitHub username.
147
+ - `<name>` must be a unique repository name (not already existing on GitHub).
127
148
 
128
149
  ---
129
150
 
130
- ### Key Features of This Version:
131
- 1. **Clear Commands**: All commands are listed with syntax, examples, and expected results.
132
- 2. **Plugin Development**: Detailed instructions for creating and managing plugins.
133
- 3. **Troubleshooting Section**: Practical solutions to common issues.
134
- 4. **User-Friendly Layout**: A clean structure with headings and examples for easy navigation.
151
+ ## Further Documentation
152
+ For additional details, best practices, and advanced usage, please refer to the [official EvoPHP documentation](#).
@@ -1,76 +1,149 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { execSync } = require('child_process');
4
- const fs = require('fs');
5
- const path = require('path');
6
- const { readLineAsync } = require('./helpers');
3
+ const { execSync } = require("child_process");
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const { readLineAsync } = require("./helpers");
7
7
 
8
8
  (async () => {
9
- try {
10
- let [, , pluginName, ...args] = process.argv;
11
-
12
- if (!pluginName) {
13
- console.error("Please specify the plugin or theme name.");
14
- process.exit(1);
15
- }
16
-
17
- // Check if flags for prod or dev are provided
18
- const isProd = true;
19
- const isDev = args.includes('--save-dev');
20
-
21
- if (!isProd && !isDev) {
22
- console.error("Please specify either '--prod' or '--dev' as flags.");
23
- process.exit(1);
24
- }
25
-
26
- const depType = isProd ? 'prod' : 'dev';
27
-
28
- const pluginPath = path.join('EvoJsDev', 'Modules', pluginName);
29
-
30
- if (!fs.existsSync(pluginPath)) {
31
- console.error(`Plugin "${pluginName}" not found in ${pluginPath}.`);
32
- process.exit(1);
33
- }
34
-
35
- const dependenciesFile = path.join(pluginPath, 'dependencies.json');
36
- let dependencies = {};
37
-
38
- // If dependencies.json exists, read its content
39
- if (fs.existsSync(dependenciesFile)) {
40
- dependencies = JSON.parse(fs.readFileSync(dependenciesFile, 'utf-8'));
41
- }
42
-
43
- console.log(`Current dependencies in dependencies.json for ${pluginName}:`);
44
- console.log("Production dependencies:", dependencies.prod || "None");
45
- console.log("Development dependencies:", dependencies.dev || "None");
46
-
47
- // Prompt user for additional dependencies
48
- const additionalDeps = await readLineAsync(`Enter additional ${depType} dependencies (comma separated): `);
49
- const newDeps = additionalDeps.split(',').map(dep => dep.trim()).filter(dep => dep);
50
-
51
- // Add new dependencies to the respective array
52
- if (newDeps.length) {
53
- dependencies[depType] = (dependencies[depType]
54
- ? dependencies[depType] + ' ' + newDeps.join(' ')
55
- : newDeps.join(' ')).trim().split(' ').filter((value, index, array) => array.indexOf(value) === index).join(' ');
56
- }
57
-
58
- // Write updated dependencies to dependencies.json
59
- fs.writeFileSync(dependenciesFile, JSON.stringify(dependencies, null, 2), 'utf-8');
60
- console.log("Updated dependencies.json successfully.");
61
-
62
- // Install the new dependencies
63
- if (newDeps.length) {
64
- const installCommand = depType === 'prod'
65
- ? `npm install ${newDeps.join(' ')} --save` // For prod dependencies
66
- : `npm install ${newDeps.join(' ')} --save-dev`; // For dev dependencies
67
- console.log(`Installing ${depType} dependencies...`);
68
- execSync(installCommand, { stdio: 'inherit' });
69
- }
70
-
71
- console.log("Dependencies installed successfully.");
72
- } catch (error) {
73
- console.error("An error occurred:", error.message);
9
+ try {
10
+ let [, , pluginName, ...args] = process.argv;
11
+
12
+ if (!pluginName) {
13
+ console.error("Please specify the plugin or theme name.");
14
+ process.exit(1);
15
+ }
16
+
17
+ // Check if flags for prod or dev are provided
18
+
19
+ const depType =
20
+ args.includes("--dev") ?? args.includes("--save-dev") ? "dev" : "prod";
21
+
22
+ if (args.includes("--composer")) {
23
+ const pluginPath = path.join("EvoJsDev", "Modules", pluginName);
24
+
25
+ if (!fs.existsSync(pluginPath)) {
26
+ console.error(`Plugin "${pluginName}" not found in ${pluginPath}.`);
27
+ process.exit(1);
28
+ }
29
+
30
+ const dependenciesFile = path.join(pluginPath, "dependencies.json");
31
+ let dependencies = {};
32
+ // If dependencies.json exists, read its content
33
+ if (fs.existsSync(dependenciesFile)) {
34
+ dependencies = JSON.parse(fs.readFileSync(dependenciesFile, "utf-8"));
35
+ }
36
+
37
+ console.log(
38
+ `Current php dependencies in dependencies.json for ${pluginName}:`
39
+ );
40
+ console.log("Production dependencies:", dependencies.prod || "None");
41
+
42
+ // Prompt user for additional dependencies
43
+ const additionalDeps = await readLineAsync(
44
+ `Enter additional ${depType} dependencies (space separated): `
45
+ );
46
+ const newDeps = additionalDeps
47
+ .split(" ")
48
+ .map((dep) => dep.trim())
49
+ .filter((dep) => dep);
50
+
51
+ // Add new dependencies to the respective array
52
+ if (newDeps.length) {
53
+ dependencies.prod = (
54
+ dependencies.prod
55
+ ? dependencies.prod + " " + newDeps.join(" ")
56
+ : newDeps.join(" ")
57
+ )
58
+ .trim()
59
+ .split(" ")
60
+ .filter((value, index, array) => array.indexOf(value) === index)
61
+ .join(" ");
62
+ }
63
+
64
+ // Write updated dependencies to dependencies.json
65
+ fs.writeFileSync(
66
+ dependenciesFile,
67
+ JSON.stringify(dependencies, null, 2),
68
+ "utf-8"
69
+ );
70
+ console.log("Updated dependencies.json successfully.");
71
+
72
+ // Install the new dependencies
73
+ if (newDeps.length) {
74
+ const installCommand = `composer require ${newDeps.join(" ")}`
75
+ console.log(`Installing ${depType} dependencies...`);
76
+ execSync(installCommand, { stdio: "inherit" });
77
+ }
78
+
79
+ console.log("Dependencies installed successfully.");
80
+
81
+ } else {
82
+ const pluginPath = path.join("EvoJsDev", "Modules", pluginName);
83
+
84
+ if (!fs.existsSync(pluginPath)) {
85
+ console.error(`Plugin "${pluginName}" not found in ${pluginPath}.`);
74
86
  process.exit(1);
87
+ }
88
+
89
+ const dependenciesFile = path.join(pluginPath, "dependencies.json");
90
+ let dependencies = {};
91
+
92
+ // If dependencies.json exists, read its content
93
+ if (fs.existsSync(dependenciesFile)) {
94
+ dependencies = JSON.parse(fs.readFileSync(dependenciesFile, "utf-8"));
95
+ }
96
+
97
+ console.log(
98
+ `Current dependencies in dependencies.json for ${pluginName}:`
99
+ );
100
+ console.log("Production dependencies:", dependencies.prod || "None");
101
+ console.log("Development dependencies:", dependencies.dev || "None");
102
+
103
+ // Prompt user for additional dependencies
104
+ const additionalDeps = await readLineAsync(
105
+ `Enter additional ${depType} dependencies (space separated): `
106
+ );
107
+ const newDeps = additionalDeps
108
+ .split(" ")
109
+ .map((dep) => dep.trim())
110
+ .filter((dep) => dep);
111
+
112
+ // Add new dependencies to the respective array
113
+ if (newDeps.length) {
114
+ dependencies[depType] = (
115
+ dependencies[depType]
116
+ ? dependencies[depType] + " " + newDeps.join(" ")
117
+ : newDeps.join(" ")
118
+ )
119
+ .trim()
120
+ .split(" ")
121
+ .filter((value, index, array) => array.indexOf(value) === index)
122
+ .join(" ");
123
+ }
124
+
125
+ // Write updated dependencies to dependencies.json
126
+ fs.writeFileSync(
127
+ dependenciesFile,
128
+ JSON.stringify(dependencies, null, 2),
129
+ "utf-8"
130
+ );
131
+ console.log("Updated dependencies.json successfully.");
132
+
133
+ // Install the new dependencies
134
+ if (newDeps.length) {
135
+ const installCommand =
136
+ depType === "prod"
137
+ ? `npm install ${newDeps.join(" ")} --save` // For prod dependencies
138
+ : `npm install ${newDeps.join(" ")} --save-dev`; // For dev dependencies
139
+ console.log(`Installing ${depType} dependencies...`);
140
+ execSync(installCommand, { stdio: "inherit" });
141
+ }
142
+
143
+ console.log("Dependencies installed successfully.");
75
144
  }
145
+ } catch (error) {
146
+ console.error("An error occurred:", error.message);
147
+ process.exit(1);
148
+ }
76
149
  })();
package/install-plugin.js CHANGED
@@ -89,6 +89,21 @@ const fs = require('fs');
89
89
  } else {
90
90
  console.log("No dependencies.json found. Skipping dependency installation.");
91
91
  }
92
+
93
+ // Check for dependencies.json in the .js plugin path
94
+ const phpDependenciesFile = path.join(paths[0], 'dependencies.json');
95
+ if (fs.existsSync(phpDependenciesFile)) {
96
+ console.log("Found dependencies.json. Installing php dependencies...");
97
+ const dependencies = JSON.parse(fs.readFileSync(phpDependenciesFile, 'utf-8'));
98
+
99
+ // Install production dependencies
100
+ if (dependencies.prod) {
101
+ console.log("Installing production dependencies...");
102
+ execSync(`composer require ${dependencies.prod}`, { stdio: 'inherit', cwd: process.cwd() });
103
+ }
104
+ } else {
105
+ console.log("No php dependencies.json found. Skipping dependency installation.");
106
+ }
92
107
  } else if (type === 'theme') {
93
108
  // Clone the theme repository
94
109
  const themeRepoURL = `https://github.com/${author}/${itemName}.git`;
package/installer.js CHANGED
@@ -59,7 +59,7 @@ let [, , command, type, name] = process.argv;
59
59
  // sample command
60
60
  // evophp (d | install-dependencies) <plugin-name> ?(--save-dev | --save)
61
61
  const args = name ? [name] : [];
62
- console.log(args)
62
+
63
63
  name = type;
64
64
  if (!name) {
65
65
  console.error("Please specify the name of the plugin.");
@@ -148,16 +148,72 @@ let [, , command, type, name] = process.argv;
148
148
  console.error(`Error initializing project: ${error.message}`);
149
149
  process.exit(1);
150
150
  }
151
+ } else if (command === "help" || command === "h") {
152
+ console.log(`
153
+ ==========================================
154
+ EvoPHP CLI - Help Guide
155
+ ==========================================
156
+
157
+ All Commands:
158
+ Initialization:
159
+ evophp init ?<project-name>
160
+ Initialize a new project.
161
+ - Example: evophp init
162
+ - Example: evophp init example-project
163
+
164
+ Plugin/Theme Creation:
165
+ evophp n | new plugin | theme <author>/<name>
166
+ Create a new plugin or theme.
167
+ - Example (plugin): evophp new plugin example-author/example-plugin
168
+ - Example (theme): evophp new theme example-author/example-theme
169
+ - Example (plugin shorthand): evophp n plugin example-author/example-plugin
170
+ - Example (theme shorthand): evophp n theme example-author/example-theme
171
+
172
+ Plugin/Theme Installation:
173
+ evophp i | install plugin | theme <author>/<name>
174
+ Install a plugin or theme.
175
+ - Example (plugin): evophp install plugin example-author/example-plugin
176
+ - Example (theme): evophp install theme example-author/example-theme
177
+ - Example (plugin shorthand): evophp i plugin example-author/example-plugin
178
+ - Example (theme shorthand): evophp i theme example-author/example-theme
179
+
180
+ Plugin/Theme Uninstallation:
181
+ evophp u | uninstall plugin | theme <plugin-name>
182
+ Uninstall a plugin or theme.
183
+ - Example (plugin): evophp uninstall plugin example-plugin
184
+ - Example (theme): evophp uninstall theme example-theme
185
+ - Example (plugin shorthand): evophp u plugin example-plugin
186
+ - Example (theme shorthand): evophp u theme example-theme
187
+
188
+ Dependency Management:
189
+ evophp d | install-dependencies <plugin-name>
190
+ Install npm production dependencies.
191
+ - Example: evophp install-dependencies example-plugin
192
+ - Example (shorthand): evophp d example-plugin
193
+
194
+ evophp d | install-dependencies <plugin-name> --dev | --save-dev
195
+ Install npm development dependencies.
196
+ - Example: evophp install-dependencies example-plugin --dev
197
+ - Example (shorthand): evophp d example-plugin --dev
198
+
199
+ evophp d | install-dependencies <plugin-name> --composer
200
+ Install composer dependencies.
201
+ - Example: evophp install-dependencies example-plugin --composer
202
+ - Example (shorthand): evophp d example-plugin --composer
203
+
204
+ ==========================================
205
+ Notes:
206
+ - <author> must be a valid GitHub username.
207
+ - <name> must be a unique repository name (not already existing on GitHub).
208
+
209
+ For further details, visit the official EvoPHP documentation.
210
+ ==========================================
211
+
212
+ `);
213
+ process.exit(1);
151
214
  } else {
152
215
  console.error(`Unknown command: "${command}".`);
153
- console.log(`
154
- Usage:
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
160
- `);
216
+ console.log(`run evophp help for list of all acceptable commands.`);
161
217
  process.exit(1);
162
218
  }
163
219
  } catch (error) {
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.28",
3
+ "version": "1.0.30",
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
  },