Skip to content

Commit 42fac03

Browse files
v5.1.0 (#63)
* consume vscode extension * update languageMap * update vscode README * add vscode issue template * ignore vscode from eslint as subrepo * update NewlineMode option, remove itemCount * update demo page, readme * update vscode extension * indent ; on tenSpace * update newline short circuiting * refresh license * clean .vscode * update linesBetweenQuery logic * fix test tabbing * add empty BigQueryFormatter class * add bigquery keywords * add test file * use numeric for loop in Formatter * add BigQuery specific tests * update vscode file type * add empty HiveFormatter class * added language items and updated tests * add ref link * update vscode file type * fix case test * ♻️ * add dedupe with Set * add vscode workspace * rename linesBetweenStatements * yo code reset * move settings to util function * add format selection command * add settings to override vscode tab settings * add command to format selection * ♻️ * add error message on format fail * add SQL flavour override * rename tests to *.test.js schema * rename Formatter classes to *.formatter.ts * update README * update issue templates * update CONTRIBUTING * update vscode README * update CHANGELOG * fix plsql filename * update vscode CHANGELOG
1 parent f9d7cae commit 42fac03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+4165
-344
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
/lib
33
/dist
44
/coverage
5+
/vscode
56
webpack.*.js

.eslintrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,17 @@
99
},
1010
"rules": {
1111
"class-methods-use-this": "off",
12+
"consistent-return": "off",
1213
"curly": ["error", "all"],
1314
"eqeqeq": "warn",
1415
"func-names": "error",
16+
"import/no-extraneous-dependencies": [
17+
"error",
18+
{
19+
"devDependencies": ["test/**", "**/*.test.js", "**/*.test.ts", "vscode/src/test/**"],
20+
"packageDir": ["./"]
21+
}
22+
],
1523
"no-continue": "off",
1624
"no-param-reassign": "off",
1725
"no-plusplus": "off",

.github/ISSUE_TEMPLATE/formatting-bug-report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Formatting Bug Report
33
about: Raise an issue about the FORMATTING output
44
title: '[FORMATTING] Issue Title Here'
5-
labels: bug
5+
labels: formatting
66
assignees: ''
77
---
88

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: VSCode Bug Report
3+
about: Raise an issue with the VSCODE Extension
4+
title: '[VSCODE] Issue Title Here'
5+
labels: vscode
6+
assignees: ''
7+
---
8+
9+
**Describe the bug**
10+
A clear and concise description of what the bug is.
11+
12+
**To Reproduce**
13+
Steps to reproduce the behavior:
14+
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Usage**
27+
28+
- What SQL language(s) does this apply to? (Plese check the bottom right of your editor for the current VSCode language type)
29+
- What VSCode version are you using?
30+
- What are your currently configured VSCode settings for the `prettier-sql` extension, if relevant to the issue?
31+
32+
**Additional context**
33+
Add any other context about the problem here.

CHANGELOG.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,59 @@
11
# CHANGELOG
22

3-
## NEXT [5.0.0] : 2021-11-22
3+
## [5.1.0] : 2021-12-21
4+
5+
### Known Issues
6+
7+
- `newline: number` does not work with `[foo]`, `[` and `]` both count as 1 token each so `[foo]` would be 3 items
8+
- `array[0]` or `map[key]` do still work as they are parsed as WORD
9+
- BigQuery formatter fails a few tests (ALTER TABLE, tricky line comments) due to those tests not including valid BigQuery SQL, those tests are currently skipped
10+
11+
### Added
12+
13+
Source:
14+
15+
- consumed VSCode Extension as subrepo
16+
- added support for Hive language
17+
- added support for BigQuery language
18+
- added keyword dedupe on Formatter classes via Set
19+
20+
VSCode:
21+
22+
- added command `prettier-sql-vscode.format-selection`
23+
- Formats SQL selections
24+
- added settings to override user/workspace `tabSize` and `insertSpaces` settings
25+
- added error message on format fail
26+
- added setting to override formatting language for `sql` files when SQL flavour does not have a VSCode language ID (Microsoft PostgreSQL and MSSQL Extensions)
27+
28+
Other:
29+
30+
- demo page now deployed as git repo subtree, served from root/ (subtree of static/)
31+
32+
### Updated
33+
34+
- fixed handling of `newline` options
35+
- simplified `NewlineMode` config
36+
- fixed ; indentation when used with `semicolonNewline` and `tenSpace` configs
37+
- Formatter now uses numeric for loop to allow for index manipulation
38+
- updated `linesBetweenQueries` to add an extra newline (0 lines = 1 line break, no space in between)
39+
- renamed Formatter class files to `<flavour>.formatter.ts`
40+
- renamed test files to `<flavour>.test.js`
41+
42+
### Removed
43+
44+
- removed `newline: hybrid` config
45+
- `newline: number` now acts like `hybrid`
46+
47+
## [5.0.1] : 2021-11-24
48+
49+
### Updated
50+
51+
- fixed bug when using SELECT \* and `denseOperators`
52+
- fixed aliasAs option on demo page
53+
- fixed handling of tokens with `aliasAs` flag
54+
- demo page now prints stack trace in textarea on error
55+
56+
## [5.0.0] : 2021-11-22
457

558
### Added
659

CONTRIBUTING.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Bugs
22

33
Please submit bugs and issues here: https://github.com/inferrinizzard/prettier-sql/issues \
4-
There are issue templates available for FORMATTING or SCRIPT related bugs.
4+
There are issue templates available for FORMATTING, SCRIPT, or VSCODE related bugs.
55

66
# Development
77

@@ -25,6 +25,7 @@ Please use one of the following prefixes: (ie. feature/new-feature)
2525

2626
- feature/ - development towards a new feature
2727
- dev/ - misc development not tied to a key feature / refactoring
28+
- vscode/ - development related to the VSCode Extension
2829
- issue/ - fix specifically for a issue #
2930
- bug/ - misc bug fixes not tied to a public issue
3031
- repo/ - meta dev related changes (ie. typescript, CI/CD, dependencies)
@@ -43,6 +44,20 @@ It can be invoked via:
4344
Please add new tests for any new features and bug fixes. \
4445
Language-specific tests should be included in their respective Test files, tests that apply to all languages should be in `behavesLikeSqlFormatter.js`
4546

47+
## VSCode
48+
49+
For development on the VSCode Extension, open the vscode/ directory as the workspace folder in VSCode and you'll be able to launch the Extension Host from the Debug menu
50+
51+
## Publish Flow
52+
53+
For those who have admin access on the repo, the new release publish flow is as such:
54+
55+
- `release-it` (bumps version, git tag, git release, npm release)
56+
- bump VSCode version + prettier-sql dependency version (can be done beforehand, must be done before push)
57+
- `git subtree push --prefix static origin gh-pages` && `gh pages deploy` (pushes demo page to GH pages)
58+
- `git dio develop` (moves origin/develop branch head to master)
59+
- `vscode deploy` (run within vscode/ subrepo, deploys VSCode Extension)
60+
4661
# Contributors
4762

4863
## `prettier-sql`

LICENSE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
The MIT License (MIT)
22

33
Copyright (c) 2016-2020 ZeroTurnaround LLC
4-
Copyright (c) 2020-present George Leslie-Waksman and other contributors
4+
Copyright (c) 2020-2021 George Leslie-Waksman and other contributors
5+
Copyright (c) 2021-Present inferrinizzard and other contributors
56

67
Permission is hereby granted, free of charge, to any person obtaining a copy
78
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<img src="static/prettier-sql-clean.svg" width="128"/>
1+
<a href='https://github.com/inferrinizzard/prettier-sql'><img src="static/prettier-sql-clean.svg" width="128"/></a>
22

33
# Prettier SQL [![NPM version](https://img.shields.io/npm/v/prettier-sql.svg)](https://npmjs.com/package/prettier-sql) ![GitHub Workflow Status (event)](https://img.shields.io/github/workflow/status/inferrinizzard/prettier-sql/coveralls/master?label=Build&logo=Github) ![Coveralls](https://img.shields.io/coveralls/github/inferrinizzard/prettier-sql?branch=master&label=Coverage&logo=coveralls&style=plastic)
44

@@ -9,12 +9,14 @@ It started as a port of a [PHP Library][], but has since considerably diverged.
99
Prettier SQL supports the following dialects:
1010

1111
- **sql** - [Standard SQL][]
12+
- **bigquery** - [GCP BigQuery][]
13+
- **db2** - [IBM DB2][]
14+
- **hive** - [Apache Hive][]
1215
- **mariadb** - [MariaDB][]
1316
- **mysql** - [MySQL][]
14-
- **postgresql** - [PostgreSQL][]
15-
- **db2** - [IBM DB2][]
16-
- **plsql** - [Oracle PL/SQL][]
1717
- **n1ql** - [Couchbase N1QL][]
18+
- **plsql** - [Oracle PL/SQL][]
19+
- **postgresql** - [PostgreSQL][]
1820
- **redshift** - [Amazon Redshift][]
1921
- **spark** - [Spark][]
2022
- **tsql** - [SQL Server Transact-SQL][tsql]
@@ -24,7 +26,7 @@ It does not support:
2426
- Stored procedures.
2527
- Changing of the delimiter type to something else than `;`.
2628

27-
[Try the demo.](https://inferrinizzard.github.io/prettier-sql/static)
29+
[Try the demo.](https://inferrinizzard.github.io/prettier-sql)
2830

2931
# Table of contents
3032

@@ -116,7 +118,7 @@ prettier-sql -h
116118

117119
```
118120
usage: sqlfmt.js [-h] [-o OUTPUT] \
119-
[-l {db2,mariadb,mysql,n1ql,plsql,postgresql,redshift,spark,sql,tsql}] [-c CONFIG] [--version] [FILE]
121+
[-l {bigquery,db2,hive,mariadb,mysql,n1ql,plsql,postgresql,redshift,spark,sql,tsql}] [-c CONFIG] [--version] [FILE]
120122
121123
Prettier SQL
122124
@@ -127,7 +129,7 @@ optional arguments:
127129
-h, --help show this help message and exit
128130
-o, --output OUTPUT
129131
File to write SQL output (defaults to stdout)
130-
-l, --language {db2,mariadb,mysql,n1ql,plsql,postgresql,redshift,spark,sql,tsql}
132+
-l, --language {bigquery,db2,hive,mariadb,mysql,n1ql,plsql,postgresql,redshift,spark,sql,tsql}
131133
SQL dialect (defaults to standard sql)
132134
-c, --config CONFIG
133135
Path to config json file (will use default configs if unspecified)
@@ -158,10 +160,7 @@ All fields are optional and all fields that are not specified will be filled wit
158160
"indent": string,
159161
"uppercase": boolean,
160162
"keywordPosition": "standard" | "tenSpaceLeft" | "tenSpaceRight",
161-
"newline": {
162-
"mode": "always" | "itemCount" | "lineWidth" | "hybrid" | "never",
163-
"itemCount"?: number // only used if newline.mode is itemCount or hybrid
164-
},
163+
"newline": "always" | "lineWidth" | "never" | number,
165164
"breakBeforeBooleanOperator": boolean,
166165
"aliasAs": "always" | "select" | "never",
167166
"tabulateAlias": boolean,
@@ -197,12 +196,14 @@ Please see [CONTRIBUTING.md](CONTRIBUTING.md)
197196

198197
[php library]: https://github.com/jdorn/sql-formatter
199198
[standard sql]: https://en.wikipedia.org/wiki/SQL:2011
200-
[couchbase n1ql]: http://www.couchbase.com/n1ql
199+
[gcp bigquery]: https://cloud.google.com/bigquery
201200
[ibm db2]: https://www.ibm.com/analytics/us/en/technology/db2/
201+
[apache hive]: https://hive.apache.org/
202+
[mariadb]: https://mariadb.com/
203+
[mysql]: https://www.mysql.com/
204+
[couchbase n1ql]: http://www.couchbase.com/n1ql
202205
[oracle pl/sql]: http://www.oracle.com/technetwork/database/features/plsql/index.html
206+
[postgresql]: https://www.postgresql.org/
203207
[amazon redshift]: https://docs.aws.amazon.com/redshift/latest/dg/cm_chap_SQLCommandRef.html
204208
[spark]: https://spark.apache.org/docs/latest/api/sql/index.html
205-
[postgresql]: https://www.postgresql.org/
206-
[mariadb]: https://mariadb.com/
207-
[mysql]: https://www.mysql.com/
208209
[tsql]: https://docs.microsoft.com/en-us/sql/sql-server/

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
"roots": [
9696
"test"
9797
],
98-
"testRegex": ".*Test",
9998
"collectCoverage": true
10099
}
101100
}

0 commit comments

Comments
 (0)