evophp 1.0.17 → 1.0.18
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 +2 -0
- package/install-dependencies.js +55 -128
- package/install-plugin.js +6 -2
- package/installer.js +23 -15
- package/new-plugin.js +1 -6
- package/package.json +1 -1
package/helpers.js
CHANGED
package/install-dependencies.js
CHANGED
|
@@ -1,147 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const fs = require("fs");
|
|
6
|
-
const { readLineAsync } = require(path.resolve(__dirname, 'helpers.js'));
|
|
7
|
-
|
|
8
|
-
let [, , command, type, name, ...args] = process.argv;
|
|
1
|
+
const { execSync } = require('child_process');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const { readLineAsync } = require('./helpers');
|
|
9
5
|
|
|
10
6
|
(async () => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (!name) {
|
|
14
|
-
console.error("Please specify the plugin or theme name.");
|
|
15
|
-
process.exit(1);
|
|
16
|
-
}
|
|
7
|
+
try {
|
|
8
|
+
let [, , pluginName, ...args] = process.argv;
|
|
17
9
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
execSync(`node install-plugin.js ${name}`, { stdio: "inherit" });
|
|
23
|
-
} catch (error) {
|
|
24
|
-
console.error(`Error installing plugin: ${error.message}`);
|
|
25
|
-
process.exit(1);
|
|
10
|
+
if (!pluginName) {
|
|
11
|
+
console.error("Please specify the plugin or theme name.");
|
|
12
|
+
process.exit(1);
|
|
26
13
|
}
|
|
27
|
-
} else if (type === "theme") {
|
|
28
|
-
try {
|
|
29
|
-
execSync(`node install-theme.js ${name}`, { stdio: "inherit" });
|
|
30
|
-
} catch (error) {
|
|
31
|
-
console.error(`Error installing theme: ${error.message}`);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
} else {
|
|
35
|
-
console.error("Invalid type. Please specify either 'plugin' or 'theme'.");
|
|
36
|
-
process.exit(1);
|
|
37
|
-
}
|
|
38
|
-
} else if (command === "n" || command === "new") {
|
|
39
|
-
if (!type || !name) {
|
|
40
|
-
console.error("Please specify both the type (plugin/theme) and name.");
|
|
41
|
-
process.exit(1);
|
|
42
|
-
}
|
|
43
14
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
execSync(`node new-plugin.js ${name}`, { stdio: "inherit" });
|
|
49
|
-
} catch (error) {
|
|
50
|
-
console.error(`Error creating new plugin: ${error.message}`);
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
} else if (type === "theme") {
|
|
54
|
-
try {
|
|
55
|
-
execSync(`node new-theme.js ${name}`, { stdio: "inherit" });
|
|
56
|
-
} catch (error) {
|
|
57
|
-
console.error(`Error creating new theme: ${error.message}`);
|
|
58
|
-
process.exit(1);
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
console.error("Invalid type. Please specify either 'plugin' or 'theme'.");
|
|
62
|
-
process.exit(1);
|
|
63
|
-
}
|
|
64
|
-
} else if (command === "install-dependencies" || command === "d") {
|
|
65
|
-
if (!name || !type) {
|
|
66
|
-
console.error("Please specify both the type (plugin) and name.");
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
15
|
+
// Check if flags for prod or dev are provided
|
|
16
|
+
const isProd = true;
|
|
17
|
+
const isDev = args.includes('--save-dev');
|
|
69
18
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
execSync(`node install-dependencies.js ${name} ${args.join(' ')}`, { stdio: "inherit" });
|
|
75
|
-
} catch (error) {
|
|
76
|
-
console.error(`Error installing dependencies: ${error.message}`);
|
|
77
|
-
process.exit(1);
|
|
19
|
+
if (!isProd && !isDev) {
|
|
20
|
+
console.error("Please specify either '--prod' or '--dev' as flags.");
|
|
21
|
+
process.exit(1);
|
|
78
22
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
console.error("Invalid name. Please provide a valid project name.");
|
|
88
|
-
process.exit(1);
|
|
23
|
+
|
|
24
|
+
const depType = isProd ? 'prod' : 'dev';
|
|
25
|
+
|
|
26
|
+
const pluginPath = path.join('EvoJsDev', 'Module', pluginName);
|
|
27
|
+
|
|
28
|
+
if (!fs.existsSync(pluginPath)) {
|
|
29
|
+
console.error(`Plugin "${pluginName}" not found in ${pluginPath}.`);
|
|
30
|
+
process.exit(1);
|
|
89
31
|
}
|
|
90
|
-
}
|
|
91
32
|
|
|
92
|
-
|
|
33
|
+
const dependenciesFile = path.join(pluginPath, 'dependencies.json');
|
|
34
|
+
let dependencies = {};
|
|
93
35
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
`git clone https://github.com/kinsokafor/evolution.git ${name}`,
|
|
99
|
-
{ stdio: "inherit" }
|
|
100
|
-
);
|
|
36
|
+
// If dependencies.json exists, read its content
|
|
37
|
+
if (fs.existsSync(dependenciesFile)) {
|
|
38
|
+
dependencies = JSON.parse(fs.readFileSync(dependenciesFile, 'utf-8'));
|
|
39
|
+
}
|
|
101
40
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
41
|
+
console.log(`Current dependencies in dependencies.json for ${pluginName}:`);
|
|
42
|
+
console.log("Production dependencies:", dependencies.prod || "None");
|
|
43
|
+
console.log("Development dependencies:", dependencies.dev || "None");
|
|
105
44
|
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
|
|
45
|
+
// Prompt user for additional dependencies
|
|
46
|
+
const additionalDeps = await readLineAsync(`Enter additional ${depType} dependencies (comma separated): `);
|
|
47
|
+
const newDeps = additionalDeps.split(',').map(dep => dep.trim()).filter(dep => dep);
|
|
109
48
|
|
|
110
|
-
//
|
|
111
|
-
if (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
console.log(
|
|
116
|
-
"Composer file not found, skipping Composer installation."
|
|
117
|
-
);
|
|
49
|
+
// Add new dependencies to the respective array
|
|
50
|
+
if (newDeps.length) {
|
|
51
|
+
dependencies[depType] = dependencies[depType]
|
|
52
|
+
? dependencies[depType] + ' ' + newDeps.join(' ')
|
|
53
|
+
: newDeps.join(' ');
|
|
118
54
|
}
|
|
119
55
|
|
|
120
|
-
//
|
|
121
|
-
|
|
122
|
-
|
|
56
|
+
// Write updated dependencies to dependencies.json
|
|
57
|
+
fs.writeFileSync(dependenciesFile, JSON.stringify(dependencies, null, 2), 'utf-8');
|
|
58
|
+
console.log("Updated dependencies.json successfully.");
|
|
59
|
+
|
|
60
|
+
// Install the new dependencies
|
|
61
|
+
if (newDeps.length) {
|
|
62
|
+
const installCommand = depType === 'prod'
|
|
63
|
+
? `npm install ${newDeps.join(' ')} --save` // For prod dependencies
|
|
64
|
+
: `npm install ${newDeps.join(' ')} --save-dev`; // For dev dependencies
|
|
65
|
+
console.log(`Installing ${depType} dependencies...`);
|
|
66
|
+
execSync(installCommand, { stdio: 'inherit' });
|
|
67
|
+
}
|
|
123
68
|
|
|
124
|
-
console.log(
|
|
125
|
-
|
|
126
|
-
);
|
|
127
|
-
console.log(`cd ${name}`);
|
|
128
|
-
} catch (error) {
|
|
129
|
-
console.error(`Error initializing project: ${error.message}`);
|
|
69
|
+
console.log("Dependencies installed successfully.");
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error("An error occurred:", error.message);
|
|
130
72
|
process.exit(1);
|
|
131
|
-
}
|
|
132
|
-
} else {
|
|
133
|
-
console.error(`Unknown command: "${command}".`);
|
|
134
|
-
console.log(`
|
|
135
|
-
Usage:
|
|
136
|
-
i | install <plugin/theme> <name> Install a plugin or theme
|
|
137
|
-
n | new <plugin/theme> <name> Create a new plugin or theme
|
|
138
|
-
d | install-dependencies <plugin> <name> Install dependencies for a plugin
|
|
139
|
-
init <name> Initialize a new project
|
|
140
|
-
`);
|
|
141
|
-
process.exit(1);
|
|
142
73
|
}
|
|
143
|
-
} catch (error) {
|
|
144
|
-
console.error("An unexpected error occurred:", error.message);
|
|
145
|
-
process.exit(1);
|
|
146
|
-
}
|
|
147
74
|
})();
|
package/install-plugin.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
1
3
|
const { execSync } = require('child_process');
|
|
2
4
|
const path = require('path');
|
|
3
|
-
const
|
|
5
|
+
const helpersPath = path.resolve(__dirname, 'helpers.js');
|
|
6
|
+
const { readLineAsync, splitPluginName } = require(helpersPath);
|
|
4
7
|
const fs = require('fs');
|
|
5
8
|
|
|
6
9
|
(async () => {
|
|
@@ -34,7 +37,7 @@ const fs = require('fs');
|
|
|
34
37
|
if (type === 'plugin') {
|
|
35
38
|
paths = [
|
|
36
39
|
path.join('Public', 'Module', itemName), // Main plugin path
|
|
37
|
-
path.join('
|
|
40
|
+
path.join('EvoJsDev', 'Module', itemName), // .js plugin path
|
|
38
41
|
];
|
|
39
42
|
} else if (type === 'theme') {
|
|
40
43
|
paths = [path.join('Public', 'Themes', itemName)];
|
|
@@ -87,6 +90,7 @@ const fs = require('fs');
|
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
console.log(`The ${type} "${itemName}" has been installed successfully.`);
|
|
93
|
+
process.exit(1);
|
|
90
94
|
} catch (error) {
|
|
91
95
|
console.error("An error occurred while installing:", error.message);
|
|
92
96
|
process.exit(1);
|
package/installer.js
CHANGED
|
@@ -10,6 +10,9 @@ let [, , command, type, name] = process.argv;
|
|
|
10
10
|
(async () => {
|
|
11
11
|
try {
|
|
12
12
|
if (command === "i" || command === "install") {
|
|
13
|
+
// sample command
|
|
14
|
+
// evophp (i | install) (plugin | theme) <author/name>
|
|
15
|
+
|
|
13
16
|
if (!name) {
|
|
14
17
|
console.error("Please specify the plugin or theme name.");
|
|
15
18
|
process.exit(1);
|
|
@@ -26,6 +29,9 @@ let [, , command, type, name] = process.argv;
|
|
|
26
29
|
process.exit(1);
|
|
27
30
|
}
|
|
28
31
|
} else if (command === "n" || command === "new") {
|
|
32
|
+
// sample command
|
|
33
|
+
// evophp (n | new) (plugin | theme) <author/name>
|
|
34
|
+
|
|
29
35
|
// Validate type and name
|
|
30
36
|
if (!type || !name) {
|
|
31
37
|
console.error("Please specify the type (plugin/theme) and the name.");
|
|
@@ -44,36 +50,38 @@ let [, , command, type, name] = process.argv;
|
|
|
44
50
|
console.log(`Creating a new ${type}: ${name}...`);
|
|
45
51
|
try {
|
|
46
52
|
const pluginPath = path.resolve(__dirname, "new-plugin.js");
|
|
47
|
-
console.log(`node "${pluginPath}" ${type} ${name}`)
|
|
48
53
|
execSync(`node "${pluginPath}" ${type} ${name}`, { stdio: "inherit" });
|
|
49
54
|
} catch (error) {
|
|
50
55
|
console.error(`Error creating new ${type}: ${error.message}`);
|
|
51
56
|
process.exit(1);
|
|
52
57
|
}
|
|
53
58
|
} else if (command === "install-dependencies" || command === "d") {
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
// sample command
|
|
60
|
+
// evophp (d | install-dependencies) <plugin-name> ?(--save-dev | --save)
|
|
61
|
+
const args = name ? name : [];
|
|
62
|
+
name = type;
|
|
63
|
+
if (!name) {
|
|
64
|
+
console.error("Please specify the name of the plugin.");
|
|
56
65
|
process.exit(1);
|
|
57
66
|
}
|
|
58
67
|
|
|
59
|
-
console.log(`Running install-dependencies for ${
|
|
68
|
+
console.log(`Running install-dependencies for ${name}...`);
|
|
60
69
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
console.error(`Error installing dependencies: ${error.message}`);
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
} else {
|
|
70
|
-
console.error("Install-dependencies only supports plugins currently.");
|
|
70
|
+
try {
|
|
71
|
+
const pluginPath = path.resolve(__dirname, "install-dependencies.js");
|
|
72
|
+
execSync(`node "${pluginPath}" ${name} ${args.join(' ')}`, { stdio: "inherit" });
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error(`Error installing dependencies: ${error.message}`);
|
|
71
75
|
process.exit(1);
|
|
72
76
|
}
|
|
77
|
+
|
|
73
78
|
} else if (command === "init") {
|
|
79
|
+
// sample command
|
|
80
|
+
// evophp init ?<projectName>
|
|
81
|
+
|
|
74
82
|
name = type;
|
|
75
83
|
if (!name) {
|
|
76
|
-
name = await readLineAsync("Enter the name of the
|
|
84
|
+
name = await readLineAsync("Enter the name of the project:");
|
|
77
85
|
if (!name.trim()) {
|
|
78
86
|
console.error("Invalid name. Please provide a valid project name.");
|
|
79
87
|
process.exit(1);
|
package/new-plugin.js
CHANGED
|
@@ -7,11 +7,6 @@ const path = require('path');
|
|
|
7
7
|
const fs = require('fs');
|
|
8
8
|
const axios = require('axios');
|
|
9
9
|
const helpersPath = path.resolve(__dirname, 'helpers.js');
|
|
10
|
-
console.log("Resolved helpers.js path:", helpersPath);
|
|
11
|
-
if (!fs.existsSync(helpersPath)) {
|
|
12
|
-
console.error("helpers.js not found at path:", helpersPath);
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
15
10
|
const { readLineAsync, splitPluginName } = require(helpersPath);
|
|
16
11
|
|
|
17
12
|
(async () => {
|
|
@@ -66,7 +61,7 @@ const { readLineAsync, splitPluginName } = require(helpersPath);
|
|
|
66
61
|
await createGitHubRepo(gitHubToken, templateRepo, `${itemName}.js`);
|
|
67
62
|
|
|
68
63
|
// Clone the newly created repositories
|
|
69
|
-
cloneDir = path.join('
|
|
64
|
+
cloneDir = path.join('EvoJsDev', 'Modules', itemName);
|
|
70
65
|
await cloneRepository(author, itemName, cloneDir);
|
|
71
66
|
|
|
72
67
|
} else if (type === 'theme') {
|