diff --git a/src/lib/config-loader.js b/src/lib/config-loader.js index 22e79b1f..0be6d49e 100644 --- a/src/lib/config-loader.js +++ b/src/lib/config-loader.js @@ -164,7 +164,11 @@ module.exports = () => { config.ow.package = `${config.app.name}-${config.app.version}` // S3 static files deployment config config.s3.folder = config.ow.namespace // this becomes the root only / - config.s3.tvmUrl = userConfig.app.tvmurl || defaultTvmUrl + // Legacy applications set the defaultTvmUrl in .env, so we need to ignore it to not + // consider it as custom. The default will be set downstream by aio-lib-core-tvm. + if (userConfig.app.tvmurl !== defaultTvmUrl) { + config.s3.tvmUrl = userConfig.app.tvmurl + } // set hostname for backend actions && UI config.app.defaultHostname = defaultAppHostname config.app.hostname = userConfig.app.hostname || defaultAppHostname diff --git a/test/commands/lib/config-loader.test.js b/test/commands/lib/config-loader.test.js index ea1738d7..88bddd9b 100644 --- a/test/commands/lib/config-loader.test.js +++ b/test/commands/lib/config-loader.test.js @@ -15,6 +15,7 @@ const loadConfig = require('../../../src/lib/config-loader') const mockAIOConfig = require('@adobe/aio-lib-core-config') const yaml = require('js-yaml') const chalk = require('chalk') +const defaults = require('../../../src/lib/defaults') jest.mock('@adobe/aio-lib-core-logging') const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:config-loader', { provider: 'debug' }) @@ -101,4 +102,34 @@ describe('load config', () => { expect(config.ow.defaultApihost).toEqual('https://adobeioruntime.net') expect(config.app.defaultHostname).toEqual('adobeio-static.net') }) + + test('Tvm url config', () => { + // custom + mockAIOConfig.get.mockReturnValue({ + ...global.fakeConfig.creds, + app: { + tvmurl: 'custom' + } + }) + config = loadConfig() + expect(config.s3.tvmUrl).toEqual('custom') + // empty + mockAIOConfig.get.mockReturnValue({ + ...global.fakeConfig.creds, + app: { + tvmurl: undefined + } + }) + config = loadConfig() + expect(config.s3.tvmUrl).toEqual(undefined) + // default (should not set it) + mockAIOConfig.get.mockReturnValue({ + ...global.fakeConfig.creds, + app: { + tvmurl: defaults.defaultTvmUrl + } + }) + config = loadConfig() + expect(config.s3.tvmUrl).toEqual(undefined) + }) })