## Description - Eject the application from create react app - Remove references to craco in the scripts and package.json dependencies - Port craco changes to webpack configuration - Remove SASS and SCSS loaders - Add babel-plugin-lodash - Remove type checks and eslint from webpack Fixes #38903 ## Automation /ok-to-test tags="@tag.All" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/13323376575> > Commit: 8f206bdf2ab40f2162b8a32ead78715e850fbf58 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=13323376575&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.All` > Spec: > <hr>Fri, 14 Feb 2025 07:06:14 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced enhanced HTTPS configuration with improved security validations. - Improved handling of environment variables for a more robust configuration experience. - **Chores** - Upgraded and streamlined the build and start processes for better reliability and faster launches. - Refined dependency management and optimized bundling to improve performance. - Modernized module resolution and asset type definitions for a more efficient development workflow. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
67 lines
1.8 KiB
JavaScript
67 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const crypto = require('crypto');
|
|
const chalk = require('react-dev-utils/chalk');
|
|
const paths = require('./paths');
|
|
|
|
// Ensure the certificate and key provided are valid and if not
|
|
// throw an easy to debug error
|
|
function validateKeyAndCerts({ cert, key, keyFile, crtFile }) {
|
|
let encrypted;
|
|
try {
|
|
// publicEncrypt will throw an error with an invalid cert
|
|
encrypted = crypto.publicEncrypt(cert, Buffer.from('test'));
|
|
} catch (err) {
|
|
throw new Error(
|
|
`The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}`
|
|
);
|
|
}
|
|
|
|
try {
|
|
// privateDecrypt will throw an error with an invalid key
|
|
crypto.privateDecrypt(key, encrypted);
|
|
} catch (err) {
|
|
throw new Error(
|
|
`The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${
|
|
err.message
|
|
}`
|
|
);
|
|
}
|
|
}
|
|
|
|
// Read file and throw an error if it doesn't exist
|
|
function readEnvFile(file, type) {
|
|
if (!fs.existsSync(file)) {
|
|
throw new Error(
|
|
`You specified ${chalk.cyan(
|
|
type
|
|
)} in your env, but the file "${chalk.yellow(file)}" can't be found.`
|
|
);
|
|
}
|
|
return fs.readFileSync(file);
|
|
}
|
|
|
|
// Get the https config
|
|
// Return cert files if provided in env, otherwise just true or false
|
|
function getHttpsConfig() {
|
|
const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env;
|
|
const isHttps = HTTPS === 'true';
|
|
|
|
if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) {
|
|
const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE);
|
|
const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE);
|
|
const config = {
|
|
cert: readEnvFile(crtFile, 'SSL_CRT_FILE'),
|
|
key: readEnvFile(keyFile, 'SSL_KEY_FILE'),
|
|
};
|
|
|
|
validateKeyAndCerts({ ...config, keyFile, crtFile });
|
|
return config;
|
|
}
|
|
return isHttps;
|
|
}
|
|
|
|
module.exports = getHttpsConfig;
|