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

reslang should be able to run outside its own repository #64

Closed j-q-arnold closed 4 years ago

j-q-arnold commented 4 years ago

The reslang executable should know how to find its required modules, without requiring a specific current directory. The command currently must be run from its own repository. Example:

$ cd ~/code/api-specs/segment-delivery
$ ~/code/reslang/reslang . --open
error Couldn't find a package.json file in "/Users/jaarno/code/api-specs/segment-delivery"
$ cd ~/code/reslang
$ ./reslang ~/code/api-specs/segment-delivery/ --open
Success - swagger copied to clipboard
[...]
liveandrew commented 4 years ago

@davinchia any comments?

davinchia commented 4 years ago

sorry missed this yesterday.

@j-q-arnold the current repo publishes a reslang container that can be consumed on any local env with docker installed.

in addition to that, the api-specs repo has a script that wraps the container and makes it slightly easier to work with.

is that sufficient? would it be helpful to update the reslang readme with all these information?

j-q-arnold commented 4 years ago

I tried using the reslang container, but it didn't work (maybe I used it wrong, maybe it has changed since then). And the reslang-docker.sh embeds a specific set of options instead of wrapping the general command. (Clearly part of the issue here could be cockpit error.)

My general position is that a command should be self-contained. Imagine if typical Unix commands had to be run from specific directories? Want to use cat? Change directory to xxx. Want to use gcc? Change directory to yyy. The reslang command should know how to find its own modules and resources, without relying on the current directory.

To answer your question about documentation. Yes. Anything one needs to know to use the command successfully should be in the readme.

liveandrew commented 4 years ago

yeah ideally we'd be able to clone the repo, do a yarn install and / or yarn link and it would be now a cmd line tool. i experimented with it a few times, but my knowledge of making a nodejs cmd line app is pretty limited

looking for some help i guess. i think it's easily possible with yarn link, just haven't worked out out to do it

davinchia commented 4 years ago

I see. Yes. The script does some volume mounting onto the container to expose the reslang file to the reslang binary within the container. It's also more suited for usage within the api-specs repo. Maybe the mounting was what was missing on your initial container trial run?

We chose containers since Reslang depends on a the JS/TS buildchain which most platform devs are not familiar with. I see Mike has updated the readme with instructions on how to install Reslang globally. Does that work for you?

I'll update the readme with better instructions on how to use the reslang container.

j-q-arnold commented 4 years ago

Does that work for you?

$ type reslang
reslang is /usr/local/bin/reslang
$ reslang segment-delivery/ --open
Success - swagger copied to clipboard
/bin/sh: ./show-redoc: No such file or directory

On Thu, Jun 25, 2020 at 11:16 AM Davin Chia notifications@github.com wrote:

I see. Yes. The script does some volume mounting onto the container to expose the reslang file to the reslang binary within the container. It's also more suited for usage within the api-specs repo. Maybe the mounting was what was missing on your initial container trial run?

We chose containers since Reslang depends on a the JS/TS buildchain which most platform devs are not familiar with. I see Mike has updated the readme with instructions on how to install Reslang globally https://github.com/LiveRamp/reslang#installing-globally-on-your-machine. Does that work for you?

I'll update the readme with better instructions on how to use the reslang container.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/LiveRamp/reslang/issues/64#issuecomment-649740677, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIYB46ABLMQFE2SVEYICUZDRYOIA5ANCNFSM4OB7464Q .

liveandrew commented 4 years ago

ah i can easily fix that part - you got further than i've gotten in the past.

jim - are you using the docker script?

liveandrew commented 4 years ago

@j-q-arnold jim can you try it again - i've corrected the ./show-redoc problem i think but can't test easily at the moment

j-q-arnold commented 4 years ago

I reinstalled:

$ yarn global add @liveramp/reslang
...
$ ls -l /usr/local/bin/reslang
lrwxr-xr-x  1 jaarno  admin  67 Jun 26 07:26 /usr/local/bin/reslang -> ../../../Users/jaarno/.config/yarn/global/node_modules/.bin/reslang
$ ls -l ~/.config/yarn/global/node_modules/.bin/reslang
lrwxr-xr-x  1 jaarno  staff  32 Jun 26 07:26 /Users/jaarno/.config/yarn/global/node_modules/.bin/reslang -> ../@liveramp/reslang/dist/run.js

which updated /usr/local/bin/reslang. Then tried running reslang:

$ pwd
/Users/jaarno/code/api-specs
$ type reslang
reslang is hashed (/usr/local/bin/reslang)
$ reslang segment-delivery/ --open
Success - swagger copied to clipboard
/bin/sh: ./show-redoc: No such file or directory

Could be a mistake on my part, but it appears not to work.

liveandrew commented 4 years ago

yeah this is an older version - @davinchia what do we need to do to get the docker stuff to use the latest version of reslang?

liveandrew commented 4 years ago

hmm the ./reslang --version doesn't currently work, otherwise i'd ask you to run this. i've fixed that now so in the future we can check more easily

liveandrew commented 4 years ago

please try v2.2.5 - the installation instructions have changed a bit - please make sure you run ./install-reslang

from then on, reslang should be available as a global command line tool! woohoo. it's not perfect, but it means it can fully run outside of the repo as per a normal tool.

fixed here: 57d3566370a98e9b3dd8b362291800dc0b59dc41