codeplay-common 4.9.9 → 4.10.1
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 +33 -17
- package/README.md +24 -10
- package/RELEASE_NOTES.md +31 -15
- package/files/buildCodeplay/{add-splash-screen-1.6.js → add-splash-screen.js} +255 -254
- package/files/buildCodeplay/apk-store-builder.js +97 -97
- package/files/buildCodeplay/{codeplayBeforeBuild-6.5.js → codeplayBeforeBuild.js} +179 -80
- package/files/buildCodeplay/fix-onesignal-plugin.js +96 -96
- package/files/buildCodeplay/ios-emi-admob-modification.js +24 -24
- package/files/buildCodeplay/manifestModification.js +23 -23
- package/files/buildCodeplay/{packageidBaseModification-1.4.js → packageidBaseModification.js} +445 -445
- package/files/buildCodeplay/project-scripts.cjs +56 -0
- package/files/buildCodeplay/{setSplashAnimation-1.4.js → setSplashAnimation.js} +156 -156
- package/files/buildCodeplay/sync-admob-nextgen.js +6 -5
- package/files/buildCodeplay/versions.json +25 -25
- package/files/finalrelease +1222 -1343
- package/files/take-screen-image.js +2 -2
- package/package.json +14 -5
- package/scripts/sync-files.js +80 -112
- package/scripts/uninstall.js +3 -123
- package/.gitattributes +0 -2
- package/files/buildCodeplay/codeplayBeforeBuild-6.4.js +0 -4510
- package/files/iap-install-2.js +0 -145
- /package/files/{scripts → scripts-common}/screenshot/background-decorations.js +0 -0
- /package/files/{scripts → scripts-common}/screenshot/frame-samples.js +0 -0
- /package/files/{scripts → scripts-common}/setup-baseline-profile.js +0 -0
|
@@ -26,12 +26,12 @@ const path = require('node:path');
|
|
|
26
26
|
const readline = require('node:readline/promises');
|
|
27
27
|
const { spawn, spawnSync } = require('node:child_process');
|
|
28
28
|
const sharp = require('sharp');
|
|
29
|
-
const { frameStyles, createFrameSamples } = require('./scripts/screenshot/frame-samples.js');
|
|
29
|
+
const { frameStyles, createFrameSamples } = require('./scripts-common/screenshot/frame-samples.js');
|
|
30
30
|
const {
|
|
31
31
|
getDecorationSeed,
|
|
32
32
|
createPromotionalDecorations,
|
|
33
33
|
getPromotionalDecorationStyles,
|
|
34
|
-
} = require('./scripts/screenshot/background-decorations.js');
|
|
34
|
+
} = require('./scripts-common/screenshot/background-decorations.js');
|
|
35
35
|
|
|
36
36
|
const screenshotDirectory = path.join(__dirname, 'Auto-Screenshot', 'Store-image-Screenshot');
|
|
37
37
|
const inFrameDirectory = path.join(__dirname, 'Auto-Screenshot', 'Store-image-Frame');
|
package/package.json
CHANGED
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codeplay-common",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.1",
|
|
4
4
|
"description": "Common build scripts and files",
|
|
5
5
|
"scripts": {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
"postinstall": "node scripts/sync-files.js",
|
|
7
|
+
"preinstall": "node scripts/uninstall.js"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"adm-zip": "^0.6.1"
|
|
10
|
+
"adm-zip": "^0.6.1",
|
|
11
|
+
"plist": "^3.1.0"
|
|
11
12
|
},
|
|
12
13
|
"repository": {
|
|
13
14
|
"type": "git",
|
|
14
15
|
"url": "https://github.com/merbin2012/codeplay-common.git"
|
|
15
16
|
},
|
|
16
17
|
"author": "Codeplay Technologies",
|
|
17
|
-
"license": "MIT"
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"files": [
|
|
20
|
+
"files/",
|
|
21
|
+
"scripts/",
|
|
22
|
+
"README.md",
|
|
23
|
+
"CHANGELOG.md",
|
|
24
|
+
"RELEASE_NOTES.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
]
|
|
18
27
|
}
|
package/scripts/sync-files.js
CHANGED
|
@@ -1,118 +1,86 @@
|
|
|
1
|
-
const fs = require(
|
|
2
|
-
const path = require(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (!fs.existsSync(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
process.stdout.write(`✅ Copied folder: ${source} -> ${destination}\n`);
|
|
21
|
-
} catch (error) {
|
|
22
|
-
process.stderr.write(`⚠️ Failed to copy folder: ${source} - ${error.message}\n`);
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { updateBuildScripts, removeVersionedBuildScripts } = require('../files/buildCodeplay/project-scripts.cjs');
|
|
4
|
+
|
|
5
|
+
function migrateAppScripts(projectRoot) {
|
|
6
|
+
const root = path.resolve(projectRoot);
|
|
7
|
+
const source = path.resolve(root, 'scripts');
|
|
8
|
+
const destination = path.resolve(root, 'scripts-common');
|
|
9
|
+
if (path.dirname(source) !== root || path.dirname(destination) !== root) throw new Error('Invalid app scripts path.');
|
|
10
|
+
if (!fs.existsSync(source)) return;
|
|
11
|
+
// Preflight the entire tree before moving anything. Never overwrite a
|
|
12
|
+
// different existing file or follow a linked directory.
|
|
13
|
+
function check(from, to) {
|
|
14
|
+
if (fs.lstatSync(from).isSymbolicLink() || (fs.existsSync(to) && fs.lstatSync(to).isSymbolicLink())) throw new Error('Cannot migrate linked script paths.');
|
|
15
|
+
if (!fs.existsSync(to)) return;
|
|
16
|
+
if (fs.statSync(from).isDirectory() && fs.statSync(to).isDirectory()) {
|
|
17
|
+
for (const name of fs.readdirSync(from)) check(path.join(from, name), path.join(to, name));
|
|
18
|
+
} else if (!fs.statSync(from).isFile() || !fs.statSync(to).isFile() || !fs.readFileSync(from).equals(fs.readFileSync(to))) {
|
|
19
|
+
throw new Error(`Scripts folder conflict; both files preserved: ${to}`);
|
|
23
20
|
}
|
|
21
|
+
}
|
|
22
|
+
function move(from, to) {
|
|
23
|
+
if (!fs.existsSync(to)) { fs.renameSync(from, to); return; }
|
|
24
|
+
if (fs.statSync(from).isDirectory()) {
|
|
25
|
+
for (const name of fs.readdirSync(from)) move(path.join(from, name), path.join(to, name));
|
|
26
|
+
fs.rmdirSync(from);
|
|
27
|
+
} else fs.unlinkSync(from); // Identical existing file, verified above.
|
|
28
|
+
}
|
|
29
|
+
check(source, destination);
|
|
30
|
+
move(source, destination);
|
|
24
31
|
}
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
if (fs.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
fs.copyFileSync(sourcePath, destPath);
|
|
38
|
-
process.stdout.write(`✅ Copied file: ${file}\n`);
|
|
39
|
-
} catch (error) {
|
|
40
|
-
process.stderr.write(`⚠️ Failed to copy file: ${file} - ${error.message}\n`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
// Function to get the latest versioned file from files/buildCodeplay
|
|
46
|
-
function getLatestFile(prefix) {
|
|
47
|
-
if (!fs.existsSync(buildCodeplayPath)) return null; // Ensure directory exists
|
|
48
|
-
|
|
49
|
-
const files = fs.readdirSync(buildCodeplayPath).filter(file => file.startsWith(prefix));
|
|
50
|
-
if (files.length === 0) return null;
|
|
51
|
-
files.sort((a, b) => b.localeCompare(a, undefined, { numeric: true }));
|
|
52
|
-
return files[0];
|
|
33
|
+
function findProjectRoot() {
|
|
34
|
+
// npm may execute a file: dependency's lifecycle in its source directory.
|
|
35
|
+
// INIT_CWD identifies the app that invoked npm in that case.
|
|
36
|
+
for (const candidate of [process.env.INIT_CWD, path.join(__dirname, '../../..')]) {
|
|
37
|
+
if (!candidate) continue;
|
|
38
|
+
const root = path.resolve(candidate);
|
|
39
|
+
const file = path.join(root, 'package.json');
|
|
40
|
+
if (!fs.existsSync(file)) continue;
|
|
41
|
+
if (JSON.parse(fs.readFileSync(file, 'utf8')).name !== 'codeplay-common' && fs.existsSync(path.join(root, 'capacitor.config.json'))) return root;
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
53
44
|
}
|
|
54
45
|
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
46
|
+
function install(options = {}) {
|
|
47
|
+
const resolved = options.projectRoot || findProjectRoot();
|
|
48
|
+
if (!resolved) {
|
|
49
|
+
console.log('codeplay-common: no consuming Capacitor app found; skipping source-package setup.');
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const projectRoot = path.resolve(resolved);
|
|
53
|
+
const commonFiles = path.resolve(__dirname, '../files');
|
|
54
|
+
const packagePath = path.join(projectRoot, 'package.json');
|
|
55
|
+
if (!fs.existsSync(packagePath)) throw new Error('Consuming application package.json was not found.');
|
|
56
|
+
const pkg = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
|
|
57
|
+
const scripts = updateBuildScripts(pkg.scripts || {});
|
|
58
|
+
migrateAppScripts(projectRoot);
|
|
59
|
+
// Copy the common templates into each application for local testing.
|
|
60
|
+
const buildSource = path.join(commonFiles, 'buildCodeplay');
|
|
61
|
+
const buildTarget = path.join(projectRoot, 'buildCodeplay');
|
|
62
|
+
fs.mkdirSync(buildTarget, { recursive: true });
|
|
63
|
+
for (const name of fs.readdirSync(buildSource)) {
|
|
64
|
+
const target = path.join(buildTarget, name);
|
|
65
|
+
if ((name === 'release-sync.config.json' || name === 'splashxml') && fs.existsSync(target)) continue;
|
|
66
|
+
fs.cpSync(path.join(buildSource, name), target, { recursive: true });
|
|
67
|
+
}
|
|
68
|
+
fs.copyFileSync(path.join(commonFiles, 'finalrelease'), path.join(projectRoot, 'finalrelease'));
|
|
69
|
+
if (options.copyAssets !== false) {
|
|
70
|
+
for (const name of fs.readdirSync(commonFiles)) {
|
|
71
|
+
if (name === 'buildCodeplay' || name === 'scripts-screenshot') continue;
|
|
72
|
+
fs.cpSync(path.join(commonFiles, name), path.join(projectRoot, name), { recursive: true });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
pkg.scripts = scripts;
|
|
76
|
+
fs.writeFileSync(packagePath, JSON.stringify(pkg, null, 2) + '\n');
|
|
77
|
+
// Cleanup happens only after replacement assets and package commands exist.
|
|
78
|
+
removeVersionedBuildScripts(projectRoot);
|
|
79
|
+
console.log('codeplay-common: unversioned build scripts copied to app buildCodeplay; app-owned settings preserved.');
|
|
80
|
+
// Coupled IAP/AdMob/Home migrations run together during before-build.
|
|
81
|
+
return pkg;
|
|
90
82
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
packageJson.scripts["build:ios"] = "cross-env CODEPLAY_BUILD_PLATFORM=ios npm run build";
|
|
96
|
-
packageJson.scripts["build-capacitor-android"] = "npm run build && npx cap copy android";
|
|
97
|
-
|
|
98
|
-
packageJson.scripts["ionic:build"] = "npm run build";
|
|
99
|
-
packageJson.scripts["ionic:serve"] = "cross-env NODE_ENV=development vite";
|
|
100
|
-
packageJson.scripts["build:storeid1"] = "vite build --mode storeid1";
|
|
101
|
-
packageJson.scripts["build:storeid2"] = "vite build --mode storeid2";
|
|
102
|
-
packageJson.scripts["build:storeid3"] = "vite build --mode storeid3";
|
|
103
|
-
packageJson.scripts["build:storeid4"] = "vite build --mode storeid4";
|
|
104
|
-
packageJson.scripts["build:storeid5"] = "vite build --mode storeid5";
|
|
105
|
-
//packageJson.scripts["build:storeid6"] = "vite build --mode storeid6";
|
|
106
|
-
packageJson.scripts["build:storeid7"] = "vite build --mode storeid7";
|
|
107
|
-
packageJson.scripts["build:storeid8"] = "vite build --mode storeid8";
|
|
108
|
-
// Save changes
|
|
109
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
|
|
110
|
-
process.stdout.write("✅ package.json updated!\n");
|
|
111
|
-
|
|
112
|
-
// Migrate AdMob packages and imports during installation, without running native builds.
|
|
113
|
-
require(path.join(projectRoot, 'buildCodeplay', 'sync-admob-nextgen.js'))
|
|
114
|
-
.syncAdmobNextgen({ projectRoot, AdmZip: require('adm-zip') })
|
|
115
|
-
.catch(error => {
|
|
116
|
-
process.stderr.write('AdMob migration failed: ' + error.message + '\n');
|
|
117
|
-
process.exitCode = 1;
|
|
118
|
-
});
|
|
83
|
+
module.exports = { install, findProjectRoot, migrateAppScripts };
|
|
84
|
+
if (require.main === module) {
|
|
85
|
+
try { install(); } catch (error) { console.error(error.message); process.exitCode = 1; }
|
|
86
|
+
}
|
package/scripts/uninstall.js
CHANGED
|
@@ -1,123 +1,3 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
"setSplashAnimation",
|
|
5
|
-
"codeplayBeforeBuild",
|
|
6
|
-
"finalrelease"
|
|
7
|
-
];
|
|
8
|
-
|
|
9
|
-
const fs = require("fs");
|
|
10
|
-
const path = require("path");
|
|
11
|
-
|
|
12
|
-
const projectRoot = path.resolve(__dirname, "../../../"); // Project root
|
|
13
|
-
const commonBuildPath = path.join(__dirname, "../files"); // Path where files were copied from
|
|
14
|
-
const splashXmlPath = path.join(projectRoot, "buildCodeplay"); // Path to splashxml folder
|
|
15
|
-
const baselineProfileSetupScript = path.join(projectRoot, "scripts", "setup-baseline-profile.js");
|
|
16
|
-
const baselineProfileBackup = path.join(projectRoot, "baselineProfiles", "baseline-prof.txt");
|
|
17
|
-
|
|
18
|
-
const isAgentInstructionAsset = (file) => {
|
|
19
|
-
const normalizedName = file.toLowerCase();
|
|
20
|
-
return normalizedName === "agents" || normalizedName === "agents.md";
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
process.stdout.write("🚀 Uninstalling: Removing old and copied files...\n");
|
|
24
|
-
|
|
25
|
-
const removeDirectory = (dirPath) => {
|
|
26
|
-
if (fs.existsSync(dirPath)) {
|
|
27
|
-
fs.readdirSync(dirPath).forEach(file => {
|
|
28
|
-
const currentPath = path.join(dirPath, file);
|
|
29
|
-
if (fs.lstatSync(currentPath).isDirectory()) {
|
|
30
|
-
removeDirectory(currentPath);
|
|
31
|
-
} else {
|
|
32
|
-
fs.unlinkSync(currentPath);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
fs.rmdirSync(dirPath);
|
|
36
|
-
process.stdout.write(`🗑️ Removed folder: ${dirPath}\n`);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
removeDirectory(splashXmlPath);
|
|
41
|
-
removeDirectory(path.join(projectRoot, "splashxml")); // Remove old splashxml folder
|
|
42
|
-
|
|
43
|
-
// Step 1: Find all matching files in the project directory
|
|
44
|
-
const filePatternsToRemove = [
|
|
45
|
-
/^add-splash-screen-.*$/,
|
|
46
|
-
/^setSplashAnimation-.*$/,
|
|
47
|
-
/^codeplayBeforeBuild-.*$/,
|
|
48
|
-
/^modify-plugin-xml\.xml$/,
|
|
49
|
-
/^finalrelease.*$/,
|
|
50
|
-
/^iap-install-\d+(\.\d+)?\.js$/,
|
|
51
|
-
/^\.env\.storeid[1-7]$/,
|
|
52
|
-
/^modify-plugin-xml\.js$/
|
|
53
|
-
];
|
|
54
|
-
|
|
55
|
-
const filesInProject = fs.readdirSync(projectRoot);
|
|
56
|
-
|
|
57
|
-
filesInProject.forEach(file => {
|
|
58
|
-
if (filePatternsToRemove.some(pattern => pattern.test(file))) {
|
|
59
|
-
const filePath = path.join(projectRoot, file);
|
|
60
|
-
try {
|
|
61
|
-
fs.unlinkSync(filePath);
|
|
62
|
-
process.stdout.write(`🗑️ Removed file: ${filePath}\n`);
|
|
63
|
-
} catch (error) {
|
|
64
|
-
process.stderr.write(`⚠️ Failed to remove ${filePath}: ${error.message}\n`);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
// Remove files and folders listed in commonBuildPath
|
|
70
|
-
if (fs.existsSync(commonBuildPath)) {
|
|
71
|
-
fs.readdirSync(commonBuildPath).forEach(file => {
|
|
72
|
-
const destPath = path.join(projectRoot, file);
|
|
73
|
-
// Screenshot data belongs to the app, including folders from older releases.
|
|
74
|
-
if (file === "scripts" || file === "scripts-screenshot" || isAgentInstructionAsset(file)) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (fs.existsSync(destPath)) {
|
|
78
|
-
try {
|
|
79
|
-
if (fs.lstatSync(destPath).isDirectory()) {
|
|
80
|
-
removeDirectory(destPath);
|
|
81
|
-
} else {
|
|
82
|
-
fs.unlinkSync(destPath);
|
|
83
|
-
process.stdout.write(`🗑️ Removed file: ${destPath}\n`);
|
|
84
|
-
}
|
|
85
|
-
} catch (error) {
|
|
86
|
-
process.stderr.write(`⚠️ Failed to remove ${destPath}: ${error.message}\n`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
for (const helperDirectory of [
|
|
93
|
-
path.join(projectRoot, "scripts", "screenshot"),
|
|
94
|
-
path.join(projectRoot, "scripts-screenshot", "screenshot")
|
|
95
|
-
]) {
|
|
96
|
-
for (const helperName of ["frame-samples.js", "background-decorations.js"]) {
|
|
97
|
-
const helperPath = path.join(helperDirectory, helperName);
|
|
98
|
-
if (fs.existsSync(helperPath)) {
|
|
99
|
-
fs.unlinkSync(helperPath);
|
|
100
|
-
process.stdout.write(`🗑️ Removed file: ${helperPath}\n`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (fs.existsSync(baselineProfileSetupScript)) {
|
|
106
|
-
try {
|
|
107
|
-
fs.unlinkSync(baselineProfileSetupScript);
|
|
108
|
-
process.stdout.write(`🗑️ Removed file: ${baselineProfileSetupScript}\n`);
|
|
109
|
-
} catch (error) {
|
|
110
|
-
process.stderr.write(`⚠️ Failed to remove ${baselineProfileSetupScript}: ${error.message}\n`);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (fs.existsSync(baselineProfileBackup)) {
|
|
115
|
-
try {
|
|
116
|
-
fs.unlinkSync(baselineProfileBackup);
|
|
117
|
-
process.stdout.write(`🗑️ Removed file: ${baselineProfileBackup}\n`);
|
|
118
|
-
} catch (error) {
|
|
119
|
-
process.stderr.write(`⚠️ Failed to remove ${baselineProfileBackup}: ${error.message}\n`);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
process.stdout.write("✅ Uninstall cleanup complete!\n");
|
|
1
|
+
// Preserve working app files during preinstall. Postinstall migrates commands
|
|
2
|
+
// first, then removes only recognized copied build scripts.
|
|
3
|
+
console.log('codeplay-common: preserving app files until installation completes.');
|
package/.gitattributes
DELETED