Skip to content

Latest commit

 

History

History
142 lines (124 loc) · 6 KB

CONTRIBUTING.md

File metadata and controls

142 lines (124 loc) · 6 KB

CONTRIBUTING

This project was generated by the dash-component-boilerplate it contains the minimal set of code required to create your own custom Dash component.

N.B.: because of the current usage of postbuild_fixups.sh build script, this project can only be build on a Linux distribution


Install dependencies

  1. Install npm packages

    $ npm install
    
  2. Create a virtual env and activate.

    $ python3 -m venv venv
    $ . venv/bin/activate
    
  3. Install python packages required to build components.

    $ pip install wheel
    $ pip install -r requirements.txt
    # or
    $ pip install -r requirements.txt --upgrade
    
  4. Install the python packages for testing (optional)

    $ pip install -r tests/requirements.txt
    # or
    $ pip install -r tests/requirements.txt --upgrade
    

Write your component code in src/lib/components/DashTextareaAutocomplete.react.js.

  • The demo app is in src/demo and you will import your example component code into your demo app.
  • Test your code in a Python environment:
    1. Build your code
      $ npm run build
      
      N.B.
      • We use postbuild_fixups.sh to re-write certain lines in the generated Julia files of this package to allow usage of Julia's Artifact system.
    2. Run and modify the usage.py sample dash app:
      $ python usage.py
      
  • Write tests for your component.
    • A sample test is available in tests/test_usage.py, it will load usage.py and you can then automate interactions with selenium.
    • Run the tests with $ pytest tests.
    • The Dash team uses these types of integration tests extensively. Browse the Dash component code on GitHub for more examples of testing (e.g. https://github.com/plotly/dash-core-components)
  • Add custom styles to your component by putting your custom CSS files into your distribution folder (dash_textarea_autocomplete).
    • Make sure that they are referenced in MANIFEST.in so that they get properly included when you're ready to publish your component.
    • Make sure the stylesheets are added to the _css_dist dict in dash_textarea_autocomplete/__init__.py so dash will serve them automatically when the component suite is requested. does not apply
  • Review your code

Create a production build and publish:

  1. Pre-requisites

    1. Contact @etpinard to get write access to this repo
    2. Create an npmjs.com account and a pypi.org account and ask @etpinard for publish rights
    3. Provide your login/pass for Pypi (if you're not using a keychain-type Python module for that) and sign-in to NPM with npm login
    4. Install dependencies and activate python virtualenv ref
  2. Version, build, commit and push your code:

    $ git checkout main
    $ npm version --no-git-tag-version <patch|minor|major>
    $ npm run build
    $ git add --all
    $ git commit -m "X.Y.Z"
    $ git push
    

    N.B.

    • we use the --no-git-tag-version flag, because Registrator.jl won't work if a tag corresponding to the to-be-registered version already exists.
  3. Create a Python distribution

    $ rm -rf dist/*
    $ pip install wheel
    $ python setup.py sdist bdist_wheel
    

    This will create source and wheel distribution in the generated the dist/ folder. See PyPA for more information.

  4. Test your tarball by copying it into a new environment and installing it locally:

    $ mkdir some-tmp-dir
    $ cd some-tmp-dir
    $ python3 -m venv venv
    $ . venv/bin/activate
    $ pip install wheel
    $ pip install /path/to/dist/dash_textarea_autocomplete-X.Y.Z.tar.gz
    
  5. If it works, then you can publish the component:

    1. Publish on PyPI (N.B. must have PyPI token and $HOME/.pypirc filled correctly)

      $ pip install twine
      $ twine upload dist/*
      
    2. Publish on NPM

      $ npm publish
      

      Publishing your component to NPM will make the JavaScript bundles available on the unpkg CDN. By default, Dash serves the component library's CSS and JS locally, but if you choose to publish the package to NPM you can set serve_locally to False and you may see faster load times.

    3. Publish to Julia's General Registry

      • Go to the repo's Github's page and add the following comment on the version commit:
      @JuliaRegistrator register branch=main
      
      If something goes wrong (like a test failure), click here
      • fix the problem,
      • run npm run build,
      • add, commit and push (but do not bump the version!),
      • redo step 2-3 and
      • make another @JuliaRegistrator register branch=main comment on the newly pushed commit on Github. The JuliaRegistrator bot will match the version number with the opened JuliaRegistries/General PR.

      After the JuliaRegistries/General PR is merged, the Julia version of the package will be out-of-sync with the NPM and PyPI versions. So, it is hightly recommanded to redo the publish process from scratch starting with an npm version --no-git-tag-version patch call. Note that we cannot simply abandoned an opened JuliaRegistries/General PR, as the Julia registries require "sequential" version increments as of 2021-12-16. That is, going from v1.1.0 to v1.2.1 if the v1.2.0 release is botched is not allowed.

  6. Tag and make a Github release

    • Done automatically by TagBot after the new version has been merged in Julia's General Registry.