Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uibuilder cannot use packages that are part of an npm @ scope #71

Closed
TotallyInformation opened this issue Sep 28, 2019 · 5 comments
Closed
Labels
enhancement Improvements to code or new features Fixed Phew, think I got away with it.

Comments

@TotallyInformation
Copy link
Owner

TotallyInformation commented Sep 28, 2019

tilib.findPackage() expects to find a simple package name and it doesn't cope with @ scoped names. These are always installed in a sub-folder.

I think that this is a bit more of an important one than this issue and I will raise a different issue for it.

While probably not that urgent to fix, it will need fixing at some point.

Software Version
uibuilder node v2.0.3

See Also Issue #69 - that issue is mainly about meta-packages (packages that install other packages) rather than this issue which is why I've created this one separately.

As a workaround, you can use one of the workarounds listed in issue 69. It may take me some while to get around to fixing this. In the meantime, if anyone fancies fixing it in a PR, please feel free to do so.

@TotallyInformation TotallyInformation added enhancement Improvements to code or new features help wanted I haven't a clue what I'm doing! Please help! labels Sep 28, 2019
@github-actions
Copy link

Stale issue message

@github-actions
Copy link

Stale issue message

@github-actions
Copy link

Stale issue message

@github-actions
Copy link

github-actions bot commented Jun 1, 2020

Stale issue message

@TotallyInformation
Copy link
Owner Author

TotallyInformation commented Jun 14, 2020

Many thanks to Steve in the forum for the following:

Steve-Mcl

Julian, I suspect there is a bug in tilib.js loading packages with a / (like this one).

I tried to add @riophae/vue-treeselect via the "manage libraries"

It installed the library into node_modules but never showed the entry in the library list.

I debug stepped the uibuilder code in tilib.js and found this part...

let pathSplit = packagePath.split(path.sep)
if ( (pathSplit.length > 1) && (pathSplit[pathSplit.length - 1] !== packageName) ) pathSplit.pop()
if ( (pathSplit.length > 1) && (pathSplit[pathSplit.length - 1] !== packageName) ) pathSplit.pop()
if ( (pathSplit.length > 1) && (pathSplit[pathSplit.length - 1] !== packageName) ) pathSplit.pop()
packagePath = pathSplit.join(path.sep)

ends up with the path to .node-red/node-modules in packagePath

whats happening is packageName contains "@riophae/vue-treeselect" but the path parts contain

[ ".node-red", "node-modules", "@riophae", "vue-treeselect", "dist"

... so none of them match the package name ("@riophae/vue-treeselect") and the path gets popped three times leaving .node-red/node-modules

To work around this I did the following...

//handle user/package package names by getting only the last part
let packageSplit = packageName.split("/"); 
let packageNameLast = packageSplit.pop();
let pathSplit = packagePath.split(path.sep)
if ( (pathSplit.length > 1) && (pathSplit[pathSplit.length - 1] !== packageNameLast) ) pathSplit.pop()
if ( (pathSplit.length > 1) && (pathSplit[pathSplit.length - 1] !== packageNameLast) ) pathSplit.pop()
if ( (pathSplit.length > 1) && (pathSplit[pathSplit.length - 1] !== packageNameLast) ) pathSplit.pop()
packagePath = pathSplit.join(path.sep)

and it seems to work (i.e. the package name no longer gets deleted from packageList.json and the server serves the files.

Hope that helps?

@TotallyInformation TotallyInformation added Fixed Phew, think I got away with it. and removed help wanted I haven't a clue what I'm doing! Please help! no-issue-activity labels Jun 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements to code or new features Fixed Phew, think I got away with it.
Projects
None yet
Development

No branches or pull requests

1 participant