cli icon indicating copy to clipboard operation
cli copied to clipboard

Publish cli to npm

Open lukebussey opened this issue 4 years ago • 3 comments

Feature request

Would it possible to publish the cli to npm using something like https://github.com/sanathkr/go-npm

Is your feature request related to a problem? Please describe.

I’m using supabase db push in an npm prebuild script on vercel and I have to install the rpm to their build image first. Installing the cli via yarn/npm would be a more elegant solution.

Describe the solution you'd like

The ability to run npx supabase db push within Vercel’s build command

Describe alternatives you've considered

Installing the rpm.

lukebussey avatar Jan 03 '22 19:01 lukebussey

Hey, sorry for the late reply! I actually thought of using go-npm at the start as being able to get started without installation steps is a big DX win (e.g. wrangler). However, the tool is not maintained anymore (even after the maintainer switch), so I decided not to do it.

I'll keep the issue open in case there's an alternative approach.

soedirgo avatar Jan 13 '22 10:01 soedirgo

As an alternative I'm just installing the RPM in my npm scripts:

{
  "name": "backend",
  "version": "1.0.0",
  "license": "UNLICENSED",
  "scripts": {
    "premigrate": "rpm -i https://github.com/supabase/cli/releases/download/v0.15.15/supabase_0.15.15_linux_amd64.rpm",
    "migrate": "supabase db push"
  }
}

lukebussey avatar Jan 15 '22 18:01 lukebussey

I am surprised the CLI is not published to npm. I think it's a must-have for any web dev to work with supabase locally. Would be awesome to make this happen!

I did a bit of digging and if you look into the go-npm package, there is a raised issue from some guy who has forked the project to keep working on it. This might be worth looking into if we are still looking for another option like you mentioned @soedirgo. Read about the fork here https://github.com/gzuidhof/go-npm

I hope this could help to push the CLI forward

LB22 avatar Apr 19 '22 08:04 LB22

We have published CLI v1.1.6 to npm and have added CI workflows to keep it in sync with other package managers. You can install it as usual:

npm install supabase
npx supabase -h

Note that the supported arch and platforms of the go binary still applies even if it's installed from npm.

Feel free to open new issues if you run into problems with the npm package.

sweatybridge avatar Aug 25 '22 07:08 sweatybridge

We have published CLI v1.1.6 to npm and have added CI workflows to keep it in sync with other package managers. You can install it as usual:

npm install supabase
npx supabase -h

Note that the supported arch and platforms of the go binary still applies even if it's installed from npm.

Feel free to open new issues if you run into problems with the npm package.

Hello @sweatybridge, I'm having a problem with this approach and I guess it is because I'm installing supabase via yarn 4.0.2 instead of npm. Then npx supabase -v does not respect the package.json version and asks me if I want to install the latest supabase version. When I run npm ls supabase, I get empty as result, running yarn why supabase I get what I have in package.json. It seems that npx considers only supabase added via npm. Is this the case?

danielfoxp2 avatar Nov 24 '23 17:11 danielfoxp2

@danielfoxp2 can you try yarn supabase -h instead? It should work the same as npx for npm

sweatybridge avatar Nov 24 '23 17:11 sweatybridge

Hello @sweatybridge, sorry the delay to answer. I tried to run supabase using yarn instead of npx (just forgot to mention in the first post), but it doesn't work too. This is the result:

$ yarn supabase -h

node:internal/process/esm_loader:40
      internalBinding('errors').triggerUncaughtException(
                                ^
Error: Qualified path resolution failed: we looked for the following paths, but none could be accessed.

Source path: C:\Work\Projects\Repos\jrc-imo\.yarn\unplugged\supabase-npm-1.112.0-fd7eed9ba5\node_modules\supabase\bin\supabase
Not found: C:\Work\Projects\Repos\jrc-imo\.yarn\unplugged\supabase-npm-1.112.0-fd7eed9ba5\node_modules\supabase\bin\supabase

    at makeError (C:\Work\Projects\Repos\jrc-imo\.pnp.cjs:10212:34)
    at resolveUnqualified (C:\Work\Projects\Repos\jrc-imo\.pnp.cjs:11976:13)
    at resolveRequest (C:\Work\Projects\Repos\jrc-imo\.pnp.cjs:12016:14)
    at Object.resolveRequest (C:\Work\Projects\Repos\jrc-imo\.pnp.cjs:12072:26)
    at resolve$1 (file:///C:/Work/Projects/Repos/jrc-imo/.pnp.loader.mjs:2019:21)
    at nextResolve (node:internal/modules/esm/hooks:833:28)
    at Hooks.resolve (node:internal/modules/esm/hooks:278:30)
    at MessagePort.handleMessage (node:internal/modules/esm/worker:168:24)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:807:20)
    at exports.emitMessage (node:internal/per_context/messageport:23:28)

Node.js v20.9.0

danielfoxp2 avatar Nov 26 '23 15:11 danielfoxp2

I see. Yup, that's a known issue with yarn 4 on windows https://github.com/supabase/cli/issues/1624

You may want to follow that issue for updates on any workarounds.

sweatybridge avatar Nov 26 '23 16:11 sweatybridge