codeplay-common 2.1.38 → 2.1.39

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.
@@ -11,6 +11,12 @@ import path from 'path';
11
11
  */
12
12
  function addAndroidPermissions(permissionsToAdd) {
13
13
  try {
14
+
15
+ if (!Array.isArray(permissionsToAdd) || permissionsToAdd.length === 0) {
16
+ console.log("ℹ️ No permissions to add");
17
+ return;
18
+ }
19
+
14
20
  // read capacitor.config.json
15
21
  const configPath = path.join(process.cwd(), 'capacitor.config.json');
16
22
  if (!fs.existsSync(configPath)) {
@@ -157,73 +163,75 @@ const appJssmallModifications=()=>{
157
163
  const replaceKeyboardSet=()=>{
158
164
 
159
165
 
160
- const appJsPath = path.join(process.cwd(), 'src', 'js', 'capacitor-app.js');
166
+ const appJsPath = path.join(process.cwd(), 'src', 'js', 'capacitor-app.js');
161
167
 
162
- if (fs.existsSync(appJsPath)) {
163
- let appJsContent = fs.readFileSync(appJsPath, 'utf8');
168
+ if (fs.existsSync(appJsPath)) {
169
+ let appJsContent = fs.readFileSync(appJsPath, 'utf8');
164
170
 
165
- const lines = appJsContent.split(/\r?\n/);
166
- const newLines = [];
171
+ const lines = appJsContent.split(/\r?\n/);
172
+ const newLines = [];
167
173
 
168
- const targetKeywords = [
169
- 'Keyboard.setResizeMode',
170
- 'Keyboard.setScroll',
171
- 'Keyboard.setAccessoryBarVisible',
172
- ];
174
+ const targetKeywords = [
175
+ 'Keyboard.setResizeMode',
176
+ 'Keyboard.setScroll',
177
+ 'Keyboard.setAccessoryBarVisible',
178
+ ];
173
179
 
174
- let insideIosWrap = false;
180
+ let insideIosWrap = false;
175
181
 
176
- lines.forEach((line, index) => {
177
- const trimmed = line.trim();
182
+ lines.forEach((line, index) => {
183
+ const trimmed = line.trim();
178
184
 
179
- // detect already inside ios check
180
- if (/if\s*\(\s*Capacitor\.getPlatform\(\)\s*===\s*['"]ios['"]\s*\)/.test(trimmed)) {
181
- insideIosWrap = true;
182
- newLines.push(line);
183
- return;
184
- }
185
+ // detect already inside ios check
186
+ if (/if\s*\(\s*Capacitor\.getPlatform\(\)\s*===\s*['"]ios['"]\s*\)/.test(trimmed)) {
187
+ insideIosWrap = true;
188
+ newLines.push(line);
189
+ return;
190
+ }
185
191
 
186
- // detect closing of a block
187
- if (insideIosWrap && trimmed === '}') {
188
- insideIosWrap = false;
189
- newLines.push(line);
190
- return;
191
- }
192
+ // detect closing of a block
193
+ if (insideIosWrap && trimmed === '}') {
194
+ insideIosWrap = false;
195
+ newLines.push(line);
196
+ return;
197
+ }
192
198
 
193
- const isKeyboardSetCall = targetKeywords.some((kw) => trimmed.startsWith(kw));
199
+ const isKeyboardSetCall = targetKeywords.some((kw) => trimmed.startsWith(kw));
194
200
 
195
- if (isKeyboardSetCall) {
196
- if (!insideIosWrap) {
197
- const indentMatch = line.match(/^(\s*)/);
198
- const indent = indentMatch ? indentMatch[1] : '';
199
- newLines.push(`${indent}if (Capacitor.getPlatform() === 'ios') {`);
200
- newLines.push(`${indent} ${trimmed}`);
201
- newLines.push(`${indent}}`);
202
- console.log(`✅ Wrapped line ${index + 1} with ios check`);
201
+ if (isKeyboardSetCall) {
202
+ if (!insideIosWrap) {
203
+ const indentMatch = line.match(/^(\s*)/);
204
+ const indent = indentMatch ? indentMatch[1] : '';
205
+ newLines.push(`${indent}if (Capacitor.getPlatform() === 'ios') {`);
206
+ newLines.push(`${indent} ${trimmed}`);
207
+ newLines.push(`${indent}}`);
208
+ console.log(`✅ Wrapped line ${index + 1} with ios check`);
209
+ } else {
210
+ // already inside ios wrap, leave alone
211
+ newLines.push(line);
212
+ }
203
213
  } else {
204
- // already inside ios wrap, leave alone
205
214
  newLines.push(line);
206
215
  }
207
- } else {
208
- newLines.push(line);
209
- }
210
- });
216
+ });
211
217
 
212
- fs.writeFileSync(appJsPath, newLines.join('\n'), 'utf8');
213
- console.log(`✅ All Keyboard.set* lines wrapped safely with ios check`);
214
- } else {
215
-
218
+ fs.writeFileSync(appJsPath, newLines.join('\n'), 'utf8');
219
+ console.log(`✅ All Keyboard.set* lines wrapped safely with ios check`);
220
+ }
221
+ else
222
+ {
223
+
216
224
 
217
- const configPath = path.join(process.cwd(), 'capacitor.config.json');
225
+ const configPath = path.join(process.cwd(), 'capacitor.config.json');
218
226
 
219
- const rawData = fs.readFileSync(configPath, 'utf8');
220
- const config = JSON.parse(rawData);
227
+ const rawData = fs.readFileSync(configPath, 'utf8');
228
+ const config = JSON.parse(rawData);
221
229
 
222
- const appUniqueId=config.android.APP_UNIQUE_ID
230
+ const appUniqueId=config.android.APP_UNIQUE_ID
223
231
 
224
- if(appUniqueId!=172)
225
- console.error(`❌ src/js/capacitor-app.js not found at: ${appJsPath}`);
226
- }
232
+ if(appUniqueId!=172)
233
+ console.error(`❌ src/js/capacitor-app.js not found at: ${appJsPath}`);
234
+ }
227
235
 
228
236
 
229
237
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeplay-common",
3
- "version": "2.1.38",
3
+ "version": "2.1.39",
4
4
  "description": "Common build scripts and files",
5
5
  "scripts": {
6
6
  "postinstall": "node scripts/sync-files.js",