-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ui): allow deployment configuration (#15383)
hopefully this commit doesnt do anything, but it opens up the ability to change the static folder of the project through the environment variable STATIC_FOLDER so that we can cache static files and not cache the index file (allowing more passive deployment strategies), and allows the user to change the base path of the project with the BASE_PATH variable, opening up the ability to run an instance behind an nginx proxy, though that change is pending an update to the @influxdata/oats package before we can turn it on
- Loading branch information
1 parent
79f8cf0
commit f08152c
Showing
6 changed files
with
120 additions
and
10 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
./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
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,35 @@ | ||
const {formatStatic, formatBase} = require('./env') | ||
|
||
describe('enviroment normalization', () => { | ||
describe('static path formatter', () => { | ||
it('should strip the first slash', () => { | ||
expect(formatStatic('/neateo')).toBe('neateo') | ||
}) | ||
|
||
it('should strip the last slash', () => { | ||
expect(formatStatic('neateo/')).toBe('neateo') | ||
}) | ||
|
||
it('should ignore middle slashes', () => { | ||
expect(formatStatic('n/ea/teo')).toBe('n/ea/teo') | ||
}) | ||
|
||
it('should pass through no slashes', () => { | ||
expect(formatStatic('neateo')).toBe('neateo') | ||
}) | ||
}) | ||
|
||
describe('base path formatter', () => { | ||
it('should ignore properly formatted things', () => { | ||
expect(formatBase('/neateo/')).toBe('/neateo/') | ||
}) | ||
|
||
it('should add a slash at the beginning', () => { | ||
expect(formatBase('neateo/')).toBe('/neateo/') | ||
}) | ||
|
||
it('should add a slash at the end', () => { | ||
expect(formatBase('/neateo')).toBe('/neateo/') | ||
}) | ||
}) | ||
}) |
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,57 @@ | ||
module.exports = (() => { | ||
const GIT_SHA = | ||
process.env.INFLUXDB_SHA || | ||
require('child_process') | ||
.execSync('git rev-parse HEAD') | ||
.toString() | ||
|
||
// Webpack has some specific rules about formatting | ||
// lets protect our developers from that! | ||
function formatStatic(dir) { | ||
if (!dir.length) { | ||
return dir | ||
} | ||
|
||
// NOTE: slices for sideeffect free editing (alex) | ||
let _dir = dir.slice(0) | ||
|
||
if (_dir[0] === '/') { | ||
_dir = _dir.slice(1) | ||
} | ||
|
||
if (_dir[_dir.length - 1] === '/') { | ||
_dir = _dir.slice(0, -1) | ||
} | ||
|
||
return _dir | ||
} | ||
|
||
// Webpack has some specific rules about formatting | ||
// lets protect our developers from that! | ||
function formatBase(prefix) { | ||
if (prefix === '/') { | ||
return prefix | ||
} | ||
|
||
// NOTE: slices for sideeffect free editing (alex) | ||
let _prefix = prefix.slice(0) | ||
|
||
if (_prefix[0] !== '/') { | ||
_prefix = '/' + _prefix | ||
} | ||
|
||
if (_prefix[_prefix.length - 1] !== '/') { | ||
_prefix = _prefix + '/' | ||
} | ||
|
||
return _prefix | ||
} | ||
|
||
const STATIC_DIRECTORY = formatStatic(process.env.STATIC_DIRECTORY || '') | ||
const BASE_PATH = '/' | ||
// TODO: adding a basePath feature in the @influxdata/oats | ||
// project is currently required before turning this on (alex) | ||
//const BASE_PATH = formatBase(process.env.BASE_PATH || '/') | ||
|
||
return {formatStatic, formatBase, GIT_SHA, STATIC_DIRECTORY, BASE_PATH} | ||
})() |
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