Skip to content

Commit

Permalink
Merge pull request #16 from pragyakar/develop
Browse files Browse the repository at this point in the history
First Boilerplate Release
  • Loading branch information
pragyakar authored Feb 27, 2021
2 parents 1b4727f + d4fec26 commit 658505e
Show file tree
Hide file tree
Showing 46 changed files with 3,788 additions and 407 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ dist/
# node_modules
node_modules/

# testcoverage
coverage/

# yarn
yarn-error.log

Expand All @@ -15,4 +18,7 @@ yarn-error.log
.env.*

# other files
.DS_Store
.DS_Store

# coverage
coverage
9 changes: 8 additions & 1 deletion .sample.env
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
TEST=
DOMAIN=
AUDIENCE=
CLIENT_ID=
REDIRECT_URI=
RESPONSE_TYPE=
SCOPE=
BASE_URL=
TIMEOUT=
22 changes: 18 additions & 4 deletions env/dot-env.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
const dotEnv = require("dotenv");
const dotEnv = require('dotenv');

function getEnvConfig(environment) {
dotEnv.config({ path: `./.env.${environment}` });

if (
process.env.TEST
process.env.DOMAIN &&
process.env.AUDIENCE &&
process.env.CLIENT_ID &&
process.env.REDIRECT_URI &&
process.env.RESPONSE_TYPE &&
process.env.SCOPE &&
process.env.BASE_URL &&
process.env.TIMEOUT
) {
return {
TEST: process.env.TEST
DOMAIN: process.env.DOMAIN || '',
AUDIENCE: process.env.AUDIENCE,
CLIENT_ID: process.env.CLIENT_ID,
REDIRECT_URI: process.env.REDIRECT_URI,
RESPONSE_TYPE: process.env.RESPONSE_TYPE,
SCOPE: process.env.SCOPE,
BASE_URL: process.env.BASE_URL,
TIMEOUT: process.env.TIMEOUT
};
} else {
let errorMessage = `Cannot find .env.${environment} file or environment values are missing`;
Expand All @@ -17,4 +31,4 @@ function getEnvConfig(environment) {

module.exports = {
getEnvConfig
};
};
186 changes: 186 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html

module.exports = {
// All imported modules in your tests should be mocked automatically
// automock: false,

// Stop running tests after `n` failures
// bail: 0,

// Respect "browser" field in package.json when resolving modules
// browser: false,

// The directory where Jest should store its cached dependency information
// cacheDirectory: "/tmp/jest_rs",

// Automatically clear mock calls and instances between every test
clearMocks: true,

// Indicates whether the coverage information should be collected while executing the test
// collectCoverage: false,

// An array of glob patterns indicating a set of files for which coverage information should be collected
collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/**/*.d.ts'],

// The directory where Jest should output its coverage files
coverageDirectory: 'coverage',

// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "/node_modules/"
// ],

// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
// "json",
// "text",
// "lcov",
// "clover"
// ],

// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: undefined,

// A path to a custom dependency extractor
// dependencyExtractor: undefined,

// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,

// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],

// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: "<rootDir>/src/setupTests.js",

// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: undefined,

// A set of global variables that need to be available in all test environments
// globals: {},

// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
// maxWorkers: "50%",

// An array of directory names to be searched recursively up from the requiring module's location
moduleDirectories: ['node_modules', 'src'],

// An array of file extensions your modules use
moduleFileExtensions: [
'js',
'json',
'jsx',
'ts',
'tsx'
// "node"
],

// A map from regular expressions to module names that allow to stub out resources with a single module
moduleNameMapper: {
'^src/(.*)$': '<rootDir>/src/$1'
},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],

// Activates notifications for test results
// notify: false,

// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",

// A preset that is used as a base for Jest's configuration
preset: 'ts-jest',

// Run tests from one or more projects
// projects: undefined,

// Use this configuration option to add custom reporters to Jest
// reporters: undefined,

// Automatically reset mock state between every test
// resetMocks: false,

// Reset the module registry before running each individual test
// resetModules: false,

// A path to a custom resolver
// resolver: undefined,

// Automatically restore mock state between every test
// restoreMocks: false,

// The root directory that Jest should scan for tests and modules within
// rootDir: undefined,

// A list of paths to directories that Jest should use to search for files in
roots: ['<rootDir>/src'],

// Allows you to use a custom runner instead of Jest's default test runner
// runner: "jest-runner",

// The paths to modules that run some code to configure or set up the testing environment before each test
setupFiles: ['<rootDir>/src/setupTests.js']

// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],

// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],

// The test environment that will be used for testing
// testEnvironment: "jest-environment-jsdom",

// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},

// Adds a location field to test results
// testLocationInResults: false,

// The glob patterns Jest uses to detect test files
// testMatch: [
// "**/__tests__/**/*.[jt]s?(x)",
// "**/?(*.)+(spec|test).[tj]s?(x)"
// ],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],

// This option allows the use of a custom results processor
// testResultsProcessor: undefined,

// This option allows use of a custom test runner
// testRunner: "jasmine2",

// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
// testURL: "http://localhost",

// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
// timers: "real",

// A map from regular expressions to paths to transformers
// transform: undefined,

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/"
// ],

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,

// Indicates whether each individual test should be reported during the run
// verbose: undefined,

// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],

// Whether to use watchman for file crawling
// watchman: true,
};
25 changes: 22 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"create:production": "NODE_ENV=production PORT=9001 webpack -p",
"build:production": "run-s clean create:production",
"format": "prettier --write \"src/**/*.{ts, tsx, js}\"",
"clean": "rimraf dist"
"clean": "rimraf dist",
"test": "jest --watch",
"test:coverage": "jest --coverage"
},
"husky": {
"hooks": {
Expand All @@ -25,15 +27,26 @@
]
},
"devDependencies": {
"@types/enzyme": "^3.10.5",
"@types/enzyme-adapter-react-16": "^1.0.6",
"@types/jest": "^25.1.4",
"@types/react": "^16.9.21",
"@types/react-dom": "^16.9.5",
"@types/react-redux": "^7.1.7",
"@types/redux": "^3.6.0",
"@types/redux-saga": "^0.10.5",
"@types/uuid": "^7.0.2",
"compression-webpack-plugin": "^3.1.0",
"css-loader": "^3.4.2",
"dotenv": "^8.2.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"file-loader": "^5.1.0",
"html-webpack-plugin": "^3.2.0",
"husky": "^4.2.3",
"jest": "^25.1.0",
"jest-enzyme": "^7.1.2",
"lint-staged": "^10.0.7",
"node-sass": "^4.13.1",
"npm-run-all": "^4.1.5",
Expand All @@ -42,6 +55,7 @@
"sass-loader": "^8.0.2",
"serve": "^11.3.0",
"source-map-loader": "^0.2.4",
"ts-jest": "^25.2.1",
"ts-loader": "^6.2.1",
"tslint": "^6.0.0",
"tslint-loader": "^3.5.4",
Expand All @@ -54,9 +68,14 @@
"dependencies": {
"@types/auth0-js": "^9.12.4",
"@types/react-router-dom": "^5.1.3",
"auth0-js": "^9.12.2",
"auth0-js": "^9.13.2",
"axios": "^0.21.1",
"connected-react-router": "^6.8.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-router-dom": "^5.1.2"
"react-redux": "^7.2.0",
"react-router-dom": "^5.1.2",
"redux": "^4.0.5",
"redux-saga": "^1.1.3"
}
}
2 changes: 2 additions & 0 deletions src/@types/webpack-define-plugin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ interface IEnvConfig {
REDIRECT_URI: string;
RESPONSE_TYPE: string;
SCOPE: string;
BASE_URL: string;
TIMEOUT: string;
}
14 changes: 8 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import * as React from 'react';
import Login from './components/Login';
import Router from './Router';
import { Provider } from 'react-redux';

