@adonisjs/sink
Advanced tools
Comparing version 1.0.17 to 2.0.0
{ | ||
"name": "@adonisjs/sink", | ||
"version": "1.0.17", | ||
"description": "Development kitchen sink for writing adonisjs providers", | ||
"main": "index.js", | ||
"version": "2.0.0", | ||
"description": "Utilities to create AdonisJs boilerplates and custom providers", | ||
"scripts": { | ||
"lint": "standard", | ||
"mrm": "mrm --preset=@adonisjs/mrm-preset", | ||
"pretest": "npm run lint", | ||
"test:local": "node ./node_modules/.bin/japa", | ||
"test": "npm run test:local", | ||
"test:win": "node ./node_modules/japa-cli/index.js" | ||
"test": "node japaFile.js", | ||
"lint": "tslint --project tsconfig.json", | ||
"clean": "del build", | ||
"compile": "npm run lint && npm run clean && tsc", | ||
"build": "npm run compile", | ||
"commit": "git-cz", | ||
"release": "np", | ||
"version": "npm run build" | ||
}, | ||
"keywords": [ | ||
"adonisjs", | ||
"adonis-development", | ||
"adonis-tests" | ||
"mrm", | ||
"scaffold", | ||
"utils" | ||
], | ||
"author": "adonisjs, amanvirk", | ||
"author": "virk,adonisjs", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@adonisjs/dev-utils": "^1.4.0", | ||
"@adonisjs/mrm-preset": "^2.0.3", | ||
"@types/node": "^12.6.2", | ||
"commitizen": "^3.1.1", | ||
"cz-conventional-changelog": "^2.1.0", | ||
"japa": "^1.0.6", | ||
"japa-cli": "^1.0.1", | ||
"standard": "^11.0.0" | ||
"del-cli": "^2.0.0", | ||
"doctoc": "^1.4.0", | ||
"husky": "^3.0.0", | ||
"ini": "^1.3.5", | ||
"japa": "^2.0.10", | ||
"mrm": "^1.2.2", | ||
"np": "^5.0.3", | ||
"ts-node": "^8.3.0", | ||
"tslint": "^5.18.0", | ||
"tslint-eslint-rules": "^5.4.0", | ||
"typescript": "^3.5.3", | ||
"yaml": "^1.6.0" | ||
}, | ||
"dependencies": { | ||
"lodash": "^4.17.5", | ||
"pify": "^4.0.0" | ||
"nyc": { | ||
"exclude": [ | ||
"test" | ||
], | ||
"extension": [ | ||
".ts" | ||
] | ||
}, | ||
"main": "build/index.js", | ||
"files": [ | ||
"build/src", | ||
"build/index.d.ts", | ||
"build/index.js" | ||
], | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "doctoc README.md --title='## Table of contents' && git add README.md", | ||
"commit-msg": "node ./node_modules/@adonisjs/mrm-preset/validateCommit/conventional/validate.js" | ||
} | ||
}, | ||
"config": { | ||
"commitizen": { | ||
"path": "./node_modules/cz-conventional-changelog" | ||
"path": "cz-conventional-changelog" | ||
} | ||
}, | ||
"dependencies": { | ||
"mrm-core": "^3.3.0" | ||
}, | ||
"directories": { | ||
@@ -45,3 +82,11 @@ "test": "test" | ||
}, | ||
"homepage": "https://github.com/adonisjs/adonis-sink#readme" | ||
"homepage": "https://github.com/adonisjs/adonis-sink#readme", | ||
"publishConfig": { | ||
"access": "public", | ||
"tag": "next" | ||
}, | ||
"np": { | ||
"contents": ".", | ||
"anyBranch": false | ||
} | ||
} |
174
README.md
@@ -1,162 +0,56 @@ | ||
# Adonis Sink | ||
# @adonisjs/sink | ||
> A collection of utilities for creating AdonisJs packages and boilerplates. | ||
Adonis sink contains fake implementations for commonly used AdonisJs providers. You can use this package to write tests for your own providers. | ||
[![circleci-image]][circleci-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url] | ||
[![NPM Version][npm-image]][npm-url] | ||
[![Build Status][travis-image]][travis-url] | ||
[![Appveyor][appveyor-image]][appveyor-url] | ||
AdonisJs sink is a collection of file utilities to mutate the contents of a file with support for **partial updates**, automatic **commits** and **rollbacks**. | ||
<img src="http://res.cloudinary.com/adonisjs/image/upload/q_100/v1497112678/adonis-purple_pzkmzt.svg" width="200px" align="right" hspace="30px" vspace="30px"> | ||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
## Table of contents | ||
It contains fake implmentations for | ||
- [Usage](#usage) | ||
- [Maintainers](#maintainers) | ||
1. Config provider | ||
2. Helpers provider | ||
3. Logger provider | ||
4. Env provider | ||
5. Setup `adonis-fold` resolver. | ||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
## Config provider | ||
If your provider has a dependency on **Config provider**, you must use a fake implementation to write tests. | ||
## Usage | ||
Install the package from npm as follows: | ||
```sh | ||
npm i @adonisjs/sink | ||
```js | ||
const { Config } = require('@adonisjs/sink') | ||
const test = require('japa') | ||
test.group('My Package', (group) => { | ||
group.beforeEach(() => { | ||
this.config = new Config() | ||
}) | ||
test('test', () => { | ||
this.config.set('services.redis', { | ||
host: '', | ||
port: '' | ||
}) | ||
const redis = new Redis(this.config) | ||
}) | ||
}) | ||
# Yarn | ||
yarn add @adonisjs/sink | ||
``` | ||
Then inside your `Redis` class you can make use of the `Config.get` method. | ||
and then use it as follows: | ||
```js | ||
class Redis { | ||
constructor (config) { | ||
const redisConfig = config.get('services.redis') | ||
} | ||
} | ||
``` | ||
```ts | ||
import { PackageFile } from '@adonisjs/sink' | ||
## Helpers Provider | ||
Helpers provider is used to get path to certain application directories. All the methods from the actual provider are available in the fake implementation. | ||
const pkg = new PackageFile(process.cwd()) | ||
```js | ||
const { Helpers } = require('@adonisjs/sink') | ||
const test = require('japa') | ||
const path = require('path') | ||
pkg.setScript('build', 'tsc') | ||
pkg.install(['typescript', 'tslint']) | ||
test.group('My Package', (group) => { | ||
group.beforeEach(() => { | ||
this.helpers = new Helpers(path.join(__dirname, './')) | ||
}) | ||
}) | ||
pkg.commit() | ||
``` | ||
The `Helpers` provider needs the `appRoot` as the constructor argument. | ||
You will use this package when creating your own boilerplates for AdonisJs or when you want to run instructions using `instructions.ts` file. | ||
## Logger Provider | ||
Logger provider is used to log messages. The fake implementation also let you verify whether a message for a given level was logged or not. | ||
In both the places, you will get the `basePath` of the application from AdonisJs itself. | ||
```js | ||
const { Logger } = require('@adonisjs/sink') | ||
const test = require('japa') | ||
const path = require('path') | ||
## Maintainers | ||
[Harminder virk](https://github.com/thetutlage) | ||
test.group('My Package', (group) => { | ||
group.beforeEach(() => { | ||
this.logger = new Logger() | ||
}) | ||
[circleci-image]: https://img.shields.io/circleci/project/github/adonisjs/adonis-sink/master.svg?style=for-the-badge&logo=circleci | ||
[circleci-url]: https://circleci.com/gh/adonisjs/adonis-sink "circleci" | ||
test('my test', () => { | ||
const someModule = new SomeModule(this.logger) | ||
someModule.connect() | ||
[npm-image]: https://img.shields.io/npm/v/@adonisjs/sink.svg?style=for-the-badge&logo=npm | ||
[npm-url]: https://npmjs.org/package/@adonisjs/sink "npm" | ||
assert.isTrue(this.logger.has('warn', 'Consider passing 127.0.0.1 over localhost')) | ||
}) | ||
}) | ||
``` | ||
[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript | ||
And use it like this | ||
```js | ||
class SomeModule { | ||
constructor (logger) { | ||
this.logger = logger | ||
} | ||
connect () { | ||
if (this.config.host = 'localhost') { | ||
this.logger.warn('Consider passing 127.0.0.1 over localhost') | ||
} | ||
} | ||
} | ||
``` | ||
For complex message, you may use `logger.contains` over `logger.has`, since `logger.has` checks the equality of 2 strings and `logger.contains` does a sub string check. | ||
```js | ||
this.logger.debug('user profile %j', { name: 'virk' }) | ||
this.logger.contains('user profile') | ||
``` | ||
## Env Provider | ||
Also env provider can be used to read environment variables. The fake implementation doesn't load any `.env` file, whereas you can set values manually before writing tests. | ||
```js | ||
const { Env } = require('@adonisjs/sink') | ||
const env = new Env() | ||
env.set('HOST', '127.0.0.1') | ||
``` | ||
## Resolver Setup | ||
The `resolver` is an object to make namespaces and resolve values for a given namespace based upon the directory structure and autoloaded namespace. | ||
Setup of `resolver` is done before AdonisJs application boots, but at the time of writing tests, there is no application and hence you can **setup the resolver** using a pre-configured method. | ||
```js | ||
const { setupResolver } = require('@adonisjs/sink') | ||
test.group('My Package', (group) => { | ||
group.before(() => { | ||
setupResolver() | ||
}) | ||
}) | ||
``` | ||
Now your application code under the test can make use of the `adonis-fold` resolver to resolve dependencies. | ||
```js | ||
const { resolver } = require('@adonisjs/fold') | ||
resolver.for('httpControllers').resolveFunc('HomeController.render') | ||
// returns { instance: HomeController, isClosure: false, method: render } | ||
``` | ||
[appveyor-image]: https://img.shields.io/appveyor/ci/thetutlage/adonis-sink/master.svg?style=flat-square | ||
[appveyor-url]: https://ci.appveyor.com/project/thetutlage/adonis-sink | ||
[npm-image]: https://img.shields.io/npm/v/adonis-sink.svg?style=flat-square | ||
[npm-url]: https://npmjs.org/package/adonis-sink | ||
[travis-image]: https://img.shields.io/travis/adonisjs/adonis-sink/master.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/adonisjs/adonis-sink | ||
[license-url]: LICENSE.md | ||
[license-image]: https://img.shields.io/aur/license/pac.svg?style=for-the-badge |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
1
25
641
0
26703
17
57
+ Addedmrm-core@^3.3.0
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedargparse@1.0.10(transitive)
+ Addedbabel-code-frame@6.26.0(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedcomment-json@1.1.3(transitive)
+ Addeddetect-indent@5.0.0(transitive)
+ Addededitorconfig@0.15.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedesprima@2.7.34.0.1(transitive)
+ Addedesutils@2.0.3(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedfind-up@3.0.0(transitive)
+ Addedfs-extra@7.0.1(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedjs-tokens@3.0.2(transitive)
+ Addedjs-yaml@3.14.1(transitive)
+ Addedjson-parser@1.1.5(transitive)
+ Addedjsonfile@4.0.0(transitive)
+ Addedkleur@2.0.2(transitive)
+ Addedlistify@1.0.3(transitive)
+ Addedlocate-path@3.0.0(transitive)
+ Addedlru-cache@4.1.5(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmrm-core@3.3.4(transitive)
+ Addedp-limit@2.3.0(transitive)
+ Addedp-locate@3.0.0(transitive)
+ Addedp-try@2.2.0(transitive)
+ Addedpath-exists@3.0.0(transitive)
+ Addedprop-ini@0.0.2(transitive)
+ Addedpseudomap@1.0.2(transitive)
+ Addedreadme-badger@0.3.0(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedsigmund@1.0.1(transitive)
+ Addedsmpltmpl@1.0.2(transitive)
+ Addedsplit-lines@2.1.0(transitive)
+ Addedsprintf-js@1.0.3(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedstrip-bom@3.0.0(transitive)
+ Addedsupports-color@2.0.0(transitive)
+ Addeduniversalify@0.1.2(transitive)
+ Addedwebpack-merge@4.2.2(transitive)
+ Addedyallist@2.1.2(transitive)
- Removedlodash@^4.17.5
- Removedpify@^4.0.0
- Removedpify@4.0.1(transitive)