codeplay-common 4.4.2 → 4.4.4
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/files/finalrelease +123 -9
- package/files/take-screen-image.js +69 -19
- package/package.json +1 -1
package/files/finalrelease
CHANGED
|
@@ -16,11 +16,128 @@ import { dirname } from 'path';
|
|
|
16
16
|
/* const path = require('path');
|
|
17
17
|
const fs = require('fs'); */
|
|
18
18
|
|
|
19
|
-
import fs from 'fs';
|
|
20
|
-
import path from 'path';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
import fs from 'fs';
|
|
20
|
+
import path from 'path';
|
|
21
|
+
|
|
22
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
23
|
+
const __dirname = dirname(__filename);
|
|
24
|
+
|
|
25
|
+
function stripJavaScriptComments(content) {
|
|
26
|
+
let result = '';
|
|
27
|
+
let state = 'code';
|
|
28
|
+
|
|
29
|
+
for (let index = 0; index < content.length; index++) {
|
|
30
|
+
const character = content[index];
|
|
31
|
+
const nextCharacter = content[index + 1];
|
|
32
|
+
|
|
33
|
+
if (state === 'lineComment') {
|
|
34
|
+
if (character === '\n') {
|
|
35
|
+
result += character;
|
|
36
|
+
state = 'code';
|
|
37
|
+
} else {
|
|
38
|
+
result += ' ';
|
|
39
|
+
}
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (state === 'blockComment') {
|
|
44
|
+
if (character === '*' && nextCharacter === '/') {
|
|
45
|
+
result += ' ';
|
|
46
|
+
index++;
|
|
47
|
+
state = 'code';
|
|
48
|
+
} else {
|
|
49
|
+
result += character === '\n' ? '\n' : ' ';
|
|
50
|
+
}
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (state !== 'code') {
|
|
55
|
+
result += character;
|
|
56
|
+
|
|
57
|
+
if (character === '\\') {
|
|
58
|
+
if (nextCharacter !== undefined) {
|
|
59
|
+
result += nextCharacter;
|
|
60
|
+
index++;
|
|
61
|
+
}
|
|
62
|
+
} else if (
|
|
63
|
+
(state === 'singleQuote' && character === "'") ||
|
|
64
|
+
(state === 'doubleQuote' && character === '"') ||
|
|
65
|
+
(state === 'templateLiteral' && character === '`')
|
|
66
|
+
) {
|
|
67
|
+
state = 'code';
|
|
68
|
+
}
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (character === '/' && nextCharacter === '/') {
|
|
73
|
+
result += ' ';
|
|
74
|
+
index++;
|
|
75
|
+
state = 'lineComment';
|
|
76
|
+
} else if (character === '/' && nextCharacter === '*') {
|
|
77
|
+
result += ' ';
|
|
78
|
+
index++;
|
|
79
|
+
state = 'blockComment';
|
|
80
|
+
} else {
|
|
81
|
+
result += character;
|
|
82
|
+
|
|
83
|
+
if (character === "'") state = 'singleQuote';
|
|
84
|
+
else if (character === '"') state = 'doubleQuote';
|
|
85
|
+
else if (character === '`') state = 'templateLiteral';
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function checkProductionAdmobAlias() {
|
|
93
|
+
const possibleConfigFiles = ['vite.config.mjs', 'vite.config.js'];
|
|
94
|
+
const viteConfigPath = possibleConfigFiles
|
|
95
|
+
.map(configFile => resolve(__dirname, configFile))
|
|
96
|
+
.find(filePath => existsSync(filePath));
|
|
97
|
+
|
|
98
|
+
if (!viteConfigPath) {
|
|
99
|
+
console.error('❌ FINAL RELEASE BLOCKED: No vite.config.mjs or vite.config.js file found.');
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const viteConfigContent = stripJavaScriptComments(readFileSync(viteConfigPath, 'utf8'));
|
|
104
|
+
const aliasPattern = /(['"])@admob\1\s*:\s*path\.resolve\(\s*__dirname\s*,\s*(['"])([^'"\r\n]+)\2\s*\)/g;
|
|
105
|
+
const activeAliases = [...viteConfigContent.matchAll(aliasPattern)].map(match => match[3]);
|
|
106
|
+
const productionAliasPattern = /^\.\/src\/js\/Ads\/admob-emi-nextgen-\d+(?:\.\d+)+\.js$/;
|
|
107
|
+
|
|
108
|
+
if (activeAliases.length === 0) {
|
|
109
|
+
console.error('❌ FINAL RELEASE BLOCKED: The production @admob alias is commented out or missing in the Vite config.');
|
|
110
|
+
console.error(" Enable: '@admob': path.resolve(__dirname, './src/js/Ads/admob-emi-nextgen-x.x.js')");
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (activeAliases.length > 1) {
|
|
115
|
+
console.error('❌ FINAL RELEASE BLOCKED: Multiple active @admob aliases were found in the Vite config.');
|
|
116
|
+
console.error(' Keep exactly one active production admob-emi-nextgen-x.x.js alias.');
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const activeAlias = activeAliases[0];
|
|
121
|
+
if (!productionAliasPattern.test(activeAlias)) {
|
|
122
|
+
console.error(`❌ FINAL RELEASE BLOCKED: @admob currently points to '${activeAlias}'.`);
|
|
123
|
+
console.error(" It must point to './src/js/Ads/admob-emi-nextgen-x.x.js', not a test AdMob file.");
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const productionAdmobPath = resolve(__dirname, activeAlias);
|
|
128
|
+
if (!existsSync(productionAdmobPath)) {
|
|
129
|
+
console.error(`❌ FINAL RELEASE BLOCKED: The production @admob file does not exist: ${productionAdmobPath}`);
|
|
130
|
+
process.exit(1);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
console.log(`✅ Production @admob alias verified: ${activeAlias}`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// This must be the first release validation so test/no-ad builds cannot proceed.
|
|
137
|
+
checkProductionAdmobAlias();
|
|
138
|
+
|
|
139
|
+
// Define a mapping between store IDs and store names
|
|
140
|
+
/* const storeNames = {
|
|
24
141
|
"1": "PlayStore",
|
|
25
142
|
"2": "SamsungStore",
|
|
26
143
|
"7": "AmazonStore"
|
|
@@ -66,10 +183,7 @@ const _appPackageId=config.appId;
|
|
|
66
183
|
|
|
67
184
|
|
|
68
185
|
|
|
69
|
-
|
|
70
|
-
const __dirname = dirname(__filename);
|
|
71
|
-
|
|
72
|
-
function fileExists(filePath) {
|
|
186
|
+
function fileExists(filePath) {
|
|
73
187
|
return existsSync(filePath);
|
|
74
188
|
}
|
|
75
189
|
|
|
@@ -5,11 +5,21 @@ const { spawn, spawnSync } = require('node:child_process');
|
|
|
5
5
|
|
|
6
6
|
const screenshotDirectory = path.join(__dirname, 'Auto-Screenshot', 'Store-image-Screenshot');
|
|
7
7
|
const inFrameDirectory = path.join(__dirname, 'Auto-Screenshot', 'Store-image-Frame');
|
|
8
|
-
const amazonAssetsDirectory = path.join(__dirname, 'Auto-Screenshot', 'Amazon-
|
|
9
|
-
const samsungAssetsDirectory = path.join(__dirname, 'Auto-Screenshot', 'Samsung-
|
|
8
|
+
const amazonAssetsDirectory = path.join(__dirname, 'Auto-Screenshot', 'Amazon-Assets');
|
|
9
|
+
const samsungAssetsDirectory = path.join(__dirname, 'Auto-Screenshot', 'Samsung-Assets');
|
|
10
10
|
const capacitorConfigPath = path.join(__dirname, 'capacitor.config.json');
|
|
11
11
|
const amazonIconPath = path.join(__dirname, 'resources', 'icon-only.png');
|
|
12
12
|
const temporaryDirectory = path.join(__dirname, 'agent-temp');
|
|
13
|
+
const amazonAssetDefinitions = [
|
|
14
|
+
{ fileName: 'icon-1280x720.png', type: 'icon', width: 1280, height: 720 },
|
|
15
|
+
{ fileName: 'background-image-1920x1080.png', type: 'background-image', width: 1920, height: 1080 },
|
|
16
|
+
{ fileName: 'featured-content-logo-640x260.png', type: 'featured-logo', width: 640, height: 260, transparent: true },
|
|
17
|
+
{ fileName: 'featured-content-background-1920x720.png', type: 'featured-background', width: 1920, height: 720 },
|
|
18
|
+
];
|
|
19
|
+
const samsungAssetDefinitions = [
|
|
20
|
+
{ fileName: 'edge-screen-160x2560.png', type: 'edge-screen', width: 160, height: 2560 },
|
|
21
|
+
{ fileName: 'edge-screen-single-550x2560.png', type: 'edge-screen-single-plus', width: 550, height: 2560 },
|
|
22
|
+
];
|
|
13
23
|
const browserExecutablePaths = [
|
|
14
24
|
'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe',
|
|
15
25
|
'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe',
|
|
@@ -430,6 +440,8 @@ function printHelp() {
|
|
|
430
440
|
console.log(' node take-screen-image.js --samsung-assets');
|
|
431
441
|
console.log(' node take-screen-image.js --dry-run');
|
|
432
442
|
console.log(' node take-screen-image.js --list');
|
|
443
|
+
console.log('');
|
|
444
|
+
console.log('A normal capture automatically creates any missing Amazon and Samsung store assets.');
|
|
433
445
|
}
|
|
434
446
|
|
|
435
447
|
function selectProfiles(input) {
|
|
@@ -1510,7 +1522,7 @@ function createAmazonAssetHtml(asset, appName, iconBuffer, storeCopy) {
|
|
|
1510
1522
|
</html>`;
|
|
1511
1523
|
}
|
|
1512
1524
|
|
|
1513
|
-
async function createAmazonAssets(client) {
|
|
1525
|
+
async function createAmazonAssets(client, skipExisting = false) {
|
|
1514
1526
|
if (!fs.existsSync(amazonIconPath)) {
|
|
1515
1527
|
throw new Error(`Amazon asset source icon was not found: ${amazonIconPath}`);
|
|
1516
1528
|
}
|
|
@@ -1519,16 +1531,15 @@ async function createAmazonAssets(client) {
|
|
|
1519
1531
|
const appName = config.appName || 'App';
|
|
1520
1532
|
const storeCopy = getStoreAssetCopy(config);
|
|
1521
1533
|
const iconBuffer = fs.readFileSync(amazonIconPath);
|
|
1522
|
-
const assets = [
|
|
1523
|
-
{ fileName: 'icon-1280x720.png', type: 'icon', width: 1280, height: 720 },
|
|
1524
|
-
{ fileName: 'background-image-1920x1080.png', type: 'background-image', width: 1920, height: 1080 },
|
|
1525
|
-
{ fileName: 'featured-content-logo-640x260.png', type: 'featured-logo', width: 640, height: 260, transparent: true },
|
|
1526
|
-
{ fileName: 'featured-content-background-1920x720.png', type: 'featured-background', width: 1920, height: 720 },
|
|
1527
|
-
];
|
|
1528
|
-
|
|
1529
1534
|
fs.mkdirSync(amazonAssetsDirectory, { recursive: true });
|
|
1530
1535
|
|
|
1531
|
-
for (const asset of
|
|
1536
|
+
for (const asset of amazonAssetDefinitions) {
|
|
1537
|
+
const outputPath = path.join(amazonAssetsDirectory, asset.fileName);
|
|
1538
|
+
|
|
1539
|
+
if (skipExisting && fs.existsSync(outputPath)) {
|
|
1540
|
+
continue;
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1532
1543
|
await client.send('Emulation.setDeviceMetricsOverride', {
|
|
1533
1544
|
width: asset.width,
|
|
1534
1545
|
height: asset.height,
|
|
@@ -1562,7 +1573,6 @@ async function createAmazonAssets(client) {
|
|
|
1562
1573
|
captureBeyondViewport: false,
|
|
1563
1574
|
omitBackground: Boolean(asset.transparent),
|
|
1564
1575
|
});
|
|
1565
|
-
const outputPath = path.join(amazonAssetsDirectory, asset.fileName);
|
|
1566
1576
|
fs.writeFileSync(outputPath, Buffer.from(screenshot.data, 'base64'));
|
|
1567
1577
|
console.log(`Saved Amazon asset ${asset.width}x${asset.height}: ${outputPath}`);
|
|
1568
1578
|
}
|
|
@@ -1673,7 +1683,7 @@ function createSamsungAssetHtml(asset, appName, iconBuffer, storeCopy) {
|
|
|
1673
1683
|
</html>`;
|
|
1674
1684
|
}
|
|
1675
1685
|
|
|
1676
|
-
async function createSamsungAssets(client) {
|
|
1686
|
+
async function createSamsungAssets(client, skipExisting = false) {
|
|
1677
1687
|
if (!fs.existsSync(amazonIconPath)) {
|
|
1678
1688
|
throw new Error(`Samsung asset source icon was not found: ${amazonIconPath}`);
|
|
1679
1689
|
}
|
|
@@ -1682,15 +1692,17 @@ async function createSamsungAssets(client) {
|
|
|
1682
1692
|
const appName = config.appName || 'App';
|
|
1683
1693
|
const storeCopy = getStoreAssetCopy(config);
|
|
1684
1694
|
const iconBuffer = fs.readFileSync(amazonIconPath);
|
|
1685
|
-
const assets = [
|
|
1686
|
-
{ fileName: 'edge-screen-160x2560.png', type: 'edge-screen', width: 160, height: 2560 },
|
|
1687
|
-
{ fileName: 'edge-screen-single-plus-550x2560.png', type: 'edge-screen-single-plus', width: 550, height: 2560 },
|
|
1688
|
-
];
|
|
1689
1695
|
const maximumFileSize = 1024 * 1024;
|
|
1690
1696
|
|
|
1691
1697
|
fs.mkdirSync(samsungAssetsDirectory, { recursive: true });
|
|
1692
1698
|
|
|
1693
|
-
for (const asset of
|
|
1699
|
+
for (const asset of samsungAssetDefinitions) {
|
|
1700
|
+
const outputPath = path.join(samsungAssetsDirectory, asset.fileName);
|
|
1701
|
+
|
|
1702
|
+
if (skipExisting && fs.existsSync(outputPath)) {
|
|
1703
|
+
continue;
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1694
1706
|
await client.send('Emulation.setDeviceMetricsOverride', {
|
|
1695
1707
|
width: asset.width,
|
|
1696
1708
|
height: asset.height,
|
|
@@ -1719,7 +1731,6 @@ async function createSamsungAssets(client) {
|
|
|
1719
1731
|
fromSurface: true,
|
|
1720
1732
|
captureBeyondViewport: false,
|
|
1721
1733
|
});
|
|
1722
|
-
const outputPath = path.join(samsungAssetsDirectory, asset.fileName);
|
|
1723
1734
|
const outputBuffer = Buffer.from(screenshot.data, 'base64');
|
|
1724
1735
|
|
|
1725
1736
|
if (outputBuffer.length >= maximumFileSize) {
|
|
@@ -1736,6 +1747,41 @@ async function createSamsungAssets(client) {
|
|
|
1736
1747
|
}
|
|
1737
1748
|
}
|
|
1738
1749
|
|
|
1750
|
+
async function createMissingStoreAssets() {
|
|
1751
|
+
const hasMissingAmazonAssets = amazonAssetDefinitions.some((asset) => (
|
|
1752
|
+
!fs.existsSync(path.join(amazonAssetsDirectory, asset.fileName))
|
|
1753
|
+
));
|
|
1754
|
+
const hasMissingSamsungAssets = samsungAssetDefinitions.some((asset) => (
|
|
1755
|
+
!fs.existsSync(path.join(samsungAssetsDirectory, asset.fileName))
|
|
1756
|
+
));
|
|
1757
|
+
|
|
1758
|
+
if (!hasMissingAmazonAssets && !hasMissingSamsungAssets) {
|
|
1759
|
+
console.log('Amazon and Samsung store assets already exist.');
|
|
1760
|
+
return;
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
let browser;
|
|
1764
|
+
let client;
|
|
1765
|
+
|
|
1766
|
+
try {
|
|
1767
|
+
browser = await launchReplayBrowser();
|
|
1768
|
+
client = await createReplayPage(browser);
|
|
1769
|
+
|
|
1770
|
+
if (hasMissingAmazonAssets) {
|
|
1771
|
+
await createAmazonAssets(client, true);
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
if (hasMissingSamsungAssets) {
|
|
1775
|
+
await createSamsungAssets(client, true);
|
|
1776
|
+
}
|
|
1777
|
+
} finally {
|
|
1778
|
+
if (client) client.close();
|
|
1779
|
+
if (browser) await closeReplayBrowser(browser);
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
console.log('Missing Amazon and Samsung store assets created.');
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1739
1785
|
async function captureFramedScreenshot(
|
|
1740
1786
|
client,
|
|
1741
1787
|
screenshotBuffer,
|
|
@@ -2037,6 +2083,10 @@ async function main() {
|
|
|
2037
2083
|
return;
|
|
2038
2084
|
}
|
|
2039
2085
|
|
|
2086
|
+
if (!options.dryRun) {
|
|
2087
|
+
await createMissingStoreAssets();
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2040
2090
|
const selectedProfiles = selectProfiles(options.profiles);
|
|
2041
2091
|
|
|
2042
2092
|
if (options.frameExisting) {
|