upydev
upydev copied to clipboard
`Watch` mode would be nice
upydev watch -fre ./src/*.py would watch for any changes in files in a project directory. If change occurred it will upload only the changed file.
I've done something similar with the 'git' integration for the SHELL-REPL modes check the gif in README: New in version 0.2.6: 'git' integration in SHELLS (SSL/Web/SERIAL): (This needs 'git' available in path, see Git)
and the Documentation for the SHELL-REPLS (SSL/Web and SERIAL)
So the device can act as a "remote" git repo, with a similar workflow. The commands I've implemented are:
- Use
git init devto initiate device repo - Use
git push devafter agit commit ..command or agit pullcommand to push the changes to the device. - Use
git log devto see the latest commit pushed to the device (git log dev -ato see all commits) - Use
git log hostto see the latest commit in the local repo - Use
git status devto see if the local repo is ahead of the device repo and track these changes - Use
git clone_devto clone the local repo into the device - Use
git repoto open the remote repo in the web browser if remote repo exists Any other git command will be echoed directly to git
The only thing to be aware is empty folders won't be pushed, so just be sure every folder has a file in it.
But You still have to type git push to push changes to board?
Yes git push dev will push local changes to the "device repo", git push will push local changes to a remote (e.g. GitHub ) if it exists.
Otherwise for this watch mode there should be some sort of demon running to check for file changes inside a directory (cwd?) (name, number of files and hashes?)
But if you want to implement this mode feel free to try/do it 👍
I'll look into this. This should work somehow like js task runners/bundlers.
Look at this: https://stackoverflow.com/a/18599427/1589989
I think I've came up with an idea on how to do this: using a log file in the cwd of the project.
The use of command upydev watch -fre cwd or similar, will create a log with with file names, hashes and number of files, so next time you do upydev put -diff will upload only the files that are different and then the log file is updated.
This could be applied to d_sync command as d_sync -diff too, it may be a bit harder but still doable.
If change occurred it will upload only the changed file.
I think there is no need to automate the upload on every change, or is there?
I may give it a go this week
Check #16
Okay, my concept was to upload immediately after file change. But that is also nice to have.
I know, but how frequent should this mode check if there are any changes? I usually tend to save the file even if I haven't finished. This would mean the file is uploaded every time I save it?
Yes. I do have an autosave enabled. So it is required, for example, 1s wait before upload, so it doesn't trigger on every character. However I do now play with React Native and it pushes changes on every character :grinning:, but works OK.