codeplay-common 4.11.4 → 4.11.6
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
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
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.
|
|
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.
|
|
7
|
+
- Stop on reinstall failure or incomplete legacy cleanup rather than continuing with stale build templates.
|
|
8
|
+
|
|
3
9
|
## 4.11.4 — 2026-10-27
|
|
4
10
|
|
|
5
11
|
Version name: 4.11.4. Version code/build number: not applicable to this npm package.
|
|
@@ -11,80 +17,80 @@ Files changed: `package.json`, `scripts/sync-files.js`, `files/buildCodeplay/fix
|
|
|
11
17
|
- Ship the helper inside `buildCodeplay` so shared templates do not depend on an app-specific `Scripts` file.
|
|
12
18
|
- Provide `npm run android:r8-rules` and migrate the known previous helper command while preserving custom commands.
|
|
13
19
|
- Keep permission declarations, prompts, minification settings and iOS configuration unchanged; already-distributed binaries require rebuilding.
|
|
14
|
-
- Preserve explicit release minification settings when distributing shared templates, and retain the tested FFmpeg JNI rules when that plugin is installed.
|
|
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
|
-
- Migrate known legacy filename lookups in an existing app configurator after installing shared scripts.
|
|
23
|
-
- Prefer unversioned pre-build and package-ID helpers while retaining the versioned fallback.
|
|
24
|
-
- Correct the known old sync-hook folder assignment without replacing app-specific configuration or adding a configurator to apps that do not have one.
|
|
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
|
-
- Ship an updated sync-after hook for apps retaining the custom hook command after script migration.
|
|
33
|
-
- Run unversioned splash helpers instead of searching for removed versioned filenames.
|
|
34
|
-
- Resolve baseline profile setup from `scripts-common/` and preserve the existing native splash when no splash icon is configured.
|
|
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
|
-
- Allow ad-free apps with `plugins.AdMob.ADMOB_ENABLED: false` to pass release validation without an AdMob alias or controller.
|
|
43
|
-
- Continue requiring a production AdMob alias when advertising is enabled or the enabled flag is unspecified.
|
|
44
|
-
- Preserve rejection of test aliases, commented or duplicate aliases, and missing production controllers for apps with ads 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
|
-
Bundled pre-build script: 6.4.
|
|
80
|
-
|
|
81
|
-
Files changed: `package.json`, `scripts/sync-files.js`, `files/buildCodeplay/codeplayBeforeBuild-6.4.js`
|
|
82
|
-
(replaces `codeplayBeforeBuild-6.3.js`), `README.md`, `CHANGELOG.md`, `RELEASE_NOTES.md`.
|
|
83
|
-
|
|
84
|
-
- Keep `npm run build` as the Android default on every host; add `npm run build:ios` automatically during installation.
|
|
85
|
-
- Route `build-capacitor-android` through the same pre-build validation before copying the web build.
|
|
86
|
-
- Migrate direct save-gallery imports to `@saveGallery` and select the matching platform helper in Vite after one detailed Enter/y confirmation.
|
|
87
|
-
- Stop without import writes on cancellation, missing helpers, mixed versions, unsupported query/hash aliases or concurrent source edits.
|
|
88
|
-
- Reuse source directory traversal and combine gallery, retired OneSignal import, StatusBar and editor checks in one content pass.
|
|
89
|
-
- Automatically remove an installed/declared `onesignal-cordova-plugin` with a warning; skip legacy OneSignal patching/helper downloads and stop on remaining package imports.
|
|
90
|
-
- Keep `agent-temp/` ignored and remove existing `buildCodeplay/` ignore entries without adding them in future projects.
|
|
20
|
+
- Preserve explicit release minification settings when distributing shared templates, and retain the tested FFmpeg JNI rules when that plugin is installed.
|
|
21
|
+
|
|
22
|
+
## 4.10.5 — 2026-10-23
|
|
23
|
+
|
|
24
|
+
Version name: 4.10.5. Version code/build number: not applicable to this npm package.
|
|
25
|
+
|
|
26
|
+
Files changed: `package.json`, `scripts/sync-files.js`, `CHANGELOG.md`, `RELEASE_NOTES.md`.
|
|
27
|
+
|
|
28
|
+
- Migrate known legacy filename lookups in an existing app configurator after installing shared scripts.
|
|
29
|
+
- Prefer unversioned pre-build and package-ID helpers while retaining the versioned fallback.
|
|
30
|
+
- Correct the known old sync-hook folder assignment without replacing app-specific configuration or adding a configurator to apps that do not have one.
|
|
31
|
+
|
|
32
|
+
## 4.10.4 — 2026-10-23
|
|
33
|
+
|
|
34
|
+
Version name: 4.10.4. Version code/build number: not applicable to this npm package.
|
|
35
|
+
|
|
36
|
+
Files changed: `package.json`, `files/scripts-common/run-codeplay-sync-after.js`, `CHANGELOG.md`, `RELEASE_NOTES.md`.
|
|
37
|
+
|
|
38
|
+
- Ship an updated sync-after hook for apps retaining the custom hook command after script migration.
|
|
39
|
+
- Run unversioned splash helpers instead of searching for removed versioned filenames.
|
|
40
|
+
- Resolve baseline profile setup from `scripts-common/` and preserve the existing native splash when no splash icon is configured.
|
|
41
|
+
|
|
42
|
+
## 4.10.3 — 2026-10-23
|
|
43
|
+
|
|
44
|
+
Version name: 4.10.3. Version code/build number: not applicable to this npm package.
|
|
45
|
+
|
|
46
|
+
Files changed: `package.json`, `files/finalrelease`, `CHANGELOG.md`, `RELEASE_NOTES.md`.
|
|
47
|
+
|
|
48
|
+
- Allow ad-free apps with `plugins.AdMob.ADMOB_ENABLED: false` to pass release validation without an AdMob alias or controller.
|
|
49
|
+
- Continue requiring a production AdMob alias when advertising is enabled or the enabled flag is unspecified.
|
|
50
|
+
- Preserve rejection of test aliases, commented or duplicate aliases, and missing production controllers for apps with ads enabled.
|
|
51
|
+
|
|
52
|
+
## 4.10.0 — 2026-10-23
|
|
53
|
+
|
|
54
|
+
Version name: 4.10.0. Version code/build number: not applicable to this npm package.
|
|
55
|
+
Bundled pre-build script: 6.7.
|
|
56
|
+
|
|
57
|
+
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`.
|
|
58
|
+
|
|
59
|
+
- Copy shared build scripts and the versions manifest into each app; run local scripts with unversioned filenames.
|
|
60
|
+
- Rename app helper scripts to scripts-common automatically, migrate command paths, and preserve existing files without overwriting folder conflicts.
|
|
61
|
+
- Migrate app build/store/sync paths automatically and remove only superseded versioned helpers; preserve app-owned configuration and screenshot data.
|
|
62
|
+
- Resolve app sources/native targets from the consuming app directory while keeping bundled assets inside the plugin.
|
|
63
|
+
- Download IAP and AdMob directly from htmlcodeplay.com, without bundling archives or adding a separate fallback.
|
|
64
|
+
- Automatically migrate deferred ownership verification, purchase-safe advertising, and Home Pro visibility according to each store IAP flag.
|
|
65
|
+
- Copy the full finalrelease implementation so it can be tested from the application folder.
|
|
66
|
+
- Preserve working files during preinstall and avoid downgrading local/newer plugin installations to an older registry release.
|
|
67
|
+
|
|
68
|
+
## 4.9.8 — 2026-10-22
|
|
69
|
+
|
|
70
|
+
Version name: 4.9.8. Version code/build number: not applicable to this npm package.
|
|
71
|
+
Bundled pre-build script: 6.5.
|
|
72
|
+
|
|
73
|
+
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`.
|
|
74
|
+
|
|
75
|
+
- Install AdMob as `src/js/Ads/admob-nextgen-4.0/` with stable `admob-emi-nextgen.js` and `app-open-state.js` filenames.
|
|
76
|
+
- Automatically migrate loose-file references, folder references and Vite aliases during installation and before builds.
|
|
77
|
+
- Preserve app-owned ad configuration and select each app's existing IAP analytics module.
|
|
78
|
+
- Download every AdMob folder ZIP from htmlcodeplay.com; no AdMob archive is included in this npm package.
|
|
79
|
+
- Validate ZIP contents before switching imports; retain the working package when a remote update fails.
|
|
80
|
+
- Validate the selected folder controller during final-release checks while continuing to reject test aliases.
|
|
81
|
+
|
|
82
|
+
## 4.7.7 — 2026-10-07
|
|
83
|
+
|
|
84
|
+
Version name: 4.7.7. Version code/build number: not applicable to this npm package.
|
|
85
|
+
Bundled pre-build script: 6.4.
|
|
86
|
+
|
|
87
|
+
Files changed: `package.json`, `scripts/sync-files.js`, `files/buildCodeplay/codeplayBeforeBuild-6.4.js`
|
|
88
|
+
(replaces `codeplayBeforeBuild-6.3.js`), `README.md`, `CHANGELOG.md`, `RELEASE_NOTES.md`.
|
|
89
|
+
|
|
90
|
+
- Keep `npm run build` as the Android default on every host; add `npm run build:ios` automatically during installation.
|
|
91
|
+
- Route `build-capacitor-android` through the same pre-build validation before copying the web build.
|
|
92
|
+
- Migrate direct save-gallery imports to `@saveGallery` and select the matching platform helper in Vite after one detailed Enter/y confirmation.
|
|
93
|
+
- Stop without import writes on cancellation, missing helpers, mixed versions, unsupported query/hash aliases or concurrent source edits.
|
|
94
|
+
- Reuse source directory traversal and combine gallery, retired OneSignal import, StatusBar and editor checks in one content pass.
|
|
95
|
+
- Automatically remove an installed/declared `onesignal-cordova-plugin` with a warning; skip legacy OneSignal patching/helper downloads and stop on remaining package imports.
|
|
96
|
+
- Keep `agent-temp/` ignored and remove existing `buildCodeplay/` ignore entries without adding them in future projects.
|
package/README.md
CHANGED
|
@@ -31,6 +31,8 @@ App package scripts run local files: node buildCodeplay/codeplayBeforeBuild.js,
|
|
|
31
31
|
|
|
32
32
|
Installation migrates both legacy versioned filenames and the temporary node_modules runner commands to these local paths. It removes only superseded versioned build scripts, preserves app-owned release configuration and splash XML overrides, and keeps screenshot data and custom helpers. The root finalrelease script is also copied as a local implementation.
|
|
33
33
|
|
|
34
|
+
After this update is installed, `npm run build` checks the app's `buildCodeplay/` folder for version-suffixed files before preparing the build. If any exist, it runs `npm uninstall codeplay-common` followed by `npm install codeplay-common`, then runs the refreshed before-build script before continuing. A failed command or remaining versioned files stops the build. Unrecognized legacy files must be migrated manually; they are not deleted automatically.
|
|
35
|
+
|
|
34
36
|
Before-build includes the automatic IAP startup and Home Pro-button migrations. IAP and AdMob ZIPs are downloaded directly from https://htmlcodeplay.com/code-play-plugin/ using the existing update flow. No plugin ZIPs are bundled in this npm package. App-specific configuration and designs remain in the app.
|
|
35
37
|
|
|
36
38
|
## AdMob folder packages
|
|
@@ -223,5 +225,5 @@ Version : 4.0.0 (Previous version 3.2.19)
|
|
|
223
225
|
1) In here we are completly remove the admob-emi and use "capacitor-admob-nextgen"
|
|
224
226
|
2) Removed "modify-plugin-xml.js"
|
|
225
227
|
3)
|
|
226
|
-
|
|
227
|
-
The fix preserves the metadata behind the release permission-check failure verified in testing. It does not guarantee every native dialog or plugin: required manifest declarations, Android permission policy, device settings and plugin-specific keep rules still apply.
|
|
228
|
+
|
|
229
|
+
The fix preserves the metadata behind the release permission-check failure verified in testing. It does not guarantee every native dialog or plugin: required manifest declarations, Android permission policy, device settings and plugin-specific keep rules still apply.
|
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.
|
|
@@ -1,7 +1,16 @@
|
|
|
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.
|
|
4
5
|
// Version 6.7: recreate failed WebViews, defer background recovery, and suppress foreground recovery toasts.
|
|
6
|
+
// Reinstall legacy build templates before loading dependencies or changing the app.
|
|
7
|
+
try {
|
|
8
|
+
if (require('./ensure-current-build.cjs').ensureCurrentBuild()) process.exit(0);
|
|
9
|
+
} catch (error) {
|
|
10
|
+
console.error(`Build preparation failed: ${error.message}`);
|
|
11
|
+
process.exit(typeof error.status === 'number' && error.status > 0 ? error.status : 1);
|
|
12
|
+
}
|
|
13
|
+
|
|
5
14
|
const fs = require('fs');
|
|
6
15
|
const path = require('path');
|
|
7
16
|
const plist = require('plist');
|
|
@@ -4597,11 +4606,32 @@ function syncAndroidCordovaResourceKeep() {
|
|
|
4597
4606
|
if (buildPlatform !== 'android' || !fs.existsSync(androidPlatformPath)) return;
|
|
4598
4607
|
|
|
4599
4608
|
// Cordova loads config.xml by name; preserve it even when no plugins are installed yet.
|
|
4600
|
-
const
|
|
4609
|
+
const resPath = path.join(androidPlatformPath, 'app', 'src', 'main', 'res');
|
|
4610
|
+
const rawPath = path.join(resPath, 'raw');
|
|
4601
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
|
+
}
|
|
4602
4632
|
const content = '<?xml version="1.0" encoding="utf-8"?>\n'
|
|
4603
4633
|
+ '<resources xmlns:tools="http://schemas.android.com/tools"\n'
|
|
4604
|
-
+
|
|
4634
|
+
+ ` tools:keep="${[...keepResources].sort().join(',')}" />\n`;
|
|
4605
4635
|
if (fs.existsSync(keepPath) && fs.readFileSync(keepPath, 'utf8') === content) return;
|
|
4606
4636
|
|
|
4607
4637
|
fs.mkdirSync(rawPath, { recursive: true });
|
|
@@ -0,0 +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 };
|
package/package.json
CHANGED
|
@@ -0,0 +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
|
+
});
|