codeplay-common 3.2.19 → 4.0.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/LICENSE +21 -21
- package/README.md +24 -12
- package/files/buildCodeplay/codeplayBeforeBuild-6.1.js +287 -125
- package/files/buildCodeplay/ios-emi-admob-modification.js +25 -28
- package/files/buildCodeplay/manifestModification.js +12 -10
- package/files/buildCodeplay/remove-force-kotlin-disable.js +43 -45
- package/files/buildCodeplay/versions.json +2 -2
- package/files/finalrelease +960 -960
- package/files/iap-install-2.js +145 -145
- package/files/ionic.config.json +6 -6
- package/files/scripts/setup-baseline-profile.js +241 -0
- package/package.json +16 -16
- package/scripts/sync-files.js +105 -86
- package/scripts/uninstall.js +104 -77
- package/files/buildCodeplay/modify-plugin-xml.js +0 -36
package/scripts/sync-files.js
CHANGED
|
@@ -1,86 +1,105 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
|
|
4
|
-
const projectRoot = path.resolve(__dirname, "../../../"); // Your project's root
|
|
5
|
-
const commonBuildPath = path.join(__dirname, "../files"); // Path to common files
|
|
6
|
-
const buildCodeplayPath = path.join(commonBuildPath, "buildCodeplay"); // Correct path
|
|
7
|
-
const packageJsonPath = path.join(projectRoot, "package.json");
|
|
8
|
-
|
|
9
|
-
// Ensure package.json exists
|
|
10
|
-
if (!fs.existsSync(packageJsonPath)) {
|
|
11
|
-
process.stderr.write("❌ package.json not found!\n");
|
|
12
|
-
process.exit(1);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function copyFolderSync(source, destination) {
|
|
16
|
-
try {
|
|
17
|
-
fs.cpSync(source, destination, { recursive: true });
|
|
18
|
-
process.stdout.write(`✅ Copied folder: ${source} -> ${destination}\n`);
|
|
19
|
-
} catch (error) {
|
|
20
|
-
process.stderr.write(`⚠️ Failed to copy folder: ${source} - ${error.message}\n`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Copy all files from `common-build-files/files/` to the project root
|
|
25
|
-
fs.readdirSync(commonBuildPath).forEach(file => {
|
|
26
|
-
const sourcePath = path.join(commonBuildPath, file);
|
|
27
|
-
const destPath = path.join(projectRoot, file);
|
|
28
|
-
|
|
29
|
-
if (fs.statSync(sourcePath).isDirectory()) {
|
|
30
|
-
copyFolderSync(sourcePath, destPath);
|
|
31
|
-
} else {
|
|
32
|
-
try {
|
|
33
|
-
fs.copyFileSync(sourcePath, destPath);
|
|
34
|
-
process.stdout.write(`✅ Copied file: ${file}\n`);
|
|
35
|
-
} catch (error) {
|
|
36
|
-
process.stderr.write(`⚠️ Failed to copy file: ${file} - ${error.message}\n`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// Function to get the latest versioned file from files/buildCodeplay
|
|
42
|
-
function getLatestFile(prefix) {
|
|
43
|
-
if (!fs.existsSync(buildCodeplayPath)) return null; // Ensure directory exists
|
|
44
|
-
|
|
45
|
-
const files = fs.readdirSync(buildCodeplayPath).filter(file => file.startsWith(prefix));
|
|
46
|
-
if (files.length === 0) return null;
|
|
47
|
-
files.sort((a, b) => b.localeCompare(a, undefined, { numeric: true }));
|
|
48
|
-
return files[0];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Detect latest script versions
|
|
52
|
-
const latestSplashScreen = getLatestFile("add-splash-screen-");
|
|
53
|
-
const latestSplashAnimation = getLatestFile("setSplashAnimation-");
|
|
54
|
-
const latestCodeplayBuild = getLatestFile("codeplayBeforeBuild-");
|
|
55
|
-
|
|
56
|
-
const latestPackageIdModification = getLatestFile("packageidBaseModification-");
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
packageJson.scripts["build
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
packageJson.scripts["
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
|
|
4
|
+
const projectRoot = path.resolve(__dirname, "../../../"); // Your project's root
|
|
5
|
+
const commonBuildPath = path.join(__dirname, "../files"); // Path to common files
|
|
6
|
+
const buildCodeplayPath = path.join(commonBuildPath, "buildCodeplay"); // Correct path
|
|
7
|
+
const packageJsonPath = path.join(projectRoot, "package.json");
|
|
8
|
+
|
|
9
|
+
// Ensure package.json exists
|
|
10
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
11
|
+
process.stderr.write("❌ package.json not found!\n");
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function copyFolderSync(source, destination) {
|
|
16
|
+
try {
|
|
17
|
+
fs.cpSync(source, destination, { recursive: true });
|
|
18
|
+
process.stdout.write(`✅ Copied folder: ${source} -> ${destination}\n`);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
process.stderr.write(`⚠️ Failed to copy folder: ${source} - ${error.message}\n`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Copy all files from `common-build-files/files/` to the project root
|
|
25
|
+
fs.readdirSync(commonBuildPath).forEach(file => {
|
|
26
|
+
const sourcePath = path.join(commonBuildPath, file);
|
|
27
|
+
const destPath = path.join(projectRoot, file);
|
|
28
|
+
|
|
29
|
+
if (fs.statSync(sourcePath).isDirectory()) {
|
|
30
|
+
copyFolderSync(sourcePath, destPath);
|
|
31
|
+
} else {
|
|
32
|
+
try {
|
|
33
|
+
fs.copyFileSync(sourcePath, destPath);
|
|
34
|
+
process.stdout.write(`✅ Copied file: ${file}\n`);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
process.stderr.write(`⚠️ Failed to copy file: ${file} - ${error.message}\n`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Function to get the latest versioned file from files/buildCodeplay
|
|
42
|
+
function getLatestFile(prefix) {
|
|
43
|
+
if (!fs.existsSync(buildCodeplayPath)) return null; // Ensure directory exists
|
|
44
|
+
|
|
45
|
+
const files = fs.readdirSync(buildCodeplayPath).filter(file => file.startsWith(prefix));
|
|
46
|
+
if (files.length === 0) return null;
|
|
47
|
+
files.sort((a, b) => b.localeCompare(a, undefined, { numeric: true }));
|
|
48
|
+
return files[0];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Detect latest script versions
|
|
52
|
+
const latestSplashScreen = getLatestFile("add-splash-screen-");
|
|
53
|
+
const latestSplashAnimation = getLatestFile("setSplashAnimation-");
|
|
54
|
+
const latestCodeplayBuild = getLatestFile("codeplayBeforeBuild-");
|
|
55
|
+
|
|
56
|
+
const latestPackageIdModification = getLatestFile("packageidBaseModification-");
|
|
57
|
+
const baselineProfileSetupScript = "node scripts/setup-baseline-profile.js";
|
|
58
|
+
const baselineProfileGenerateScript = "cd android && gradlew.bat :app:generateBaselineProfile --console=plain";
|
|
59
|
+
|
|
60
|
+
function appendIfMissing(base, suffix) {
|
|
61
|
+
if (!suffix) return base;
|
|
62
|
+
if (!base || typeof base !== "string") return suffix;
|
|
63
|
+
if (base.includes(suffix)) return base;
|
|
64
|
+
return `${base} && ${suffix}`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
// Update package.json
|
|
69
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
70
|
+
|
|
71
|
+
// Ensure scripts object exists
|
|
72
|
+
packageJson.scripts = packageJson.scripts || {};
|
|
73
|
+
|
|
74
|
+
// Update or add necessary scripts
|
|
75
|
+
if (latestCodeplayBuild) {
|
|
76
|
+
packageJson.scripts["build"] = `node buildCodeplay/${latestCodeplayBuild} && node buildCodeplay/${latestPackageIdModification} && cross-env NODE_ENV=production vite build --logLevel warn`;
|
|
77
|
+
}
|
|
78
|
+
if (latestSplashScreen && latestSplashAnimation) {
|
|
79
|
+
packageJson.scripts["capacitor:sync:after"] = appendIfMissing(
|
|
80
|
+
`node buildCodeplay/${latestSplashScreen} && node buildCodeplay/${latestSplashAnimation} && node buildCodeplay/manifestModification.js`,
|
|
81
|
+
baselineProfileSetupScript
|
|
82
|
+
);
|
|
83
|
+
//node buildCodeplay/ios-emi-admob-modification.js &&
|
|
84
|
+
} else if (packageJson.scripts["capacitor:sync:after"]) {
|
|
85
|
+
packageJson.scripts["capacitor:sync:after"] = appendIfMissing(
|
|
86
|
+
packageJson.scripts["capacitor:sync:after"],
|
|
87
|
+
baselineProfileSetupScript
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
packageJson.scripts["baseline-profile:setup"] = baselineProfileSetupScript;
|
|
91
|
+
packageJson.scripts["baseline-profile:generate"] = baselineProfileGenerateScript;
|
|
92
|
+
|
|
93
|
+
packageJson.scripts["ionic:build"] = "npm run build";
|
|
94
|
+
packageJson.scripts["ionic:serve"] = "npm run start";
|
|
95
|
+
packageJson.scripts["build:storeid1"] = "vite build --mode storeid1";
|
|
96
|
+
packageJson.scripts["build:storeid2"] = "vite build --mode storeid2";
|
|
97
|
+
packageJson.scripts["build:storeid3"] = "vite build --mode storeid3";
|
|
98
|
+
packageJson.scripts["build:storeid4"] = "vite build --mode storeid4";
|
|
99
|
+
packageJson.scripts["build:storeid5"] = "vite build --mode storeid5";
|
|
100
|
+
//packageJson.scripts["build:storeid6"] = "vite build --mode storeid6";
|
|
101
|
+
packageJson.scripts["build:storeid7"] = "vite build --mode storeid7";
|
|
102
|
+
packageJson.scripts["build:storeid8"] = "vite build --mode storeid8";
|
|
103
|
+
// Save changes
|
|
104
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
|
|
105
|
+
process.stdout.write("✅ package.json updated!\n");
|
package/scripts/uninstall.js
CHANGED
|
@@ -1,77 +1,104 @@
|
|
|
1
|
-
// Define file prefixes to delete
|
|
2
|
-
const filePrefixes = [
|
|
3
|
-
"add-splash-screen",
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
/^
|
|
41
|
-
/^
|
|
42
|
-
/^
|
|
43
|
-
/^
|
|
44
|
-
|
|
45
|
-
/^
|
|
46
|
-
]
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
filesInProject.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
process.
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
process.stdout.write(
|
|
1
|
+
// Define file prefixes to delete
|
|
2
|
+
const filePrefixes = [
|
|
3
|
+
"add-splash-screen",
|
|
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
|
+
process.stdout.write("🚀 Uninstalling: Removing old and copied files...\n");
|
|
19
|
+
|
|
20
|
+
const removeDirectory = (dirPath) => {
|
|
21
|
+
if (fs.existsSync(dirPath)) {
|
|
22
|
+
fs.readdirSync(dirPath).forEach(file => {
|
|
23
|
+
const currentPath = path.join(dirPath, file);
|
|
24
|
+
if (fs.lstatSync(currentPath).isDirectory()) {
|
|
25
|
+
removeDirectory(currentPath);
|
|
26
|
+
} else {
|
|
27
|
+
fs.unlinkSync(currentPath);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
fs.rmdirSync(dirPath);
|
|
31
|
+
process.stdout.write(`🗑️ Removed folder: ${dirPath}\n`);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
removeDirectory(splashXmlPath);
|
|
36
|
+
removeDirectory(path.join(projectRoot, "splashxml")); // Remove old splashxml folder
|
|
37
|
+
|
|
38
|
+
// Step 1: Find all matching files in the project directory
|
|
39
|
+
const filePatternsToRemove = [
|
|
40
|
+
/^add-splash-screen-.*$/,
|
|
41
|
+
/^setSplashAnimation-.*$/,
|
|
42
|
+
/^codeplayBeforeBuild-.*$/,
|
|
43
|
+
/^modify-plugin-xml\.xml$/,
|
|
44
|
+
/^finalrelease.*$/,
|
|
45
|
+
/^iap-install-\d+(\.\d+)?\.js$/,
|
|
46
|
+
/^\.env\.storeid[1-7]$/,
|
|
47
|
+
/^modify-plugin-xml\.js$/
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
const filesInProject = fs.readdirSync(projectRoot);
|
|
51
|
+
|
|
52
|
+
filesInProject.forEach(file => {
|
|
53
|
+
if (filePatternsToRemove.some(pattern => pattern.test(file))) {
|
|
54
|
+
const filePath = path.join(projectRoot, file);
|
|
55
|
+
try {
|
|
56
|
+
fs.unlinkSync(filePath);
|
|
57
|
+
process.stdout.write(`🗑️ Removed file: ${filePath}\n`);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
process.stderr.write(`⚠️ Failed to remove ${filePath}: ${error.message}\n`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Remove files and folders listed in commonBuildPath
|
|
65
|
+
if (fs.existsSync(commonBuildPath)) {
|
|
66
|
+
fs.readdirSync(commonBuildPath).forEach(file => {
|
|
67
|
+
const destPath = path.join(projectRoot, file);
|
|
68
|
+
if (file === "scripts") {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (fs.existsSync(destPath)) {
|
|
72
|
+
try {
|
|
73
|
+
if (fs.lstatSync(destPath).isDirectory()) {
|
|
74
|
+
removeDirectory(destPath);
|
|
75
|
+
} else {
|
|
76
|
+
fs.unlinkSync(destPath);
|
|
77
|
+
process.stdout.write(`🗑️ Removed file: ${destPath}\n`);
|
|
78
|
+
}
|
|
79
|
+
} catch (error) {
|
|
80
|
+
process.stderr.write(`⚠️ Failed to remove ${destPath}: ${error.message}\n`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (fs.existsSync(baselineProfileSetupScript)) {
|
|
87
|
+
try {
|
|
88
|
+
fs.unlinkSync(baselineProfileSetupScript);
|
|
89
|
+
process.stdout.write(`🗑️ Removed file: ${baselineProfileSetupScript}\n`);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
process.stderr.write(`⚠️ Failed to remove ${baselineProfileSetupScript}: ${error.message}\n`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (fs.existsSync(baselineProfileBackup)) {
|
|
96
|
+
try {
|
|
97
|
+
fs.unlinkSync(baselineProfileBackup);
|
|
98
|
+
process.stdout.write(`🗑️ Removed file: ${baselineProfileBackup}\n`);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
process.stderr.write(`⚠️ Failed to remove ${baselineProfileBackup}: ${error.message}\n`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
process.stdout.write("✅ Uninstall cleanup complete!\n");
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
// Path to the plugin.xml file
|
|
5
|
-
const pluginXmlPath = path.join('node_modules', 'emi-indo-cordova-plugin-admob', 'plugin.xml');
|
|
6
|
-
|
|
7
|
-
// Get the store ID from the environment variable
|
|
8
|
-
const storeId = process.env.VITE_STORE_ID || '1';
|
|
9
|
-
|
|
10
|
-
// Determine the framework to use based on storeId
|
|
11
|
-
const framework = storeId === '7'
|
|
12
|
-
? '<framework src="com.google.android.gms:play-services-ads:$PLAY_SERVICES_VERSION" />'
|
|
13
|
-
: '<framework src="com.google.android.gms:play-services-ads-lite:24.6.0" />';
|
|
14
|
-
|
|
15
|
-
// Read and modify the plugin.xml file
|
|
16
|
-
fs.readFile(pluginXmlPath, 'utf8', (err, data) => {
|
|
17
|
-
if (err) {
|
|
18
|
-
console.error('Error reading plugin.xml:', err);
|
|
19
|
-
process.exit(1);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Replace the existing framework line with the selected one
|
|
23
|
-
const modifiedData = data.replace(
|
|
24
|
-
/<framework src="com.google.android.gms:play-services-ads.*" \/>\n/,
|
|
25
|
-
`${framework}\n`
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
// Write the modified content back to plugin.xml
|
|
29
|
-
fs.writeFile(pluginXmlPath, modifiedData, 'utf8', (err) => {
|
|
30
|
-
if (err) {
|
|
31
|
-
console.error('Error writing plugin.xml:', err);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
console.log('plugin.xml updated successfully.');
|
|
35
|
-
});
|
|
36
|
-
});
|