allenai/pdf-component-library

Create OSS repository for Component Library

mjlangan opened this issue · 7 comments

For ease of development, the "Hello World" app and components are being worked on in the https://github.com/allenai/pdf-component-library repository. When we are ready to begin using the library in S2 as well, we should drop the component library into a new OSS repository (probably with a better repo name).

AI2 Open source policy: https://sites.google.com/allenai.org/intranet/processes-resources/publishing-your-work/open-source-your-code?pli=1&authuser=1

  • Add docs. Provide context, motivation, getting started instructions, contact, instruction to open github issues
  • Add license
  • pre-publish review. You need written approval from Michael Schmitz, Darrell Plessas, and Jen Dumas
  • email opensource-approval@allenai.org:

Brainstorming- running list of things to consider before open sourcing:

  • Refactor directory structure. Determine if api/sonar/proxy are needed for our project. Separate demo/library code.
  • Script for publishing to npm
  • Refactor demo code to use npm package instead of pulling directly from library once a package has been created.
  • Backwards compatible if anything changes
  • Documentation
  • Licensing
  • Unit tests
  • Versioning (Use Semantic versioning)
  • Loose ends ticket cleanup- re-rendering, code cleanup

tsdx could be useful for setting this up, or at least as a guide.
Related: https://dominik.sumer.dev/blog/publishing-a-typescript-library-in-2021

Publishing the package to private Github

Good blog here on how to set this up.

Npm private repo is paid. The GitHub package feature allows 500Mb free private packages. The packages visibility depends on the github repository visibility

Steps to publish the package:

  1. Create a personal access token on github -> developer settings. Set the scope to repo, read:package, write:package
  2. npm login --registry=https://npm.pkg.github.com with github username and access token created in step 1. Or can also set up the github access token in an .npmrc file
  3. Add a package.json file to ui/src/library/package.json
{
    "name": "@allenai/pdf-component-library",
    "version": "0.0.1",
    "publishConfig": {
        "registry": "https://npm.pkg.github.com"
    },
    "repository": {
        "type": "git",
        "url": "ssh://git@github.com:allenai/pdf-component-library.git",
        "directory": "ui/src/library"
    }
}
  1. npm publish

Installing packages from Github

  1. set the github access token created in Step 1 above as an env variable.
    echo "export GITHUB_TOKEN=your_access_token" >> ~/.bash_profile
  2. online/webapp/.npmrc
@allenai:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
  1. webapp % npm install @allenai/pdf-component-library

This is going to be OSS, so you can publish it to the existing @allenai org on NPM. The reviz team has been using this for their library releases like https://www.npmjs.com/package/@allenai/varnish

Ask @codeviking to add your NPM accounts to the org.

@mjlangan I made you an administrator, so you can add folks too.

I sent an invite to smitar@allenai.org.

Thanks! got added to our NPM account. Until we are ready to make the github project for the pdf-component-library public, we could use the github repo to publish the component.
Npm private repo is paid. The GitHub package feature allows 500Mb free private packages.

Using AWS CodeArtifact to publish npm private libraries is also an option. We have some scala libraries on AWS CodeArtifact.

Done!