forked from AccelByte/justice-js-common-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b19dee4
commit bd077cb
Showing
24 changed files
with
7,906 additions
and
1 deletion.
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,15 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
max_line_length = 80 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
max_line_length = 0 | ||
trim_trailing_whitespace = false |
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,12 @@ | ||
node_modules | ||
build | ||
test | ||
src/**.js | ||
.idea/* | ||
.Trash-0 | ||
|
||
coverage | ||
.nyc_output | ||
*.log | ||
|
||
package-lock.json |
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,14 @@ | ||
src | ||
test | ||
tsconfig.json | ||
tsconfig.module.json | ||
tslint.json | ||
.travis.yml | ||
.github | ||
.prettierignore | ||
.vscode | ||
build/docs | ||
**/*.spec.* | ||
coverage | ||
.nyc_output | ||
*.log |
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,2 @@ | ||
# package.json is formatted by package managers, so we ignore it here | ||
package.json |
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,11 @@ | ||
{ | ||
"singleQuote": false, | ||
"arrowParens": "always", | ||
"jsxSingleQuote": false, | ||
"jsxBracketSameLine": false, | ||
"bracketSpacing": true, | ||
"semi": true, | ||
"trailingComma": "es5", | ||
"printWidth": 120, | ||
"proseWrap": "never" | ||
} |
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,9 @@ | ||
# Copyright (c) 2018-2019 AccelByte Inc. All Rights Reserved. | ||
# This is licensed software from AccelByte Inc, for limitations | ||
# and restrictions contact your company contract manager. | ||
|
||
FROM accelbyte/node:10.14.1-alpine3.8 as builder | ||
RUN apk update && \ | ||
apk add \ | ||
yarn bash | ||
|
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,3 @@ | ||
// Copyright (c) 2018-2019 AccelByte Inc. All Rights Reserved. | ||
// This is licensed software from AccelByte Inc, for limitations | ||
// and restrictions contact your company contract manager. |
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,45 @@ | ||
# Copyright (c) 2018-2019 AccelByte Inc. All Rights Reserved. | ||
# This is licensed software from AccelByte Inc, for limitations | ||
# and restrictions contact your company contract manager. | ||
|
||
ifeq ($(CUSTOMER),) | ||
SERVICE=justice-js-common-utils | ||
else | ||
SERVICE=$(CUSTOMER)-justice-js-common-utils | ||
endif | ||
|
||
SERVICE_PATH=$(SERVICE) | ||
BUILDER_IMAGE=$(SERVICE)-builder | ||
REVISION_ID?=unknown | ||
export SONARQUBE?=false | ||
|
||
RUN=docker run --rm \ | ||
-v $(CURDIR):/workspace/$(SERVICE_PATH) \ | ||
-w /workspace/$(SERVICE_PATH) | ||
|
||
.PHONY: build test | ||
|
||
build: | ||
docker build --target builder --tag="$(BUILDER_IMAGE)" . | ||
$(RUN) $(BUILDER_IMAGE) yarn install | ||
$(RUN) $(BUILDER_IMAGE) yarn build | ||
|
||
publish: | ||
$(RUN) $(BUILDER_IMAGE) yarn install | ||
$(RUN) $(BUILDER_IMAGE) yarn build | ||
$(RUN) $(BUILDER_IMAGE) yarn run prepare-release | ||
$(RUN) $(BUILDER_IMAGE) npm publish | ||
|
||
clean: | ||
$(RUN) $(BUILDER_IMAGE) yarn run clean | ||
-$(RUN) --user=root $(BUILDER_IMAGE) rm -rf node_modules | ||
-$(RUN) --user=root $(BUILDER_IMAGE) rm -rf build | ||
-docker rmi -f $(BUILDER_IMAGE) $(SERVICE):$(REVISION_ID) | ||
|
||
rebuild: | ||
$(RUN) $(BUILDER_IMAGE) yarn install | ||
$(RUN) $(BUILDER_IMAGE) npm rebuild --update-binary | ||
|
||
test: | ||
$(RUN) $(BUILDER_IMAGE) yarn test | ||
|
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,2 +1,28 @@ | ||
# justice-input-validation-javascript | ||
# Justice JS Common Utils | ||
|
||
## Overview | ||
|
||
Justice JS Common Utils | ||
|
||
## High Level Features | ||
|
||
- Common javascript utilities for Justice Platform | ||
- Fully containerized development | ||
|
||
## Quick Start | ||
|
||
run `make build`, to build the project | ||
run `make publish`, to publish the project | ||
|
||
## Build Requirements | ||
|
||
- Docker with support for Linux containers | ||
- GNU Make | ||
- Internet connection | ||
|
||
## Development Requirements | ||
|
||
- See _Build Requirements_ | ||
- Docker Compose | ||
- IDE (we like WebStorm) | ||
|
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,84 @@ | ||
/* | ||
* Copyright (c) 2018-2019 AccelByte Inc. All Rights Reserved | ||
* This is licensed software from AccelByte Inc, for limitations | ||
* and restrictions contact your company contract manager. | ||
*/ | ||
|
||
const chalk = require("chalk"); | ||
const paths = require("./paths"); | ||
|
||
module.exports = (resolve, rootDir) => { | ||
console.log(rootDir); | ||
const config = { | ||
collectCoverageFrom: [ | ||
"<rootDir>/src/**/*.{ts,tsx}", | ||
"!<rootDir>/src/**/*.d.{ts,tsx}", | ||
"!**/node_modules/**", | ||
], | ||
testMatch: ["<rootDir>/src/**/__tests__/**/*.{ts,tsx}", "<rootDir>/src/**/?(*.)(spec|test).{ts,tsx}"], | ||
testEnvironment: "jsdom", | ||
transformIgnorePatterns: ["[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$"], | ||
moduleNameMapper: { | ||
"^react-native$": "react-native-web", | ||
"src/(.*)": "<rootDir>/src/$1", | ||
}, | ||
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "web.js", "mjs", "json", "web.jsx", "node"], | ||
setupFiles: ["<rootDir>/config/polyfills.js"], | ||
transform: { | ||
"^.+\\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest", | ||
}, | ||
globals: { | ||
"ts-jest": { | ||
diagnostics: { | ||
pathRegex: /\.test\.tsx?$/, | ||
}, | ||
}, | ||
}, | ||
}; | ||
if (rootDir) { | ||
config.rootDir = rootDir; | ||
} | ||
const overrides = Object.assign({}, require(paths.appPackageJson).jest); | ||
const supportedKeys = [ | ||
"collectCoverageFrom", | ||
"coverageReporters", | ||
"coverageThreshold", | ||
"mapCoverage", | ||
"moduleFileExtensions", | ||
"moduleNameMapper", | ||
"modulePaths", | ||
"snapshotSerializers", | ||
"setupFiles", | ||
"testMatch", | ||
"testEnvironmentOptions", | ||
"testResultsProcessor", | ||
"testPathIgnorePatterns", | ||
"transform", | ||
"transformIgnorePatterns", | ||
"setupFilesAfterEnv", | ||
]; | ||
if (overrides) { | ||
supportedKeys.forEach((key) => { | ||
if (overrides.hasOwnProperty(key)) { | ||
config[key] = overrides[key]; | ||
delete overrides[key]; | ||
} | ||
}); | ||
const unsupportedKeys = Object.keys(overrides); | ||
if (unsupportedKeys.length) { | ||
console.error( | ||
chalk.red( | ||
"Out of the box, Razzle only supports overriding " + | ||
"these Jest options:\n\n" + | ||
supportedKeys.map((key) => chalk.bold(" \u2022 " + key)).join("\n") + | ||
".\n\n" + | ||
"These options in your package.json Jest configuration " + | ||
"are not currently supported by Razzle:\n\n" + | ||
unsupportedKeys.map((key) => chalk.bold(" \u2022 " + key)).join("\n") | ||
) | ||
); | ||
process.exit(1); | ||
} | ||
} | ||
return config; | ||
}; |
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,14 @@ | ||
/* | ||
* Copyright (c) 2018-2019 AccelByte Inc. All Rights Reserved | ||
* This is licensed software from AccelByte Inc, for limitations | ||
* and restrictions contact your company contract manager. | ||
*/ | ||
|
||
const path = require("path"); | ||
const paths = require("./paths"); | ||
const createJestConfig = require("./createJestConfig"); | ||
|
||
module.exports = createJestConfig( | ||
(relativePath) => path.resolve(__dirname, "..", relativePath), | ||
path.resolve(paths.appSrc, "..") | ||
); |
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,76 @@ | ||
"use strict"; | ||
|
||
const path = require("path"); | ||
const fs = require("fs"); | ||
const url = require("url"); | ||
|
||
// Make sure any symlinks in the project folder are resolved: | ||
// https://github.com/facebook/create-react-app/issues/637 | ||
const appDirectory = fs.realpathSync(process.cwd()); | ||
const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath); | ||
|
||
const envPublicUrl = process.env.PUBLIC_URL; | ||
|
||
function ensureSlash(inputPath, needsSlash) { | ||
const hasSlash = inputPath.endsWith("/"); | ||
if (hasSlash && !needsSlash) { | ||
return inputPath.substr(0, inputPath.length - 1); | ||
} else if (!hasSlash && needsSlash) { | ||
return `${inputPath}/`; | ||
} else { | ||
return inputPath; | ||
} | ||
} | ||
|
||
const getPublicUrl = (appPackageJson) => envPublicUrl || require(appPackageJson).homepage; | ||
|
||
// We use `PUBLIC_URL` environment variable or "homepage" field to infer | ||
// "public path" at which the app is served. | ||
// Webpack needs to know it to put the right <script> hrefs into HTML even in | ||
// single-page apps that may serve index.html for nested URLs like /todos/42. | ||
// We can't use a relative path in HTML because we don't want to load something | ||
// like /todos/42/static/js/bundle.7289d.js. We have to know the root. | ||
function getServedPath(appPackageJson) { | ||
const publicUrl = getPublicUrl(appPackageJson); | ||
const servedUrl = envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : "/"); | ||
return ensureSlash(servedUrl, true); | ||
} | ||
|
||
const moduleFileExtensions = [ | ||
"web.mjs", | ||
"mjs", | ||
"web.js", | ||
"js", | ||
"web.ts", | ||
"ts", | ||
"web.tsx", | ||
"tsx", | ||
"json", | ||
"web.jsx", | ||
"jsx", | ||
]; | ||
|
||
// Resolve file paths in the same order as webpack | ||
const resolveModule = (resolveFn, filePath) => { | ||
const extension = moduleFileExtensions.find((extension) => fs.existsSync(resolveFn(`${filePath}.${extension}`))); | ||
|
||
if (extension) { | ||
return resolveFn(`${filePath}.${extension}`); | ||
} | ||
|
||
return resolveFn(`${filePath}.js`); | ||
}; | ||
|
||
// config after eject: we're in ./config/ | ||
module.exports = { | ||
appBuild: resolveApp("dist"), | ||
appPackageJson: resolveApp("package.json"), | ||
appVersionJson: resolveApp("version.json"), | ||
changelog: resolveApp("CHANGELOG.md"), | ||
appSrc: resolveApp("packages"), | ||
appTsConfig: resolveApp("tsconfig.json"), | ||
yarnLockFile: resolveApp("yarn.lock"), | ||
appNodeModules: resolveApp("node_modules"), | ||
}; | ||
|
||
module.exports.moduleFileExtensions = moduleFileExtensions; |
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,22 @@ | ||
"use strict"; | ||
|
||
if (typeof Promise === "undefined") { | ||
// Rejection tracking prevents a common issue where React gets into an | ||
// inconsistent state due to an error, but it gets swallowed by a Promise, | ||
// and the user has no idea what causes React's erratic future behavior. | ||
require("promise/lib/rejection-tracking").enable(); | ||
window.Promise = require("promise/lib/es6-extensions.js"); | ||
} | ||
|
||
// fetch() polyfill for making API calls. | ||
require("whatwg-fetch"); | ||
|
||
// Object.assign() is commonly used with React. | ||
// It will use the native implementation if it's present and isn't buggy. | ||
Object.assign = require("object-assign"); | ||
|
||
// In tests, polyfill requestAnimationFrame since jsdom doesn't provide it yet. | ||
// We don't polyfill it in the browser--this is user's responsibility. | ||
if (process.env.NODE_ENV === "test") { | ||
require("raf").polyfill(global); | ||
} |
Oops, something went wrong.