Skip to content

Commit 09d3083

Browse files
author
Julian Hundeloh
committed
docs(readme.md): fix badge link
2 parents 1d187b7 + 99ed4e3 commit 09d3083

File tree

6 files changed

+2866
-87
lines changed

6 files changed

+2866
-87
lines changed

.github/workflows/dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: dev
33
on:
44
pull_request:
55
branches:
6-
- dev
6+
- master
77

88
jobs:
99
build:

.github/workflows/master.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ jobs:
1616
run: yarn install
1717
- name: yarn ci
1818
run: yarn ci
19-
- name: publish
20-
uses: actions/npm@master
21-
args: publish --access public
19+
- name: semantic release
20+
run: npx semantic-release
2221
env:
23-
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
24+
GITHUB_ACTION: true

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44
"description": "Another parser for advanced search query syntax.",
55
"main": "build/cjs/src/index.js",
66
"module": "build/esm/src/index.js",
7-
"types": "build/cjs/index.d.ts",
7+
"types": "build/cjs/src/index.d.ts",
88
"files": [
99
"src",
1010
"build"
1111
],
1212
"scripts": {
1313
"build": "ts-build . --cjs --esm --out-dir build",
14-
"ci": "npm run test && npm run build",
15-
"prepublish": "npm run ci",
14+
"ci": "yarn test && yarn build",
15+
"prepare": "yarn build",
16+
"prepublishOnly": "yarn ci",
1617
"test": "jest",
17-
"testWatch": "jest --watch"
18+
"testWatch": "jest --watch",
19+
"semantic-release": "semantic-release"
1820
},
1921
"author": "Julian Hundeloh <julian@approvals.cloud> (https://approvals.cloud)",
2022
"license": "MIT",
@@ -36,7 +38,8 @@
3638
"jest": "^24.8.0",
3739
"jest-cli": "^24.8.0",
3840
"prettier": "^1.18.2",
39-
"pretty-quick": "^1.11.1"
41+
"pretty-quick": "^1.11.1",
42+
"semantic-release": "^15.13.19"
4043
},
4144
"config": {
4245
"commitizen": {

src/index.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { getQuotePairMap } from './utils'
22

3-
// types
3+
const RESET = 'RESET'
4+
const IN_OPERAND = 'IN_OPERAND'
5+
const IN_TEXT = 'IN_TEXT'
6+
const SINGLE_QUOTE = 'SINGLE_QUOTE'
7+
const DOUBLE_QUOTE = 'DOUBLE_QUOTE'
8+
49
type State = typeof RESET | typeof IN_OPERAND | typeof IN_TEXT
510
type QuoteState = typeof RESET | typeof SINGLE_QUOTE | typeof DOUBLE_QUOTE
611
type Keyword = Exclude<string, 'exclude'>
@@ -12,13 +17,6 @@ type ParsedQuery = Record<string, any> & {
1217
exclude: Record<string, Value[]>
1318
}
1419

15-
// state tokens
16-
const RESET = 'RESET'
17-
const IN_OPERAND = 'IN_OPERAND'
18-
const IN_TEXT = 'IN_TEXT'
19-
const SINGLE_QUOTE = 'SINGLE_QUOTE'
20-
const DOUBLE_QUOTE = 'DOUBLE_QUOTE'
21-
2220
/**
2321
* AdvancedSearchQuery is a parsed search string which allows you to fetch conditions
2422
* and text being searched.
@@ -40,15 +38,14 @@ export default class AdvancedSearchQuery {
4038
}
4139

4240
/**
43-
* @param {String} str to parse e.g. 'to:me -from:joe@acme.com foobar'.
41+
* @param {String} string to parse e.g. 'to:me -from:joe@acme.com foobar'.
4442
* @param {Array} transformTextToConditions Array of functions to transform text into conditions
4543
* @returns {AdvancedSearchQuery} An instance of this class AdvancedSearchQuery.
4644
*/
4745
static parse(
48-
str?: string | null,
46+
string: string = '',
4947
transformTextToConditions: Transformer[] = []
5048
) {
51-
if (!str) str = ''
5249
const conditionArray: Condition[] = []
5350
const textSegments: TextSegment[] = []
5451

@@ -104,10 +101,10 @@ export default class AdvancedSearchQuery {
104101

105102
performReset()
106103

107-
const quotePairMap = getQuotePairMap(str)
104+
const quotePairMap = getQuotePairMap(string)
108105

109-
for (let i = 0; i < str.length; i++) {
110-
const char = str[i]
106+
for (let i = 0; i < string.length; i++) {
107+
const char = string[i]
111108
if (char === ' ') {
112109
if (inOperand()) {
113110
if (inQuote()) {

tests/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ describe('searchString', () => {
2828
expect(AdvancedSearchQuery.parse().getConditionArray()).toEqual([])
2929
expect(AdvancedSearchQuery.parse('').getConditionArray()).toEqual([])
3030
expect(AdvancedSearchQuery.parse(' ').getConditionArray()).toEqual([])
31-
expect(AdvancedSearchQuery.parse(null).getConditionArray()).toEqual([])
32-
expect(AdvancedSearchQuery.parse(null).getParsedQuery()).toEqual({
31+
expect(AdvancedSearchQuery.parse('').getConditionArray()).toEqual([])
32+
expect(AdvancedSearchQuery.parse('').getParsedQuery()).toEqual({
3333
exclude: {},
3434
})
3535
})

0 commit comments

Comments
 (0)