codeplay-common 3.0.8 → 3.1.0
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.
|
@@ -1111,50 +1111,39 @@ const VITE_ALIAS_ONLY = [
|
|
|
1111
1111
|
"certificatejs",
|
|
1112
1112
|
"ffmpeg"
|
|
1113
1113
|
];
|
|
1114
|
+
|
|
1114
1115
|
function updateImports(oldName, newName) {
|
|
1115
1116
|
|
|
1116
1117
|
const projectRoot = process.cwd();
|
|
1117
1118
|
|
|
1118
|
-
const
|
|
1119
|
+
const filesToScan = [
|
|
1119
1120
|
path.join(projectRoot, "vite.config.js"),
|
|
1120
1121
|
path.join(projectRoot, "vite.config.mjs")
|
|
1121
1122
|
];
|
|
1122
1123
|
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1124
|
+
const srcDir = path.join(projectRoot, "src");
|
|
1125
|
+
|
|
1126
|
+
// scan vite config
|
|
1127
|
+
filesToScan.forEach(file => {
|
|
1127
1128
|
|
|
1128
|
-
//--------------------------------------------------
|
|
1129
|
-
// 1️⃣ ALWAYS update vite config
|
|
1130
|
-
//--------------------------------------------------
|
|
1131
|
-
viteFiles.forEach(file => {
|
|
1132
1129
|
if (!fs.existsSync(file)) return;
|
|
1133
1130
|
|
|
1134
1131
|
let content = fs.readFileSync(file, "utf8");
|
|
1135
1132
|
|
|
1136
1133
|
if (content.includes(oldName)) {
|
|
1137
|
-
|
|
1134
|
+
|
|
1135
|
+
content = content.split(oldName).join(newName);
|
|
1136
|
+
|
|
1138
1137
|
fs.writeFileSync(file, content);
|
|
1139
1138
|
|
|
1140
1139
|
console.log(`✏️ Updated alias in ${path.basename(file)}`);
|
|
1141
1140
|
}
|
|
1142
|
-
});
|
|
1143
|
-
|
|
1144
|
-
//--------------------------------------------------
|
|
1145
|
-
// 2️⃣ If alias-only → STOP here
|
|
1146
|
-
//--------------------------------------------------
|
|
1147
|
-
if (isAliasOnly) {
|
|
1148
|
-
console.log(`⚡ Alias-only plugin → skipped full scan`);
|
|
1149
|
-
return;
|
|
1150
|
-
}
|
|
1151
1141
|
|
|
1152
|
-
|
|
1153
|
-
// 3️⃣ Otherwise scan src
|
|
1154
|
-
//--------------------------------------------------
|
|
1155
|
-
const srcDir = path.join(projectRoot, "src");
|
|
1142
|
+
});
|
|
1156
1143
|
|
|
1144
|
+
// scan src files
|
|
1157
1145
|
function walk(dir) {
|
|
1146
|
+
|
|
1158
1147
|
fs.readdirSync(dir).forEach(file => {
|
|
1159
1148
|
|
|
1160
1149
|
if (["node_modules","android","ios","dist",".git"].includes(file))
|
|
@@ -1166,29 +1155,36 @@ function updateImports(oldName, newName) {
|
|
|
1166
1155
|
if (stat.isDirectory()) {
|
|
1167
1156
|
walk(full);
|
|
1168
1157
|
}
|
|
1158
|
+
|
|
1169
1159
|
else if (
|
|
1170
1160
|
(full.endsWith(".js") ||
|
|
1171
1161
|
full.endsWith(".f7") ||
|
|
1172
1162
|
full.endsWith(".mjs")) &&
|
|
1173
1163
|
!full.endsWith(".min.js")
|
|
1174
1164
|
) {
|
|
1165
|
+
|
|
1175
1166
|
let content = fs.readFileSync(full, "utf8");
|
|
1176
1167
|
|
|
1177
1168
|
if (content.includes(oldName)) {
|
|
1178
|
-
|
|
1169
|
+
|
|
1170
|
+
content = content.split(oldName).join(newName);
|
|
1171
|
+
|
|
1179
1172
|
fs.writeFileSync(full, content);
|
|
1180
1173
|
|
|
1181
1174
|
console.log(`✏️ Updated import in ${path.relative(projectRoot, full)}`);
|
|
1182
1175
|
}
|
|
1176
|
+
|
|
1183
1177
|
}
|
|
1178
|
+
|
|
1184
1179
|
});
|
|
1180
|
+
|
|
1185
1181
|
}
|
|
1186
1182
|
|
|
1187
1183
|
if (fs.existsSync(srcDir)) {
|
|
1188
1184
|
walk(srcDir);
|
|
1189
1185
|
}
|
|
1190
|
-
}
|
|
1191
1186
|
|
|
1187
|
+
}
|
|
1192
1188
|
|
|
1193
1189
|
|
|
1194
1190
|
/**
|
|
@@ -1265,91 +1261,104 @@ async function autoUpdatePlugin(pluginDef, pluginInfo) {
|
|
|
1265
1261
|
// ===============================
|
|
1266
1262
|
// FOLDER PLUGIN UPDATE
|
|
1267
1263
|
// ===============================
|
|
1268
|
-
|
|
1264
|
+
if (pluginDef.isFolder) {
|
|
1269
1265
|
|
|
1270
|
-
|
|
1271
|
-
|
|
1266
|
+
const zipName = `${baseName}-${latestVersion}.zip`;
|
|
1267
|
+
const url = `https://htmlcodeplay.com/code-play-plugin/${zipName}`;
|
|
1272
1268
|
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1269
|
+
const destRoot = path.join(srcDir, pluginDef.destDir || pluginDef.baseDir || '');
|
|
1270
|
+
const oldPath = path.join(destRoot, pluginInfo.name);
|
|
1271
|
+
const newPath = path.join(destRoot, `${baseName}-${latestVersion}`);
|
|
1276
1272
|
|
|
1277
|
-
|
|
1273
|
+
if (!(await urlExists(url))) return false;
|
|
1278
1274
|
|
|
1279
|
-
|
|
1275
|
+
fs.rmSync(oldPath, { recursive: true, force: true });
|
|
1280
1276
|
|
|
1281
|
-
|
|
1277
|
+
await downloadAndExtractZip(url, newPath);
|
|
1282
1278
|
|
|
1283
|
-
|
|
1279
|
+
// 🔥 FIX: update imports
|
|
1280
|
+
updateImports(pluginInfo.name, `${baseName}-${latestVersion}`);
|
|
1284
1281
|
|
|
1285
|
-
|
|
1286
|
-
}
|
|
1282
|
+
console.log(`✅ Folder updated → ${baseName}-${latestVersion}`);
|
|
1287
1283
|
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1284
|
+
return true;
|
|
1285
|
+
}
|
|
1286
|
+
// ===============================
|
|
1287
|
+
// FILE PLUGIN UPDATE
|
|
1288
|
+
// ===============================
|
|
1291
1289
|
|
|
1292
|
-
|
|
1290
|
+
const pluginDir = path.dirname(oldFullPath);
|
|
1293
1291
|
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1292
|
+
// Only this plugin has ios variant
|
|
1293
|
+
const IOS_VARIANT_PLUGINS = [
|
|
1294
|
+
"saveToGalleryAndSaveAnyFile"
|
|
1295
|
+
];
|
|
1298
1296
|
|
|
1299
|
-
|
|
1297
|
+
let variants = [
|
|
1298
|
+
`${baseName}-${latestVersion}.js`
|
|
1299
|
+
];
|
|
1300
1300
|
|
|
1301
|
-
|
|
1302
|
-
|
|
1301
|
+
if (IOS_VARIANT_PLUGINS.includes(baseName)) {
|
|
1302
|
+
variants.push(`${baseName}-${latestVersion}-ios.js`);
|
|
1303
|
+
}
|
|
1303
1304
|
|
|
1304
|
-
|
|
1305
|
+
let downloaded = [];
|
|
1305
1306
|
|
|
1306
|
-
|
|
1307
|
+
// Download files
|
|
1308
|
+
for (const fileName of variants) {
|
|
1307
1309
|
|
|
1308
|
-
|
|
1310
|
+
const url = `https://htmlcodeplay.com/code-play-plugin/${fileName}`;
|
|
1309
1311
|
|
|
1310
|
-
|
|
1312
|
+
console.log(`🔍 Checking latest: ${fileName}`);
|
|
1311
1313
|
|
|
1312
|
-
|
|
1314
|
+
if (await urlExists(url)) {
|
|
1313
1315
|
|
|
1314
|
-
|
|
1316
|
+
const destPath = path.join(pluginDir, fileName);
|
|
1315
1317
|
|
|
1316
|
-
|
|
1317
|
-
}
|
|
1318
|
-
}
|
|
1318
|
+
await downloadFile(url, destPath);
|
|
1319
1319
|
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
console.log(
|
|
1323
|
-
return false;
|
|
1320
|
+
downloaded.push(fileName);
|
|
1321
|
+
|
|
1322
|
+
console.log(`⬇ Downloaded → ${fileName}`);
|
|
1324
1323
|
}
|
|
1324
|
+
}
|
|
1325
1325
|
|
|
1326
|
-
|
|
1327
|
-
|
|
1326
|
+
if (downloaded.length === 0) {
|
|
1327
|
+
console.log(`❌ No files downloaded for ${baseName}`);
|
|
1328
|
+
return false;
|
|
1329
|
+
}
|
|
1328
1330
|
|
|
1329
|
-
|
|
1331
|
+
// Remove ONLY versioned files (safe)
|
|
1332
|
+
const versionPattern = new RegExp(`^${baseName}-\\d+\\.\\d+(-ios)?\\.js$`);
|
|
1330
1333
|
|
|
1331
|
-
|
|
1332
|
-
file.startsWith(baseName + "-") &&
|
|
1333
|
-
file.endsWith(".js") &&
|
|
1334
|
-
!downloaded.includes(file)
|
|
1335
|
-
) {
|
|
1334
|
+
const existingFiles = fs.readdirSync(pluginDir);
|
|
1336
1335
|
|
|
1337
|
-
|
|
1336
|
+
existingFiles.forEach(file => {
|
|
1338
1337
|
|
|
1339
|
-
|
|
1338
|
+
if (
|
|
1339
|
+
versionPattern.test(file) &&
|
|
1340
|
+
!downloaded.includes(file)
|
|
1341
|
+
) {
|
|
1340
1342
|
|
|
1341
|
-
|
|
1342
|
-
}
|
|
1343
|
+
const oldPath = path.join(pluginDir, file);
|
|
1343
1344
|
|
|
1344
|
-
|
|
1345
|
+
fs.unlinkSync(oldPath);
|
|
1345
1346
|
|
|
1346
|
-
|
|
1347
|
+
console.log(`🗑 Removed old file → ${file}`);
|
|
1348
|
+
}
|
|
1347
1349
|
|
|
1348
|
-
|
|
1350
|
+
});
|
|
1349
1351
|
|
|
1350
|
-
|
|
1352
|
+
const newFileName = `${baseName}-${latestVersion}.js`;
|
|
1351
1353
|
|
|
1352
|
-
|
|
1354
|
+
updateImports(oldFileName, newFileName);
|
|
1355
|
+
//updateImports(baseName, `${baseName}-${latestVersion}.js`);
|
|
1356
|
+
//updateImports(pluginInfo.name, `${baseName}-${latestVersion}`);
|
|
1357
|
+
|
|
1358
|
+
//console.log(`✅ Updated → ${newFileName}`);
|
|
1359
|
+
//console.log(`✅ Updated → ${baseName}-${latestVersion}`);
|
|
1360
|
+
|
|
1361
|
+
return true;
|
|
1353
1362
|
}
|
|
1354
1363
|
|
|
1355
1364
|
|
|
@@ -1556,7 +1565,11 @@ if (hasMandatoryUpdate) {
|
|
|
1556
1565
|
process.exit(1);
|
|
1557
1566
|
}
|
|
1558
1567
|
|
|
1559
|
-
console.log('\n🎉 All mandatory plugins auto-updated!');
|
|
1568
|
+
console.log('\n🎉 All mandatory plugins auto-updated! Rechecking plugins...\n');
|
|
1569
|
+
|
|
1570
|
+
// Re-run plugin check so outdated list becomes empty
|
|
1571
|
+
await checkPlugins();
|
|
1572
|
+
return;
|
|
1560
1573
|
}
|
|
1561
1574
|
|
|
1562
1575
|
|