elm-git-install icon indicating copy to clipboard operation
elm-git-install copied to clipboard

Custom Source Directory

Open JesterXL opened this issue 2 years ago • 8 comments

I've managed to get elm-git-install to install a component library from Gitlab. However, it expects it to be in root/src. The idea was this Elm UI component library we're building would live in a monorepo with other tech stacks like React, documentation, etc. so it'd be in a sub-directory. I've briefly glanced at the elm-git-install source code, and it appears y'all were thinking along the same lines:

const depSources = ['src']; // Can packages have source directories?

If you look at how it installs it, it puts your repo + "/src" at the end. Before I go attempting to make a PR, I just want to make sure I have the right idea here. It appears I'd need to modify populateSources to look at opts to see if there are any custom options, and instead of hardcoding /src it'd be like opts.path + '/src' or something like that.

JesterXL avatar Mar 09 '22 17:03 JesterXL

How do you propose this path get's specified?

robinheghan avatar Mar 22 '22 09:03 robinheghan

+1. Allowing source-directories key for type package in elm.json, should be the way to go, right?

phenax avatar Jun 20 '22 12:06 phenax

The Elm compiler doesn't support source-directories in elm.json for packages.

robinheghan avatar Jun 22 '22 10:06 robinheghan

The Elm compiler doesn't support source-directories in elm.json for packages.

But with elm-git-install, the package's elm.json is never read by the compiler. In which case, elm would never get a chance to complain. Although, I guess using elm-git.json at package level with the source-directories key could work as well and it'll be less hacky.

phenax avatar Jun 22 '22 11:06 phenax

the package's elm.json is never read by the compiler

elm-git-install only downloads the relevant code. The code is still compiled by the elm compiler. Also, any time the elm compiler performs modifications (like adding a package) it strips away unsupported properties.

robinheghan avatar Jun 22 '22 11:06 robinheghan

Right. It'll make working on the package more difficult.

using elm-git.json at package level with the source-directories key could work as well

What about this?

phenax avatar Jun 22 '22 12:06 phenax

Sorry for the delay on this. I'll try to articulate my concerns this weekend.

robinheghan avatar Jun 29 '22 08:06 robinheghan

In think the way this would have to be implemented, is that elm-git.json is altered so that instead of just being an object of gitUrl -> version, it also works with gitUrl -> { path: customPath, version: version }.

This is not an ideal situation, though, as you'd have to specify it per project, but I think that's the best we can do.

robinheghan avatar Jul 06 '22 10:07 robinheghan