evophp 1.0.6 → 1.0.7
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/helpers.js +52 -0
- package/package.json +3 -2
package/helpers.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const readline = require('readline');
|
|
2
|
+
const rl = readline.createInterface({
|
|
3
|
+
input: process.stdin,
|
|
4
|
+
output: process.stdout
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Prompt user for input with a message
|
|
9
|
+
* @param {string} msg - The prompt message to display
|
|
10
|
+
* @returns {Promise<string>} - Resolves with user input
|
|
11
|
+
*/
|
|
12
|
+
const readLineAsync = (msg) => {
|
|
13
|
+
return new Promise((resolve) => {
|
|
14
|
+
rl.question(msg, (userRes) => {
|
|
15
|
+
resolve(userRes);
|
|
16
|
+
rl.close(); // Ensures the readline interface is closed after resolving
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Validates and splits the plugin name into [author, pluginName]
|
|
23
|
+
* @param {string} name - Plugin name or GitHub URL
|
|
24
|
+
* @returns {Promise<string[]>} - Resolves with an array [author, pluginName]
|
|
25
|
+
*/
|
|
26
|
+
const splitPluginName = async (name) => {
|
|
27
|
+
const isValidName = (input) =>
|
|
28
|
+
/^[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+$/.test(input);
|
|
29
|
+
|
|
30
|
+
let arr = [];
|
|
31
|
+
while (true) {
|
|
32
|
+
// Remove common GitHub URL prefixes and trim whitespace
|
|
33
|
+
name = name.replace(/^(https?:\/\/)?(www\.)?github\.com\//, '').trim();
|
|
34
|
+
|
|
35
|
+
if (isValidName(name)) {
|
|
36
|
+
arr = name.split('/');
|
|
37
|
+
break;
|
|
38
|
+
} else {
|
|
39
|
+
console.log(
|
|
40
|
+
"Plugin name must include the author's name (e.g., johndoe/exampleplugin)."
|
|
41
|
+
);
|
|
42
|
+
name = await readLineAsync("Enter the name of the plugin (or type 'cancel' to exit): ");
|
|
43
|
+
if (name.toLowerCase() === 'cancel') {
|
|
44
|
+
console.log("Process canceled by user.");
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return arr;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
module.exports = { readLineAsync, splitPluginName };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "evophp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Installer for the Evolution PHP project",
|
|
5
5
|
"main": "installer.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"installer.js",
|
|
17
17
|
"new-plugin.js",
|
|
18
18
|
"install-plugin.js",
|
|
19
|
-
"install-dependencies.js"
|
|
19
|
+
"install-dependencies.js",
|
|
20
|
+
"helpers.js"
|
|
20
21
|
]
|
|
21
22
|
}
|
|
22
23
|
|