forked from b2network/frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENVs integrity check (blockscout#1039)
* group account envs in docs * remove NEXT_PUBLIC_LOGOUT_RETURN_URL env * simple ENVs checker * add types for all envs * group values in config * global envs types * text tweaks * fixes * [skip ci] fix docker build
- Loading branch information
Showing
48 changed files
with
2,096 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
Dockerfile | ||
.dockerignore | ||
node_modules | ||
/**/node_modules | ||
node_modules_linux | ||
npm-debug.log | ||
README.md | ||
.next | ||
.git | ||
.git | ||
*.tsbuildinfo | ||
.eslintcache | ||
/test-results/ | ||
/playwright-report/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* eslint-disable no-console */ | ||
import type { ZodError } from 'zod-validation-error'; | ||
import { fromZodError } from 'zod-validation-error'; | ||
|
||
import { nextPublicEnvsSchema } from './schema'; | ||
|
||
try { | ||
const appEnvs = Object.entries(process.env) | ||
.filter(([ key ]) => key.startsWith('NEXT_PUBLIC_')) | ||
.reduce((result, [ key, value ]) => { | ||
result[key] = value || ''; | ||
return result; | ||
}, {} as Record<string, string>); | ||
|
||
console.log(`⏳ Validating environment variables schema...`); | ||
nextPublicEnvsSchema.parse(appEnvs); | ||
console.log('👍 All good!\n'); | ||
} catch (error) { | ||
const validationError = fromZodError( | ||
error as ZodError, | ||
{ | ||
prefix: '', | ||
prefixSeparator: '\n ', | ||
issueSeparator: ';\n ', | ||
}, | ||
); | ||
console.log(validationError); | ||
console.log('🚨 ENV set is invalid\n'); | ||
process.exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "envs-validator", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "yarn ts-to-zod ./envs.ts ./schema.ts && yarn webpack-cli -c ./webpack.config.js", | ||
"validate": "node ./index.js", | ||
"dev": "cp ../../../types/envs.ts ./ && yarn build && yarn dotenv -e ../../../configs/envs/.env.poa_core yarn validate" | ||
}, | ||
"dependencies": { | ||
"ts-loader": "^9.4.4", | ||
"ts-to-zod": "^3.1.3", | ||
"webpack": "^5.88.2", | ||
"webpack-cli": "^5.1.4", | ||
"zod": "^3.21.4", | ||
"zod-validation-error": "^1.3.1" | ||
}, | ||
"devDependencies": { | ||
"dotenv-cli": "^7.2.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es6", | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"esModuleInterop": true, | ||
"module": "CommonJS", | ||
"moduleResolution": "node", | ||
"isolatedModules": true, | ||
"incremental": true, | ||
"baseUrl": "." | ||
}, | ||
"include": ["./schema.ts"], | ||
"exclude": ["node_modules"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const path = require('path'); | ||
module.exports = { | ||
mode: 'production', | ||
entry: path.resolve(__dirname) + '/index.ts', | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.tsx?$/, | ||
use: 'ts-loader', | ||
exclude: /node_modules/, | ||
}, | ||
], | ||
}, | ||
resolve: { | ||
extensions: [ '.tsx', '.ts', '.js' ], | ||
}, | ||
output: { | ||
filename: 'index.js', | ||
path: path.resolve(__dirname), | ||
}, | ||
}; |
Oops, something went wrong.