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

Automated installation of beautifiers which are not preinstalled #1687

Closed
3 tasks
Glavin001 opened this issue May 29, 2017 · 11 comments
Closed
3 tasks

Automated installation of beautifiers which are not preinstalled #1687

Glavin001 opened this issue May 29, 2017 · 11 comments

Comments

@Glavin001
Copy link
Owner

Glavin001 commented May 29, 2017

Attention

If you are viewing this issue and think it is a great idea, please vote with a 👍. Thanks in advance! Your feedback is appreciated. After all, Atom-Beautify is for you 😄 .


Problem: Some beautifiers require manual installation by users

Not all beautifiers are written in Node.js and therefore require manual installation by users.
See https://github.com/Glavin001/atom-beautify#beautifiers for list of beautifiers and support.
Some users experience issues trying to install these dependencies on their own.

Can we make this process smoother? Or could we make this process automated? Better yet, could we make this process automatic, such that if the dependency is not already installed then Atom-Beautify will detect this and install it for the user, upon request?

Yes, I think we can.

Solution: Add Docker support to Executables

Executables is a new feature being developed in this branch: https://github.com/Glavin001/atom-beautify/tree/feature/executables

Docker will allow us to abstract away most of the problems with cross-platform (i.e. Windows, Mac, Linux) installation.

Here are some useful Docker images:

Inspired by https://github.com/whalebrew/whalebrew-packages

Questions for Users

  • Can users be expected to install Docker as a requirement to opt-in to this automated installation process?
  • Can using Docker become the expected/preferred installation route such that Travis CI can switch over to Docker-only tests? It is pretty messy already with cross-platform installation in Travis CI: https://github.com/Glavin001/atom-beautify/blob/master/.travis.yml#L105-L136
  • Is a 0.5-1 second additional time for beautifying using Docker acceptable to users? In my tests using php-cs-fixer --help vs docker run -it unibeautify/php-cs-fixer --help the former ran faster, however not by much.
@Glavin001
Copy link
Owner Author

Here are the Docker images: https://hub.docker.com/u/unibeautify/
And the Git repository: https://github.com/Unibeautify/docker-beautifiers

More coming soon!

@Glavin001 Glavin001 changed the title Add Docker support to Executables Automated installation of beautifiers which are not preinstalled Jun 4, 2017
This was referenced Jun 4, 2017
@Glavin001
Copy link
Owner Author

Published to v0.30.0

kumekay added a commit to kumekay/atom-beautify that referenced this issue Jun 20, 2017
* master: (79 commits)
  Update changelog [skip ci]
  Prepare 0.30.2 release
  Fixes Glavin001#1030. Add support for alpha versions of autopep8
  Fixes Glavin001#1725. Fix version parsing of PHP executable
  Fixes Glavin001#1730. Correctly parse PHPCBF version and improve handling of Executable
  See Glavin001#1708. Re-generate documentation for Fortran file extension changes
  Prepare 0.30.1 release
  Prepare changelog for v0.30.1
  See Glavin001#1725. Update changelog
  Fixes Glavin001#1725. Improve PHP-CS-Fixer support with handling script path
  Update changelog. See Glavin001#1030.
  Fix Glavin001#1030. Autopep8 Executable did not handle older and newer versions
  Prepare 0.30.0 release
  See Glavin001#1687. Update README, remove note about Executables now that it is supported
  See Glavin001#1687. Update Changelog with info about Executables
  Add Greenkeeper badge
  See Glavin001#1687. Update README docs to include details about Executables and Docker support
  Add more dependencies to next-update and greenkeep ignore list
  See Glavin001#1687. Fix typos in Travis CI config
  See Glavin001#1687. Install Sass-convert and Uncrustify beautifiers via Docker for Linux Travis CI build
  ...

# Conflicts:
#	README.md
@ghost
Copy link

ghost commented Aug 22, 2017

hi, i have installed docker pull unibeautify/php-cs-fixer and it works when docker run unibeautify/php-cs-fixer --help , but it doesnt works as looking for which path, i never used docker before, i wonder what path should i use in the beautifiers settings. thanks in advance (and sorry if this issue was not in the scope, it was the most similar i could find)

@Glavin001
Copy link
Owner Author

Hey @JDias ! Thank you for reaching out. Could you please provide a debug.md Gist link and I'll try to help you debug the issue. See https://github.com/Glavin001/atom-beautify/blob/master/docs/troubleshooting.md

@ghost
Copy link

ghost commented Aug 22, 2017

Hi @Glavin001 , i can do that but im almost sure that is a issue related to docker.
I installed portainer and i can see that the image is not running, and i fail to make it start.

I never used docker, so im big lost.(and the provided docker install directions doesnt give nothing more than the pull command)

@Glavin001
Copy link
Owner Author

