Merged master again

This commit is contained in:
Brian Bugh 2017-12-22 09:07:00 -06:00
commit c0cf53c6df
20 changed files with 344 additions and 39 deletions

19
.github/stale.yml vendored Normal file
View File

@ -0,0 +1,19 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- high priority
- pending-publication
- add-language
- add-beautifier
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. If this is still an issue, please add a comment. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false

View File

@ -92,12 +92,12 @@ before_install:
git clone --depth=1 https://github.com/Linuxbrew/brew.git ~/.linuxbrew || true; git clone --depth=1 https://github.com/Linuxbrew/brew.git ~/.linuxbrew || true;
fi fi
# Update Homebrew # Update Homebrew
# - brew update - brew update
- brew tap homebrew/dupes - brew tap homebrew/dupes
- brew tap homebrew/versions - brew tap homebrew/versions
# Ruby language support # Ruby language support
# - gem install ruby-beautify --verbose # - gem install ruby-beautify --verbose
- gem install rubocop # - gem install rubocop
- gem install htmlbeautifier - gem install htmlbeautifier
- gem install puppet-lint - gem install puppet-lint
# Sass language support # Sass language support
@ -186,3 +186,9 @@ before_install:
else else
pip install beautysh; pip install beautysh;
fi fi
# terraform
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew install terraform;
else
docker pull hashicorp/terraform;
fi

View File

