From a94eb98b542d9b42230fbb1974cc19459de3587b Mon Sep 17 00:00:00 2001 From: jpina1 Date: Fri, 5 Jan 2024 13:17:13 -0800 Subject: [PATCH] chore: removed applyEnvironmentOverrides --- packages/gasket-utils/docs/api.md | 19 -- .../gasket-utils/lib/apply-env-overrides.js | 17 -- packages/gasket-utils/lib/index.d.ts | 11 - packages/gasket-utils/lib/index.js | 2 - .../test/apply-env-overrides.test.js | 208 ------------------ packages/gasket-utils/test/index.test.js | 1 - 6 files changed, 258 deletions(-) delete mode 100644 packages/gasket-utils/lib/apply-env-overrides.js delete mode 100644 packages/gasket-utils/test/apply-env-overrides.test.js diff --git a/packages/gasket-utils/docs/api.md b/packages/gasket-utils/docs/api.md index bc3ba03de..5bde5bd8d 100644 --- a/packages/gasket-utils/docs/api.md +++ b/packages/gasket-utils/docs/api.md @@ -10,7 +10,6 @@ Name | Description Name | Description ------ | ----------- [applyConfigOverrides(config, context)] | Normalize the config by applying any overrides for environments, commands, or local-only config file. -~~[applyEnvironmentOverrides(gasketConfig, config, \[localFile\])]~~ | Normalize the config by applying any environment or local overrides [installDependency(dependency, gasket)] | installDependency - install dependency [requireWithInstall(dependency, gasket)] | requireWithInstall - load devDependency request programmatically when needed [runShellCommand(cmd, \[argv\], \[options\], \[debug\])] | Promise friendly wrapper to running a shell command (eg: git, npm, ls) which passes back any { stdout, stderr } to the error thrown. @@ -151,23 +150,6 @@ or local-only config file. | \[context.root\] | `string` | Project root; required if using localeFile | | \[context.localFile\] | `string` | Optional file to load relative to gasket root | - -## ~~applyEnvironmentOverrides(gasketConfig, config, \[localFile\])~~ - -***Deprecated*** - -Normalize the config by applying any environment or local overrides - -**Kind**: global function -**Returns**: `object` - config - -| Param | Type | Description | -| --- | --- | --- | -| gasketConfig | `object` | Gasket config | -| config | `object` | Target config to be normalized | -| \[localFile\] | `string` | Optional file to load relative to gasket root | - - ## installDependency(dependency, gasket) installDependency - install dependency @@ -276,7 +258,6 @@ const { tryRequire } = require('@gasket/utils'); [PackageManager]:#packagemanager [`PackageManager`]:#new-packagemanageroptions [applyConfigOverrides(config, context)]:#applyconfigoverridesconfig-context -[applyEnvironmentOverrides(gasketConfig, config, \[localFile\])]:#applyenvironmentoverridesgasketconfig-config-localfile [installDependency(dependency, gasket)]:#installdependencydependency-gasket [requireWithInstall(dependency, gasket)]:#requirewithinstalldependency-gasket [runShellCommand(cmd, \[argv\], \[options\], \[debug\])]:#runshellcommandcmd-argv-options-debug diff --git a/packages/gasket-utils/lib/apply-env-overrides.js b/packages/gasket-utils/lib/apply-env-overrides.js deleted file mode 100644 index 8f7879da0..000000000 --- a/packages/gasket-utils/lib/apply-env-overrides.js +++ /dev/null @@ -1,17 +0,0 @@ -const applyConfigOverrides = require('./apply-config-overrides'); - -/** - * Normalize the config by applying any environment or local overrides - * - * @param {object} gasketConfig - Gasket config - * @param {object} config - Target config to be normalized - * @param {string} [localFile] - Optional file to load relative to gasket root - * @returns {object} config - * @deprecated use applyConfigOverrides - */ -function applyEnvironmentOverrides(gasketConfig, config, localFile) { - const { env = '', root } = gasketConfig; - return applyConfigOverrides(config, { env, root, localFile }); -} - -module.exports = applyEnvironmentOverrides; diff --git a/packages/gasket-utils/lib/index.d.ts b/packages/gasket-utils/lib/index.d.ts index 62010faed..2d4537da4 100644 --- a/packages/gasket-utils/lib/index.d.ts +++ b/packages/gasket-utils/lib/index.d.ts @@ -60,17 +60,6 @@ export function applyConfigOverrides(config: GasketConfig, { env, commandId, roo localFile?: string; }): GasketConfig; -/** - * Normalize the config by applying any environment or local overrides - * - * @param gasketConfig - Gasket config - * @param config - Target config to be normalized - * @param [localFile] - Optional file to load relative to gasket root - * @returns config - * @deprecated use applyConfigOverrides - */ -declare function applyEnvironmentOverrides(gasketConfig: GasketConfig, config: GasketConfig, localFile?: string): object; - /** * Promise friendly wrapper to running a shell command (eg: git, npm, ls) * which passes back any { stdout, stderr } to the error thrown. diff --git a/packages/gasket-utils/lib/index.js b/packages/gasket-utils/lib/index.js index 0a82376e9..1d579ba32 100644 --- a/packages/gasket-utils/lib/index.js +++ b/packages/gasket-utils/lib/index.js @@ -1,7 +1,6 @@ const tryRequire = require('./try-require'); const { tryResolve } = require('./try-resolve'); const applyConfigOverrides = require('./apply-config-overrides'); -const applyEnvironmentOverrides = require('./apply-env-overrides'); const runShellCommand = require('./run-shell-command'); const PackageManager = require('./package-manager'); const requireWithInstall = require('./require-with-install'); @@ -10,7 +9,6 @@ module.exports = { tryRequire, tryResolve, applyConfigOverrides, - applyEnvironmentOverrides, runShellCommand, PackageManager, requireWithInstall diff --git a/packages/gasket-utils/test/apply-env-overrides.test.js b/packages/gasket-utils/test/apply-env-overrides.test.js deleted file mode 100644 index ea14cfe35..000000000 --- a/packages/gasket-utils/test/apply-env-overrides.test.js +++ /dev/null @@ -1,208 +0,0 @@ -const applyEnvironmentOverrides = require('../lib/apply-env-overrides'); - -describe('applyEnvironmentOverrides', () => { - let results, mockGasketConfig, mockConfig; - - beforeEach(() => { - mockGasketConfig = { - env: 'dev', - root: __dirname - }; - mockConfig = { - someService: { - url: 'https://some-test.url/' - } - }; - }); - - it('returns unmodified config if no "environments"', () => { - results = applyEnvironmentOverrides(mockGasketConfig, mockConfig); - expect(results).toEqual(mockConfig); - }); - - it('removes "environments" from config result', () => { - mockConfig.environments = { - bogus: {} - }; - - results = applyEnvironmentOverrides(mockGasketConfig, mockConfig); - expect(results).not.toHaveProperty('environments'); - }); - - it('returns unmodified config if no matching env', () => { - mockConfig.environments = { - bogus: {} - }; - - results = applyEnvironmentOverrides(mockGasketConfig, mockConfig); - expect(results).toEqual({ - someService: { - url: 'https://some-test.url/' - } - }); - }); - - it('deep merges properties from matching env', () => { - mockConfig.environments = { - dev: { - someService: { - requestRate: 9000 - } - } - }; - - results = applyEnvironmentOverrides(mockGasketConfig, mockConfig); - expect(results).toEqual({ - someService: { - url: 'https://some-test.url/', - requestRate: 9000 - } - }); - }); - - it('overrides properties from matching env', () => { - mockConfig.environments = { - dev: { - someService: { - url: 'https://some-dev-test.url/' - } - } - }; - - results = applyEnvironmentOverrides(mockGasketConfig, mockConfig); - expect(results).toEqual({ - someService: { - url: 'https://some-dev-test.url/' - } - }); - }); - - it('deep merges sub-env', () => { - mockGasketConfig.env = 'dev.sub'; - mockConfig.environments = { - 'dev': { - someService: { - url: 'https://some-dev-test.url/', - requestRate: 9000 - } - }, - 'dev.sub': { - someService: { - url: 'https://some-sub-dev-test.url/' - }, - other: 'setting' - } - }; - - results = applyEnvironmentOverrides(mockGasketConfig, mockConfig); - expect(results).toEqual({ - someService: { - url: 'https://some-sub-dev-test.url/', - requestRate: 9000 - }, - other: 'setting' - }); - }); - - it('ignores non-matching sub-env', () => { - mockGasketConfig.env = 'dev.sub2'; - mockConfig.environments = { - 'dev': { - someService: { - url: 'https://some-dev-test.url/', - requestRate: 9000 - } - }, - 'dev.sub': { - someService: { - url: 'https://some-sub-dev-test.url/' - }, - other: 'setting' - } - }; - - results = applyEnvironmentOverrides(mockGasketConfig, mockConfig); - expect(results).toEqual({ - someService: { - url: 'https://some-dev-test.url/', - requestRate: 9000 - } - }); - }); - - it('local inherits from development env', () => { - mockGasketConfig.env = 'local'; - - mockConfig.someService.requestRate = 5000; - mockConfig.environments = { - dev: { - someService: { - url: 'https://some-dev-test.url/', - requestRate: 9000 - } - } - }; - - results = applyEnvironmentOverrides(mockGasketConfig, mockConfig); - expect(results).toEqual({ - someService: { - url: 'https://some-dev-test.url/', - requestRate: 9000 - } - }); - }); - - it('local inherits from development env, supporting local specific settings', () => { - mockGasketConfig.env = 'local'; - - mockConfig.someService.requestRate = 5000; - mockConfig.environments = { - dev: { - someService: { - url: 'https://some-dev-test.url/', - requestRate: 9000 - } - }, - local: { - someService: { - url: 'https://some-local-test.url/' - } - } - }; - - results = applyEnvironmentOverrides(mockGasketConfig, mockConfig); - expect(results).toEqual({ - someService: { - url: 'https://some-local-test.url/', - requestRate: 9000 - } - }); - }); - - it('load locale override file for local env when set', () => { - mockGasketConfig.env = 'local'; - results = applyEnvironmentOverrides( - mockGasketConfig, - mockConfig, - './fixtures/config.local'); - expect(results).toEqual({ - localsOnly: true, - someService: { - url: 'https://some-test.url/' - } - }); - }); - - it('ingores missing local override file', () => { - mockGasketConfig.env = 'local'; - results = applyEnvironmentOverrides( - mockGasketConfig, - mockConfig, - './fixtures/missing'); - expect(results).toEqual({ - someService: { - url: 'https://some-test.url/' - } - }); - }); -}); diff --git a/packages/gasket-utils/test/index.test.js b/packages/gasket-utils/test/index.test.js index ac34e2e83..9defb0bd7 100644 --- a/packages/gasket-utils/test/index.test.js +++ b/packages/gasket-utils/test/index.test.js @@ -6,7 +6,6 @@ describe('index', () => { 'tryRequire', 'tryResolve', 'applyConfigOverrides', - 'applyEnvironmentOverrides', 'runShellCommand', 'PackageManager', 'requireWithInstall'