Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: parse pluginType from d2 config to add to manifest.webapp #849

Merged
merged 7 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cli/src/lib/generateManifests.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ module.exports = (paths, config, publicUrl) => {

launch_path: shouldIncludeAppLaunchPath ? paths.launchPath : undefined,
plugin_launch_path: includesPlugin ? paths.pluginLaunchPath : undefined,
plugin_type: includesPlugin ? config.pluginType : undefined,
default_locale: 'en',
activities: {
dhis: {
Expand Down
12 changes: 12 additions & 0 deletions cli/src/lib/parseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ const validateConfig = (config) => {
)
}
})

const { pluginType } = config
if (pluginType && !/^[A-Z0-9-_]+$/.test(pluginType)) {
throw new Error(
`Field ${chalk.bold(
'pluginType'
)} must contain only the characters A-Z (uppercase), 0-9, -, or _. Got: ${chalk.bold(
`"${pluginType}"`
)}`
)
}

return true
}

Expand Down
1 change: 1 addition & 0 deletions docs/config/d2-config-js-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The following configuration properties are supported:
| **entryPoints.plugin** | _string_ | | The path to the application's plugin entrypoint (not used for libraries) |
| **entryPoints.lib** | _string_ or _object_ | **./src/index** | The path to the library entrypoint(s) (not used for applications). Supports [conditional exports](https://nodejs.org/dist/latest-v16.x/docs/api/packages.html#packages_conditional_exports) |
| **skipPluginLogic** | _boolean_ | **false** | By default, plugin entry points will be wrapped with logic to allow the passing of properties and resizing between the parent app and the child plugin. This logic will allow users to use the plugin inside an app when wrapped in `<Plugin>` component from app-runtime. If set to true, this logic will not be loaded. |
| **pluginType** | _string_ | | Gets added to the `plugin_type` field for this app in the `/api/apps` response -- an example is `pluginType: 'DASHBOARD'` for a plugin meant to be consumed by the Dashboard app. Must be contain only characters from the set A-Z (uppercase), 0-9, `-` and `_`; i.e., it's tested against the regex `/^[A-Z0-9-_]+$/`. |
| **dataStoreNamespace** | _string_ | | The DataStore and UserDataStore namespace to reserve for this application. The reserved namespace **must** be suitably unique, as other apps will fail to install if they attempt to reserve the same namespace - see the [webapp manifest docs](https://docs.dhis2.org/en/develop/loading-apps.html) |
| **customAuthorities** | _Array(string)_ | | An array of custom authorities to create when installing the app, these do not provide security protections in the DHIS2 REST API but can be assigned to user roles and used to modify the interface displayed to a user - see the [webapp manifest docs](https://docs.dhis2.org/en/develop/loading-apps.html) |
| **minDHIS2Version** | _string_ | | The minimum DHIS2 version the App supports (eg. '2.35'). Required when uploading an app to the App Hub. The app's major version in the app's package.json needs to be increased when changing this property. |
Expand Down
2 changes: 2 additions & 0 deletions examples/pwa-app/d2.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const config = {
// Uncomment this to test plugin builds:
// plugin: './src/components/VisualizationsList.js',
},

// pluginType: 'DASHBOARD',
skipPluginLogic: true,
}

Expand Down
Loading