Skip to content

Commit

Permalink
pnpm monorepo (#606)
Browse files Browse the repository at this point in the history
  • Loading branch information
manzt authored Jul 29, 2022
1 parent e330811 commit d8b0aee
Show file tree
Hide file tree
Showing 248 changed files with 13,961 additions and 18,052 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
31 changes: 31 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'react', 'react-hooks'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
],
settings: {
react: { version: 'detect' },
},
env: { browser: true },
ignorePatterns: ['*.glsl', '*.css'],
rules: {
// My practice is to use "log" for messages I intend to clean up before merging.
// All these others reflect the intension that they should be left in the codebase.
'no-console': [2, { 'allow': ['warn', 'error', 'info', 'groupCollapsed', 'groupEnd'] }],
'no-underscore-dangle': [0],
'@typescript-eslint/no-empty-function': [0],
// Non-alphabetical groupings can make more sense.
'react/sort-comp': [0],
// Makes punctuation after tab awkward.
'react/jsx-one-expression-per-line': [0],
// TODO: Re-enable: https://github.com/hubmapconsortium/vitessce/issues/144
'react/prop-types': [0],
// Hit eslint error: SyntaxError: Unexpected token, expected {
'react/jsx-curly-newline': [0],
}
}
31 changes: 0 additions & 31 deletions .eslintrc.yml

This file was deleted.

32 changes: 0 additions & 32 deletions .github/workflows/build_and_deploy.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Avivator GitHub Pages
on:
push:
branches:
- master
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
with:
persist-credentials: false

- uses: actions/setup-node@v3
with:
node-version: '16.x'

- uses: pnpm/[email protected]
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: true

- name: Build 🔧
run: pnpm --filter=avivator build && touch sites/avivator/dist/.nojekyll

- name: Deploy 🚀
uses: JamesIves/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: sites/avivator/dist
CLEAN: true
47 changes: 0 additions & 47 deletions .github/workflows/test.yml

This file was deleted.

117 changes: 117 additions & 0 deletions .github/workflows/test_and_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Node.js CI

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
check-changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Updated CHANGELOG.md
if: ${{ github.ref != 'refs/heads/main' }} && !contains(github.ref, 'dependabot')
run: |
! diff CHANGELOG.md <(curl -s "https://raw.githubusercontent.com/hms-dbmi/viv/master/CHANGELOG.md")
build-windows:
runs-on: windows-latest

steps:
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'

- uses: pnpm/[email protected]
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: true

- name: Build Avivator
run: pnpm --filter=avivator build

test-linux:
runs-on: ubuntu-latest
env:
DISPLAY: :0
steps:
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'

- name: Install pnpm
uses: pnpm/[email protected]
id: pnpm-install
with:
version: 7
run_install: true

- name: Check formatting
run: pnpm check-format

- name: Lint
run: pnpm lint

- name: Setup xvf (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get install -y xvfb
# start xvfb in the background
sudo /usr/bin/Xvfb $DISPLAY -screen 0 1280x1024x24 &
- name: Test
run: pnpm test

- name: Build packages and sites
run: pnpm build

publish:
needs: [check-changelog, build-windows, test-linux]
runs-on: ubuntu-latest
# this will run when you have tagged a commit, starting with "v*"
if: contains(github.ref, 'tags')
steps:
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: https://registry.npmjs.org

- name: Install pnpm
uses: pnpm/[email protected]
id: pnpm-install
with:
version: 7
run_install: true

- name: Build packages and sites
run: pnpm build

- name: Publish to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm publish --filter='./packages/*' --dry-run

- name: Upload to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.VIV_S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.VIV_S3_ACCESS_KEY_SECRET }}
run: |
aws s3 cp --recursive sites/avivator/dist s3://avivator.gehlenborglab.org --dry-run
aws s3 cp --recursive sites/docs/dist s3://viv.gehlenborglab.org --dry-run
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
.env.production.local
*.tgz

npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log

# auto-generated via `pnpm --filter=@viv/extensions prepare`
packages/extensions/src/generated-colormaps.js
56 changes: 56 additions & 0 deletions .meta-updater/main.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import * as fs from 'node:fs';
import * as path from 'node:path';

// temporary - @vivjs/* should follow same version of `@hms-dbmi/viv` after we have successfully tested a release.
const VIV_VERSION = '0.12.10-alpha.0';

const DECK_VERSION = '8.6.7';
const LUMAGL_VERSION = '8.5.13';
const MATHGL_VERSION = '^3.5.7';
const REACT_VERSION = '^16.8.0 || ^17.0.0';


/** @typedef {import('@pnpm/types').PackageManifest} PackageManifest */

/**
* Mutates package metadata in-place to pin specific package versions.
*
* @param {PackageManifest} manifest
*/
function pinVersions(manifest) {
for (let key of /** @type {const} */ (['dependencies', 'devDependencies', 'peerDependencies'])) {
let deps = manifest[key] ?? {};
for (let name of Object.keys(deps)) {
if (name.startsWith('@deck.gl/') || name === 'deck.gl') {
deps[name] = DECK_VERSION;
}
if (name.startsWith('@luma.gl/') || name === 'luma.gl') {
deps[name] = LUMAGL_VERSION;
}
if (name.startsWith('@math.gl/')) {
deps[name] = MATHGL_VERSION;
}
if (name === 'react' || name === 'react-dom') {
deps[name] = REACT_VERSION;
}
}

}
}

export default (/** @type {string} */ workspaceDir) => {
let root = path.resolve(workspaceDir, 'package.json');
/** @type {PackageManifest} */
let meta = JSON.parse(fs.readFileSync(root, { encoding: 'utf-8' }));
return {
'package.json': (
/** @type {PackageManifest} */ manifest,
/** @type {string} */ _dir
) => {
const version = manifest.name === '@hms-dbmi/viv' ? VIV_VERSION : meta.version;
// Only pin deps in @vivjs/*. Avivator should manually update.
manifest.name?.includes('@vivjs') && pinVersions(manifest);
return { ...manifest, version };
}
};
};
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
auto-install-peers=true
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added

### Changed
- Migrate to pnpm monorepo

## 0.12.9

Expand Down
Loading

0 comments on commit d8b0aee

Please sign in to comment.