codeplay-common 4.3.0 → 4.3.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.
@@ -275,14 +275,14 @@ const checkIsAdsDisableByReturnStatement=()=>{
275
275
 
276
276
 
277
277
  const adsFolder = join('src', 'js', 'Ads');
278
- const filePattern = /^admob-emi-nextgen-(\d+\.)+\d+\.js$/;
278
+ const filePattern = /^admob-emi-nextgen-(\d+\.)+\d+\.js$/;
279
279
 
280
280
  // Step 1: Find the admob file
281
281
  const files = readdirSync(adsFolder);
282
282
  const admobFile = files.find(f => filePattern.test(f));
283
283
 
284
284
  if (!admobFile) {
285
- console.log('❌ No Admob nextgen file found.');
285
+ console.log('❌ No Admob nextgen file found.');
286
286
  process.exit(1);
287
287
  }
288
288
 
@@ -714,11 +714,11 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
714
714
 
715
715
 
716
716
  // Copy the built files to the appropriate folder
717
- const src = join("www", "*");
717
+ const src = join("www");
718
718
  const dest = join("android", "app", "src", "main", "assets", "public");
719
719
 
720
- // Use 'xcopy' command for Windows
721
- execSync(`xcopy ${src} ${dest} /E /I /Y`, { stdio: 'inherit' });
720
+ // Copy the web build with Node so releases work on every platform.
721
+ fs.cpSync(src, dest, { recursive: true, force: true });
722
722
 
723
723
  // Build Android AAB file
724
724
  //child_process.execSync('cd android && ./gradlew bundleRelease', { stdio: 'inherit' });
@@ -0,0 +1,110 @@
1
+ const fs = require('node:fs');
2
+ const path = require('node:path');
3
+ const readline = require('node:readline');
4
+ const { spawnSync } = require('node:child_process');
5
+
6
+ const screenshotDirectory = path.join(__dirname, 'Auto-Screenshot');
7
+
8
+ function getNextNumberedPath() {
9
+ const highestNumber = fs.readdirSync(screenshotDirectory, { withFileTypes: true })
10
+ .filter((entry) => entry.isFile())
11
+ .reduce((highest, entry) => {
12
+ const match = entry.name.match(/^(\d+)\.png$/i);
13
+ return match ? Math.max(highest, Number(match[1])) : highest;
14
+ }, 0);
15
+
16
+ return path.join(screenshotDirectory, `${highestNumber + 1}.png`);
17
+ }
18
+
19
+ function getCustomPath(input) {
20
+ let fileName = input.trim().replace(/\.png$/i, '');
21
+ fileName = fileName
22
+ .replace(/[<>:"/\\|?*\u0000-\u001F]/g, '_')
23
+ .replace(/[. ]+$/g, '');
24
+
25
+ if (!fileName) {
26
+ return getNextNumberedPath();
27
+ }
28
+
29
+ if (/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(fileName)) {
30
+ fileName = `${fileName}_`;
31
+ }
32
+
33
+ let screenshotPath = path.join(screenshotDirectory, `${fileName}.png`);
34
+ let duplicateNumber = 2;
35
+
36
+ while (fs.existsSync(screenshotPath)) {
37
+ screenshotPath = path.join(
38
+ screenshotDirectory,
39
+ `${fileName}-${duplicateNumber}.png`,
40
+ );
41
+ duplicateNumber += 1;
42
+ }
43
+
44
+ return screenshotPath;
45
+ }
46
+
47
+ function takeScreenshot(fileNameInput) {
48
+ const result = spawnSync('adb', ['exec-out', 'screencap', '-p'], {
49
+ encoding: null,
50
+ maxBuffer: 100 * 1024 * 1024,
51
+ timeout: 30000,
52
+ windowsHide: true,
53
+ });
54
+
55
+ if (result.error) {
56
+ if (result.error.code === 'ENOENT') {
57
+ throw new Error('ADB was not found. Add Android platform-tools to your PATH.');
58
+ }
59
+
60
+ if (result.error.code === 'ETIMEDOUT') {
61
+ throw new Error('ADB did not respond within 30 seconds. Check the device connection.');
62
+ }
63
+
64
+ throw result.error;
65
+ }
66
+
67
+ if (result.status !== 0) {
68
+ const adbMessage = result.stderr.toString().trim();
69
+ throw new Error(adbMessage || `ADB exited with code ${result.status}.`);
70
+ }
71
+
72
+ if (!result.stdout.length) {
73
+ throw new Error('ADB returned an empty screenshot. Check the connected device.');
74
+ }
75
+
76
+ const screenshotPath = fileNameInput.trim()
77
+ ? getCustomPath(fileNameInput)
78
+ : getNextNumberedPath();
79
+
80
+ fs.writeFileSync(screenshotPath, result.stdout, { flag: 'wx' });
81
+ return screenshotPath;
82
+ }
83
+
84
+ fs.mkdirSync(screenshotDirectory, { recursive: true });
85
+
86
+ const terminal = readline.createInterface({
87
+ input: process.stdin,
88
+ output: process.stdout,
89
+ prompt: 'Enter a filename, or press Enter for the next number: ',
90
+ });
91
+
92
+ console.log(`Screenshots will be saved in: ${screenshotDirectory}`);
93
+ console.log('Press Ctrl+C to exit.');
94
+ terminal.prompt();
95
+
96
+ terminal.on('line', (fileNameInput) => {
97
+ try {
98
+ const screenshotPath = takeScreenshot(fileNameInput);
99
+ console.log(`Screenshot saved: ${screenshotPath}`);
100
+ } catch (error) {
101
+ console.error(`Screenshot failed: ${error.message}`);
102
+ }
103
+
104
+ terminal.prompt();
105
+ });
106
+
107
+ terminal.on('SIGINT', () => {
108
+ console.log('\nScreenshot tool closed.');
109
+ terminal.close();
110
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeplay-common",
3
- "version": "4.3.0",
3
+ "version": "4.3.2",
4
4
  "description": "Common build scripts and files",
5
5
  "scripts": {
6
6
  "postinstall": "node scripts/sync-files.js",