codeplay-common 2.0.3 → 2.0.5
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/.gitattributes +2 -2
- package/LICENSE +21 -21
- package/README.md +11 -11
- package/files/buildCodeplay/add-splash-screen-1.6.js +248 -248
- package/files/buildCodeplay/{codeplayBeforeBuild-4.7.js → codeplayBeforeBuild-4.8.js} +100 -2
- package/files/buildCodeplay/modify-plugin-xml.js +36 -36
- package/files/buildCodeplay/splashxml/codeplay_splashScreen.xml +11 -11
- package/files/iap-install-2.js +145 -145
- package/files/ionic.config.json +6 -6
- package/package.json +16 -16
- package/scripts/sync-files.js +86 -86
- package/scripts/uninstall.js +77 -77
package/scripts/sync-files.js
CHANGED
|
@@ -1,86 +1,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
|
-
|
|
58
|
-
|
|
59
|
-
// Update package.json
|
|
60
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
61
|
-
|
|
62
|
-
// Ensure scripts object exists
|
|
63
|
-
packageJson.scripts = packageJson.scripts || {};
|
|
64
|
-
|
|
65
|
-
// Update or add necessary scripts
|
|
66
|
-
if (latestCodeplayBuild) {
|
|
67
|
-
packageJson.scripts["build"] = `node buildCodeplay/${latestCodeplayBuild} && node buildCodeplay/${latestPackageIdModification} && cross-env NODE_ENV=production vite build --logLevel warn`;
|
|
68
|
-
}
|
|
69
|
-
if (latestSplashScreen && latestSplashAnimation) {
|
|
70
|
-
packageJson.scripts["capacitor:sync:after"] = ` node buildCodeplay/${latestSplashScreen} && node buildCodeplay/${latestSplashAnimation}`;
|
|
71
|
-
//node buildCodeplay/ios-emi-admob-modification.js &&
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
packageJson.scripts["ionic:build"] = "npm run build";
|
|
75
|
-
packageJson.scripts["ionic:serve"] = "npm run start";
|
|
76
|
-
packageJson.scripts["build:storeid1"] = "vite build --mode storeid1";
|
|
77
|
-
packageJson.scripts["build:storeid2"] = "vite build --mode storeid2";
|
|
78
|
-
packageJson.scripts["build:storeid3"] = "vite build --mode storeid3";
|
|
79
|
-
packageJson.scripts["build:storeid4"] = "vite build --mode storeid4";
|
|
80
|
-
packageJson.scripts["build:storeid5"] = "vite build --mode storeid5";
|
|
81
|
-
//packageJson.scripts["build:storeid6"] = "vite build --mode storeid6";
|
|
82
|
-
packageJson.scripts["build:storeid7"] = "vite build --mode storeid7";
|
|
83
|
-
packageJson.scripts["build:storeid8"] = "vite build --mode storeid8";
|
|
84
|
-
// Save changes
|
|
85
|
-
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
|
|
86
|
-
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
|
+
|
|
58
|
+
|
|
59
|
+
// Update package.json
|
|
60
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
61
|
+
|
|
62
|
+
// Ensure scripts object exists
|
|
63
|
+
packageJson.scripts = packageJson.scripts || {};
|
|
64
|
+
|
|
65
|
+
// Update or add necessary scripts
|
|
66
|
+
if (latestCodeplayBuild) {
|
|
67
|
+
packageJson.scripts["build"] = `node buildCodeplay/${latestCodeplayBuild} && node buildCodeplay/${latestPackageIdModification} && cross-env NODE_ENV=production vite build --logLevel warn`;
|
|
68
|
+
}
|
|
69
|
+
if (latestSplashScreen && latestSplashAnimation) {
|
|
70
|
+
packageJson.scripts["capacitor:sync:after"] = ` node buildCodeplay/${latestSplashScreen} && node buildCodeplay/${latestSplashAnimation}`;
|
|
71
|
+
//node buildCodeplay/ios-emi-admob-modification.js &&
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
packageJson.scripts["ionic:build"] = "npm run build";
|
|
75
|
+
packageJson.scripts["ionic:serve"] = "npm run start";
|
|
76
|
+
packageJson.scripts["build:storeid1"] = "vite build --mode storeid1";
|
|
77
|
+
packageJson.scripts["build:storeid2"] = "vite build --mode storeid2";
|
|
78
|
+
packageJson.scripts["build:storeid3"] = "vite build --mode storeid3";
|
|
79
|
+
packageJson.scripts["build:storeid4"] = "vite build --mode storeid4";
|
|
80
|
+
packageJson.scripts["build:storeid5"] = "vite build --mode storeid5";
|
|
81
|
+
//packageJson.scripts["build:storeid6"] = "vite build --mode storeid6";
|
|
82
|
+
packageJson.scripts["build:storeid7"] = "vite build --mode storeid7";
|
|
83
|
+
packageJson.scripts["build:storeid8"] = "vite build --mode storeid8";
|
|
84
|
+
// Save changes
|
|
85
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
|
|
86
|
+
process.stdout.write("✅ package.json updated!\n");
|
package/scripts/uninstall.js
CHANGED
|
@@ -1,77 +1,77 @@
|
|
|
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
|
-
process.stdout.write("🚀 Uninstalling: Removing old and copied files...\n");
|
|
17
|
-
|
|
18
|
-
const removeDirectory = (dirPath) => {
|
|
19
|
-
if (fs.existsSync(dirPath)) {
|
|
20
|
-
fs.readdirSync(dirPath).forEach(file => {
|
|
21
|
-
const currentPath = path.join(dirPath, file);
|
|
22
|
-
if (fs.lstatSync(currentPath).isDirectory()) {
|
|
23
|
-
removeDirectory(currentPath);
|
|
24
|
-
} else {
|
|
25
|
-
fs.unlinkSync(currentPath);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
fs.rmdirSync(dirPath);
|
|
29
|
-
process.stdout.write(`🗑️ Removed folder: ${dirPath}\n`);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
removeDirectory(splashXmlPath);
|
|
34
|
-
removeDirectory(path.join(projectRoot, "splashxml")); // Remove old splashxml folder
|
|
35
|
-
|
|
36
|
-
// Step 1: Find all matching files in the project directory
|
|
37
|
-
const filePatternsToRemove = [
|
|
38
|
-
/^add-splash-screen-.*$/,
|
|
39
|
-
/^setSplashAnimation-.*$/,
|
|
40
|
-
/^codeplayBeforeBuild-.*$/,
|
|
41
|
-
/^modify-plugin-xml\.xml$/,
|
|
42
|
-
/^finalrelease.*$/,
|
|
43
|
-
/^iap-install-\d+(\.\d+)?\.js$/,
|
|
44
|
-
/^\.env\.storeid[1-7]$/,
|
|
45
|
-
/^modify-plugin-xml\.js$/
|
|
46
|
-
];
|
|
47
|
-
|
|
48
|
-
const filesInProject = fs.readdirSync(projectRoot);
|
|
49
|
-
|
|
50
|
-
filesInProject.forEach(file => {
|
|
51
|
-
if (filePatternsToRemove.some(pattern => pattern.test(file))) {
|
|
52
|
-
const filePath = path.join(projectRoot, file);
|
|
53
|
-
try {
|
|
54
|
-
fs.unlinkSync(filePath);
|
|
55
|
-
process.stdout.write(`🗑️ Removed file: ${filePath}\n`);
|
|
56
|
-
} catch (error) {
|
|
57
|
-
process.stderr.write(`⚠️ Failed to remove ${filePath}: ${error.message}\n`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// Remove files listed in commonBuildPath
|
|
63
|
-
if (fs.existsSync(commonBuildPath)) {
|
|
64
|
-
fs.readdirSync(commonBuildPath).forEach(file => {
|
|
65
|
-
const destPath = path.join(projectRoot, file);
|
|
66
|
-
if (fs.existsSync(destPath)) {
|
|
67
|
-
try {
|
|
68
|
-
fs.unlinkSync(destPath);
|
|
69
|
-
process.stdout.write(`🗑️ Removed file: ${destPath}\n`);
|
|
70
|
-
} catch (error) {
|
|
71
|
-
process.stderr.write(`⚠️ Failed to remove ${destPath}: ${error.message}\n`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
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
|
+
|
|
16
|
+
process.stdout.write("🚀 Uninstalling: Removing old and copied files...\n");
|
|
17
|
+
|
|
18
|
+
const removeDirectory = (dirPath) => {
|
|
19
|
+
if (fs.existsSync(dirPath)) {
|
|
20
|
+
fs.readdirSync(dirPath).forEach(file => {
|
|
21
|
+
const currentPath = path.join(dirPath, file);
|
|
22
|
+
if (fs.lstatSync(currentPath).isDirectory()) {
|
|
23
|
+
removeDirectory(currentPath);
|
|
24
|
+
} else {
|
|
25
|
+
fs.unlinkSync(currentPath);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
fs.rmdirSync(dirPath);
|
|
29
|
+
process.stdout.write(`🗑️ Removed folder: ${dirPath}\n`);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
removeDirectory(splashXmlPath);
|
|
34
|
+
removeDirectory(path.join(projectRoot, "splashxml")); // Remove old splashxml folder
|
|
35
|
+
|
|
36
|
+
// Step 1: Find all matching files in the project directory
|
|
37
|
+
const filePatternsToRemove = [
|
|
38
|
+
/^add-splash-screen-.*$/,
|
|
39
|
+
/^setSplashAnimation-.*$/,
|
|
40
|
+
/^codeplayBeforeBuild-.*$/,
|
|
41
|
+
/^modify-plugin-xml\.xml$/,
|
|
42
|
+
/^finalrelease.*$/,
|
|
43
|
+
/^iap-install-\d+(\.\d+)?\.js$/,
|
|
44
|
+
/^\.env\.storeid[1-7]$/,
|
|
45
|
+
/^modify-plugin-xml\.js$/
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
const filesInProject = fs.readdirSync(projectRoot);
|
|
49
|
+
|
|
50
|
+
filesInProject.forEach(file => {
|
|
51
|
+
if (filePatternsToRemove.some(pattern => pattern.test(file))) {
|
|
52
|
+
const filePath = path.join(projectRoot, file);
|
|
53
|
+
try {
|
|
54
|
+
fs.unlinkSync(filePath);
|
|
55
|
+
process.stdout.write(`🗑️ Removed file: ${filePath}\n`);
|
|
56
|
+
} catch (error) {
|
|
57
|
+
process.stderr.write(`⚠️ Failed to remove ${filePath}: ${error.message}\n`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Remove files listed in commonBuildPath
|
|
63
|
+
if (fs.existsSync(commonBuildPath)) {
|
|
64
|
+
fs.readdirSync(commonBuildPath).forEach(file => {
|
|
65
|
+
const destPath = path.join(projectRoot, file);
|
|
66
|
+
if (fs.existsSync(destPath)) {
|
|
67
|
+
try {
|
|
68
|
+
fs.unlinkSync(destPath);
|
|
69
|
+
process.stdout.write(`🗑️ Removed file: ${destPath}\n`);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
process.stderr.write(`⚠️ Failed to remove ${destPath}: ${error.message}\n`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
process.stdout.write("✅ Uninstall cleanup complete!\n");
|