codeplay-common 3.1.0 → 3.1.2

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,25 @@ 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
+
1318
+
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;
1253
1325
 
1254
- const latestVersion = versions[baseName];
1326
+
1327
+ // Only common plugin has js and less variants
1328
+ if (baseName === "common") {
1329
+ if (ext === ".js") pluginKey = "common-js";
1330
+ if (ext === ".less") pluginKey = "common-less";
1331
+ }
1332
+
1333
+ const latestVersion = versions[pluginKey];
1255
1334
 
1256
1335
  if (!latestVersion) {
1257
1336
  console.log(`❌ No version entry for ${baseName}`);
@@ -1294,9 +1373,13 @@ const IOS_VARIANT_PLUGINS = [
1294
1373
  "saveToGalleryAndSaveAnyFile"
1295
1374
  ];
1296
1375
 
1297
- let variants = [
1376
+ /* let variants = [
1298
1377
  `${baseName}-${latestVersion}.js`
1299
- ];
1378
+ ]; */
1379
+
1380
+ //const ext = path.extname(oldFileName);
1381
+ const variants = [`${baseName.replace(ext,'')}-${latestVersion}${ext}`];
1382
+
1300
1383
 
1301
1384
  if (IOS_VARIANT_PLUGINS.includes(baseName)) {
1302
1385
  variants.push(`${baseName}-${latestVersion}-ios.js`);
@@ -1320,6 +1403,9 @@ for (const fileName of variants) {
1320
1403
  downloaded.push(fileName);
1321
1404
 
1322
1405
  console.log(`⬇ Downloaded → ${fileName}`);
1406
+
1407
+ //writeUpdateLine(`Downloaded: ${fileName}`);
1408
+
1323
1409
  }
1324
1410
  }
1325
1411
 
@@ -1329,7 +1415,8 @@ if (downloaded.length === 0) {
1329
1415
  }
1330
1416
 
1331
1417
  // Remove ONLY versioned files (safe)
1332
- const versionPattern = new RegExp(`^${baseName}-\\d+\\.\\d+(-ios)?\\.js$`);
1418
+ //const versionPattern = new RegExp(`^${baseName}-\\d+\\.\\d+(-ios)?\\.js$`);
1419
+ const versionPattern = new RegExp(`^${baseName}-\\d+\\.\\d+(-ios)?\\${ext}$`);
1333
1420
 
1334
1421
  const existingFiles = fs.readdirSync(pluginDir);
1335
1422
 
@@ -1345,11 +1432,15 @@ existingFiles.forEach(file => {
1345
1432
  fs.unlinkSync(oldPath);
1346
1433
 
1347
1434
  console.log(`🗑 Removed old file → ${file}`);
1435
+ //writeUpdateLine(`Removed old file: ${file}`);
1348
1436
  }
1349
1437
 
1350
1438
  });
1351
1439
 
1352
- const newFileName = `${baseName}-${latestVersion}.js`;
1440
+ //const newFileName = `${baseName}-${latestVersion}.js`;
1441
+ const newFileName = `${baseName}-${latestVersion}${ext}`;
1442
+
1443
+ writeUpdateLine(`${oldVersionFile} -> ${newFileName}`);
1353
1444
 
1354
1445
  updateImports(oldFileName, newFileName);
1355
1446
  //updateImports(baseName, `${baseName}-${latestVersion}.js`);
@@ -1599,6 +1690,7 @@ if (hasMandatoryUpdate) {
1599
1690
  );
1600
1691
  } else {
1601
1692
  console.log('✅ All plugin versions are up to date.');
1693
+ saveUpdateLogs();
1602
1694
  resolve();
1603
1695
  }
1604
1696
  });
@@ -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},