Files
webstudio/apps/builder/env-check.js
T
Oleg IsonenandShyanRoyChoudhury ce2a5ebc52 feat: Outline Section UX improvement (#2789)
## Description

1. What is this PR about (link the issue and add a short description)
The PR has 2 improvements mentioned in the issue #2602 :
 * Ordered the Outline section after the Effects section
 * Hides all properties except Style until a Style value is selected
 
## Steps for reproduction

1. Login and create a project.
2. On the style section on the right side of the screen. scroll down to
find the updates.
3.  Outline section has shifted below Effects section.
4. And only on selecting the other toggles on style property other than
none, renders the colour, width and offset properties.


## Code Review

- [x] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [x] made a self-review
- [x] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [x] tested locally and on preview environment (preview dev login:
d252)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory

---------

Co-authored-by: ShyanRoyChoudhury <shayan.roy31@gmail.com>
2024-01-21 17:22:31 +01:00

72 lines
2.3 KiB
JavaScript

// @ts-check
/**
* This file is included in `/remix.config.js` which ensures the app isn't built with invalid env vars.
* It has to be a `.js`-file to be imported there.
*/
/**
* Remix does not read .env files when building for production so this would make it to that when you tried to run pnpm build locally
* you would get an error because your environment variables are in the .env file.
* `dot-env` makes it so that when you run this file the `process.env` is always populated with your `.env` file if it finds one,
* if not it will read the environment variables set by your hosting provider like remix does.
*/
require("dotenv/config");
const REQUIRED_ENVS = ["DATABASE_URL", "AUTH_SECRET"];
const S3_KEYS = [
"S3_ENDPOINT",
"S3_REGION",
"S3_SECRET_ACCESS_KEY",
"S3_ACCESS_KEY_ID",
"S3_BUCKET",
];
const errors = [];
REQUIRED_ENVS.map((env) => {
if (!process.env[env]) {
errors.push(`👉 The ${env} environment variable is required`);
}
});
if (process.env.DEPLOYMENT_ENVIRONMENT === "production") {
if (!process.env.DEPLOYMENT_URL) {
errors.push(
"👉 In production DEPLOYMENT_URL is required for website functionality. Please set it to your production URL."
);
}
if (!process.env.BUILDER_HOST) {
errors.push(
"👉 In production BUILDER_HOST is required for website functionality. Please set it to your production URL of the builder."
);
}
if (!process.env.PUBLISHER_HOST) {
errors.push(
"👉 In production PUBLISHER_HOST is required for website functionality. Please set it to your production URL of the builder."
);
}
}
// check for when user has some S3 env variables but not all required
if (
S3_KEYS.some((key) => Object.keys(process.env).includes(key)) &&
!S3_KEYS.every((key) => Object.keys(process.env).includes(key))
) {
const notIncluded = S3_KEYS.filter(
(key) => !Object.keys(process.env).includes(key)
);
errors.push(
`👉 You don't have all the necessary envriroment variables to have S3 asset hosting, you are missing ${notIncluded.join(
","
)}`
);
}
if (errors.length) {
// eslint-disable-next-line no-console
console.error("❌ Invalid environment variables:");
// eslint-disable-next-line no-console
console.error(errors.join("\n"));
process.exit(1);
}