can do that but im almost sure that is a issue related to docker.

Likely. And the debug.md Gist should point to that.

I installed portainer and i can see that the image is not running, and i fail to make it start.

This is expected. The Docker container for unibeautify/php-cs-fixer (and others) will run and then exit upon completion.

I never used docker, so im big lost.(and the provided docker install directions doesnt give nothing more than the pull command)

The pull command should be all you need, and Atom-Beautify should do the rest. The debug.md should tell us where Atom-Beautify went wrong.

@ghost
Copy link

ghost commented Aug 22, 2017

Hi @Glavin001 thanks for the attention.
should i start a new issue? here is the link:

https://gist.github.com/JDias/f575266640b0b647453b0ac27bd62180

Ps: i manually added the php bin path

Maybe it was a root/non root issue? Before docker just worked with sudo, now it works without it. Dunno how the scan/probe code work and if a rerun could help.

@oxk4r01
Copy link

oxk4r01 commented Apr 7, 2018

What a nigthmare, man. I really appreciate your effort but I think it's not reasonable such difficulty to install a simple format plugin... This should work with a simple click or two... Several days trying to make it work with php, but it seems an impossible task.

@Glavin001
Copy link
Owner Author

I definitely agree. This experience is something I have been trying to improve for years. Unibeautify is a complete rewrite of Atom-Beautify with the goal to improve user experience while adding great new features.

Unfortunately, it is not so simple. The beautifiers for PHP are written in PHP, not JavaScript/Node.js. Therefore the integration is different and installation is separated using whatever package manager PHP requires. There are 4 different installation methods for PHP-CS-Fixer alone: https://github.com/FriendsOfPHP/PHP-CS-Fixer#installation
This is where I am investigating using Docker to normalize each of these various installation methods. See https://github.com/Unibeautify/docker-beautifiers

Since there are so many different user setups for external tools like PHP-CS-Fixer, Atom-Beautify has a builtin debugging tool to help us figure out what is wrong. It is almost always some kind of user error from operating system specific environment variable issues (ie. PATH not correct) to Atom-Beautify configuration.

For example, @JDias 's Gist:

2017-08-22T22:02:51.429Z - debug: [] spawn php-cs-fixer 0=fix, 1=--allow-risky=no, 2=--using-cache=no, 3=temp117722-3266-1qy1g09.444bpm0a4i.php
2017-08-22T22:02:51.512Z - debug: [] error Error: spawn php-cs-fixer ENOENT
    at exports._errnoException (util.js:1022:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Looks like the PHP-CS-Fixer does not have a configured Executable path.
The important PATH environment variable is reported in the logs as well:

2017-08-22T22:02:51.417Z - debug: [] PATH: /home/jaime/.local/share/umake/bin:/home/jaime/bin:/home/jaime/.local/bin:/home/jaime/.local/share/umake/bin:/home/jaime/bin:/home/jaime/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin

If php-cs-fixer is not found here, then there is no way for Atom-Beautify to find the program, regardless of whether it does exist somewhere.

@oxk4r01 : Please see https://github.com/Glavin001/atom-beautify/blob/master/docs/troubleshooting.md and create a Gist with your debugging information. Post a link here and we will try to help.

Also feel free to submit Pull Requests improving error messages or documentation.

@oxk4r01
Copy link

oxk4r01 commented Apr 8, 2018

Installed and "working" but the behavior is not correct. There are continuous problems with the indentation and when php and html are mixed (as in 99 % of projects occurs), the code ends completelly messed up. Not aproppiate for professional use at all (talking in therms of code formatting). I think this is an Atom's base problem, and a feature that should be addressed for the app by default, but to my knowledge, there isn't any package that could solve this question correctly. In other ides, such Netbeans, this format and beautyfying is zero problem and the results are perfect in one click. I like some of Atom's features very much (leaving appart issues such slowness and others), but the lack of implementation of basic features like this one is taking me to abandon it for basic productive reasons.

@Glavin001
Copy link
Owner Author

@oxk4r01 : Atom-Beautify does not perform any beautification, it wraps existing beautifiers in a unified experience.

See https://github.com/Glavin001/atom-beautify#language-support for language support. For PHP, two of the most populate would be:

If you are experiencing issues where the Atom-Beautify is correctly detecting PHP, however, the beautifier (PHP-CS-Fixer or PHPCBF) is not generating your desired result, I recommend you reach out to their respective GitHub pages with the links above.

If you need assistance determining if Atom-Beautify is working and which beautifier is being applied:

Please follow the issue template provided. More specifically, adding a link to the required debug.md Gist which includes debugging information that answers our most commonly asked questions.
Thank you.

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
v1.0 - Unibeautify
Awaiting triage
Development

No branches or pull requests

2 participants