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

try to download the latest version of htmx during startproject #22

Closed
Tobi-De opened this issue Dec 24, 2023 · 9 comments · Fixed by #34
Closed

try to download the latest version of htmx during startproject #22

Tobi-De opened this issue Dec 24, 2023 · 9 comments · Fixed by #34

Comments

@Tobi-De
Copy link
Collaborator

Tobi-De commented Dec 24, 2023

The starter project comes with an htmx js file already. The idea is, after initializing the project, try to download and install the latest version using falco htmx. This way, in case there is a new version, the user always starts with the latest htmx version. This step is optional, so it should fails silently in case of a network error, for example.

@Tobi-De Tobi-De changed the title try to download lates version of htmx during startproject try to download the latest version of htmx during startproject Dec 25, 2023
@786raees
Copy link
Contributor

786raees commented Jan 6, 2024

@Tobi-De can you please explain this because when I see the code I think you are already doing this?

@786raees
Copy link
Contributor

786raees commented Jan 6, 2024

@Tobi-De can you please explain this because when I see the code I think you are already doing this?

Would you like to allow developers to update the HTMX version in their project simply by using the command falco htmx update after they've set up the project?

@Tobi-De
Copy link
Collaborator Author

Tobi-De commented Jan 6, 2024

@Tobi-De can you please explain this because when I see the code I think you are already doing this?

Hi @786raees , nope the current code does not do this
The start-project currently uses Django's startproject to generate a new project with the included project blueprint, and that blueprint already includes an htmx.js. Since this file comes with the blueprint, it might not always be the latest available version of htmx, so the idea is:

  • There should be some kind of update_htmx method that runs after the init_project function.
  • This method will execute falco htmx or import and run the class similar to how the reset-migration command runs the rm-migrations here.
  • If there is any kind of error, the function will fail silently, meaning it won't report any errors to the user so that start-project does not depend on the network.
  • If the command is successful, it will override the existing file in static/vendors/htmx.js with the newly downloaded file.

@Tobi-De
Copy link
Collaborator Author

Tobi-De commented Jan 6, 2024

@Tobi-De can you please explain this because when I see the code I think you are already doing this?

Would you like to allow developers to update the HTMX version in their project simply by using the command falco htmx update after they've set up the project?

Hum..., interesting that would be basically equivalent to falco htmx -o <project_name>/static/vendors/htmx.js, maybe a new script to add here but I don't think it is worth adding code for that.

@786raees
Copy link
Contributor

786raees commented Jan 6, 2024

/attempt Issue #22

@786raees
Copy link
Contributor

786raees commented Jan 6, 2024

@Tobi-De really sorry to bother you but can you please guide me on how can I test my code on local?

@Tobi-De
Copy link
Collaborator Author

Tobi-De commented Jan 6, 2024

@Tobi-De really sorry to bother you but can you please guide me on how can I test my code on local?

No worries :), what have you used to setup the project ? hatch ?

@786raees
Copy link
Contributor

786raees commented Jan 6, 2024

@Tobi-De really sorry to bother you but can you please guide me on how can I test my code on local?

No worries :), what have you used to setup the project ? hatch ?

yes

@Tobi-De
Copy link
Collaborator Author

Tobi-De commented Jan 6, 2024

If you want want to run the test suite, then simply run hatch run pytest, if you want to run tests only for the start-project command then run hatch run pytest tests/commands/test_start_project.py.

If you want to see if your changes are working, the simplest way (and that's what I've being doing) is just to run falco start-project whatever_name in a hatch shell to see if it works as expected, there is not special setup for that, just try the command directly to see if it does what you expect, if yes, and everything is working, delete the created project, commit and make a pull request.

Have I answered your question ?

Tobi-De added a commit that referenced this issue Jan 8, 2024
* Add htmx latest version support to start-project command #22

* Added functionality to try to download htmx latest version
after setting up project and added the ability to setup project with "--skip-new-version-check"
if internet is not working.

* docs: add 786raees as a contributor for code (#33)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* refactor: move everything needed for htmx update into it own method

* fix: start-project now complete when there is no internet access

* test: check if start-project can run with no internet

---------

Co-authored-by: Waqar Khan <waqarkhan1252617@gmail.com>
Co-authored-by: Waqar Khan <96701299+786raees@users.noreply.github.com>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Tobi-De added a commit that referenced this issue Jan 8, 2024
* Add htmx latest version support to start-project command #22

* Added functionality to try to download htmx latest version
after setting up project and added the ability to setup project with "--skip-new-version-check"
if internet is not working.

* docs: add 786raees as a contributor for code (#33)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* refactor: move everything needed for htmx update into it own method

* fix: start-project now complete when there is no internet access

* test: check if start-project can run with no internet

---------

Co-authored-by: Waqar Khan <waqarkhan1252617@gmail.com>
Co-authored-by: Waqar Khan <96701299+786raees@users.noreply.github.com>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants