Skip to content

Commit

Permalink
Add hermit and docs about hermit (#1659)
Browse files Browse the repository at this point in the history
Also rewrite some Rush docs from RELEASING to README.

Why hermit: it removes any doubt about which node version devs use, and removes the need for nvm or a global node installation.

Note that the CI builds do not use Hermit. This is because they run on multiple versions of node.
  • Loading branch information
r3mariano authored Aug 9, 2021
1 parent 9623a10 commit e2305d8
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Hermit
.hermit

# Logs
*.log
npm-debug.log*
Expand Down
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,34 @@ Misk-Web is still bleeding edge and may have breaking changes up until version `
[testdocs]: https://cashapp.github.io/misk-web/docs/packages/test/
[tslintdocs]: https://cashapp.github.io/misk-web/docs/packages/tslint/
[componentsdocs]: https://cashapp.github.io/misk-web/docs/packages/components/

## How to work with this repo

misk-web manages its Node installation via [Hermit](https://cashapp.github.io/hermit/). Follow the
Quickstart guide, then activate the hermit environment:

```bash
cd path/to/misk-web
source bin/activate-hermit
```

Also consider enabling [Hermit shell hooks](https://cashapp.github.io/hermit/usage/shell/).

This repo is a monorepo managed by [Rush](https://rushjs.io/). Using Rush allows coordinated version
releases and iterative builds, among other headache-saving features. Please take time to read their
documentation for other commands not described below.

Set up rush:

```bash
npm i -g @microsoft/rush
```

Then build everything:

```bash
# Like `npm install`, but for all packages in the repo.
rush update
# Like `npm run build`, but for all of them.
rush build
```
19 changes: 1 addition & 18 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,9 @@ This outlines the steps necessary to manually release new `@misk` packages on NP
- Create an NPM user at [npmjs.com](http://npmjs.com/) and request membership in the [`@Misk` organization ](https://www.npmjs.com/org/misk). Membership will give you publish permissions for `@Misk` scoped packages.
- **Note:** member level may not actually be high enough to publish, needs further testing whether publish permissions are only available at Admin or Owner level.
- On your development machine, run `$ npm login` to authorize your local environment with publish permissions.

## Rush: Setup

- `@misk` packages are in a directory managed by [Rush](https://rushjs.io/). This allows coordinated version releases and iterative builds among other headache saving features.
- Developing `@misk` packages is different than regular Misk tabs in that all builds are not done in Docker, but locally with Rush. This is much faster and highly recommended.
- Using Rush requires a working local Node `10.5+` Long Term Support (LTS) environment. Consider using [nvm](https://github.com/creationix/nvm) to ensure the latest `10.5+` LTS version is present.
- Take the time to familiarize yourself with [Rush](https://rushjs.io/). They have [good documentation](https://rushjs.io/pages/intro/welcome/) and a quick start guide is below.

## Rush: Quick Start Guide

```Bash
$ npm install -g @microsoft/rush
$ cd </your/code/directory>/misk-web
$ rush update
$ rush build
```

## Releasing

- `@misk` packages in this repo are managed by [Rush](https://rushjs.io/), which allows easy coordinated releases of all packages (ie. release all with a common version number). [Read their docs](https://rushjs.io/pages/intro/welcome/) to understand how to develop using Rush and how to setup your environment.
- `@misk` packages in this repo are managed by [Rush](https://rushjs.io/), which allows easy coordinated releases of all packages (ie. release all with a common version number). Make sure Rush is set up locally. A guide is available in the [README](README.md).
- All commands below must be run from the `misk-web` root directory.
- Use the command below to bump the version across all packages.

Expand Down
1 change: 1 addition & 0 deletions bin/[email protected]
7 changes: 7 additions & 0 deletions bin/README.hermit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Hermit environment

This is a [Hermit](https://github.com/cashapp/hermit) bin directory.

The symlinks in this directory are managed by Hermit and will automatically
download and install Hermit itself as well as packages. These packages are
local to this environment.
19 changes: 19 additions & 0 deletions bin/activate-hermit
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
# This file must be used with "source bin/activate-hermit" from bash or zsh.
# You cannot run it directly

if [ "${BASH_SOURCE-}" = "$0" ]; then
echo "You must source this script: \$ source $0" >&2
exit 33
fi

BIN_DIR="$(dirname "${BASH_SOURCE[0]:-${(%):-%x}}")"
if "${BIN_DIR}/hermit" noop > /dev/null; then
eval "$("${BIN_DIR}/hermit" activate "${BIN_DIR}/..")"

if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ]; then
hash -r 2>/dev/null
fi

echo "Hermit environment $("${HERMIT_ENV}"/bin/hermit env HERMIT_ENV) activated"
fi
26 changes: 26 additions & 0 deletions bin/hermit
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -eo pipefail

if [ -z "${HERMIT_STATE_DIR}" ]; then
case "$(uname -s)" in
Darwin)
export HERMIT_STATE_DIR="${HOME}/Library/Caches/hermit"
;;
Linux)
export HERMIT_STATE_DIR="${XDG_CACHE_HOME:-${HOME}/.cache}/hermit"
;;
esac
fi

export HERMIT_DIST_URL="${HERMIT_DIST_URL:-https://d1abdrezunyhdp.cloudfront.net/square}"
HERMIT_CHANNEL="$(basename "${HERMIT_DIST_URL}")"
export HERMIT_CHANNEL
export HERMIT_EXE=${HERMIT_EXE:-${HERMIT_STATE_DIR}/pkg/hermit@${HERMIT_CHANNEL}/hermit}

if [ ! -x "${HERMIT_EXE}" ]; then
echo "Bootstrapping ${HERMIT_EXE} from ${HERMIT_DIST_URL}" 1>&2
curl -fsSL "${HERMIT_DIST_URL}/install.sh" | /bin/bash 1>&2
fi

exec "${HERMIT_EXE}" --level=fatal exec "$0" -- "$@"
Empty file added bin/hermit.hcl
Empty file.
1 change: 1 addition & 0 deletions bin/node
1 change: 1 addition & 0 deletions bin/npm
1 change: 1 addition & 0 deletions bin/npx

0 comments on commit e2305d8

Please sign in to comment.