evophp 1.0.19 → 1.0.21
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 +134 -0
- package/new-plugin.js +118 -20
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# EvoPHP
|
|
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.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 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)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
### Prerequisites
|
|
22
|
+
Ensure the following are installed on your system:
|
|
23
|
+
- **Node.js**: Verify by running `node -v` and `npm -v`.
|
|
24
|
+
- **Composer** (optional): For managing PHP dependencies.
|
|
25
|
+
|
|
26
|
+
### Install EvoPHP
|
|
27
|
+
To install EvoPHP globally, run:
|
|
28
|
+
```bash
|
|
29
|
+
npm install -g evophp
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
This command makes the `evophp` CLI available system-wide.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Getting Started
|
|
37
|
+
|
|
38
|
+
### Initialize a New Project
|
|
39
|
+
To create and set up a new project, run:
|
|
40
|
+
```bash
|
|
41
|
+
evophp init <project-name>
|
|
42
|
+
```
|
|
43
|
+
Example:
|
|
44
|
+
```bash
|
|
45
|
+
evophp init my-project
|
|
46
|
+
```
|
|
47
|
+
|
|
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`.
|
|
53
|
+
|
|
54
|
+
After setup, navigate to your project folder:
|
|
55
|
+
```bash
|
|
56
|
+
cd my-project
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
To start your project:
|
|
60
|
+
```bash
|
|
61
|
+
npm run start
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
### Install a Plugin or Theme
|
|
67
|
+
To install a plugin or theme, use the following command:
|
|
68
|
+
```bash
|
|
69
|
+
evophp install <plugin|theme> <author/repository-name>
|
|
70
|
+
```
|
|
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.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
### Create a New Plugin or Theme
|
|
81
|
+
To create a new plugin or theme, use:
|
|
82
|
+
```bash
|
|
83
|
+
evophp new <plugin|theme> <author/repository-name>
|
|
84
|
+
```
|
|
85
|
+
Example:
|
|
86
|
+
```bash
|
|
87
|
+
evophp new plugin kinsokafor/MyAwesomePlugin
|
|
88
|
+
```
|
|
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:
|
|
106
|
+
```bash
|
|
107
|
+
npm run --i plugin
|
|
108
|
+
```
|
|
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`).
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
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.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
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.
|
package/new-plugin.js
CHANGED
|
@@ -5,7 +5,7 @@ const path = require('path');
|
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const axios = require('axios');
|
|
7
7
|
const helpersPath = path.resolve(__dirname, 'helpers.js');
|
|
8
|
-
const { readLineAsync,
|
|
8
|
+
const { readLineAsync, splitpluginName } = require(helpersPath);
|
|
9
9
|
|
|
10
10
|
(async () => {
|
|
11
11
|
try {
|
|
@@ -29,7 +29,7 @@ const { readLineAsync, splitPluginName } = require(helpersPath);
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// Validate name and split it into author and item name
|
|
32
|
-
const [author,
|
|
32
|
+
const [author, pluginName] = await splitpluginName(name);
|
|
33
33
|
|
|
34
34
|
// Validate PAT by checking the authenticated user's username
|
|
35
35
|
const userData = await getUserData(gitHubToken);
|
|
@@ -48,34 +48,107 @@ const { readLineAsync, splitPluginName } = require(helpersPath);
|
|
|
48
48
|
console.log("Creating a new plugin (EvoPlugin and EvoPlugin.js)...");
|
|
49
49
|
|
|
50
50
|
// Create repository for EvoPlugin
|
|
51
|
-
await createGitHubRepo(gitHubToken, templateRepo,
|
|
51
|
+
await createGitHubRepo(gitHubToken, templateRepo, pluginName);
|
|
52
52
|
|
|
53
53
|
// Clone the newly created repositories
|
|
54
|
-
cloneDir = path.join('Public', 'Modules',
|
|
55
|
-
await cloneRepository(author,
|
|
54
|
+
cloneDir = path.join('Public', 'Modules', pluginName);
|
|
55
|
+
await cloneRepository(author, pluginName, cloneDir);
|
|
56
56
|
|
|
57
57
|
// Create repository for EvoPlugin.js (plugin.js)
|
|
58
58
|
templateRepo = 'kinsokafor/EvoPlugin.js';
|
|
59
|
-
await createGitHubRepo(gitHubToken, templateRepo, `${
|
|
59
|
+
await createGitHubRepo(gitHubToken, templateRepo, `${pluginName}.js`);
|
|
60
60
|
|
|
61
61
|
// Clone the newly created repositories
|
|
62
|
-
cloneDir = path.join('EvoJsDev', 'Modules',
|
|
63
|
-
await cloneRepository(author,
|
|
62
|
+
cloneDir = path.join('EvoJsDev', 'Modules', pluginName);
|
|
63
|
+
await cloneRepository(author, pluginName, cloneDir);
|
|
64
|
+
|
|
65
|
+
var pluginPrefix = await readLineAsync("Enter Plugin Prefix?");
|
|
66
|
+
while(!test(pluginPrefix, 3)) {
|
|
67
|
+
pluginPrefix = await readLineAsync("Enter Plugin Prefix?");
|
|
68
|
+
}
|
|
69
|
+
pluginPrefix = pluginPrefix.trim().replaceAll(" ", "").toUpperCase()
|
|
70
|
+
|
|
71
|
+
var entryURI = await readLineAsync("Entry URI?");
|
|
72
|
+
while(!test(entryURI, 20)) {
|
|
73
|
+
entryURI = await readLineAsync("Entry URI?");
|
|
74
|
+
}
|
|
75
|
+
entryURI = entryURI.trim().replaceAll(" ", "").toLowerCase()
|
|
76
|
+
|
|
77
|
+
const entry = pluginPrefix + "Main"
|
|
78
|
+
|
|
79
|
+
await editFile(`./EvoJsDev/Modules/${pluginName}/config.json`, {
|
|
80
|
+
pluginName: pluginName,
|
|
81
|
+
entry: entry
|
|
82
|
+
}).then(file => {
|
|
83
|
+
try {
|
|
84
|
+
fs.rename(`./EvoJsDev/Modules/${pluginName}/Entry`,
|
|
85
|
+
`./EvoJsDev/Modules/${pluginName}/${entry}`, function(err) {
|
|
86
|
+
if ( err ) console.error('ERROR: ' + err);
|
|
87
|
+
});
|
|
88
|
+
} catch(e) {}
|
|
89
|
+
|
|
90
|
+
const configFile = path.resolve(__dirname, `./EvoJsDev/Modules/${pluginName}/config.json`)
|
|
91
|
+
if (fs.existsSync(configFile)) {
|
|
92
|
+
const pluginConfig = require(configFile)
|
|
93
|
+
mergeConfig(pluginConfig)
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
await editFile(`./Public/Modules/${pluginName}/Routes.php`, {
|
|
98
|
+
pluginName: pluginName,
|
|
99
|
+
entry: entry,
|
|
100
|
+
entryURI: entryURI,
|
|
101
|
+
pluginPrefix: pluginPrefix
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
if (fs.existsSync(path.resolve(__dirname, `./Public/Modules/${pluginName}/Controller.php`))) {
|
|
105
|
+
await editFile(`./Public/Modules/${pluginName}/Controller.php`, {
|
|
106
|
+
pluginName: pluginName,
|
|
107
|
+
pluginPrefix: pluginPrefix
|
|
108
|
+
}).then(file => {
|
|
109
|
+
|
|
110
|
+
fs.rename(`./Public/Modules/${pluginName}/Controller.php`,
|
|
111
|
+
`./Public/Modules/${pluginName}/${pluginPrefix}Controller.php`, function(err) {
|
|
112
|
+
if ( err ) console.error('ERROR: ' + err);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
fs.rename(`./Public/Modules/${pluginName}/Views/Entry`,
|
|
116
|
+
`./Public/Modules/${pluginName}/Views/${entry}`, function(err) {
|
|
117
|
+
if ( err ) console.error('ERROR: ' + err);
|
|
118
|
+
});
|
|
119
|
+
})
|
|
120
|
+
}
|
|
64
121
|
|
|
65
122
|
} else if (type === 'theme') {
|
|
66
123
|
templateRepo = 'kinsokafor/EvoTheme'; // Theme template
|
|
67
124
|
console.log("Creating a new theme (EvoTheme)...");
|
|
68
125
|
|
|
69
126
|
// Create repository for EvoTheme
|
|
70
|
-
await createGitHubRepo(gitHubToken, templateRepo,
|
|
127
|
+
await createGitHubRepo(gitHubToken, templateRepo, pluginName);
|
|
71
128
|
|
|
72
129
|
// Clone the newly created repositories
|
|
73
|
-
cloneDir = path.join('Public', 'Themes',
|
|
74
|
-
await cloneRepository(author,
|
|
130
|
+
cloneDir = path.join('Public', 'Themes', pluginName);
|
|
131
|
+
await cloneRepository(author, pluginName, cloneDir);
|
|
132
|
+
|
|
133
|
+
await editFile(`./Public/Themes/${pluginName}/Data/index.data.php`, {
|
|
134
|
+
pluginName: pluginName
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
await editFile(`./Public/Themes/${pluginName}/Data/login.data.php`, {
|
|
138
|
+
pluginName: pluginName
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
await editFile(`./Public/Themes/${pluginName}/Views/index.blade.php`, {
|
|
142
|
+
pluginName: pluginName
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
await editFile(`./Public/Themes/${pluginName}/Views/login.blade.php`, {
|
|
146
|
+
pluginName: pluginName
|
|
147
|
+
})
|
|
75
148
|
}
|
|
76
149
|
|
|
77
150
|
|
|
78
|
-
console.log(`The ${type} "${
|
|
151
|
+
console.log(`The ${type} "${pluginName}" has been set up successfully!`);
|
|
79
152
|
|
|
80
153
|
} catch (error) {
|
|
81
154
|
console.error("An error occurred while setting up the plugin or theme:", error.message);
|
|
@@ -84,12 +157,12 @@ const { readLineAsync, splitPluginName } = require(helpersPath);
|
|
|
84
157
|
})();
|
|
85
158
|
|
|
86
159
|
// Function to create a repository from a template
|
|
87
|
-
async function createGitHubRepo(token, templateRepo,
|
|
160
|
+
async function createGitHubRepo(token, templateRepo, pluginName) {
|
|
88
161
|
try {
|
|
89
162
|
const response = await axios.post(
|
|
90
163
|
`https://api.github.com/repos/${templateRepo}/generate`,
|
|
91
164
|
{
|
|
92
|
-
name:
|
|
165
|
+
name: pluginName,
|
|
93
166
|
private: false, // Set to true if you want the repository to be private
|
|
94
167
|
description: `A new ${templateRepo.split('/')[1]} created from template.`,
|
|
95
168
|
},
|
|
@@ -102,7 +175,7 @@ async function createGitHubRepo(token, templateRepo, itemName) {
|
|
|
102
175
|
);
|
|
103
176
|
|
|
104
177
|
if (response.status === 201) {
|
|
105
|
-
console.log(`Successfully created the repository: ${
|
|
178
|
+
console.log(`Successfully created the repository: ${pluginName} from ${templateRepo}`);
|
|
106
179
|
} else {
|
|
107
180
|
console.error('Failed to create the repository:', response.data);
|
|
108
181
|
process.exit(1);
|
|
@@ -114,22 +187,22 @@ async function createGitHubRepo(token, templateRepo, itemName) {
|
|
|
114
187
|
}
|
|
115
188
|
|
|
116
189
|
// Function to clone the newly created repository
|
|
117
|
-
async function cloneRepository(author,
|
|
190
|
+
async function cloneRepository(author, pluginName, cloneDir) {
|
|
118
191
|
try {
|
|
119
192
|
// Ensure directories do not exist before cloning
|
|
120
193
|
if (fs.existsSync(cloneDir)) {
|
|
121
|
-
console.log(`The plugin "${
|
|
194
|
+
console.log(`The plugin "${pluginName}" already exists in the directory. Exiting.`);
|
|
122
195
|
process.exit(0);
|
|
123
196
|
}
|
|
124
197
|
|
|
125
|
-
const cloneUrl = `https://github.com/${author}/${
|
|
198
|
+
const cloneUrl = `https://github.com/${author}/${pluginName}.git`;
|
|
126
199
|
|
|
127
200
|
console.log(`Cloning the newly created repository from GitHub...`);
|
|
128
201
|
execSync(`git clone ${cloneUrl} ${cloneDir}`, { stdio: 'inherit' });
|
|
129
202
|
|
|
130
|
-
console.log(`Cloned the repository ${
|
|
203
|
+
console.log(`Cloned the repository ${pluginName} successfully.`);
|
|
131
204
|
} catch (error) {
|
|
132
|
-
console.error(`Error cloning the repository ${
|
|
205
|
+
console.error(`Error cloning the repository ${pluginName}:`, error.message);
|
|
133
206
|
process.exit(1);
|
|
134
207
|
}
|
|
135
208
|
}
|
|
@@ -149,3 +222,28 @@ async function getUserData(token) {
|
|
|
149
222
|
process.exit(1);
|
|
150
223
|
}
|
|
151
224
|
}
|
|
225
|
+
|
|
226
|
+
const editFile = async (file, data) => {
|
|
227
|
+
return new Promise((resolve, reject) => {
|
|
228
|
+
fs.readFile(file, 'utf8', (err, fileData) => {
|
|
229
|
+
if (err) {
|
|
230
|
+
console.error('Error reading color scheme file:', err);
|
|
231
|
+
reject(err)
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
for(var i in data) {
|
|
235
|
+
fileData = fileData.replaceAll(`<${i}>`, data[i])
|
|
236
|
+
}
|
|
237
|
+
// Write the content to the destination file
|
|
238
|
+
fs.writeFile(file, fileData, 'utf8', (err) => {
|
|
239
|
+
if (err) {
|
|
240
|
+
console.error('Error writing color scheme file:', err);
|
|
241
|
+
reject(err)
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
console.log(`${file} file created successfully.`);
|
|
245
|
+
resolve(file);
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
})
|
|
249
|
+
}
|