Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: single top level dev .env file and quicker quickstart #1021

Merged
merged 5 commits into from
Feb 28, 2022

Conversation

olizilla
Copy link
Contributor

@olizilla olizilla commented Feb 21, 2022

Use a single top level .env flle to set all dev env vars. With this PR getting started with the api and website is just

  • create a magic.link account
  • copy .env.tpl to .env in the monorepo root and fill out the magic link keys
  • npm i
  • npm start

and you'll be off to the races with the api and website 🏇 💨 ✨

This PR includes:

  • create a new .env.tpl template that aggregates all the module env needs.
  • add top level npm start task to run the api and the website, for a quicker quickstart.
  • remove old FAUNA logic from pinpin so we don't have to set the DATABASE var any more.
  • Updated README's

TODO:

  • warn people that they need to copy the env template and fill out their magic link keys, and maybe copy their SALT over.
  • fix it so that the api start command does't fail if you are already running the cluster and db containers.

License: (Apache-2.0 AND MIT)
Signed-off-by: Oli Evans [email protected]

use a single top level .env flle to set all dev env vars.

- remove old FAUNA logic from pinpin so we don't have to set the DATABASE var any more.
- add top level `npm start` task to run the api and the website, for a quicker quickstart.
- Update README's

License: (Apache-2.0 AND MIT)
Signed-off-by: Oli Evans <[email protected]>
@olizilla
Copy link
Contributor Author

one command to bind them

❯ npm start                                                                                                   16:02:01

> [email protected] start
> npm-run-all --print-label -p web api

[web] 
[web] > [email protected] web
[web] > npm start -w packages/website
[web] 
[api] 
[api] > [email protected] api
[api] > npm start -w packages/api
[api] 
[web] 
[web] > @web3-storage/[email protected] start
[web] > env-cmd -f ../../.env next dev -p 4000
[web] 
[api] 
[api] > @web3-storage/[email protected] start
[api] > npm-run-all -p cluster:start pg:start -s miniflare
[api] 
[web] ready - started server on 0.0.0.0:4000, url: http://localhost:4000
[web] info  - Loaded env from /Users/oli/Code/web3-storage/web3.storage/packages/website/.env.local
[web] info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
[api] 
[api] > @web3-storage/[email protected] cluster:start
[api] > web3-storage-tools cluster --start
[api] 
[api] 
[api] > @web3-storage/[email protected] pg:start
[api] > cd ../db && npm start
[api] 
[api] 
[api] > @web3-storage/[email protected] start
[api] > node scripts/cli.js db --start --project web3-storage
[api] 
[web] Defining routes from exportPathMap
[web] event - compiled successfully
[api] 
[api] > @web3-storage/[email protected] miniflare
[api] > miniflare --env ../../.env --watch
[api] 
[api] 
[api] > @web3-storage/[email protected] build
[api] > node scripts/cli.js build
[api] 
[api] ▲ [WARNING] Non-relative path "packages/blob/src/lib.js" is not allowed when "baseUrl" is not set (did you forget a leading "./"?)
[api] 
[api]     ../../node_modules/ipfs-car/node_modules/@web-std/blob/tsconfig.json:6:24:
[api]       6 │       "@web-std/blob": ["packages/blob/src/lib.js"]
[api]         ╵                         ~~~~~~~~~~~~~~~~~~~~~~~~~~
[api] 
[api] [mf:inf] Build succeeded
[api] [mf:inf] Worker reloaded! (2.15MiB)
[api] [mf:wrn] Worker's uncompressed size exceeds the 1MiB limit! Note that your worker will be compressed during upload so you may still be able to deploy it.
[api] [mf:inf] Listening on :8787
[api] [mf:inf] - http://127.0.0.1:8787
[api] [mf:inf] - http://192.168.1.26:8787

@hugomrdias hugomrdias self-requested a review February 21, 2022 16:39
just assume that the thing is running if its port is reachable and skip trying to start it.

this allows us to kill and re-start our top level `npm start` without error.

License: (Apache-2.0 AND MIT)
Signed-off-by: Oli Evans <[email protected]>
@olizilla
Copy link
Contributor Author

