-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2760 from crherman7/feat/ENG-5744
feat(env): ENG-5744 app-env package
- Loading branch information
Showing
49 changed files
with
4,903 additions
and
143 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,4 @@ | ||
{ | ||
"hiddenEnvs": [], | ||
"dir": "./coderc/env" | ||
} |
This file was deleted.
Oops, something went wrong.
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,3 +1,4 @@ | ||
module.exports = { | ||
presets: ['module:@react-native/babel-preset'], | ||
plugins: ['@brandingbrand/code-app-env/plugin'], | ||
}; |
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,30 @@ | ||
/** | ||
* @jest-environment-options {"requireTemplate": true} | ||
*/ | ||
|
||
/// <reference types="@brandingbrand/code-jest-config" /> | ||
|
||
import {fs, path} from '@brandingbrand/code-cli-kit'; | ||
import plugin from '../src'; | ||
|
||
describe('plugin', () => { | ||
it('ios', async () => { | ||
await plugin.ios?.({} as any, {} as any); | ||
|
||
const infoPlist = await fs.readFile(path.ios.infoPlist, 'utf-8'); | ||
|
||
expect(infoPlist).toContain(`<key>FlagshipEnv</key> | ||
<string>prod</string> | ||
<key>FlagshipDevMenu</key> | ||
<true/>`); | ||
}); | ||
|
||
it('android', async () => { | ||
await plugin.android?.({} as any, {} as any); | ||
|
||
const strings = await fs.readFile(path.android.strings, 'utf-8'); | ||
|
||
expect(strings).toContain('<string name="flagship_env">prod</string>'); | ||
expect(strings).toContain('<string name="flagship_dev_menu">true</string>'); | ||
}); | ||
}); |
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,19 @@ | ||
{ | ||
"name": "plugin-env", | ||
"version": "0.0.0", | ||
"license": "UNLICENSED", | ||
"private": true, | ||
"main": "src/index.ts", | ||
"scripts": { | ||
"lint": "eslint . --max-warnings 0", | ||
"test": "jest" | ||
}, | ||
"jest": { | ||
"preset": "@brandingbrand/code-jest-config" | ||
}, | ||
"types": "src/index.ts", | ||
"devDependencies": { | ||
"eslint": "^8.0.0", | ||
"jest": "^29.0.0" | ||
} | ||
} |
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,49 @@ | ||
/** | ||
* Defines a plugin for @brandingbrand/code-cli-kit. | ||
* @module Plugin | ||
*/ | ||
|
||
import { | ||
definePlugin, | ||
withInfoPlist, | ||
withStrings, | ||
} from '@brandingbrand/code-cli-kit'; | ||
|
||
/** | ||
* Defines a plugin with functions for both iOS and Android platforms. | ||
* @alias module:Plugin | ||
* @param {Object} build - The build configuration object. | ||
* @param {Object} options - The options object. | ||
*/ | ||
export default definePlugin({ | ||
/** | ||
* Function to be executed for iOS platform. | ||
* @param {Object} _build - The build configuration object for iOS. | ||
* @param {Object} _options - The options object for iOS. | ||
* @returns {Promise<void>} A promise that resolves when the process completes. | ||
*/ | ||
ios: async function (_build: object, _options: object): Promise<void> { | ||
await withInfoPlist(plist => { | ||
return { | ||
...plist, | ||
FlagshipEnv: 'prod', | ||
FlagshipDevMenu: true, | ||
}; | ||
}); | ||
}, | ||
|
||
/** | ||
* Function to be executed for Android platform. | ||
* @param {Object} _build - The build configuration object for Android. | ||
* @param {Object} _options - The options object for Android. | ||
* @returns {Promise<void>} A promise that resolves when the process completes. | ||
*/ | ||
android: async function (_build: object, _options: object): Promise<void> { | ||
return withStrings(xml => { | ||
xml.resources.string?.push({$: {name: 'flagship_env'}, _: 'prod'}); | ||
xml.resources.string?.push({$: {name: 'flagship_dev_menu'}, _: 'true'}); | ||
|
||
return xml; | ||
}); | ||
}, | ||
}); |
Oops, something went wrong.