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

should `spago sources` include sources in spago.dhall? #287

Closed
hdgarrood opened this issue Jun 21, 2019 · 3 comments

Comments

@hdgarrood
Copy link
Contributor

commented Jun 21, 2019

Possibly related to #276.

We have nonstandard sources in some of our spago.dhall files, and we want to use pscid in our projects. At the moment we have something along the lines of this in our package.json file:

    "pscid": "set -o noglob && pscid -I $(npm run --silent sources:purs:directories | tr '\\n' ';')",
    "sources:purs": "spago sources | sed '/*.purs/!d' && echo 'web/src/purs/**/*.purs' && printf 'more-sources/**/*.purs'",
    "sources:purs:directories": "npm run --silent sources:purs | sed 's|/\\*\\*/\\*.purs||'"

so that sources:purs prints out a list of globs, sources:purs:directories strips the trailing **/*.purs, and then we use tr to join all of those directories together with ; and pass that to pscid, because pscid expects a list of directory names (not globs) separated by ;.

I would quite like to get rid of the sources:purs script and have this list of directories stored in the sources key of our spago.dhall files, but I wasn't able to come up with an easy way of getting this information out of spago.dhall without involving jq and dhall-to-json.

If spago sources could include any extra sources listed in spago.dhall this would be fairly straightforward to achieve. Perhaps it would make sense to include these only if a --with-local flag is passed or something, so as not to be a breaking change?

@f-f

This comment has been minimized.

Copy link
Member

commented Jun 21, 2019

When #273 went in I started wondering about the fact that the project sources are not returned by spago sources, and I think we should include them.

So yes, I'd say we should use the --with-local flag to add them to the output, nudge the tooling to support the new behaviour, and then switch to the new behaviour as default in some breaking release. Would purescript/purescript#3653 help in making this pain-free?

Btw I think you can incrementally improve on your current solution by exploiting Dhall's native support for JSON which just got merged to the Prelude: i.e. if it's ok for you to depend on the dhall binary then you could replace the jq + dhall-to-json pipeline with dhall + some Dhall code using this JSON stuff to pretty print the things as you wish

@hdgarrood

This comment has been minimized.

Copy link
Contributor Author

commented Jun 21, 2019

Yeah, having the compiler ignore repeated source files would definitely help. So add the flag for now, and then wait until purescript/purescript#3653 is fixed and released to make --with-local the default? That sounds good to me yeah :)

@f-f

This comment has been minimized.

Copy link
Member

commented Jul 9, 2019

Update: since v0.13.2 is out with the fix for purescript/purescript#3653 it looks like we can even skip the flag and just add the project sources here 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.