Relative paths in complex nested components

Hello,

I really like concept of paths relative to tox files and I am trying to figure out how to migrate my components to this new workflow. :nerd_face: However I have a hard time figuring it out for more complex (nested) scenarios.

I am attaching simple example with multiple components in following file structure. There are two fonts, one is part of a main component, the other is part of a child1. All components use tox-relative paths. What I am trying to do is to use both fonts in child2, but I don’t want to use β€œβ€¦/” to jump up (since this can get unreadable when jumping up multiple levels). Instead I am trying to point to some component and define relative path based on it.

β”œβ”€β”€ main
β”‚   β”œβ”€β”€ child1
β”‚   β”‚   β”œβ”€β”€ child1.tox
β”‚   β”‚   β”œβ”€β”€ child2
β”‚   β”‚   β”‚   └── child2.tox
β”‚   β”‚   └── font
β”‚   β”‚       └── Sevillana-Regular.ttf
β”‚   β”œβ”€β”€ font
β”‚   β”‚   └── NotoMono-Regular.ttf
β”‚   └── main.tox
└── test.4.toe

Real example: nested_test.zip (148.5 KB)

In the past I have usually used expressions like this to find proper file:

tdu.expandPath(parent.Child1.par.externaltox + '/..') + '/font/Sevillana-Regular.ttf'

This concept however doesn’t play well with paths that are relative to tox files, as they are incorrectly expanded (as if they were relative to toe file). Therefore I am looking for some alternative solution. Please is there some way to correctly expand these paths? Thanks.


Also I am hitting one more problem, that is very much expected with tox-relative paths, but is something I am trying to figure out too… Lets say I would like to make main component from previous example deployable in a single tox file (something like main_release.tox). As soon as I do that, I break all paths to external fonts / assets / configs etc. - as they all use relative paths throughout the code and parameters of nested components. Please what do you think might be a good approach for handling such situation? I have originally thought it might just work if I turn β€œEnable External .tox” off, but keep the β€œExternal .tox Path” present - so that relative paths would still be working, just the tox will become β€œembedded”, but this doesn’t seem to be the case.

I would generally like to keep the structure untouched even for the release, but when I need to enable component privacy, this concept quickly breaks due to various reasons and I am kinda forced into deployment of β€œflat” private component (with all sub-components embedded within it). Thanks once again. :slight_smile:

Uh oh, I didn’t know about filePath and fileFolder attributes of COMP class (I have stumbled upon them just now), this is great, exactly what I was looking for, thanks so much for adding these! :partying_face:

3 Likes

Hey @monty_python

Yeah, I was reading your first post and later realized you answered.

That’s what we have mostly been using internally. As well as as project.folder.

You could get to them via parent. or through an extension using the ext. shortcut as well.

Best,
Michel

Sorry @JetXS - I forgot to mark it as solved :slight_smile: