codeplay-common 4.11.28 → 4.11.30
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 +1 -0
- package/README.md +89 -89
- package/RELEASE_NOTES.md +13 -13
- package/files/buildCodeplay/HUAWEI-PRIVACY.md +9 -0
- package/files/buildCodeplay/add-splash-screen.js +1 -1
- package/files/buildCodeplay/codeplayBeforeBuild.js +4756 -4755
- package/files/buildCodeplay/disabled-ads.mjs +45 -45
- package/files/buildCodeplay/ensure-current-build.cjs +42 -42
- package/files/buildCodeplay/fix-optimize-builld/android-r8-rules.cjs +31 -31
- package/files/buildCodeplay/fix-optimize-builld/ffmpeg-jni-rules.cjs +28 -28
- package/files/buildCodeplay/fix-optimize-builld/fix-optimize-build.gradle +9 -9
- package/files/buildCodeplay/fix-optimize-builld/restore-android-r8-rules.cjs +30 -30
- package/files/buildCodeplay/huawei-privacy-entry.js +135 -0
- package/files/buildCodeplay/huawei-privacy.cjs +92 -0
- package/files/buildCodeplay/huawei-privacy.css +22 -0
- package/files/buildCodeplay/iap-alias.cjs +116 -108
- package/files/buildCodeplay/ios-ad-consent.cjs +56 -56
- package/files/buildCodeplay/ios-emi-admob-modification.js +25 -25
- package/files/buildCodeplay/migrate-system-bars.cjs +115 -115
- package/files/buildCodeplay/newly added.txt +89 -89
- package/files/buildCodeplay/non-google-billing.pro +3 -3
- 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 +2 -2
- package/files/buildCodeplay/setup-ruads.cjs +55 -55
- package/files/buildCodeplay/splash-setup.cjs +88 -88
- package/files/buildCodeplay/store-billing.cjs +43 -43
- package/files/buildCodeplay/tests/huawei-privacy.test.cjs +49 -0
- package/files/buildCodeplay/tests/huawei-vite.test.cjs +35 -0
- package/files/scripts-common/generate-baseline-profile.js +46 -46
- package/files/take-screen-image.js +4414 -4414
- package/package.json +28 -28
- package/runtime/splash-ready.mjs +52 -52
- 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 +117 -78
- 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/splash-setup.test.cjs +142 -142
- package/scripts/sync-files.js +1 -1
- package/scripts/system-bars.test.cjs +77 -77
- package/scripts/vite-build-settings.test.cjs +92 -92
|
@@ -1,92 +1,92 @@
|
|
|
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 vm = require('node:vm');
|
|
6
|
-
const { pathToFileURL } = require('node:url');
|
|
7
|
-
const { install } = require('./sync-files.js');
|
|
8
|
-
|
|
9
|
-
function fixture(configuration) {
|
|
10
|
-
const base = path.resolve(process.env.CODEPLAY_TEST_ROOT || path.join(__dirname, '../agent-temp'));
|
|
11
|
-
fs.mkdirSync(base, { recursive: true });
|
|
12
|
-
const root = fs.mkdtempSync(path.join(base, 'vite-settings-'));
|
|
13
|
-
fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify({ name: 'vite-fixture', scripts: {}, dependencies: {} }));
|
|
14
|
-
fs.writeFileSync(path.join(root, 'capacitor.config.json'), JSON.stringify({ appId: 'fixture.app', plugins: {
|
|
15
|
-
AdMob: { ADMOB_ENABLED: true }, RuAds: { VK_ADS_ENABLED: true, STORE_IDS: [4, 10] },
|
|
16
|
-
} }));
|
|
17
|
-
fs.mkdirSync(path.join(root, 'src/js/Ads/vk-ads-1.3'), { recursive: true });
|
|
18
|
-
fs.writeFileSync(path.join(root, 'src/js/Ads/vk-ads-1.3/vk-ads.js'), '// manually installed VK controller');
|
|
19
|
-
fs.writeFileSync(path.join(root, 'vite.config.mjs'), configuration);
|
|
20
|
-
install({ projectRoot: root, copyAssets: false });
|
|
21
|
-
// Run the real before-build migration after the real installer. Loading the
|
|
22
|
-
// full before-build CLI would also install SDKs and change native platforms.
|
|
23
|
-
const source = fs.readFileSync(path.join(root, 'buildCodeplay/codeplayBeforeBuild.js'), 'utf8');
|
|
24
|
-
const migration = source.slice(source.indexOf('const migrateViteTreeShaking ='), source.indexOf('// BEGIN IAP BUILD MIGRATION'));
|
|
25
|
-
const migrate = vm.runInNewContext(migration + '\nmigrateViteTreeShaking;');
|
|
26
|
-
return { root, file: path.join(root, 'vite.config.mjs'), migrate };
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const alias = "resolve: { alias: { '@admob': '/original-admob.js' } }";
|
|
30
|
-
const build = { outDir: '../www', minify: 'terser', sourcemap: true, emptyOutDir: false,
|
|
31
|
-
target: 'es2022', rollupOptions: { external: ['preserved-module'], output: { entryFileNames: 'custom-[name].js' } } };
|
|
32
|
-
|
|
33
|
-
test('installer and before-build preserve build settings for object/function/defineConfig exports and all ad providers', async () => {
|
|
34
|
-
const previous = { cwd: process.cwd(), store: process.env.VITE_STORE_ID, platform: process.env.CODEPLAY_BUILD_PLATFORM };
|
|
35
|
-
try {
|
|
36
|
-
delete process.env.CODEPLAY_BUILD_PLATFORM;
|
|
37
|
-
const config = `{ build: ${JSON.stringify(build)}, ${alias}, define: { custom: 'true' } }`;
|
|
38
|
-
for (const source of [`export default ${config};`, `export default async () => (${config});`, `const defineConfig = c => c;\nexport default defineConfig(${config});`]) {
|
|
39
|
-
const f = fixture(source);
|
|
40
|
-
const updated = f.migrate(fs.readFileSync(f.file, 'utf8'));
|
|
41
|
-
assert.equal(f.migrate(updated), updated);
|
|
42
|
-
fs.writeFileSync(f.file, updated);
|
|
43
|
-
process.chdir(f.root);
|
|
44
|
-
const { default: configure } = await import(pathToFileURL(f.file).href);
|
|
45
|
-
for (const store of ['1', '4', '10']) {
|
|
46
|
-
process.env.VITE_STORE_ID = store;
|
|
47
|
-
const resolved = await configure({ mode: 'production' });
|
|
48
|
-
assert.deepEqual(resolved.build, { ...build, rollupOptions: { ...build.rollupOptions, treeshake: true } });
|
|
49
|
-
assert.equal(resolved.define.custom, 'true');
|
|
50
|
-
assert.equal(resolved.define['import.meta.env.VITE_STORE_ID'], JSON.stringify(store));
|
|
51
|
-
assert.equal(resolved.resolve.alias['@admob'], store === '1' ? '/original-admob.js' : path.join(f.root, 'src/js/Ads/vk-ads-1.3/vk-ads.js'));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
} finally {
|
|
55
|
-
process.chdir(previous.cwd);
|
|
56
|
-
for (const [key, value] of [['VITE_STORE_ID', previous.store], ['CODEPLAY_BUILD_PLATFORM', previous.platform]]) {
|
|
57
|
-
if (value === undefined) delete process.env[key]; else process.env[key] = value;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test('migration preserves custom treeshake options and repairs only the previous generated override', async () => {
|
|
63
|
-
const custom = { ...build, rollupOptions: { ...build.rollupOptions, treeshake: { moduleSideEffects: false } } };
|
|
64
|
-
const f = fixture(`export default { build: ${JSON.stringify(custom)}, ${alias} };`);
|
|
65
|
-
let source = fs.readFileSync(f.file, 'utf8');
|
|
66
|
-
source = source.replace('return { ...base,', 'return { ...base, build: { rollupOptions: { treeshake: true } },');
|
|
67
|
-
const updated = f.migrate(source);
|
|
68
|
-
assert.ok(!updated.includes('...base, build:'));
|
|
69
|
-
assert.equal(f.migrate(updated), updated);
|
|
70
|
-
fs.writeFileSync(f.file, updated);
|
|
71
|
-
const previous = process.cwd();
|
|
72
|
-
try {
|
|
73
|
-
process.chdir(f.root);
|
|
74
|
-
const { default: configure } = await import(pathToFileURL(f.file).href);
|
|
75
|
-
assert.deepEqual((await configure({})).build, custom);
|
|
76
|
-
} finally { process.chdir(previous); }
|
|
77
|
-
const customized = source.replace('build: { rollupOptions: { treeshake: true } },', "build: { outDir: '/custom-wrapper', rollupOptions: { treeshake: true } },");
|
|
78
|
-
assert.ok(f.migrate(customized).includes("outDir: '/custom-wrapper'"));
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test('missing build/rollup settings are added to the original config; unwrapped configs still migrate', () => {
|
|
82
|
-
const f = fixture(`export default { ${alias} };`);
|
|
83
|
-
const updated = f.migrate(fs.readFileSync(f.file, 'utf8'));
|
|
84
|
-
assert.match(updated, /codeplayOriginalViteConfig\s*=\s*\{[\s\S]*build:/);
|
|
85
|
-
assert.ok(!updated.includes('...base, build:'));
|
|
86
|
-
assert.equal(f.migrate(updated), updated);
|
|
87
|
-
const plain = `export default { build: { outDir: '../www', rollupOptions: { treeshake: false, external: ['keep'] } } };`;
|
|
88
|
-
const result = f.migrate(plain);
|
|
89
|
-
assert.ok(result.includes("outDir: '../www'"));
|
|
90
|
-
assert.ok(result.includes("external: ['keep']"));
|
|
91
|
-
assert.ok(result.includes('treeshake: true'));
|
|
92
|
-
});
|
|
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 vm = require('node:vm');
|
|
6
|
+
const { pathToFileURL } = require('node:url');
|
|
7
|
+
const { install } = require('./sync-files.js');
|
|
8
|
+
|
|
9
|
+
function fixture(configuration) {
|
|
10
|
+
const base = path.resolve(process.env.CODEPLAY_TEST_ROOT || path.join(__dirname, '../agent-temp'));
|
|
11
|
+
fs.mkdirSync(base, { recursive: true });
|
|
12
|
+
const root = fs.mkdtempSync(path.join(base, 'vite-settings-'));
|
|
13
|
+
fs.writeFileSync(path.join(root, 'package.json'), JSON.stringify({ name: 'vite-fixture', scripts: {}, dependencies: {} }));
|
|
14
|
+
fs.writeFileSync(path.join(root, 'capacitor.config.json'), JSON.stringify({ appId: 'fixture.app', plugins: {
|
|
15
|
+
AdMob: { ADMOB_ENABLED: true }, RuAds: { VK_ADS_ENABLED: true, STORE_IDS: [4, 10] },
|
|
16
|
+
} }));
|
|
17
|
+
fs.mkdirSync(path.join(root, 'src/js/Ads/vk-ads-1.3'), { recursive: true });
|
|
18
|
+
fs.writeFileSync(path.join(root, 'src/js/Ads/vk-ads-1.3/vk-ads.js'), '// manually installed VK controller');
|
|
19
|
+
fs.writeFileSync(path.join(root, 'vite.config.mjs'), configuration);
|
|
20
|
+
install({ projectRoot: root, copyAssets: false });
|
|
21
|
+
// Run the real before-build migration after the real installer. Loading the
|
|
22
|
+
// full before-build CLI would also install SDKs and change native platforms.
|
|
23
|
+
const source = fs.readFileSync(path.join(root, 'buildCodeplay/codeplayBeforeBuild.js'), 'utf8');
|
|
24
|
+
const migration = source.slice(source.indexOf('const migrateViteTreeShaking ='), source.indexOf('// BEGIN IAP BUILD MIGRATION'));
|
|
25
|
+
const migrate = vm.runInNewContext(migration + '\nmigrateViteTreeShaking;');
|
|
26
|
+
return { root, file: path.join(root, 'vite.config.mjs'), migrate };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const alias = "resolve: { alias: { '@admob': '/original-admob.js' } }";
|
|
30
|
+
const build = { outDir: '../www', minify: 'terser', sourcemap: true, emptyOutDir: false,
|
|
31
|
+
target: 'es2022', rollupOptions: { external: ['preserved-module'], output: { entryFileNames: 'custom-[name].js' } } };
|
|
32
|
+
|
|
33
|
+
test('installer and before-build preserve build settings for object/function/defineConfig exports and all ad providers', async () => {
|
|
34
|
+
const previous = { cwd: process.cwd(), store: process.env.VITE_STORE_ID, platform: process.env.CODEPLAY_BUILD_PLATFORM };
|
|
35
|
+
try {
|
|
36
|
+
delete process.env.CODEPLAY_BUILD_PLATFORM;
|
|
37
|
+
const config = `{ build: ${JSON.stringify(build)}, ${alias}, define: { custom: 'true' } }`;
|
|
38
|
+
for (const source of [`export default ${config};`, `export default async () => (${config});`, `const defineConfig = c => c;\nexport default defineConfig(${config});`]) {
|
|
39
|
+
const f = fixture(source);
|
|
40
|
+
const updated = f.migrate(fs.readFileSync(f.file, 'utf8'));
|
|
41
|
+
assert.equal(f.migrate(updated), updated);
|
|
42
|
+
fs.writeFileSync(f.file, updated);
|
|
43
|
+
process.chdir(f.root);
|
|
44
|
+
const { default: configure } = await import(pathToFileURL(f.file).href);
|
|
45
|
+
for (const store of ['1', '4', '10']) {
|
|
46
|
+
process.env.VITE_STORE_ID = store;
|
|
47
|
+
const resolved = await configure({ mode: 'production' });
|
|
48
|
+
assert.deepEqual(resolved.build, { ...build, rollupOptions: { ...build.rollupOptions, treeshake: true } });
|
|
49
|
+
assert.equal(resolved.define.custom, 'true');
|
|
50
|
+
assert.equal(resolved.define['import.meta.env.VITE_STORE_ID'], JSON.stringify(store));
|
|
51
|
+
assert.equal(resolved.resolve.alias['@admob'], store === '1' ? '/original-admob.js' : path.join(f.root, 'src/js/Ads/vk-ads-1.3/vk-ads.js'));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
} finally {
|
|
55
|
+
process.chdir(previous.cwd);
|
|
56
|
+
for (const [key, value] of [['VITE_STORE_ID', previous.store], ['CODEPLAY_BUILD_PLATFORM', previous.platform]]) {
|
|
57
|
+
if (value === undefined) delete process.env[key]; else process.env[key] = value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('migration preserves custom treeshake options and repairs only the previous generated override', async () => {
|
|
63
|
+
const custom = { ...build, rollupOptions: { ...build.rollupOptions, treeshake: { moduleSideEffects: false } } };
|
|
64
|
+
const f = fixture(`export default { build: ${JSON.stringify(custom)}, ${alias} };`);
|
|
65
|
+
let source = fs.readFileSync(f.file, 'utf8');
|
|
66
|
+
source = source.replace('return { ...base,', 'return { ...base, build: { rollupOptions: { treeshake: true } },');
|
|
67
|
+
const updated = f.migrate(source);
|
|
68
|
+
assert.ok(!updated.includes('...base, build:'));
|
|
69
|
+
assert.equal(f.migrate(updated), updated);
|
|
70
|
+
fs.writeFileSync(f.file, updated);
|
|
71
|
+
const previous = process.cwd();
|
|
72
|
+
try {
|
|
73
|
+
process.chdir(f.root);
|
|
74
|
+
const { default: configure } = await import(pathToFileURL(f.file).href);
|
|
75
|
+
assert.deepEqual((await configure({})).build, custom);
|
|
76
|
+
} finally { process.chdir(previous); }
|
|
77
|
+
const customized = source.replace('build: { rollupOptions: { treeshake: true } },', "build: { outDir: '/custom-wrapper', rollupOptions: { treeshake: true } },");
|
|
78
|
+
assert.ok(f.migrate(customized).includes("outDir: '/custom-wrapper'"));
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('missing build/rollup settings are added to the original config; unwrapped configs still migrate', () => {
|
|
82
|
+
const f = fixture(`export default { ${alias} };`);
|
|
83
|
+
const updated = f.migrate(fs.readFileSync(f.file, 'utf8'));
|
|
84
|
+
assert.match(updated, /codeplayOriginalViteConfig\s*=\s*\{[\s\S]*build:/);
|
|
85
|
+
assert.ok(!updated.includes('...base, build:'));
|
|
86
|
+
assert.equal(f.migrate(updated), updated);
|
|
87
|
+
const plain = `export default { build: { outDir: '../www', rollupOptions: { treeshake: false, external: ['keep'] } } };`;
|
|
88
|
+
const result = f.migrate(plain);
|
|
89
|
+
assert.ok(result.includes("outDir: '../www'"));
|
|
90
|
+
assert.ok(result.includes("external: ['keep']"));
|
|
91
|
+
assert.ok(result.includes('treeshake: true'));
|
|
92
|
+
});
|