Repository: brainhubeu/react-permissible
Branch: master
Commit: f9122aa4c945
Files: 55
Total size: 79.7 KB
Directory structure:
gitextract_wgril_c7/
├── .babelrc
├── .circleci/
│ └── config.yml
├── .editorconfig
├── .eslintignore
├── .eslintrc
├── .gitignore
├── .npmignore
├── .npmrc
├── LICENSE.md
├── README.md
├── docs/
│ ├── examples/
│ │ ├── callback.md
│ │ ├── oneMatch.md
│ │ ├── permissionsMatch.md
│ │ └── renderOtherwise.md
│ ├── getting-started/
│ │ ├── installation.md
│ │ └── overview.md
│ └── usage/
│ ├── basic.md
│ └── hoc.md
├── docs-www/
│ ├── .gitignore
│ ├── LICENSE
│ ├── README.md
│ ├── gatsby-config.js
│ ├── gatsby-docs-kit.yml
│ ├── package.json
│ ├── src/
│ │ ├── globalReferences.js
│ │ ├── layouts/
│ │ │ └── .gitkeep
│ │ ├── pages/
│ │ │ ├── 404.js
│ │ │ ├── landing.js
│ │ │ ├── landing.module.scss
│ │ │ └── variables.scss
│ │ └── templates/
│ │ └── .gitkeep
│ └── tools/
│ ├── deploy-github.sh
│ ├── seed/
│ │ └── example.md
│ └── seed.sh
├── lib/
│ └── react-permissible.js
├── package.json
├── renovate.json
├── src/
│ ├── components/
│ │ ├── permissible.js
│ │ └── permissibleRender.js
│ └── index.js
├── test/
│ ├── .eslintrc
│ ├── accessible.component.js
│ ├── permissible.test.js
│ └── permissibleRender.test.js
├── tools/
│ ├── build.js
│ └── testSetup.js
├── types/
│ ├── .eslintrc
│ ├── react-permissible.d.ts
│ └── tests/
│ ├── .gitignore
│ ├── .npmrc
│ ├── Permissible.test.tsx
│ ├── PermissibleRender.test.tsx
│ ├── package.json
│ └── tsconfig.json
└── webpack.config.prod.js
================================================
FILE CONTENTS
================================================
================================================
FILE: .babelrc
================================================
{
"presets": [
"env",
"react",
"stage-1"
],
"plugins": [
"transform-decorators-legacy"
],
"env": {
"production": {
"plugins": [
"transform-react-constant-elements",
"transform-react-remove-prop-types"
]
}
}
}
================================================
FILE: .circleci/config.yml
================================================
version: 2.1
executors:
node-executor:
docker:
- image: circleci/node:14.4.0
working_directory: ~/app
jobs:
check_branch_name:
docker:
- image: circleci/node:14.4.0
working_directory: ~/app
steps:
- run:
name: fail if the branch name does not start with a valid prefix
command: |
branch=$CIRCLE_BRANCH
if [[ "$branch" =~ ^(dependabot|fix|feature|breaking)/ || "$branch" == 'master' ]]
then
echo $branch is a valid name
else
echo $branch is not valid because the branch name must match '^(dependabot|fix|feature|breaking)/' or be master
exit 1
fi
build:
working_directory: ~/app
docker:
- image: circleci/node:14.4.0
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Install npm dependencies
command: npm install --production=false
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- node_modules
test:
executor: node-executor
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Install npm dependencies
command: npm install --production=false
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- node_modules
- run:
name: Test
command: npm run test:coverage:ci
- persist_to_workspace:
root: ~/app
paths:
- .git
- node_modules
- coverage
lint:
docker:
- image: circleci/node:14.4.0
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Install npm dependencies
command: npm install --production=false
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- node_modules
- run:
name: Lint
command: npm run lint
compile:
docker:
- image: circleci/node:14.4.0
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Install npm dependencies
command: npm install --production=false
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- node_modules
- run:
name: Compile
command: npm run build
publish_package:
executor: node-executor
steps:
- attach_workspace:
at: ~/app
- run: git checkout .
- run:
name: Generate coveralls config
command: "echo repo_token: $REPO_TOKEN > ./.coveralls.yml"
- run:
name: Upload coverage to coveralls
command: cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
- run:
name: configure GitHub user
command: |
git config --global user.email "devops@brainhub.pl"
git config --global user.name "DevOps Brainhub"
git remote -v
git remote remove origin
git remote add origin https://$GIT_TOKEN@github.com/brainhubeu/react-permissible
git remote -v
- run:
name: bump NPM version
command: |
branch=`git log --oneline | grep '[0-9a-f]\{6,40\} Merge pull request #[0-9]\+ from brainhubeu/' | head -1 | sed 's@.* from brainhubeu/@@g' || true`
echo branch=$branch
if [[ "$branch" =~ ^(dependabot)/ ]]; then
npm version patch -m "%s [ci skip]"
elif [[ "$branch" =~ ^(fix)/ ]]; then
npm version patch -m "%s [ci skip]"
elif [[ "$branch" =~ ^(feature)/ ]]; then
npm version minor -m "%s [ci skip]"
elif [[ "$branch" =~ ^(breaking)/ ]]; then
npm version major -m "%s [ci skip]"
else
echo $branch is not valid because the branch name must match '^(dependabot|fix|feature|breaking)/'
exit 1
fi
- run: git pull --no-edit origin $CIRCLE_BRANCH
- run: git push origin $CIRCLE_BRANCH
- run:
name: npm publish
command: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
npm publish
workflows:
version: 2
build_and_test:
jobs:
- check_branch_name
- build:
requires:
- check_branch_name
- test:
requires:
- build
- lint:
requires:
- build
- compile:
requires:
- build
- publish_package:
requires:
- test
- lint
- compile
filters:
branches:
only:
- master
================================================
FILE: .editorconfig
================================================
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
================================================
FILE: .eslintignore
================================================
/lib/**/*.js
================================================
FILE: .eslintrc
================================================
{
"root": true,
"extends": [
"brainhub"
],
"settings": {
"import/resolve": {
"moduleDirectory": ["node_modules", "src"]
}
}
}
================================================
FILE: .gitignore
================================================
dist
# Logs
logs
*.log*
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
reports
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
# IDEA/Webstorm project files
.idea
*.iml
#VSCode metadata
.vscode
# Mac files
.DS_Store
# Debug files
selenium-debug.log
.npm.debug
# Merge conflicts
*.orig
================================================
FILE: .npmignore
================================================
.babelrc
.circleci/
.coveralls.yml
.dockerignore
.editorconfig
.eslintignore
.eslintrc
.git/
.github/
.gitignore
.istanbul.yml
.npmignore
.npmrc
.nvmrc
Dockerfile.e2e
coverage/
cypress.json
docker-compose.e2e.yml
docs-www/
docs/
jest.config.js
jest.setup.js
renovate.json
test/
tools/
types/
webpack.config.prod.js
================================================
FILE: .npmrc
================================================
engine-strict=true
================================================
FILE: LICENSE.md
================================================
The MIT License (MIT)
Copyright (c) 2017-2020 [Brainhub](https://brainhub.eu/?utm_source=github)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
Making the permission management for React components easier.
Restricted component
); const PermissibleComponent = Permissible( RestrictedComponent, userPermissions, requiredPermissions, callbackFunction, oneperm, ); render() {You just hit a route that doesn't exist... the sadness.
Making the permission management for components easier.
0&&r(c)?e>1?F(c,e-1,r,n,o):u(o,c):n||(o[o.length]=c)}return o}function V(t){return!(!Q(t)||z(t))&&(H(t)||y(t)?_t:ut).test(U(t))}function D(t,e){var r=t.__data__;return W(e)?r["string"==typeof e?"string":"hash"]:r.map}function q(t,e){var r=p(t,e);return V(r)?r:void 0}function L(t){return xt(t)||J(t)||!!(Ot&&t&&t[Ot])}function W(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}function z(t){return!!dt&&dt in t}function U(t){if(null!=t){try{return ht.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Y(t,e){return t===e||t!==t&&e!==e}function J(t){return G(t)&&vt.call(t,"callee")&&(!gt.call(t,"callee")||bt.call(t)==rt)}function B(t){return null!=t&&K(t.length)&&!H(t)}function G(t){return X(t)&&B(t)}function H(t){var e=Q(t)?bt.call(t):"";return e==nt||e==ot}function K(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=et}function Q(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function X(t){return!!t&&"object"==typeof t}var Z=200,tt="__lodash_hash_undefined__",et=9007199254740991,rt="[object Arguments]",nt="[object Function]",ot="[object GeneratorFunction]",it=/[\\^$.*+?()[\]{}|]/g,ut=/^\[object .+?Constructor\]$/,at="object"==typeof e&&e&&e.Object===Object&&e,ct="object"==typeof self&&self&&self.Object===Object&&self,ft=at||ct||Function("return this")(),st=Array.prototype,lt=Function.prototype,pt=Object.prototype,yt=ft["__core-js_shared__"],dt=function(){var t=/[^.]+$/.exec(yt&&yt.keys&&yt.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),ht=lt.toString,vt=pt.hasOwnProperty,bt=pt.toString,_t=RegExp("^"+ht.call(vt).replace(it,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),mt=ft.Symbol,gt=pt.propertyIsEnumerable,wt=st.splice,Ot=mt?mt.isConcatSpreadable:void 0,jt=Math.max,Pt=q(ft,"Map"),Et=q(Object,"create");d.prototype.clear=h,d.prototype.delete=v,d.prototype.get=b,d.prototype.has=_,d.prototype.set=m,g.prototype.clear=w,g.prototype.delete=O,g.prototype.get=j,g.prototype.has=P,g.prototype.set=E,S.prototype.clear=x,S.prototype.delete=T,S.prototype.get=$,S.prototype.has=k,S.prototype.set=C,A.prototype.add=A.prototype.push=R,A.prototype.has=M;var St=function(t,e){return e=jt(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=jt(n.length-e,0),u=Array(i);++o1?e-1:0),n=1;n
{oneperm ? 'One of' : 'Whole set of'} {permission} is necessary to see this component.