Skip to content

Commit

Permalink
chore: build fixes related to environment files handling
Browse files Browse the repository at this point in the history
  • Loading branch information
evereq committed Jun 29, 2024
1 parent 31cb8af commit 372f496
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 49 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@
}
},
"engines": {
"node": ">=16.20.1",
"node": ">=20.11.1",
"yarn": ">=1.22.19"
},
"prettier": {
Expand Down
23 changes: 20 additions & 3 deletions packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
"url": "https://ever.co"
},
"license": "AGPL-3.0",
"repository": {
"type": "git",
"url": "https://github.com/ever-co/ever-gauzy"
},
"bugs": {
"url": "https://github.com/ever-co/ever-gauzy/issues"
},
"homepage": "https://ever.co",
"keywords": [
"gauzy",
"angular",
"configuration",
"environment",
"settings",
"library"
],
"private": true,
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -23,10 +39,10 @@
},
"scripts": {
"build": "rimraf dist && yarn run compile",
"build:prod": "node replaceEnvFiles.js && yarn build",
"compile": "tsc -p tsconfig.build.json"
"build:prod": "cross-env NODE_ENV=production yarn ts-node scripts/replace-env-files.ts --environment=prod && yarn build",
"compile": "tsc -p tsconfig.build.json",
"clean": "rimraf dist"
},
"keywords": [],
"dependencies": {
"@nestjs/config": "^3.2.0",
"dotenv": "^16.0.3",
Expand All @@ -36,6 +52,7 @@
"@gauzy/common": "^0.1.0",
"@types/node": "^20.14.9",
"rimraf": "^3.0.2",
"cross-env": "^7.0.3",
"typescript": "5.1.6"
}
}
20 changes: 0 additions & 20 deletions packages/config/replaceEnvFiles.js

This file was deleted.

20 changes: 20 additions & 0 deletions packages/config/scripts/replace-env-files.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as path from 'path';
import * as fs from 'fs';

function replaceFilesForProduction() {
const env = process.env['NODE_ENV'] || 'development';

console.log(`Current NODE_ENV: ${process.env['NODE_ENV']}`);

if (env === 'production') {
const sourceFile = path.join(path.resolve('./src/environments'), 'environment.prod.ts');
const targetFile = path.join(path.resolve('./src/environments'), 'environment.ts');

fs.copyFileSync(sourceFile, targetFile);
console.log(`Replaced environment file with ${sourceFile}`);
} else {
console.log('Development build, no file replacement necessary.');
}
}

replaceFilesForProduction();
1 change: 1 addition & 0 deletions packages/config/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const environment: IEnvironment = {
*/
THROTTLE_TTL: parseInt(process.env.THROTTLE_TTL) || 60 * 1000,
THROTTLE_LIMIT: parseInt(process.env.THROTTLE_LIMIT) || 60000,
THROTTLE_ENABLED: process.env.THROTTLE_ENABLED == 'true',

/**
* Jitsu Server Configuration
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/job-search-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"job listings"
],
"engines": {
"node": ">=16.20.1",
"node": ">=20.11.1",
"yarn": ">=1.22.19"
},
"sideEffects": false
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"ui"
],
"engines": {
"node": ">=16.20.1",
"node": ">=20.11.1",
"yarn": ">=1.22.19"
},
"sideEffects": false
Expand Down
41 changes: 21 additions & 20 deletions packages/ui-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
"url": "https://ever.co"
},
"license": "AGPL-3.0",
"repository": {
"type": "git",
"url": "https://github.com/ever-co/ever-gauzy"
},
"bugs": {
"url": "https://github.com/ever-co/ever-gauzy/issues"
},
"homepage": "https://ever.co",
"keywords": [
"gauzy",
"angular",
"configuration",
"environment",
"settings",
"library"
],
"private": true,
"main": "dist/fesm2022/gauzy-ui-config.mjs",
"module": "dist/fesm2022/gauzy-ui-config.mjs",
Expand All @@ -28,8 +44,8 @@
"access": "restricted"
},
"scripts": {
"lib:build": "ng build ui-config --configuration development",
"lib:build:prod": "yarn ts-node scripts/replace-env-files.ts && ng build ui-config --configuration production",
"lib:build": "rimraf dist && ng build ui-config --configuration development",
"lib:build:prod": "cross-env NODE_ENV=production yarn ts-node scripts/replace-env-files.ts --environment=prod && ng build ui-config --configuration production",
"lib:watch": "ng build ui-config --watch --configuration development",
"clean": "rimraf dist"
},
Expand All @@ -42,26 +58,11 @@
},
"devDependencies": {
"@types/node": "^20.14.9",
"rimraf": "^3.0.2"
"rimraf": "^3.0.2",
"cross-env": "^7.0.3"
},
"repository": {
"type": "git",
"url": "https://github.com/ever-co/ever-gauzy"
},
"bugs": {
"url": "https://github.com/ever-co/ever-gauzy/issues"
},
"homepage": "https://ever.co",
"keywords": [
"gauzy",
"angular",
"configuration",
"environment",
"settings",
"library"
],
"engines": {
"node": ">=16.20.1",
"node": ">=20.11.1",
"yarn": ">=1.22.19"
},
"sideEffects": false
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-config/scripts/replace-env-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import * as path from 'path';
import * as fs from 'fs';

function replaceFilesForProduction() {
const env = process.env.NODE_ENV || 'development';
const env = process.env['NODE_ENV'] || 'development';

console.log(`Current NODE_ENV: ${process.env.NODE_ENV}`);
console.log(`Current NODE_ENV: ${process.env['NODE_ENV']}`);

if (env === 'production') {
const sourceFile = path.join(path.resolve(`./src/lib/environments`), 'environment.prod.ts');
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"ui"
],
"engines": {
"node": ">=16.20.1",
"node": ">=20.11.1",
"yarn": ">=1.22.19"
},
"sideEffects": false,
Expand Down

0 comments on commit 372f496

Please sign in to comment.