Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Synchronizing learn with curriculum during development #68

Open
Flarp opened this issue Jun 27, 2018 · 25 comments · May be fixed by #179
Open

Synchronizing learn with curriculum during development #68

Flarp opened this issue Jun 27, 2018 · 25 comments · May be fixed by #179

Comments

@Flarp
Copy link

Flarp commented Jun 27, 2018

Is your feature request related to a problem? Please describe.
On my computer, compiling learn takes several minutes (usually 5-10) and waiting this long to view a change with curriculum is just impractical when making minor adjustments.

Describe the solution you'd like
I'd like to be able to run something similar to unpacked, but there is an editor, and the learning tests (i.e buffer should be 64 bytes) can be run. It should not affect learn progress. This can be done by, when unpacking (maybe a different kind of unpack?), parsing the tests section of the challenge, and converting it to the TAP test syntax. (I have no idea how that would be repacked, however. Probably some very structured comments, like the whole<!--description--> stuff.)

Describe alternatives you've considered
Testing it normally with learn, and using the unpacked version, but using the test suite to test pre-written code.

Additional context
My computer is rather old, so this is really just a convenience thing. Maybe I'm the only one who's developing with such a slow computer, and for everyone else, running learn takes a few seconds.

Many thanks.

@anku255
Copy link
Contributor

anku255 commented Jun 28, 2018

Hi @Flarp! I have a question for you.

compiling learn takes several minutes (usually 5-10) and waiting this long to view a change with curriculum

If you make a change in curriculum repo then how do you get it to reflect in the learn repo? I currently change the files in node_modules to test the changes made in curriculum files.

@Flarp Flarp closed this as completed Jun 29, 2018
@Flarp Flarp reopened this Jun 29, 2018
@Flarp
Copy link
Author

Flarp commented Jun 29, 2018

Whoops, my bad.

@anku255

Modify the package.json file, replacing the version number of @freecodecamp/curriculum with file:/path/to/local/curriculum, an installation of the curriculum repo from Git.

@anku255
Copy link
Contributor

anku255 commented Jun 30, 2018

@Flarp Great! Thanks for the tip.

@scissorsneedfoodtoo
Copy link
Contributor

@Flarp, cool! That's way easier than modifying node_modules every time to test changes. Thanks!

@Flarp
Copy link
Author

Flarp commented Jul 2, 2018

Glad to be helpful, but does anyone have a work around for this right now, where I can run each item in curriculum independent of learn?

@ojeytonwilliams
Copy link
Contributor

Hey @Flarp while this probably isn't exactly what you're after, hopefully it helps.

You can avoid rebuilding learn by editing the Gatsby cache directly.

First off get learn running via yarn develop. That should populate learn's .cache/json directory with the challenge data. Once you've found the file you want, you can just copy over any changes you want from curriculum and they'll appear when you reload that page.

@Flarp
Copy link
Author

Flarp commented Jul 12, 2018

@ojeytonwilliams That should do it, I'll test that out soon (either tonight or tomorrow) and fill you in on how it goes, thank you!

@ojeytonwilliams
Copy link
Contributor

@Flarp you're very welcome! Definitely let me know how it goes.

@Flarp
Copy link
Author

Flarp commented Jul 13, 2018

@ojeytonwilliams It works wonders! Thank you so much!

@Flarp Flarp closed this as completed Jul 13, 2018
@Flarp
Copy link
Author

Flarp commented Jul 13, 2018

Actually, this doesn't solve everything, the changes in learn are not reflected in curriculum, and vice versa. Also, you need to recompile if you make a new page.

@Flarp Flarp reopened this Jul 13, 2018
@ojeytonwilliams
Copy link
Contributor

@Flarp Indeed, it's far from a perfect solution. What I think would be ideal is if a change in curriculum was immediately reflected in learn. Gatsby should do this, but at the moment it's ignoring changes in curriculum.

I've been looking into this, and I'll keep you posted, but I haven't made great strides yet.

@Flarp
Copy link
Author

Flarp commented Jul 17, 2018

@ojeytonwilliams My approach would be to use require.resolve() to locate the module directory (as said above, I don't use the default node_modules dir, as it's counter-intuitive for development), and then using some form of observable on the directory with Gatsby

@ojeytonwilliams
Copy link
Contributor

@Flarp I think yarn link should do the first part of the job - as you say, you want to use a local version of curriculum.

The tricky bit is setting up the observable, but I think I'm getting there. I'm also learning a bit about Gatsby in the process.

@Flarp
Copy link
Author

Flarp commented Jul 18, 2018

https://github.com/freeCodeCamp/learn/blob/30b5516f826e98ad23daee51f2e4ed89d54c05b6/plugins/fcc-source-challenges/gatsby-node.js#L47

This line seems to already do what we want, it's simply commented out. I'll uncomment and get back to you on anything that occurs.

@Flarp
Copy link
Author

Flarp commented Jul 18, 2018

