Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nextjs][RAV] avoid unexpected linebreaks when generating config #1791

Merged
merged 3 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
14 changes: 7 additions & 7 deletions docs/upgrades/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@
# 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`;
```

Expand All @@ -38,5 +38,5 @@
* Replace comma before a newline (`,`) with semicolon (`;`) in configText prop assignment so it would look like this:
art-alexeyenko marked this conversation as resolved.
Show resolved Hide resolved

```
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