@@ -46,8 +46,8 @@ export type LoadConfigOptions = {
|
||||
configTargets: ConfigTarget[];
|
||||
env?: string;
|
||||
experimentalEnvFunc?: (name: string) => Promise<string | undefined>;
|
||||
remote?: Remote;
|
||||
watch?: Watch;
|
||||
remote?: LoadConfigOptionsRemote;
|
||||
watch?: LoadConfigOptionsWatch;
|
||||
};
|
||||
|
||||
// @public
|
||||
@@ -73,10 +73,10 @@ export function readEnvConfig(env: {
|
||||
[name: string]: string | undefined;
|
||||
}): AppConfig[];
|
||||
|
||||
// Warning: (ae-missing-release-tag) "Remote" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
// Warning: (ae-missing-release-tag) "LoadConfigOptionsRemote" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export type Remote = {
|
||||
export type LoadConfigOptionsRemote = {
|
||||
reloadIntervalSeconds: number;
|
||||
};
|
||||
|
||||
@@ -88,10 +88,10 @@ export type TransformFunc<T extends number | string | boolean> = (
|
||||
},
|
||||
) => T | undefined;
|
||||
|
||||
// Warning: (ae-missing-release-tag) "Watch" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
// Warning: (ae-missing-release-tag) "LoadConfigOptionsWatch" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
|
||||
//
|
||||
// @public (undocumented)
|
||||
export type Watch = {
|
||||
export type LoadConfigOptionsWatch = {
|
||||
onChange: (configs: AppConfig[]) => void;
|
||||
stopSignal?: Promise<void>;
|
||||
};
|
||||
|
||||
@@ -29,4 +29,9 @@ export type {
|
||||
TransformFunc,
|
||||
} from './lib';
|
||||
export { loadConfig } from './loader';
|
||||
export type { ConfigTarget, LoadConfigOptions, Watch, Remote } from './loader';
|
||||
export type {
|
||||
ConfigTarget,
|
||||
LoadConfigOptions,
|
||||
LoadConfigOptionsWatch,
|
||||
LoadConfigOptionsRemote,
|
||||
} from './loader';
|
||||
|
||||
@@ -32,7 +32,7 @@ import { isValidUrl } from '@backstage/integration';
|
||||
|
||||
export type ConfigTarget = { path: string } | { url: string };
|
||||
|
||||
export type Watch = {
|
||||
export type LoadConfigOptionsWatch = {
|
||||
/**
|
||||
* A listener that is called when a config file is changed.
|
||||
*/
|
||||
@@ -44,12 +44,7 @@ export type Watch = {
|
||||
stopSignal?: Promise<void>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Options that control the loading of configuration files in the backend.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type Remote = {
|
||||
export type LoadConfigOptionsRemote = {
|
||||
/**
|
||||
* An optional remote config reloading period, in seconds
|
||||
*/
|
||||
@@ -104,12 +99,12 @@ export type LoadConfigOptions = {
|
||||
/**
|
||||
* An optional remote config
|
||||
*/
|
||||
remote?: Remote;
|
||||
remote?: LoadConfigOptionsRemote;
|
||||
|
||||
/**
|
||||
* An optional configuration that enables watching of config files.
|
||||
*/
|
||||
watch?: Watch;
|
||||
watch?: LoadConfigOptionsWatch;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -222,13 +217,13 @@ export async function loadConfig(
|
||||
try {
|
||||
remoteConfigs = await loadRemoteConfigFiles();
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to read remote configuration file, ${error}`);
|
||||
throw new ForwardedError(`Failed to read remote configuration file, ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
const envConfigs = await readEnvConfig(process.env);
|
||||
|
||||
const watchConfigFile = (watchProp: Watch) => {
|
||||
const watchConfigFile = (watchProp: LoadConfigOptionsWatch) => {
|
||||
const watcher = chokidar.watch(configPaths, {
|
||||
usePolling: process.env.NODE_ENV === 'test',
|
||||
});
|
||||
@@ -257,7 +252,10 @@ export async function loadConfig(
|
||||
}
|
||||
};
|
||||
|
||||
const watchRemoteConfig = (watchProp: Watch, remoteProp: Remote) => {
|
||||
const watchRemoteConfig = (
|
||||
watchProp: LoadConfigOptionsWatch,
|
||||
remoteProp: LoadConfigOptionsRemote,
|
||||
) => {
|
||||
const hasConfigChanged = async (
|
||||
oldRemoteConfigs: AppConfig[],
|
||||
newRemoteConfigs: AppConfig[],
|
||||
|
||||
Reference in New Issue
Block a user