use dotenv for loading env vars from data/config.env
This commit is contained in:
parent
2168c40aa5
commit
6a7594fa32
4 changed files with 25 additions and 7 deletions
|
|
@ -46,9 +46,9 @@ After login, the script will just continue claiming the current games. If it sti
|
||||||
### Options
|
### Options
|
||||||
Options are set via [environment variables](https://kinsta.com/knowledgebase/what-is-an-environment-variable/) which can be set in many ways and allow for flexible configuration.
|
Options are set via [environment variables](https://kinsta.com/knowledgebase/what-is-an-environment-variable/) which can be set in many ways and allow for flexible configuration.
|
||||||
|
|
||||||
TODO: On the first run, the script will guide you through configuration and save all settings to a `.env` file. You can edit this file directly or run `node fgc config` to run the configuration assistant again.
|
TODO: On the first run, the script will guide you through configuration and save all settings to `data/config.env`. You can edit this file directly or run `node fgc config` to run the configuration assistant again.
|
||||||
|
|
||||||
The available options/variables and their default values are:
|
Available options/variables and their default values:
|
||||||
|
|
||||||
| Option | Default | Description |
|
| Option | Default | Description |
|
||||||
|--------------- |--------- |------------------------------------------------------------------------ |
|
|--------------- |--------- |------------------------------------------------------------------------ |
|
||||||
|
|
@ -65,6 +65,8 @@ The available options/variables and their default values are:
|
||||||
| GOG_EMAIL | | GOG email for login. Overrides EMAIL. |
|
| GOG_EMAIL | | GOG email for login. Overrides EMAIL. |
|
||||||
| GOG_PASSWORD | | GOG password for login. Overrides PASSWORD. |
|
| GOG_PASSWORD | | GOG password for login. Overrides PASSWORD. |
|
||||||
|
|
||||||
|
See `config.js` for all options.
|
||||||
|
|
||||||
#### Other ways to set options
|
#### Other ways to set options
|
||||||
On Linux/macOS you can prefix the variables you want to set, for example `EMAIL=foo@bar.baz SHOW=1 node epic-games` will show the browser and skip asking you for your login email.
|
On Linux/macOS you can prefix the variables you want to set, for example `EMAIL=foo@bar.baz SHOW=1 node epic-games` will show the browser and skip asking you for your login email.
|
||||||
For Docker you can pass variables using `-e VAR=VAL`, for example `docker run -e EMAIL=foo@bar.baz ...` or using `--env-file` (see [docs](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file)). If you are using [docker compose](https://docs.docker.com/compose/environment-variables/), you can put them in the `environment:` section.
|
For Docker you can pass variables using `-e VAR=VAL`, for example `docker run -e EMAIL=foo@bar.baz ...` or using `--env-file` (see [docs](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file)). If you are using [docker compose](https://docs.docker.com/compose/environment-variables/), you can put them in the `environment:` section.
|
||||||
|
|
|
||||||
11
config.js
11
config.js
|
|
@ -1,15 +1,16 @@
|
||||||
// import * as dotenv from 'dotenv';
|
import * as dotenv from 'dotenv';
|
||||||
// dotenv.config({ path: 'data/config.env' });
|
dotenv.config({ path: 'data/config.env' }); // loads env vars from file - will not set vars that are already set, i.e., can overwrite values from file by prefixing, e.g., VAR=VAL node ...
|
||||||
|
|
||||||
|
// Options - also see table in README.md
|
||||||
export const cfg = {
|
export const cfg = {
|
||||||
debug: process.env.PWDEBUG == '1', // runs non-headless and opens https://playwright.dev/docs/inspector
|
debug: process.env.PWDEBUG == '1', // runs non-headless and opens https://playwright.dev/docs/inspector
|
||||||
dryrun: process.env.DRYRUN == '1', // don't claim anything
|
dryrun: process.env.DRYRUN == '1', // don't claim anything
|
||||||
show: process.env.SHOW == '1', // run non-headless
|
show: process.env.SHOW == '1', // run non-headless
|
||||||
get headless() { return !this.debug && !this.show },
|
get headless() { return !this.debug && !this.show },
|
||||||
width: Number(process.env.WIDTH) || 1280,
|
width: Number(process.env.WIDTH) || 1280, // width of the opened browser
|
||||||
height: Number(process.env.HEIGHT) || 1280,
|
height: Number(process.env.HEIGHT) || 1280, // height of the opened browser
|
||||||
timeout: (Number(process.env.TIMEOUT) || 20) * 1000, // 20s, default for playwright is 30s
|
timeout: (Number(process.env.TIMEOUT) || 20) * 1000, // 20s, default for playwright is 30s
|
||||||
novnc_port: process.env.NOVNC_PORT,
|
novnc_port: process.env.NOVNC_PORT, // running in docker if set
|
||||||
eg_email: process.env.EG_EMAIL || process.env.EMAIL,
|
eg_email: process.env.EG_EMAIL || process.env.EMAIL,
|
||||||
eg_password: process.env.EG_PASSWORD || process.env.PASSWORD,
|
eg_password: process.env.EG_PASSWORD || process.env.PASSWORD,
|
||||||
pg_email: process.env.PG_EMAIL || process.env.EMAIL,
|
pg_email: process.env.PG_EMAIL || process.env.EMAIL,
|
||||||
|
|
|
||||||
14
package-lock.json
generated
14
package-lock.json
generated
|
|
@ -10,6 +10,7 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
|
"dotenv": "^16.0.3",
|
||||||
"lowdb": "^5.0.5",
|
"lowdb": "^5.0.5",
|
||||||
"playwright": "^1.29.0",
|
"playwright": "^1.29.0",
|
||||||
"prompts": "^2.4.2",
|
"prompts": "^2.4.2",
|
||||||
|
|
@ -125,6 +126,14 @@
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/dotenv": {
|
||||||
|
"version": "16.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
|
||||||
|
"integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/for-in": {
|
"node_modules/for-in": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
|
||||||
|
|
@ -693,6 +702,11 @@
|
||||||
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz",
|
||||||
"integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg=="
|
"integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg=="
|
||||||
},
|
},
|
||||||
|
"dotenv": {
|
||||||
|
"version": "16.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
|
||||||
|
"integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ=="
|
||||||
|
},
|
||||||
"for-in": {
|
"for-in": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
|
"dotenv": "^16.0.3",
|
||||||
"lowdb": "^5.0.5",
|
"lowdb": "^5.0.5",
|
||||||
"playwright": "^1.29.0",
|
"playwright": "^1.29.0",
|
||||||
"prompts": "^2.4.2",
|
"prompts": "^2.4.2",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue