Files
threshold-ui/ui/admin/app/instance-initializers/feature-edition.js
T
Zhihe Li 999c21c66a Upgrade eslint (#3175)
* chore: 🤖 Upgrade eslint config for admin ui

* chore: 🤖 Fix eslint issues for admin

* chore: 🤖 Upgrade eslint config for desktop

* chore: 🤖 Fix linting errors in desktop

* chore: 🤖 Upgrade eslint for api addon

* chore: 🤖 Fix eslint issues in api addon

* chore: 🤖 Upgrade eslint for auth addon

* chore: 🤖 Fix eslint issues in auth addon

* chore: 🤖 Upgrade core eslint config

* chore: 🤖 Fix eslint issue for core addon

* chore: 🤖 Upgrade eslint config for rose addon

* chore: 🤖 Fix eslint issue for rose addon

* chore: 🤖 Upgrade e2e eslint config

* chore: 🤖 Fix eslint issues in e2e

* chore: 🤖 Fix CI linting issues

* chore: 🤖 Add back linting server files for the future

* chore: 🤖 Update qunit rules to use extends
2026-02-27 13:32:27 -05:00

45 lines
1.2 KiB
JavaScript

/**
* Copyright IBM Corp. 2021, 2026
* SPDX-License-Identifier: BUSL-1.1
*/
async function autoInitializeFeatureEdition(owner) {
const service = owner.lookup('service:feature-edition');
const adapter = owner.lookup('adapter:application');
let edition;
let features;
// Attempt to load edition for the metadata JSON
try {
const { host } = adapter;
const path = '/metadata.json';
const url = `${host}${path}`;
const response = await fetch(url);
const json = await response.json();
edition = json?.license?.edition;
features = json?.license?.features;
} catch {
// if the request fails, the service will initialize the default edition
// as specified in the config
}
// Initialize the feature edition and its associated features
service.initialize(edition, features);
}
export async function initialize(owner) {
const config = owner.resolveRegistration('config:environment');
const isTesting = config.environment === 'test';
// Do not auto-init in a test environment.
// Tests should explicitly enable editions and features as needed.
if (!isTesting) {
await autoInitializeFeatureEdition(owner);
}
}
export default {
initialize,
};