Skip to content

Commit

Permalink
fix: semantic-release + format
Browse files Browse the repository at this point in the history
  • Loading branch information
yann510 committed Sep 11, 2023
1 parent 0f9d647 commit 4661021
Show file tree
Hide file tree
Showing 18 changed files with 10,033 additions and 10,075 deletions.
7 changes: 1 addition & 6 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
{
"recommendations": [
"nrwl.angular-console",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"firsttris.vscode-jest-runner"
]
"recommendations": ["nrwl.angular-console", "esbenp.prettier-vscode", "dbaeumer.vscode-eslint", "firsttris.vscode-jest-runner"]
}
2 changes: 1 addition & 1 deletion apps/web-app/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/apps/web-app',
};
}
2 changes: 1 addition & 1 deletion apps/web-app/src/assets/benchmarkResults.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,4 @@
"operationsPerSecond": 345.1457845458141,
"runsSampled": 285
}
]
]
5 changes: 1 addition & 4 deletions apps/web-app/src/components/backdrop-loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ export function BackdropProgress(props: Props) {
return (
<Backdrop className={classes.backdrop} open={isLoading}>
<div className={classes.backdropContent}>
<CircularProgress
className={classes.circularProgress}
color="inherit"
/>
<CircularProgress className={classes.circularProgress} color="inherit" />
<span>{text}</span>
</div>
</Backdrop>
Expand Down
2 changes: 1 addition & 1 deletion apps/web-app/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement)
root.render(
<StrictMode>
<App />
</StrictMode>,
</StrictMode>
)

serviceWorker.register()
6 changes: 3 additions & 3 deletions apps/web-app/src/pages/benchmark-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const debouncedSearches = debounce(
lunrIndex: lunr.Index | undefined,
jsSearch: JsSearch.Search | undefined,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
flexsearch: any,
flexsearch: any
) => {
setSearchWords(tokenize(searchText))

Expand Down Expand Up @@ -87,7 +87,7 @@ const debouncedSearches = debounce(
})
}
},
200,
200
)

function BenchmarkPage(props: Props) {
Expand Down Expand Up @@ -151,7 +151,7 @@ function BenchmarkPage(props: Props) {
})),
{
keys: Object.keys(data[0]),
},
}
)
.map((x) => x.obj),
},
Expand Down
4 changes: 2 additions & 2 deletions apps/web-app/src/pages/demo-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ const debouncedSearch = debounce(
searchText: string,
data: Data[],
setSearchResults: React.Dispatch<React.SetStateAction<Data[]>>,
setSearchTime: React.Dispatch<React.SetStateAction<number>>,
setSearchTime: React.Dispatch<React.SetStateAction<number>>
) => {
const searchResults = search(data, Object.keys(data[0]), searchText)
setSearchResults(searchResults)

const endTime = performance.now()
setSearchTime(endTime - (startTime + debounceTime))
},
debounceTime,
debounceTime
)

interface Props {
Expand Down
2 changes: 1 addition & 1 deletion apps/web-app/src/serviceWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const isLocalhost = Boolean(
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.0/8 are considered localhost for IPv4.
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/),
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)
)

type Config = {
Expand Down
2 changes: 1 addition & 1 deletion apps/web-app/src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import "@testing-library/jest-dom/extend-expect"
import '@testing-library/jest-dom/extend-expect'
7 changes: 1 addition & 6 deletions apps/web-app/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": [
"node",

"@nx/react/typings/cssmodule.d.ts",
"@nx/react/typings/image.d.ts"
]
"types": ["node", "@nx/react/typings/cssmodule.d.ts", "@nx/react/typings/image.d.ts"]
},
"exclude": [
"jest.config.ts",
Expand Down
20,000 changes: 10,000 additions & 10,000 deletions benchmark/src/data.ts

Large diffs are not rendered by default.

17 changes: 5 additions & 12 deletions benchmark/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@ export interface BenchmarkResult {
const benchmarkResultPath = `${__dirname}/../../../../apps/web-app/src/assets/benchmarkResults.json`

async function main() {
const packageVersions: string[] = JSON.parse(
execSync('npm view ss-search versions --json').toString(),
)
const packageVersions: string[] = JSON.parse(execSync('npm view ss-search versions --json').toString())

let benchmarkResults: BenchmarkResult[] = existsSync(benchmarkResultPath)
? JSON.parse(readFileSync(benchmarkResultPath).toString())
: []
let benchmarkResults: BenchmarkResult[] = existsSync(benchmarkResultPath) ? JSON.parse(readFileSync(benchmarkResultPath).toString()) : []

const missingVersionsToBenchmark = difference(
packageVersions,
benchmarkResults.map((x) => x.version),
benchmarkResults.map((x) => x.version)
)

for (const version of missingVersionsToBenchmark) {
Expand All @@ -45,7 +41,7 @@ async function main() {
() => {
lib.search(data, Object.keys(data[0]), 'l o r a w e l l s Lesmuf')
},
{ minSamples: 200 },
{ minSamples: 200 }
)
// add listeners
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -58,10 +54,7 @@ async function main() {
}
benchmarkResults = [...benchmarkResults, benchmarkResult]

writeFileSync(
benchmarkResultPath,
JSON.stringify(benchmarkResults, null, 2),
)
writeFileSync(benchmarkResultPath, JSON.stringify(benchmarkResults, null, 2))

console.log(`Benchmarked version ${version} - ${event.target}`)
})
Expand Down
4 changes: 2 additions & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getJestProjects } from '@nx/jest';
import { getJestProjects } from '@nx/jest'

export default {
projects: getJestProjects(),
};
}
4 changes: 2 additions & 2 deletions jest.preset.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const nxPreset = require('@nx/jest/preset').default;
const nxPreset = require('@nx/jest/preset').default

module.exports = { ...nxPreset };
module.exports = { ...nxPreset }
34 changes: 6 additions & 28 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
"default": {
"runner": "nx-cloud",
"options": {
"cacheableOperations": [
"build",
"lint",
"test",
"e2e"
],
"cacheableOperations": ["build", "lint", "test", "e2e"],
"accessToken": "MjQ2ZjUxOTUtYWEyOS00M2I4LTg0NmUtOWZiYzY1OWFkMTUyfHJlYWQtd3JpdGU="
}
}
Expand All @@ -19,35 +14,18 @@
},
"targetDefaults": {
"build": {
"dependsOn": [
"^build"
],
"inputs": [
"production",
"^production"
]
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
},
"lint": {
"inputs": [
"default",
"{workspaceRoot}/.eslintrc.json",
"{workspaceRoot}/.eslintignore",
"{workspaceRoot}/eslint.config.js"
]
"inputs": ["default", "{workspaceRoot}/.eslintrc.json", "{workspaceRoot}/.eslintignore", "{workspaceRoot}/eslint.config.js"]
},
"test": {
"inputs": [
"default",
"^production",
"{workspaceRoot}/jest.preset.js"
]
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"]
}
},
"namedInputs": {
"default": [
"{projectRoot}/**/*",
"sharedGlobals"
],
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"production": [
"default",
"!{projectRoot}/.eslintrc.json",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"vitest": "0.32.4"
},
"release": {
"repositoryUrl": "https://github.com/yann510/ss-search",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
Expand Down
1 change: 0 additions & 1 deletion ss-search/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

module.exports = (config) => {
return {
...config,
Expand Down
8 changes: 4 additions & 4 deletions ss-search/src/lib/ss-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const convertToSearchableStrings = memoize(<T>(elements: T[] | null, sear

return value
})
.reduce((a, b) => a + b, ''),
.reduce((a, b) => a + b, '')
)
.map((x) => normalize(x))
})
Expand All @@ -57,7 +57,7 @@ export const getScore = (matchesAllSearchWords: boolean, searchWords: string[],
.sort((a, b) => b.length - a.length)
.reduce(
(remainingText, searchWord) => remainingText.replace(new RegExp(searchWord, 'gm'), ''),
searchableDataStringWithoutNonWordCharacters,
searchableDataStringWithoutNonWordCharacters
)
return round(1 - remainingTextAfterRemovingSearchWords.length / searchableDataStringWithoutNonWordCharacters.length, 4)
}
Expand All @@ -70,15 +70,15 @@ export function search<T>(
elements: T[],
searchableKeys: string[],
searchText: string,
options: { withScore: true },
options: { withScore: true }
): { element: T; score: number }[]

// Implementation signature
export function search<T>(
elements: T[],
searchableKeys: string[],
searchText: string,
options?: { withScore?: boolean },
options?: { withScore?: boolean }
): T[] | { element: T; score: number }[] {
if (!searchText) {
return elements
Expand Down

0 comments on commit 4661021

Please sign in to comment.