codeplay-common 4.11.5 → 4.11.7
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/RELEASE_NOTES.md +79 -75
- package/files/buildCodeplay/codeplayBeforeBuild.js +24 -2
- 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/ios-emi-admob-modification.js +25 -25
- package/files/buildCodeplay/newly added.txt +89 -89
- package/files/buildCodeplay/remove-force-kotlin-disable.js +43 -43
- package/files/scripts-common/generate-baseline-profile.js +46 -46
- package/files/take-screen-image.js +40 -10
- package/package.json +1 -1
- package/scripts/ensure-current-build.test.cjs +76 -76
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- Preserve configured LocalNotifications small/large drawables and the default OneSignal drawable when present in Android resources; regenerate the shrinker keep rules on every before-build run, including after platform recreation.
|
|
5
6
|
- Detect version-suffixed files in the app's `buildCodeplay` folder at build startup, then run `npm uninstall codeplay-common` and `npm install codeplay-common` sequentially before resuming with the refreshed before-build script.
|
|
6
7
|
- Stop on reinstall failure or incomplete legacy cleanup rather than continuing with stale build templates.
|
|
7
8
|
|
package/RELEASE_NOTES.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Release notes
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
- Keep notification icons in optimized Android apps by generating resource protection from each app's configuration during build preparation. Rebuild and reinstall consuming apps to apply this fix.
|
|
6
|
+
|
|
3
7
|
## 4.11.4 — 2026-10-27
|
|
4
8
|
|
|
5
9
|
Version name: 4.11.4. Version code/build number: not applicable to this npm package.
|
|
@@ -11,78 +15,78 @@ Files changed: `package.json`, `scripts/sync-files.js`, `files/buildCodeplay/fix
|
|
|
11
15
|
- Restore protection after native platform regeneration and package updates, and check it on every Gradle build without overwriting custom ProGuard rules.
|
|
12
16
|
- Keep the fix self-contained in the shared package and provide a manual restore command.
|
|
13
17
|
- No new permissions or prompts are added. Update the package and rebuild each app to include the correction.
|
|
14
|
-
- Preserve existing release minification choices and protect FFmpeg native entry points in apps using that plugin.
|
|
15
|
-
|
|
16
|
-
## 4.10.5 — 2026-10-23
|
|
17
|
-
|
|
18
|
-
Version name: 4.10.5. Version code/build number: not applicable to this npm package.
|
|
19
|
-
|
|
20
|
-
Files changed: `package.json`, `scripts/sync-files.js`, `CHANGELOG.md`, `RELEASE_NOTES.md`.
|
|
21
|
-
|
|
22
|
-
- Prevent app postinstall failures after shared scripts switch to unversioned filenames.
|
|
23
|
-
- Repair the known old sync-hook path during plugin installation.
|
|
24
|
-
- Preserve each app's custom configuration and leave apps without the affected configurator unchanged.
|
|
25
|
-
|
|
26
|
-
## 4.10.4 — 2026-10-23
|
|
27
|
-
|
|
28
|
-
Version name: 4.10.4. Version code/build number: not applicable to this npm package.
|
|
29
|
-
|
|
30
|
-
Files changed: `package.json`, `files/scripts-common/run-codeplay-sync-after.js`, `CHANGELOG.md`, `RELEASE_NOTES.md`.
|
|
31
|
-
|
|
32
|
-
- Fix Android sync failures caused by the old versioned splash script lookup.
|
|
33
|
-
- Use the migrated baseline profile setup path.
|
|
34
|
-
- Update the custom sync hook automatically during plugin installation.
|
|
35
|
-
|
|
36
|
-
## 4.10.3 — 2026-10-23
|
|
37
|
-
|
|
38
|
-
Version name: 4.10.3. Version code/build number: not applicable to this npm package.
|
|
39
|
-
|
|
40
|
-
Files changed: `package.json`, `files/finalrelease`, `CHANGELOG.md`, `RELEASE_NOTES.md`.
|
|
41
|
-
|
|
42
|
-
- Release ad-free apps without adding an unnecessary AdMob alias or controller.
|
|
43
|
-
- Explicitly set `plugins.AdMob.ADMOB_ENABLED` to `false` to use the ad-free release path.
|
|
44
|
-
- Keep production AdMob safety checks for apps with advertising enabled.
|
|
45
|
-
|
|
46
|
-
## 4.10.0 — 2026-10-23
|
|
47
|
-
|
|
48
|
-
Version name: 4.10.0. Version code/build number: not applicable to this npm package.
|
|
49
|
-
Bundled pre-build script: 6.7.
|
|
50
|
-
|
|
51
|
-
Files changed: `package.json`, `files/buildCodeplay/project-scripts.cjs`, `scripts/sync-files.js`, `scripts/uninstall.js`, `files/finalrelease`, `files/buildCodeplay/`, `files/scripts-common/`, `files/take-screen-image.js`, `README.md`, `CHANGELOG.md`, `RELEASE_NOTES.md`.
|
|
52
|
-
|
|
53
|
-
- Copy shared build scripts and the versions manifest into each app; run local scripts with unversioned filenames.
|
|
54
|
-
- Rename app helper scripts to scripts-common automatically, migrate command paths, and preserve existing files without overwriting folder conflicts.
|
|
55
|
-
- Migrate app build/store/sync paths automatically and remove only superseded versioned helpers; preserve app-owned configuration and screenshot data.
|
|
56
|
-
- Resolve app sources/native targets from the consuming app directory while keeping bundled assets inside the plugin.
|
|
57
|
-
- Download IAP and AdMob directly from htmlcodeplay.com, without bundling archives or adding a separate fallback.
|
|
58
|
-
- Automatically migrate deferred ownership verification, purchase-safe advertising, and Home Pro visibility according to each store IAP flag.
|
|
59
|
-
- Copy the full finalrelease implementation so it can be tested from the application folder.
|
|
60
|
-
- Preserve working files during preinstall and avoid downgrading local/newer plugin installations to an older registry release.
|
|
61
|
-
|
|
62
|
-
## 4.9.8 — 2026-10-22
|
|
63
|
-
|
|
64
|
-
Version name: 4.9.8. Version code/build number: not applicable to this npm package.
|
|
65
|
-
Bundled pre-build script: 6.5.
|
|
66
|
-
|
|
67
|
-
Files changed: `package.json`, `scripts/sync-files.js`, `files/buildCodeplay/codeplayBeforeBuild-6.5.js`, `files/buildCodeplay/sync-admob-nextgen.js`, `files/buildCodeplay/versions.json`, `files/finalrelease`, `README.md`, `CHANGELOG.md`, `RELEASE_NOTES.md`.
|
|
68
|
-
|
|
69
|
-
- Install AdMob as `src/js/Ads/admob-nextgen-4.0/` with stable `admob-emi-nextgen.js` and `app-open-state.js` filenames.
|
|
70
|
-
- Automatically migrate loose-file references, folder references and Vite aliases during installation and before builds.
|
|
71
|
-
- Preserve app-owned ad configuration and select each app's existing IAP analytics module.
|
|
72
|
-
- Download every AdMob folder ZIP from htmlcodeplay.com; no AdMob archive is included in this npm package.
|
|
73
|
-
- Validate ZIP contents before switching imports; retain the working package when a remote update fails.
|
|
74
|
-
- Validate the selected folder controller during final-release checks while continuing to reject test aliases.
|
|
75
|
-
|
|
76
|
-
## 4.7.7 — 2026-10-07
|
|
77
|
-
|
|
78
|
-
Version name: 4.7.7. Version code/build number: not applicable to this npm package.
|
|
79
|
-
|
|
80
|
-
Files changed: `package.json`, `scripts/sync-files.js`, `files/buildCodeplay/codeplayBeforeBuild-6.4.js`
|
|
81
|
-
(replaces `codeplayBeforeBuild-6.3.js`), `README.md`, `CHANGELOG.md`, `RELEASE_NOTES.md`.
|
|
82
|
-
|
|
83
|
-
- Installation automatically configures Android and iOS build commands in your app's `package.json`.
|
|
84
|
-
- Android builds remain the default; use `npm run build:ios` for iOS.
|
|
85
|
-
- Save-gallery imports use one alias with a platform-specific helper and a clear confirmation before source changes.
|
|
86
|
-
- Shared checks reuse file traversal to reduce repeated scanning.
|
|
87
|
-
- Builds warn and automatically uninstall the retired OneSignal Cordova plugin when found.
|
|
88
|
-
- `agent-temp/` stays ignored, while `buildCodeplay/` is removed from ignore rules.
|
|
18
|
+
- Preserve existing release minification choices and protect FFmpeg native entry points in apps using that plugin.
|
|
19
|
+
|
|
20
|
+
## 4.10.5 — 2026-10-23
|
|
21
|
+
|
|
22
|
+
Version name: 4.10.5. Version code/build number: not applicable to this npm package.
|
|
23
|
+
|
|
24
|
+
Files changed: `package.json`, `scripts/sync-files.js`, `CHANGELOG.md`, `RELEASE_NOTES.md`.
|
|
25
|
+
|
|
26
|
+
- Prevent app postinstall failures after shared scripts switch to unversioned filenames.
|
|
27
|
+
- Repair the known old sync-hook path during plugin installation.
|
|
28
|
+
- Preserve each app's custom configuration and leave apps without the affected configurator unchanged.
|
|
29
|
+
|
|
30
|
+
## 4.10.4 — 2026-10-23
|
|
31
|
+
|
|
32
|
+
Version name: 4.10.4. Version code/build number: not applicable to this npm package.
|
|
33
|
+
|
|
34
|
+
Files changed: `package.json`, `files/scripts-common/run-codeplay-sync-after.js`, `CHANGELOG.md`, `RELEASE_NOTES.md`.
|
|
35
|
+
|
|
36
|
+
- Fix Android sync failures caused by the old versioned splash script lookup.
|
|
37
|
+
- Use the migrated baseline profile setup path.
|
|
38
|
+
- Update the custom sync hook automatically during plugin installation.
|
|
39
|
+
|
|
40
|
+
## 4.10.3 — 2026-10-23
|
|
41
|
+
|
|
42
|
+
Version name: 4.10.3. Version code/build number: not applicable to this npm package.
|
|
43
|
+
|
|
44
|
+
Files changed: `package.json`, `files/finalrelease`, `CHANGELOG.md`, `RELEASE_NOTES.md`.
|
|
45
|
+
|
|
46
|
+
- Release ad-free apps without adding an unnecessary AdMob alias or controller.
|
|
47
|
+
- Explicitly set `plugins.AdMob.ADMOB_ENABLED` to `false` to use the ad-free release path.
|
|
48
|
+
- Keep production AdMob safety checks for apps with advertising enabled.
|
|
49
|
+
|
|
50
|
+
## 4.10.0 — 2026-10-23
|
|
51
|
+
|
|
52
|
+
Version name: 4.10.0. Version code/build number: not applicable to this npm package.
|
|
53
|
+
Bundled pre-build script: 6.7.
|
|
54
|
+
|
|
55
|
+
Files changed: `package.json`, `files/buildCodeplay/project-scripts.cjs`, `scripts/sync-files.js`, `scripts/uninstall.js`, `files/finalrelease`, `files/buildCodeplay/`, `files/scripts-common/`, `files/take-screen-image.js`, `README.md`, `CHANGELOG.md`, `RELEASE_NOTES.md`.
|
|
56
|
+
|
|
57
|
+
- Copy shared build scripts and the versions manifest into each app; run local scripts with unversioned filenames.
|
|
58
|
+
- Rename app helper scripts to scripts-common automatically, migrate command paths, and preserve existing files without overwriting folder conflicts.
|
|
59
|
+
- Migrate app build/store/sync paths automatically and remove only superseded versioned helpers; preserve app-owned configuration and screenshot data.
|
|
60
|
+
- Resolve app sources/native targets from the consuming app directory while keeping bundled assets inside the plugin.
|
|
61
|
+
- Download IAP and AdMob directly from htmlcodeplay.com, without bundling archives or adding a separate fallback.
|
|
62
|
+
- Automatically migrate deferred ownership verification, purchase-safe advertising, and Home Pro visibility according to each store IAP flag.
|
|
63
|
+
- Copy the full finalrelease implementation so it can be tested from the application folder.
|
|
64
|
+
- Preserve working files during preinstall and avoid downgrading local/newer plugin installations to an older registry release.
|
|
65
|
+
|
|
66
|
+
## 4.9.8 — 2026-10-22
|
|
67
|
+
|
|
68
|
+
Version name: 4.9.8. Version code/build number: not applicable to this npm package.
|
|
69
|
+
Bundled pre-build script: 6.5.
|
|
70
|
+
|
|
71
|
+
Files changed: `package.json`, `scripts/sync-files.js`, `files/buildCodeplay/codeplayBeforeBuild-6.5.js`, `files/buildCodeplay/sync-admob-nextgen.js`, `files/buildCodeplay/versions.json`, `files/finalrelease`, `README.md`, `CHANGELOG.md`, `RELEASE_NOTES.md`.
|
|
72
|
+
|
|
73
|
+
- Install AdMob as `src/js/Ads/admob-nextgen-4.0/` with stable `admob-emi-nextgen.js` and `app-open-state.js` filenames.
|
|
74
|
+
- Automatically migrate loose-file references, folder references and Vite aliases during installation and before builds.
|
|
75
|
+
- Preserve app-owned ad configuration and select each app's existing IAP analytics module.
|
|
76
|
+
- Download every AdMob folder ZIP from htmlcodeplay.com; no AdMob archive is included in this npm package.
|
|
77
|
+
- Validate ZIP contents before switching imports; retain the working package when a remote update fails.
|
|
78
|
+
- Validate the selected folder controller during final-release checks while continuing to reject test aliases.
|
|
79
|
+
|
|
80
|
+
## 4.7.7 — 2026-10-07
|
|
81
|
+
|
|
82
|
+
Version name: 4.7.7. Version code/build number: not applicable to this npm package.
|
|
83
|
+
|
|
84
|
+
Files changed: `package.json`, `scripts/sync-files.js`, `files/buildCodeplay/codeplayBeforeBuild-6.4.js`
|
|
85
|
+
(replaces `codeplayBeforeBuild-6.3.js`), `README.md`, `CHANGELOG.md`, `RELEASE_NOTES.md`.
|
|
86
|
+
|
|
87
|
+
- Installation automatically configures Android and iOS build commands in your app's `package.json`.
|
|
88
|
+
- Android builds remain the default; use `npm run build:ios` for iOS.
|
|
89
|
+
- Save-gallery imports use one alias with a platform-specific helper and a clear confirmation before source changes.
|
|
90
|
+
- Shared checks reuse file traversal to reduce repeated scanning.
|
|
91
|
+
- Builds warn and automatically uninstall the retired OneSignal Cordova plugin when found.
|
|
92
|
+
- `agent-temp/` stays ignored, while `buildCodeplay/` is removed from ignore rules.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// Version 6.9: preserve configured notification icons during Android resource shrinking.
|
|
1
2
|
// Version 6.8: preserve Capacitor permission annotations for Love Calculator Android builds.
|
|
2
3
|
// Version 6.7: deferred IAP startup, ownership-safe ads, and unified store preparation.
|
|
3
4
|
// Version 6.7: migrate AdMob files to ZIP-distributed folder packages.
|
|
@@ -4605,11 +4606,32 @@ function syncAndroidCordovaResourceKeep() {
|
|
|
4605
4606
|
if (buildPlatform !== 'android' || !fs.existsSync(androidPlatformPath)) return;
|
|
4606
4607
|
|
|
4607
4608
|
// Cordova loads config.xml by name; preserve it even when no plugins are installed yet.
|
|
4608
|
-
const
|
|
4609
|
+
const resPath = path.join(androidPlatformPath, 'app', 'src', 'main', 'res');
|
|
4610
|
+
const rawPath = path.join(resPath, 'raw');
|
|
4609
4611
|
const keepPath = path.join(rawPath, 'codeplay_cordova_keep.xml');
|
|
4612
|
+
const keepResources = new Set(['@xml/config']);
|
|
4613
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
4614
|
+
const notifications = config.plugins?.LocalNotifications || {};
|
|
4615
|
+
const iconNames = new Set(['ic_stat_onesignal_default']);
|
|
4616
|
+
for (const icon of [notifications.smallIcon, notifications.largeIcon]) {
|
|
4617
|
+
if (typeof icon !== 'string') continue;
|
|
4618
|
+
const name = icon.replace(/^@drawable\//, '').replace(/\.(?:png|webp|xml)$/, '');
|
|
4619
|
+
if (/^[a-z][a-z0-9_]*$/.test(name)) iconNames.add(name);
|
|
4620
|
+
}
|
|
4621
|
+
// Native notification plugins resolve these drawables by name, outside R8's static graph.
|
|
4622
|
+
// Only keep resources present in this project, including density/API-qualified variants.
|
|
4623
|
+
if (fs.existsSync(resPath)) {
|
|
4624
|
+
for (const directory of fs.readdirSync(resPath, { withFileTypes: true })) {
|
|
4625
|
+
if (!directory.isDirectory() || !/^drawable(?:-|$)/.test(directory.name)) continue;
|
|
4626
|
+
for (const file of fs.readdirSync(path.join(resPath, directory.name))) {
|
|
4627
|
+
const name = file.replace(/(?:\.9)?\.[^.]+$/, '');
|
|
4628
|
+
if (iconNames.has(name)) keepResources.add(`@drawable/${name}`);
|
|
4629
|
+
}
|
|
4630
|
+
}
|
|
4631
|
+
}
|
|
4610
4632
|
const content = '<?xml version="1.0" encoding="utf-8"?>\n'
|
|
4611
4633
|
+ '<resources xmlns:tools="http://schemas.android.com/tools"\n'
|
|
4612
|
-
+
|
|
4634
|
+
+ ` tools:keep="${[...keepResources].sort().join(',')}" />\n`;
|
|
4613
4635
|
if (fs.existsSync(keepPath) && fs.readFileSync(keepPath, 'utf8') === content) return;
|
|
4614
4636
|
|
|
4615
4637
|
fs.mkdirSync(rawPath, { recursive: true });
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { execSync, execFileSync } = require('child_process');
|
|
4
|
-
|
|
5
|
-
function findVersionedBuildFiles(projectRoot) {
|
|
6
|
-
const directory = path.join(projectRoot, 'buildCodeplay');
|
|
7
|
-
if (!fs.existsSync(directory)) return [];
|
|
8
|
-
return fs.readdirSync(directory, { withFileTypes: true })
|
|
9
|
-
.filter(entry => entry.isFile() && /-\d+(?:\.\d+)*(?:-beta-\d+)?\.[^.]+$/i.test(entry.name))
|
|
10
|
-
.map(entry => entry.name);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function ensureCurrentBuild(options = {}) {
|
|
14
|
-
const projectRoot = path.resolve(options.projectRoot || process.cwd());
|
|
15
|
-
const legacyFiles = findVersionedBuildFiles(projectRoot);
|
|
16
|
-
if (!legacyFiles.length) return false;
|
|
17
|
-
|
|
18
|
-
console.log(`Legacy buildCodeplay files found: ${legacyFiles.join(', ')}. Reinstalling codeplay-common before continuing.`);
|
|
19
|
-
const runNpm = options.runNpm || (command => execSync(command, { cwd: projectRoot, stdio: 'inherit' }));
|
|
20
|
-
runNpm('npm uninstall codeplay-common');
|
|
21
|
-
runNpm('npm install codeplay-common');
|
|
22
|
-
|
|
23
|
-
// Postinstall replaces the scripts and removes recognized legacy files.
|
|
24
|
-
// Do not run stale code or retry indefinitely if migration did not finish.
|
|
25
|
-
const remaining = findVersionedBuildFiles(projectRoot);
|
|
26
|
-
if (remaining.length) {
|
|
27
|
-
throw new Error(`Legacy buildCodeplay files remain after reinstall: ${remaining.join(', ')}. Build stopped; migrate these files before retrying.`);
|
|
28
|
-
}
|
|
29
|
-
const entrypoint = path.join(projectRoot, 'buildCodeplay', 'codeplayBeforeBuild.js');
|
|
30
|
-
if (!fs.existsSync(entrypoint)) throw new Error('codeplayBeforeBuild.js is missing after reinstall. Build stopped.');
|
|
31
|
-
|
|
32
|
-
// The current process loaded the old templates. Finish preparation in a fresh
|
|
33
|
-
// process before the caller's remaining build commands are allowed to run.
|
|
34
|
-
const runBeforeBuild = options.runBeforeBuild || (script => execFileSync(process.execPath, [script, ...process.argv.slice(2)], {
|
|
35
|
-
cwd: projectRoot,
|
|
36
|
-
stdio: 'inherit',
|
|
37
|
-
}));
|
|
38
|
-
runBeforeBuild(entrypoint);
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
module.exports = { ensureCurrentBuild, findVersionedBuildFiles };
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { execSync, execFileSync } = require('child_process');
|
|
4
|
+
|
|
5
|
+
function findVersionedBuildFiles(projectRoot) {
|
|
6
|
+
const directory = path.join(projectRoot, 'buildCodeplay');
|
|
7
|
+
if (!fs.existsSync(directory)) return [];
|
|
8
|
+
return fs.readdirSync(directory, { withFileTypes: true })
|
|
9
|
+
.filter(entry => entry.isFile() && /-\d+(?:\.\d+)*(?:-beta-\d+)?\.[^.]+$/i.test(entry.name))
|
|
10
|
+
.map(entry => entry.name);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function ensureCurrentBuild(options = {}) {
|
|
14
|
+
const projectRoot = path.resolve(options.projectRoot || process.cwd());
|
|
15
|
+
const legacyFiles = findVersionedBuildFiles(projectRoot);
|
|
16
|
+
if (!legacyFiles.length) return false;
|
|
17
|
+
|
|
18
|
+
console.log(`Legacy buildCodeplay files found: ${legacyFiles.join(', ')}. Reinstalling codeplay-common before continuing.`);
|
|
19
|
+
const runNpm = options.runNpm || (command => execSync(command, { cwd: projectRoot, stdio: 'inherit' }));
|
|
20
|
+
runNpm('npm uninstall codeplay-common');
|
|
21
|
+
runNpm('npm install codeplay-common');
|
|
22
|
+
|
|
23
|
+
// Postinstall replaces the scripts and removes recognized legacy files.
|
|
24
|
+
// Do not run stale code or retry indefinitely if migration did not finish.
|
|
25
|
+
const remaining = findVersionedBuildFiles(projectRoot);
|
|
26
|
+
if (remaining.length) {
|
|
27
|
+
throw new Error(`Legacy buildCodeplay files remain after reinstall: ${remaining.join(', ')}. Build stopped; migrate these files before retrying.`);
|
|
28
|
+
}
|
|
29
|
+
const entrypoint = path.join(projectRoot, 'buildCodeplay', 'codeplayBeforeBuild.js');
|
|
30
|
+
if (!fs.existsSync(entrypoint)) throw new Error('codeplayBeforeBuild.js is missing after reinstall. Build stopped.');
|
|
31
|
+
|
|
32
|
+
// The current process loaded the old templates. Finish preparation in a fresh
|
|
33
|
+
// process before the caller's remaining build commands are allowed to run.
|
|
34
|
+
const runBeforeBuild = options.runBeforeBuild || (script => execFileSync(process.execPath, [script, ...process.argv.slice(2)], {
|
|
35
|
+
cwd: projectRoot,
|
|
36
|
+
stdio: 'inherit',
|
|
37
|
+
}));
|
|
38
|
+
runBeforeBuild(entrypoint);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = { ensureCurrentBuild, findVersionedBuildFiles };
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
function syncCapacitorPermissionRules(projectRoot = path.resolve(__dirname, '../..')) {
|
|
5
|
-
const appPath = path.join(projectRoot, 'android', 'app');
|
|
6
|
-
if (!fs.existsSync(path.join(appPath, 'build.gradle'))) return false;
|
|
7
|
-
|
|
8
|
-
const rulesPath = path.join(appPath, 'proguard-rules.pro');
|
|
9
|
-
const original = fs.existsSync(rulesPath) ? fs.readFileSync(rulesPath, 'utf8') : '';
|
|
10
|
-
const rules = [
|
|
11
|
-
'-keepattributes RuntimeVisibleAnnotations,AnnotationDefault',
|
|
12
|
-
'-keep @interface com.getcapacitor.annotation.CapacitorPlugin { *; }',
|
|
13
|
-
'-keep @interface com.getcapacitor.annotation.Permission { *; }',
|
|
14
|
-
];
|
|
15
|
-
const existing = new Set(original.split(/\r?\n/).map(line => line.trim()));
|
|
16
|
-
const missing = rules.filter(rule => !existing.has(rule));
|
|
17
|
-
if (!missing.length) return false;
|
|
18
|
-
|
|
19
|
-
const newline = original.includes('\r\n') ? '\r\n' : '\n';
|
|
20
|
-
fs.writeFileSync(rulesPath, `${original.trimEnd()}${newline}${newline}`
|
|
21
|
-
+ `# Preserve Capacitor permission metadata used at runtime.${newline}`
|
|
22
|
-
+ `${missing.join(newline)}${newline}`, 'utf8');
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (require.main === module) {
|
|
27
|
-
const changed = syncCapacitorPermissionRules();
|
|
28
|
-
console.log(changed ? 'Capacitor R8 permission rules restored.' : 'Capacitor R8 permission rules unchanged.');
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
module.exports = { syncCapacitorPermissionRules };
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
function syncCapacitorPermissionRules(projectRoot = path.resolve(__dirname, '../..')) {
|
|
5
|
+
const appPath = path.join(projectRoot, 'android', 'app');
|
|
6
|
+
if (!fs.existsSync(path.join(appPath, 'build.gradle'))) return false;
|
|
7
|
+
|
|
8
|
+
const rulesPath = path.join(appPath, 'proguard-rules.pro');
|
|
9
|
+
const original = fs.existsSync(rulesPath) ? fs.readFileSync(rulesPath, 'utf8') : '';
|
|
10
|
+
const rules = [
|
|
11
|
+
'-keepattributes RuntimeVisibleAnnotations,AnnotationDefault',
|
|
12
|
+
'-keep @interface com.getcapacitor.annotation.CapacitorPlugin { *; }',
|
|
13
|
+
'-keep @interface com.getcapacitor.annotation.Permission { *; }',
|
|
14
|
+
];
|
|
15
|
+
const existing = new Set(original.split(/\r?\n/).map(line => line.trim()));
|
|
16
|
+
const missing = rules.filter(rule => !existing.has(rule));
|
|
17
|
+
if (!missing.length) return false;
|
|
18
|
+
|
|
19
|
+
const newline = original.includes('\r\n') ? '\r\n' : '\n';
|
|
20
|
+
fs.writeFileSync(rulesPath, `${original.trimEnd()}${newline}${newline}`
|
|
21
|
+
+ `# Preserve Capacitor permission metadata used at runtime.${newline}`
|
|
22
|
+
+ `${missing.join(newline)}${newline}`, 'utf8');
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (require.main === module) {
|
|
27
|
+
const changed = syncCapacitorPermissionRules();
|
|
28
|
+
console.log(changed ? 'Capacitor R8 permission rules restored.' : 'Capacitor R8 permission rules unchanged.');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = { syncCapacitorPermissionRules };
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
// FFmpegKit's JNI library looks up these Java members by name at runtime.
|
|
5
|
-
const FFMPEG_JNI_RULES = [
|
|
6
|
-
'-keep class com.antonkarpenko.ffmpegkit.** { *; }',
|
|
7
|
-
'-keep interface com.antonkarpenko.ffmpegkit.** { *; }',
|
|
8
|
-
];
|
|
9
|
-
|
|
10
|
-
function syncFfmpegJniRules(projectRoot) {
|
|
11
|
-
const pluginPath = path.join(projectRoot, 'node_modules', 'codeplay-fmpg', 'plugin.xml');
|
|
12
|
-
const appPath = path.join(projectRoot, 'android', 'app');
|
|
13
|
-
if (!fs.existsSync(pluginPath) || !fs.existsSync(appPath)) return false;
|
|
14
|
-
|
|
15
|
-
const rulesPath = path.join(appPath, 'proguard-rules.pro');
|
|
16
|
-
const original = fs.existsSync(rulesPath) ? fs.readFileSync(rulesPath, 'utf8') : '';
|
|
17
|
-
const existing = new Set(original.split(/\r?\n/).map(line => line.trim()));
|
|
18
|
-
const missing = FFMPEG_JNI_RULES.filter(rule => !existing.has(rule));
|
|
19
|
-
if (!missing.length) return false;
|
|
20
|
-
|
|
21
|
-
const newline = original.includes('\r\n') ? '\r\n' : '\n';
|
|
22
|
-
fs.writeFileSync(rulesPath, `${original.trimEnd()}${newline}${newline}`
|
|
23
|
-
+ `# Preserve FFmpegKit JNI entry points and callbacks.${newline}`
|
|
24
|
-
+ `${missing.join(newline)}${newline}`, 'utf8');
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = { syncFfmpegJniRules };
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
// FFmpegKit's JNI library looks up these Java members by name at runtime.
|
|
5
|
+
const FFMPEG_JNI_RULES = [
|
|
6
|
+
'-keep class com.antonkarpenko.ffmpegkit.** { *; }',
|
|
7
|
+
'-keep interface com.antonkarpenko.ffmpegkit.** { *; }',
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
function syncFfmpegJniRules(projectRoot) {
|
|
11
|
+
const pluginPath = path.join(projectRoot, 'node_modules', 'codeplay-fmpg', 'plugin.xml');
|
|
12
|
+
const appPath = path.join(projectRoot, 'android', 'app');
|
|
13
|
+
if (!fs.existsSync(pluginPath) || !fs.existsSync(appPath)) return false;
|
|
14
|
+
|
|
15
|
+
const rulesPath = path.join(appPath, 'proguard-rules.pro');
|
|
16
|
+
const original = fs.existsSync(rulesPath) ? fs.readFileSync(rulesPath, 'utf8') : '';
|
|
17
|
+
const existing = new Set(original.split(/\r?\n/).map(line => line.trim()));
|
|
18
|
+
const missing = FFMPEG_JNI_RULES.filter(rule => !existing.has(rule));
|
|
19
|
+
if (!missing.length) return false;
|
|
20
|
+
|
|
21
|
+
const newline = original.includes('\r\n') ? '\r\n' : '\n';
|
|
22
|
+
fs.writeFileSync(rulesPath, `${original.trimEnd()}${newline}${newline}`
|
|
23
|
+
+ `# Preserve FFmpegKit JNI entry points and callbacks.${newline}`
|
|
24
|
+
+ `${missing.join(newline)}${newline}`, 'utf8');
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = { syncFfmpegJniRules };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// Restore native metadata before Gradle configures an optimized Android build.
|
|
2
|
-
def codeplayAppRoot = rootProject.projectDir.parentFile
|
|
3
|
-
def codeplayRepairScript = new File(codeplayAppRoot, 'buildCodeplay/fix-optimize-builld/restore-android-r8-rules.cjs')
|
|
4
|
-
def codeplayNodeBinary = project.findProperty('codeplayNodeBinary') ?: 'node'
|
|
5
|
-
|
|
6
|
-
providers.exec {
|
|
7
|
-
workingDir codeplayAppRoot
|
|
8
|
-
commandLine codeplayNodeBinary, codeplayRepairScript.absolutePath
|
|
9
|
-
}.result.get().assertNormalExitValue()
|
|
1
|
+
// Restore native metadata before Gradle configures an optimized Android build.
|
|
2
|
+
def codeplayAppRoot = rootProject.projectDir.parentFile
|
|
3
|
+
def codeplayRepairScript = new File(codeplayAppRoot, 'buildCodeplay/fix-optimize-builld/restore-android-r8-rules.cjs')
|
|
4
|
+
def codeplayNodeBinary = project.findProperty('codeplayNodeBinary') ?: 'node'
|
|
5
|
+
|
|
6
|
+
providers.exec {
|
|
7
|
+
workingDir codeplayAppRoot
|
|
8
|
+
commandLine codeplayNodeBinary, codeplayRepairScript.absolutePath
|
|
9
|
+
}.result.get().assertNormalExitValue()
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { syncFfmpegJniRules } = require('./ffmpeg-jni-rules.cjs');
|
|
4
|
-
const { syncCapacitorPermissionRules } = require('./android-r8-rules.cjs');
|
|
5
|
-
|
|
6
|
-
function syncAndroidR8Rules(projectRoot = path.resolve(__dirname, '../..'), { installGradleHook = false } = {}) {
|
|
7
|
-
const buildPath = path.join(projectRoot, 'android', 'app', 'build.gradle');
|
|
8
|
-
if (!fs.existsSync(buildPath)) return false;
|
|
9
|
-
const capacitorChanged = syncCapacitorPermissionRules(projectRoot);
|
|
10
|
-
const ffmpegChanged = syncFfmpegJniRules(projectRoot);
|
|
11
|
-
let hookChanged = false;
|
|
12
|
-
if (installGradleHook) {
|
|
13
|
-
const original = fs.readFileSync(buildPath, 'utf8');
|
|
14
|
-
const hook = "apply from: '../../buildCodeplay/fix-optimize-builld/fix-optimize-build.gradle'";
|
|
15
|
-
const existingHook = /^[ \t]*apply\s+from:\s*(['"])\.\.\/\.\.\/buildCodeplay\/fix-optimize-builld\/fix-optimize-build\.gradle\1[ \t]*;?[ \t]*$/m;
|
|
16
|
-
if (!existingHook.test(original)) {
|
|
17
|
-
const newline = original.includes('\r\n') ? '\r\n' : '\n';
|
|
18
|
-
fs.writeFileSync(buildPath, `${original.trimEnd()}${newline}${newline}${hook}${newline}`, 'utf8');
|
|
19
|
-
hookChanged = true;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return capacitorChanged || ffmpegChanged || hookChanged;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (require.main === module) {
|
|
26
|
-
const changed = syncAndroidR8Rules(undefined, { installGradleHook: process.argv.includes('--install-gradle-hook') });
|
|
27
|
-
console.log(changed ? 'Android R8 keep rules restored.' : 'Android R8 keep rules unchanged; no Android app or rules already present.');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
module.exports = { syncAndroidR8Rules };
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { syncFfmpegJniRules } = require('./ffmpeg-jni-rules.cjs');
|
|
4
|
+
const { syncCapacitorPermissionRules } = require('./android-r8-rules.cjs');
|
|
5
|
+
|
|
6
|
+
function syncAndroidR8Rules(projectRoot = path.resolve(__dirname, '../..'), { installGradleHook = false } = {}) {
|
|
7
|
+
const buildPath = path.join(projectRoot, 'android', 'app', 'build.gradle');
|
|
8
|
+
if (!fs.existsSync(buildPath)) return false;
|
|
9
|
+
const capacitorChanged = syncCapacitorPermissionRules(projectRoot);
|
|
10
|
+
const ffmpegChanged = syncFfmpegJniRules(projectRoot);
|
|
11
|
+
let hookChanged = false;
|
|
12
|
+
if (installGradleHook) {
|
|
13
|
+
const original = fs.readFileSync(buildPath, 'utf8');
|
|
14
|
+
const hook = "apply from: '../../buildCodeplay/fix-optimize-builld/fix-optimize-build.gradle'";
|
|
15
|
+
const existingHook = /^[ \t]*apply\s+from:\s*(['"])\.\.\/\.\.\/buildCodeplay\/fix-optimize-builld\/fix-optimize-build\.gradle\1[ \t]*;?[ \t]*$/m;
|
|
16
|
+
if (!existingHook.test(original)) {
|
|
17
|
+
const newline = original.includes('\r\n') ? '\r\n' : '\n';
|
|
18
|
+
fs.writeFileSync(buildPath, `${original.trimEnd()}${newline}${newline}${hook}${newline}`, 'utf8');
|
|
19
|
+
hookChanged = true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return capacitorChanged || ffmpegChanged || hookChanged;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (require.main === module) {
|
|
26
|
+
const changed = syncAndroidR8Rules(undefined, { installGradleHook: process.argv.includes('--install-gradle-hook') });
|
|
27
|
+
console.log(changed ? 'Android R8 keep rules restored.' : 'Android R8 keep rules unchanged; no Android app or rules already present.');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports = { syncAndroidR8Rules };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
const replaceEmiPluginCode=()=>
|
|
5
|
-
{
|
|
6
|
-
// path to your .m file
|
|
7
|
-
const filePath = path.join(__dirname, '../ios/capacitor-cordova-ios-plugins/sourcesstatic/EmiIndoCordovaPluginAdmob/emiAdmobPlugin.m');
|
|
8
|
-
const nextGenPackagePath = path.join(__dirname, '../node_modules/capacitor-admob-nextgen/package.json');
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (fs.existsSync(filePath)) {
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const replaceEmiPluginCode=()=>
|
|
5
|
+
{
|
|
6
|
+
// path to your .m file
|
|
7
|
+
const filePath = path.join(__dirname, '../ios/capacitor-cordova-ios-plugins/sourcesstatic/EmiIndoCordovaPluginAdmob/emiAdmobPlugin.m');
|
|
8
|
+
const nextGenPackagePath = path.join(__dirname, '../node_modules/capacitor-admob-nextgen/package.json');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
if (fs.existsSync(filePath)) {
|
|
12
12
|
let fileContent = fs.readFileSync(filePath, 'utf8');
|
|
13
13
|
|
|
14
14
|
// match the hideBannerAd method
|
|
@@ -33,17 +33,17 @@ const replaceEmiPluginCode=()=>
|
|
|
33
33
|
fileContent.slice(match.index + match[0].length);
|
|
34
34
|
|
|
35
35
|
fs.writeFileSync(filePath, updatedFileContent, 'utf8');
|
|
36
|
-
console.log(
|
|
37
|
-
'✅ Successfully ensured [self resetWebViewHeight]; is commented only inside hideBannerAd in emiAdmobPlugin.m'
|
|
38
|
-
);
|
|
39
|
-
} else {
|
|
40
|
-
console.log('⚠️ hideBannerAd method not found.');
|
|
41
|
-
}
|
|
42
|
-
} else if (fs.existsSync(nextGenPackagePath)) {
|
|
43
|
-
console.log('ℹ️ Skipping legacy iOS EMI AdMob patch. capacitor-admob-nextgen does not use emiAdmobPlugin.m.');
|
|
44
|
-
} else {
|
|
45
|
-
console.log('ℹ️ emiAdmobPlugin.m file not found, skipping modification.');
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
replaceEmiPluginCode();
|
|
36
|
+
console.log(
|
|
37
|
+
'✅ Successfully ensured [self resetWebViewHeight]; is commented only inside hideBannerAd in emiAdmobPlugin.m'
|
|
38
|
+
);
|
|
39
|
+
} else {
|
|
40
|
+
console.log('⚠️ hideBannerAd method not found.');
|
|
41
|
+
}
|
|
42
|
+
} else if (fs.existsSync(nextGenPackagePath)) {
|
|
43
|
+
console.log('ℹ️ Skipping legacy iOS EMI AdMob patch. capacitor-admob-nextgen does not use emiAdmobPlugin.m.');
|
|
44
|
+
} else {
|
|
45
|
+
console.log('ℹ️ emiAdmobPlugin.m file not found, skipping modification.');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
replaceEmiPluginCode();
|
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
Note: This changes are added with my old(current) code. Might we need to integrate this features into our new optimized code.
|
|
2
|
-
|
|
3
|
-
1) If no import(saveToGalleryAndSaveAnyFile) found it through error issue is fixed
|
|
4
|
-
// iOS Checks
|
|
5
|
-
/* if (isMac && !iosImportFound) {
|
|
6
|
-
console.warn(`⚠️ WARNING: You're on macOS but no iOS version (saveToGalleryAndSaveAnyFile-x.x-ios.js) found.`);
|
|
7
|
-
process.exit(1);
|
|
8
|
-
} else if (isMac && iosImportFound) {
|
|
9
|
-
console.log('✅ iOS version detected for macOS build.');
|
|
10
|
-
} else if (!iosImportFound) {
|
|
11
|
-
console.log('✅ No iOS-specific imports detected for non-macOS.');
|
|
12
|
-
} */
|
|
13
|
-
|
|
14
|
-
// ✅ Only care if iOS import is found in NON-mac systems
|
|
15
|
-
if (iosImportFound && !isMac) {
|
|
16
|
-
console.error(`\n❌ ERROR: iOS-specific file is imported in non-macOS environment.`);
|
|
17
|
-
process.exit(1);
|
|
18
|
-
} else if (iosImportFound && isMac) {
|
|
19
|
-
console.log('✅ iOS import detected (valid for macOS build).');
|
|
20
|
-
} else {
|
|
21
|
-
console.log('✅ No iOS-specific imports found (this is totally fine).');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
2) Statusbar color set in app startup is checked and through erro
|
|
26
|
-
|
|
27
|
-
const STATUSBAR_FILE = path.resolve(__dirname, '../src/js/common-configuration.js');
|
|
28
|
-
const STATUSBAR_REGEX = /^(?!\s*\/\/).*Capacitor\.Plugins\.StatusBar\.setStyle/m;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const ONESIGNAL_OLD_FILES = [
|
|
32
|
-
path.resolve(__dirname, '../src/js/onesignal-settings.js')
|
|
33
|
-
];
|
|
34
|
-
const ONESIGNAL_VERSION_REGEX = /^onesignal-\d+(\.\d+)*\.js$/;
|
|
35
|
-
|
|
36
|
-
....
|
|
37
|
-
....
|
|
38
|
-
....
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const JS_ROOT = path.resolve(__dirname, '../src/js');
|
|
42
|
-
const ONESIGNAL_DIR = path.join(JS_ROOT, 'onesignal');
|
|
43
|
-
|
|
44
|
-
// 🚨 Block old OneSignal file locations (ONLY in src/js root)
|
|
45
|
-
if (path.dirname(dir) === JS_ROOT) {
|
|
46
|
-
|
|
47
|
-
// ❌ onesignal-settings.js
|
|
48
|
-
if (ONESIGNAL_OLD_FILES.includes(dir)) {
|
|
49
|
-
console.error(`\n❌ ERROR: onesignal-settings.js should not be in src/js/`);
|
|
50
|
-
console.error(`📁 Move it to: src/js/onesignal/`);
|
|
51
|
-
console.error(`📄 File: ${dir}\n`);
|
|
52
|
-
process.exit(1);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// ❌ onesignal-x.x.js
|
|
56
|
-
if (ONESIGNAL_VERSION_REGEX.test(baseName)) {
|
|
57
|
-
console.error(`\n❌ ERROR: ${baseName} should not be in src/js/`);
|
|
58
|
-
console.error(`📁 Move it to: src/js/onesignal/`);
|
|
59
|
-
console.error(`📄 File: ${dir}\n`);
|
|
60
|
-
process.exit(1);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// 🚨 Special check ONLY for common-configuration.js
|
|
65
|
-
if (dir === STATUSBAR_FILE) {
|
|
66
|
-
let content = fs.readFileSync(dir, 'utf8');
|
|
67
|
-
|
|
68
|
-
// 🧹 Remove ALL comments (single-line + multi-line)
|
|
69
|
-
const contentWithoutComments = content
|
|
70
|
-
.replace(/\/\/.*$/gm, '') // remove // comments
|
|
71
|
-
.replace(/\/\*[\s\S]*?\*\//g, ''); // remove /* */ comments
|
|
72
|
-
|
|
73
|
-
// ✅ Now check only real code
|
|
74
|
-
if (contentWithoutComments.includes('Capacitor.Plugins.StatusBar.setStyle')) {
|
|
75
|
-
console.error(`\n❌ ERROR: StatusBar.setStyle should NOT be used in common-configuration.js`);
|
|
76
|
-
console.error(`🚫 iOS status bar is controlled via other methods. Remove this line.`);
|
|
77
|
-
console.error(`📄 File: ${dir}\n`);
|
|
78
|
-
process.exit(1);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
3) Modification in "fix-onesignal-plugin.js" file
|
|
84
|
-
Search following and that whole block added for add permission to "info.plist" file
|
|
85
|
-
INFO.PLIST START
|
|
86
|
-
|
|
87
|
-
4) In "codeplayBeforeBuild-6.1.js" file following whole method is replaced. Due to add ads related permission to info.plist file
|
|
88
|
-
updateInfoPlist()
|
|
89
|
-
|
|
1
|
+
Note: This changes are added with my old(current) code. Might we need to integrate this features into our new optimized code.
|
|
2
|
+
|
|
3
|
+
1) If no import(saveToGalleryAndSaveAnyFile) found it through error issue is fixed
|
|
4
|
+
// iOS Checks
|
|
5
|
+
/* if (isMac && !iosImportFound) {
|
|
6
|
+
console.warn(`⚠️ WARNING: You're on macOS but no iOS version (saveToGalleryAndSaveAnyFile-x.x-ios.js) found.`);
|
|
7
|
+
process.exit(1);
|
|
8
|
+
} else if (isMac && iosImportFound) {
|
|
9
|
+
console.log('✅ iOS version detected for macOS build.');
|
|
10
|
+
} else if (!iosImportFound) {
|
|
11
|
+
console.log('✅ No iOS-specific imports detected for non-macOS.');
|
|
12
|
+
} */
|
|
13
|
+
|
|
14
|
+
// ✅ Only care if iOS import is found in NON-mac systems
|
|
15
|
+
if (iosImportFound && !isMac) {
|
|
16
|
+
console.error(`\n❌ ERROR: iOS-specific file is imported in non-macOS environment.`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
} else if (iosImportFound && isMac) {
|
|
19
|
+
console.log('✅ iOS import detected (valid for macOS build).');
|
|
20
|
+
} else {
|
|
21
|
+
console.log('✅ No iOS-specific imports found (this is totally fine).');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
2) Statusbar color set in app startup is checked and through erro
|
|
26
|
+
|
|
27
|
+
const STATUSBAR_FILE = path.resolve(__dirname, '../src/js/common-configuration.js');
|
|
28
|
+
const STATUSBAR_REGEX = /^(?!\s*\/\/).*Capacitor\.Plugins\.StatusBar\.setStyle/m;
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
const ONESIGNAL_OLD_FILES = [
|
|
32
|
+
path.resolve(__dirname, '../src/js/onesignal-settings.js')
|
|
33
|
+
];
|
|
34
|
+
const ONESIGNAL_VERSION_REGEX = /^onesignal-\d+(\.\d+)*\.js$/;
|
|
35
|
+
|
|
36
|
+
....
|
|
37
|
+
....
|
|
38
|
+
....
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const JS_ROOT = path.resolve(__dirname, '../src/js');
|
|
42
|
+
const ONESIGNAL_DIR = path.join(JS_ROOT, 'onesignal');
|
|
43
|
+
|
|
44
|
+
// 🚨 Block old OneSignal file locations (ONLY in src/js root)
|
|
45
|
+
if (path.dirname(dir) === JS_ROOT) {
|
|
46
|
+
|
|
47
|
+
// ❌ onesignal-settings.js
|
|
48
|
+
if (ONESIGNAL_OLD_FILES.includes(dir)) {
|
|
49
|
+
console.error(`\n❌ ERROR: onesignal-settings.js should not be in src/js/`);
|
|
50
|
+
console.error(`📁 Move it to: src/js/onesignal/`);
|
|
51
|
+
console.error(`📄 File: ${dir}\n`);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ❌ onesignal-x.x.js
|
|
56
|
+
if (ONESIGNAL_VERSION_REGEX.test(baseName)) {
|
|
57
|
+
console.error(`\n❌ ERROR: ${baseName} should not be in src/js/`);
|
|
58
|
+
console.error(`📁 Move it to: src/js/onesignal/`);
|
|
59
|
+
console.error(`📄 File: ${dir}\n`);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 🚨 Special check ONLY for common-configuration.js
|
|
65
|
+
if (dir === STATUSBAR_FILE) {
|
|
66
|
+
let content = fs.readFileSync(dir, 'utf8');
|
|
67
|
+
|
|
68
|
+
// 🧹 Remove ALL comments (single-line + multi-line)
|
|
69
|
+
const contentWithoutComments = content
|
|
70
|
+
.replace(/\/\/.*$/gm, '') // remove // comments
|
|
71
|
+
.replace(/\/\*[\s\S]*?\*\//g, ''); // remove /* */ comments
|
|
72
|
+
|
|
73
|
+
// ✅ Now check only real code
|
|
74
|
+
if (contentWithoutComments.includes('Capacitor.Plugins.StatusBar.setStyle')) {
|
|
75
|
+
console.error(`\n❌ ERROR: StatusBar.setStyle should NOT be used in common-configuration.js`);
|
|
76
|
+
console.error(`🚫 iOS status bar is controlled via other methods. Remove this line.`);
|
|
77
|
+
console.error(`📄 File: ${dir}\n`);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
3) Modification in "fix-onesignal-plugin.js" file
|
|
84
|
+
Search following and that whole block added for add permission to "info.plist" file
|
|
85
|
+
INFO.PLIST START
|
|
86
|
+
|
|
87
|
+
4) In "codeplayBeforeBuild-6.1.js" file following whole method is replaced. Due to add ads related permission to info.plist file
|
|
88
|
+
updateInfoPlist()
|
|
89
|
+
|
|
90
90
|
5) The "checkPackageVersion()" metod is updated. Now check the "codeplay-common" latest version and uninstall/install automatically.
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
const legacyPluginXmlPath = path.resolve(
|
|
5
|
-
__dirname,
|
|
6
|
-
'../node_modules/emi-indo-cordova-plugin-admob/plugin.xml'
|
|
7
|
-
);
|
|
8
|
-
|
|
9
|
-
const nextGenPackagePath = path.resolve(
|
|
10
|
-
__dirname,
|
|
11
|
-
'../node_modules/capacitor-admob-nextgen/package.json'
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
if (!fs.existsSync(legacyPluginXmlPath)) {
|
|
15
|
-
if (fs.existsSync(nextGenPackagePath)) {
|
|
16
|
-
console.log('ℹ️ Skipping legacy Kotlin patch. capacitor-admob-nextgen is installed and does not use plugin.xml.');
|
|
17
|
-
process.exit(0);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
console.log('ℹ️ Legacy AdMob plugin.xml not found, skipping Kotlin patch.');
|
|
21
|
-
process.exit(0);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
fs.readFile(legacyPluginXmlPath, 'utf8', (err, data) => {
|
|
25
|
-
if (err) {
|
|
26
|
-
console.error('Error reading plugin.xml:', err);
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const modifiedData = data.replace(
|
|
31
|
-
/<framework\s+src="src\/android\/force-kotlin\.gradle"\s+custom="true"\s+type="gradleReference"\s*\/>\s*\n?/g,
|
|
32
|
-
''
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
fs.writeFile(legacyPluginXmlPath, modifiedData, 'utf8', (writeErr) => {
|
|
36
|
-
if (writeErr) {
|
|
37
|
-
console.error('Error writing plugin.xml:', writeErr);
|
|
38
|
-
process.exit(1);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
console.log('plugin.xml updated successfully.');
|
|
42
|
-
});
|
|
43
|
-
});
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const legacyPluginXmlPath = path.resolve(
|
|
5
|
+
__dirname,
|
|
6
|
+
'../node_modules/emi-indo-cordova-plugin-admob/plugin.xml'
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
const nextGenPackagePath = path.resolve(
|
|
10
|
+
__dirname,
|
|
11
|
+
'../node_modules/capacitor-admob-nextgen/package.json'
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
if (!fs.existsSync(legacyPluginXmlPath)) {
|
|
15
|
+
if (fs.existsSync(nextGenPackagePath)) {
|
|
16
|
+
console.log('ℹ️ Skipping legacy Kotlin patch. capacitor-admob-nextgen is installed and does not use plugin.xml.');
|
|
17
|
+
process.exit(0);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
console.log('ℹ️ Legacy AdMob plugin.xml not found, skipping Kotlin patch.');
|
|
21
|
+
process.exit(0);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
fs.readFile(legacyPluginXmlPath, 'utf8', (err, data) => {
|
|
25
|
+
if (err) {
|
|
26
|
+
console.error('Error reading plugin.xml:', err);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const modifiedData = data.replace(
|
|
31
|
+
/<framework\s+src="src\/android\/force-kotlin\.gradle"\s+custom="true"\s+type="gradleReference"\s*\/>\s*\n?/g,
|
|
32
|
+
''
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
fs.writeFile(legacyPluginXmlPath, modifiedData, 'utf8', (writeErr) => {
|
|
36
|
+
if (writeErr) {
|
|
37
|
+
console.error('Error writing plugin.xml:', writeErr);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
console.log('plugin.xml updated successfully.');
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
const { execFileSync, spawnSync } = require('child_process');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const { syncGeneratedProfileBackup } = require('./setup-baseline-profile.js');
|
|
4
|
-
|
|
5
|
-
function main() {
|
|
6
|
-
const devices = execFileSync('adb', ['devices'], { encoding: 'utf8' })
|
|
7
|
-
.split(/\r?\n/)
|
|
8
|
-
.map(line => line.match(/^(.+?)\tdevice\s*$/))
|
|
9
|
-
.filter(Boolean)
|
|
10
|
-
.map(match => match[1]);
|
|
11
|
-
const requestedSerial = process.env.ANDROID_SERIAL?.trim();
|
|
12
|
-
if (requestedSerial?.includes(',')) {
|
|
13
|
-
throw new Error('Set ANDROID_SERIAL to one device connection for Baseline Profile generation.');
|
|
14
|
-
}
|
|
15
|
-
const serial = requestedSerial || devices[0];
|
|
16
|
-
if (!serial || !devices.includes(serial)) {
|
|
17
|
-
throw new Error(requestedSerial
|
|
18
|
-
? `ADB device is not online: ${requestedSerial}`
|
|
19
|
-
: 'No online ADB device. Connect an Android device before generating a Baseline Profile.');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
console.log(`Generating Baseline Profile using one ADB connection: ${serial}`);
|
|
23
|
-
const args = [':app:generateBaselineProfile', '--console=plain'];
|
|
24
|
-
const result = spawnSync(
|
|
25
|
-
process.platform === 'win32' ? 'cmd.exe' : './gradlew',
|
|
26
|
-
process.platform === 'win32' ? ['/d', '/s', '/c', `gradlew.bat ${args.join(' ')}`] : args,
|
|
27
|
-
{
|
|
28
|
-
cwd: path.resolve(__dirname, '..', 'android'),
|
|
29
|
-
env: { ...process.env, ANDROID_SERIAL: serial },
|
|
30
|
-
stdio: 'inherit',
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
if (result.error) throw result.error;
|
|
34
|
-
if (result.signal) throw new Error(`Baseline Profile generation stopped by ${result.signal}.`);
|
|
35
|
-
process.exitCode = result.status ?? 1;
|
|
36
|
-
if (process.exitCode === 0) {
|
|
37
|
-
syncGeneratedProfileBackup({ backupOnly: true });
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
main();
|
|
43
|
-
} catch (error) {
|
|
44
|
-
console.error(`Baseline Profile generation failed: ${error.message}`);
|
|
45
|
-
process.exitCode = 1;
|
|
46
|
-
}
|
|
1
|
+
const { execFileSync, spawnSync } = require('child_process');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { syncGeneratedProfileBackup } = require('./setup-baseline-profile.js');
|
|
4
|
+
|
|
5
|
+
function main() {
|
|
6
|
+
const devices = execFileSync('adb', ['devices'], { encoding: 'utf8' })
|
|
7
|
+
.split(/\r?\n/)
|
|
8
|
+
.map(line => line.match(/^(.+?)\tdevice\s*$/))
|
|
9
|
+
.filter(Boolean)
|
|
10
|
+
.map(match => match[1]);
|
|
11
|
+
const requestedSerial = process.env.ANDROID_SERIAL?.trim();
|
|
12
|
+
if (requestedSerial?.includes(',')) {
|
|
13
|
+
throw new Error('Set ANDROID_SERIAL to one device connection for Baseline Profile generation.');
|
|
14
|
+
}
|
|
15
|
+
const serial = requestedSerial || devices[0];
|
|
16
|
+
if (!serial || !devices.includes(serial)) {
|
|
17
|
+
throw new Error(requestedSerial
|
|
18
|
+
? `ADB device is not online: ${requestedSerial}`
|
|
19
|
+
: 'No online ADB device. Connect an Android device before generating a Baseline Profile.');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
console.log(`Generating Baseline Profile using one ADB connection: ${serial}`);
|
|
23
|
+
const args = [':app:generateBaselineProfile', '--console=plain'];
|
|
24
|
+
const result = spawnSync(
|
|
25
|
+
process.platform === 'win32' ? 'cmd.exe' : './gradlew',
|
|
26
|
+
process.platform === 'win32' ? ['/d', '/s', '/c', `gradlew.bat ${args.join(' ')}`] : args,
|
|
27
|
+
{
|
|
28
|
+
cwd: path.resolve(__dirname, '..', 'android'),
|
|
29
|
+
env: { ...process.env, ANDROID_SERIAL: serial },
|
|
30
|
+
stdio: 'inherit',
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
if (result.error) throw result.error;
|
|
34
|
+
if (result.signal) throw new Error(`Baseline Profile generation stopped by ${result.signal}.`);
|
|
35
|
+
process.exitCode = result.status ?? 1;
|
|
36
|
+
if (process.exitCode === 0) {
|
|
37
|
+
syncGeneratedProfileBackup({ backupOnly: true });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
main();
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error(`Baseline Profile generation failed: ${error.message}`);
|
|
45
|
+
process.exitCode = 1;
|
|
46
|
+
}
|
|
@@ -1413,6 +1413,45 @@ async function capturePageSnapshot(client) {
|
|
|
1413
1413
|
}
|
|
1414
1414
|
}
|
|
1415
1415
|
|
|
1416
|
+
// Replay runs outside the WebView origin. Preserve imported icon styles and
|
|
1417
|
+
// embed fonts so native localhost URLs and font CORS cannot break ligatures.
|
|
1418
|
+
const fontResources = new Map();
|
|
1419
|
+
const serializeCss = async (cssText, baseUrl, ancestors = []) => {
|
|
1420
|
+
const imports = [...cssText.matchAll(/@import\\s+(?:url\\(\\s*(['"]?)([^'"\\)]+)\\1\\s*\\)|(['"])([^'"]+)\\3)\\s*([^;]*);/gi)];
|
|
1421
|
+
for (const match of imports) {
|
|
1422
|
+
const importUrl = new URL((match[2] || match[4]).trim(), baseUrl).href;
|
|
1423
|
+
if (ancestors.includes(importUrl)) continue;
|
|
1424
|
+
const response = await fetch(importUrl);
|
|
1425
|
+
if (!response.ok) throw new Error('Could not capture stylesheet: ' + importUrl);
|
|
1426
|
+
const importedCss = await serializeCss(await response.text(), importUrl, [...ancestors, importUrl]);
|
|
1427
|
+
cssText = cssText.replace(match[0], match[5].trim()
|
|
1428
|
+
? '@media ' + match[5].trim() + '{' + importedCss + '}'
|
|
1429
|
+
: importedCss);
|
|
1430
|
+
}
|
|
1431
|
+
const resources = [...cssText.matchAll(/url\\(\\s*(['"]?)(?!data:|#)([^'"\\)]+)\\1\\s*\\)/gi)];
|
|
1432
|
+
for (const match of resources) {
|
|
1433
|
+
const resourceUrl = new URL(match[2].trim(), baseUrl).href;
|
|
1434
|
+
let replayUrl = resourceUrl;
|
|
1435
|
+
if (/\\.(?:woff2?|ttf|otf)(?:[?#]|$)/i.test(resourceUrl) || resourceUrl.startsWith('blob:')) {
|
|
1436
|
+
if (!fontResources.has(resourceUrl)) {
|
|
1437
|
+
fontResources.set(resourceUrl, (async () => {
|
|
1438
|
+
const response = await fetch(resourceUrl);
|
|
1439
|
+
if (!response.ok) throw new Error('Could not capture font: ' + resourceUrl);
|
|
1440
|
+
return blobToDataUrl(await response.blob());
|
|
1441
|
+
})());
|
|
1442
|
+
}
|
|
1443
|
+
replayUrl = await fontResources.get(resourceUrl);
|
|
1444
|
+
}
|
|
1445
|
+
cssText = cssText.replace(match[0], 'url("' + replayUrl + '")');
|
|
1446
|
+
}
|
|
1447
|
+
return cssText;
|
|
1448
|
+
};
|
|
1449
|
+
|
|
1450
|
+
await Promise.all(originalElements.map(async (element, index) => {
|
|
1451
|
+
if (element.tagName?.toLowerCase() !== 'style') return;
|
|
1452
|
+
clonedElements[index].textContent = await serializeCss(element.textContent, sourceDocument.baseURI);
|
|
1453
|
+
}));
|
|
1454
|
+
|
|
1416
1455
|
const stylesheetLinks = [...sourceDocument.querySelectorAll('link[rel="stylesheet"]')];
|
|
1417
1456
|
const clonedStylesheetLinks = [...clonedRoot.querySelectorAll('link[rel="stylesheet"]')];
|
|
1418
1457
|
|
|
@@ -1421,16 +1460,7 @@ async function capturePageSnapshot(client) {
|
|
|
1421
1460
|
const response = await fetch(link.href);
|
|
1422
1461
|
if (!response.ok) return;
|
|
1423
1462
|
|
|
1424
|
-
const cssText = (await response.text())
|
|
1425
|
-
/url\\(\\s*(['"]?)(?!data:|blob:|#)([^'"\\)]+)\\1\\s*\\)/gi,
|
|
1426
|
-
(match, quote, resourceUrl) => {
|
|
1427
|
-
try {
|
|
1428
|
-
return 'url("' + new URL(resourceUrl.trim(), link.href).href + '")';
|
|
1429
|
-
} catch {
|
|
1430
|
-
return match;
|
|
1431
|
-
}
|
|
1432
|
-
},
|
|
1433
|
-
);
|
|
1463
|
+
const cssText = await serializeCss(await response.text(), link.href);
|
|
1434
1464
|
const style = sourceDocument.createElement('style');
|
|
1435
1465
|
style.textContent = cssText;
|
|
1436
1466
|
clonedStylesheetLinks[index].replaceWith(style);
|
package/package.json
CHANGED
|
@@ -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
|
+
});
|