From 1edd6c27ee943747bd58e0bf35c86944902287e6 Mon Sep 17 00:00:00 2001 From: Tim Klever Date: Sat, 29 Jun 2024 11:29:38 -0700 Subject: [PATCH 1/2] feat: update ConfigSources options to match process.env typings Signed-off-by: Tim Klever --- .changeset/neat-bears-divide.md | 28 +++++++++++++++++++ packages/config-loader/api-report.md | 2 +- .../src/sources/ConfigSources.ts | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 .changeset/neat-bears-divide.md diff --git a/.changeset/neat-bears-divide.md b/.changeset/neat-bears-divide.md new file mode 100644 index 0000000000..b40db6c7bd --- /dev/null +++ b/.changeset/neat-bears-divide.md @@ -0,0 +1,28 @@ +--- +'@backstage/config-loader': major +--- + +**BREAKING** The `env` property on the `ConfigSourcesDefaultOptions` interface allows for undefined members. + +This change makes `ConfigSourcesDefaultOptions.env` consistent with other parts of this package and the wider +`node` ecosystem. Specifically, with this update `ConfigSourcesDefaultOptions.env`'s types match: + +#### EnvConfigSource + +- [`EnvConfigSource.constructor`](https://github.com/backstage/backstage/blob/c780320418b7775f18fc0d2cc279ee7db9c7cb25/packages/config-loader/src/sources/EnvConfigSource.ts#L68) +- [`EnvConfigSourceOptions`](https://github.com/backstage/backstage/blob/c780320418b7775f18fc0d2cc279ee7db9c7cb25/packages/config-loader/src/sources/EnvConfigSource.ts#L31) +- [`readEnvConfig`](https://github.com/backstage/backstage/blob/c780320418b7775f18fc0d2cc279ee7db9c7cb25/packages/config-loader/src/sources/EnvConfigSource.ts#L114) + +#### NodeJS process.env + +- [`ProcessEnv`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/aa121ee3a7a3caa16433b66c1103df5904f612ea/types/node/v18/process.d.ts#L137) + which extends [`Dict`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/aa121ee3a7a3caa16433b66c1103df5904f612ea/types/node/v18/globals.d.ts#L333-L335) + +While this is a somewhat trivial change, it does loosen typings on a public interface, so by definition it's a breaking +change and a major version bump. + +You may meed to update your backstage instance if you have built an implementation of `ConfigSources` or any other +functionality that relies on `ConfigSourcesDefaultOptions`. This change means you'll have to update that code to account +for the possibility of `undefined` values inside `ConfigSourcesDefaultOptions.env`, although it is very likely already +accounted for as the typings for [`process.env`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/aa121ee3a7a3caa16433b66c1103df5904f612ea/types/node/v18/process.d.ts#L137) +already include the possibility of [`undefined`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/aa121ee3a7a3caa16433b66c1103df5904f612ea/types/node/v18/globals.d.ts#L333-L335). diff --git a/packages/config-loader/api-report.md b/packages/config-loader/api-report.md index bc8f217bbb..da836ffd21 100644 --- a/packages/config-loader/api-report.md +++ b/packages/config-loader/api-report.md @@ -87,7 +87,7 @@ export interface ConfigSourcesDefaultOptions extends BaseConfigSourcesOptions { // (undocumented) argv?: string[]; // (undocumented) - env?: Record; + env?: Record; } // @public diff --git a/packages/config-loader/src/sources/ConfigSources.ts b/packages/config-loader/src/sources/ConfigSources.ts index ecff39da2d..15eede736e 100644 --- a/packages/config-loader/src/sources/ConfigSources.ts +++ b/packages/config-loader/src/sources/ConfigSources.ts @@ -102,7 +102,7 @@ export interface ConfigSourcesDefaultForTargetsOptions */ export interface ConfigSourcesDefaultOptions extends BaseConfigSourcesOptions { argv?: string[]; - env?: Record; + env?: Record; } /** From 1383f4c98cb16ed97f1e5064b30beb94b934dcdf Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 26 Jul 2024 10:04:55 +0200 Subject: [PATCH 2/2] Update .changeset/neat-bears-divide.md Signed-off-by: Patrik Oldsberg --- .changeset/neat-bears-divide.md | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/.changeset/neat-bears-divide.md b/.changeset/neat-bears-divide.md index b40db6c7bd..a94b17f74d 100644 --- a/.changeset/neat-bears-divide.md +++ b/.changeset/neat-bears-divide.md @@ -1,28 +1,5 @@ --- -'@backstage/config-loader': major +'@backstage/config-loader': patch --- -**BREAKING** The `env` property on the `ConfigSourcesDefaultOptions` interface allows for undefined members. - -This change makes `ConfigSourcesDefaultOptions.env` consistent with other parts of this package and the wider -`node` ecosystem. Specifically, with this update `ConfigSourcesDefaultOptions.env`'s types match: - -#### EnvConfigSource - -- [`EnvConfigSource.constructor`](https://github.com/backstage/backstage/blob/c780320418b7775f18fc0d2cc279ee7db9c7cb25/packages/config-loader/src/sources/EnvConfigSource.ts#L68) -- [`EnvConfigSourceOptions`](https://github.com/backstage/backstage/blob/c780320418b7775f18fc0d2cc279ee7db9c7cb25/packages/config-loader/src/sources/EnvConfigSource.ts#L31) -- [`readEnvConfig`](https://github.com/backstage/backstage/blob/c780320418b7775f18fc0d2cc279ee7db9c7cb25/packages/config-loader/src/sources/EnvConfigSource.ts#L114) - -#### NodeJS process.env - -- [`ProcessEnv`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/aa121ee3a7a3caa16433b66c1103df5904f612ea/types/node/v18/process.d.ts#L137) - which extends [`Dict`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/aa121ee3a7a3caa16433b66c1103df5904f612ea/types/node/v18/globals.d.ts#L333-L335) - -While this is a somewhat trivial change, it does loosen typings on a public interface, so by definition it's a breaking -change and a major version bump. - -You may meed to update your backstage instance if you have built an implementation of `ConfigSources` or any other -functionality that relies on `ConfigSourcesDefaultOptions`. This change means you'll have to update that code to account -for the possibility of `undefined` values inside `ConfigSourcesDefaultOptions.env`, although it is very likely already -accounted for as the typings for [`process.env`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/aa121ee3a7a3caa16433b66c1103df5904f612ea/types/node/v18/process.d.ts#L137) -already include the possibility of [`undefined`](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/aa121ee3a7a3caa16433b66c1103df5904f612ea/types/node/v18/globals.d.ts#L333-L335). +The `env` option of `ConfigSources.default` now correctly allows undefined members.