├── .babelrc ├── .eslintrc.json ├── .gitignore ├── .npmignore ├── .npmrc ├── .travis.yml ├── LICENSE.txt ├── README.md ├── config ├── env.js ├── jest.config.base.js ├── jest.config.preact.js ├── jest.polyfills.js ├── kit_exports.js ├── paths.js ├── polyfills.js ├── shims.js ├── styleguide.setup.js ├── test_helpers.js ├── webpack.config.dev.js ├── webpack.config.prod.js └── webpackDevServer.config.js ├── docs └── introduction.md ├── package.json ├── public ├── favicon.ico ├── index.html └── manifest.json ├── scripts ├── build.js ├── release.js ├── start.js └── test.js ├── src ├── components │ ├── AsciiTable │ │ ├── AsciiTable.js │ │ ├── AsciiTable.test.js │ │ ├── README.md │ │ ├── __snapshots__ │ │ │ └── AsciiTable.test.js.snap │ │ └── index.js │ ├── Chart │ │ ├── Chart.js │ │ ├── README.md │ │ ├── charts │ │ │ ├── Textual.jsx │ │ │ ├── circular │ │ │ │ └── RadialChart.jsx │ │ │ └── xy │ │ │ │ ├── AreaChart.jsx │ │ │ │ ├── BarChart.jsx │ │ │ │ └── LineChart.jsx │ │ ├── index.js │ │ ├── utils │ │ │ ├── chartHelpers.js │ │ │ ├── chartHelpers.test.js │ │ │ └── simpleMappers.js │ │ └── wrappers │ │ │ ├── ChartSwitch.jsx │ │ │ └── CypherChartWrapper.jsx │ ├── Cypher │ │ ├── Cypher.js │ │ ├── Cypher.test.js │ │ ├── README.md │ │ ├── __snapshots__ │ │ │ └── Cypher.test.js.snap │ │ └── index.js │ ├── DesktopIntegration │ │ ├── DesktopIntegration.js │ │ ├── DesktopIntegration.test.js │ │ ├── README.md │ │ ├── helpers.js │ │ ├── helpers.test.js │ │ └── index.js │ ├── DriverProvider │ │ ├── DriverProvider.js │ │ ├── DriverProvider.test.js │ │ ├── README.md │ │ ├── __snapshots__ │ │ │ └── DriverProvider.test.js.snap │ │ └── index.js │ ├── Editor │ │ ├── CypherEditor.js │ │ ├── README.md │ │ └── index.js │ ├── GraphAppBase │ │ ├── ConnectModal.jsx │ │ ├── GraphAppBase.js │ │ ├── GraphAppBase.test.js │ │ ├── README.md │ │ ├── __snapshots__ │ │ │ └── GraphAppBase.test.js.snap │ │ ├── helpers.js │ │ ├── helpers.test.js │ │ └── index.js │ └── Render │ │ ├── README.md │ │ ├── Render.js │ │ ├── Render.test.js │ │ ├── __snapshots__ │ │ └── Render.test.js.snap │ │ └── index.js ├── dev │ ├── Component.jsx │ ├── Component.test.jsx │ ├── __snapshots__ │ │ └── Component.test.jsx.snap │ └── index.js ├── index.js └── lib │ ├── boltTransforms.js │ ├── boltTransforms.test.js │ ├── utils.js │ └── utils.test.js ├── styleguide.config.js ├── test_package ├── preact │ ├── .babelrc │ ├── __snapshots__ │ │ └── preact.test.js.snap │ └── preact.test.js └── react │ ├── __snapshots__ │ └── package.test.js.snap │ └── package.test.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env", "react-app"], 3 | "ignore": ["dist/", "coverage/"], 4 | "plugins": ["babel-plugin-transform-object-rest-spread"] 5 | } 6 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["prettier", "react-app"], 3 | "plugins": ["prettier"], 4 | "rules": { 5 | "prettier/prettier": "error" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | dist/ 4 | 5 | # dependencies 6 | /node_modules 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | /styleguide 14 | 15 | # misc 16 | .DS_Store 17 | .env.local 18 | .env.development.local 19 | .env.test.local 20 | .env.production.local 21 | 22 | npm-debug.log* 23 | yarn-debug.log* 24 | yarn-error.log* 25 | 26 | .eslintrc.json 27 | .vscode 28 | bundle-report.html 29 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | config/ 2 | coverage/ 3 | scripts/ 4 | src/ 5 | .babelrc 6 | .travis.yml 7 | package-lock.json 8 | yarn.lock 9 | .npmrc 10 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://neo.jfrog.io/neo/api/npm/npm/ 2 | tag-version-prefix="" 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "8" 4 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2017 Neo4j, Inc. 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Graph App Kit 2 | 3 | Build Neo4j Graph Apps using components and utilities from this graph app kit. 4 | 5 | Browse source code and read README:s in sub directories for examples and docs. 6 | 7 | Check out the interactive [playground](https://styleguide-cqfmjsxkhp.now.sh) for 8 | a demo of the components. 9 | 10 | ## What's in here 11 | 12 | | Component | Description | 13 | | -------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | 14 | | [<AsciiTable>](https://github.com/neo4j-apps/graph-app-kit/tree/master/src/components/AsciiTable) | Render your data in an text/ascii table with fixed width font. | 15 | | [<Chart>](https://github.com/neo4j-apps/graph-app-kit/tree/master/src/components/Chart) | Render your data in a chart visualization. | 16 | | [<Cypher>](https://github.com/neo4j-apps/graph-app-kit/tree/master/src/components/Cypher) | A simple component to execute a Cypher query and return the result to your render function. | | 17 | | [<CypherEditor>](https://github.com/neo4j-apps/graph-app-kit/tree/master/src/components/Editor) | A cypher editor component with code highlighting and autocomplete functionality. | 18 | | [<DesktopIntegration>](https://github.com/neo4j-apps/graph-app-kit/tree/master/src/components/DesktopIntegration) | Easy integration for your app into the Neo4j Desktop API. Subscribe to events etc. | 19 | | [<DriverProvider>](https://github.com/neo4j-apps/graph-app-kit/tree/master/src/components/DriverProvider) | Provide your React application with a [`neo4j-driver`](https://github.com/neo4j/neo4j-javascript-driver) in application context. | 20 | | [<GraphAppBase>](https://github.com/neo4j-apps/graph-app-kit/tree/master/src/components/GraphAppBase) | A base component for apps to reduce the amount of boilerplate code for connection handling. Integrates the app with the Neo4j Desktop API and provides the application with a [`neo4j-driver`](https://github.com/neo4j/neo4j-javascript-driver) in application context. | 21 | | [<Render>](https://github.com/neo4j-apps/graph-app-kit/tree/master/src/components/Render) | A declarative toggling component to mount / unmount child components under certain conditions. | 22 | 23 | ## Install and import 24 | 25 | ```bash 26 | npm install graph-app-kit --registry https://neo.jfrog.io/neo/api/npm/npm 27 | // or 28 | yarn add graph-app-kit --registry https://neo.jfrog.io/neo/api/npm/npm 29 | ``` 30 | 31 | ```javascript 32 | import "semantic-ui-css/semantic.min.css"; 33 | import { Cypher } from "graph-app-kit/components/Cypher"; 34 | import { DriverProvider } from "graph-app-kit/components/DriverProvider"; 35 | import { Render } from "graph-app-kit/components/Render"; 36 | import { Chart } from "graph-app-kit/components/Chart"; 37 | import { CypherEditor } from "graph-app-kit/components/Editor"; 38 | ``` 39 | 40 | ## Component playground / library 41 | 42 | There's an interactive playground to view and modify the components.\ 43 | This is temporarily hosted at https://styleguide-cqfmjsxkhp.now.sh 44 | 45 | Feedback wanted! 46 | 47 | To use the playground when developing components: `yarn playground` and to 48 | generate a static version to deploy: `yarn playground:build` (the artifacts end 49 | up in `styleguide/`) 50 | 51 | ## Development mode 52 | 53 | ```bash 54 | git clone git@github.com:neo4j-apps/graph-app-kit.git graph-app-kit 55 | cd graph-app-kit 56 | yarn install 57 | ``` 58 | 59 | ### Dev environment setup 60 | 61 | The preferred way to develop new components is to either develop it directly in 62 | `src/dev/Component` or import there.\ 63 | To start dev server on http://localhost:3000/ (loads `src/dev/index.js` in webpack): 64 | `yarn start`\ 65 | To have continous testing (add tests to `src/dev/Component.test.js`): `yarn dev` 66 | 67 | ### Exposing components 68 | 69 | Here's a checklist for things to be done before opening a PR with a new 70 | component: 71 | 72 | 1. Restore `src/dev` to it's initial state. 73 | 1. Name the component file `ComponentName.js` and the test file 74 | `ComponentName.test.js`. 75 | 1. Export the component as a named export + a default export. Named for the kit 76 | users and default for placing it in the playground. 77 | 1. Add an `index.js` in the components directory, which just exports the named 78 | import. i.e. `export { ComponentName } from './ComponentName'`. 79 | 1. Execute `yarn test` and make sure the test coverage for the component is 80 | reasonable. 81 | 1. Add a `README.md` in the components directory where you showcase one (or 82 | more) example usages and instructions of the component. 83 | 1. Execute `yarn playground` to see it in action. Make sure it looks good and 84 | makes sense. 85 | 1. Add an import test for the component in `test_package/react/package.test.js` 86 | AND `test_package/preact/preact.test.js`. Execute `yarn test:package` and 87 | watch it fail. 88 | 1. Add the component to the file `conf/kit_exports.js`. Follow the named / path 89 | convention. 90 | 1. Execute `yarn test:package` again and watch it pass. 91 | 1. Open a PR and wait for praise. 92 | 93 | ### Linting 94 | 95 | ```bash 96 | yarn lint 97 | ``` 98 | 99 | ### Testing 100 | 101 | Single run: 102 | 103 | ``` 104 | yarn test 105 | // or for including production bundle tests 106 | yarn test:all 107 | ``` 108 | 109 | Continous testing (watch mode): 110 | 111 | ```bash 112 | yarn dev 113 | ``` 114 | -------------------------------------------------------------------------------- /config/env.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const fs = require('fs'); 4 | const path = require('path'); 5 | const paths = require('./paths'); 6 | 7 | // Make sure that including paths.js after env.js will read .env variables. 8 | delete require.cache[require.resolve('./paths')]; 9 | 10 | const NODE_ENV = process.env.NODE_ENV; 11 | if (!NODE_ENV) { 12 | throw new Error( 13 | 'The NODE_ENV environment variable is required but was not specified.' 14 | ); 15 | } 16 | 17 | // https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use 18 | var dotenvFiles = [ 19 | `${paths.dotenv}.${NODE_ENV}.local`, 20 | `${paths.dotenv}.${NODE_ENV}`, 21 | // Don't include `.env.local` for `test` environment 22 | // since normally you expect tests to produce the same 23 | // results for everyone 24 | NODE_ENV !== 'test' && `${paths.dotenv}.local`, 25 | paths.dotenv, 26 | ].filter(Boolean); 27 | 28 | // Load environment variables from .env* files. Suppress warnings using silent 29 | // if this file is missing. dotenv will never modify any environment variables 30 | // that have already been set. 31 | // https://github.com/motdotla/dotenv 32 | dotenvFiles.forEach(dotenvFile => { 33 | if (fs.existsSync(dotenvFile)) { 34 | require('dotenv').config({ 35 | path: dotenvFile, 36 | }); 37 | } 38 | }); 39 | 40 | // We support resolving modules according to `NODE_PATH`. 41 | // This lets you use absolute paths in imports inside large monorepos: 42 | // https://github.com/facebookincubator/create-react-app/issues/253. 43 | // It works similar to `NODE_PATH` in Node itself: 44 | // https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders 45 | // Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored. 46 | // Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims. 47 | // https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421 48 | // We also resolve them to make sure all tools using them work consistently. 49 | const appDirectory = fs.realpathSync(process.cwd()); 50 | process.env.NODE_PATH = (process.env.NODE_PATH || '') 51 | .split(path.delimiter) 52 | .filter(folder => folder && !path.isAbsolute(folder)) 53 | .map(folder => path.resolve(appDirectory, folder)) 54 | .join(path.delimiter); 55 | 56 | // Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be 57 | // injected into the application via DefinePlugin in Webpack configuration. 58 | const REACT_APP = /^REACT_APP_/i; 59 | 60 | function getClientEnvironment(publicUrl) { 61 | const raw = Object.keys(process.env) 62 | .filter(key => REACT_APP.test(key)) 63 | .reduce( 64 | (env, key) => { 65 | env[key] = process.env[key]; 66 | return env; 67 | }, 68 | { 69 | // Useful for determining whether we’re running in production mode. 70 | // Most importantly, it switches React into the correct mode. 71 | NODE_ENV: process.env.NODE_ENV || 'development', 72 | // Useful for resolving the correct path to static assets in `public`. 73 | // For example, . 74 | // This should only be used as an escape hatch. Normally you would put 75 | // images into the `src` and `import` them in code to get their paths. 76 | PUBLIC_URL: publicUrl, 77 | } 78 | ); 79 | // Stringify all values so we can feed into Webpack DefinePlugin 80 | const stringified = { 81 | 'process.env': Object.keys(raw).reduce((env, key) => { 82 | env[key] = JSON.stringify(raw[key]); 83 | return env; 84 | }, {}), 85 | }; 86 | 87 | return { raw, stringified }; 88 | } 89 | 90 | module.exports = getClientEnvironment; 91 | -------------------------------------------------------------------------------- /config/jest.config.base.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | rootDir: "../", 3 | collectCoverageFrom: ["src/**/*.{js,jsx}"], 4 | setupFiles: [ 5 | "/config/polyfills.js", 6 | "/config/jest.polyfills.js" 7 | ], 8 | testEnvironment: "node", 9 | transform: { 10 | "^.+\\.(js|jsx)$": "/node_modules/babel-jest" 11 | }, 12 | transformIgnorePatterns: ["[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"], 13 | moduleNameMapper: { 14 | "^react-native$": "react-native-web", 15 | "^graph-app-kit(.*)": "/src$1" 16 | }, 17 | moduleFileExtensions: ["web.js", "js", "json", "web.jsx", "jsx", "node"] 18 | }; 19 | -------------------------------------------------------------------------------- /config/jest.config.preact.js: -------------------------------------------------------------------------------- 1 | const base = require("./jest.config.base"); 2 | 3 | const out = Object.assign({}, base, { 4 | moduleNameMapper: Object.assign({}, base.moduleNameMapper, { 5 | "^react$": "preact-compat", 6 | "^react-dom$": "preact-compat" 7 | }), 8 | snapshotSerializers: ["preact-render-spy/snapshot"] 9 | }); 10 | 11 | module.exports = out; 12 | -------------------------------------------------------------------------------- /config/jest.polyfills.js: -------------------------------------------------------------------------------- 1 | global.document.body.createTextRange = jest.fn(() => ({ 2 | getBoundingClientRect: jest.fn(() => ({})), 3 | getClientRects: jest.fn(() => []) 4 | })); 5 | -------------------------------------------------------------------------------- /config/kit_exports.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const fs = require("fs"); 3 | 4 | // Make sure any symlinks in the project folder are resolved: 5 | // https://github.com/facebookincubator/create-react-app/issues/637 6 | const appDirectory = fs.realpathSync(process.cwd()); 7 | const resolveApp = relativePath => path.resolve(appDirectory, relativePath); 8 | 9 | module.exports = { 10 | "components/AsciiTable": resolveApp("src/components/AsciiTable"), 11 | "components/Chart": resolveApp("src/components/Chart"), 12 | "components/Render": resolveApp("src/components/Render"), 13 | "components/Cypher": resolveApp("src/components/Cypher"), 14 | "components/DesktopIntegration": resolveApp( 15 | "src/components/DesktopIntegration" 16 | ), 17 | "components/DriverProvider": resolveApp("src/components/DriverProvider"), 18 | "components/GraphAppBase": resolveApp("src/components/GraphAppBase"), 19 | "components/Editor": resolveApp("src/components/Editor"), 20 | "lib/utils": resolveApp("src/lib/utils"), 21 | "lib/boltTransforms": resolveApp("src/lib/boltTransforms") 22 | }; 23 | -------------------------------------------------------------------------------- /config/paths.js: -------------------------------------------------------------------------------- 1 | const kitExports = require("./kit_exports"); 2 | 3 | const path = require("path"); 4 | const fs = require("fs"); 5 | const url = require("url"); 6 | 7 | // Make sure any symlinks in the project folder are resolved: 8 | // https://github.com/facebookincubator/create-react-app/issues/637 9 | const appDirectory = fs.realpathSync(process.cwd()); 10 | const resolveApp = relativePath => path.resolve(appDirectory, relativePath); 11 | 12 | const envPublicUrl = process.env.PUBLIC_URL; 13 | 14 | function ensureSlash(path, needsSlash) { 15 | const hasSlash = path.endsWith("/"); 16 | if (hasSlash && !needsSlash) { 17 | return path.substr(path, path.length - 1); 18 | } else if (!hasSlash && needsSlash) { 19 | return `${path}/`; 20 | } else { 21 | return path; 22 | } 23 | } 24 | 25 | const getPublicUrl = appPackageJson => 26 | envPublicUrl || require(appPackageJson).homepage; 27 | 28 | // We use `PUBLIC_URL` environment variable or "homepage" field to infer 29 | // "public path" at which the app is served. 30 | // Webpack needs to know it to put the right