Skip to content

Commit 6f2e2f8

Browse files
committed
Initial commit 🙈
0 parents  commit 6f2e2f8

File tree

10 files changed

+4123
-0
lines changed

10 files changed

+4123
-0
lines changed

‎.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# OS File
2+
.DS_Store
3+
4+
# Npm
5+
node_modules
6+
format.js

‎LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2017 TablePlus Software Foundation (https://tableplus.io/)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

‎README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# What is this
2+
3+
This is a TablePlus Plugin, install SQL Formatter you will have a menu `Format SQL` in main menu.
4+
5+
![menu](https://github.com/TablePlus/OpenURL/blob/master/Resource/demo.gif "menu")
6+
7+
# Support
8+
9+
TablePlus build 114 and above.
10+
11+
# Install
12+
13+
### From release
14+
15+
Download [release](https://github.com/TablePlus/sql-formatter/releases), unzip and double click on file plugin to install.
16+
17+
### Build from source
18+
19+
```
20+
git clone [email protected]:TablePlus/sql-formatter.git
21+
cd sql-formatter/SQLFormatter.tableplusplugin
22+
npm install
23+
npm run build
24+
open .
25+
```
26+
27+
# How to use
28+
29+
1. Open a SQL Query.
30+
2. Select statement.
31+
3. Menu: Plugins -> Format SQL.
32+
33+
# License
34+
35+
OpenURL is released under the MIT license. See [LICENSE](https://github.com/TablePlus/sql-formatter/blob/master/LICENSE) for details.

‎Resource/demo.gif

374 KB
Loading
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
3+
import sqlFormatter from "sql-formatter";
4+
5+
var formatSQL = function(string) {
6+
var formatterStatement = sqlFormatter.format(string);
7+
return formatterStatement;
8+
}
9+
10+
export { formatSQL };
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict';
2+
3+
import { formatSQL } from './library/helper';
4+
5+
var onRun = function(context) {
6+
// Get table in opening tab
7+
var queryEditor = context.currentQueryEditor();
8+
if (queryEditor == null) {
9+
context.alert('Error', 'No SQL Editor');
10+
return;
11+
}
12+
var range = queryEditor.currentSelectedRange();
13+
var statement = queryEditor.currentSelectedString();
14+
var formattedStatement = formatSQL(statement);
15+
queryEditor.replaceStringInRange(formattedStatement, range);
16+
};
17+
18+
global.onRun = onRun;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "SQL Formatter Plugin",
3+
"identifier": "com.tinyapp.TablePlus.SQLFormatter",
4+
"version": "1.0",
5+
"detail": "This plugin helps you format the SQL statement",
6+
"author": "TablePlus",
7+
"authorEmail": "[email protected]",
8+
"scripts": [
9+
{
10+
"location": "main",
11+
"type": "action",
12+
"shortcut": "control+i",
13+
"script": "format.js",
14+
"name": "Format SQL"
15+
}
16+
]
17+
}

0 commit comments

Comments
 (0)