-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
10 changed files
with
767 additions
and
54 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,14 @@ | ||
# Configuration | ||
## Build | ||
Build support scripts. | ||
|
||
## cspell config | ||
The cspell config file(s) contain spelling configuration and include project specific terms. | ||
|
||
## Spandx config | ||
The Spandx config file(s) has multiple team and build dependencies. **Before relocating/moving this file(s) the appropriate teams should be informed.** | ||
|
||
[See CONTRIBUTING.md for up-to-date information](../CONTRIBUTING.md#spandx-config) | ||
|
||
## Testing | ||
Jest configuration setup and transform scripts. |
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,62 @@ | ||
const path = require('path'); | ||
const dotenv = require('dotenv'); | ||
const dotenvExpand = require('dotenv-expand'); | ||
|
||
/** | ||
* Setup, and access, a dotenv file and the related set of parameters. | ||
* | ||
* @param {string} filePath | ||
* @returns {void} | ||
*/ | ||
const setupDotenvFile = filePath => { | ||
const dotenvInitial = dotenv.config({ path: filePath }); | ||
dotenvExpand(dotenvInitial); | ||
}; | ||
|
||
/** | ||
* Setup and access local and specific dotenv file parameters. | ||
* | ||
* @param {object} params | ||
* @param {string} params.env | ||
* @param {string} params.relativePath | ||
* @param {string} params.dotenvNamePrefix | ||
* @param {boolean} params.setBuildDefaults | ||
*/ | ||
const setupDotenvFilesForEnv = ({ | ||
env, | ||
relativePath = path.resolve(__dirname, '..'), | ||
dotenvNamePrefix = 'BUILD', | ||
setBuildDefaults = true | ||
} = {}) => { | ||
if (env) { | ||
setupDotenvFile(path.resolve(relativePath, `.env.${env}.local`)); | ||
setupDotenvFile(path.resolve(relativePath, `.env.${env}`)); | ||
} | ||
|
||
setupDotenvFile(path.resolve(relativePath, '.env.local')); | ||
setupDotenvFile(path.resolve(relativePath, '.env')); | ||
|
||
if (setBuildDefaults) { | ||
const STATIC_DIR = process.env[`${dotenvNamePrefix}_STATIC_DIR`] || 'public'; | ||
const PUBLIC_PATH = process.env[`${dotenvNamePrefix}_PUBLIC_PATH`] || '/'; | ||
const SRC_DIR = path.resolve(relativePath, process.env[`${dotenvNamePrefix}_SRC_DIR`] || 'src'); | ||
const DIST_DIR = path.resolve(relativePath, process.env[`${dotenvNamePrefix}_DIST_DIR`] || 'dist'); | ||
const HOST = process.env[`${dotenvNamePrefix}_HOST`] || 'localhost'; | ||
const PORT = process.env[`${dotenvNamePrefix}_PORT`] || '3000'; | ||
const DEV_MODE = process.env[`${dotenvNamePrefix}_DEV_MODE`] || undefined; | ||
const OUTPUT_ONLY = process.env[`_${dotenvNamePrefix}_OUTPUT_ONLY`] === 'true'; | ||
|
||
process.env[`_${dotenvNamePrefix}_ENV`] = process.env.NODE_ENV; | ||
process.env[`_${dotenvNamePrefix}_STATIC_DIR`] = STATIC_DIR; | ||
process.env[`_${dotenvNamePrefix}_RELATIVE_DIRNAME`] = relativePath; | ||
process.env[`_${dotenvNamePrefix}_PUBLIC_PATH`] = PUBLIC_PATH; | ||
process.env[`_${dotenvNamePrefix}_SRC_DIR`] = SRC_DIR; | ||
process.env[`_${dotenvNamePrefix}_DIST_DIR`] = DIST_DIR; | ||
process.env[`_${dotenvNamePrefix}_HOST`] = HOST; | ||
process.env[`_${dotenvNamePrefix}_PORT`] = PORT; | ||
process.env[`_${dotenvNamePrefix}_OUTPUT_ONLY`] = OUTPUT_ONLY; | ||
process.env[`_${dotenvNamePrefix}_DEV_MODE`] = DEV_MODE; | ||
} | ||
}; | ||
|
||
module.exports = { setupDotenvFilesForEnv }; |
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,8 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
process(src, filename) { | ||
const assetFilename = JSON.stringify(path.basename(filename)); | ||
return `module.exports = ${assetFilename};`; | ||
} | ||
}; |
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,8 @@ | ||
module.exports = { | ||
process() { | ||
return 'module.exports = {};'; | ||
}, | ||
getCacheKey() { | ||
return 'cssTransform'; | ||
} | ||
}; |
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,48 @@ | ||
module.exports = { | ||
collectCoverageFrom: [ | ||
'src/**/*.{js,jsx}', | ||
'!src/**/.*/**', | ||
'!src/index.js', | ||
'!src/setupTests.js', | ||
'!src/components/app.js', | ||
'!src/components/**/index.js', | ||
'!src/common/index.js', | ||
'!src/redux/index.js', | ||
'!src/redux/store.js', | ||
'!src/redux/middleware/**', | ||
'!src/redux/actions/index.js', | ||
'!src/redux/common/index.js', | ||
'!src/redux/reducers/index.js', | ||
'!src/redux/selectors/index.js' | ||
], | ||
coverageThreshold: { | ||
global: { | ||
branches: 80, | ||
functions: 80, | ||
lines: 90, | ||
statements: 90 | ||
} | ||
}, | ||
moduleFileExtensions: ['web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', 'node'], | ||
moduleNameMapper: { | ||
'^react-native$': 'react-native-web', | ||
'^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy' | ||
}, | ||
modulePaths: [], | ||
resetMocks: true, | ||
roots: ['<rootDir>/src', '<rootDir>/tests'], | ||
setupFilesAfterEnv: ['<rootDir>/config/jest.setupTests.js'], | ||
snapshotSerializers: ['enzyme-to-json/serializer'], | ||
testMatch: ['<rootDir>/**/__tests__/**/*.{js,jsx,ts,tsx}', '<rootDir>/**/*.{spec,test}.{js,jsx,ts,tsx}'], | ||
testEnvironment: 'jsdom', | ||
transform: { | ||
'^.+\\.(js|jsx|ts|tsx)$': '<rootDir>/node_modules/babel-jest', | ||
'^.+\\.css$': '<rootDir>/config/jest.transform.style.js', | ||
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '<rootDir>/config/jest.transform.file.js' | ||
}, | ||
transformIgnorePatterns: [ | ||
'[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$', | ||
'^.+\\.module\\.(css|sass|scss)$' | ||
], | ||
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'] | ||
}; |
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
Oops, something went wrong.