codeplay-common 4.3.1 → 4.3.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,104 +1,104 @@
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
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
16
-
17
- function copyFolderSync(source, destination) {
18
- try {
19
- fs.cpSync(source, destination, { recursive: true });
20
- process.stdout.write(`✅ Copied folder: ${source} -> ${destination}\n`);
21
- } catch (error) {
22
- process.stderr.write(`⚠️ Failed to copy folder: ${source} - ${error.message}\n`);
23
- }
24
- }
25
-
26
- // Copy all files from `common-build-files/files/` to the project root
27
- fs.readdirSync(commonBuildPath).forEach(file => {
28
- const sourcePath = path.join(commonBuildPath, file);
29
- const destPath = path.join(projectRoot, file);
30
-
31
- if (fs.statSync(sourcePath).isDirectory()) {
32
- copyFolderSync(sourcePath, destPath);
33
- } else {
34
- try {
35
- fs.copyFileSync(sourcePath, destPath);
36
- process.stdout.write(`✅ Copied file: ${file}\n`);
37
- } catch (error) {
38
- process.stderr.write(`⚠️ Failed to copy file: ${file} - ${error.message}\n`);
39
- }
40
- }
41
- });
42
-
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
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
16
+
17
+ function copyFolderSync(source, destination) {
18
+ try {
19
+ fs.cpSync(source, destination, { recursive: true });
20
+ process.stdout.write(`✅ Copied folder: ${source} -> ${destination}\n`);
21
+ } catch (error) {
22
+ process.stderr.write(`⚠️ Failed to copy folder: ${source} - ${error.message}\n`);
23
+ }
24
+ }
25
+
26
+ // Copy all files from `common-build-files/files/` to the project root
27
+ fs.readdirSync(commonBuildPath).forEach(file => {
28
+ const sourcePath = path.join(commonBuildPath, file);
29
+ const destPath = path.join(projectRoot, file);
30
+
31
+ if (fs.statSync(sourcePath).isDirectory()) {
32
+ copyFolderSync(sourcePath, destPath);
33
+ } else {
34
+ try {
35
+ fs.copyFileSync(sourcePath, destPath);
36
+ process.stdout.write(`✅ Copied file: ${file}\n`);
37
+ } catch (error) {
38
+ process.stderr.write(`⚠️ Failed to copy file: ${file} - ${error.message}\n`);
39
+ }
40
+ }
41
+ });
42
+
43
43
  // Function to get the latest versioned file from files/buildCodeplay
