whyrusleeping / gx

A package management tool
MIT License
1.88k stars 110 forks source link

Can't publish node module with NPM scope in package name #125

Open cdata opened 7 years ago

cdata commented 7 years ago

NPM supports scopes in package names. When trying to publish a Node module with gx publish, publishing fails if the package name has an NPM scope e.g., @foo/bar. It results in the following message:

ERROR: publishing: object/patch/add-link: no link by that name
whyrusleeping commented 7 years ago

Interesting... Yeah, this isnt supported. I kindof assumed that package names would be a single string. I'm now wondering what the best way to address this is.

cdata commented 7 years ago

For context: I'm interested in experimenting with publishing several packages from the Polymer and PolymerElements orgs via gx. Currently Polymer packages published to NPM are scoped to @polymer, because users have previously published some of our projects to the unscoped names.

whyrusleeping commented 7 years ago

@cdata Thats great! I see two options here...

We can just use the unscoped package name for gx purposes (should be fine since its all content addressed). Or we can make gx handle paths as filenames, which means that the package urls would look like: QmFooBar/@polymer/pkgname

whyrusleeping commented 7 years ago

Actually, just doing the second option will be really easy...

whyrusleeping commented 7 years ago

Though a good bit of the gx tooling assumes that it can find the package.json at HASH/$firstthingitfinds/package.json. This would break some of that code

cdata commented 7 years ago

It seems like the simplest solution may be to use a directory structure that maps to the package scoping literally.

If that is the case, maybe a gx-npm or similar helper could traverse the directory structure and create symlinks for scoped packages in their parent directory where appropriate. Does that seem like a reasonable approach?

whyrusleeping commented 7 years ago

@cdata Yeah, that could work. The only thing that will be not quite right is some existing gx tooling won't work with scoped packages until we find them and fix them

whyrusleeping commented 7 years ago

@cdata Try building gx from latest master, i pushed a commit that should do what you're expecting