const App = () => {
import store from 'src/store';
import Router from 'src/Router';

const App: React.FC<{}> = () => {
return (
<>
<p>React Webpack BP</p>
<Login />
<Router />
<Provider store={store}>
<Router />
</Provider>
</>
);
};
Expand Down
14 changes: 8 additions & 6 deletions src/Router.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import * as React from 'react';
import { Route, Switch, BrowserRouter } from 'react-router-dom';
import { Route, Switch } from 'react-router-dom';
import { ConnectedRouter } from 'connected-react-router';

import * as routes from './constants/routes';
import Callback from './components/Callback';
import Dashboard from './components/Dashboard';
import history from 'src/utils/history';
import Callback from 'src/components/Callback';
import Dashboard from 'src/components/Dashboard';
import * as routes from 'src/constants/routes';

const Router = () => (
<BrowserRouter>
<ConnectedRouter history={history}>
<Switch>
<Route path={routes.DASHBOARD} component={Dashboard} />
<Route path={routes.CALLBACK} component={Callback} />
</Switch>
</BrowserRouter>
</ConnectedRouter>
);

export default Router;
4 changes: 4 additions & 0 deletions src/actionCreators/action.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface ActionCallbacks {
resolve?: Function;
reject?: Function;
}
13 changes: 13 additions & 0 deletions src/actionCreators/sample/sample.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as actions from 'src/constants/actions';
import { ActionCallbacks } from 'src/actionCreators/action';
import { IFillSampleActionPayload } from './sample';

export interface fetchSampleAction extends ActionCallbacks {
type: typeof actions.SAMPLE_ACTION;
payload: string;
}

export interface fillSampleAction extends ActionCallbacks {
type: typeof actions.FILL_SAMPLE_ACTION;
payload: IFillSampleActionPayload;
}
Loading

0 comments on commit 658505e

Please sign in to comment.