codeplay-common 4.2.0 → 4.2.2

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.
@@ -1,105 +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
- 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"] = "cross-env NODE_ENV=development vite";
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");
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"] = "cross-env NODE_ENV=development vite";
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");
@@ -1,104 +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
- 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
+ // 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");