codeplay-common 1.2.4 → 1.2.6
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 +1 -1
- package/README.md +11 -11
- package/files/buildCodeplay/{add-splash-screen-1.0.js → add-splash-screen-1.1.js} +1 -1
- package/files/buildCodeplay/{codeplayBeforeBuild-1.1.js → codeplayBeforeBuild-1.2.js} +187 -124
- package/files/buildCodeplay/modify-plugin-xml.js +36 -36
- package/files/buildCodeplay/setSplashAnimation-1.1.js +167 -167
- package/files/buildCodeplay/splashxml/codeplay_splashScreen.xml +11 -11
- package/files/finalrelease14 +493 -493
- package/files/ionic.config.json +6 -6
- package/package.json +14 -14
- package/scripts/sync-files.js +78 -78
- package/scripts/uninstall.js +76 -76
package/.gitattributes
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
# Auto detect text files and perform LF normalization
|
|
2
|
-
* text=auto
|
|
1
|
+
# Auto detect text files and perform LF normalization
|
|
2
|
+
* text=auto
|
package/LICENSE
CHANGED
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# codeplay-common
|
|
2
|
-
Everything automatted in Capacitor apps, easy to maintain many apps in capacitor. It will reduce your 40% of work, with common file code.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Easy add splashscreen and set animation
|
|
6
|
-
Admob id automatically from capacitor.config.json file
|
|
7
|
-
Make three build file for different store as per our requirement
|
|
8
|
-
Based on store install various IAP plugins
|
|
9
|
-
Make it to ionic project
|
|
10
|
-
|
|
11
|
-
Donate to get full code including many common functions
|
|
1
|
+
# codeplay-common
|
|
2
|
+
Everything automatted in Capacitor apps, easy to maintain many apps in capacitor. It will reduce your 40% of work, with common file code.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
Easy add splashscreen and set animation
|
|
6
|
+
Admob id automatically from capacitor.config.json file
|
|
7
|
+
Make three build file for different store as per our requirement
|
|
8
|
+
Based on store install various IAP plugins
|
|
9
|
+
Make it to ionic project
|
|
10
|
+
|
|
11
|
+
Donate to get full code including many common functions
|
|
12
12
|
https://ko-fi.com/codeplay
|
|
@@ -14,7 +14,7 @@ const destinationSplashIcon = path.join(
|
|
|
14
14
|
"drawable-nodpi",
|
|
15
15
|
"splash_icon.png"
|
|
16
16
|
);
|
|
17
|
-
const sourceSplashXML = path.join(projectFolder, "splashxml", "codeplay_splashScreen.xml");
|
|
17
|
+
const sourceSplashXML = path.join(projectFolder,"buildCodeplay", "splashxml", "codeplay_splashScreen.xml");
|
|
18
18
|
const destinationSplashXML = path.join(
|
|
19
19
|
projectFolder,
|
|
20
20
|
"android",
|
|
@@ -1,124 +1,187 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const plist = require('plist');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
console.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const plist = require('plist');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
//Check codeplay-common latest version installed or not Start
|
|
8
|
+
const { execSync } = require('child_process');
|
|
9
|
+
|
|
10
|
+
function getInstalledVersion(packageName) {
|
|
11
|
+
try {
|
|
12
|
+
const packageJsonPath = path.join(process.cwd(), 'node_modules', packageName, 'package.json');
|
|
13
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
14
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
15
|
+
return packageJson.version;
|
|
16
|
+
}
|
|
17
|
+
} catch (error) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getLatestVersion(packageName) {
|
|
24
|
+
try {
|
|
25
|
+
return execSync(`npm view ${packageName} version`).toString().trim();
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error(`Failed to fetch latest version for ${packageName}`);
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function checkPackageVersion() {
|
|
33
|
+
const packageName = 'codeplay-common';
|
|
34
|
+
const installedVersion = getInstalledVersion(packageName);
|
|
35
|
+
const latestVersion = getLatestVersion(packageName);
|
|
36
|
+
|
|
37
|
+
if (!installedVersion) {
|
|
38
|
+
console.error(`${packageName} is not installed. Please install it using "npm install ${packageName}".`);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (installedVersion !== latestVersion) {
|
|
43
|
+
console.error(`\x1b[31m${packageName} is outdated (installed: ${installedVersion}, latest: ${latestVersion}). Please update it.\x1b[0m\n\x1b[33mUse 'npm uninstall codeplay-common ; npm i codeplay-common'\x1b[0m`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
console.log(`${packageName} is up to date (version ${installedVersion}).`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Run package version check before executing the main script
|
|
51
|
+
try {
|
|
52
|
+
checkPackageVersion();
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error(error.message);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//Check codeplay-common latest version installed or not End
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
69
|
+
const androidPlatformPath = path.join(process.cwd(), 'android');
|
|
70
|
+
const iosPlatformPath = path.join(process.cwd(), 'ios');
|
|
71
|
+
const pluginPath = path.join(process.cwd(), 'node_modules', 'emi-indo-cordova-plugin-admob', 'plugin.xml');
|
|
72
|
+
const infoPlistPath = path.join(process.cwd(), 'ios', 'App', 'App', 'Info.plist');
|
|
73
|
+
const resourcesPath = path.join(process.cwd(), 'resources', 'res');
|
|
74
|
+
const androidResPath = path.join(process.cwd(), 'android', 'app', 'src', 'main', 'res');
|
|
75
|
+
const localNotificationsPluginPath = path.join(process.cwd(), 'node_modules', '@capacitor', 'local-notifications');
|
|
76
|
+
|
|
77
|
+
function fileExists(filePath) {
|
|
78
|
+
return fs.existsSync(filePath);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function copyFolderSync(source, target) {
|
|
82
|
+
if (!fs.existsSync(target)) {
|
|
83
|
+
fs.mkdirSync(target, { recursive: true });
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
fs.readdirSync(source).forEach(file => {
|
|
87
|
+
const sourceFile = path.join(source, file);
|
|
88
|
+
const targetFile = path.join(target, file);
|
|
89
|
+
|
|
90
|
+
if (fs.lstatSync(sourceFile).isDirectory()) {
|
|
91
|
+
copyFolderSync(sourceFile, targetFile);
|
|
92
|
+
} else {
|
|
93
|
+
fs.copyFileSync(sourceFile, targetFile);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function checkAndCopyResources() {
|
|
99
|
+
if (fileExists(resourcesPath)) {
|
|
100
|
+
copyFolderSync(resourcesPath, androidResPath);
|
|
101
|
+
console.log('Successfully copied resources/res to android/app/src/main/res.');
|
|
102
|
+
} else {
|
|
103
|
+
console.log('resources/res folder not found.');
|
|
104
|
+
|
|
105
|
+
if (fileExists(localNotificationsPluginPath)) {
|
|
106
|
+
throw new Error('resources/res is required for @capacitor/local-notifications. Stopping execution.');
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function getAdMobConfig() {
|
|
112
|
+
if (!fileExists(configPath)) {
|
|
113
|
+
throw new Error('capacitor.config.json not found. Ensure this is a Capacitor project.');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
117
|
+
const admobConfig = config.plugins?.AdMob;
|
|
118
|
+
|
|
119
|
+
if (!admobConfig || !admobConfig.APP_ID_ANDROID || !admobConfig.APP_ID_IOS) {
|
|
120
|
+
throw new Error('AdMob configuration is missing in capacitor.config.json. Ensure APP_ID_ANDROID and APP_ID_IOS are defined.');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
APP_ID_ANDROID: admobConfig.APP_ID_ANDROID,
|
|
125
|
+
APP_ID_IOS: admobConfig.APP_ID_IOS,
|
|
126
|
+
USE_LITE_ADS: admobConfig.USE_LITE_ADS === "lite",
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function updatePluginXml(admobConfig) {
|
|
131
|
+
if (!fileExists(pluginPath)) {
|
|
132
|
+
console.error('plugin.xml not found. Ensure the plugin is installed.');
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
let pluginContent = fs.readFileSync(pluginPath, 'utf8');
|
|
137
|
+
|
|
138
|
+
pluginContent = pluginContent
|
|
139
|
+
.replace(/<preference name="APP_ID_ANDROID" default=".*?" \/>/, `<preference name="APP_ID_ANDROID" default="${admobConfig.APP_ID_ANDROID}" />`)
|
|
140
|
+
.replace(/<preference name="APP_ID_IOS" default=".*?" \/>/, `<preference name="APP_ID_IOS" default="${admobConfig.APP_ID_IOS}" />`);
|
|
141
|
+
|
|
142
|
+
fs.writeFileSync(pluginPath, pluginContent, 'utf8');
|
|
143
|
+
console.log('AdMob IDs successfully updated in plugin.xml');
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function updateInfoPlist(admobConfig) {
|
|
147
|
+
if (!fileExists(infoPlistPath)) {
|
|
148
|
+
console.error('Info.plist not found. Ensure you have built the iOS project.');
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const plistContent = fs.readFileSync(infoPlistPath, 'utf8');
|
|
153
|
+
const plistData = plist.parse(plistContent);
|
|
154
|
+
|
|
155
|
+
plistData.GADApplicationIdentifier = admobConfig.APP_ID_IOS;
|
|
156
|
+
plistData.NSUserTrackingUsageDescription = 'This identifier will be used to deliver personalized ads to you.';
|
|
157
|
+
plistData.GADDelayAppMeasurementInit = true;
|
|
158
|
+
|
|
159
|
+
const updatedPlistContent = plist.build(plistData);
|
|
160
|
+
fs.writeFileSync(infoPlistPath, updatedPlistContent, 'utf8');
|
|
161
|
+
console.log('AdMob IDs and additional configurations successfully updated in Info.plist');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
try {
|
|
165
|
+
if (!fileExists(configPath)) {
|
|
166
|
+
throw new Error('capacitor.config.json not found. Skipping setup.');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (!fileExists(androidPlatformPath) && !fileExists(iosPlatformPath)) {
|
|
170
|
+
throw new Error('Neither Android nor iOS platforms are found. Ensure platforms are added to your Capacitor project.');
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
checkAndCopyResources();
|
|
174
|
+
|
|
175
|
+
const admobConfig = getAdMobConfig();
|
|
176
|
+
|
|
177
|
+
if (fileExists(androidPlatformPath)) {
|
|
178
|
+
updatePluginXml(admobConfig);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (fileExists(iosPlatformPath)) {
|
|
182
|
+
updateInfoPlist(admobConfig);
|
|
183
|
+
}
|
|
184
|
+
} catch (error) {
|
|
185
|
+
console.error(error.message);
|
|
186
|
+
process.exit(1); // Stop execution if there's a critical error
|
|
187
|
+
}
|
|
@@ -1,36 +1,36 @@
|
|
|
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:$PLAY_SERVICES_VERSION" />';
|
|
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
|
-
});
|
|
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:$PLAY_SERVICES_VERSION" />';
|
|
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
|
+
});
|