codeplay-common 3.1.0 → 3.1.1

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/.gitattributes CHANGED
@@ -1,2 +1,2 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Merbin Joe
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Merbin Joe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
- # codeplay-common
2
- Everything automatted in Capacitor apps, easy to maintain many apps in capacitor. It will reduce your 40% of work, with common file code.
3
-
4
-
5
- Easy add splashscreen and set animation
6
- Admob id automatically from capacitor.config.json file
7
- Make three build file for different store as per our requirement
8
- Based on store install various IAP plugins
9
- Make it to ionic project
10
-
11
- Donate to get full code including many common functions
1
+ # codeplay-common
2
+ Everything automatted in Capacitor apps, easy to maintain many apps in capacitor. It will reduce your 40% of work, with common file code.
3
+
4
+
5
+ Easy add splashscreen and set animation
6
+ Admob id automatically from capacitor.config.json file
7
+ Make three build file for different store as per our requirement
8
+ Based on store install various IAP plugins
9
+ Make it to ionic project
10
+
11
+ Donate to get full code including many common functions
12
12
  https://ko-fi.com/codeplay
@@ -15,6 +15,7 @@ const ENABLE_AUTO_UPDATE = true;
15
15
  const USE_LIVE_SERVER_VERSION = true;
16
16
 
17
17
  const configPath = path.join(process.cwd(), 'capacitor.config.json');
18
+ const updateLogFile = path.join(process.cwd(), "", "plugin-update-log.txt");
18
19
 
19
20
  // Expected plugin list with minimum versions
20
21
  /* const requiredPlugins = [
@@ -74,6 +75,69 @@ const AdmZip = requireOrInstall("adm-zip");
74
75
 
75
76
 
76
77
 
78
+ const pkg = require(path.join(process.cwd(), 'node_modules', 'codeplay-common', 'package.json'));
79
+
80
+ const pluginName = pkg.name;
81
+ const pluginVersion = pkg.version;
82
+
83
+ let updateLogs = [];
84
+
85
+ function writeUpdateLine(message) {
86
+ updateLogs.push(message);
87
+ }
88
+
89
+ const MAX_LOG_BLOCKS = 50;
90
+
91
+ function saveUpdateLogs() {
92
+
93
+ if (updateLogs.length === 0) return;
94
+
95
+ const logDir = path.dirname(updateLogFile);
96
+
97
+ if (!fs.existsSync(logDir)) {
98
+ fs.mkdirSync(logDir, { recursive: true });
99
+ }
100
+
101
+ const now = new Date();
102
+
103
+ const formattedTime = now.toLocaleString('en-GB', {
104
+ day: '2-digit',
105
+ month: '2-digit',
106
+ year: 'numeric',
107
+ hour: '2-digit',
108
+ minute: '2-digit',
109
+ hour12: true
110
+ }).replace(',', '').replace(/\//g, '-');
111
+
112
+ let newBlock = `${pluginName}: ${pluginVersion}\n[${formattedTime}]\n`;
113
+
114
+ updateLogs.forEach(line => {
115
+ newBlock += `${line}\n`;
116
+ });
117
+
118
+ newBlock += "\n";
119
+
120
+ let existingLog = "";
121
+
122
+ if (fs.existsSync(updateLogFile)) {
123
+ existingLog = fs.readFileSync(updateLogFile, "utf8");
124
+ }
125
+
126
+ let combinedLog = newBlock + existingLog;
127
+
128
+ // Split blocks by plugin header
129
+ const blocks = combinedLog.split(/\n(?=codeplay-common:)/);
130
+
131
+ // Keep only latest 50
132
+ const trimmed = blocks.slice(0, MAX_LOG_BLOCKS).join("\n");
133
+
134
+ fs.writeFileSync(updateLogFile, trimmed);
135
+
136
+ }
137
+
138
+
139
+
140
+
77
141
 
78
142
  const versionsFile = path.join(__dirname, "versions.json");
79
143
 
@@ -1248,10 +1312,21 @@ async function autoUpdatePlugin(pluginDef, pluginInfo) {
1248
1312
  const oldFullPath = path.join(srcDir, pluginInfo.name);
1249
1313
  const oldFileName = path.basename(oldFullPath);
1250
1314
 
1251
- // Extract base name
1252
- const baseName = oldFileName.replace(/-\d+\.\d+.*$/, "");
1315
+ //const oldFileName = path.basename(oldFullPath);
1316
+ const oldVersionFile = oldFileName;
1317
+
1253
1318
 
1254
- const latestVersion = versions[baseName];
1319
+ const ext = path.extname(oldFileName); // .js or .less
1320
+ //const baseName = oldFileName.replace(/-\d+\.\d+.*$/, "");
1321
+ const baseName = oldFileName.replace(/-\d+\.\d+.*$/, '').replace(/\.(js|less)$/, '');
1322
+
1323
+ // version lookup key
1324
+ let pluginKey = baseName;
1325
+
1326
+ if (ext === ".js") pluginKey = `${baseName}-js`;
1327
+ if (ext === ".less") pluginKey = `${baseName}-less`;
1328
+
1329
+ const latestVersion = versions[pluginKey];
1255
1330
 
1256
1331
  if (!latestVersion) {
1257
1332
  console.log(`❌ No version entry for ${baseName}`);
@@ -1294,9 +1369,13 @@ const IOS_VARIANT_PLUGINS = [
1294
1369
  "saveToGalleryAndSaveAnyFile"
1295
1370
  ];
1296
1371
 
1297
- let variants = [
1372
+ /* let variants = [
1298
1373
  `${baseName}-${latestVersion}.js`
1299
- ];
1374
+ ]; */
1375
+
1376
+ //const ext = path.extname(oldFileName);
1377
+ const variants = [`${baseName.replace(ext,'')}-${latestVersion}${ext}`];
1378
+
1300
1379
 
1301
1380
  if (IOS_VARIANT_PLUGINS.includes(baseName)) {
1302
1381
  variants.push(`${baseName}-${latestVersion}-ios.js`);
@@ -1320,6 +1399,9 @@ for (const fileName of variants) {
1320
1399
  downloaded.push(fileName);
1321
1400
 
1322
1401
  console.log(`⬇ Downloaded → ${fileName}`);
1402
+
1403
+ //writeUpdateLine(`Downloaded: ${fileName}`);
1404
+
1323
1405
  }
1324
1406
  }
1325
1407
 
@@ -1329,7 +1411,8 @@ if (downloaded.length === 0) {
1329
1411
  }
1330
1412
 
1331
1413
  // Remove ONLY versioned files (safe)
1332
- const versionPattern = new RegExp(`^${baseName}-\\d+\\.\\d+(-ios)?\\.js$`);
1414
+ //const versionPattern = new RegExp(`^${baseName}-\\d+\\.\\d+(-ios)?\\.js$`);
1415
+ const versionPattern = new RegExp(`^${baseName}-\\d+\\.\\d+(-ios)?\\${ext}$`);
1333
1416
 
1334
1417
  const existingFiles = fs.readdirSync(pluginDir);
1335
1418
 
@@ -1345,11 +1428,15 @@ existingFiles.forEach(file => {
1345
1428
  fs.unlinkSync(oldPath);
1346
1429
 
1347
1430
  console.log(`🗑 Removed old file → ${file}`);
1431
+ //writeUpdateLine(`Removed old file: ${file}`);
1348
1432
  }
1349
1433
 
1350
1434
  });
1351
1435
 
1352
- const newFileName = `${baseName}-${latestVersion}.js`;
1436
+ //const newFileName = `${baseName}-${latestVersion}.js`;
1437
+ const newFileName = `${baseName}-${latestVersion}${ext}`;
1438
+
1439
+ writeUpdateLine(`${oldVersionFile} -> ${newFileName}`);
1353
1440
 
1354
1441
  updateImports(oldFileName, newFileName);
1355
1442
  //updateImports(baseName, `${baseName}-${latestVersion}.js`);
@@ -1599,6 +1686,7 @@ if (hasMandatoryUpdate) {
1599
1686
  );
1600
1687
  } else {
1601
1688
  console.log('✅ All plugin versions are up to date.');
1689
+ saveUpdateLogs();
1602
1690
  resolve();
1603
1691
  }
1604
1692
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "plugins":[
3
3
  {"name":"backbutton","pattern":"backbutton-(\\d+\\.\\d+)\\.js$","minVersion":"2.0","baseDir":"js","mandatoryUpdate":true},
4
- {"name":"common","pattern":"common-(\\d+\\.\\d+)(?:-beta-(\\d+))?\\.js$","minVersion":"6.0","baseDir":"js","mandatoryUpdate":true},
4
+ {"name":"common-js","pattern":"common-(\\d+\\.\\d+)(?:-beta-(\\d+))?\\.js$","minVersion":"6.0","baseDir":"js","mandatoryUpdate":true},
5
5
  {"name":"localization_settings","pattern":"localization_settings-(\\d+\\.\\d+)\\.js$","minVersion":"1.1","baseDir":"js","mandatoryUpdate":true},
6
6
  {"name":"localization","pattern":"localization-(\\d+\\.\\d+)\\.js$","minVersion":"1.5","baseDir":"js","mandatoryUpdate":true},
7
7
  {"name":"admob-emi","pattern":"Ads[\\\\/]admob-emi-(\\d+\\.\\d+)\\.js$","minVersion":"3.7","baseDir":"js","mandatoryUpdate":true},
@@ -12,7 +12,7 @@
12
12
  {"name":"theme","pattern":"theme-(\\d+\\.\\d+)$","minVersion":"3.3","baseDir":"theme","destDir":"theme","mandatoryUpdate":true,"isFolder":true},
13
13
  {"name":"certificatejs","pattern":"certificatejs-(\\d+\\.\\d+)$","minVersion":"1.6","baseDir":"certificate","destDir":"certificate","mandatoryUpdate":true,"isFolder":true},
14
14
  {"name":"IAP","pattern":"IAP-(\\d+\\.\\d+)$","minVersion":"2.8","baseDir":"js/Ads","mandatoryUpdate":true,"isFolder":true},
15
- {"name":"common-css","pattern":"common-(\\d+\\.\\d+)\\.less$","minVersion":"1.6","baseDir":"assets/css","mandatoryUpdate":true},
15
+ {"name":"common-less","pattern":"common-(\\d+\\.\\d+)\\.less$","minVersion":"1.7","baseDir":"assets/css","mandatoryUpdate":true},
16
16
  {"name":"localNotification_AppSettings","pattern":"localNotification_AppSettings-(\\d+\\.\\d+)\\.js$","minVersion":"1.0","baseDir":"js","mandatoryUpdate":true},
17
17
  {"name":"localNotification","pattern":"localNotification-(\\d+\\.\\d+)\\.js$","minVersion":"2.2","baseDir":"js","mandatoryUpdate":true},
18
18
  {"name":"onesignal","pattern":"onesignal-(\\d+\\.\\d+)\\.js$","minVersion":"2.3","baseDir":"js","mandatoryUpdate":true},