Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/production' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
daneryl committed Jan 18, 2024
2 parents 988df41 + 38a8ee9 commit 0587dbf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uwazi",
"version": "1.150.0-rc2",
"version": "1.150.0-rc3",
"description": "Uwazi is a free, open-source solution for organising, analysing and publishing your documents.",
"keywords": [
"react"
Expand Down
48 changes: 39 additions & 9 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,49 @@
/* eslint-disable no-multi-str */
/* eslint-disable no-console */
const { access } = require('fs/promises');

/* eslint-disable global-require */
require('dotenv').config();

process.env.ROOT_PATH = process.env.ROOT_PATH || __dirname;
const { NODE_ENV } = process.env;

require.extensions['.scss'] = function scss() {};
require.extensions['.css'] = function css() {};
require.extensions['.scss'] = function scss() { };
require.extensions['.css'] = function css() { };

if (NODE_ENV === 'production') {
const fileExists = async filePath => {
try {
require('./app/server.js');
await access(filePath);
} catch (err) {
require('./prod/app/server.js');
if (err?.code === 'ENOENT') {
return false;
}
if (err) {
throw err;
}
}
return true;
};

(async () => {
if (NODE_ENV === 'production') {
const productionBuildExists = await fileExists('./prod/app/server.js');
if (productionBuildExists) {
require('./prod/app/server.js');
} else {
try {
require('./app/server.js');
} catch (e) {
console.error(e);
console.error(
'\x1b[31m%s\x1b[0m',
"\nIf you are in a development environment you are probably trying to run a production uwazi without a production build, \
try 'yarn production-build' first"
);
}
}
} else {
require('@babel/register')({ extensions: ['.js', '.jsx', '.ts', '.tsx'] });
require('./app/server.js');
}
} else {
require('@babel/register')({ extensions: ['.js', '.jsx', '.ts', '.tsx'] });
require('./app/server.js');
}
})();

0 comments on commit 0587dbf

Please sign in to comment.