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

JS package reorganization #565

Merged
merged 16 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/annotated-pkgs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This is a basic workflow to help you get started with Actions

name: Test Yarn Workspaces

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [main]
pull_request:
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
yarn-monorepo-install:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "14"

- name: Install yarn 3
JackUrb marked this conversation as resolved.
Show resolved Hide resolved
run: npm i -g yarn

- name: Install package dependencies
run: yarn install

- name: Build packages
run: yarn workspaces foreach -ptA run build

- name: Test that storybook compiles
run: yarn workspace sb build-storybook
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ examples/**/build/*

# PyCharm
.idea


# https://next.yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
.yarn/*
!.yarn/patches
!.yarn/releases
pringshia marked this conversation as resolved.
Show resolved Hide resolved
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*

docs/storybook/storybook-static/*
4 changes: 3 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ repos:
exclude: |
(?x)(
^.*build/|
^.*md
^.*md|
.yarn/*|
yarn-patches
)
- id: check-yaml
- id: check-added-large-files
Expand Down
367 changes: 367 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-version.cjs

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

631 changes: 631 additions & 0 deletions .yarn/releases/yarn-3.0.2.cjs

Large diffs are not rendered by default.

631 changes: 631 additions & 0 deletions .yarn/releases/yarn-berry.cjs

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
initFields:
bugs:
url: "https://github.com/facebookresearch/Mephisto/issues"
homepage: "https://github.com/facebookresearch/Mephisto.git"
license: MIT
main: build/bundle.js
repository:
type: git
url: "git+https://github.com/facebookresearch/Mephisto.git"
source: src/index.js

initScope: annotated

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"

yarnPath: .yarn/releases/yarn-berry.cjs
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ As of now we're in an early alpha release, more details to come.

Check out our [guidelines for contributing](https://github.com/facebookresearch/Mephisto/blob/main/CONTRIBUTING.md) and then take a look at some of our tagged issues: [good first issue](https://github.com/facebookresearch/Mephisto/labels/good%20first%20issue), [help wanted](https://github.com/facebookresearch/Mephisto/labels/help%20wanted).

For library authors, you may also find the [development documentation][development] helpful.

[quickstart]: https://github.com/facebookresearch/mephisto/blob/main/docs/quickstart.md
[development]: https://github.com/facebookresearch/mephisto/blob/main/docs/development.md


## License
Expand Down
74 changes: 73 additions & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,79 @@ To setup your local codebase to auto-lint and avoid lint test failures for your
2. `pre-commit install` to install git hooks
3. `pre-commit run --all-files` (optional - run ad-hoc against all files)

# Front-end Development

# Front-end Development (new)
*For commits after the `yarn-pkg-reorg` tag and for newer packages (`@annotated/*`)*

This repo uses yarn workspaces to manage it's front-end dependencies.

**First ensure that you're on the latest version of yarn.**

```bash
$ npm i -g yarn
```

> *Note: Our repo uses yarn v3.0.2 (yarn versions >= 2.0 have codename berry). This version of yarn is checked into the repo at `.yarn/releases` and is targeted by the `"yarnPath"` property in the root `.yarnrc.yml` file. More details can be found [here](https://yarnpkg.com/cli/set/version) and [here](https://yarnpkg.com/configuration/yarnrc#yarnPath).*

**Install all dependencies.**

You can think of this as both running `npm install` in all local workspaces and running `npm link` to link local package dependencies where appropriate.

```bash
$ yarn install

# This is similar to running `lerna --hoist` in the past
```

> You'll notice that individual packages don't have `node_modules/` folders anymore. This is because all packages are hoisted to the top level and placed within the `.yarn/cache` folder. This speeds up `npm install`s, attempts to share dependencies between projects when necessary, and avoids ambiguous module resolutions.

**Build the workspaces**

We can use yarn to build all the dependencies in our project easily.

```bash
$ yarn build-all
```

*Note: You can see the root `package.json` to see the underlying command under this convenience script.*

### Tips & Recipes

- View all of the workspaces in the project:

```bash
$ yarn workspaces list

➤ YN0000: .
➤ YN0000: docs/sb
➤ YN0000: packages/annotated/bbox
➤ YN0000: packages/annotated/dev-scripts
➤ YN0000: packages/annotated/keypoint
➤ YN0000: packages/annotated/shell
➤ YN0000: packages/annotated/video-player
```

- Run a command in a specific workspace

```bash
$ yarn workspace sb build-storybook

$ yarn workspace @annotated/bbox build
```

- Run a command in all workspaces

```bash
$ yarn workspaces foreach -ptA run build
```

More information on the flags for `foreach` can be found [here](https://yarnpkg.com/cli/workspaces/foreach).


# Front-end Development (old)

*For commits before the `yarn-pkg-reorg` tag or for non-workspace packages, e.g. `global-context-store`, `annotation-toolkit`, `bootstrap-chat`.*


This repo has a few npm packages. If you're developing on them, you may want them to reference each other so your local edits across packages are reflected in your build.
To accomplish this we use [Lerna](https://github.com/lerna/lerna). Lerna is also used to hoist `react` across packages to avoid this dreaded warning/error: https://reactjs.org/warnings/invalid-hook-call-warning.html
Expand Down
4 changes: 4 additions & 0 deletions docs/storybook/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: ["react-app"],
};
4 changes: 0 additions & 4 deletions docs/storybook/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

storybook-static/

# dependencies
/node_modules
/.pnp
Expand All @@ -23,5 +21,3 @@ storybook-static/
npm-debug.log*
yarn-debug.log*
yarn-error.log*

.vercel
8 changes: 0 additions & 8 deletions docs/storybook/.storybook/BrandTheme.js

This file was deleted.

6 changes: 0 additions & 6 deletions docs/storybook/.storybook/manager.js

This file was deleted.

71 changes: 4 additions & 67 deletions docs/storybook/README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,7 @@
# Getting Started with Create React App
# Storybook

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
This storybook houses UI components from the `@annotated/*` packages as well as other Mephisto front-end components.

## Available Scripts
It was bootstrapped using `create-react-app` as the base.

In the project directory, you can run:

### `yarn start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.\
You will also see any lint errors in the console.

### `yarn test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `yarn build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `yarn eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

### Analyzing the Bundle Size

This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

### Making a Progressive Web App

This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

### Advanced Configuration

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

### Deployment

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

### `yarn build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
To add your own stories, see the [official React storybook documentation](https://storybook.js.org/docs/react/get-started/introduction).
Loading