@surrealdb/surql-fmt 0.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -0
- package/SECURITY.md +13 -0
- package/dist/surql-fmt-cli.js +8374 -0
- package/dist/surql-fmt.cjs +5290 -0
- package/dist/surql-fmt.d.ts +20 -0
- package/dist/surql-fmt.mjs +5288 -0
- package/package.json +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# SurrealQL Formatter
|
|
2
|
+
|
|
3
|
+
A formatter CLI and JavaScript library for formatting SurrealQL queries.
|
|
4
|
+
|
|
5
|
+
## CLI Tool
|
|
6
|
+
|
|
7
|
+
The CLI can be used as a standalone tool to format SurrealQL queries. It is usually installed globally and accessed via the `surqlfmt` command.
|
|
8
|
+
|
|
9
|
+
### Installation
|
|
10
|
+
|
|
11
|
+
The CLI tool can be installed using your preferred Node.js package manager.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g @surrealdb/surql-fmt
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Usage
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Format a single file
|
|
21
|
+
surqlfmt ./query.surql
|
|
22
|
+
|
|
23
|
+
# Check if files are formatted
|
|
24
|
+
surqlfmt --check ./src/**/*.surql
|
|
25
|
+
|
|
26
|
+
# Format from stdin
|
|
27
|
+
cat query.surql | surqlfmt --stdin
|
|
28
|
+
|
|
29
|
+
# Configure indentation and line length
|
|
30
|
+
surqlfmt --indent 4 --indent-char tab --max-line-length 120 *.surql
|
|
31
|
+
|
|
32
|
+
# Write files in-place
|
|
33
|
+
surqlfmt --write ./src/**/*.surql
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
You can use `surqlfmt --help` to see all the available options.
|
|
37
|
+
|
|
38
|
+
## Library
|
|
39
|
+
|
|
40
|
+
You can also install surql-fmt as a library to format SurrealQL queries programmatically.
|
|
41
|
+
|
|
42
|
+
### Installation
|
|
43
|
+
|
|
44
|
+
You can install surql-fmt as a library using your preferred Node.js package manager.
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install @surrealdb/surql-fmt
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Usage
|
|
51
|
+
|
|
52
|
+
You can use the `format` function to format a SurrealQL query string.
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import { format } from "@surrealdb/surql-fmt";
|
|
56
|
+
|
|
57
|
+
// Format the query with 4 spaces indentation
|
|
58
|
+
const formatted = format(query, {
|
|
59
|
+
indent: 4
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
You can also use the `formatRange` function to format a range of a SurrealQL query string.
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
// Format characters 0 to 100 of the query
|
|
67
|
+
const formatted = formatRange(query, 0, 100);
|
|
68
|
+
```
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Reporting a Vulnerability
|
|
4
|
+
|
|
5
|
+
We take the security of SurrealDB code, software, and cloud platform very
|
|
6
|
+
seriously. If you believe you have found a security vulnerability in
|
|
7
|
+
SurrealDB, we encourage you to let us know right away. We will investigate
|
|
8
|
+
all legitimate reports and do our best to quickly fix the problem.
|
|
9
|
+
|
|
10
|
+
Please report any issues or vulnerabilities to security@surrealdb.com,
|
|
11
|
+
instead of posting a public issue in GitHub. Please include the version
|
|
12
|
+
identifier, by running `surrealdb version` on the command-line, and
|
|
13
|
+
details on how the vulnerability can be exploited.
|