diff --git a/.gitignore b/.gitignore index 91c0db0..ef13c79 100644 --- a/.gitignore +++ b/.gitignore @@ -15,8 +15,6 @@ node_modules/ # builds dist/ -dist_web/ -dist_serve/ -dist_ts_web/ +dist_*/ # custom \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ac532d3..9a4467e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,14 +3,14 @@ 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,21 +18,36 @@ 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 npm prepare - - npmci command npm install -g snyk - - npmci command npm install --ignore-scripts - - npmci command snyk test + - 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 + +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 @@ -41,37 +56,36 @@ snyk: testStable: stage: test script: - - npmci npm prepare - - npmci node install stable - - 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 - - priv + - docker testBuild: stage: test script: - - npmci npm prepare - - npmci node install stable - - npmci npm install - - npmci command npm run build + - 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 @@ -79,35 +93,39 @@ release: codequality: stage: metadata allow_failure: true + only: + - tags script: - 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-dbase:npmci - services: - - docker:stable-dind stage: metadata script: + - npmci node install lts - npmci command npm install -g @gitzone/tsdoc - npmci npm prepare - npmci npm install - npmci command tsdoc tags: + - lossless - docker - notpriv only: @@ -115,5 +133,5 @@ pages: artifacts: expire_in: 1 week paths: - - public + - public allow_failure: true diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..112db52 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,29 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "current file", + "type": "node", + "request": "launch", + "args": [ + "${relativeFile}" + ], + "runtimeArgs": ["-r", "@gitzone/tsrun"], + "cwd": "${workspaceRoot}", + "protocol": "inspector", + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": "test.ts", + "type": "node", + "request": "launch", + "args": [ + "test/test.ts" + ], + "runtimeArgs": ["-r", "@gitzone/tsrun"], + "cwd": "${workspaceRoot}", + "protocol": "inspector", + "internalConsoleOptions": "openOnSessionStart" + } + ] +} 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/README.md b/README.md deleted file mode 100644 index c8d3fd6..0000000 --- a/README.md +++ /dev/null @@ -1,90 +0,0 @@ -# @pushrocks/smartpromise - -simple promises and Deferred constructs - -## Availabililty and Links - -- [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartpromise) -- [gitlab.com (source)](https://gitlab.com/pushrocks/smartpromise) -- [github.com (source mirror)](https://github.com/pushrocks/smartpromise) -- [docs (typedoc)](https://pushrocks.gitlab.io/smartpromise/) - -## Status for master - -[![build status](https://gitlab.com/pushrocks/smartpromise/badges/master/build.svg)](https://gitlab.com/pushrocks/smartpromise/commits/master) -[![coverage report](https://gitlab.com/pushrocks/smartpromise/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartpromise/commits/master) -[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartpromise.svg)](https://www.npmjs.com/package/@pushrocks/smartpromise) -[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartpromise/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartpromise) -[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/) - -## Usage - -Use TypeScript for best in class instellisense. - -> Note: smartq uses native ES6 promises -> smartq does not repeat any native functions, so for things like .all() simply use Promise.all() - -```typescript -import * as q from '@pushrocks/smartpromise' - -// Deferred -// ----------------------------------------------- -let myAsyncFunction = (): Promise => { - let done = q.defer() // returns your typical Deferred object - setTimeout(() => { - done.resolve('hi') // will throw type error for other types than string as argument ;) - },6000); - - console.log(done.status) // logs "pending"; - done.promise.then(() => { - console.log(done.status) // logs "fullfilled" - console.log(done.duration) // logs the milliseconds between instantiation and fullfillment - }) - - return done.promise -} - -let myAsyncFunction2 = async () => { - let aString = await myAsyncFunction() - console.log(aString) // will log 'hi' to console -} - -myAsyncFunction2(); - - -// Resolved and Rejected promises -// ------------------------------------------------ -q.resolvedPromise(`I'll get logged to console soon`) - .then(x => { - console.log(x) - }) - -q.rejectedPromise(`what a lovely error message`) - .then(() => { - console.log('This never makes it to console') - }/*, alternatively put a reject function here */) - .catch(err => { - console.log(err) - }) - -// Promisify (typed) -// ------------------------------------------------ - -let myCallbackedFunction = (someString: string, someNumber: number, cb) => { - cb(null, someString) -} - -let myPromisedFunction = q.promisify(myCallbackFunction) -myPromisedFunction('helloThere', 2).then(x => { - console.log(x) // will log 'helloThere' to console -}) -``` - -For further information read the linked docs at the top of this readme. - -> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) -> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) - -[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com) diff --git a/package.json b/package.json index 96bbef9..1953cc1 100644 --- a/package.json +++ b/package.json @@ -29,14 +29,18 @@ "tslint-config-prettier": "^1.18.0" }, "files": [ - "ts/*", - "ts_web/*", - "dist/*", - "dist_web/*", - "dist_ts_web/*", - "assets/*", + "ts/**/*", + "ts_web/**/*", + "dist/**/*", + "dist_*/**/*", + "dist_ts/**/*", + "dist_ts_web/**/*", + "assets/**/*", "cli.js", "npmextra.json", "readme.md" + ], + "browserslist": [ + "last 1 chrome versions" ] -} +} \ No newline at end of file diff --git a/test/test.ts b/test/test.ts index 810befd..cb31047 100644 --- a/test/test.ts +++ b/test/test.ts @@ -18,12 +18,12 @@ tap.test('should let types flow through the Promise', async () => { tap.test('should map callbacks', async () => { const inputArray = ['hi', 'awesome']; - const myPromisified = async myInput => { + const myPromisified = async (myInput) => { return myInput; }; - const expectPromise = expect(smartpromise.map(inputArray, myPromisified)).to.eventually.deep.equal( - inputArray - ); + const expectPromise = expect( + smartpromise.map(inputArray, myPromisified) + ).to.eventually.deep.equal(inputArray); return expectPromise; });