codeplay-common 4.11.30 → 4.11.32
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/CHANGELOG.md +115 -115
- package/LICENSE +21 -21
- package/README.md +368 -368
- package/RELEASE_NOTES.md +97 -97
- package/files/buildCodeplay/HUAWEI-PRIVACY.md +9 -9
- package/files/buildCodeplay/add-splash-screen.js +255 -255
- package/files/buildCodeplay/apk-store-builder.js +97 -97
- package/files/buildCodeplay/codeplayBeforeBuild.js +4769 -4756
- package/files/buildCodeplay/disabled-ads.mjs +45 -45
- package/files/buildCodeplay/ensure-current-build.cjs +42 -42
- package/files/buildCodeplay/fix-onesignal-plugin.js +96 -96
- package/files/buildCodeplay/huawei-privacy-entry.js +135 -135
- package/files/buildCodeplay/huawei-privacy.cjs +92 -92
- package/files/buildCodeplay/huawei-privacy.css +22 -22
- package/files/buildCodeplay/iap-alias.cjs +108 -116
- package/files/buildCodeplay/ios-ad-consent.cjs +56 -56
- package/files/buildCodeplay/ios-emi-admob-modification.js +49 -49
- package/files/buildCodeplay/manifestModification.js +38 -38
- package/files/buildCodeplay/migrate-system-bars.cjs +122 -115
- package/files/buildCodeplay/newly added.txt +89 -89
- package/files/buildCodeplay/non-google-billing.pro +3 -3
- package/files/buildCodeplay/packageidBaseModification.js +528 -528
- package/files/buildCodeplay/project-scripts.cjs +69 -69
- package/files/buildCodeplay/release-sync.config.json +4 -4
- package/files/buildCodeplay/remove-force-kotlin-disable.js +43 -43
- package/files/buildCodeplay/ruads.cjs +211 -211
- package/files/buildCodeplay/saf-mediastore-dependency.cjs +21 -21
- package/files/buildCodeplay/setSplashAnimation.js +226 -226
- package/files/buildCodeplay/setup-ruads.cjs +55 -55
- package/files/buildCodeplay/splashxml/codeplay_splashScreen.xml +11 -11
- package/files/buildCodeplay/store-billing.cjs +43 -43
- package/files/buildCodeplay/sync-admob-nextgen.js +219 -219
- package/files/buildCodeplay/tests/huawei-privacy.test.cjs +49 -49
- package/files/buildCodeplay/tests/huawei-vite.test.cjs +35 -35
- package/files/buildCodeplay/versions.json +28 -28
- package/files/finalrelease +1365 -1365
- package/files/generate-ai-promo-video.js +23 -23
- package/files/ionic.config.json +6 -6
- package/files/scripts-common/generate-baseline-profile.js +46 -46
- package/files/scripts-common/run-codeplay-sync-after.js +21 -21
- package/files/scripts-common/screenshot/background-decorations.js +120 -120
- package/files/scripts-common/screenshot/frame-samples.js +117 -117
- package/files/scripts-common/setup-baseline-profile.js +291 -291
- package/files/take-screen-image.js +4414 -4414
- package/files/take-screen-video.js +644 -644
- package/package.json +3 -2
- package/runtime/vk-ads/vk-ad-configuration.json +39 -39
- package/scripts/ensure-current-build.test.cjs +76 -76
- package/scripts/iap-alias.test.cjs +78 -117
- package/scripts/ios-ad-consent.test.cjs +99 -99
- package/scripts/ruads-install.test.cjs +180 -180
- package/scripts/ruads-policy.test.cjs +174 -174
- package/scripts/saf-mediastore-dependency.test.cjs +44 -44
- package/scripts/sync-files.js +120 -120
- package/scripts/system-bars-package.test.cjs +38 -0
- package/scripts/system-bars.test.cjs +93 -77
- package/scripts/uninstall.js +2 -2
- package/scripts/vite-build-settings.test.cjs +92 -92
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codeplay-common",
|
|
3
|
-
"version": "4.11.
|
|
3
|
+
"version": "4.11.32",
|
|
4
4
|
"description": "Common build scripts and files",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"postinstall": "node scripts/sync-files.js",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"adm-zip": "^0.6.1",
|
|
11
|
-
"plist": "^3.1.0"
|
|
11
|
+
"plist": "^3.1.0",
|
|
12
|
+
"terser": "^5.51.4"
|
|
12
13
|
},
|
|
13
14
|
"repository": {
|
|
14
15
|
"type": "git",
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
{
|
|
2
|
-
"VERSION": "1.2",
|
|
3
|
-
"android": {
|
|
4
|
-
"HuaweiStore": {
|
|
5
|
-
"appId": 0,
|
|
6
|
-
"bannerSlotId": 0,
|
|
7
|
-
"interstitialSlotId": 0,
|
|
8
|
-
"rewardedSlotId": 0
|
|
9
|
-
},
|
|
10
|
-
"RuStore": {
|
|
11
|
-
"appId": 0,
|
|
12
|
-
"bannerSlotId": 0,
|
|
13
|
-
"interstitialSlotId": 0,
|
|
14
|
-
"rewardedSlotId": 0
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"config": {
|
|
18
|
-
"isTesting": false,
|
|
19
|
-
"bannerEnabled": true,
|
|
20
|
-
"bannerSize": "320x50",
|
|
21
|
-
"bannerDisabledPages": [],
|
|
22
|
-
"bannerStartupDelayMs": 3000,
|
|
23
|
-
"interstitialEnabled": true,
|
|
24
|
-
"interstitialStartupDelayMs": 30000,
|
|
25
|
-
"minimumClick": 2,
|
|
26
|
-
"interstitialFirstTimeOutMs": 252000,
|
|
27
|
-
"interstitialTimeOutMs": 360000,
|
|
28
|
-
"interstitialPerSession": 8,
|
|
29
|
-
"rewardVideoEnabled": true,
|
|
30
|
-
"userAgeRestricted": false,
|
|
31
|
-
"retryDelayMs": 30000,
|
|
32
|
-
"debug": false
|
|
33
|
-
},
|
|
34
|
-
"testid": {
|
|
35
|
-
"bannerSlotId": 794557,
|
|
36
|
-
"interstitialSlotId": 6481,
|
|
37
|
-
"rewardedSlotId": 45101
|
|
38
|
-
}
|
|
39
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"VERSION": "1.2",
|
|
3
|
+
"android": {
|
|
4
|
+
"HuaweiStore": {
|
|
5
|
+
"appId": 0,
|
|
6
|
+
"bannerSlotId": 0,
|
|
7
|
+
"interstitialSlotId": 0,
|
|
8
|
+
"rewardedSlotId": 0
|
|
9
|
+
},
|
|
10
|
+
"RuStore": {
|
|
11
|
+
"appId": 0,
|
|
12
|
+
"bannerSlotId": 0,
|
|
13
|
+
"interstitialSlotId": 0,
|
|
14
|
+
"rewardedSlotId": 0
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"config": {
|
|
18
|
+
"isTesting": false,
|
|
19
|
+
"bannerEnabled": true,
|
|
20
|
+
"bannerSize": "320x50",
|
|
21
|
+
"bannerDisabledPages": [],
|
|
22
|
+
"bannerStartupDelayMs": 3000,
|
|
23
|
+
"interstitialEnabled": true,
|
|
24
|
+
"interstitialStartupDelayMs": 30000,
|
|
25
|
+
"minimumClick": 2,
|
|
26
|
+
"interstitialFirstTimeOutMs": 252000,
|
|
27
|
+
"interstitialTimeOutMs": 360000,
|
|
28
|
+
"interstitialPerSession": 8,
|
|
29
|
+
"rewardVideoEnabled": true,
|
|
30
|
+
"userAgeRestricted": false,
|
|
31
|
+
"retryDelayMs": 30000,
|
|
32
|
+
"debug": false
|
|
33
|
+
},
|
|
34
|
+
"testid": {
|
|
35
|
+
"bannerSlotId": 794557,
|
|
36
|
+
"interstitialSlotId": 6481,
|
|
37
|
+
"rewardedSlotId": 45101
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
const { test } = require('node:test');
|
|
2
|
-
const assert = require('node:assert/strict');
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const os = require('os');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
const { ensureCurrentBuild } = require('../files/buildCodeplay/ensure-current-build.cjs');
|
|
7
|
-
const { removeVersionedBuildScripts } = require('../files/buildCodeplay/project-scripts.cjs');
|
|
8
|
-
|
|
9
|
-
function fixture(t, names = []) {
|
|
10
|
-
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'codeplay-legacy-build-'));
|
|
11
|
-
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
|
|
12
|
-
fs.mkdirSync(path.join(root, 'buildCodeplay'));
|
|
13
|
-
for (const name of ['codeplayBeforeBuild.js', ...names]) fs.writeFileSync(path.join(root, 'buildCodeplay', name), '');
|
|
14
|
-
return root;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
test('current structure continues without npm commands', t => {
|
|
18
|
-
const projectRoot = fixture(t, ['versions.json', 'custom-helper.js']);
|
|
19
|
-
assert.equal(ensureCurrentBuild({ projectRoot, runNpm: () => assert.fail('unexpected npm command') }), false);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('legacy files force ordered reinstall and fresh preparation before continuing', t => {
|
|
23
|
-
const projectRoot = fixture(t, ['codeplayBeforeBuild-6.7.js', 'setSplashAnimation-1.2.mjs']);
|
|
24
|
-
const calls = [];
|
|
25
|
-
assert.equal(ensureCurrentBuild({
|
|
26
|
-
projectRoot,
|
|
27
|
-
runNpm(command) {
|
|
28
|
-
calls.push(command);
|
|
29
|
-
if (command === 'npm install codeplay-common') removeVersionedBuildScripts(projectRoot);
|
|
30
|
-
},
|
|
31
|
-
runBeforeBuild(script) {
|
|
32
|
-
assert.equal(script, path.join(projectRoot, 'buildCodeplay', 'codeplayBeforeBuild.js'));
|
|
33
|
-
calls.push('fresh preparation');
|
|
34
|
-
},
|
|
35
|
-
}), true);
|
|
36
|
-
assert.deepEqual(calls, ['npm uninstall codeplay-common', 'npm install codeplay-common', 'fresh preparation']);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
for (const failedCommand of ['npm uninstall codeplay-common', 'npm install codeplay-common']) {
|
|
40
|
-
test(`failure of ${failedCommand} stops preparation`, t => {
|
|
41
|
-
const projectRoot = fixture(t, ['add-splash-screen-1.0.js']);
|
|
42
|
-
const calls = [];
|
|
43
|
-
assert.throws(() => ensureCurrentBuild({
|
|
44
|
-
projectRoot,
|
|
45
|
-
runNpm(command) {
|
|
46
|
-
calls.push(command);
|
|
47
|
-
if (command === failedCommand) throw new Error('npm failed');
|
|
48
|
-
},
|
|
49
|
-
runBeforeBuild: () => assert.fail('must not continue'),
|
|
50
|
-
}), /npm failed/);
|
|
51
|
-
assert.equal(calls.at(-1), failedCommand);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
test('unknown versioned files trigger reinstall but stop without deleting app files or looping', t => {
|
|
56
|
-
const projectRoot = fixture(t, ['custom-helper-1.0.js']);
|
|
57
|
-
const calls = [];
|
|
58
|
-
assert.throws(() => ensureCurrentBuild({
|
|
59
|
-
projectRoot,
|
|
60
|
-
runNpm: command => calls.push(command),
|
|
61
|
-
runBeforeBuild: () => assert.fail('must not continue'),
|
|
62
|
-
}), /Legacy buildCodeplay files remain/);
|
|
63
|
-
assert.deepEqual(calls, ['npm uninstall codeplay-common', 'npm install codeplay-common']);
|
|
64
|
-
assert.ok(fs.existsSync(path.join(projectRoot, 'buildCodeplay', 'custom-helper-1.0.js')));
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
test('failed refreshed preparation propagates to stop the build', t => {
|
|
68
|
-
const projectRoot = fixture(t, ['packageidBaseModification-1.0.js']);
|
|
69
|
-
assert.throws(() => ensureCurrentBuild({
|
|
70
|
-
projectRoot,
|
|
71
|
-
runNpm(command) {
|
|
72
|
-
if (command === 'npm install codeplay-common') removeVersionedBuildScripts(projectRoot);
|
|
73
|
-
},
|
|
74
|
-
runBeforeBuild() { throw Object.assign(new Error('preparation failed'), { status: 7 }); },
|
|
75
|
-
}), { message: 'preparation failed', status: 7 });
|
|
76
|
-
});
|
|
1
|
+
const { test } = require('node:test');
|
|
2
|
+
const assert = require('node:assert/strict');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const { ensureCurrentBuild } = require('../files/buildCodeplay/ensure-current-build.cjs');
|
|
7
|
+
const { removeVersionedBuildScripts } = require('../files/buildCodeplay/project-scripts.cjs');
|
|
8
|
+
|
|
9
|
+
function fixture(t, names = []) {
|
|
10
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'codeplay-legacy-build-'));
|
|
11
|
+
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
|
|
12
|
+
fs.mkdirSync(path.join(root, 'buildCodeplay'));
|
|
13
|
+
for (const name of ['codeplayBeforeBuild.js', ...names]) fs.writeFileSync(path.join(root, 'buildCodeplay', name), '');
|
|
14
|
+
return root;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
test('current structure continues without npm commands', t => {
|
|
18
|
+
const projectRoot = fixture(t, ['versions.json', 'custom-helper.js']);
|
|
19
|
+
assert.equal(ensureCurrentBuild({ projectRoot, runNpm: () => assert.fail('unexpected npm command') }), false);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('legacy files force ordered reinstall and fresh preparation before continuing', t => {
|
|
23
|
+
const projectRoot = fixture(t, ['codeplayBeforeBuild-6.7.js', 'setSplashAnimation-1.2.mjs']);
|
|
24
|
+
const calls = [];
|
|
25
|
+
assert.equal(ensureCurrentBuild({
|
|
26
|
+
projectRoot,
|
|
27
|
+
runNpm(command) {
|
|
28
|
+
calls.push(command);
|
|
29
|
+
if (command === 'npm install codeplay-common') removeVersionedBuildScripts(projectRoot);
|
|
30
|
+
},
|
|
31
|
+
runBeforeBuild(script) {
|
|
32
|
+
assert.equal(script, path.join(projectRoot, 'buildCodeplay', 'codeplayBeforeBuild.js'));
|
|
33
|
+
calls.push('fresh preparation');
|
|
34
|
+
},
|
|
35
|
+
}), true);
|
|
36
|
+
assert.deepEqual(calls, ['npm uninstall codeplay-common', 'npm install codeplay-common', 'fresh preparation']);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
for (const failedCommand of ['npm uninstall codeplay-common', 'npm install codeplay-common']) {
|
|
40
|
+
test(`failure of ${failedCommand} stops preparation`, t => {
|
|
41
|
+
const projectRoot = fixture(t, ['add-splash-screen-1.0.js']);
|
|
42
|
+
const calls = [];
|
|
43
|
+
assert.throws(() => ensureCurrentBuild({
|
|
44
|
+
projectRoot,
|
|
45
|
+
runNpm(command) {
|
|
46
|
+
calls.push(command);
|
|
47
|
+
if (command === failedCommand) throw new Error('npm failed');
|
|
48
|
+
},
|
|
49
|
+
runBeforeBuild: () => assert.fail('must not continue'),
|
|
50
|
+
}), /npm failed/);
|
|
51
|
+
assert.equal(calls.at(-1), failedCommand);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
test('unknown versioned files trigger reinstall but stop without deleting app files or looping', t => {
|
|
56
|
+
const projectRoot = fixture(t, ['custom-helper-1.0.js']);
|
|
57
|
+
const calls = [];
|
|
58
|
+
assert.throws(() => ensureCurrentBuild({
|
|
59
|
+
projectRoot,
|
|
60
|
+
runNpm: command => calls.push(command),
|
|
61
|
+
runBeforeBuild: () => assert.fail('must not continue'),
|
|
62
|
+
}), /Legacy buildCodeplay files remain/);
|
|
63
|
+
assert.deepEqual(calls, ['npm uninstall codeplay-common', 'npm install codeplay-common']);
|
|
64
|
+
assert.ok(fs.existsSync(path.join(projectRoot, 'buildCodeplay', 'custom-helper-1.0.js')));
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('failed refreshed preparation propagates to stop the build', t => {
|
|
68
|
+
const projectRoot = fixture(t, ['packageidBaseModification-1.0.js']);
|
|
69
|
+
assert.throws(() => ensureCurrentBuild({
|
|
70
|
+
projectRoot,
|
|
71
|
+
runNpm(command) {
|
|
72
|
+
if (command === 'npm install codeplay-common') removeVersionedBuildScripts(projectRoot);
|
|
73
|
+
},
|
|
74
|
+
runBeforeBuild() { throw Object.assign(new Error('preparation failed'), { status: 7 }); },
|
|
75
|
+
}), { message: 'preparation failed', status: 7 });
|
|
76
|
+
});
|
|
@@ -1,117 +1,78 @@
|
|
|
1
|
-
const { test } = require('node:test');
|
|
2
|
-
const assert = require('node:assert/strict');
|
|
3
|
-
const fs = require('node:fs');
|
|
4
|
-
const path = require('node:path');
|
|
5
|
-
const { pathToFileURL } = require('node:url');
|
|
6
|
-
const { syncIapAliases, findLatestIapDirectory, legacyIapPlugin } = require('../files/buildCodeplay/iap-alias.cjs');
|
|
7
|
-
|
|
8
|
-
function fixture(alias = '{}') {
|
|
9
|
-
const base = path.resolve(process.env.CODEPLAY_TEST_ROOT || path.join(__dirname, '../agent-temp'));
|
|
10
|
-
fs.mkdirSync(base, { recursive: true });
|
|
11
|
-
const root = fs.mkdtempSync(path.join(base, 'iap-alias-'));
|
|
12
|
-
const write = (name, value) => { const file = path.join(root, name); fs.mkdirSync(path.dirname(file), { recursive: true }); fs.writeFileSync(file, value); return file; };
|
|
13
|
-
write('buildCodeplay/iap-alias.cjs', fs.readFileSync(path.join(__dirname, '../files/buildCodeplay/iap-alias.cjs')));
|
|
14
|
-
write('src/js/Ads/IAP-4.8/IAP-state.js', 'export const shouldBlockIapAds = () => false;');
|
|
15
|
-
write('src/js/Ads/IAP-4.8/IAP-bootstrap.js', 'export const initIAP = () => {};');
|
|
16
|
-
write('vite.config.mjs', `export default async () => ({ resolve: { alias: ${alias} }, define: { preserved: true } });`);
|
|
17
|
-
return { root, write };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
test('migrates imports and re-exports without changing comments, text or F7 templates; repeat is stable', () => {
|
|
21
|
-
const f = fixture();
|
|
22
|
-
const file = f.write('src/pages/home.f7', `<template><div>import '../IAP-4.9/IAP-state.js'</div></template>\n<script>\n// import '../IAP-4.9/IAP-state.js'\nconst text = "../IAP-4.9/IAP-state.js";\nimport { shouldBlockIapAds } from '../js/Ads/IAP-4.9/IAP-state.js';\nconst module = import('@/js/Ads/IAP-4.9/IAP-bootstrap.js');\nexport { initIAP } from '../js/Ads/IAP-4.9/IAP-bootstrap.js';\n</script>`);
|
|
23
|
-
assert.equal(syncIapAliases(f.root, [file]).length, 2);
|
|
24
|
-
const result = fs.readFileSync(file, 'utf8');
|
|
25
|
-
assert.ok(result.includes("from '@iap/IAP-state.js'"));
|
|
26
|
-
assert.ok(result.includes("import('@iap/IAP-bootstrap.js')"));
|
|
27
|
-
assert.ok(result.includes("from '@iap/IAP-bootstrap.js'"));
|
|
28
|
-
assert.ok(result.includes('// import \'../IAP-4.9/IAP-state.js\''));
|
|
29
|
-
assert.ok(result.includes('const text = "../IAP-4.9/IAP-state.js"'));
|
|
30
|
-
assert.ok(result.includes('<div>import \'../IAP-4.9/IAP-state.js\'</div>'));
|
|
31
|
-
assert.deepEqual(syncIapAliases(f.root, [file]), []);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('Vite object and array aliases resolve IAP 4.8 and change automatically when a newer folder appears', async () => {
|
|
35
|
-
const previous = process.cwd();
|
|
36
|
-
try {
|
|
37
|
-
for (const aliases of ["{'@existing':'/unchanged'}", "[{ find: '@existing', replacement: '/unchanged' }]"]) {
|
|
38
|
-
const f = fixture(aliases); syncIapAliases(f.root); process.chdir(f.root);
|
|
39
|
-
const { default: configure } = await import(pathToFileURL(path.join(f.root, 'vite.config.mjs')).href);
|
|
40
|
-
const selected = config => Array.isArray(config.resolve.alias) ? config.resolve.alias.find(a => a.find === '@iap').replacement : config.resolve.alias['@iap'];
|
|
41
|
-
assert.equal(selected(await configure({})), path.join(f.root, 'src/js/Ads/IAP-4.8'));
|
|
42
|
-
f.write('src/js/Ads/IAP-4.10/IAP-state.js', '// newest state');
|
|
43
|
-
f.write('src/js/Ads/IAP-5.0/README.txt', 'incomplete');
|
|
44
|
-
assert.equal(selected(await configure({})), path.join(f.root, 'src/js/Ads/IAP-4.10'));
|
|
45
|
-
assert.equal((await configure({})).define.preserved, true);
|
|
46
|
-
assert.equal(findLatestIapDirectory(f.root), path.join(f.root, 'src/js/Ads/IAP-4.10'));
|
|
47
|
-
}
|
|
48
|
-
} finally { process.chdir(previous); }
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
test('missing IAP modules fail before any source or Vite changes', () => {
|
|
52
|
-
const f = fixture();
|
|
53
|
-
const source = "import { x } from '../IAP-4.9/missing.js';";
|
|
54
|
-
const file = f.write('src/caller.js', source);
|
|
55
|
-
const vite = fs.readFileSync(path.join(f.root, 'vite.config.mjs'), 'utf8');
|
|
56
|
-
assert.throws(() => syncIapAliases(f.root, [file]), /Missing @iap\/missing.js/);
|
|
57
|
-
assert.equal(fs.readFileSync(file, 'utf8'), source);
|
|
58
|
-
assert.equal(fs.readFileSync(path.join(f.root, 'vite.config.mjs'), 'utf8'), vite);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test('
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
assert.deepEqual(syncIapAliases(f.root), []);
|
|
80
|
-
}
|
|
81
|
-
} finally { process.chdir(previous); }
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test('custom IAP aliases fail without changing source or Vite configuration', () => {
|
|
85
|
-
for (const aliases of [
|
|
86
|
-
"{'@iap': path.resolve(__dirname, './custom/IAP-5.2')}",
|
|
87
|
-
"[{ find: '@iap', replacement: customIapDirectory() }]",
|
|
88
|
-
]) {
|
|
89
|
-
const f = fixture(aliases);
|
|
90
|
-
const source = "import { x } from '../IAP-4.9/IAP-state.js';";
|
|
91
|
-
const file = f.write('src/caller.js', source);
|
|
92
|
-
const vite = path.join(f.root, 'vite.config.mjs');
|
|
93
|
-
const original = fs.readFileSync(vite, 'utf8');
|
|
94
|
-
assert.throws(() => syncIapAliases(f.root, [file]), /Cannot replace a custom @iap alias/);
|
|
95
|
-
assert.equal(fs.readFileSync(vite, 'utf8'), original);
|
|
96
|
-
assert.equal(fs.readFileSync(file, 'utf8'), source);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
test('apps without IAP are left unchanged', () => {
|
|
101
|
-
const f = fixture(); fs.unlinkSync(path.join(f.root, 'src/js/Ads/IAP-4.8/IAP-state.js'));
|
|
102
|
-
assert.equal(findLatestIapDirectory(f.root), null);
|
|
103
|
-
assert.deepEqual(syncIapAliases(f.root), []);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
test('protected AdMob source stays unchanged and legacy imports resolve to installed IAP', async () => {
|
|
107
|
-
const f = fixture();
|
|
108
|
-
const original = "import { shouldBlockIapAds } from '../IAP-4.9/IAP-state.js';";
|
|
109
|
-
const file = f.write('src/js/Ads/admob-nextgen-4.7/admob-emi-nextgen.js', original);
|
|
110
|
-
syncIapAliases(f.root, [file]);
|
|
111
|
-
assert.equal(fs.readFileSync(file, 'utf8'), original);
|
|
112
|
-
const plugin = legacyIapPlugin(f.root);
|
|
113
|
-
const resolver = { resolve: async target => ({ id: target }) };
|
|
114
|
-
const result = await plugin.resolveId.call(resolver, '../IAP-4.9/IAP-state.js', file);
|
|
115
|
-
assert.equal(result.id, path.join(f.root, 'src/js/Ads/IAP-4.8/IAP-state.js'));
|
|
116
|
-
assert.equal(await plugin.resolveId.call(resolver, '@capacitor/core', file), null);
|
|
117
|
-
});
|
|
1
|
+
const { test } = require('node:test');
|
|
2
|
+
const assert = require('node:assert/strict');
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const { pathToFileURL } = require('node:url');
|
|
6
|
+
const { syncIapAliases, findLatestIapDirectory, legacyIapPlugin } = require('../files/buildCodeplay/iap-alias.cjs');
|
|
7
|
+
|
|
8
|
+
function fixture(alias = '{}') {
|
|
9
|
+
const base = path.resolve(process.env.CODEPLAY_TEST_ROOT || path.join(__dirname, '../agent-temp'));
|
|
10
|
+
fs.mkdirSync(base, { recursive: true });
|
|
11
|
+
const root = fs.mkdtempSync(path.join(base, 'iap-alias-'));
|
|
12
|
+
const write = (name, value) => { const file = path.join(root, name); fs.mkdirSync(path.dirname(file), { recursive: true }); fs.writeFileSync(file, value); return file; };
|
|
13
|
+
write('buildCodeplay/iap-alias.cjs', fs.readFileSync(path.join(__dirname, '../files/buildCodeplay/iap-alias.cjs')));
|
|
14
|
+
write('src/js/Ads/IAP-4.8/IAP-state.js', 'export const shouldBlockIapAds = () => false;');
|
|
15
|
+
write('src/js/Ads/IAP-4.8/IAP-bootstrap.js', 'export const initIAP = () => {};');
|
|
16
|
+
write('vite.config.mjs', `export default async () => ({ resolve: { alias: ${alias} }, define: { preserved: true } });`);
|
|
17
|
+
return { root, write };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
test('migrates imports and re-exports without changing comments, text or F7 templates; repeat is stable', () => {
|
|
21
|
+
const f = fixture();
|
|
22
|
+
const file = f.write('src/pages/home.f7', `<template><div>import '../IAP-4.9/IAP-state.js'</div></template>\n<script>\n// import '../IAP-4.9/IAP-state.js'\nconst text = "../IAP-4.9/IAP-state.js";\nimport { shouldBlockIapAds } from '../js/Ads/IAP-4.9/IAP-state.js';\nconst module = import('@/js/Ads/IAP-4.9/IAP-bootstrap.js');\nexport { initIAP } from '../js/Ads/IAP-4.9/IAP-bootstrap.js';\n</script>`);
|
|
23
|
+
assert.equal(syncIapAliases(f.root, [file]).length, 2);
|
|
24
|
+
const result = fs.readFileSync(file, 'utf8');
|
|
25
|
+
assert.ok(result.includes("from '@iap/IAP-state.js'"));
|
|
26
|
+
assert.ok(result.includes("import('@iap/IAP-bootstrap.js')"));
|
|
27
|
+
assert.ok(result.includes("from '@iap/IAP-bootstrap.js'"));
|
|
28
|
+
assert.ok(result.includes('// import \'../IAP-4.9/IAP-state.js\''));
|
|
29
|
+
assert.ok(result.includes('const text = "../IAP-4.9/IAP-state.js"'));
|
|
30
|
+
assert.ok(result.includes('<div>import \'../IAP-4.9/IAP-state.js\'</div>'));
|
|
31
|
+
assert.deepEqual(syncIapAliases(f.root, [file]), []);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('Vite object and array aliases resolve IAP 4.8 and change automatically when a newer folder appears', async () => {
|
|
35
|
+
const previous = process.cwd();
|
|
36
|
+
try {
|
|
37
|
+
for (const aliases of ["{'@existing':'/unchanged'}", "[{ find: '@existing', replacement: '/unchanged' }]"]) {
|
|
38
|
+
const f = fixture(aliases); syncIapAliases(f.root); process.chdir(f.root);
|
|
39
|
+
const { default: configure } = await import(pathToFileURL(path.join(f.root, 'vite.config.mjs')).href);
|
|
40
|
+
const selected = config => Array.isArray(config.resolve.alias) ? config.resolve.alias.find(a => a.find === '@iap').replacement : config.resolve.alias['@iap'];
|
|
41
|
+
assert.equal(selected(await configure({})), path.join(f.root, 'src/js/Ads/IAP-4.8'));
|
|
42
|
+
f.write('src/js/Ads/IAP-4.10/IAP-state.js', '// newest state');
|
|
43
|
+
f.write('src/js/Ads/IAP-5.0/README.txt', 'incomplete');
|
|
44
|
+
assert.equal(selected(await configure({})), path.join(f.root, 'src/js/Ads/IAP-4.10'));
|
|
45
|
+
assert.equal((await configure({})).define.preserved, true);
|
|
46
|
+
assert.equal(findLatestIapDirectory(f.root), path.join(f.root, 'src/js/Ads/IAP-4.10'));
|
|
47
|
+
}
|
|
48
|
+
} finally { process.chdir(previous); }
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('missing IAP modules fail before any source or Vite changes', () => {
|
|
52
|
+
const f = fixture();
|
|
53
|
+
const source = "import { x } from '../IAP-4.9/missing.js';";
|
|
54
|
+
const file = f.write('src/caller.js', source);
|
|
55
|
+
const vite = fs.readFileSync(path.join(f.root, 'vite.config.mjs'), 'utf8');
|
|
56
|
+
assert.throws(() => syncIapAliases(f.root, [file]), /Missing @iap\/missing.js/);
|
|
57
|
+
assert.equal(fs.readFileSync(file, 'utf8'), source);
|
|
58
|
+
assert.equal(fs.readFileSync(path.join(f.root, 'vite.config.mjs'), 'utf8'), vite);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('apps without IAP are left unchanged', () => {
|
|
62
|
+
const f = fixture(); fs.unlinkSync(path.join(f.root, 'src/js/Ads/IAP-4.8/IAP-state.js'));
|
|
63
|
+
assert.equal(findLatestIapDirectory(f.root), null);
|
|
64
|
+
assert.deepEqual(syncIapAliases(f.root), []);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('protected AdMob source stays unchanged and legacy imports resolve to installed IAP', async () => {
|
|
68
|
+
const f = fixture();
|
|
69
|
+
const original = "import { shouldBlockIapAds } from '../IAP-4.9/IAP-state.js';";
|
|
70
|
+
const file = f.write('src/js/Ads/admob-nextgen-4.7/admob-emi-nextgen.js', original);
|
|
71
|
+
syncIapAliases(f.root, [file]);
|
|
72
|
+
assert.equal(fs.readFileSync(file, 'utf8'), original);
|
|
73
|
+
const plugin = legacyIapPlugin(f.root);
|
|
74
|
+
const resolver = { resolve: async target => ({ id: target }) };
|
|
75
|
+
const result = await plugin.resolveId.call(resolver, '../IAP-4.9/IAP-state.js', file);
|
|
76
|
+
assert.equal(result.id, path.join(f.root, 'src/js/Ads/IAP-4.8/IAP-state.js'));
|
|
77
|
+
assert.equal(await plugin.resolveId.call(resolver, '@capacitor/core', file), null);
|
|
78
|
+
});
|