Skip to content

Commit

Permalink
Initial commit 🙈
Browse files Browse the repository at this point in the history
  • Loading branch information
huyphams committed Jul 9, 2018
0 parents commit 6f2e2f8
Show file tree
Hide file tree
Showing 10 changed files with 4,123 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# OS File
.DS_Store

# Npm
node_modules
format.js
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2017 TablePlus Software Foundation (https://tableplus.io/)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# What is this

This is a TablePlus Plugin, install SQL Formatter you will have a menu `Format SQL` in main menu.

![menu](https://github.com/TablePlus/OpenURL/blob/master/Resource/demo.gif "menu")

# Support

TablePlus build 114 and above.

# Install

### From release

Download [release](https://github.com/TablePlus/sql-formatter/releases), unzip and double click on file plugin to install.

### Build from source

```
git clone [email protected]:TablePlus/sql-formatter.git
cd sql-formatter/SQLFormatter.tableplusplugin
npm install
npm run build
open .
```

# How to use

1. Open a SQL Query.
2. Select statement.
3. Menu: Plugins -> Format SQL.

# License

OpenURL is released under the MIT license. See [LICENSE](https://github.com/TablePlus/sql-formatter/blob/master/LICENSE) for details.
Binary file added Resource/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions SQLFormatter.tableplusplugin/library/helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

import sqlFormatter from "sql-formatter";

var formatSQL = function(string) {
var formatterStatement = sqlFormatter.format(string);
return formatterStatement;
}

export { formatSQL };
18 changes: 18 additions & 0 deletions SQLFormatter.tableplusplugin/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

import { formatSQL } from './library/helper';

var onRun = function(context) {
// Get table in opening tab
var queryEditor = context.currentQueryEditor();
if (queryEditor == null) {
context.alert('Error', 'No SQL Editor');
return;
}
var range = queryEditor.currentSelectedRange();
var statement = queryEditor.currentSelectedString();
var formattedStatement = formatSQL(statement);
queryEditor.replaceStringInRange(formattedStatement, range);
};

global.onRun = onRun;
17 changes: 17 additions & 0 deletions SQLFormatter.tableplusplugin/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "SQL Formatter Plugin",
"identifier": "com.tinyapp.TablePlus.SQLFormatter",
"version": "1.0",
"detail": "This plugin helps you format the SQL statement",
"author": "TablePlus",
"authorEmail": "[email protected]",
"scripts": [
{
"location": "main",
"type": "action",
"shortcut": "control+i",
"script": "format.js",
"name": "Format SQL"
}
]
}
Loading

0 comments on commit 6f2e2f8

Please sign in to comment.