Upon uncommenting (and a lot of other minor changes throughout both learn and curriculum), I guess it was commented out due to it causing Gatsby to recompile infinitely. However, it does not update like it should.

@ojeytonwilliams
Copy link
Contributor

Indeed. The challenge plugin's a bit odd - it's based on the gatsby-source-filesystem plugin and has a few bits of redundant code and some quirks. I've managed to get something working partially, but it's not pull request ready.

Nonetheless, I'll clean up what I have tomorrow and push it to my fork, so you can take a look.

@Flarp
Copy link
Author

Flarp commented Jul 19, 2018

I'll push my fork too, show you the changes I've made

@Flarp Flarp changed the title Running without learn Synchronizing learn with curriculum during development Jul 19, 2018
@Flarp
Copy link
Author

Flarp commented Jul 19, 2018

ojeytonwilliams added a commit to ojeytonwilliams/curriculum that referenced this issue Jul 20, 2018
Rather than 'require'ing challenges this reads them with fs, so they are no longer cached.  As a
result developers will not have to restart learn to see changes in curriculum.  Also, the build:dev
script skips the expensive minification step.

ISSUES CLOSED: freeCodeCamp#68
ojeytonwilliams added a commit to ojeytonwilliams/curriculum that referenced this issue Jul 20, 2018
Rather than 'require'ing challenges, read them directly with fs, which does not cache files.  This
allows learn to watch the files and rebuild when one changes.  Also, the build:dev script skips the
expensive minification step.

ISSUES CLOSED: freeCodeCamp#68
@ojeytonwilliams
Copy link
Contributor

It looks like we were going in similar directions.
learn
and
curriculum

The key problems I encountered were that the json was being read with require, and getting cached. Also if you want to do your work in the challenges directory (rather than dist/challenges), as is reasonable, you can't just pipe any changes over to dist. If you do, then occasionally learn will read an incomplete json file and crash.

There's also weird issue with watches - Gatsby keeps trying to add them, and I've not figured out why. This doesn't break anything that I'm aware of, but it's troubling.

Finally I thought it was a nice touch using require.resolve to get the curriculum directory - much better than what I was doing!

@Flarp
Copy link
Author

Flarp commented Jul 20, 2018

A mind boggling error that came about during development was Vim creating copies of files (for saving purposes) faster than Node could read them, which caused learn to crash. I fixed this by adding the tilde (~) as a character ignored by the watcher.

You can read more about this oddity here

(This isn't reflected in my codebase because I was directly editing /dist)

I also disagree with removing the ignored options in the watcher, those files should not be reported to Gatsby when modified.

@Flarp
Copy link
Author

Flarp commented Jul 20, 2018

Most of what we're doing actually pertains to the learn repository, so this issue will be continued in the issue above.

@Flarp Flarp closed this as completed Jul 20, 2018
@ojeytonwilliams
Copy link
Contributor

ojeytonwilliams commented Jul 20, 2018 via email

@ojeytonwilliams
Copy link
Contributor

@Flarp So, I looked into this a bit more and it's a bit odd. Are you developing on a Mac, by any chance? For some reason, it seems that chokidar ignores vim's tmp files on Linux, but not on Mac. I'll make sure they're ignored regardless.

As for the rest of the files, I agree they shouldn't be reported to Gatsby, but they also shouldn't be appearing in the dist directory in the first place!

@Flarp
Copy link
Author

Flarp commented Jul 23, 2018

I am on Arch Linux, so that's strange.

@ojeytonwilliams
Copy link
Contributor

It is. Regardless, I think I've fixed the problem - by just watching .json files.

Would you mind re-opening this? The changes span both learn and curriculum after all.

@Flarp Flarp reopened this Jul 24, 2018
ojeytonwilliams added a commit to ojeytonwilliams/curriculum that referenced this issue Jul 24, 2018
Avoid caching challenges so that changes can be hotloaded into Gatsby.  Add scripts to watch
challenges and atomically copy them in the dist directory, without minification.

ISSUES CLOSED: freeCodeCamp#68
ojeytonwilliams added a commit to ojeytonwilliams/curriculum that referenced this issue Jul 24, 2018
Avoid caching challenges so that changes can be hotloaded into Gatsby.  Add scripts to watch
challenges and atomically copy them to the dist directory, without minification.

ISSUES CLOSED: freeCodeCamp#68
ojeytonwilliams added a commit to ojeytonwilliams/curriculum that referenced this issue Jul 30, 2018
Avoid caching challenges so that changes can be hotloaded into Gatsby.  Add scripts to watch
challenges and atomically copy them to the dist directory, without minification.

ISSUES CLOSED: freeCodeCamp#68
ojeytonwilliams added a commit to ojeytonwilliams/curriculum that referenced this issue Jul 30, 2018
Avoid caching challenges so that changes can be hotloaded into Gatsby.  Add scripts to watch
challenges and atomically copy them to the dist directory, without minification.

ISSUES CLOSED: freeCodeCamp#68
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants