Skip to content

Commit

Permalink
fix(application-config): allow to define entryPointUriPath with env…
Browse files Browse the repository at this point in the history
… placeholder (#2474)

* fix(application-config): allow env vars in entryPointUriPath config

* fix(application-config): allow env vars in entryPointUriPath config

* fix: update Readme instruction command for playground

* chore: changeset added

* chore: better changeset description

Co-authored-by: Nicola Molinari <[email protected]>

* chore: update version type in changeset

Co-authored-by: Nicola Molinari <[email protected]>

* fix(application-config): incorrect schema typing

Co-authored-by: Nicola Molinari <[email protected]>

* fix(application-config): incorrect entryPointUriPath TS type

* test(application-config): udpate json-schema test

* test(application-config): update fixture for entry point as env variable

Co-authored-by: Nicola Molinari <[email protected]>
  • Loading branch information
CarlosCortizasCT and emmenko authored Feb 7, 2022
1 parent 7490740 commit e4eeccb
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/slimy-parrots-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-frontend/application-config': patch
---

Allow to use environment variable placeholders for the `entryPointUriPath` field.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Start the [playground application](./playground):
```bash
// Terminal process 1
$ yarn build:bundles:watch
$ yarn build:watch

// Terminal process 2
$ yarn playground:start
Expand Down
12 changes: 9 additions & 3 deletions packages/application-config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@
},
"entryPointUriPath": {
"description": "See https://docs.commercetools.com/custom-applications/api-reference/application-config#entrypointuripath",
"type": "string",
"pattern": "^[^\\-_]([0-9a-z]|[\\-_](?![\\-_])){2,64}[^\\-_]$"
"oneOf": [
{
"type": "string",
"pattern": "^[^\\-_]([0-9a-z]|[\\-_](?![\\-_])){2,64}[^\\-_]$"
},
{
"$ref": "#/definitions/envVariablePlaceholder"
}
]
},
"cloudIdentifier": {
"description": "See https://docs.commercetools.com/custom-applications/api-reference/application-config#cloudidentifier",
"type": "string",
"oneOf": [
{
"enum": ["gcp-au", "gcp-eu", "gcp-us", "aws-fra", "aws-ohio"]
Expand Down
2 changes: 1 addition & 1 deletion packages/application-config/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface JSONSchemaForCustomApplicationConfigurationFiles {
/**
* See https://docs.commercetools.com/custom-applications/api-reference/application-config#cloudidentifier
*/
cloudIdentifier: (('gcp-au' | 'gcp-eu' | 'gcp-us' | 'aws-fra' | 'aws-ohio') | EnvVariablePlaceholder) & string;
cloudIdentifier: ('gcp-au' | 'gcp-eu' | 'gcp-us' | 'aws-fra' | 'aws-ohio') | EnvVariablePlaceholder;
/**
* See https://docs.commercetools.com/custom-applications/api-reference/application-config#mcapiurl
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "avengers-app",
"entryPointUriPath": "avengers",
"entryPointUriPath": "${env:ENTRY_POINT_URI_PATH}",
"cloudIdentifier": "${env:CLOUD_IDENTIFIER}",
"env": {
"development": {
Expand Down
1 change: 1 addition & 0 deletions packages/application-config/test/json-schema.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe.each`
${'avengers01'}
${'avengers-01'}
${'avengers_01'}
${'${env:APP_ENTRY_POINT_URI_PATH}'}
`('validating "entryPointUriPath"', ({ entryPointUriPath }) => {
it(`should validate "${entryPointUriPath}" correctly`, () => {
expect(() =>
Expand Down
4 changes: 4 additions & 0 deletions packages/application-config/test/process-config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ describe('processing a config with environment variable placeholders', () => {
const result = processConfig(
createTestOptions({
processEnv: {
ENTRY_POINT_URI_PATH: 'avengers',
APP_URL: 'https://avengers.app',
CLOUD_IDENTIFIER: 'gcp-eu',
NODE_ENV: 'test',
Expand Down Expand Up @@ -473,6 +474,7 @@ describe('processing a config with environment variable placeholders', () => {
const result = processConfig(
createTestOptions({
processEnv: {
ENTRY_POINT_URI_PATH: 'avengers',
APP_URL: 'https://avengers.app',
CLOUD_IDENTIFIER: 'gcp-eu',
NODE_ENV: 'production',
Expand Down Expand Up @@ -511,6 +513,7 @@ describe('processing a config with environment variable placeholders', () => {
const result = processConfig(
createTestOptions({
processEnv: {
ENTRY_POINT_URI_PATH: 'avengers',
APP_URL: 'https://avengers.app',
CLOUD_IDENTIFIER: 'gcp-eu',
NODE_ENV: 'production',
Expand Down Expand Up @@ -567,6 +570,7 @@ describe('processing a config with environment variable placeholders', () => {
const result = processConfig(
createTestOptions({
processEnv: {
ENTRY_POINT_URI_PATH: 'avengers',
APP_URL: 'https://avengers.app',
CLOUD_IDENTIFIER: 'gcp-eu',
NODE_ENV: 'production',
Expand Down

1 comment on commit e4eeccb

@vercel
Copy link

@vercel vercel bot commented on e4eeccb Feb 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.