cron pins still blends

❯ DEBUG="*" npm run start:pins -w packages/cron

> @web3-storage/[email protected] start:pins
> node src/bin/pins.js

  pins:updatePinStatuses 📥 Processing 0 -> 2 +0ms
  pins:updatePinStatuses ⏳ bafkreiabltrd5zm73pvi7plq25pef3hm7jxhbi3kv4hapegrkfpkqtkbme: Checking status... +1ms
  pins:updatePinStatuses ⏳ bafybeidmahqfk7jthbnaspso6skywa7fcqokswrxiw22nzjgnebqkqmrqy: Checking status... +3ms
  pins:updatePinStatuses 📌 bafybeidmahqfk7jthbnaspso6skywa7fcqokswrxiw22nzjgnebqkqmrqy@12D3KooWEuBKsspmFCi9Bpub7LX21NC4YJh8QoZZsqveuxPXubQU: Pinning => Pinned +12ms
  pins:updatePinStatuses 📌 bafkreiabltrd5zm73pvi7plq25pef3hm7jxhbi3kv4hapegrkfpkqtkbme@12D3KooWEuBKsspmFCi9Bpub7LX21NC4YJh8QoZZsqveuxPXubQU: Pinning => Pinned +1ms
  pins:updatePinStatuses ⏳ Updating 2 pins... +0ms
  pins:updatePinStatuses ✅ Updated 2 pins... +10ms
  pins:updatePinStatuses ⏳ Removing 2 pin sync requests... +0ms
  pins:updatePinStatuses ✅ Removed 2 pin sync requests... +10ms
  pins:updatePinStatuses ⏳ Re-queuing 0 pin sync requests... +0ms
  pins:updatePinStatuses ✅ Re-queued 0 pin sync requests... +1ms
  pins:updatePinStatuses 🎉 Done +0ms

@olizilla
Copy link
Contributor Author

pinpin still blends

DEBUG="*" npm run start -w packages/pinpin

> @web3-storage/[email protected] start
> DEBUG_HIDE_DATE=true DEBUG=pinpin ./src/bin.js

  pinpin 📡 Fetcing Pin Requests from DB +0ms
  pinpin 📥 Processing 3 Pin Requests +35ms
  pinpin 📌 bafkreiabltrd5zm73pvi7plq25pef3hm7jxhbi3kv4hapegrkfpkqtkbme 1/3 pinned on Pinata! Request created: 2022-02-22T15:25:12.062+00:00 +835ms
  pinpin 📌 bafybeidmahqfk7jthbnaspso6skywa7fcqokswrxiw22nzjgnebqkqmrqy 2/3 pinned on Pinata! Request created: 2022-02-22T15:25:41.154+00:00 +17ms
  pinpin 📌 bafybeidt4xhqaizqq2bvferllxcdrk7sfkry72etwbuacfkyqsq3bheody 3/3 pinned on Pinata! Request created: 2022-02-11T12:13:20.299+00:00 +11ms
  pinpin 📡 Deleting 3 processed Pin Requests +0ms
  pinpin 🎉 Done! Pinned 3 of 3 +14ms
  pinpin 📡 Fetcing Pin Requests from DB +1ms
  pinpin 📥 Processing 0 Pin Requests +10ms
  pinpin 📡 Deleting 0 processed Pin Requests +0ms
  pinpin 🎉 Done! Pinned 0 of 0 +11ms
  pinpin Waiting 10s before checking for new Pin Requests +0ms
  pinpin 📡 Fetcing Pin Requests from DB +10s
  pinpin 📥 Processing 0 Pin Requests +11ms
  pinpin 📡 Deleting 0 processed Pin Requests +0ms
  pinpin 🎉 Done! Pinned 0 of 0 +10ms
  pinpin Waiting 10s before checking for new Pin Requests +10s

Copy link
Contributor

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ❤️

@olizilla olizilla merged commit e537f26 into main Feb 28, 2022
@olizilla olizilla deleted the unified-dev-env branch February 28, 2022 15:52
@flea89 flea89 mentioned this pull request Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants