codeplay-common 3.0.9 → 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,25 +1261,28 @@ 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}`);
|
|
1283
|
+
|
|
1284
|
+
return true;
|
|
1285
|
+
}
|
|
1287
1286
|
// ===============================
|
|
1288
1287
|
// FILE PLUGIN UPDATE
|
|
1289
1288
|
// ===============================
|
|
@@ -1353,8 +1352,11 @@ existingFiles.forEach(file => {
|
|
|
1353
1352
|
const newFileName = `${baseName}-${latestVersion}.js`;
|
|
1354
1353
|
|
|
1355
1354
|
updateImports(oldFileName, newFileName);
|
|
1355
|
+
//updateImports(baseName, `${baseName}-${latestVersion}.js`);
|
|
1356
|
+
//updateImports(pluginInfo.name, `${baseName}-${latestVersion}`);
|
|
1356
1357
|
|
|
1357
|
-
console.log(`✅ Updated → ${newFileName}`);
|
|
1358
|
+
//console.log(`✅ Updated → ${newFileName}`);
|
|
1359
|
+
//console.log(`✅ Updated → ${baseName}-${latestVersion}`);
|
|
1358
1360
|
|
|
1359
1361
|
return true;
|
|
1360
1362
|
}
|