Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/highcharts-custom-scripts-env #578

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ HIGHCHARTS_CDN_URL = https://code.highcharts.com/
HIGHCHARTS_CORE_SCRIPTS =
HIGHCHARTS_MODULE_SCRIPTS =
HIGHCHARTS_INDICATOR_SCRIPTS =
HIGHCHARTS_CUSTOM_SCRIPTS =
HIGHCHARTS_FORCE_FETCH = false
HIGHCHARTS_CACHE_PATH =
HIGHCHARTS_ADMIN_TOKEN =
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ These variables are set in your environment and take precedence over options fro
- `HIGHCHARTS_CORE_SCRIPTS`: Highcharts core scripts to fetch (defaults to ``).
- `HIGHCHARTS_MODULE_SCRIPTS`: Highcharts module scripts to fetch (defaults to ``).
- `HIGHCHARTS_INDICATOR_SCRIPTS`: Highcharts indicator scripts to fetch (defaults to ``).
- `HIGHCHARTS_CUSTOM_SCRIPTS`: Custom scripts that you want to fetch, ex. additional maps (defaults to ``).
- `HIGHCHARTS_FORCE_FETCH`: The flag that determines whether to refetch all scripts after each server rerun (defaults to `false`).
- `HIGHCHARTS_CACHE_PATH`: In which directory should the fetched Highcharts scripts be placed (defaults to `.cache`).
- `HIGHCHARTS_ADMIN_TOKEN`: An authentication token that is required to switch the Highcharts version on the server at runtime (defaults to ``).
Expand Down
3 changes: 2 additions & 1 deletion lib/envs.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const v = {
value
.split(',')
.map((value) => value.trim())
.filter((value) => filterArray.includes(value))
.filter((value) => !filterArray || filterArray.includes(value))
)
.transform((value) => (value.length ? value : undefined)),

Expand Down Expand Up @@ -123,6 +123,7 @@ export const Config = z.object({
HIGHCHARTS_CORE_SCRIPTS: v.array(scriptsNames.core),
HIGHCHARTS_MODULE_SCRIPTS: v.array(scriptsNames.modules),
HIGHCHARTS_INDICATOR_SCRIPTS: v.array(scriptsNames.indicators),
HIGHCHARTS_CUSTOM_SCRIPTS: v.array(),
HIGHCHARTS_FORCE_FETCH: v.boolean(),
HIGHCHARTS_CACHE_PATH: v.string(),
HIGHCHARTS_ADMIN_TOKEN: v.string(),
Expand Down
1 change: 1 addition & 0 deletions lib/schemas/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export const defaultConfig = {
customScripts: {
value: scriptsNames.custom,
type: 'string[]',
envLink: 'HIGHCHARTS_CUSTOM_SCRIPTS',
description: 'Additional custom scripts or dependencies to fetch.'
},
forceFetch: {
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/envs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ describe('Environment variables should be correctly parsed', () => {
const env = {
HIGHCHARTS_CORE_SCRIPTS: 'core1, core2, highcharts',
HIGHCHARTS_MODULE_SCRIPTS: 'module1, map, module2',
HIGHCHARTS_INDICATOR_SCRIPTS: 'indicators-all, indicator1, indicator2'
HIGHCHARTS_INDICATOR_SCRIPTS: 'indicators-all, indicator1, indicator2',
HIGHCHARTS_CUSTOM_SCRIPTS: 'custom1, custom2'
};

const parsed = Config.partial().parse(env);

expect(parsed.HIGHCHARTS_CORE_SCRIPTS).toEqual(['highcharts']);
expect(parsed.HIGHCHARTS_MODULE_SCRIPTS).toEqual(['map']);
expect(parsed.HIGHCHARTS_INDICATOR_SCRIPTS).toEqual(['indicators-all']);
expect(parsed.HIGHCHARTS_CUSTOM_SCRIPTS).toEqual(['custom1', 'custom2']);
});

test('HIGHCHARTS_FORCE_FETCH should be a boolean', () => {
Expand Down
Loading