codeplay-common 1.0.57 → 1.1.60
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/codeplayBeforeBuild-1.0.js +138 -138
- package/files/{setSplashAnimation-1.0.js → setSplashAnimation-1.1.js} +1 -1
- package/package.json +2 -3
- package/scripts/sync-files.js +62 -38
- package/scripts/uninstall.js +9 -1
- /package/files/{add-splash-screen-1.1.js → add-splash-screen-1.0.js} +0 -0
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const plist = require('plist');
|
|
4
|
-
|
|
5
|
-
const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
6
|
-
const androidPlatformPath = path.join(process.cwd(), 'android');
|
|
7
|
-
const iosPlatformPath = path.join(process.cwd(), 'ios');
|
|
8
|
-
const pluginPath = path.join(process.cwd(), 'node_modules', 'emi-indo-cordova-plugin-admob', 'plugin.xml');
|
|
9
|
-
const infoPlistPath = path.join(process.cwd(), 'ios', 'App', 'App', 'Info.plist');
|
|
10
|
-
|
|
11
|
-
function fileExists(filePath) {
|
|
12
|
-
return fs.existsSync(filePath);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function getAdMobConfig() {
|
|
16
|
-
if (!fileExists(configPath)) {
|
|
17
|
-
throw new Error('capacitor.config.json not found. Ensure this is a Capacitor project.');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
21
|
-
const admobConfig = config.plugins?.AdMob;
|
|
22
|
-
|
|
23
|
-
if (!admobConfig || !admobConfig.APP_ID_ANDROID || !admobConfig.APP_ID_IOS) {
|
|
24
|
-
throw new Error('AdMob configuration is missing in capacitor.config.json. Ensure APP_ID_ANDROID and APP_ID_IOS are defined.');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
APP_ID_ANDROID: admobConfig.APP_ID_ANDROID,
|
|
29
|
-
APP_ID_IOS: admobConfig.APP_ID_IOS,
|
|
30
|
-
USE_LITE_ADS: admobConfig.USE_LITE_ADS === "lite",
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function updatePluginXml(admobConfig) {
|
|
35
|
-
if (!fileExists(pluginPath)) {
|
|
36
|
-
console.error('plugin.xml not found. Ensure the plugin is installed.');
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
let pluginContent = fs.readFileSync(pluginPath, 'utf8');
|
|
41
|
-
|
|
42
|
-
pluginContent = pluginContent
|
|
43
|
-
.replace(/<preference name="APP_ID_ANDROID" default=".*?" \/>/, `<preference name="APP_ID_ANDROID" default="${admobConfig.APP_ID_ANDROID}" />`)
|
|
44
|
-
.replace(/<preference name="APP_ID_IOS" default=".*?" \/>/, `<preference name="APP_ID_IOS" default="${admobConfig.APP_ID_IOS}" />`);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
fs.writeFileSync(pluginPath, pluginContent, 'utf8');
|
|
48
|
-
console.log('AdMob IDs successfully updated in plugin.xml');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function updateInfoPlist(admobConfig) {
|
|
52
|
-
if (!fileExists(infoPlistPath)) {
|
|
53
|
-
console.error('Info.plist not found. Ensure you have built the iOS project.');
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const plistContent = fs.readFileSync(infoPlistPath, 'utf8');
|
|
58
|
-
const plistData = plist.parse(plistContent);
|
|
59
|
-
|
|
60
|
-
plistData.GADApplicationIdentifier = admobConfig.APP_ID_IOS;
|
|
61
|
-
plistData.NSUserTrackingUsageDescription = 'This identifier will be used to deliver personalized ads to you.';
|
|
62
|
-
plistData.GADDelayAppMeasurementInit = true;
|
|
63
|
-
|
|
64
|
-
// https://developers.google.com/admob/ios/quick-start
|
|
65
|
-
plistData.SKAdNetworkItems = [
|
|
66
|
-
{ SKAdNetworkIdentifier: 'cstr6suwn9.skadnetwork' }, // Google
|
|
67
|
-
{ SKAdNetworkIdentifier: '4fzdc2evr5.skadnetwork' }, // Aarki
|
|
68
|
-
{ SKAdNetworkIdentifier: '2fnua5tdw4.skadnetwork' }, // Adform
|
|
69
|
-
{ SKAdNetworkIdentifier: 'ydx93a7ass.skadnetwork' }, // Adikteev
|
|
70
|
-
{ SKAdNetworkIdentifier: 'p78axxw29g.skadnetwork' }, // Amazon
|
|
71
|
-
{ SKAdNetworkIdentifier: 'v72qych5uu.skadnetwork' }, // Appier
|
|
72
|
-
{ SKAdNetworkIdentifier: 'ludvb6z3bs.skadnetwork' }, // Applovin
|
|
73
|
-
{ SKAdNetworkIdentifier: 'cp8zw746q7.skadnetwork' }, // Arpeely
|
|
74
|
-
{ SKAdNetworkIdentifier: '3sh42y64q3.skadnetwork' }, // Basis
|
|
75
|
-
{ SKAdNetworkIdentifier: 'c6k4g5qg8m.skadnetwork' }, // Beeswax.io
|
|
76
|
-
{ SKAdNetworkIdentifier: 's39g8k73mm.skadnetwork' }, // Bidease
|
|
77
|
-
{ SKAdNetworkIdentifier: '3qy4746246.skadnetwork' }, // Bigabid
|
|
78
|
-
{ SKAdNetworkIdentifier: 'hs6bdukanm.skadnetwork' }, // Criteo
|
|
79
|
-
{ SKAdNetworkIdentifier: 'mlmmfzh3r3.skadnetwork' }, // Digital Turbine DSP
|
|
80
|
-
{ SKAdNetworkIdentifier: 'v4nxqhlyqp.skadnetwork' }, // i-mobile
|
|
81
|
-
{ SKAdNetworkIdentifier: 'wzmmz9fp6w.skadnetwork' }, // InMobi
|
|
82
|
-
{ SKAdNetworkIdentifier: 'su67r6k2v3.skadnetwork' }, // ironSource Ads
|
|
83
|
-
{ SKAdNetworkIdentifier: 'yclnxrl5pm.skadnetwork' }, // Jampp
|
|
84
|
-
{ SKAdNetworkIdentifier: '7ug5zh24hu.skadnetwork' }, // Liftoff
|
|
85
|
-
{ SKAdNetworkIdentifier: 'gta9lk7p23.skadnetwork' }, // Liftoff Monetize
|
|
86
|
-
{ SKAdNetworkIdentifier: 'vutu7akeur.skadnetwork' }, // LINE
|
|
87
|
-
{ SKAdNetworkIdentifier: 'y5ghdn5j9k.skadnetwork' }, // Mediaforce
|
|
88
|
-
{ SKAdNetworkIdentifier: 'v9wttpbfk9.skadnetwork' }, // Meta (1 of 2)
|
|
89
|
-
{ SKAdNetworkIdentifier: 'n38lu8286q.skadnetwork' }, // Meta (2 of 2)
|
|
90
|
-
{ SKAdNetworkIdentifier: '47vhws6wlr.skadnetwork' }, // MicroAd
|
|
91
|
-
{ SKAdNetworkIdentifier: 'kbd757ywx3.skadnetwork' }, // Mintegral / Mobvista
|
|
92
|
-
{ SKAdNetworkIdentifier: '9t245vhmpl.skadnetwork' }, // Moloco
|
|
93
|
-
{ SKAdNetworkIdentifier: 'a2p9lx4jpn.skadnetwork' }, // Opera
|
|
94
|
-
{ SKAdNetworkIdentifier: '22mmun2rn5.skadnetwork' }, // Pangle
|
|
95
|
-
{ SKAdNetworkIdentifier: '4468km3ulz.skadnetwork' }, // Realtime Technologies GmbH
|
|
96
|
-
{ SKAdNetworkIdentifier: '2u9pt9hc89.skadnetwork' }, // Remerge
|
|
97
|
-
{ SKAdNetworkIdentifier: '8s468mfl3y.skadnetwork' }, // RTB House
|
|
98
|
-
{ SKAdNetworkIdentifier: 'ppxm28t8ap.skadnetwork' }, // Smadex
|
|
99
|
-
{ SKAdNetworkIdentifier: 'uw77j35x4d.skadnetwork' }, // The Trade Desk
|
|
100
|
-
{ SKAdNetworkIdentifier: 'pwa73g5rt2.skadnetwork' }, // Tremor
|
|
101
|
-
{ SKAdNetworkIdentifier: '578prtvx9j.skadnetwork' }, // Unicorn
|
|
102
|
-
{ SKAdNetworkIdentifier: '4dzt52r2t5.skadnetwork' }, // Unity Ads
|
|
103
|
-
{ SKAdNetworkIdentifier: 'tl55sbb4fm.skadnetwork' }, // Verve
|
|
104
|
-
{ SKAdNetworkIdentifier: 'e5fvkxwrpn.skadnetwork' }, // Yahoo!
|
|
105
|
-
{ SKAdNetworkIdentifier: '8c4e2ghe7u.skadnetwork' }, // Yahoo! Japan Ads
|
|
106
|
-
{ SKAdNetworkIdentifier: '3rd42ekr43.skadnetwork' }, // YouAppi
|
|
107
|
-
{ SKAdNetworkIdentifier: '3qcr597p9d.skadnetwork' }, // Zucks
|
|
108
|
-
];
|
|
109
|
-
|
|
110
|
-
const updatedPlistContent = plist.build(plistData);
|
|
111
|
-
fs.writeFileSync(infoPlistPath, updatedPlistContent, 'utf8');
|
|
112
|
-
console.log('AdMob IDs and additional configurations successfully updated in Info.plist');
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
if (!fileExists(configPath)) {
|
|
117
|
-
throw new Error('capacitor.config.json not found. Skipping setup.');
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (!fileExists(androidPlatformPath) && !fileExists(iosPlatformPath)) {
|
|
121
|
-
throw new Error('Neither Android nor iOS platforms are found. Ensure platforms are added to your Capacitor project.');
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const admobConfig = getAdMobConfig();
|
|
125
|
-
|
|
126
|
-
if (fileExists(androidPlatformPath)) {
|
|
127
|
-
updatePluginXml(admobConfig);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (fileExists(iosPlatformPath)) {
|
|
131
|
-
updateInfoPlist(admobConfig);
|
|
132
|
-
}
|
|
133
|
-
} catch (error) {
|
|
134
|
-
console.error(error.message);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const plist = require('plist');
|
|
4
|
+
|
|
5
|
+
const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
6
|
+
const androidPlatformPath = path.join(process.cwd(), 'android');
|
|
7
|
+
const iosPlatformPath = path.join(process.cwd(), 'ios');
|
|
8
|
+
const pluginPath = path.join(process.cwd(), 'node_modules', 'emi-indo-cordova-plugin-admob', 'plugin.xml');
|
|
9
|
+
const infoPlistPath = path.join(process.cwd(), 'ios', 'App', 'App', 'Info.plist');
|
|
10
|
+
|
|
11
|
+
function fileExists(filePath) {
|
|
12
|
+
return fs.existsSync(filePath);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function getAdMobConfig() {
|
|
16
|
+
if (!fileExists(configPath)) {
|
|
17
|
+
throw new Error('capacitor.config.json not found. Ensure this is a Capacitor project.');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
21
|
+
const admobConfig = config.plugins?.AdMob;
|
|
22
|
+
|
|
23
|
+
if (!admobConfig || !admobConfig.APP_ID_ANDROID || !admobConfig.APP_ID_IOS) {
|
|
24
|
+
throw new Error('AdMob configuration is missing in capacitor.config.json. Ensure APP_ID_ANDROID and APP_ID_IOS are defined.');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
APP_ID_ANDROID: admobConfig.APP_ID_ANDROID,
|
|
29
|
+
APP_ID_IOS: admobConfig.APP_ID_IOS,
|
|
30
|
+
USE_LITE_ADS: admobConfig.USE_LITE_ADS === "lite",
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function updatePluginXml(admobConfig) {
|
|
35
|
+
if (!fileExists(pluginPath)) {
|
|
36
|
+
console.error('plugin.xml not found. Ensure the plugin is installed.');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let pluginContent = fs.readFileSync(pluginPath, 'utf8');
|
|
41
|
+
|
|
42
|
+
pluginContent = pluginContent
|
|
43
|
+
.replace(/<preference name="APP_ID_ANDROID" default=".*?" \/>/, `<preference name="APP_ID_ANDROID" default="${admobConfig.APP_ID_ANDROID}" />`)
|
|
44
|
+
.replace(/<preference name="APP_ID_IOS" default=".*?" \/>/, `<preference name="APP_ID_IOS" default="${admobConfig.APP_ID_IOS}" />`);
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
fs.writeFileSync(pluginPath, pluginContent, 'utf8');
|
|
48
|
+
console.log('AdMob IDs successfully updated in plugin.xml');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function updateInfoPlist(admobConfig) {
|
|
52
|
+
if (!fileExists(infoPlistPath)) {
|
|
53
|
+
console.error('Info.plist not found. Ensure you have built the iOS project.');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const plistContent = fs.readFileSync(infoPlistPath, 'utf8');
|
|
58
|
+
const plistData = plist.parse(plistContent);
|
|
59
|
+
|
|
60
|
+
plistData.GADApplicationIdentifier = admobConfig.APP_ID_IOS;
|
|
61
|
+
plistData.NSUserTrackingUsageDescription = 'This identifier will be used to deliver personalized ads to you.';
|
|
62
|
+
plistData.GADDelayAppMeasurementInit = true;
|
|
63
|
+
|
|
64
|
+
// https://developers.google.com/admob/ios/quick-start
|
|
65
|
+
plistData.SKAdNetworkItems = [
|
|
66
|
+
{ SKAdNetworkIdentifier: 'cstr6suwn9.skadnetwork' }, // Google
|
|
67
|
+
{ SKAdNetworkIdentifier: '4fzdc2evr5.skadnetwork' }, // Aarki
|
|
68
|
+
{ SKAdNetworkIdentifier: '2fnua5tdw4.skadnetwork' }, // Adform
|
|
69
|
+
{ SKAdNetworkIdentifier: 'ydx93a7ass.skadnetwork' }, // Adikteev
|
|
70
|
+
{ SKAdNetworkIdentifier: 'p78axxw29g.skadnetwork' }, // Amazon
|
|
71
|
+
{ SKAdNetworkIdentifier: 'v72qych5uu.skadnetwork' }, // Appier
|
|
72
|
+
{ SKAdNetworkIdentifier: 'ludvb6z3bs.skadnetwork' }, // Applovin
|
|
73
|
+
{ SKAdNetworkIdentifier: 'cp8zw746q7.skadnetwork' }, // Arpeely
|
|
74
|
+
{ SKAdNetworkIdentifier: '3sh42y64q3.skadnetwork' }, // Basis
|
|
75
|
+
{ SKAdNetworkIdentifier: 'c6k4g5qg8m.skadnetwork' }, // Beeswax.io
|
|
76
|
+
{ SKAdNetworkIdentifier: 's39g8k73mm.skadnetwork' }, // Bidease
|
|
77
|
+
{ SKAdNetworkIdentifier: '3qy4746246.skadnetwork' }, // Bigabid
|
|
78
|
+
{ SKAdNetworkIdentifier: 'hs6bdukanm.skadnetwork' }, // Criteo
|
|
79
|
+
{ SKAdNetworkIdentifier: 'mlmmfzh3r3.skadnetwork' }, // Digital Turbine DSP
|
|
80
|
+
{ SKAdNetworkIdentifier: 'v4nxqhlyqp.skadnetwork' }, // i-mobile
|
|
81
|
+
{ SKAdNetworkIdentifier: 'wzmmz9fp6w.skadnetwork' }, // InMobi
|
|
82
|
+
{ SKAdNetworkIdentifier: 'su67r6k2v3.skadnetwork' }, // ironSource Ads
|
|
83
|
+
{ SKAdNetworkIdentifier: 'yclnxrl5pm.skadnetwork' }, // Jampp
|
|
84
|
+
{ SKAdNetworkIdentifier: '7ug5zh24hu.skadnetwork' }, // Liftoff
|
|
85
|
+
{ SKAdNetworkIdentifier: 'gta9lk7p23.skadnetwork' }, // Liftoff Monetize
|
|
86
|
+
{ SKAdNetworkIdentifier: 'vutu7akeur.skadnetwork' }, // LINE
|
|
87
|
+
{ SKAdNetworkIdentifier: 'y5ghdn5j9k.skadnetwork' }, // Mediaforce
|
|
88
|
+
{ SKAdNetworkIdentifier: 'v9wttpbfk9.skadnetwork' }, // Meta (1 of 2)
|
|
89
|
+
{ SKAdNetworkIdentifier: 'n38lu8286q.skadnetwork' }, // Meta (2 of 2)
|
|
90
|
+
{ SKAdNetworkIdentifier: '47vhws6wlr.skadnetwork' }, // MicroAd
|
|
91
|
+
{ SKAdNetworkIdentifier: 'kbd757ywx3.skadnetwork' }, // Mintegral / Mobvista
|
|
92
|
+
{ SKAdNetworkIdentifier: '9t245vhmpl.skadnetwork' }, // Moloco
|
|
93
|
+
{ SKAdNetworkIdentifier: 'a2p9lx4jpn.skadnetwork' }, // Opera
|
|
94
|
+
{ SKAdNetworkIdentifier: '22mmun2rn5.skadnetwork' }, // Pangle
|
|
95
|
+
{ SKAdNetworkIdentifier: '4468km3ulz.skadnetwork' }, // Realtime Technologies GmbH
|
|
96
|
+
{ SKAdNetworkIdentifier: '2u9pt9hc89.skadnetwork' }, // Remerge
|
|
97
|
+
{ SKAdNetworkIdentifier: '8s468mfl3y.skadnetwork' }, // RTB House
|
|
98
|
+
{ SKAdNetworkIdentifier: 'ppxm28t8ap.skadnetwork' }, // Smadex
|
|
99
|
+
{ SKAdNetworkIdentifier: 'uw77j35x4d.skadnetwork' }, // The Trade Desk
|
|
100
|
+
{ SKAdNetworkIdentifier: 'pwa73g5rt2.skadnetwork' }, // Tremor
|
|
101
|
+
{ SKAdNetworkIdentifier: '578prtvx9j.skadnetwork' }, // Unicorn
|
|
102
|
+
{ SKAdNetworkIdentifier: '4dzt52r2t5.skadnetwork' }, // Unity Ads
|
|
103
|
+
{ SKAdNetworkIdentifier: 'tl55sbb4fm.skadnetwork' }, // Verve
|
|
104
|
+
{ SKAdNetworkIdentifier: 'e5fvkxwrpn.skadnetwork' }, // Yahoo!
|
|
105
|
+
{ SKAdNetworkIdentifier: '8c4e2ghe7u.skadnetwork' }, // Yahoo! Japan Ads
|
|
106
|
+
{ SKAdNetworkIdentifier: '3rd42ekr43.skadnetwork' }, // YouAppi
|
|
107
|
+
{ SKAdNetworkIdentifier: '3qcr597p9d.skadnetwork' }, // Zucks
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
const updatedPlistContent = plist.build(plistData);
|
|
111
|
+
fs.writeFileSync(infoPlistPath, updatedPlistContent, 'utf8');
|
|
112
|
+
console.log('AdMob IDs and additional configurations successfully updated in Info.plist');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
if (!fileExists(configPath)) {
|
|
117
|
+
throw new Error('capacitor.config.json not found. Skipping setup.');
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (!fileExists(androidPlatformPath) && !fileExists(iosPlatformPath)) {
|
|
121
|
+
throw new Error('Neither Android nor iOS platforms are found. Ensure platforms are added to your Capacitor project.');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const admobConfig = getAdMobConfig();
|
|
125
|
+
|
|
126
|
+
if (fileExists(androidPlatformPath)) {
|
|
127
|
+
updatePluginXml(admobConfig);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (fileExists(iosPlatformPath)) {
|
|
131
|
+
updateInfoPlist(admobConfig);
|
|
132
|
+
}
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.error(error.message);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
139
|
|
|
@@ -92,7 +92,7 @@ const mainActivityPath = constructMainActivityPath(packageName);
|
|
|
92
92
|
|
|
93
93
|
console.log('Select an animation type for the splash screen:');
|
|
94
94
|
animations.forEach((animation) => {
|
|
95
|
-
console.log(`${animation.id}. ${animation.name}`);
|
|
95
|
+
//console.log(`${animation.id}. ${animation.name}`);
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
// Prompt user for animation selection
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codeplay-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.60",
|
|
4
4
|
"description": "Common build scripts and files",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"postinstall": "node scripts/sync-files.js"
|
|
7
|
-
"preinstall": "node scripts/uninstall.js"
|
|
6
|
+
"postinstall": "node scripts/sync-files.js"
|
|
8
7
|
},
|
|
9
8
|
"repository": {
|
|
10
9
|
"type": "git",
|
package/scripts/sync-files.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const fs = require("fs");
|
|
2
2
|
const path = require("path");
|
|
3
3
|
|
|
4
|
-
const projectRoot = path.resolve(__dirname, "../../../")
|
|
4
|
+
const projectRoot = path.resolve(__dirname, "../../../"); // Your project's root
|
|
5
5
|
const commonBuildPath = path.join(__dirname, "../files"); // Path to common files
|
|
6
6
|
const packageJsonPath = path.join(projectRoot, "package.json");
|
|
7
|
-
|
|
7
|
+
const buildCodeplayPath = path.join(projectRoot, "buildCodeplay");
|
|
8
8
|
|
|
9
9
|
// Ensure package.json exists
|
|
10
10
|
if (!fs.existsSync(packageJsonPath)) {
|
|
@@ -12,37 +12,20 @@ if (!fs.existsSync(packageJsonPath)) {
|
|
|
12
12
|
process.exit(1);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
// Ensure buildCodeplay directory exists
|
|
16
|
+
if (!fs.existsSync(buildCodeplayPath)) {
|
|
17
|
+
fs.mkdirSync(buildCodeplayPath, { recursive: true });
|
|
18
|
+
}
|
|
15
19
|
|
|
16
20
|
function copyFolderSync(source, destination) {
|
|
17
21
|
try {
|
|
18
22
|
fs.cpSync(source, destination, { recursive: true });
|
|
19
|
-
process.stdout.write(`✅ Copied folder: ${source} -> ${destination}`);
|
|
23
|
+
process.stdout.write(`✅ Copied folder: ${source} -> ${destination}\n`);
|
|
20
24
|
} catch (error) {
|
|
21
|
-
process.stderr.write(`⚠️ Failed to copy folder: ${source} - ${error.message}`);
|
|
25
|
+
process.stderr.write(`⚠️ Failed to copy folder: ${source} - ${error.message}\n`);
|
|
22
26
|
}
|
|
23
27
|
}
|
|
24
28
|
|
|
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}`);
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
process.stderr.write(`⚠️ Failed to copy file: ${file} - ${error.message}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
29
|
// Function to get the latest versioned file
|
|
47
30
|
function getLatestFile(prefix) {
|
|
48
31
|
const files = fs.readdirSync(commonBuildPath).filter(file => file.startsWith(prefix));
|
|
@@ -51,30 +34,72 @@ function getLatestFile(prefix) {
|
|
|
51
34
|
return files[0];
|
|
52
35
|
}
|
|
53
36
|
|
|
37
|
+
// List of file prefixes to be copied to buildCodeplay
|
|
38
|
+
const filePrefixes = [
|
|
39
|
+
"add-splash-screen-",
|
|
40
|
+
"codeplayBeforeBuild-",
|
|
41
|
+
"modify-plugin-xml",
|
|
42
|
+
"setSplashAnimation-"
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
const copiedFiles = new Set();
|
|
46
|
+
|
|
47
|
+
// Copy required files to buildCodeplay
|
|
48
|
+
filePrefixes.forEach(prefix => {
|
|
49
|
+
const latestFile = getLatestFile(prefix);
|
|
50
|
+
if (latestFile) {
|
|
51
|
+
const sourcePath = path.join(commonBuildPath, latestFile);
|
|
52
|
+
const destPath = path.join(buildCodeplayPath, latestFile);
|
|
53
|
+
try {
|
|
54
|
+
fs.copyFileSync(sourcePath, destPath);
|
|
55
|
+
process.stdout.write(`✅ Copied file: ${latestFile} -> ${destPath}\n`);
|
|
56
|
+
copiedFiles.add(latestFile);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
process.stderr.write(`⚠️ Failed to copy file: ${latestFile} - ${error.message}\n`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
54
62
|
|
|
63
|
+
// Copy splashxml folder
|
|
64
|
+
const splashXmlSource = path.join(commonBuildPath, "splashxml");
|
|
65
|
+
const splashXmlDest = path.join(buildCodeplayPath, "splashxml");
|
|
66
|
+
if (fs.existsSync(splashXmlSource)) {
|
|
67
|
+
copyFolderSync(splashXmlSource, splashXmlDest);
|
|
68
|
+
}
|
|
55
69
|
|
|
70
|
+
// Copy remaining files to the project root
|
|
71
|
+
fs.readdirSync(commonBuildPath).forEach(file => {
|
|
72
|
+
const sourcePath = path.join(commonBuildPath, file);
|
|
73
|
+
const destPath = path.join(projectRoot, file);
|
|
56
74
|
|
|
75
|
+
if (!copiedFiles.has(file)) {
|
|
76
|
+
if (fs.statSync(sourcePath).isDirectory()) {
|
|
77
|
+
copyFolderSync(sourcePath, destPath);
|
|
78
|
+
} else {
|
|
79
|
+
try {
|
|
80
|
+
fs.copyFileSync(sourcePath, destPath);
|
|
81
|
+
process.stdout.write(`✅ Copied file: ${file} -> ${destPath}\n`);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
process.stderr.write(`⚠️ Failed to copy file: ${file} - ${error.message}\n`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
57
88
|
|
|
58
|
-
|
|
59
|
-
|
|
89
|
+
// Update package.json
|
|
90
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
91
|
+
packageJson.scripts = packageJson.scripts || {};
|
|
60
92
|
|
|
61
93
|
// Detect latest script versions
|
|
62
94
|
const latestSplashScreen = getLatestFile("add-splash-screen-");
|
|
63
95
|
const latestSplashAnimation = getLatestFile("setSplashAnimation-");
|
|
64
96
|
const latestCodeplayBuild = getLatestFile("codeplayBeforeBuild-");
|
|
65
97
|
|
|
66
|
-
// Update package.json
|
|
67
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
68
|
-
|
|
69
|
-
// Ensure scripts object exists
|
|
70
|
-
packageJson.scripts = packageJson.scripts || {};
|
|
71
|
-
|
|
72
|
-
// Update or add necessary scripts
|
|
73
98
|
if (latestCodeplayBuild) {
|
|
74
|
-
packageJson.scripts["build"] = `node
|
|
99
|
+
packageJson.scripts["build"] = `node buildCodeplay/${latestCodeplayBuild} && cross-env NODE_ENV=production vite build`;
|
|
75
100
|
}
|
|
76
101
|
if (latestSplashScreen && latestSplashAnimation) {
|
|
77
|
-
packageJson.scripts["capacitor:sync:after"] = `node
|
|
102
|
+
packageJson.scripts["capacitor:sync:after"] = `node buildCodeplay/${latestSplashScreen} && node buildCodeplay/${latestSplashAnimation}`;
|
|
78
103
|
}
|
|
79
104
|
|
|
80
105
|
packageJson.scripts["ionic:build"] = "npm run build";
|
|
@@ -83,6 +108,5 @@ packageJson.scripts["build:storeid1"] = "vite build --mode storeid1";
|
|
|
83
108
|
packageJson.scripts["build:storeid2"] = "vite build --mode storeid2";
|
|
84
109
|
packageJson.scripts["build:storeid7"] = "vite build --mode storeid7";
|
|
85
110
|
|
|
86
|
-
// Save changes
|
|
87
111
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8");
|
|
88
|
-
process.stdout.write("✅ package.json updated
|
|
112
|
+
process.stdout.write("✅ package.json updated!\n");
|
package/scripts/uninstall.js
CHANGED
|
@@ -7,6 +7,7 @@ const filePrefixes = [
|
|
|
7
7
|
];
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
const splashXmlPath = path.join(projectRoot, "splashxml"); // Path to splashxml folder
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
|
|
@@ -17,7 +18,12 @@ const path = require("path");
|
|
|
17
18
|
const projectRoot = path.resolve(__dirname, "../../../"); // Project root
|
|
18
19
|
const commonBuildPath = path.join(__dirname, "../files"); // Path where files were copied from
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
21
27
|
|
|
22
28
|
process.stdout.write("🚀 Uninstalling: Removing old and copied files...");
|
|
23
29
|
|
|
@@ -41,6 +47,8 @@ const removeDirectory = (dirPath) => {
|
|
|
41
47
|
removeDirectory(splashXmlPath);
|
|
42
48
|
|
|
43
49
|
|
|
50
|
+
|
|
51
|
+
|
|
44
52
|
// Helper function to extract version from filename
|
|
45
53
|
const extractVersion = (filename) => {
|
|
46
54
|
const match = filename.match(/-(\d+\.\d+)\.js$/);
|
|
File without changes
|