codeplay-common 3.0.8 ā 3.0.9
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.
|
@@ -1284,72 +1284,79 @@ async function autoUpdatePlugin(pluginDef, pluginInfo) {
|
|
|
1284
1284
|
|
|
1285
1285
|
return true;
|
|
1286
1286
|
}
|
|
1287
|
+
// ===============================
|
|
1288
|
+
// FILE PLUGIN UPDATE
|
|
1289
|
+
// ===============================
|
|
1287
1290
|
|
|
1288
|
-
|
|
1289
|
-
// FILE PLUGIN UPDATE
|
|
1290
|
-
// ===============================
|
|
1291
|
+
const pluginDir = path.dirname(oldFullPath);
|
|
1291
1292
|
|
|
1292
|
-
|
|
1293
|
+
// Only this plugin has ios variant
|
|
1294
|
+
const IOS_VARIANT_PLUGINS = [
|
|
1295
|
+
"saveToGalleryAndSaveAnyFile"
|
|
1296
|
+
];
|
|
1293
1297
|
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
];
|
|
1298
|
+
let variants = [
|
|
1299
|
+
`${baseName}-${latestVersion}.js`
|
|
1300
|
+
];
|
|
1298
1301
|
|
|
1299
|
-
|
|
1302
|
+
if (IOS_VARIANT_PLUGINS.includes(baseName)) {
|
|
1303
|
+
variants.push(`${baseName}-${latestVersion}-ios.js`);
|
|
1304
|
+
}
|
|
1300
1305
|
|
|
1301
|
-
|
|
1302
|
-
for (const fileName of variants) {
|
|
1306
|
+
let downloaded = [];
|
|
1303
1307
|
|
|
1304
|
-
|
|
1308
|
+
// Download files
|
|
1309
|
+
for (const fileName of variants) {
|
|
1305
1310
|
|
|
1306
|
-
|
|
1311
|
+
const url = `https://htmlcodeplay.com/code-play-plugin/${fileName}`;
|
|
1307
1312
|
|
|
1308
|
-
|
|
1313
|
+
console.log(`š Checking latest: ${fileName}`);
|
|
1309
1314
|
|
|
1310
|
-
|
|
1315
|
+
if (await urlExists(url)) {
|
|
1311
1316
|
|
|
1312
|
-
|
|
1317
|
+
const destPath = path.join(pluginDir, fileName);
|
|
1313
1318
|
|
|
1314
|
-
|
|
1319
|
+
await downloadFile(url, destPath);
|
|
1315
1320
|
|
|
1316
|
-
|
|
1317
|
-
}
|
|
1318
|
-
}
|
|
1321
|
+
downloaded.push(fileName);
|
|
1319
1322
|
|
|
1320
|
-
|
|
1321
|
-
if (downloaded.length === 0) {
|
|
1322
|
-
console.log(`ā No files downloaded for ${baseName}`);
|
|
1323
|
-
return false;
|
|
1323
|
+
console.log(`⬠Downloaded ā ${fileName}`);
|
|
1324
1324
|
}
|
|
1325
|
+
}
|
|
1325
1326
|
|
|
1326
|
-
|
|
1327
|
-
|
|
1327
|
+
if (downloaded.length === 0) {
|
|
1328
|
+
console.log(`ā No files downloaded for ${baseName}`);
|
|
1329
|
+
return false;
|
|
1330
|
+
}
|
|
1328
1331
|
|
|
1329
|
-
|
|
1332
|
+
// Remove ONLY versioned files (safe)
|
|
1333
|
+
const versionPattern = new RegExp(`^${baseName}-\\d+\\.\\d+(-ios)?\\.js$`);
|
|
1330
1334
|
|
|
1331
|
-
|
|
1332
|
-
file.startsWith(baseName + "-") &&
|
|
1333
|
-
file.endsWith(".js") &&
|
|
1334
|
-
!downloaded.includes(file)
|
|
1335
|
-
) {
|
|
1335
|
+
const existingFiles = fs.readdirSync(pluginDir);
|
|
1336
1336
|
|
|
1337
|
-
|
|
1337
|
+
existingFiles.forEach(file => {
|
|
1338
1338
|
|
|
1339
|
-
|
|
1339
|
+
if (
|
|
1340
|
+
versionPattern.test(file) &&
|
|
1341
|
+
!downloaded.includes(file)
|
|
1342
|
+
) {
|
|
1340
1343
|
|
|
1341
|
-
|
|
1342
|
-
}
|
|
1344
|
+
const oldPath = path.join(pluginDir, file);
|
|
1343
1345
|
|
|
1344
|
-
|
|
1346
|
+
fs.unlinkSync(oldPath);
|
|
1345
1347
|
|
|
1346
|
-
|
|
1348
|
+
console.log(`š Removed old file ā ${file}`);
|
|
1349
|
+
}
|
|
1347
1350
|
|
|
1348
|
-
|
|
1351
|
+
});
|
|
1349
1352
|
|
|
1350
|
-
|
|
1353
|
+
const newFileName = `${baseName}-${latestVersion}.js`;
|
|
1351
1354
|
|
|
1352
|
-
|
|
1355
|
+
updateImports(oldFileName, newFileName);
|
|
1356
|
+
|
|
1357
|
+
console.log(`ā
Updated ā ${newFileName}`);
|
|
1358
|
+
|
|
1359
|
+
return true;
|
|
1353
1360
|
}
|
|
1354
1361
|
|
|
1355
1362
|
|
|
@@ -1556,7 +1563,11 @@ if (hasMandatoryUpdate) {
|
|
|
1556
1563
|
process.exit(1);
|
|
1557
1564
|
}
|
|
1558
1565
|
|
|
1559
|
-
console.log('\nš All mandatory plugins auto-updated!');
|
|
1566
|
+
console.log('\nš All mandatory plugins auto-updated! Rechecking plugins...\n');
|
|
1567
|
+
|
|
1568
|
+
// Re-run plugin check so outdated list becomes empty
|
|
1569
|
+
await checkPlugins();
|
|
1570
|
+
return;
|
|
1560
1571
|
}
|
|
1561
1572
|
|
|
1562
1573
|
|