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

Undo removal of run.js #866

Merged
merged 83 commits into from
Apr 27, 2022

Conversation

sigma-andex
Copy link
Contributor

Description of the change

Undo #846 since this does not work in the case of cli commands, see this comment.
Use run.mjs in the case of es modules since otherwise this will fail if "type":"module" is not set in the package.json.

Checklist:

  • Added the change to the "Unreleased" section of the changelog
  • Added some example of the new feature to the README
  • Added a test for the contribution (if applicable)

P.S.: the above checks are not compulsory to get a change merged, so you may skip them. However, taking care of them will result in less work for the maintainers and will be much appreciated 😊

Copy link
Contributor

@JordanMartinez JordanMartinez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few comments about this overall.

src/Spago/Build.hs Outdated Show resolved Hide resolved
src/Spago/Build.hs Outdated Show resolved Hide resolved
@JordanMartinez
Copy link
Contributor

Also, by reverting back to using files for run/test, we need to reopen #822. I think that issue should be tackled in a separate PR because it also affects CJS modules, too.

@sigma-andex
Copy link
Contributor Author

Also, by reverting back to using files for run/test, we need to reopen #822. I think that issue should be tackled in a separate PR because it also affects CJS modules, too.

yep makes sense. I wonder if there is a reason to use an absolute path, this problem shouldn’t happen with relative paths I guess

@JordanMartinez
Copy link
Contributor

yep makes sense. I wonder if there is a reason to use an absolute path, this problem shouldn’t happen with relative paths I guess

I'm not sure absolute paths are needed, but it seemed like it might have been needed for pulp test to work.

@f-f
Copy link
Member

f-f commented Mar 18, 2022

Also, by reverting back to using files for run/test, we need to reopen #822. I think that issue should be tackled in a separate PR because it also affects CJS modules, too.

I wouldn't like to fix a bug by introducing a regression, so I think that bug should also be fixed in this PR.
To reproduce it we just need to have a project's folder name contain a space, so it's a test that we can easily add (and the fix should be very easy too I suspect)

@sigma-andex
Copy link
Contributor Author

I wouldn't like to fix a bug by introducing a regression, so I think that bug should also be fixed in this PR.
To reproduce it we just need to have a project's folder name contain a space, so it's a test that we can easily add (and the fix should be very easy too I suspect)

Regarding tests: I think it would be also nice to have some tests for this, since it has grown now in logic. But the problem is that we would need different purescript versions and I am not sure how we would do that.
The alternative would be to refactor it and provide unit tests instead.. Do you have a proposal on how to provide some test for this whole bundling logic?

@sigma-andex
Copy link
Contributor Author

I have added the escaping of the file name with spaces, which should fix the bug. I added also two more fixes for source maps and esm format on node when bundling modules.

As it is right now, it is ready for review, but I still don't know how to write some test cases without refactoring the whole thing. Also I don't really know how to add a test for the space in file path bug.

@sigma-andex
Copy link
Contributor Author

Hi @f-f , do you have time to review this soon? It is currently blocking the v0.15.0 ecosystem update since the purescript-contrib libraries depend on spago test. Thank you! :-)

Copy link
Contributor

@JordanMartinez JordanMartinez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some general comments.

Also, I think a test can be added for #822 by changing this line to replace spago-test with spago test. However, when I did that locally, a few other tests failed, too.

CHANGELOG.md Outdated Show resolved Hide resolved
src/Spago/Build.hs Outdated Show resolved Hide resolved
src/Spago/Build.hs Outdated Show resolved Hide resolved
@thomashoneyman
Copy link
Member

Hi @f-f , do you have time to review this soon? It is currently blocking the v0.15.0 ecosystem update since the purescript-contrib libraries depend on spago test. Thank you! :-)

We can also comment out spago test temporarily in CI and only rely on spago build, switching to pulp test for the time being. After all, we need to add bower and pulp to all the contrib libraries too. That way @f-f can have some breathing room to review as he’s got a ton of things on his plate.

@JordanMartinez
Copy link
Contributor

We can also comment out spago test temporarily in CI and only rely on spago build, switching to pulp test for the time being. After all, we need to add bower and pulp to all the contrib libraries too. That way @f-f can have some breathing room to review as he’s got a ton of things on his plate.

Works for me!

src/Spago/Cmd.hs Outdated
import qualified Data.Versions as Version

-- | Get the semantic version of a command, e.g. purs --version
getCmdVersion :: Text -> RIO env (Either Text Version.SemVer)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a whole separate module only for this is a bit noisy - we usually hold all these utilities in our custom Spago.Prelude, could we move this function there?

Copy link
Contributor Author

@sigma-andex sigma-andex Mar 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this before, but then I ran into a cyclic dependency issue, that's why I had to create a separate module

CHANGELOG.md Outdated Show resolved Hide resolved
@f-f
Copy link
Member

f-f commented Mar 23, 2022

@sigma-andex a few more notes:

  • as Jordan noted, to reproduce the "space in path" bug we need to rename the test directory to have a space in it. Let's do that and see what else breaks
  • to test different purescript versions we could rework the build to be nix-based, as we're about to do in the Registry. AFAIK @thomashoneyman might have some input on this, as he's been looking at Update chameleon-transformers registry#360.
    Alternatively, and in a less disruptive way, we could install purescript 0.14, run tests, then install purescript 0.15 and run tests again. We have some setup to deal with a similar things for the psa-related tests, as we run them both with psa and without.

@JordanMartinez
Copy link
Contributor

Alternatively, and in a less disruptive way, we could install purescript 0.14, run tests, then install purescript 0.15 and run tests again. We have some setup to deal with a similar things for the psa-related tests, as we run them both with psa and without.

This sounds like the easiest way forward.

@JordanMartinez
Copy link
Contributor

@sd-yip sorry I haven't seen your PR before. Looks good to me! @JordanMartinez any comments from your side or can we merge @sd-yip 's change ?

Other than 'thanks!', nope! 😄

This change forces the `build` command's `Env` arg to have
more capabilities. For now, I've propagated
that by granting it the `HasBuildEnv`,
but that might be granting it too many
capabilities.
- checkFixture and fixPackagesDhall works regardless of the number of nested dirs used
- run and test tests run in another nested folder with space
- run, test, bundle-app/module tests remain in original positions
- run, test, bundle-app/module tests wrapped by a purs-0.15 label
@f-f
Copy link
Member

f-f commented Apr 14, 2022

Thanks @JordanMartinez for improving the diff! I'll have another look now 🙂

Copy link
Member

@f-f f-f left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great now! Thanks everyone 👏

I think this is good to merge once we figure out the NPM stuff.

@JordanMartinez
Copy link
Contributor

Ok. CI builds! 🎉 @f-f Since you previously approved this and the last thing to resolve--the NPM installation--has now been resolved, I'm going to merge this.

@JordanMartinez
Copy link
Contributor

Since the most recent commit gets rid of the metadata needed to install and runs purs via the tar download approach, CI now expects build (macOS-latest, macos, purs) and build (windows-latest, win64, purs.exe) builds to occur, which no longer exist. @f-f Not sure how that was changed last time, but just FYI.

Copy link
Member

@f-f f-f left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful, we're good to go! Thanks everyone for contributing to this 😊

@f-f f-f merged commit 678e004 into purescript:master Apr 27, 2022
@f-f
Copy link
Member

f-f commented Apr 27, 2022

I'll cut a release later today so we get to use this ASAP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants