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

Watch mode would be nice #9

Open
stsdc opened this issue May 2, 2020 · 10 comments
Open

Watch mode would be nice #9

stsdc opened this issue May 2, 2020 · 10 comments

Comments

@stsdc
Copy link
Contributor

stsdc commented May 2, 2020

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.

@Carglglz
Copy link
Owner

Carglglz commented May 2, 2020

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 dev to initiate device repo
  • Use git push dev after a git commit .. command or a git pull command to push the changes to the device.
  • Use git log dev to see the latest commit pushed to the device (git log dev -a to see all commits)
  • Use git log host to see the latest commit in the local repo
  • Use git status dev to see if the local repo is ahead of the device repo and track these changes
  • Use git clone_dev to clone the local repo into the device
  • Use git repo to 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.

@stsdc
Copy link
Contributor Author

stsdc commented May 2, 2020

But You still have to type git push to push changes to board?

@Carglglz
Copy link
Owner

Carglglz commented May 2, 2020

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 👍

@stsdc
Copy link
Contributor Author

stsdc commented May 2, 2020

I'll look into this. This should work somehow like js task runners/bundlers.

@stsdc
Copy link
Contributor Author

stsdc commented May 7, 2020

Look at this: https://stackoverflow.com/a/18599427/1589989

@Carglglz
Copy link
Owner

Carglglz commented May 7, 2020

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

@Carglglz
Copy link
Owner

Carglglz commented May 8, 2020

Check #16

@stsdc
Copy link
Contributor Author

stsdc commented May 12, 2020

Okay, my concept was to upload immediately after file change. But that is also nice to have.

@Carglglz
Copy link
Owner

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?

@stsdc
Copy link
Contributor Author

stsdc commented May 12, 2020

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 😀, but works OK.

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

No branches or pull requests

2 participants