2018-05-08 21:21:19 +00:00
|
|
|
// @flow
|
2018-02-18 16:13:29 +00:00
|
|
|
const path = require("path");
|
|
|
|
const fs = require("fs");
|
2018-02-17 21:28:47 +00:00
|
|
|
|
|
|
|
// Make sure any symlinks in the project folder are resolved:
|
|
|
|
// https://github.com/facebookincubator/create-react-app/issues/637
|
|
|
|
const appDirectory = fs.realpathSync(process.cwd());
|
2018-02-18 16:13:29 +00:00
|
|
|
const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath);
|
2018-02-17 21:28:47 +00:00
|
|
|
|
|
|
|
// config after eject: we're in ./config/
|
|
|
|
module.exports = {
|
2018-07-31 01:01:47 +00:00
|
|
|
root: appDirectory,
|
2018-02-18 16:13:29 +00:00
|
|
|
dotenv: resolveApp(".env"),
|
2018-08-10 20:15:49 +00:00
|
|
|
favicon: resolveApp("src/assets/logo/sourcecred_32.png"),
|
2018-02-18 16:13:29 +00:00
|
|
|
appBuild: resolveApp("build"),
|
2018-06-30 23:01:54 +00:00
|
|
|
appIndexJs: resolveApp("src/app/index.js"),
|
2018-07-21 06:19:40 +00:00
|
|
|
appServerSideRenderingIndexJs: resolveApp("src/app/server.js"),
|
2018-07-23 19:31:00 +00:00
|
|
|
appRouteData: resolveApp("src/app/routeData.js"),
|
2018-02-18 16:13:29 +00:00
|
|
|
appPackageJson: resolveApp("package.json"),
|
|
|
|
appSrc: resolveApp("src"),
|
|
|
|
yarnLockFile: resolveApp("yarn.lock"),
|
|
|
|
appNodeModules: resolveApp("node_modules"),
|
2018-03-19 05:43:23 +00:00
|
|
|
|
|
|
|
backendBuild: resolveApp("bin"),
|
|
|
|
// This object should have one key-value pair per entry point. For
|
|
|
|
// each key, the value should be the path to the entry point for the
|
|
|
|
// source file, and the key will be the filename of the bundled entry
|
|
|
|
// point within the build directory.
|
|
|
|
backendEntryPoints: {
|
2018-09-02 23:11:56 +00:00
|
|
|
sourcecred: resolveApp("src/cli/main.js"),
|
2018-06-29 19:12:37 +00:00
|
|
|
//
|
2018-06-30 23:01:54 +00:00
|
|
|
fetchAndPrintGithubRepo: resolveApp(
|
|
|
|
"src/plugins/github/bin/fetchAndPrintGithubRepo.js"
|
2018-06-12 01:57:37 +00:00
|
|
|
),
|
2018-06-30 23:01:54 +00:00
|
|
|
createExampleRepo: resolveApp("src/plugins/git/bin/createExampleRepo.js"),
|
mirror: add an end-to-end `update` function (#909)
Summary:
This completes the minimum viable public API for the `Mirror` class. As
described on the docstring, the typical workflow for a client is:
- Invoke the constructor to acquire a `Mirror` instance.
- Invoke `registerObject` to register a root object of interest.
- Invoke `update` to update all transitive dependencies.
- Invoke `extract` to retrieve the data in structured form.
It is the third step that is added in this commit.
In this commit, we also include a command-line demo of the Mirror
module, which exercises exactly the workflow above with a hard-coded
GitHub schema. This can be used to test the module’s behavior with
real-world data. I plan to remove this entry point once we integrate
this module into SourceCred.
This commit makes progress toward #622.
Test Plan:
Unit tests included for the core functionality. The imperative shell
does not have automated tests. You can test it as follows.
First, run `yarn backend` to build `bin/mirror.js`. Then, run:
```shell
$ node bin/mirror.js /tmp/mirror-demo.db \
> Repository MDEwOlJlcG9zaXRvcnkxMjMyNTUwMDY= \
> 60
```
Here, the big base64 string is the ID for the sourcecred/example-github
repository. (This is listed in `graphql/demo.js`, alongside the ID for
the SourceCred repository itself.) The value 60 is a TTL in seconds. The
database filename is arbitrary.
This will print out a ton of output to stderr (all intermediate queries
and responses, for debugging purposes), and then the full contents of
the example repository to stdout.
Run the command again, and it should finish instantly. On my machine,
the main function runs faster than the Node startup time (50ms vs 60ms).
Then, re-run the command, changing the TTL from `60` to `1`. Note that
it sends off some queries and then prints the same repository.
It is safe to kill the program at any time, either while waiting for a
response from GitHub or while processing the results, because the mirror
module takes advantage of SQLite’s transaction-safety. Intermediate
updates will be persisted, so you’ll lose just a few seconds of
progress.
You can also of course dive into the generated database yourself to
explore the data. It’s good fun.
wchargin-branch: mirror-e2e-update
2018-10-03 04:06:01 +00:00
|
|
|
mirror: resolveApp("src/graphql/demo.js"),
|
2018-03-19 05:43:23 +00:00
|
|
|
},
|
2018-02-17 21:28:47 +00:00
|
|
|
};
|