@unvired/cordova-plugin-unvired-electron-db 0.0.47 → 0.0.48
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/hooks/update-c-flags.js +75 -0
- package/package.json +1 -1
- package/plugin.xml +1 -1
- package/src/electron/package.json +1 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const xcode = require('xcode');
|
|
4
|
+
|
|
5
|
+
module.exports = function (context) {
|
|
6
|
+
const projectRoot = context.opts.projectRoot;
|
|
7
|
+
const iosPath = path.join(projectRoot, 'platforms', 'ios');
|
|
8
|
+
|
|
9
|
+
if (!fs.existsSync(iosPath)) {
|
|
10
|
+
console.warn('[c-flags] iOS platform folder not found, skipping patch.');
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const files = fs.readdirSync(iosPath);
|
|
15
|
+
const xcodeProjName = files.find(file => file.endsWith('.xcodeproj'));
|
|
16
|
+
if (!xcodeProjName) {
|
|
17
|
+
console.warn('[c-flags] xcodeproj not found, skipping patch.');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const projectPath = path.join(iosPath, xcodeProjName, 'project.pbxproj');
|
|
22
|
+
const myProj = xcode.project(projectPath);
|
|
23
|
+
|
|
24
|
+
myProj.parseSync();
|
|
25
|
+
|
|
26
|
+
const cFlags = [
|
|
27
|
+
'-DNDEBUG',
|
|
28
|
+
'-DSQLCIPHER_CRYPTO_CC',
|
|
29
|
+
'-DSQLITE_HAS_CODEC',
|
|
30
|
+
'-DSQLITE_TEMP_STORE=2',
|
|
31
|
+
'-DSQLITE_THREADSAFE=1'
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const buildConfigs = myProj.pbxXCBuildConfigurationSection();
|
|
35
|
+
let updated = false;
|
|
36
|
+
|
|
37
|
+
for (const key in buildConfigs) {
|
|
38
|
+
if (key.endsWith('_comment')) continue;
|
|
39
|
+
const config = buildConfigs[key];
|
|
40
|
+
if (config && config.buildSettings) {
|
|
41
|
+
let currentFlags = config.buildSettings.OTHER_CFLAGS || '';
|
|
42
|
+
|
|
43
|
+
// Normalize currentFlags to a string and strip quotes
|
|
44
|
+
if (typeof currentFlags === 'string') {
|
|
45
|
+
currentFlags = currentFlags.replace(/"/g, '');
|
|
46
|
+
} else if (Array.isArray(currentFlags)) {
|
|
47
|
+
currentFlags = currentFlags.map(f => typeof f === 'string' ? f.replace(/"/g, '') : f).join(' ');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Convert current flags to an array of tokens
|
|
51
|
+
let flagTokens = currentFlags.split(/\s+/).filter(t => t.length > 0);
|
|
52
|
+
|
|
53
|
+
// Make sure $(inherited) is the first flag if not already present
|
|
54
|
+
if (!flagTokens.includes('$(inherited)')) {
|
|
55
|
+
flagTokens.unshift('$(inherited)');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Add our flags if they are not already present
|
|
59
|
+
cFlags.forEach(flag => {
|
|
60
|
+
if (!flagTokens.includes(flag)) {
|
|
61
|
+
flagTokens.push(flag);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Join back as a single string wrapped in quotes
|
|
66
|
+
config.buildSettings.OTHER_CFLAGS = `"${flagTokens.join(' ')}"`;
|
|
67
|
+
updated = true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (updated) {
|
|
72
|
+
fs.writeFileSync(projectPath, myProj.writeSync());
|
|
73
|
+
console.log('✅ programmatically added SQLCipher C Flags to all configurations.');
|
|
74
|
+
}
|
|
75
|
+
};
|
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
|
2
2
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
3
3
|
id="@unvired/cordova-plugin-unvired-electron-db"
|
|
4
|
-
version="0.0.
|
|
4
|
+
version="0.0.48"
|
|
5
5
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
6
6
|
<name>Unvired DB</name>
|
|
7
7
|
<description>Unvired DB Native Support for Cordova</description>
|