evophp 1.0.25 → 1.0.26

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.
Files changed (2) hide show
  1. package/new-plugin.js +32 -7
  2. package/package.json +1 -1
package/new-plugin.js CHANGED
@@ -186,23 +186,48 @@ async function createGitHubRepo(token, templateRepo, pluginName) {
186
186
  }
187
187
  }
188
188
 
189
- // Function to clone the newly created repository
189
+ // Function to clone the newly created repository with retry mechanism
190
190
  async function cloneRepository(author, pluginName, cloneDir) {
191
191
  try {
192
+ const cloneUrl = `https://github.com/${author}/${pluginName}.git`;
193
+
192
194
  // Ensure directories do not exist before cloning
193
195
  if (fs.existsSync(cloneDir)) {
194
196
  console.log(`The plugin "${pluginName}" already exists in the directory. Exiting.`);
195
- process.exit(0);
197
+ return;
196
198
  }
197
-
198
- const cloneUrl = `https://github.com/${author}/${pluginName}.git`;
199
199
 
200
200
  console.log(`Cloning ${author}/${pluginName}.git from GitHub...`);
201
- execSync(`git clone ${cloneUrl} ${cloneDir}`, { stdio: 'inherit' });
202
201
 
203
- console.log(`Cloned the repository ${pluginName} successfully.`);
202
+ let retries = 5;
203
+ while (retries > 0) {
204
+ try {
205
+ execSync(`git clone ${cloneUrl} ${cloneDir}`, { stdio: 'inherit' });
206
+
207
+ // Check if the cloned repository is non-empty
208
+ const files = fs.readdirSync(cloneDir);
209
+ if (files.length > 0) {
210
+ console.log(`Cloned the repository ${pluginName} successfully.`);
211
+ return;
212
+ } else {
213
+ console.warn("Repository appears to be empty. Retrying...");
214
+ retries--;
215
+ await new Promise(resolve => setTimeout(resolve, 3000)); // Wait for 3 seconds before retrying
216
+ }
217
+ } catch (error) {
218
+ console.error(`Error during cloning attempt: ${error.message}`);
219
+ retries--;
220
+ if (retries > 0) {
221
+ console.log(`Retrying... (${5 - retries}/5)`);
222
+ await new Promise(resolve => setTimeout(resolve, 3000)); // Wait for 3 seconds before retrying
223
+ }
224
+ }
225
+ }
226
+
227
+ console.error(`Failed to clone the repository ${pluginName} after multiple attempts.`);
228
+ process.exit(1);
204
229
  } catch (error) {
205
- console.error(`Error cloning the repository ${pluginName}:`, error.message);
230
+ console.error(`Unexpected error while cloning the repository ${pluginName}:`, error.message);
206
231
  process.exit(1);
207
232
  }
208
233
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evophp",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "description": "Installer for the Evolution PHP project",
5
5
  "main": "installer.js",
6
6
  "scripts": {