Skip to content

Commit

Permalink
Add Makefile, enable configuring NODES_DIR, use linked desci-models
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ar committed Jul 12, 2023
1 parent 66be9e9 commit 3db671c
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 42 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ yarn-error.log*
.npmrc

.idea

# contract symlinks
src/desci-contracts-*
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Override this location with env `NODES_DIR=../some/path`
NODES_DIR?=../nodes
NODES_ABS=$(realpath $(NODES_DIR))

.PHONY: build
build: .env install nodes

.PHONY: nodes
nodes:
$(MAKE) -C $(NODES_DIR) build
yarn link @desci-labs/desci-models

# Link contract artifacts to this project.
# -s symlink
# -f overwrite (so we can re-build against a different contract repo version)
# -T treat target as a file (otherwise it will nest in an existing dir link)
ln -sfT $(NODES_ABS)/desci-contracts/artifacts src/desci-contracts-artifacts
ln -sfT $(NODES_ABS)/desci-contracts/.openzeppelin src/desci-contracts-config


.PHONY: install
install:
yarn

.PHONY: clean
clean:
rm -rf node_modules
rm -rf build
# Unlinking desci-models (may fail if not present, that's okay)
yarn unlink @desci-labs/desci-models || true
# Clean up symlinks
rm -f src/desci-contracts-*

.PHONY: .env
.env:
cp --no-clobber .env.example .env || true

38 changes: 35 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,44 @@
# Quickstart
First, make sure you have set up the [nodes](https://github.com/desci-labs/nodes) repository and that its `./dockerDev.sh` script is running.

Then, run `yarn start` in this repository and visit http://localhost:3000.

_Note:_ `nodes-web` by default assumes `nodes` is in a sibling directory. See details on this in the [Building](#building) section

_Note:_ If running for the first time, you may have to wait until the `dockerDev.sh` script shows `desci_nodes_backend | Server running on port 5420`.

<br>

Login with your email (or `noreply@desci.com`) and input the verification code logged in the `dockerDev.sh` output:

```
yarn
yarn start
Simulating email to noreply@desci.com token: 123456
```

Note: Make sure you have the [nodes backend](https://github.com/desci-labs/nodes) running and cloned as a sibling to `nodes-web`. Standalone `nodes-web` configuration is not currently streamlined.
# Building
Run `yarn build` to build the project or `yarn start` to run the devserver.

The dependency on [`nodes`](https://github.com/desci-labs/nodes) (`desci-models` and `desci-contracts`) is managed by the [`Makefile`](./Makefile). Building this project will make sure the `nodes` repo is built as well, which may take a while the first time. The `@desci-labs/desci-models` package is linked to `node_modules` as part of the build process. This alone is not enough to actually _run_ the backend cluster; see the [nodes README.me](https://github.com/desci-labs/nodes/blob/develop/README.md) for details on doing that.

To reset the repository state, i.e. wiping dependencies, artifacts, and unlinking local packages:
```bash
make clean
```

## Configure `nodes` location
If building against a `nodes` repo that is not in a sibling directory, set the `NODES_DIR` environment variable. This can be done inline:
```bash
NODES_DIR=path/to/nodes yarn start
NODES_DIR=path/to/nodes make
```

...or by exporting the variable:
```bash
export NODES_DIR=path/to/nodes
yarn start
```

# Bundling
This project uses create-react-app and is not ejected. Webpack config is handled by [CRACO](https://github.com/gsoft-inc/craco).

This project uses [Webpack v5](https://webpack.js.org/migrate/5/) under the hood
Expand Down
69 changes: 33 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,43 @@
"version": "0.3.4",
"private": true,
"engine": "16.13.1",
"scripts": {
"analyze": "source-map-explorer 'build/static/js/*.js'",
"start": "make && REACT_APP_VERSION=$npm_package_version TAILWIND_MODE=watch craco start",
"build": "make && REACT_APP_VERSION=$npm_package_version GENERATE_SOURCEMAP=false craco build && yarn terser",
"test": "craco test",
"eject": "react-scripts eject",
"terser": "terser ./build/static/js/*.js -c -m --mangle-props regex=/_$/",
"tunnel": "./tunnel.sh",
"tunnel:stop": "./tunnelKill.sh"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"resolutions": {
"styled-components": "^5",
"webpack-dev-server": "4.6.0"
},
"dependencies": {
"@amplitude/analytics-browser": "^1.10.3",
"@coinbase/wallet-sdk": "^3.0.1",
"@craco/craco": "^6.4.3",
"@desci-labs/desci-models": "link:../nodes/desci-models",
"@desci-labs/desci-models": "^0.1.8",
"@emotion/css": "^11.10.0",
"@ethersproject/bignumber": "^5.4.2",
"@ethersproject/experimental": "^5.5.0",
Expand Down Expand Up @@ -150,41 +182,6 @@
"web-vitals": "^1.0.1",
"yup": "^1.0.2"
},
"resolutions": {
"styled-components": "^5",
"webpack-dev-server": "4.6.0"
},
"scripts": {
"analyze": "source-map-explorer 'build/static/js/*.js'",
"models:compile": "cd ../nodes/desci-models && yarn && yarn build && cd ../../nodes-web && rm node_modules/.yarn-integrity && yarn",
"contracts:compile": "cd ../nodes/desci-contracts && yarn && npx hardhat compile --network ganache && cd ../../nodes-web && rm node_modules/.yarn-integrity && yarn",
"start": "yarn models:compile && yarn contracts:compile && REACT_APP_VERSION=$npm_package_version TAILWIND_MODE=watch craco start",
"build": "yarn stub && yarn models:compile && yarn contracts:compile && REACT_APP_VERSION=$npm_package_version GENERATE_SOURCEMAP=false craco build && yarn terser",
"stub": "./stubContract.sh",
"test": "craco test",
"eject": "react-scripts eject",
"terser": "terser ./build/static/js/*.js -c -m --mangle-props regex=/_$/",
"tunnel": "./tunnel.sh",
"tunnel:stop": "./tunnelKill.sh"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@babel/core": "^7.17.5",
"@babel/plugin-transform-async-to-generator": "^7.16.8",
Expand Down
13 changes: 10 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1620,9 +1620,16 @@
dependencies:
postcss-value-parser "^4.2.0"

"@desci-labs/desci-models@link:../nodes/desci-models":
version "0.0.0"
uid ""
"@desci-labs/desci-models@^0.1.8":
version "0.1.9"
resolved "https://registry.yarnpkg.com/@desci-labs/desci-models/-/desci-models-0.1.9.tgz#0f999593de376b331bcbf58a5be115b5aad206a2"
integrity sha512-Zty8XSE0Eg/hCn2P9+6dQhiMi2tuWx3Nlu8O3ie3O5YId/ylV5i1cs7Ufzsfudnrvij6y7kFWS0R8I/CkyRJMw==
dependencies:
jsonld "^8.1.1"
schema-dts "^1.1.2"
typescript "^4.9.4"
util "^0.12.5"
zod "^3.20.2"

"@digitalbazaar/http-client@^3.2.0":
version "3.4.0"
Expand Down

0 comments on commit 3db671c

Please sign in to comment.