44
- function getLatestFile(prefix) {
45
- if (!fs.existsSync(buildCodeplayPath)) return null; // Ensure directory exists
46
-
47
- const files = fs.readdirSync(buildCodeplayPath).filter(file => file.startsWith(prefix));
48
- if (files.length === 0) return null;
49
- files.sort((a, b) => b.localeCompare(a, undefined, { numeric: true }));
50
- return files[0];
51
- }
52
-
53
- // Detect latest script versions
54
- const latestSplashScreen = getLatestFile("add-splash-screen-");
55
- const latestSplashAnimation = getLatestFile("setSplashAnimation-");
56
- const latestCodeplayBuild = getLatestFile("codeplayBeforeBuild-");
57
-
58
- const latestPackageIdModification = getLatestFile("packageidBaseModification-");
59
- const baselineProfileSetupScript = "node scripts/setup-baseline-profile.js";
60
- const baselineProfileGenerateScript = "cd android && gradlew.bat :app:generateBaselineProfile --console=plain";
61
-
62
- function appendIfMissing(base, suffix) {
63
- if (!suffix) return base;
64
- if (!base || typeof base !== "string") return suffix;
65
- if (base.includes(suffix)) return base;
66
- return `${base} && ${suffix}`;
67
- }
68
-
69
-
70
- // Ensure scripts object exists
71
- packageJson.scripts = packageJson.scripts || {};
72
-
73
- // Update or add necessary scripts
74
- if (latestCodeplayBuild) {
75
- packageJson.scripts["build"] = `node buildCodeplay/${latestCodeplayBuild} && node buildCodeplay/${latestPackageIdModification} && cross-env NODE_ENV=production vite build --logLevel warn`;
76
- }
77
- if (latestSplashScreen && latestSplashAnimation) {
78
- packageJson.scripts["capacitor:sync:after"] = appendIfMissing(
79
- `node buildCodeplay/${latestSplashScreen} && node buildCodeplay/${latestSplashAnimation} && node buildCodeplay/manifestModification.js`,
80
- baselineProfileSetupScript
81
- );
82
- //node buildCodeplay/ios-emi-admob-modification.js &&
83
- } else if (packageJson.scripts["capacitor:sync:after"]) {
84
- packageJson.scripts["capacitor:sync:after"] = appendIfMissing(
85
- packageJson.scripts["capacitor:sync:after"],
86
- baselineProfileSetupScript
87
- );
88
- }
89
- packageJson.scripts["baseline-profile:setup"] = baselineProfileSetupScript;
90
- packageJson.scripts["baseline-profile:generate"] = baselineProfileGenerateScript;
91
-
92
- packageJson.scripts["ionic:build"] = "npm run build";
93
- packageJson.scripts["ionic:serve"] = "cross-env NODE_ENV=development vite";
94
- packageJson.scripts["build:storeid1"] = "vite build --mode storeid1";
95
- packageJson.scripts["build:storeid2"] = "vite build --mode storeid2";
96
- packageJson.scripts["build:storeid3"] = "vite build --mode storeid3";
97
- packageJson.scripts["build:storeid4"] = "vite build --mode storeid4";
98
- packageJson.scripts["build:storeid5"] = "vite build --mode storeid5";
99
- //packageJson.scripts["build:storeid6"] = "vite build --mode storeid6";
100
- packageJson.scripts["build:storeid7"] = "vite build --mode storeid7";
101
- packageJson.scripts["build:storeid8"] = "vite build --mode storeid8";
102
- // Save changes
103
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
104
- process.stdout.write("✅ package.json updated!\n");
44
+ function getLatestFile(prefix) {
45
+ if (!fs.existsSync(buildCodeplayPath)) return null; // Ensure directory exists
46
+
47
+ const files = fs.readdirSync(buildCodeplayPath).filter(file => file.startsWith(prefix));
48
+ if (files.length === 0) return null;
49
+ files.sort((a, b) => b.localeCompare(a, undefined, { numeric: true }));
50
+ return files[0];
51
+ }
52
+
53
+ // Detect latest script versions
54
+ const latestSplashScreen = getLatestFile("add-splash-screen-");
55
+ const latestSplashAnimation = getLatestFile("setSplashAnimation-");
56
+ const latestCodeplayBuild = getLatestFile("codeplayBeforeBuild-");
57
+
58
+ const latestPackageIdModification = getLatestFile("packageidBaseModification-");
59
+ const baselineProfileSetupScript = "node scripts/setup-baseline-profile.js";
60
+ const baselineProfileGenerateScript = "cd android && gradlew.bat :app:generateBaselineProfile --console=plain";
61
+
62
+ function appendIfMissing(base, suffix) {
63
+ if (!suffix) return base;
64
+ if (!base || typeof base !== "string") return suffix;
65
+ if (base.includes(suffix)) return base;
66
+ return `${base} && ${suffix}`;
67
+ }
68
+
69
+
70
+ // Ensure scripts object exists
71
+ packageJson.scripts = packageJson.scripts || {};
72
+
73
+ // Update or add necessary scripts
74
+ if (latestCodeplayBuild) {
75
+ packageJson.scripts["build"] = `node buildCodeplay/${latestCodeplayBuild} && node buildCodeplay/${latestPackageIdModification} && cross-env NODE_ENV=production vite build --logLevel warn`;
76
+ }
77
+ if (latestSplashScreen && latestSplashAnimation) {
78
+ packageJson.scripts["capacitor:sync:after"] = appendIfMissing(
79
+ `node buildCodeplay/${latestSplashScreen} && node buildCodeplay/${latestSplashAnimation} && node buildCodeplay/manifestModification.js`,
80
+ baselineProfileSetupScript
81
+ );
82
+ //node buildCodeplay/ios-emi-admob-modification.js &&
83
+ } else if (packageJson.scripts["capacitor:sync:after"]) {
84
+ packageJson.scripts["capacitor:sync:after"] = appendIfMissing(
85
+ packageJson.scripts["capacitor:sync:after"],
86
+ baselineProfileSetupScript
87
+ );
88
+ }
89
+ packageJson.scripts["baseline-profile:setup"] = baselineProfileSetupScript;
90
+ packageJson.scripts["baseline-profile:generate"] = baselineProfileGenerateScript;
91
+
92
+ packageJson.scripts["ionic:build"] = "npm run build";
93
+ packageJson.scripts["ionic:serve"] = "cross-env NODE_ENV=development vite";
94
+ packageJson.scripts["build:storeid1"] = "vite build --mode storeid1";
95
+ packageJson.scripts["build:storeid2"] = "vite build --mode storeid2";
96
+ packageJson.scripts["build:storeid3"] = "vite build --mode storeid3";
97
+ packageJson.scripts["build:storeid4"] = "vite build --mode storeid4";
98
+ packageJson.scripts["build:storeid5"] = "vite build --mode storeid5";
99
+ //packageJson.scripts["build:storeid6"] = "vite build --mode storeid6";
100
+ packageJson.scripts["build:storeid7"] = "vite build --mode storeid7";
101
+ packageJson.scripts["build:storeid8"] = "vite build --mode storeid8";
102
+ // Save changes
103
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
104
+ process.stdout.write("✅ package.json updated!\n");
@@ -1,109 +1,109 @@
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
- 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
- if (file === "scripts" || isAgentInstructionAsset(file)) {
74
- return;
75
- }
76
- if (fs.existsSync(destPath)) {
77
- try {
78
- if (fs.lstatSync(destPath).isDirectory()) {
79
- removeDirectory(destPath);
80
- } else {
81
- fs.unlinkSync(destPath);
82
- process.stdout.write(`🗑️ Removed file: ${destPath}\n`);
83
- }
84
- } catch (error) {
85
- process.stderr.write(`⚠️ Failed to remove ${destPath}: ${error.message}\n`);
86
- }
87
- }
88
- });
89
- }
90
-
91
- if (fs.existsSync(baselineProfileSetupScript)) {
92
- try {
93
- fs.unlinkSync(baselineProfileSetupScript);
94
- process.stdout.write(`🗑️ Removed file: ${baselineProfileSetupScript}\n`);
95
- } catch (error) {
96
- process.stderr.write(`⚠️ Failed to remove ${baselineProfileSetupScript}: ${error.message}\n`);
97
- }
98
- }
99
-
100
- if (fs.existsSync(baselineProfileBackup)) {
101
- try {
102
- fs.unlinkSync(baselineProfileBackup);
103
- process.stdout.write(`🗑️ Removed file: ${baselineProfileBackup}\n`);
104
- } catch (error) {
105
- process.stderr.write(`⚠️ Failed to remove ${baselineProfileBackup}: ${error.message}\n`);
106
- }
107
- }
108
-
109
- 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
+ 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
+ if (file === "scripts" || isAgentInstructionAsset(file)) {
74
+ return;
75
+ }
76
+ if (fs.existsSync(destPath)) {
77
+ try {
78
+ if (fs.lstatSync(destPath).isDirectory()) {
79
+ removeDirectory(destPath);
80
+ } else {
81
+ fs.unlinkSync(destPath);
82
+ process.stdout.write(`🗑️ Removed file: ${destPath}\n`);
83
+ }
84
+ } catch (error) {
85
+ process.stderr.write(`⚠️ Failed to remove ${destPath}: ${error.message}\n`);
86
+ }
87
+ }
88
+ });
89
+ }
90
+
91
+ if (fs.existsSync(baselineProfileSetupScript)) {
92
+ try {
93
+ fs.unlinkSync(baselineProfileSetupScript);
94
+ process.stdout.write(`🗑️ Removed file: ${baselineProfileSetupScript}\n`);
95
+ } catch (error) {
96
+ process.stderr.write(`⚠️ Failed to remove ${baselineProfileSetupScript}: ${error.message}\n`);
97
+ }
98
+ }
99
+
100
+ if (fs.existsSync(baselineProfileBackup)) {
101
+ try {
102
+ fs.unlinkSync(baselineProfileBackup);
103
+ process.stdout.write(`🗑️ Removed file: ${baselineProfileBackup}\n`);
104
+ } catch (error) {
105
+ process.stderr.write(`⚠️ Failed to remove ${baselineProfileBackup}: ${error.message}\n`);
106
+ }
107
+ }
108
+
109
+ process.stdout.write("✅ Uninstall cleanup complete!\n");