codeplay-common 1.8.7 → 1.8.9
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/files/buildCodeplay/add-splash-screen-1.4.js +187 -188
- package/files/buildCodeplay/codeplayBeforeBuild-4.5.js +979 -890
- package/files/buildCodeplay/ios-emi-admob-modification.js +52 -52
- package/files/buildCodeplay/modify-plugin-xml.js +36 -36
- package/files/buildCodeplay/packageidBaseModification-1.2.js +257 -257
- package/files/buildCodeplay/setSplashAnimation-1.1.js +167 -167
- package/files/{finalrelease21 → finalrelease} +798 -722
- package/package.json +1 -1
- package/scripts/sync-files.js +5 -1
|
@@ -1,188 +1,187 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const { isStringObject } = require("util/types");
|
|
4
|
-
|
|
5
|
-
const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
6
|
-
|
|
7
|
-
// Define file paths
|
|
8
|
-
const projectFolder = path.resolve(".");
|
|
9
|
-
const sourceSplashIcon = path.join(projectFolder, "resources", "splash_icon.png");
|
|
10
|
-
const destinationSplashIcon = path.join(
|
|
11
|
-
projectFolder,
|
|
12
|
-
"android",
|
|
13
|
-
"app",
|
|
14
|
-
"src",
|
|
15
|
-
"main",
|
|
16
|
-
"res",
|
|
17
|
-
"drawable-nodpi",
|
|
18
|
-
"splash_icon.png"
|
|
19
|
-
);
|
|
20
|
-
const sourceSplashXML = path.join(projectFolder,"buildCodeplay", "splashxml", "codeplay_splashScreen.xml");
|
|
21
|
-
const destinationSplashXML = path.join(
|
|
22
|
-
projectFolder,
|
|
23
|
-
"android",
|
|
24
|
-
"app",
|
|
25
|
-
"src",
|
|
26
|
-
"main",
|
|
27
|
-
"res",
|
|
28
|
-
"values",
|
|
29
|
-
"codeplay_splashScreen.xml"
|
|
30
|
-
);
|
|
31
|
-
const androidManifestPath = path.join(
|
|
32
|
-
projectFolder,
|
|
33
|
-
"android",
|
|
34
|
-
"app",
|
|
35
|
-
"src",
|
|
36
|
-
"main",
|
|
37
|
-
"AndroidManifest.xml"
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
// Helper function to copy files
|
|
41
|
-
function copyFile(source, destination) {
|
|
42
|
-
if (!fs.existsSync(source)) {
|
|
43
|
-
throw new Error(`Source file not found: ${source}`);
|
|
44
|
-
}
|
|
45
|
-
fs.mkdirSync(path.dirname(destination), { recursive: true });
|
|
46
|
-
fs.copyFileSync(source, destination);
|
|
47
|
-
console.log(`Copied: ${source} -> ${destination}`);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Helper function to update AndroidManifest.xml
|
|
51
|
-
function updateAndroidManifest() {
|
|
52
|
-
if (!fs.existsSync(androidManifestPath)) {
|
|
53
|
-
throw new Error(`AndroidManifest.xml not found: ${androidManifestPath}`);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
'<activity'
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
'<activity'
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
copyFile(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const { isStringObject } = require("util/types");
|
|
4
|
+
|
|
5
|
+
const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
6
|
+
|
|
7
|
+
// Define file paths
|
|
8
|
+
const projectFolder = path.resolve(".");
|
|
9
|
+
const sourceSplashIcon = path.join(projectFolder, "resources", "splash_icon.png");
|
|
10
|
+
const destinationSplashIcon = path.join(
|
|
11
|
+
projectFolder,
|
|
12
|
+
"android",
|
|
13
|
+
"app",
|
|
14
|
+
"src",
|
|
15
|
+
"main",
|
|
16
|
+
"res",
|
|
17
|
+
"drawable-nodpi",
|
|
18
|
+
"splash_icon.png"
|
|
19
|
+
);
|
|
20
|
+
const sourceSplashXML = path.join(projectFolder,"buildCodeplay", "splashxml", "codeplay_splashScreen.xml");
|
|
21
|
+
const destinationSplashXML = path.join(
|
|
22
|
+
projectFolder,
|
|
23
|
+
"android",
|
|
24
|
+
"app",
|
|
25
|
+
"src",
|
|
26
|
+
"main",
|
|
27
|
+
"res",
|
|
28
|
+
"values",
|
|
29
|
+
"codeplay_splashScreen.xml"
|
|
30
|
+
);
|
|
31
|
+
const androidManifestPath = path.join(
|
|
32
|
+
projectFolder,
|
|
33
|
+
"android",
|
|
34
|
+
"app",
|
|
35
|
+
"src",
|
|
36
|
+
"main",
|
|
37
|
+
"AndroidManifest.xml"
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
// Helper function to copy files
|
|
41
|
+
function copyFile(source, destination) {
|
|
42
|
+
if (!fs.existsSync(source)) {
|
|
43
|
+
throw new Error(`Source file not found: ${source}`);
|
|
44
|
+
}
|
|
45
|
+
fs.mkdirSync(path.dirname(destination), { recursive: true });
|
|
46
|
+
fs.copyFileSync(source, destination);
|
|
47
|
+
console.log(`Copied: ${source} -> ${destination}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Helper function to update AndroidManifest.xml
|
|
51
|
+
function updateAndroidManifest() {
|
|
52
|
+
if (!fs.existsSync(androidManifestPath)) {
|
|
53
|
+
throw new Error(`AndroidManifest.xml not found: ${androidManifestPath}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
let logErrorMessage="";
|
|
61
|
+
|
|
62
|
+
const RESIZEABLE_ACTIVITY = config.android?.RESIZEABLE_ACTIVITY;
|
|
63
|
+
const orientation = config.android?.ORIENTATION;
|
|
64
|
+
|
|
65
|
+
// 1️⃣ Check if it’s missing
|
|
66
|
+
if (RESIZEABLE_ACTIVITY === undefined) {
|
|
67
|
+
logErrorMessage+='❌ Missing android.RESIZEABLE_ACTIVITY option in capacitor.config.json.\n';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 2️⃣ Check if it’s not boolean (true/false only)
|
|
71
|
+
else if (typeof RESIZEABLE_ACTIVITY !== 'boolean') {
|
|
72
|
+
logErrorMessage+='❌ Invalid android.RESIZEABLE_ACTIVITY value. Please use only true or false (without quotes).\n';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
if (!orientation) {
|
|
78
|
+
logErrorMessage+='❌ Missing android.ORIENTATION option in capacitor.config.json.\n';
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
else if(orientation!="portrait" && orientation!="landscape" && orientation!="auto")
|
|
82
|
+
{
|
|
83
|
+
logErrorMessage+='❌ Spelling mistake in android.ORIENTATION option in capacitor.config.json. Please use only ["portrait" "landscape" "auto"]\n';
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if(logErrorMessage!="")
|
|
87
|
+
{
|
|
88
|
+
console.error(logErrorMessage);
|
|
89
|
+
process.exit(1)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
let manifestContent = fs.readFileSync(androidManifestPath, "utf-8");
|
|
94
|
+
|
|
95
|
+
manifestContent = manifestContent.replace(
|
|
96
|
+
/<activity[^>]*?>/,
|
|
97
|
+
(match) => {
|
|
98
|
+
let updated = match;
|
|
99
|
+
|
|
100
|
+
// If android:theme is already present, update it
|
|
101
|
+
if (updated.includes('android:theme=')) {
|
|
102
|
+
updated = updated.replace(
|
|
103
|
+
/android:theme="[^"]*"/,
|
|
104
|
+
'android:theme="@style/Theme.Codeplay.SplashScreen"'
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// If android:resizeableActivity is already present, update it
|
|
109
|
+
if (updated.includes('android:resizeableActivity=')) {
|
|
110
|
+
updated = updated.replace(
|
|
111
|
+
/android:resizeableActivity="[^"]*"/,
|
|
112
|
+
`android:resizeableActivity="${RESIZEABLE_ACTIVITY}"`
|
|
113
|
+
);
|
|
114
|
+
} else {
|
|
115
|
+
// Add resizeableActivity attribute
|
|
116
|
+
updated = updated.replace(`<activity`, `<activity android:resizeableActivity="${RESIZEABLE_ACTIVITY}"`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
//const admobConfig = getAdMobConfig();
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
if(orientation=="portrait"){
|
|
127
|
+
// If android:screenOrientation is already present, update it
|
|
128
|
+
if (updated.includes('android:screenOrientation=')) {
|
|
129
|
+
updated = updated.replace(
|
|
130
|
+
/android:screenOrientation="[^"]*"/,
|
|
131
|
+
'android:screenOrientation="portrait"'
|
|
132
|
+
);
|
|
133
|
+
} else {
|
|
134
|
+
updated = updated.replace(
|
|
135
|
+
'<activity',
|
|
136
|
+
'<activity android:screenOrientation="portrait"'
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
if(orientation=="landscape"){
|
|
144
|
+
// If android:screenOrientation is already present, update it
|
|
145
|
+
if (updated.includes('android:screenOrientation=')) {
|
|
146
|
+
updated = updated.replace(
|
|
147
|
+
/android:screenOrientation="[^"]*"/,
|
|
148
|
+
'android:screenOrientation="landscape"'
|
|
149
|
+
);
|
|
150
|
+
} else {
|
|
151
|
+
updated = updated.replace(
|
|
152
|
+
'<activity',
|
|
153
|
+
'<activity android:screenOrientation="landscape"'
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
if (orientation === "auto") {
|
|
160
|
+
// Remove android:screenOrientation attribute if present
|
|
161
|
+
updated = updated.replace(/\s*android:screenOrientation="[^"]*"/, '');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
return updated;
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
fs.writeFileSync(androidManifestPath, manifestContent, "utf-8");
|
|
171
|
+
console.log(`Updated AndroidManifest.xml: ensured resizeableActivity="false" and updated theme if present.`);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Perform the tasks
|
|
175
|
+
try {
|
|
176
|
+
console.log("Starting splash screen setup...");
|
|
177
|
+
copyFile(sourceSplashIcon, destinationSplashIcon);
|
|
178
|
+
copyFile(sourceSplashXML, destinationSplashXML);
|
|
179
|
+
updateAndroidManifest();
|
|
180
|
+
console.log("Splash screen setup completed.");
|
|
181
|
+
} catch (error) {
|
|
182
|
+
console.error(`Error: ${error.message}`);
|
|
183
|
+
process.exit(1);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|