Skip to content

Commit

Permalink
Merge pull request #808 from jtpio/monorepo
Browse files Browse the repository at this point in the history
Adopt monorepo structure
  • Loading branch information
jtpio authored Jan 21, 2021
2 parents 50577c3 + 1372b45 commit 3209c1f
Show file tree
Hide file tree
Showing 47 changed files with 6,922 additions and 20,019 deletions.
24 changes: 24 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
lint-staged.config.js
.eslintrc.js

node_modules
**/build
**/lib
**/node_modules
**/mock_packages
**/static
**/labextension
**/typings
**/schemas
**/themes
**/templates
coverage
*.map.js
*.bundle.js

# jetbrains IDE stuff
.idea/

# ms IDE stuff
.history/
.vscode/
56 changes: 56 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
module.exports = {
env: {
browser: true,
es6: true,
commonjs: true,
node: true,
'jest/globals': true
},
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'plugin:react/recommended',
'plugin:jest/recommended'
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.eslint.json',
sourceType: 'module'
},
plugins: ['@typescript-eslint', 'jest'],
rules: {
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'interface',
format: ['PascalCase'],
custom: {
regex: '^I[A-Z]',
match: true
}
}
],
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/quotes': [
'error',
'single',
{ avoidEscape: true, allowTemplateLiterals: false }
],
curly: ['error', 'all'],
eqeqeq: 'error',
'prefer-arrow-callback': 'error'
},
settings: {
react: {
version: 'detect'
}
}
};
16 changes: 10 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build JupyterLab Extension
name: Build Frontend Packages

on:
push:
Expand All @@ -25,14 +25,12 @@ jobs:
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
python-version: '3.9'
architecture: 'x64'

- name: Install JupyterLab
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install jupyter_packaging
python -m pip install jupyterlab
python -m pip install -U pip jupyterlab~=3.0 jupyter_packaging~=0.7.9
- name: Install the Voilà Preview JupyterLab extension
run: |
Expand All @@ -47,3 +45,9 @@ jobs:
- name: Browser check
run: |
python -m jupyterlab.browser_check
- name: Lint
run: |
jlpm
jlpm run eslint:check
jlpm run prettier:check
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

- name: Create the conda environment
shell: bash -l {0}
run: mamba install -q python=${{ matrix.python_version }} pip jupyterlab_pygments==0.1.0 pytest-cov nodejs flake8 ipywidgets matplotlib xeus-cling
run: mamba install -q python=${{ matrix.python_version }} pip jupyterlab_pygments==0.1.0 pytest-cov nodejs flake8 ipywidgets matplotlib xeus-cling xtl=0.6.23

- name: Install dependencies
shell: bash -l {0}
Expand Down
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
**/node_modules
**/lib
**/package.json
**/labextension
**/static
build
notebooks/
.vscode/
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ https://voila.readthedocs.io/
The following two examples show how a standalone Jupyter notebook can be turned into a separate app, from the command-line integration.

### Rendering a notebook including interactive widgets and rich mime-type rendering

![Voilà basics](voila-basics.gif)