@ -1,8 +1,25 @@
# Next # Next
- Fixes [#1773](https://github.com/Glavin001/atom-beautify/issues/1773) and [#793](https://github.com/Glavin001/atom-beautify/issues/793). ruby-beautify with Rubocop now respects `Exclude` settings, and properly loads inherited config files (like `~/.rubocop.yml`) - Fixes [#1773](https://github.com/Glavin001/atom-beautify/issues/1773) and [#793](https://github.com/Glavin001/atom-beautify/issues/793). ruby-beautify with Rubocop now respects `Exclude` settings, and properly loads inherited config files (like `~/.rubocop.yml`)
- See [#881](https://github.com/Glavin001/atom-beautify/issues/881). Update to Prettydiff version 2!
- ... - ...
# v0.30.9 (2017-11-22)
- Fix [#1949](https://github.com/Glavin001/atom-beautify/issues/1949): Fix beautify on save when text has not changed.
# v0.30.8 (2017-11-22)
- Fix [#1949](https://github.com/Glavin001/atom-beautify/issues/1949): Fix beautify on save when text has not changed.
# v0.30.7 (2017-11-21)
- Refactor handleSaveEvent to use onWillSave async ([#1924](https://github.com/Glavin001/atom-beautify/pull/1924), [#1895](https://github.com/Glavin001/atom-beautify/issues/1895))
# v0.30.6 (2017-10-30)
- See [#645](https://github.com/Glavin001/atom-beautify/issues/645). Add support for Terraform fmt.
- See [#881](https://github.com/Glavin001/atom-beautify/issues/881). Update to Prettydiff version 2!
- Fix for [#1888](https://github.com/Glavin001/atom-beautify/issues/1888). Allow 0 for minor and patch versions of Docker
- Add Atom-Beautify package settings menu item to Packages menu [#1869](https://github.com/Glavin001/atom-beautify/issues/1869)
- Add `.ttslua` file extension to Lua language
- Fix [#1638]. Update TypeScript Formatter dependency
- Fix [#1833] `os.tmpDir` deprecation warning
# v0.30.5 (2017-08-11) # v0.30.5 (2017-08-11)
- Fix for [#1721](https://github.com/Glavin001/atom-beautify/issues/1721). Changes required due to TextBuffer.save becoming async in Atom 1.19 - Fix for [#1721](https://github.com/Glavin001/atom-beautify/issues/1721). Changes required due to TextBuffer.save becoming async in Atom 1.19
- Fixes [#1638](https://github.com/Glavin001/atom-beautify/issues/1638). Update type-formatter and Fixes indent size not supported - Fixes [#1638](https://github.com/Glavin001/atom-beautify/issues/1638). Update type-formatter and Fixes indent size not supported

View File

@ -1,4 +1,5 @@
# :lipstick: [{{package.name}}](https://github.com/Glavin001/atom-beautify) # :lipstick: [{{package.name}}](https://github.com/Glavin001/atom-beautify)
[![apm](https://img.shields.io/apm/dm/atom-beautify.svg)](https://atom.io/packages/atom-beautify)
[![Greenkeeper badge](https://badges.greenkeeper.io/Glavin001/atom-beautify.svg)](https://greenkeeper.io/) [![Greenkeeper badge](https://badges.greenkeeper.io/Glavin001/atom-beautify.svg)](https://greenkeeper.io/)
[![GitHub issues](https://img.shields.io/github/issues/Glavin001/atom-beautify.svg?style=flat-square)](https://github.com/Glavin001/atom-beautify/issues) [![GitHub issues](https://img.shields.io/github/issues/Glavin001/atom-beautify.svg?style=flat-square)](https://github.com/Glavin001/atom-beautify/issues)
[![GitHub stars](https://img.shields.io/github/stars/Glavin001/atom-beautify.svg?style=flat-square)](https://github.com/Glavin001/atom-beautify/stargazers) [![GitHub stars](https://img.shields.io/github/stars/Glavin001/atom-beautify.svg?style=flat-square)](https://github.com/Glavin001/atom-beautify/stargazers)
@ -45,7 +46,7 @@ Atom Package: https://atom.io/packages/atom-beautify
apm install atom-beautify apm install atom-beautify
``` ```
Or Settings/Preferences ➔ Packages ➔ Search for `atom-beautify` Or Settings/Preferences ➔ Install ➔ Search for `atom-beautify`
### Important Notice: Analytics ### Important Notice: Analytics
@ -203,6 +204,8 @@ See [`docs/troubleshooting.md`](docs/troubleshooting.md).
## Contributing ## Contributing
See [`CONTRIBUTING.md`](CONTRIBUTING.md).
[See all contributors on GitHub](../../graphs/contributors). [See all contributors on GitHub](../../graphs/contributors).
Please update the [CHANGELOG.md](CHANGELOG.md), Please update the [CHANGELOG.md](CHANGELOG.md),

View File

@ -1,4 +1,5 @@
# :lipstick: [atom-beautify](https://github.com/Glavin001/atom-beautify) # :lipstick: [atom-beautify](https://github.com/Glavin001/atom-beautify)
[![apm](https://img.shields.io/apm/dm/atom-beautify.svg)](https://atom.io/packages/atom-beautify)
[![Greenkeeper badge](https://badges.greenkeeper.io/Glavin001/atom-beautify.svg)](https://greenkeeper.io/) [![Greenkeeper badge](https://badges.greenkeeper.io/Glavin001/atom-beautify.svg)](https://greenkeeper.io/)
[![GitHub issues](https://img.shields.io/github/issues/Glavin001/atom-beautify.svg?style=flat-square)](https://github.com/Glavin001/atom-beautify/issues) [![GitHub issues](https://img.shields.io/github/issues/Glavin001/atom-beautify.svg?style=flat-square)](https://github.com/Glavin001/atom-beautify/issues)
[![GitHub stars](https://img.shields.io/github/stars/Glavin001/atom-beautify.svg?style=flat-square)](https://github.com/Glavin001/atom-beautify/stargazers) [![GitHub stars](https://img.shields.io/github/stars/Glavin001/atom-beautify.svg?style=flat-square)](https://github.com/Glavin001/atom-beautify/stargazers)
@ -45,7 +46,7 @@ Atom Package: https://atom.io/packages/atom-beautify
apm install atom-beautify apm install atom-beautify
``` ```
Or Settings/Preferences ➔ Packages ➔ Search for `atom-beautify` Or Settings/Preferences ➔ Install ➔ Search for `atom-beautify`
### Important Notice: Analytics ### Important Notice: Analytics
@ -111,6 +112,7 @@ Some of the supported beautifiers are developed for Node.js and are automaticall
| SassConvert | :warning: 1 executable | :white_check_mark: :100:% of executables | :whale: With [Docker](https://www.docker.com/):<br/>1. Install [SassConvert (`sass-convert`)](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax) with `docker pull unibeautify/sass-convert`<br/><br/>:bookmark_tabs: Manually:<br/>1. Install [SassConvert (`sass-convert`)](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax) by following http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax<br/> | | SassConvert | :warning: 1 executable | :white_check_mark: :100:% of executables | :whale: With [Docker](https://www.docker.com/):<br/>1. Install [SassConvert (`sass-convert`)](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax) with `docker pull unibeautify/sass-convert`<br/><br/>:bookmark_tabs: Manually:<br/>1. Install [SassConvert (`sass-convert`)](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax) by following http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax<br/> |
| sqlformat | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to https://github.com/andialbrecht/sqlparse and follow the instructions. | | sqlformat | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to https://github.com/andialbrecht/sqlparse and follow the instructions. |
| stylish-haskell | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to https://github.com/jaspervdj/stylish-haskell and follow the instructions. | | stylish-haskell | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to https://github.com/jaspervdj/stylish-haskell and follow the instructions. |
| terraformfmt | :warning: 1 executable | :white_check_mark: :100:% of executables | :whale: With [Docker](https://www.docker.com/):<br/>1. Install [Terraform (`terraform`)](https://www.terraform.io) with `docker pull hashicorp/terraform`<br/><br/>:bookmark_tabs: Manually:<br/>1. Install [Terraform (`terraform`)](https://www.terraform.io) by following https://www.terraform.io<br/> |
| Tidy Markdown | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! | | Tidy Markdown | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! |
| TypeScript Formatter | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! | | TypeScript Formatter | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! |
| Uncrustify | :warning: 1 executable | :white_check_mark: :100:% of executables | :whale: With [Docker](https://www.docker.com/):<br/>1. Install [Uncrustify (`uncrustify`)](http://uncrustify.sourceforge.net/) with `docker pull unibeautify/uncrustify`<br/><br/>:bookmark_tabs: Manually:<br/>1. Install [Uncrustify (`uncrustify`)](http://uncrustify.sourceforge.net/) by following https://github.com/uncrustify/uncrustify<br/> | | Uncrustify | :warning: 1 executable | :white_check_mark: :100:% of executables | :whale: With [Docker](https://www.docker.com/):<br/>1. Install [Uncrustify (`uncrustify`)](http://uncrustify.sourceforge.net/) with `docker pull unibeautify/uncrustify`<br/><br/>:bookmark_tabs: Manually:<br/>1. Install [Uncrustify (`uncrustify`)](http://uncrustify.sourceforge.net/) by following https://github.com/uncrustify/uncrustify<br/> |
@ -178,6 +180,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti
| SQL | `SQL (Rails)`, `SQL` |`.sql` | **[`sqlformat`](https://github.com/andialbrecht/sqlparse)** | | SQL | `SQL (Rails)`, `SQL` |`.sql` | **[`sqlformat`](https://github.com/andialbrecht/sqlparse)** |
| SVG | `SVG` |`.svg` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** | | SVG | `SVG` |`.svg` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** |
| Swig | `HTML (Swig)`, `SWIG` |`.swig` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** | | Swig | `HTML (Swig)`, `SWIG` |`.swig` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** |
| Terraform | `Terraform` |`.tf` | **[`terraformfmt`](https://www.terraform.io/docs/commands/fmt.html)** |
| TSS | `TSS` |`.tss` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** | | TSS | `TSS` |`.tss` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** |
| Twig | `HTML (Twig)` |`.twig` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** | | Twig | `HTML (Twig)` |`.twig` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** |
| TypeScript | `TypeScript` |`.ts` | **[`TypeScript Formatter`](https://github.com/vvakame/typescript-formatter)** | | TypeScript | `TypeScript` |`.ts` | **[`TypeScript Formatter`](https://github.com/vvakame/typescript-formatter)** |
@ -316,6 +319,8 @@ See [`docs/troubleshooting.md`](docs/troubleshooting.md).
## Contributing ## Contributing
See [`CONTRIBUTING.md`](CONTRIBUTING.md).
[See all contributors on GitHub](../../graphs/contributors). [See all contributors on GitHub](../../graphs/contributors).
Please update the [CHANGELOG.md](CHANGELOG.md), Please update the [CHANGELOG.md](CHANGELOG.md),

View File

@ -98,6 +98,10 @@ install:
- cinst emacs -y - cinst emacs -y
- where emacs - where emacs
# terraform
- cinst terraform -y
- where terraform
# FIXME: Enable allowEmptyChecksums, until someone fixes the checksum issue of php # FIXME: Enable allowEmptyChecksums, until someone fixes the checksum issue of php
- choco feature enable -n allowEmptyChecksums - choco feature enable -n allowEmptyChecksums
# PHP # PHP

View File

@ -11,8 +11,6 @@ You can use [`codo`](https://github.com/coffeedoc/codo) to build your own docume
After you make a change to language or beautifier `options` you will need to update the `options.json` file that is created on install. After you make a change to language or beautifier `options` you will need to update the `options.json` file that is created on install.
```bash ```bash
# Update src/options.json file to have new/changed options
npm run postinstall
# Update documentation to include information about those options # Update documentation to include information about those options
npm run docs npm run docs
``` ```

View File

@ -368,6 +368,23 @@ Options for SassConvert executable.
2. Go into *Packages* and search for "*Atom Beautify*" package. 2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*SassConvert*" and change it to your desired configuration. 3. Find the option "*SassConvert*" and change it to your desired configuration.
##### [Terraform](#terraform)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Type**: `object`
**Description**:
Options for Terraform executable.
**How to Configure**
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*Terraform*" and change it to your desired configuration.
##### [Uncrustify](#uncrustify) ##### [Uncrustify](#uncrustify)
**Important**: This option is only configurable from within Atom Beautify's setting panel. **Important**: This option is only configurable from within Atom Beautify's setting panel.
@ -12171,6 +12188,75 @@ Maximum characters per line (0 disables) (Supported by Pretty Diff)
} }
``` ```
#### [Terraform](#terraform)
**Supported Beautifiers**: [`terraformfmt`](#terraformfmt)
| Option | terraformfmt |
| --- | --- |
| `disabled` | :white_check_mark: |
| `default_beautifier` | :white_check_mark: |
| `beautify_on_save` | :white_check_mark: |
**Description**:
Options for language Terraform
##### [Disable Beautifying Language](#disable-beautifying-language)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Type**: `boolean`
**Description**:
Disable Terraform Beautification
**How to Configure**
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*Disable Beautifying Language*" and change it to your desired configuration.
##### [Default Beautifier](#default-beautifier)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Default**: `terraformfmt`
**Type**: `string`
**Enum**: `terraformfmt`
**Description**:
Default Beautifier to be used for Terraform
**How to Configure**
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*Default Beautifier*" and change it to your desired configuration.
##### [Beautify On Save](#beautify-on-save)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Type**: `boolean`
**Description**:
Automatically beautify Terraform files on save
**How to Configure**
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*Beautify On Save*" and change it to your desired configuration.
#### [TSS](#tss) #### [TSS](#tss)
**Supported Beautifiers**: [`Pretty Diff`](#pretty-diff) **Supported Beautifiers**: [`Pretty Diff`](#pretty-diff)

View File

@ -16,3 +16,9 @@ The debugging results will be copied to your clipboard.
3. Create a file in your new Gist called `debug.md`. 3. Create a file in your new Gist called `debug.md`.
4. Paste your debugging results from Atom beautify into `debug.md` file in your Gist. 4. Paste your debugging results from Atom beautify into `debug.md` file in your Gist.
5. Add a link to your Gist in your new Issue. 5. Add a link to your Gist in your new Issue.
## Common Issues
> I receive an error when I try to install or update Atom Beautify
Run `apm clean` from your terminal, then retry

View File

@ -0,0 +1,18 @@
resource "aws_db_instance" "wordpress" {
# worng spaces # to much spaces
allocated_storage = 10
storage_type = "gp2"
engine = "mariadb"
engine_version = "10.0.24"
instance_class = "db.t2.micro"
identifier = "db-${var.env}"
name = "wordpress"
username = "wordpress"
password = "${var.wordpress_db_pass}"
db_subnet_group_name = "${aws_db_subnet_group.default.name}"
vpc_security_group_ids = ["${aws_security_group.RuleWebServerIn.id}"]
apply_immediately = true
}

View File

@ -0,0 +1,21 @@
resource "aws_db_instance" "wordpress" {
# worng spaces
# to much spaces
allocated_storage = 10
storage_type = "gp2"
engine = "mariadb"
engine_version = "10.0.24"
instance_class = "db.t2.micro"
identifier = "db-${var.env}"
name = "wordpress"
username = "wordpress"
password = "${var.wordpress_db_pass}"
db_subnet_group_name = "${aws_db_subnet_group.default.name}"
vpc_security_group_ids = ["${aws_security_group.RuleWebServerIn.id}"]
apply_immediately = true
}

View File

@ -25,6 +25,10 @@
'label': 'Debug' 'label': 'Debug'
'command': 'atom-beautify:help-debug-editor' 'command': 'atom-beautify:help-debug-editor'
} }
{
'label': 'Settings'
'command': 'atom-beautify:open-settings'
}
] ]
] ]
} }

View File

@ -1,12 +1,12 @@
{ {
"name": "atom-beautify", "name": "atom-beautify",
"main": "./src/beautify", "main": "./src/beautify",
"version": "0.30.5", "version": "0.30.9",
"private": true, "private": true,
"description": "Beautify HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, TypeScript, Coldfusion, SQL, and more in Atom", "description": "Beautify HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, TypeScript, Coldfusion, SQL, and more in Atom",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/Glavin001/atom-beautify" "url": "git@github.com:Glavin001/atom-beautify.git"
}, },
"bugs": { "bugs": {
"url": "https://github.com/Glavin001/atom-beautify/issues" "url": "https://github.com/Glavin001/atom-beautify/issues"
@ -146,10 +146,14 @@
{ {
"name": "Kamontat Chantrachirathumrong", "name": "Kamontat Chantrachirathumrong",
"url": "https://github.com/kamontat" "url": "https://github.com/kamontat"
},
{
"name": "Steven Zeck",
"url": "https://github.com/szeck87"
} }
], ],
"engines": { "engines": {
"atom": ">=1.6.0 <2.0.0" "atom": ">=1.21.0 <2.0.0"
}, },
"dependencies": { "dependencies": {
"align-yaml": "^0.1.8", "align-yaml": "^0.1.8",
@ -204,6 +208,7 @@
"atom-workspace": [ "atom-workspace": [
"atom-beautify:help-debug-editor", "atom-beautify:help-debug-editor",
"atom-beautify:beautify-editor", "atom-beautify:beautify-editor",
"atom-beautify:open-settings",
"atom-beautify:migrate-settings", "atom-beautify:migrate-settings",
"core:save", "core:save",
"core:save-as", "core:save-as",
@ -271,7 +276,8 @@
"atom-beautify:beautify-language-visualforce", "atom-beautify:beautify-language-visualforce",
"atom-beautify:beautify-language-xml", "atom-beautify:beautify-language-xml",
"atom-beautify:beautify-language-xtemplate", "atom-beautify:beautify-language-xtemplate",
"atom-beautify:beautify-language-yaml" "atom-beautify:beautify-language-yaml",
"atom-beautify:beautify-language-terraform"
], ],
".tree-view .file .name": [ ".tree-view .file .name": [
"atom-beautify:beautify-file" "atom-beautify:beautify-file"
@ -404,7 +410,9 @@
"nginx beautify", "nginx beautify",
"golang template", "golang template",
"align-yaml", "align-yaml",
"goimports" "goimports",
"terraform",
"terraformfmt"
], ],
"devDependencies": { "devDependencies": {
"coffeelint": "1.16.0" "coffeelint": "1.16.0"

View File

@ -379,7 +379,7 @@ class HybridExecutable extends Executable
homepage: "https://www.docker.com/" homepage: "https://www.docker.com/"
installation: "https://www.docker.com/get-docker" installation: "https://www.docker.com/get-docker"
version: { version: {
parse: (text) -> text.match(/version [0]*([1-9]\d*).[0]*([1-9]\d*).[0]*([1-9]\d*)/).slice(1).join('.') parse: (text) -> text.match(/version [0]*([1-9]\d*).[0]*([0-9]\d*).[0]*([0-9]\d*)/).slice(1).join('.')
} }
}) })
return @docker return @docker

View File

@ -80,6 +80,7 @@ module.exports = class Beautifiers extends EventEmitter
'marko-beautifier' 'marko-beautifier'
'formatR' 'formatR'
'beautysh' 'beautysh'
'terraformfmt'
] ]
### ###

View File

@ -0,0 +1,38 @@
###
Requires terraform installed
###
"use strict"
Beautifier = require('./beautifier')
module.exports = class Terraformfmt extends Beautifier
name: "terraformfmt"
link: "https://www.terraform.io/docs/commands/fmt.html"
options: {
Terraform: false
}
executables: [
{
name: "Terraform"
cmd: "terraform"
homepage: "https://www.terraform.io"
installation: "https://www.terraform.io"
version: {
parse: (text) -> text.match(/Terraform v(\d+\.\d+\.\d+)/)[1]
}
docker: {
image: "hashicorp/terraform"
}
}
]
beautify: (text, language, options) ->
@exe("terraform").run([
"fmt"
tempFile = @tempFile("input", text)
])
.then(=>
@readFile(tempFile)
)

View File

@ -96,9 +96,10 @@ beautify = ({ editor, onSave, language }) ->
if not text? if not text?
# Do nothing, is undefined # Do nothing, is undefined
# console.log 'beautifyCompleted' # console.log 'beautifyCompleted'
return resolve(text)
else if text instanceof Error else if text instanceof Error
showError(text) showError(text)
return reject(text) return resolve(text)
else if typeof text is "string" else if typeof text is "string"
if oldText isnt text if oldText isnt text
@ -127,15 +128,18 @@ beautify = ({ editor, onSave, language }) ->
# otherwise setScrollTop is not working, probably because the cursor # otherwise setScrollTop is not working, probably because the cursor
# addition happens asynchronously # addition happens asynchronously
setTimeout ( -> setTimeout ( ->
# console.log "setScrollTop" # console.log "setScrollTop"
setScrollTop editor, origScrollTop setScrollTop editor, origScrollTop
return resolve(text) return resolve(text)
), 0 ), 0
else
return setTimeout(() ->
resolve(text)
, 0)
else else
error = new Error("Unsupported beautification result '#{text}'.") error = new Error("Unsupported beautification result '#{text}'.")
showError(error) showError(error)
return reject(error) return resolve(text)
# else # else
# console.log "Already Beautiful!" # console.log "Already Beautiful!"
@ -506,20 +510,17 @@ debug = () ->
handleSaveEvent = -> handleSaveEvent = ->
atom.workspace.observeTextEditors (editor) -> atom.workspace.observeTextEditors (editor) ->
pendingPaths = {}
beautifyOnSaveHandler = ({path: filePath}) -> beautifyOnSaveHandler = ({path: filePath}) ->
logger.verbose('Should beautify on this save?')
if pendingPaths[filePath]
logger.verbose("Editor with file path #{filePath} already beautified!")
return
buffer = editor.getBuffer()
path ?= require('path') path ?= require('path')
# Get Grammar
grammar = editor.getGrammar().name
# Get file extension # Get file extension
fileExtension = path.extname(filePath) fileExtension = path.extname(filePath)
# Remove prefix "." (period) in fileExtension # Remove prefix "." (period) in fileExtension
fileExtension = fileExtension.substr(1) fileExtension = fileExtension.substr(1)
# Set path of buffer for unsaved files
if editor.getPath() is undefined
editor.getBuffer().setPath(filePath)
# Get Grammar from the editor
grammar = editor.getGrammar().name
# Get language # Get language
languages = beautifier.languages.getLanguages({grammar, extension: fileExtension}) languages = beautifier.languages.getLanguages({grammar, extension: fileExtension})
if languages.length < 1 if languages.length < 1
@ -535,27 +536,18 @@ handleSaveEvent = ->
beautify({editor, onSave: true}) beautify({editor, onSave: true})
.then(() -> .then(() ->
logger.verbose('Done beautifying file', filePath) logger.verbose('Done beautifying file', filePath)
if editor.isAlive() is true
logger.verbose('Saving TextEditor...')
# Store the filePath to prevent infinite looping
# When Whitespace package has option "Ensure Single Trailing Newline" enabled
# It will add a newline and keep the file from converging on a beautified form
# and saving without emitting onDidSave event, because there were no changes.
pendingPaths[filePath] = true
Promise.resolve(editor.save()).then(() ->
delete pendingPaths[filePath]
logger.verbose('Saved TextEditor.')
)
) )
.catch((error) -> .catch((error) ->
return showError(error) return showError(error)
) )
disposable = editor.onDidSave(({path : filePath}) -> disposable = editor.getBuffer().onWillSave(({path: filePath}) ->
# TODO: Implement debouncing
beautifyOnSaveHandler({path: filePath}) beautifyOnSaveHandler({path: filePath})
) )
plugin.subscriptions.add disposable plugin.subscriptions.add disposable
openSettings = ->
atom.workspace.open('atom://config/packages/atom-beautify')
getUnsupportedOptions = -> getUnsupportedOptions = ->
settings = atom.config.get('atom-beautify') settings = atom.config.get('atom-beautify')
schema = atom.config.getSchema('atom-beautify') schema = atom.config.getSchema('atom-beautify')
@ -622,6 +614,7 @@ plugin.activate = ->
@subscriptions.add handleSaveEvent() @subscriptions.add handleSaveEvent()
@subscriptions.add atom.commands.add "atom-workspace", "atom-beautify:beautify-editor", beautify @subscriptions.add atom.commands.add "atom-workspace", "atom-beautify:beautify-editor", beautify
@subscriptions.add atom.commands.add "atom-workspace", "atom-beautify:help-debug-editor", debug @subscriptions.add atom.commands.add "atom-workspace", "atom-beautify:help-debug-editor", debug
@subscriptions.add atom.commands.add "atom-workspace", "atom-beautify:open-settings", openSettings
@subscriptions.add atom.commands.add ".tree-view .file .name", "atom-beautify:beautify-file", beautifyFile @subscriptions.add atom.commands.add ".tree-view .file .name", "atom-beautify:beautify-file", beautifyFile
@subscriptions.add atom.commands.add ".tree-view .directory .name", "atom-beautify:beautify-directory", beautifyDirectory @subscriptions.add atom.commands.add ".tree-view .directory .name", "atom-beautify:beautify-directory", beautifyDirectory
@subscriptions.add atom.commands.add "atom-workspace", "atom-beautify:migrate-settings", plugin.migrateSettings @subscriptions.add atom.commands.add "atom-workspace", "atom-beautify:migrate-settings", plugin.migrateSettings

View File

@ -77,6 +77,7 @@ module.exports = class Languages
"xml" "xml"
"xtemplate" "xtemplate"
"yaml" "yaml"
"terraform"
] ]
### ###

View File

@ -0,0 +1,20 @@
module.exports = {
name: "Terraform"
namespace: "terraform"
fallback: ['js']
###
Supported Grammars
###
grammars: [
"Terraform"
]
###
Supported extensions
###
extensions: [
"tf"
]
}

View File

@ -9128,6 +9128,47 @@
} }
} }
}, },
"terraform": {
"title": "Terraform",
"type": "object",
"description": "Options for language Terraform",
"collapsed": true,
"beautifiers": [
"terraformfmt"
],
"grammars": [
"Terraform"
],
"extensions": [
"tf"
],
"properties": {
"disabled": {
"title": "Disable Beautifying Language",
"order": -3,
"type": "boolean",
"default": false,
"description": "Disable Terraform Beautification"
},
"default_beautifier": {
"title": "Default Beautifier",
"order": -2,
"type": "string",
"default": "terraformfmt",
"description": "Default Beautifier to be used for Terraform",
"enum": [
"terraformfmt"
]
},
"beautify_on_save": {
"title": "Beautify On Save",
"order": -1,
"type": "boolean",
"default": false,
"description": "Automatically beautify Terraform files on save"
}
}
},
"executables": { "executables": {
"title": "Executables", "title": "Executables",
"type": "object", "type": "object",
@ -9374,6 +9415,22 @@
"description": "Absolute path to the \"beautysh\" executable's binary/script." "description": "Absolute path to the \"beautysh\" executable's binary/script."
} }
} }
},
"terraform": {
"key": "terraform",
"title": "Terraform",
"type": "object",
"collapsed": true,
"description": "Options for Terraform executable.",
"properties": {
"path": {
"key": "path",
"title": "Binary/Script Path",
"type": "string",
"default": "",
"description": "Absolute path to the \"terraform\" executable's binary/script."
}
}
} }
} }
} }