Skip to content

Commit d3c67df

Browse files
committed
feat(managed-config): Add Managed Config plugin (@config-plugins/managed-config)
1 parent fa4397d commit d3c67df

15 files changed

Lines changed: 874 additions & 1 deletion

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
react-native-siri-shortcut,
4444
react-native-google-cast,
4545
react-native-pdf,
46+
managed-config,
4647
]
4748
name: Test ${{ matrix.package }} on Node ${{ matrix.node }}
4849
steps:

apps/app/app.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,21 @@
3333
"@config-plugins/react-native-adjust",
3434
"@config-plugins/react-native-callkeep",
3535
"@config-plugins/android-jsc-intl",
36-
"expo-localization"
36+
"expo-localization",
37+
[
38+
"@config-plugins/managed-config",
39+
{
40+
"restrictions": [
41+
{
42+
"key": "test_key",
43+
"title": "Test Title",
44+
"restrictionType": "string",
45+
"description": "Testing managed config plugin",
46+
"defaultValue": "Hello world"
47+
}
48+
]
49+
}
50+
]
3751
]
3852
}
3953
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// @generated by expo-module-scripts
2+
module.exports = require("expo-module-scripts/eslintrc.base.js");

packages/managed-config/README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# @config-plugins/managed-config
2+
3+
Expo Config Plugin to auto-configure [Managed Configurations](https://developer.android.com/work/managed-configurations) on Android, facilitating the integration with Mobile Device Management (MDM) solutions like [Microsoft Intune](https://www.microsoft.com/en-us/mem/intune) and [VMware Workspace ONE](https://www.vmware.com/products/workspace-one.html). This allows enterprises to remotely manage and configure apps. It can be used with libraries such as [react-native-emm](https://github.com/mattermost/react-native-emm) or [react-native-mdm](https://github.com/robinpowered/react-native-mdm) to allow your app to be managed by an MDM solution.
4+
5+
## Expo Installation
6+
7+
> Note: This package cannot be utilized in the "Expo Go" app due to its reliance on custom native code, as detailed in Expo's [customizing the build process guide](https://docs.expo.io/workflow/customizing/).
8+
9+
First, install the package using yarn, npm, or [`npx expo install`](https://docs.expo.io/workflow/expo-cli/#expo-install) for better version compatibility:
10+
11+
```sh
12+
npm install @config-plugins/managed-config
13+
```
14+
15+
Or
16+
17+
```sh
18+
yarn add @config-plugins/managed-config
19+
```
20+
21+
After installation, add the [config plugin](https://docs.expo.io/guides/config-plugins/) to the [`plugins`](https://docs.expo.io/versions/latest/config/app/#plugins) array in your project's `app.json` or `app.config.js`:
22+
23+
```json
24+
{
25+
"expo": {
26+
"plugins": [
27+
[
28+
"@config-plugins/managed-config",
29+
{
30+
"restrictions": [
31+
{
32+
"key": "test_key",
33+
"title": "Test Title",
34+
"restrictionType": "string",
35+
"description": "A test description",
36+
"defaultValue": "Default value"
37+
}
38+
// Add more restrictions as needed
39+
]
40+
}
41+
]
42+
]
43+
}
44+
}
45+
```
46+
47+
Lastly, you'll need to rebuild your app to apply these changes. Refer to Expo's guide on ["Adding custom native code"](https://docs.expo.io/workflow/customizing/) for instructions on rebuilding your app.
48+
49+
## API
50+
51+
The plugin is configured through the `plugins` section of your `app.json` or `app.config.js`. The configuration object accepts a `restrictions` array, where each object represents a managed configuration that your app supports. The structure for each restriction object is as follows:
52+
53+
### Properties
54+
55+
- **`key`** (string): A unique identifier for the restriction.
56+
- **`title`** (string): A human-readable title for the restriction, used by the MDM solution to display to admins.
57+
- **`restrictionType`** (string): The type of the restriction. Possible values include `bool`, `string`, `integer`, `choice`, `multi-select`, `hidden`, `bundle`, and `bundle_array`.
58+
- **`description`** (optional, string): A detailed description of the restriction.
59+
- **`defaultValue`** (optional, string | boolean | number | string[] | null): The default value for the restriction. The type depends on the `restrictionType`.
60+
- **`entries`** (optional, string[]): Applicable to `choice` and `multi-select` types. An array of human-readable options.
61+
- **`entryValues`** (optional, string[]): Applicable to `choice` and `multi-select` types. An array of values corresponding to each option in `entries`.
62+
63+
### Example:
64+
65+
Adding a configuration for a "dark mode" setting that allows users to choose between 'enabled' and 'disabled'.
66+
67+
```json
68+
{
69+
"expo": {
70+
"plugins": [
71+
[
72+
"@config-plugins/managed-config",
73+
{
74+
"restrictions": [
75+
{
76+
"key": "dark_mode",
77+
"title": "Dark Mode",
78+
"restrictionType": "choice",
79+
"entries": ["Enabled", "Disabled"],
80+
"entryValues": ["enabled", "disabled"],
81+
"defaultValue": "disabled",
82+
"description": "Allow users to select dark mode preference"
83+
}
84+
]
85+
}
86+
]
87+
]
88+
}
89+
}
90+
```
91+
92+
This plugin simplifies the process of making your app manageable through MDM solutions by automating the setup of managed configurations.
93+
94+
For further details or support, check the [official documentation](https://developer.android.com/work/managed-configurations) on managed configurations.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require("./build/withManagedConfig");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require("expo-module-scripts/jest-preset-plugin");
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "@config-plugins/managed-config",
3+
"version": "0.0.0",
4+
"description": "Config plugin for managed-config package",
5+
"main": "build/withManagedConfig.js",
6+
"types": "build/withManagedConfig.d.ts",
7+
"sideEffects": false,
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/expo/config-plugins.git",
11+
"directory": "packages/managed-config"
12+
},
13+
"scripts": {
14+
"build": "expo-module build",
15+
"clean": "expo-module clean",
16+
"lint": "expo-module lint",
17+
"test": "expo-module test",
18+
"prepare": "expo-module prepare",
19+
"prepublishOnly": "expo-module prepublishOnly",
20+
"expo-module": "expo-module"
21+
},
22+
"keywords": [
23+
"react",
24+
"expo",
25+
"config-plugins",
26+
"prebuild",
27+
"managed-config",
28+
"expo-50"
29+
],
30+
"peerDependencies": {
31+
"expo": "^50"
32+
},
33+
"devDependencies": {
34+
"expo-module-scripts": "^3.4.1"
35+
}
36+
}

0 commit comments

Comments
 (0)