Skip to content

Commit

Permalink
feat(*): modernise project stack
Browse files Browse the repository at this point in the history
Switch to current babel, switch to jest.

BREAKING CHANGE:
Changed major versions of tools respectively changed tools completly and
drop support for node < 6.
  • Loading branch information
ds82 committed Dec 6, 2018
1 parent 124ddef commit 59ec57a
Show file tree
Hide file tree
Showing 24 changed files with 3,773 additions and 2,411 deletions.
30 changes: 30 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 6,
browsers: ['last 4 versions', 'safari >= 7']
}
}
]
],
env: {
production: {
presets: ['minify'],
retainLines: false
}
},
plugins: [
// ['@babel/plugin-proposal-decorators', { legacy: true }],
'@babel/plugin-transform-modules-commonjs',
'@babel/plugin-transform-runtime',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-react-constant-elements',
'@babel/plugin-proposal-function-bind'
]
// ignore: ['/node_modules/(?!__mocks__|__tests__)'],
// retainLines: true
};
64 changes: 0 additions & 64 deletions .jscsrc

This file was deleted.

4 changes: 0 additions & 4 deletions .jshintrc

This file was deleted.

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8
24 changes: 11 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
sudo: false
language: node_js
cache:
directories:
- node_modules
- ~/.npm
notifications:
email: false
node_js:
- '4'
- '0.12'
- '0.10'
before_install:
- npm i -g npm@^2.0.0
- '10'
- '9'
- '8'
- '6'
before_script:
- npm prune
- yarn install --ignore-engines
script:
- yarn test
- yarn run build
after_success:
- 'curl -Lo travis_after_all.py https://git.io/travis_after_all'
- python travis_after_all.py
- 'export $(cat .to_export_back) &> /dev/null'
- npm run semantic-release
- npm run travis-deploy-once "npm run semantic-release"
branches:
except:
- "/^v\\d+\\.\\d+\\.\\d+$/"
- /^v\d+\.\d+\.\d+$/
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--install.ignore-engines true
38 changes: 0 additions & 38 deletions gulpfile.js

This file was deleted.

61 changes: 42 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
{
"name": "tiny-di",
"description": "A tini tiny dependency injection container for node/io.js applications",
"version": "0.0.0",
"version": "0.0.0-development",
"main": "dist/index.js",
"scripts": {
"prepublish": "npm run clean && npm run build && npm test",
"clean": "rimraf dist",
"test": "istanbul cover jasmine",
"test": "jest",
"test-travis": "istanbul cover jasmine && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"build": "gulp",
"watch": "gulp watch",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
"build": "babel src -d dist",
"watch": "babel src -d dist --watch",
"semantic-release": "semantic-release",
"travis-deploy-once": "travis-deploy-once"
},
"jest": {
"moduleFileExtensions": [
"js",
"jsx",
"ts",
"tsx"
],
"testMatch": [
"**/__tests__/**/*.(js|ts)?(x)",
"**/?(*.)+(spec|test).(js|ts)?(x)"
],
"testPathIgnorePatterns": [
"<rootDir>/build/",
"<rootDir>/node_modules/",
"<rootDir>/dist/"
],
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "babel-jest"
}
},
"repository": {
"type": "git",
Expand All @@ -28,23 +49,25 @@
"author": "Dennis Saenger <[email protected]>",
"license": "MIT",
"devDependencies": {
"coveralls": "2.11.4",
"@babel/cli": "7.2.0",
"@babel/core": "7.2.0",
"@babel/plugin-proposal-class-properties": "7.2.1",
"@babel/plugin-proposal-function-bind": "7.2.0",
"@babel/plugin-proposal-object-rest-spread": "7.2.0",
"@babel/plugin-transform-modules-commonjs": "7.2.0",
"@babel/plugin-transform-react-constant-elements": "7.2.0",
"@babel/plugin-transform-runtime": "7.2.0",
"@babel/preset-env": "7.2.0",
"@babel/runtime": "7.2.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "23.6.0",
"git-changelog": "0.1.8",
"grunt": "0.4.5",
"gulp": "3.9.0",
"gulp-babel": "5.2.1",
"gulp-cli": "0.3.0",
"gulp-jasmine": "2.1.0",
"gulp-rename": "1.2.2",
"gulp-sourcemaps": "1.5.2",
"istanbul": "0.3.21",
"jasmine": "2.4.1",
"proxyquire": "1.7.3",
"jest": "23.6.0",
"rimraf": "2.4.3",
"source-map-support": "0.3.2",
"semantic-release": "^4.3.5"
"semantic-release": "15",
"travis-deploy-once": "^5.0.9"
},
"dependencies": {
"babel-runtime": "5.8.25"
"@babel/polyfill": "7.0.0"
}
}
File renamed without changes.
10 changes: 4 additions & 6 deletions spec/base.spec.js → src/__tests__/base.spec.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
'use strict';

var UUT = require('../dist/base').AbstractBase;
const { AbstractBase } = require('../base');

describe('base.es6', function() {

it('should take injector & key via constructor', function() {
var injector = jasmine.createSpy('injector');
var key = jasmine.createSpy(key);
var injector = jest.fn();
var key = jest.fn();

var uut = new UUT(injector, key);
var uut = new AbstractBase(injector, key);

expect(uut.injector).toEqual(injector);
expect(uut.key).toEqual(key);
});

});
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
'use strict';

var proxy = require('proxyquire').noCallThru().noPreserveCache();

var lazyStub = {};
lazyStub.LazyBinding = jasmine.createSpy('Lazy');

var UUT = proxy('../../dist/binder/generic', {
'../binding/lazy': lazyStub
}).GenericBinder;
lazyStub.LazyBinding = jest.fn();

proxy.callThru();
jest.doMock('../../binding/lazy', () => lazyStub);
const { GenericBinder } = require('../../binder/generic');

describe('binder/generic', function() {
var uut;
var injectorSpy, key;

beforeEach(function() {
lazyStub.LazyBinding.calls.reset();
injectorSpy = jasmine.createSpyObj('injector', ['set']);
// lazyStub.LazyBinding.calls.reset();
jest.resetAllMocks();
injectorSpy = {
set: jest.fn()
};
key = 'some';

uut = new UUT(injectorSpy, key);
uut = new GenericBinder(injectorSpy, key);
});

describe('to()', function() {

it('should set object on injector with given key', function() {
var stub = jasmine.createSpy('stub');
var stub = jest.fn();

uut.to(stub);

Expand All @@ -37,11 +34,9 @@ describe('binder/generic', function() {
var result = uut.to({});
expect(result).toEqual(injectorSpy);
});

});

describe('lazy()', function() {

it('should init a lazyBinding with injector, key and path', function() {
var path = '/blubb/blah';

Expand All @@ -52,14 +47,15 @@ describe('binder/generic', function() {

it('should call set() on injector with key and LazyBinding', function() {
uut.lazy('');
expect(injectorSpy.set).toHaveBeenCalledWith(key, jasmine.any(lazyStub.LazyBinding));
expect(injectorSpy.set).toHaveBeenCalledWith(
key,
jasmine.any(lazyStub.LazyBinding)
);
});

it('should return the injector', function() {
it.only('should return the injector', function() {
var result = uut.lazy('');
expect(result).toEqual(injectorSpy);
});

});

});
Loading

0 comments on commit 59ec57a

Please sign in to comment.