LiveRamp / reslang

A language for describing resource-oriented APIs & turning them into Swagger or resource diagrams. Oriented around the concepts we want to expose in the APIs.
Apache License 2.0
23 stars 7 forks source link

Create setup for packages #49

Closed sagarrbatchu closed 4 years ago

sagarrbatchu commented 4 years ago

Small quality of life improvement to install reslang as a versioned package. Any dev can then run npm install @liveramp/reslang@01.4.2 to have available globally on their path. Thanks Mike for the idea !

If this is a thumbs up I'll run npm version 1.4.2 to set the version in package.json and then run npm publish to publish it under https://github.com/orgs/LiveRamp/packages . Since this is a private repo the package maintains the same scopes, you will have to be a member of the LiveRamp org with read permissions on the reslang repo to install it as a binary.

mharris717 commented 4 years ago

Thinking, will reply again later today. Nice job.

mharris717 commented 4 years ago

Support building JS, publishing to Github Packages, and installing globally

Pushed some changes

This is probably good to go now, although decent change I missed something. Need to add some short instructions to the README for how to install globally.

Basically you need to get a Github token for installing packages, then setup your global .npmrc file. ~/.npmrc looks like this:

//npm.pkg.github.com/:_authToken=${GITHUB_PACKAGE_TOKEN}
@liveramp:registry=https://npm.pkg.github.com/

Then you can install reslang globally with

yarn global add @liveramp/reslang

Needed to change the name to @liveramp/reslang because Github Packages requires the package to be prefixed with the org name. If this is a dealbreaker, we can figure something else out. Same thing with changing bin in package.json and removing the ts-node shebang from main.ts. Let me know.

After installing globally, you can run it with reslang from anywhere. You get proper handling of relative paths passed to reslang for free.

mharris717 commented 4 years ago

The rollup file is basically just copied from our Customer Profiles apps. It works, and it's not long or confusing, so I didn't bother tweaking it.

Note: I removed the ts-node shebang because for whatever reason it broke the rollup build. That's dumb, but I guessed that instead of investigating, we could do just fine without the shebang.