### Rendering a notebook making use of a custom widget library ([bqplot](https://github.com/bloomberg/bqplot))
Expand All @@ -103,7 +104,7 @@ The sources of the Jupyter notebook can be displayed in a Voilà app if option `

![Voilà sources](voila-sources.gif)

### Voilà dashboards with other language kernels**
### Voilà dashboards with other language kernels\*\*

Voilà is built upon Jupyter standard formats and protocols, and is agnostic to the programming language of the notebook. In this example, we present an example of a Voilà application powered by the C++ Jupyter kernel [xeus-cling](https://github.com/jupyter-xeus/xeus-cling), and the [xleaflet](https://github.com/jupyter-xeus/xleaflet) project.

Expand Down
4 changes: 2 additions & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ git clean -fdx

Make sure the `dist/` folder is empty.

1. Update [voila/_version.py](./voila/_version.py) and [environment.yml](./environment.yml) with the new version number (see and [example diff](https://github.com/voila-dashboards/voila/commit/5c6fd8dd3ea71412ae9c20c25248453d22a3b60a))
1. Update [voila/\_version.py](./voila/_version.py) and [environment.yml](./environment.yml) with the new version number (see and [example diff](https://github.com/voila-dashboards/voila/commit/5c6fd8dd3ea71412ae9c20c25248453d22a3b60a))
2. `python setup.py sdist bdist_wheel`
3. Double check the size of the bundles in the `dist/` folder
4. If the JupyterLab extension has changed, make sure to bump the version number in `./packages/jupyterlab-preview/package.json`
5. Make sure the JupyterLab extension is correctly bundled in source distribution
6. Run the tests
* (pip install "dist/voila-X.Y.Z-py3-none-any.whl[test]" && (cd tests/test_template; pip install .) && (cd tests/skip_template; pip install .) && py.test)
- (pip install "dist/voila-X.Y.Z-py3-none-any.whl[test]" && (cd tests/test_template; pip install .) && (cd tests/skip_template; pip install .) && py.test)
7. `export TWINE_USERNAME=mypypi_username`
8. `twine upload dist/*`

Expand Down
8 changes: 4 additions & 4 deletions docs/source/_static/main_stylesheet.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.wy-nav-content {
max-width: 1000px;
margin: auto;
max-width: 1000px;
margin: auto;
}

.wy-nav-content img {
margin: 5px auto 25px;
}
margin: 5px auto 25px;
}
42 changes: 37 additions & 5 deletions docs/source/contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,47 @@ added in JupyterLab 3.0. To setup the development environment:
# link your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite
# go to the extension directory
cd packages/jupyterlab-preview
# build the extension
jlpm run build
# build the lab extension
jlpm run build --scope @voila-dashboards/jupyterlab-preview
# it is also possible to start in watch mode to pick up changes automatically
jlpm run watch
Frontend Packages
-----------------

The Voilà repository consists of several packages such as the Voilà frontend and the JupyterLab extension.

It follows a monorepo structure and uses ``lerna`` to streamline the workflow.

To build all the frontend packages at once, run the following commands:

.. code-block:: bash
# install dependencies
jlpm
# build the packages
jlpm run build
This will run the ``build`` script in each of the packages.

Using this structure, packages can easily be linted and follow the same code style and conventions used in other Jupyter projects.
To lint the packages:

.. code-block:: bash
# install dependencies
jlpm
# run ESLint
jlpm run eslint
# run prettier
jlpm run prettier
Tests
=====

Expand Down
8 changes: 4 additions & 4 deletions etc/jupyter/jupyter_notebook_config.d/voila.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"NotebookApp": {
"nbserver_extensions": {
"voila.server_extension": true
}
"NotebookApp": {
"nbserver_extensions": {
"voila.server_extension": true
}
}
}
8 changes: 4 additions & 4 deletions etc/jupyter/jupyter_server_config.d/voila.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ServerApp": {
"jpserver_extensions": {
"voila.server_extension": true
}
"ServerApp": {
"jpserver_extensions": {
"voila.server_extension": true
}
}
}
6 changes: 3 additions & 3 deletions etc/jupyter/nbconfig/notebook.d/voila.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"load_extensions": {
"voila/extension": true
}
"load_extensions": {
"voila/extension": true
}
}
5 changes: 5 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"npmClient": "yarn",
"version": "independent",
"useWorkspaces": true
}
27 changes: 27 additions & 0 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const escape = require('shell-quote').quote;
const fs = require('fs');
const isWin = process.platform === 'win32';

const escapeFileNames = filenames =>
filenames
.filter(filename => fs.existsSync(filename))
.map(filename => `"${isWin ? filename : escape([filename])}"`)
.join(' ');

module.exports = {
'**/*{.css,.json,.md}': filenames => {
const escapedFileNames = escapeFileNames(filenames);
return [
`prettier --write ${escapedFileNames}`,
`git add -f ${escapedFileNames}`
];
},
'**/*{.ts,.tsx,.js,.jsx}': filenames => {
const escapedFileNames = escapeFileNames(filenames);
return [
`prettier --write ${escapedFileNames}`,
`eslint --fix ${escapedFileNames}`,
`git add -f ${escapedFileNames}`
];
}
};
56 changes: 56 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"private": true,
"homepage": "https://github.com/voila-dashboards/voila",
"bugs": {
"url": "https://github.com/voila-dashboards/voila/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/voila-dashboards/voila"
},
"license": "BSD-3-Clause",
"author": "Voilà contributors",
"workspaces": {
"packages": [
"packages/*"
]
},
"scripts": {
"build": "lerna run build",
"build:prod": "lerna run build:prod",
"build:test": "lerna run build:test",
"clean": "lerna run clean",
"eslint": "eslint . --ext .ts,.tsx,.js,.jsx --fix",
"eslint:check": "eslint . --ext .ts,.tsx,.js,.jsx",
"install": "lerna bootstrap",
"prettier": "prettier --write \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
"prettier:check": "prettier --list-different \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"",
"test": "lerna run test"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.2.0",
"@typescript-eslint/parser": "^4.2.0",
"eslint": "^7.10.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.21.5",
"husky": "^3",
"jest": "^26.4.2",
"jest-junit": "^11.1.0",
"jest-raw-loader": "^1.0.1",
"jest-summary-reporter": "^0.0.2",
"lerna": "^3.22.1",
"lint-staged": "^10.4.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.19.0",
"rimraf": "^3.0.2",
"shell-quote": "^1.7.2",
"typescript": "~4.1.3"
}
}
Loading

0 comments on commit 3209c1f

Please sign in to comment.