Skip to content

Commit

Permalink
Merge pull request #1707 from Glavin001/feature/executables
Browse files Browse the repository at this point in the history
Close #1687. Add Executables with Docker support
  • Loading branch information
Glavin001 committed Jun 17, 2017
2 parents 88fbdaa + 5caa236 commit 908b53c
Show file tree
Hide file tree
Showing 31 changed files with 1,690 additions and 558 deletions.
33 changes: 27 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ go:

matrix:
include:
- os: linux
dist: trusty
sudo: required
services:
- docker
env:
- ATOM_CHANNEL=stable
# - os: linux
# dist: trusty
# sudo: require
Expand Down Expand Up @@ -78,7 +85,7 @@ before_install:
git clone --depth=1 https://github.com/Linuxbrew/brew.git ~/.linuxbrew || true;
fi
# Update Homebrew
- brew update
# - brew update
- brew tap homebrew/dupes
- brew tap homebrew/versions
# Ruby language support
Expand All @@ -87,7 +94,11 @@ before_install:
- gem install htmlbeautifier
- gem install puppet-lint
# Sass language support
- gem install sass
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
gem install sass;
else
docker pull unibeautify/sass-convert;
fi
# Python language support
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo chmod 777 -R /opt/python; fi
- pip install --upgrade pip
Expand All @@ -96,10 +107,19 @@ before_install:
# SQL language support
- pip install --upgrade sqlparse
# Java, C, C++, C#, Objective-C, D, Pawn, Vala
- brew install uncrustify
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew install uncrustify;
else
docker pull unibeautify/uncrustify;
fi
# R
- brew tap homebrew/science
- brew install r
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew install r;
rscript --version;
else
docker pull unibeautify/rscript;
fi
# PHP
- brew tap homebrew/homebrew-php
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
Expand All @@ -122,11 +142,12 @@ before_install:
# - stack install stylish-haskell
# Elm
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
curl -L -o /tmp/elm-format.tgz https://github.com/avh4/elm-format/releases/download/0.2.0-alpha/elm-format-0.2.0-alpha-mac-x64.tgz;
curl -L -o /tmp/elm-format.tgz
https://github.com/avh4/elm-format/releases/download/0.7.0-exp/elm-format-0.17-0.7.0-exp-mac-x64.tgz;
tar xvzf /tmp/elm-format.tgz -C /usr/local/bin;
fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
curl -L -o /tmp/elm-format.tgz https://github.com/avh4/elm-format/releases/download/0.2.0-alpha/elm-format-0.2.0-alpha-linux-x64.tgz;
curl -L -o /tmp/elm-format.tgz https://github.com/avh4/elm-format/releases/download/0.7.0-exp/elm-format-0.17-0.7.0-exp-linux-x64.tgz;
tar xvzf /tmp/elm-format.tgz -C $HOME/.linuxbrew/bin;
fi
# OCaml
Expand Down
4 changes: 4 additions & 0 deletions README-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ Thank you.
Atom-Beautify is going to be completely rewritten with [Unibeautify](https://github.com/Unibeautify/unibeautify) at its core!
See [`unibeautify` branch](../../tree/unibeautify) for work in progress and [Issue #1174](https://github.com/Glavin001/atom-beautify/issues/1174).

### Want automated installation?

See [Issue #1678](https://github.com/Glavin001/atom-beautify/issues/1687) for a solution utilizing [Docker](https://www.docker.com/) to achieve automated installation of beautifiers which are not already preinstalled.

## Beautifiers

Some of the supported beautifiers are developed for Node.js and are automatically installed when Atom-Beautify is installed. However, other beautifiers are command-line interface (CLI) applications and require you to manually install them.
Expand Down
228 changes: 116 additions & 112 deletions README.md

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: "{build}"
os: Windows Server 2012 R2
image: Visual Studio 2017

test: off
deploy: off
Expand Down Expand Up @@ -46,9 +46,6 @@ install:
- ECHO "Filesystem root:"
- ps: "ls \"C:/\""

- ECHO "Installed SDKs:"
- ps: "ls \"C:/Program Files/Microsoft SDKs/Windows\""

- cinst atom -y
- cd %APPVEYOR_BUILD_FOLDER%
# Add Atom's bin (apm, etc) to PATH
Expand Down Expand Up @@ -116,18 +113,22 @@ install:
- where php-cs-fixer

# Uncrustify
- curl -k -L http://sourceforge.net/projects/uncrustify/files/uncrustify/uncrustify-0.61/uncrustify-0.61.3-gf65394e-win32.zip/download -o uncrustify.zip
- curl -k -L https://sourceforge.net/projects/uncrustify/files/uncrustify/uncrustify-0.65/uncrustify-0.65-win32.zip/download -o uncrustify.zip
- cinst 7zip.commandline -y
- 7za e uncrustify.zip -ouncrustify-d
- "SET PATH=%cd%\\uncrustify-d;%PATH%"
- where uncrustify

# elm-format
- curl -k -L https://github.com/avh4/elm-format/releases/download/0.2.0-alpha/elm-format-0.2.0-alpha-win-x64.zip -o elm-format.zip
- curl -k -L https://github.com/avh4/elm-format/releases/download/0.7.0-exp/elm-format-0.18-0.7.0-exp-win-i386.zip -o elm-format.zip
- 7za e elm-format.zip -oelm-format-d
- "SET PATH=%cd%\\elm-format-d;%PATH%"
- where elm-format

# Beautysh
- pip install beautysh
- where beautysh

build_script:

- cd %APPVEYOR_BUILD_FOLDER%
Expand Down
111 changes: 88 additions & 23 deletions docs/index.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#!/usr/bin/env coffee

# Dependencies
Expand All @@ -11,7 +12,10 @@ pkg = require('../package.json')
console.log('Generating options...')
beautifier = new Beautifiers()
languageOptions = beautifier.options
executableOptions = languageOptions.executables
delete languageOptions.executables
packageOptions = require('../src/config.coffee')
packageOptions.executables = executableOptions
# Build options by Beautifier
beautifiersMap = _.keyBy(beautifier.beautifiers, 'name')
languagesMap = _.keyBy(beautifier.languages.languages, 'name')
Expand Down Expand Up @@ -82,25 +86,36 @@ Handlebars.registerHelper('example-config', (key, option, options) ->

Handlebars.registerHelper('language-beautifiers-support', (languageOptions, options) ->

rows = _.map(languageOptions, (val, k) ->
name = val.title
defaultBeautifier = _.get(val, "properties.default_beautifier.default")
beautifiers = _.map(val.beautifiers, (b) ->
beautifier = beautifiersMap[b]
isDefault = b is defaultBeautifier
if beautifier.link
r = "[`#{b}`](#{beautifier.link})"
else
r = "`#{b}`"
if isDefault
r += " (Default)"
return r
)
grammars = _.map(val.grammars, (b) -> "`#{b}`")
extensions = _.map(val.extensions, (b) -> "`.#{b}`")
rows = _.chain(languageOptions)
.filter((val, k) -> k isnt "executables")
.map((val, k) ->
name = val.title
defaultBeautifier = _.get(val, "properties.default_beautifier.default")
beautifiers = _.chain(val.beautifiers)
.sortBy()
.sortBy((b) ->
beautifier = beautifiersMap[b]
isDefault = b is defaultBeautifier
return !isDefault
)
.map((b) ->
beautifier = beautifiersMap[b]
isDefault = b is defaultBeautifier
if beautifier.link
r = "[`#{b}`](#{beautifier.link})"
else
r = "`#{b}`"
if isDefault
r = "**#{r}**"
return r
)
.value()
grammars = _.map(val.grammars, (b) -> "`#{b}`")
extensions = _.map(val.extensions, (b) -> "`.#{b}`")

return "| #{name} | #{grammars.join(', ')} |#{extensions.join(', ')} | #{beautifiers.join(', ')} |"
)
return "| #{name} | #{grammars.join(', ')} |#{extensions.join(', ')} | #{beautifiers.join(', ')} |"
)
.value()
results = """
| Language | Grammars | File Extensions | Supported Beautifiers |
| --- | --- | --- | ---- |
Expand Down Expand Up @@ -148,7 +163,7 @@ Handlebars.registerHelper('language-options-support', (languageOptions, options)
Handlebars.registerHelper('beautifiers-info', (beautifiers, options) ->

###
| Beautifier | Is Pre-Installed? | Installation Instructions |
| Beautifier | Preinstalled? | Installation Instructions |
| --- | ---- |
| Pretty Diff | :white_check_mark: | N/A |
| AutoPEP8 | :x: | LINK |
Expand All @@ -157,13 +172,63 @@ Handlebars.registerHelper('beautifiers-info', (beautifiers, options) ->
rows = _.map(beautifiers, (beautifier, k) ->
name = beautifier.name
isPreInstalled = beautifier.isPreInstalled
if typeof isPreInstalled is "function"
isPreInstalled = beautifier.isPreInstalled()
link = beautifier.link
installationInstructions = if isPreInstalled then "Nothing!" else "Go to #{link} and follow the instructions."
return "| #{name} | #{if isPreInstalled then ':white_check_mark:' else ':x:'} | #{installationInstructions} |"
executables = beautifier.executables or []
hasExecutables = executables.length > 0
dockerExecutables = executables.filter((exe) -> !!exe.docker)
hasDockerExecutables = dockerExecutables.length > 0
installWithDocker = dockerExecutables.map((d) -> "- #{d.docker.image}").join('\n')

preinstalledCell = do (() ->
if isPreInstalled
":white_check_mark:"
else
if executables.length > 0
":warning: #{executables.length} executable#{if executables.length is 1 then '' else 's'}"
else
":warning: Manual installation"
)
dockerCell = do (() ->
if isPreInstalled
":ok_hand: Not necessary"
else
if hasExecutables
if dockerExecutables.length is executables.length
":white_check_mark: :100:% of executables"
else if dockerExecutables.length > 0
":warning: Only #{dockerExecutables.length} of #{executables.length} executables"
else
":x: No Docker support"
else
":construction: Not an executable"
)
installationInstructions = do (() ->
if isPreInstalled
":smiley: Nothing!"
else
if hasExecutables
executablesInstallation = ""
if hasDockerExecutables
executablesInstallation += ":whale: With [Docker](https://www.docker.com/):<br/>"
dockerExecutables.forEach((e, i) ->
executablesInstallation += "#{i+1}. Install [#{e.name or e.cmd} (`#{e.cmd}`)](#{e.homepage}) with `docker pull #{e.docker.image}`<br/>"
)
executablesInstallation += "<br/>"
executablesInstallation += ":bookmark_tabs: Manually:<br/>"
executables.forEach((e, i) ->
executablesInstallation += "#{i+1}. Install [#{e.name or e.cmd} (`#{e.cmd}`)](#{e.homepage}) by following #{e.installation}<br/>"
)
return executablesInstallation
else
":page_facing_up: Go to #{link} and follow the instructions."
)
return "| #{name} | #{preinstalledCell} | #{dockerCell} | #{installationInstructions} |"
)
results = """
| Beautifier | Is Pre-Installed? | Installation Instructions |
| --- | --- | --- |
| Beautifier | Preinstalled | [:whale: Docker](https://www.docker.com/) | Installation |
| --- | --- | --- |--- |
#{rows.join('\n')}
"""
return new Handlebars.SafeString(results)
Expand Down
Loading

0 comments on commit 908b53c

Please sign in to comment.