-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor script to add Intercom api keys (#3426)
* Refactor * Revert capacitor config mod * changelog
- Loading branch information
Showing
2 changed files
with
23 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[Added] [#3425](https://github.com/cosmos/lunie/issues/3425) Refactor script to add Intercom API keys at the top-level capacitor config file. @mariopino |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,39 @@ | ||
const fs = require("fs") | ||
|
||
const iosConfigPath = "ios/App/App/capacitor.config.json" | ||
const androidConfigPath = "android/app/src/main/assets/capacitor.config.json" | ||
|
||
/* | ||
* this script adds the required intercom keys to the capacitor configs | ||
* this script adds the required intercom keys to the capacitor config | ||
* this is done in this script to avoid checking the keys into GitHub | ||
* | ||
* Usage: | ||
* | ||
* node tasks/add-intercom-key.js INTERCOM_APP_ID INTERCOM_ANDROID_KEY INTERCOM_IOS_KEY | ||
* | ||
*/ | ||
|
||
const fs = require("fs") | ||
|
||
const capacitorConfigPath = "capacitor.config.json" | ||
|
||
function main() { | ||
const intercomAppId = process.argv[2] | ||
const androidKey = process.argv[3] | ||
const iosKey = process.argv[4] | ||
|
||
const iosConfig = JSON.parse(fs.readFileSync(iosConfigPath)) | ||
if (!iosConfig.plugins) { | ||
iosConfigPath.plugins = {} | ||
const capacitorConfig = JSON.parse(fs.readFileSync(capacitorConfigPath)) | ||
|
||
if (!capacitorConfig.plugins) { | ||
capacitorConfigPath.plugins = {} | ||
} | ||
iosConfig.plugins.IntercomPlugin = { | ||
|
||
capacitorConfig.plugins.IntercomPlugin = { | ||
"android-apiKey": androidKey, | ||
"android-appId": intercomAppId, | ||
"ios-apiKey": iosKey, | ||
"ios-appId": intercomAppId | ||
} | ||
fs.writeFileSync(iosConfigPath, JSON.stringify(iosConfig)) | ||
|
||
const androidConfig = JSON.parse(fs.readFileSync(androidConfigPath)) | ||
if (!androidConfig.plugins) { | ||
androidConfig.plugins = {} | ||
} | ||
androidConfig.plugins.IntercomPlugin = { | ||
"android-apiKey": androidKey, | ||
"android-appId": intercomAppId | ||
} | ||
fs.writeFileSync(androidConfigPath, JSON.stringify(androidConfig)) | ||
fs.writeFileSync( | ||
capacitorConfigPath, | ||
JSON.stringify(capacitorConfig, null, 2) | ||
) | ||
} | ||
|
||
main() |