Skip to content

Commit

Permalink
[nextjs][RAV] avoid unexpected linebreaks when generating config (#1791)
Browse files Browse the repository at this point in the history
* [nextjs][RAV] avoid unexpected linebreaks when generating config
  • Loading branch information
art-alexeyenko authored May 9, 2024
1 parent 74bfc59 commit 0165bb1
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Our versioning strategy is as follows:

### 🐛 Bug Fixes

* `[templates/nextjs]` `[templates/react]` `[templates/vue]` `[templates/angular]` Changed formatting in temp/config to prevent parse issues in Unix systems ([#1787](https://github.com/Sitecore/jss/pull/1787))
* `[templates/nextjs]` `[templates/react]` `[templates/vue]` `[templates/angular]` Changed formatting in temp/config to prevent parse issues in Unix systems ([#1787](https://github.com/Sitecore/jss/pull/1787) [#1791](https://github.com/Sitecore/jss/pull/1791))

### 🎉 New Features & Improvements

Expand Down
16 changes: 8 additions & 8 deletions docs/upgrades/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,40 @@
# react

* Replace `scripts/generate-config.js` if you have not modified it. Otherwise:
* Replace comma before a newline (`,`) with semicolon (`;`) in configText prop assignment so it would look like this:
* Add a `trim()` call to `config[prop]` and replace comma before a newline (`,`) with semicolon (`;`) in configText prop assignment so it would look like this:

```
configText += `config.${prop} = process.env.REACT_APP_${constantCase(prop)} || "${
config[prop]
config[prop]?.trim()
}";\n`;
```

# angular

* Replace `scripts/generate-config.ts` if you have not modified it. Otherwise:
* Replace comma before a newline (`,`) with semicolon (`;`) in configText prop assignment so it would look like this:
* Add a `trim()` call to `config[prop]` (use toString() to avoid type conflicts) and replace commas before a newline (`,`) with semicolon (`;`) in configText prop assignments so it would look like this:

```
configText += `config.${prop} = process.env.${constantCase(prop)} || "${config[prop]}";\n`;
configText += `config.${prop} = process.env.${constantCase(prop)} || "${config[prop]?.toString().trim()}";\n`;
```


# vue

* Replace `scripts/generate-config.js` if you have not modified it. Otherwise:
* Replace comma before a newline (`,`) with semicolon (`;`) in configText prop assignment so it would look like this:
* Add a `trim()` call to `config[prop]` and replace commas before a newline (`,`) with semicolon (`;`) in configText prop assignments so it would look like this:

```
configText += `config.${prop} = process.env.VUE_APP_${constantCase(prop)} || "${
config[prop]
config[prop]?.trim()
}";\n`;
```
# nextjs
* Replace `scripts/generate-config.ts` if you have not modified it. Otherwise:
* Replace comma before a newline (`,`) with semicolon (`;`) in configText prop assignment so it would look like this:
* Add a `trim()` call to `config[prop]` and replace comma before a newline (`,`) with semicolon (`;`) in configText prop assignment so it would look like this:
```
configText += `config.${prop} = process.env.${constantCase(prop)} || '${config[prop]}';\n`;
configText += `config.${prop} = process.env.${constantCase(prop)} || '${config[prop]?.trim()}';\n`;
```
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ const config = {};\n`;

// Set base configuration values, allowing override with environment variables
Object.keys(config).forEach((prop) => {
configText += `config.${prop} = process.env.${constantCase(prop)} || "${config[prop]}";\n`;
configText += `config.${prop} = process.env.${constantCase(prop)} || "${config[prop]?.toString().trim()}";\n`;
});
// Set computed values, allowing override with environment variables
Object.keys(computedConfig).forEach((prop) => {
configText += `config.${prop} = process.env.${constantCase(prop)} || ${
computedConfig[prop]
computedConfig[prop]?.toString().trim()
};\n`;
});
configText += `module.exports.environment = config;`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const config = {};\n`;

// Set configuration values, allowing override with environment variables
Object.keys(config).forEach(prop => {
configText += `config.${prop} = process.env.${constantCase(prop)} || '${config[prop]}';\n`;
configText += `config.${prop} = process.env.${constantCase(prop)} || '${config[prop]?.trim()}';\n`;
});

configText += `module.exports = config;`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const config = {};\n`;
// Set base configuration values, allowing override with environment variables
Object.keys(config).forEach(prop => {
configText += `config.${prop} = process.env.REACT_APP_${constantCase(prop)} || "${
config[prop]
config[prop]?.trim()
}";\n`;
});
configText += 'module.exports = config;';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ const config = {};\n`;
// Set base configuration values, allowing override with environment variables
Object.keys(config).forEach((prop) => {
configText += `config.${prop} = process.env.VUE_APP_${constantCase(prop)} || "${
config[prop]
config[prop]?.trim()
}";\n`;
});
// Set computed values, allowing override with environment variables
Object.keys(computedConfig).forEach((prop) => {
configText += `config.${prop} = process.env.VUE_APP_${constantCase(prop)} || ${
computedConfig[prop]
computedConfig[prop]?.trim()
};\n`;
});
configText += 'module.exports = config;';
Expand Down

0 comments on commit 0165bb1

Please sign in to comment.