Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@adonisjs/sink

Package Overview
Dependencies
Maintainers
2
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adonisjs/sink - npm Package Compare versions

Comparing version 1.0.17 to 2.0.0

build/index.d.ts

81

package.json
{
"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
}
}

@@ -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
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc