diff --git a/.gitignore b/.gitignore index 344b0dc..ef13c79 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,20 @@ .nogit/ -node_modules/ + +# artifacts coverage/ public/ pages/ + +# installs +node_modules/ + +# caches .yarn/ +.cache/ +.rpt2_cache + +# builds +dist/ +dist_*/ + +# custom \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a1d614e..88889cf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,16 +1,16 @@ -# gitzone standard -image: hosttoday/ht-docker-node:npmci +# gitzone ci_default +image: registry.gitlab.com/hosttoday/ht-docker-node:npmci cache: paths: - - .npmci_cache/ - key: "$CI_BUILD_STAGE" + - .npmci_cache/ + key: '$CI_BUILD_STAGE' stages: -- security -- test -- release -- metadata + - security + - test + - release + - metadata # ==================== # security stage @@ -18,109 +18,115 @@ stages: mirror: stage: security script: - - npmci git mirror + - npmci git mirror + only: + - tags tags: - - docker - - notpriv + - lossless + - docker + - notpriv -snyk: +auditProductionDependencies: + image: registry.gitlab.com/hosttoday/ht-docker-node:npmci stage: security script: - - npmci command npm install -g snyk - - npmci command npm install --ignore-scripts - - npmci command snyk test + - npmci npm prepare + - npmci command npm install --production --ignore-scripts + - npmci command npm config set registry https://registry.npmjs.org + - npmci command npm audit --audit-level=high --only=prod --production tags: - - docker - - notpriv + - docker + allow_failure: true + +auditDevDependencies: + image: registry.gitlab.com/hosttoday/ht-docker-node:npmci + stage: security + script: + - npmci npm prepare + - npmci command npm install --ignore-scripts + - npmci command npm config set registry https://registry.npmjs.org + - npmci command npm audit --audit-level=high --only=dev + tags: + - docker + allow_failure: true # ==================== # test stage # ==================== -testLEGACY: - stage: test - script: - - npmci node install legacy - - npmci npm install - - npmci npm test - coverage: /\d+.?\d+?\%\s*coverage/ - tags: - - docker - - notpriv - allow_failure: true -testLTS: +testStable: stage: test script: - - npmci node install lts - - npmci npm install - - npmci npm test + - npmci npm prepare + - npmci node install stable + - npmci npm install + - npmci npm test coverage: /\d+.?\d+?\%\s*coverage/ tags: - - docker - - notpriv - -testSTABLE: + - docker + +testBuild: stage: test script: - - npmci node install stable - - npmci npm install - - npmci npm test + - npmci npm prepare + - npmci node install stable + - npmci npm install + - npmci command npm run build coverage: /\d+.?\d+?\%\s*coverage/ tags: - - docker - - notpriv + - docker release: stage: release script: - - npmci node install stable - - npmci npm publish + - npmci node install stable + - npmci npm publish only: - - tags + - tags tags: - - docker - - notpriv + - lossless + - docker + - notpriv # ==================== # metadata stage # ==================== codequality: stage: metadata - image: docker:stable allow_failure: true - services: - - docker:stable-dind + only: + - tags script: - - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/') - - docker run - --env SOURCE_CODE="$PWD" - --volume "$PWD":/code - --volume /var/run/docker.sock:/var/run/docker.sock - "registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code - artifacts: - paths: [codeclimate.json] + - npmci command npm install -g tslint typescript + - npmci npm prepare + - npmci npm install + - npmci command "tslint -c tslint.json ./ts/**/*.ts" tags: - - docker - - priv + - lossless + - docker + - priv trigger: stage: metadata script: - - npmci trigger + - npmci trigger only: - - tags + - tags tags: - - docker - - notpriv + - lossless + - docker + - notpriv pages: - image: hosttoday/ht-docker-node:npmci stage: metadata script: - - npmci command npm install -g typedoc typescript + - npmci node install lts + - npmci command npm install -g @gitzone/tsdoc + - npmci npm prepare - npmci npm install - - npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/ + - npmci command tsdoc tags: + - lossless - docker - notpriv only: @@ -128,15 +134,5 @@ pages: artifacts: expire_in: 1 week paths: - - public - allow_failure: true - -windowsCompatibility: - image: stefanscherer/node-windows:10-build-tools - stage: metadata - script: - - npm install & npm test - coverage: /\d+.?\d+?\%\s*coverage/ - tags: - - windows + - public allow_failure: true diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..26e9f92 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,11 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "command": "npm test", + "name": "Run npm test", + "request": "launch", + "type": "node-terminal" + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3648eaa --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,26 @@ +{ + "json.schemas": [ + { + "fileMatch": ["/npmextra.json"], + "schema": { + "type": "object", + "properties": { + "npmci": { + "type": "object", + "description": "settings for npmci" + }, + "gitzone": { + "type": "object", + "description": "settings for gitzone", + "properties": { + "projectType": { + "type": "string", + "enum": ["website", "element", "service", "npm", "wcc"] + } + } + } + } + } + } + ] +} diff --git a/npmextra.json b/npmextra.json index 193d59b..f78cb17 100644 --- a/npmextra.json +++ b/npmextra.json @@ -1,6 +1,17 @@ { + "gitzone": { + "projectType": "npm", + "module": { + "githost": "gitlab.com", + "gitscope": "pushrocks", + "gitrepo": "smartfuzzy", + "shortDescription": "search things easily", + "npmPackagename": "@pushrocks/smartfuzzy", + "license": "MIT" + } + }, "npmci": { "npmGlobalTools": [], "npmAccessLevel": "public" } -} +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 15b53fc..49b5e67 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@gitzone/tsbuild": "^2.1.27", "@gitzone/tstest": "^1.0.57", "@pushrocks/tapbundle": "^3.2.14", - "@types/node": "^10.7.1" + "@types/node": "^16.10.2" } }, "node_modules/@apiglobal/typedrequest": { @@ -1890,13 +1890,6 @@ "tsbundle": "cli.js" } }, - "node_modules/@gitzone/tsbundle/node_modules/@types/node": { - "version": "16.10.2", - "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-16.10.2.tgz", - "integrity": "sha512-zCclL4/rx+W5SQTzFs9wyvvyCwoK9QtBpratqz2IYJ3O8Umrn0m3nsTv0wQBk9sRGpvUe9CwPDrQFB10f1FIjQ==", - "dev": true, - "license": "MIT" - }, "node_modules/@gitzone/tsbundle/node_modules/rollup-plugin-sourcemaps": { "version": "0.6.3", "resolved": "https://verdaccio.lossless.one/rollup-plugin-sourcemaps/-/rollup-plugin-sourcemaps-0.6.3.tgz", @@ -3164,9 +3157,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "10.7.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.7.1.tgz", - "integrity": "sha512-EGoI4ylB/lPOaqXqtzAyL8HcgOuCtH2hkEaLmkueOYufsTFWBn4VCvlCDC2HW8Q+9iF+QVC3sxjDKQYjHQeZ9w==", + "version": "16.10.2", + "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-16.10.2.tgz", + "integrity": "sha512-zCclL4/rx+W5SQTzFs9wyvvyCwoK9QtBpratqz2IYJ3O8Umrn0m3nsTv0wQBk9sRGpvUe9CwPDrQFB10f1FIjQ==", "dev": true, "license": "MIT" }, @@ -16076,12 +16069,6 @@ "typescript": "^4.4.2" }, "dependencies": { - "@types/node": { - "version": "16.10.2", - "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-16.10.2.tgz", - "integrity": "sha512-zCclL4/rx+W5SQTzFs9wyvvyCwoK9QtBpratqz2IYJ3O8Umrn0m3nsTv0wQBk9sRGpvUe9CwPDrQFB10f1FIjQ==", - "dev": true - }, "rollup-plugin-sourcemaps": { "version": "0.6.3", "resolved": "https://verdaccio.lossless.one/rollup-plugin-sourcemaps/-/rollup-plugin-sourcemaps-0.6.3.tgz", @@ -17137,9 +17124,9 @@ "integrity": "sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==" }, "@types/node": { - "version": "10.7.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.7.1.tgz", - "integrity": "sha512-EGoI4ylB/lPOaqXqtzAyL8HcgOuCtH2hkEaLmkueOYufsTFWBn4VCvlCDC2HW8Q+9iF+QVC3sxjDKQYjHQeZ9w==", + "version": "16.10.2", + "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-16.10.2.tgz", + "integrity": "sha512-zCclL4/rx+W5SQTzFs9wyvvyCwoK9QtBpratqz2IYJ3O8Umrn0m3nsTv0wQBk9sRGpvUe9CwPDrQFB10f1FIjQ==", "dev": true }, "@types/parcel-bundler": { diff --git a/package.json b/package.json index c510d78..56fddde 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "version": "1.1.3", "private": false, "description": "fuzzy match strings against word dictionaries/arrays", - "main": "dist/index.js", - "typings": "dist/index.d.ts", + "main": "dist_ts/index.js", + "typings": "dist_ts/index.d.ts", "author": "Lossless GmbH", "license": "MIT", "scripts": { @@ -16,12 +16,27 @@ "@gitzone/tsbuild": "^2.1.27", "@gitzone/tstest": "^1.0.57", "@pushrocks/tapbundle": "^3.2.14", - "@types/node": "^10.7.1" + "@types/node": "^16.10.2" }, "dependencies": { "@pushrocks/smartpromise": "^3.1.6", "@tsclass/tsclass": "^3.0.33", "fuse.js": "^6.4.6", "leven": "^3.1.0" - } -} + }, + "browserslist": [ + "last 1 chrome versions" + ], + "files": [ + "ts/**/*", + "ts_web/**/*", + "dist/**/*", + "dist_*/**/*", + "dist_ts/**/*", + "dist_ts_web/**/*", + "assets/**/*", + "cli.js", + "npmextra.json", + "readme.md" + ] +} \ No newline at end of file diff --git a/test/test.articlesearch.ts b/test/test.articlesearch.ts index f90a48b..9d0ca8d 100644 --- a/test/test.articlesearch.ts +++ b/test/test.articlesearch.ts @@ -11,7 +11,7 @@ tap.test('should sort objects', async () => { tags: ['city', 'Europe', 'hello'], timestamp: Date.now(), featuredImageUrl: null, - url: null + url: null, }, { title: 'Washington is a great city', @@ -20,15 +20,15 @@ tap.test('should sort objects', async () => { tags: ['city', 'USA', 'hello'], timestamp: Date.now(), featuredImageUrl: null, - url: null - } + url: null, + }, ]; const testArticleSearch = new smartfuzzy.ArticleSearch(articleArray); const result = await testArticleSearch.search('USA'); console.log(result); - console.log(result[0].matches) + console.log(result[0].matches); }); tap.start(); diff --git a/test/test.objectsorter.ts b/test/test.objectsorter.ts index 2a62c63..53e95aa 100644 --- a/test/test.objectsorter.ts +++ b/test/test.objectsorter.ts @@ -11,7 +11,7 @@ tap.test('should sort objects', async () => { testObjectSorter = new smartfuzzy.ObjectSorter([ new Car('BMW'), new Car('Mercedes Benz'), - new Car('Volvo') + new Car('Volvo'), ]); const result = testObjectSorter.sort('Volvo', ['brand']); diff --git a/test/test.smartfuzzy.ts b/test/test.smartfuzzy.ts index 8bc318d..87fd459 100644 --- a/test/test.smartfuzzy.ts +++ b/test/test.smartfuzzy.ts @@ -8,7 +8,7 @@ tap.test('should create an instance of Smartfuzzy', async () => { 'Sony', 'Deutsche Bahn', 'Apple Inc.', - "Trader Joe's" + "Trader Joe's", ]); expect(testSmartfuzzy).to.be.instanceof(smartfuzzy.Smartfuzzy); }); diff --git a/ts/smartfuzzy.articlesearch.ts b/ts/smartfuzzy.articlesearch.ts index 71e67fd..53f4a9b 100644 --- a/ts/smartfuzzy.articlesearch.ts +++ b/ts/smartfuzzy.articlesearch.ts @@ -54,7 +54,7 @@ export class ArticleSearch { weight: 1, }, ], - includeMatches: true + includeMatches: true, }); this.readyDeferred.resolve(); } else { diff --git a/ts/smartfuzzy.classes.objectsorter.ts b/ts/smartfuzzy.classes.objectsorter.ts index f0066fd..21b4de1 100644 --- a/ts/smartfuzzy.classes.objectsorter.ts +++ b/ts/smartfuzzy.classes.objectsorter.ts @@ -3,7 +3,6 @@ import * as plugins from './smartfuzzy.plugins'; export class ObjectSorter { public objectDictionary: T[]; - constructor(objectDictionaryArg: T[] = []) { this.objectDictionary = objectDictionaryArg; } @@ -16,11 +15,10 @@ export class ObjectSorter { distance: 100, maxPatternLength: 32, minMatchCharLength: 1, - keys: objectKeysArg + keys: objectKeysArg, }; const fuse = new plugins.fuseJs(this.objectDictionary, fuseOptions); const result = fuse.search(stringArg); return result; } - -} \ No newline at end of file +} diff --git a/ts/smartfuzzy.classes.smartfuzzy.ts b/ts/smartfuzzy.classes.smartfuzzy.ts index c2e5492..9649947 100644 --- a/ts/smartfuzzy.classes.smartfuzzy.ts +++ b/ts/smartfuzzy.classes.smartfuzzy.ts @@ -38,7 +38,7 @@ export class Smartfuzzy { const fuseDictionary: { name: string }[] = []; for (const wordArg of this.dictionary) { fuseDictionary.push({ - name: wordArg + name: wordArg, }); } const fuseOptions = { @@ -48,13 +48,13 @@ export class Smartfuzzy { distance: 100, maxPatternLength: 32, minMatchCharLength: 1, - keys: ['name'] + keys: ['name'], }; const fuse = new plugins.fuseJs(fuseDictionary, fuseOptions); const fuzzyResult = fuse.search(stringArg); let closestMatch: string = null; - if(fuzzyResult.length > 0) { - closestMatch = fuzzyResult[0].item.name + if (fuzzyResult.length > 0) { + closestMatch = fuzzyResult[0].item.name; } return closestMatch; } diff --git a/ts/smartfuzzy.plugins.ts b/ts/smartfuzzy.plugins.ts index dbf3807..9255bad 100644 --- a/ts/smartfuzzy.plugins.ts +++ b/ts/smartfuzzy.plugins.ts @@ -1,16 +1,12 @@ // @pushrocks scope import * as smartpromise from '@pushrocks/smartpromise'; -export { - smartpromise -} +export { smartpromise }; // @tsclass scope import * as tsclass from '@tsclass/tsclass'; -export { - tsclass -} +export { tsclass }; // third party scope import leven from 'leven'; diff --git a/tslint.json b/tslint.json index 566dd3b..d4ea2e9 100644 --- a/tslint.json +++ b/tslint.json @@ -1,7 +1,17 @@ { - "extends": ["tslint:latest", "tslint-config-prettier"], - "rules": { - "semicolon": [true, "always"] + "extends": ["tslint:latest", "tslint-config-prettier"], + "rules": { + "semicolon": [true, "always"], + "no-console": false, + "ordered-imports": false, + "object-literal-sort-keys": false, + "member-ordering": { + "options":{ + "order": [ + "static-method" + ] + } } - } - \ No newline at end of file + }, + "defaultSeverity": "warning" +}