153 Commits

Author SHA1 Message Date
William Chargin
7ab3a74c3a
cli: add site subcommand (#1905)
Summary:
The `sourcecred site` command now sets up a static site for a cred
instance, which may be deployed to (e.g.) GitHub Pages or IPFS.

This implementation sets up a directory structure where the site is
contained in a `site/` subdirectory whose top-level entries are also
symbolically linked from the root of the instance. Thus:

```
my-instance/
    sourcecred.json
    config/
    output/
    site/
        index.html
        favicon.png
        static/
            static/js/...
    index.html -> site/index.html
    favicon.png -> site/favicon.png
    static -> site/static
```

The purpose of this is to enable the instance to be served directly as a
GitHub Pages site without the user having to navigate to a URL that
includes a `site/` path component.

It’s not a perfect solution. The top level of the instance is cluttered.
If we have any web pages other than the root directory, then they’ll
appear at top level, too. If we change the structure, we’ll need to
teach `sourcecred site` to clean up vestiges of old structures. We also
won’t be able to have any pages called `config` or `output` or `cache`
due to namespace collision. But we think that it’s at least a reasonable
stopgap, and doesn’t incur much conceptual overhead.

This isn’t tested or officially supported on Windows.

Paired with @decentralion.

Test Plan:
Run `yarn build` to build the frontend and backend, then `cd` into a
SourceCred instance and run `node "${OLDPWD}/bin/sourcecred.js site`.
Note that a `site/` directory is created, and when the static site is
served it works from either `site/` or the instance root. Note that this
all works when actually deployed to GitHub Pages as well.

wchargin-branch: cli-site
2020-06-27 23:21:56 -07:00
William Chargin
69e945ab23
build: create unified yarn build command (#1903)
Summary:
Previously, we used `backend` to build the backend and `build` to build
the frontend, which was a bit confusing. Now, `build:backend` and
`build:frontend` build the respective components, and `build` builds
both in parallel.

Test Plan:
Run `rm -r bin build` and then `yarn build`, and note that the `bin` and
`build` directories are recreated.

wchargin-branch: build-unified-cmd
2020-06-27 21:16:55 -07:00
William Chargin
652190eb2d
deps: add dev dependency on npm-run-all (#1902)
Summary:
We want this to run the frontend and backend builds in parallel.

wchargin-branch: deps-npm-run-all
2020-06-27 21:11:28 -07:00
Dandelion Mané
dcb7219cb8
Add a new Explorer UI for instanced cred (#1894)
This commit integrates a new version of the cred explorer, which is
compatible with the new instance-based cred. It combines some of the
benefits of the v1 explorer (shows cred source decomposition) and the v2
explorer (shows cred-over-time for users). It's still very basic, and it
lacks an important feature of both v1 and v2 in that it doesn't allow
recomputing cred scores with new weights.

Nonetheless, it's a big improvement over having no functional ui at all!

Test plan: Manually test with a real instance, e.g. via
`yarn start --instance $PATH`
2020-06-25 16:22:39 -07:00
William Chargin
222f4a0738
deps: upgrade flow-bin@^0.127.0 (#1881)
Summary:
One weird hack needs to be slightly amended; everything else still works
given recent changes to suppression comments.

Test Plan:
Running `yarn flow` passes as is, but fails if a suppression comment is
removed.

wchargin-branch: flow-v0.127.0
2020-06-21 21:39:32 -07:00
Dandelion Mané
e744b2bd4a
Remove build2 / start2 references (#1882)
Now that we're making the new UI the canonical one, we can remove
references to calling it `build2` or `start2`.

Test plan: `yarn start --instance $PATH` and `yarn build` both work.
`yarn test --full` passes.
2020-06-21 21:17:25 -07:00
Dandelion Mané
f25bc795c6
Fork the frontend to build towards cli2 compat (#1853)
The cli2 ("instance") system has a foundationally different assumption
about how the frontend works: rather than having a unified frontend that
abstracts over many separate SourceCred projects, we'll have a single
frontend entry per instance. This means we no longer need (for example)
to make project IDs available at build time.

Our frontend setup and server side rendering is pretty complex, so
rather than rebuild it from scratch, I'm going to fork it into an
independent copy and then change it to suit our needs.

To start here, I've duplicated the `src/homepage` directory into
`src/homepage2`, duplicated the webpack config to
`config/webpack.config.web2.js`, and duplicated the paths and
package.json scripts.

Test plan:
Run `yarn start2` and it will start an identical frontend, using the
duplicated directory. Run `yarn build2` and it will build a viable
frontend into the `build2` directory. `build2` is gitignored.
2020-06-17 18:44:34 -07:00
Robin van Boven
338ab3b016
Release: bump version to 0.5.0 (#1787)
See tracking issue #1679 for release notes.
2020-05-08 16:31:26 +02:00
Robin van Boven
a6d184ad23
Chore: upgrade flow-bin (#1786)
Versions >= v0.121.0 require more specific suppression comments.
See https://github.com/facebook/flow/releases/tag/v0.121.0

Closes #1711
2020-05-08 15:31:29 +02:00
Robin van Boven
b5fa5abb49
Chore: upgrade packages (#1785)
This includes packages that can be upgraded without making changes.

* Chore: minor version upgrades
* Chore: upgrade fs-extra
* Chore: upgrade chalk
* Chore: upgrade jest, babel-jest

Closes #1712
Closes #1734
2020-05-07 18:48:52 +02:00
William Chargin
c18244bf19
deps: upgrade better-sqlite3@^7.0.0 (#1769)
Summary:
Notably, this includes a Jest compatibility improvement:
<https://github.com/JoshuaWise/better-sqlite3/issues/162#issuecomment-619401380>

Test Plan:
Existing unit tests pass.

wchargin-branch: better-sqlite3-v7.0.0
2020-04-26 13:04:31 -07:00
greenkeeper[bot]
f362a2409a
Update file-loader to the latest version 🚀 (#1706)
* chore(package): update file-loader to version 6.0.0

* chore(package): update lockfile yarn.lock

Co-authored-by: greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com>
Co-authored-by: Dandelion Mané <decentralion@dandelion.io>
2020-04-14 21:58:05 -07:00
greenkeeper[bot]
d0a3327782
Update url-loader to the latest version 🚀 (#1707)
* chore(package): update url-loader to version 4.0.0

* chore(package): update lockfile yarn.lock

Co-authored-by: greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com>
2020-04-14 21:57:57 -07:00
William Chargin
eda3d19772 prettier: re-enable with new 2.0.1 formatting
Test Plan:
Running `yarn check-pretty` passes as is, and properly fails if a
formatting error is introduced.

wchargin-branch: prettier-2.0.1-reenable
2020-03-24 07:57:14 -07:00
William Chargin
ffc97fdc9c prettier: upgrade to 2.0.1
Summary:
Prettier 2.0.0 introduced some far-reaching formatting changes, so this
commit temporarily neutralizes `check-pretty`. Follow-up commits will
update all formatting and re-enable the package script.

Generated with `yarn add prettier@^2.0.1`.

Test Plan:
Running `yarn check-pretty` prints a bunch of files and then the
expected “Failures OK” message, exiting 0.

wchargin-branch: prettier-2.0.1-upgrade
2020-03-24 07:57:14 -07:00
Dandelion Mané
2397afc3d2
Add the grain/grain.js (#1696)
This commit adds a `grain/grain.js` module, which contains a type and
logic for representing Grain balances with 18 digits of precision. We
use the native BigInt type (and add the necessary babel plugin to
support it).

Unfortunately, Flow does not yet support BigInts (see
[facebook/flow#6639]). To hack around this, we lie to Flow, claiming
that BigInts are numbers, and we expect/suppress the flow errors
whenever we actually instantiate one. For example:

```js
// $ExpectFlowError
const myBigInt = 5n;
```

We can use the BigInt operators like `+`, `-`, `>` without flow errors,
since these actually exist on numbers too. However, flow will fail to
detect improper combinations of regular numbers and BigInts:

```js
// $ExpectFlowError
const x = 5n;
const y = x + 5;
// Uncaught TypeError: Cannot mix BigInt and other types
```

Since any improper mixing will result in a runtime error, these issues
will be easy to detect via unit tests.

In addition to adding the basic Grain type, I exported a `format`
function which will display Grain balances in a human readable way.
It supports arbitrary decimal precision, groups large amounts with comma
separators, handles negative numbers, and adds a suffix string.

The format method is thoroughly documented and tested. Thanks to @Beanow
for valuable feedback on its implementation.

Test plan: See included unit tests. `yarn test` passes.

[facebook/flow#6639]: https://github.com/facebook/flow/issues/6639
2020-03-14 12:31:02 -07:00
Robin van Boven
4ed96e9d39
Chore: update major versions that aren't breaking for us (#1694)
Pinning tmp, as it seems to have an undocumented breaking change or
regression in v0.1.0.
2020-03-08 00:43:59 +01:00
Robin van Boven
d0e1c23d4c
Chore: make all minor-version package upgrades (#1692)
Preparing for release #1679

Note: due to a regression, not upgrading eslint-plugin-react
See https://github.com/yannickcr/eslint-plugin-react/issues/2570

Also updated package.json to latest semver in-range versions.
Note, this changes all packages (other than eslint-plugin-react)
to ^x.x.x format.
2020-03-08 00:37:42 +01:00
Dandelion Mané
c298842788
chore(package): update flow-bin to version 0.120.1 (#1691)
Closes #1690

Co-authored-by: greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com>
2020-03-06 09:46:10 -08:00
greenkeeper[bot]
09739512ab
Update promise to the latest version 🚀 (#1688)
* fix(package): update promise to version 8.1.0

* chore(package): update lockfile yarn.lock
2020-03-02 11:37:10 -08:00
Dandelion Mané
660f607011
Greenkeeper/flow bin 0.119.1 (#1680)
* chore(package): update flow-bin to version 0.119.1

Closes #1678

* chore(package): update lockfile yarn.lock

Co-authored-by: greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com>
2020-02-28 18:54:41 -08:00
greenkeeper[bot]
57f66c50b6
Update better-sqlite3 to version 6.0.0 (#1677)
* fix(package): update better-sqlite3 to version 6.0.0

* chore(package): update lockfile yarn.lock

Co-authored-by: William Chargin <wchargin@gmail.com>
2020-02-27 21:45:02 -08:00
Robin van Boven
4a4c35bfdc
Initiatives: validate and read files from local directory (#1644)
Helper functions intended to be used in succession by `loadDirectory`.
Only `_validatePath` provides helfpul error messages. It's the caller's
responsiblity to do this first.

Introduces dependency `globby` for globbing with a Promises API.
2020-02-09 00:46:23 +01:00
greenkeeper[bot]
d6a2618e9e
Update flow-bin to the latest version 🚀 (#1645)
* chore(package): update flow-bin to version 0.118.0

* chore(package): update lockfile yarn.lock
2020-02-07 00:15:26 -08:00
greenkeeper[bot]
f22b6a539f
Update eslint-plugin-import to the latest version 🚀 (#1611)
* chore(package): update eslint-plugin-import to version 2.20.1

* chore(package): update lockfile yarn.lock
2020-02-03 12:56:12 -08:00
greenkeeper[bot]
3d3c8c92b3
Update flow-bin to the latest version 🚀 (#1600)
* chore(package): update flow-bin to version 0.117.0

* chore(package): update lockfile yarn.lock

* Fixup flow error

From the [Flow 0.117.0 release notes](https://github.com/facebook/flow/releases/tag/v0.117.0)
> Removed uses of Symbol from libdefs in favor of symbol.

Test plan: `yarn flow`

Co-authored-by: Dandelion Mané <decentralion@dandelion.io>
2020-01-28 18:28:16 -08:00
William Chargin
8ed0585bb6
api: extract browser-friendly build target (#1536)
Summary:
This re-packages the build for the internal APIs exposed under #1526 to
be more browser-friendly. Removing `target: "node"` (and adding an
explicit `globalObject: "this"` for best-effort cross-compatibility) is
the biggest change from the backend build; removing all the extra
loaders and static site generation is the biggest change from the
frontend build.

This build configuration is forked from `webpack.config.backend.js`.

Test Plan:
Run `yarn api`, then upload the contents of `dist/api.js` to an
Observable notebook and require it as an ES module. Verify that the
SourceCred APIs are exposed: e.g., `sourcecred.core.graph.Graph` should
be a valid constructor.

wchargin-branch: api-build
2020-01-09 21:27:37 -08:00
greenkeeper[bot]
e68f99bf00 Update jest-fetch-mock to the latest version 🚀 (#1494)
* chore(package): update jest-fetch-mock to version 3.0.0

* chore(package): update lockfile yarn.lock
2019-12-22 13:23:19 -06:00
greenkeeper[bot]
0aea1ff13b Update flow-bin to the latest version 🚀 (#1489)
* chore(package): update flow-bin to version 0.114.0

* chore(package): update lockfile yarn.lock
2019-12-16 14:34:16 -06:00
Robin van Boven
f35d7e088f
Chore: update packages & bugfix new versions (#1487)
* chore(package): yarn upgrade

Updates all packages within version range.

* Bugfix update stacktrace matching code

The stacktrace has changed, most likely due to
a babel plugin updating. It now seems based on
the name of the `handlingErrors` argument
instead of the variable name storing the
anonymous function.

* Bugfix update react-router patch version

By updating the react packages, warnings were
logged about unsafe componentWillMount usage.
These warnings tripped a unit test.
react-router was the cause of these, so this
update avoids getting the warnings.
2019-12-10 20:52:55 +01:00
greenkeeper[bot]
ef3e1d6c48 Update eslint-plugin-import to the latest version 🚀 (#1484)
* chore(package): update eslint-plugin-import to version 2.19.0

* chore(package): update lockfile yarn.lock
2019-12-09 15:19:42 +01:00
greenkeeper[bot]
7951d3adae Update file-loader to the latest version 🚀 (#1468)
* chore(package): update file-loader to version 5.0.2

Closes #1468

* chore(package): update lockfile yarn.lock
2019-12-09 15:07:58 +01:00
greenkeeper[bot]
13fa8e78a6 Update url-loader to the latest version 🚀 (#1470)
* chore(package): update url-loader to version 3.0.0

* chore(package): update lockfile yarn.lock
2019-12-09 14:57:52 +01:00
greenkeeper[bot]
c5d7d27459 Update flow-bin to the latest version 🚀 (#1476)
* chore(package): update flow-bin to version 0.113.0

* chore(package): update lockfile yarn.lock
2019-12-03 12:51:25 -06:00
greenkeeper[bot]
811d22aa61 Update eslint-plugin-flowtype to the latest version 🚀 (#1467)
* chore(package): update eslint-plugin-flowtype to version 4.5.0

* chore(package): update lockfile yarn.lock
2019-11-28 18:54:52 -06:00
greenkeeper[bot]
98c0bebeef Update flow-bin to the latest version 🚀 (#1449)
* chore(package): update flow-bin to version 0.112.0

* chore(package): update lockfile yarn.lock
2019-11-12 16:57:15 -08:00
greenkeeper[bot]
7b3b0f054d Update eslint-plugin-flowtype to the latest version 🚀 (#1447)
* chore(package): update eslint-plugin-flowtype to version 4.3.1

* chore(package): update lockfile yarn.lock
2019-11-12 16:55:34 -08:00
William Chargin
c07a3fe208
deps: upgrade prettier@1.19.1 (#1439)
Summary:
Most changes due to <https://github.com/prettier/prettier/pull/6694>.

Generated with `yarn add prettier@1.19.1 && yarn prettify`.

Test Plan:
Running `yarn test` suffices.

wchargin-branch: prettier-v1.19.1
2019-11-11 12:47:26 -08:00
William Chargin
ada9140663
Upgrade Flow to v0.111.0 (#1436)
Summary:
The Flow team fixed a lot of bugs related to object spreading recently.
Some of these enable us to simplify our code (`generateGraphqlFlowTypes`
and `mirror`). Some find new genuine errors. Others require suppressions
in place of a larger change.

Test Plan:
Running `yarn flow` now passes.

wchargin-branch: upgrade-flow-v0.111.0
2019-11-01 19:55:07 -07:00
greenkeeper[bot]
c560f508b1 Update flow-bin to the latest version 🚀 (#1421)
* chore(package): update flow-bin to version 0.110.0

* chore(package): update lockfile yarn.lock
2019-10-22 12:05:50 -06:00
greenkeeper[bot]
f725f7c47a Update dotenv to the latest version 🚀 (#1411)
* chore(package): update dotenv to version 8.2.0

* chore(package): update lockfile yarn.lock
2019-10-16 16:32:49 -07:00
Dandelion Mané
5e02a2caeb
Add logic for plucking hyperlinks from cooked html (#1403)
This commit adds a `parseLinks` method to a new module,
`plugins/discourse/references`. `parseLinks` allows us to extract the
hyperlinks from `<a>` tags in "cooked" html.

I added `htmlparser2` as a dependency to parse the html. There were a
lot of options to choose from; I chose htmlparser2 because it has a lot
of usage, reasonable performance, and suits our needs. We use this
dependency in a lightweight and local way, so we can always change it
later if needed.

One thing which was a bit odd: I wasn't able to import it using
`import`, and needed a `require` statement instead.

Test plan: Unit tests added; `yarn test` passes.

This is progress towards [Discourse reference and mention detection][1].

[1]: https://discourse.sourcecred.io/t/discourse-reference-mention-detection/270
2019-10-11 13:36:31 -06:00
greenkeeper[bot]
65edd01dcf Update eslint-plugin-react to the latest version 🚀 (#1400)
* chore(package): update eslint-plugin-react to version 7.16.0

* chore(package): update lockfile yarn.lock
2019-10-04 09:22:12 -06:00
greenkeeper[bot]
74e7508f11 chore(package): update dependencies (#1394) 2019-10-03 12:03:25 -06:00
Dandelion Mané
026d3dc705
Upgrade flow to v109 (#1395)
We need one tiny change in test code, where Flow (correctly) detects an
error. I've added an error suppression comment because it is truly a
Flow error, but is appropriate as we are testing an error condition.

Test plan: `yarn test`
2019-10-03 10:41:51 -06:00
William Chargin
e762d2b900
security: upgrade transitive eslint-utils to 1.4.2 (#1332)
Summary:
Upgrading past a security fix in that package. Generated by running
`yarn add eslint@^6.2.2 babel-eslint@^10.0.3`: `eslint` to update the
problematic transitive dependency, and `babel-eslint` to avoid
<https://github.com/eslint/eslint/issues/12117>.

Test Plan:
Running `yarn lint` yields no false positives, and does complain on true
positives. Running `yarn list --pattern eslint-utils` lists only v1.4.2.

wchargin-branch: eslint-utils-1.4.2
2019-08-28 07:51:41 -07:00
Dandelion Mané
012f19eb48
discourse fetch: add rate limiting (#1321)
This implements rate limiting to the Discourse fetch logic, so that we
can actually load nontrivial servers without getting a 529 failure.

We could have used retry; I thought it was more polite to actually limit
the rate at which we make requests. However, to avoid seeing 529s in
practice, I left a bit of a buffer: we make only 55 requests per minute,
although 60 would be allowed.

If we want to improve Discourse loading time, we could boost up to the
full 60 request/min, but add in retries. (Or we could switch to retries
entirely.)

Test plan: This logic is untested, however my full discourse-plugin
branch uses it to do full Discourse loads without issue.
2019-08-23 17:51:35 +02:00
Dandelion Mané
610ace0cff
chore(package): update webpack to version 4.39.2 (#1285) 2019-08-14 16:11:47 +02:00
Dandelion Mané
95b8974f6a
Make SourceCred a public package (#1284)
I'm mostly motivated by wanting to get greenkeeper lockfile
auto-updating working (see #1269) although this is also a first step
towards making SourceCred usable from NPM (#1232).

For now, see this as us making sure we claim the sourcecred package name
on npm (see: https://www.npmjs.com/package/sourcecred).

I also fixed the license spec so that it's valid SPDX.
2019-08-13 17:46:23 +02:00
greenkeeper[bot]
027de6d3f0 chore(package): update flow-bin to version 0.105.0 2019-08-13 17:03:50 +02:00