Skip to content

Commit e64af73

Browse files
authored
Upgraded dependencies (#15)
* upgrading dependencies * Upgraded dependencies * Removed I prefix from interfaces
1 parent e783a15 commit e64af73

36 files changed

+298
-319
lines changed

README.md

+65-49
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ An utility that allows developers to declare [InversifyJS](http://inversify.io/)
2020
You can install `inversify-binding-decorators` using npm:
2121

2222
```
23-
$ npm install --save inversify inversify-binding-decorators reflect-metadata inversify-dts
23+
$ npm install --save inversify inversify-binding-decorators reflect-metadata
24+
$ npm install --save-dev inversify-dts
2425
```
2526

2627
If you are workiong with TypeScript you will need the following `.d.ts` files:
@@ -38,22 +39,22 @@ import { injectable, Kernel } from "inversify";
3839
import "reflect-metadata";
3940

4041
@injectable()
41-
class Katana implements IKatana {
42+
class Katana implements Weapon {
4243
public hit() {
4344
return "cut!";
4445
}
4546
}
4647

4748
@injectable()
48-
class Shuriken implements IShuriken {
49+
class Shuriken implements ThrowableWeapon {
4950
public throw() {
5051
return "hit!";
5152
}
5253
}
5354

5455
var kernel = new Kernel();
55-
kernel.bind<IKatana>("IKatana").to(Katana);
56-
kernel.bind<IShuriken>("IShuriken").to(Shuriken);
56+
kernel.bind<Katana>("Katana").to(Katana);
57+
kernel.bind<Shuriken>("Shuriken").to(Shuriken);
5758
```
5859

5960
This small utility allows you to declare bindings using decorators:
@@ -67,14 +68,14 @@ var kernel = new Kernel();
6768
let provide = makeProvideDecorator(kernel);
6869

6970
@provide(Katana)
70-
class Katana implements IKatana {
71+
class Katana implements Weapon {
7172
public hit() {
7273
return "cut!";
7374
}
7475
}
7576

7677
@provide(Shuriken)
77-
class Shuriken implements IShuriken {
78+
class Shuriken implements ThrowableWeapon {
7879
public throw() {
7980
return "hit!";
8081
}
@@ -99,9 +100,9 @@ class Katana {
99100

100101
@provide(Ninja)
101102
class Ninja {
102-
private _katana: Katana;
103+
private _katana: Weapon;
103104
public constructor(
104-
katana: Katana
105+
katana: Weapon
105106
) {
106107
this._katana = katana;
107108
}
@@ -120,24 +121,24 @@ These bindings use classes as identidiers but you can also use string literals a
120121

121122
```ts
122123
let TYPE = {
123-
IKatana: "IKatana",
124-
INinja: "INinja"
124+
IKatana: "Katana",
125+
INinja: "Ninja"
125126
};
126127

127-
@provide(TYPE.IKatana)
128-
class Katana implements IKatana {
128+
@provide(TYPE.Katana)
129+
class Katana implements Weapon {
129130
public hit() {
130131
return "cut!";
131132
}
132133
}
133134

134-
@provide(TYPE.INinja)
135-
class Ninja implements INinja {
135+
@provide(TYPE.Ninja)
136+
class Ninja implements Ninja {
136137

137-
private _katana: IKatana;
138+
private _katana: Weapon;
138139

139140
public constructor(
140-
@inject(TYPE.IKatana) katana: IKatana
141+
@inject(TYPE.Katana) katana: Weapon
141142
) {
142143
this._katana = katana;
143144
}
@@ -151,24 +152,24 @@ You can also use symbols as identifiers:
151152

152153
```ts
153154
let TYPE = {
154-
IKatana: Symbol("IKatana"),
155-
INinja: Symbol("INinja")
155+
Katana: Symbol("Katana"),
156+
Ninja: Symbol("Ninja")
156157
};
157158

158-
@provide(TYPE.IKatana)
159-
class Katana implements IKatana {
159+
@provide(TYPE.Katana)
160+
class Katana implements Weapon {
160161
public hit() {
161162
return "cut!";
162163
}
163164
}
164165

165-
@provide(TYPE.INinja)
166-
class Ninja implements INinja {
166+
@provide(TYPE.Ninja)
167+
class Ninja implements Ninja {
167168

168-
private _katana: IKatana;
169+
private _katana: Weapon;
169170

170171
public constructor(
171-
@inject(TYPE.IKatana) katana: IKatana
172+
@inject(TYPE.Katana) katana: Weapon
172173
) {
173174
this._katana = katana;
174175
}
@@ -179,9 +180,13 @@ class Ninja implements INinja {
179180
```
180181

181182
### Fluent binding decorator
182-
The basic `@provide` decorator doesn't allow you to declare contextual constraints, scope and other advanced binding features. However, `inversify-binding-decorators` includes a second decorator that allows you to achieve access the full potential of the fluent binding syntax:
183+
The basic `@provide` decorator doesn't allow you to declare contextual constraints,
184+
scope and other advanced binding features. However, `inversify-binding-decorators`
185+
includes a second decorator that allows you to achieve access the full potential
186+
of the fluent binding syntax:
183187

184-
The decorator returned by `makeProvideDecorator` is not fluent and is very limited when compared to `makeFluentProvideDecorator`:
188+
The decorator returned by `makeProvideDecorator` is not fluent and is very limited
189+
when compared to `makeFluentProvideDecorator`:
185190

186191
```ts
187192
import { injectable, Kernel } from "inversify";
@@ -191,33 +196,33 @@ var kernel = new Kernel();
191196
let provide = makeFluentProvideDecorator(kernel);
192197

193198
let TYPE = {
194-
IWeapon : "IWeapon",
195-
INinja: "INinja"
199+
Weapon : "Weapon",
200+
Ninja: "Ninja"
196201
};
197202

198-
@provide(TYPE.IWeapon).whenTargetTagged("throwable", true).done();
199-
class Katana implements IWeapon {
203+
@provide(TYPE.Weapon).whenTargetTagged("throwable", true).done();
204+
class Katana implements Weapon {
200205
public hit() {
201206
return "cut!";
202207
}
203208
}
204209

205-
@provide(TYPE.IWeapon).whenTargetTagged("throwable", false).done();
206-
class Shuriken implements IWeapon {
210+
@provide(TYPE.Weapon).whenTargetTagged("throwable", false).done();
211+
class Shuriken implements Weapon {
207212
public hit() {
208213
return "hit!";
209214
}
210215
}
211216

212-
@provide(TYPE.INinja)
213-
class Ninja implements INinja {
217+
@provide(TYPE.Ninja)
218+
class Ninja implements Ninja {
214219

215-
private _katana: IWeapon;
216-
private _shuriken: IWeapon;
220+
private _katana: Weapon;
221+
private _shuriken: Weapon;
217222

218223
public constructor(
219-
@inject(TYPE.IWeapon) @tagged("throwable", false) katana: IKatana,
220-
@inject(TYPE.IWeapon) @tagged("throwable", true) shuriken: IShuriken
224+
@inject(TYPE.Weapon) @tagged("throwable", false) katana: Weapon,
225+
@inject(TYPE.Weapon) @tagged("throwable", true) shuriken: ThrowableWeapon
221226
) {
222227
this._katana = katana;
223228
this._shuriken = shuriken;
@@ -238,15 +243,15 @@ let provideThrowable = function(identifier, isThrowable) {
238243
.done();
239244
};
240245

241-
@provideThrowable(TYPE.IWeapon, true)
242-
class Katana implements IWeapon {
246+
@provideThrowable(TYPE.Weapon, true)
247+
class Katana implements Weapon {
243248
public hit() {
244249
return "cut!";
245250
}
246251
}
247252

248-
@provideThrowable(TYPE.IWeapon, false)
249-
class Shuriken implements IWeapon {
253+
@provideThrowable(TYPE.Weapon, false)
254+
class Shuriken implements Weapon {
250255
public hit() {
251256
return "hit!";
252257
}
@@ -262,8 +267,8 @@ let provideSingleton = function(identifier) {
262267
.done();
263268
};
264269

265-
@provideSingleton(TYPE.IWeapon)
266-
class Shuriken implements IWeapon {
270+
@provideSingleton(TYPE.Weapon)
271+
class Shuriken implements Weapon {
267272
public hit() {
268273
return "hit!";
269274
}
@@ -275,6 +280,7 @@ This library includes a small utility apply to add the default `@provide` decora
275280
the public properties of a module:
276281
277282
Consider the following example:
283+
278284
```ts
279285
import * as entites from "../entities";
280286

@@ -285,11 +291,14 @@ expect(warrior.fight()).eql("Using Katana...");
285291
```
286292

287293
The contents of the entities.ts file are the following:
294+
288295
```ts
289296
export { default as Warrior } from "./warrior";
290297
export { default as Katana } from "./katana";
291298
```
299+
292300
The contents of the katana.ts file are the following:
301+
293302
```ts
294303
class Katana {
295304
public use() {
@@ -299,19 +308,21 @@ class Katana {
299308

300309
export default Katana;
301310
```
311+
302312
The contents of the warrior.ts file are the following:
313+
303314
```ts
304315
import Katana from "./katana";
305316
import { inject } from "inversify";
306317

307318
class Warrior {
308-
private _weapon: Katana;
319+
private _weapon: Weapon;
309320
public constructor(
310321
// we need to declare binding because auto-provide uses
311322
// @injectbale decorator at runtime not compilation time
312323
// in the future maybe this limitation will desapear
313324
// thanks to design-time decorators or some other TS feature
314-
@inject(Katana) weapon: Katana
325+
@inject(Katana) weapon: Weapon
315326
) {
316327
this._weapon = weapon;
317328
}
@@ -355,6 +366,11 @@ following conditions:
355366
The above copyright notice and this permission notice shall be included in all copies or substantial
356367
portions of the Software.
357368

358-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
369+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
370+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
371+
PURPOSE AND NONINFRINGEMENT.
359372

360-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
373+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
374+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
375+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
376+
DEALINGS IN THE SOFTWARE.

gulpfile.js

+12
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ var tsLibProject = tsc.createProject("tsconfig.json", { module : "commonjs" });
9797

9898
gulp.task("build-lib", function() {
9999
return gulp.src([
100+
"node_modules/inversify-dts/inversify/inversify.d.ts",
101+
"node_modules/reflect-metadata/reflect-metadata.d.ts",
102+
"typings/index.d.ts",
100103
"src/**/*.ts"
101104
])
102105
.pipe(tsc(tsLibProject ))
@@ -112,6 +115,9 @@ var tsEsProject = tsc.createProject("tsconfig.json", { module : "es2015" });
112115

113116
gulp.task("build-es", function() {
114117
return gulp.src([
118+
"node_modules/inversify-dts/inversify/inversify.d.ts",
119+
"node_modules/reflect-metadata/reflect-metadata.d.ts",
120+
"typings/index.d.ts",
115121
"src/**/*.ts"
116122
])
117123
.pipe(tsc(tsEsProject))
@@ -130,6 +136,9 @@ var tstProject = tsc.createProject("tsconfig.json");
130136

131137
gulp.task("build-src", function() {
132138
return gulp.src([
139+
"node_modules/inversify-dts/inversify/inversify.d.ts",
140+
"node_modules/reflect-metadata/reflect-metadata.d.ts",
141+
"typings/index.d.ts",
133142
"src/**/*.ts"
134143
])
135144
.pipe(tsc(tstProject))
@@ -143,6 +152,9 @@ var tsTestProject = tsc.createProject("tsconfig.json");
143152

144153
gulp.task("build-test", function() {
145154
return gulp.src([
155+
"node_modules/inversify-dts/inversify/inversify.d.ts",
156+
"node_modules/reflect-metadata/reflect-metadata.d.ts",
157+
"typings/index.d.ts",
146158
"test/**/*.ts"
147159
])
148160
.pipe(tsc(tsTestProject))

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "inversify-binding-decorators",
3-
"version": "1.0.0-beta.5",
3+
"version": "1.0.0-beta.6",
44
"description": "An utility that allows developers to declare InversifyJS bindings using ES2016 decorators",
55
"main": "lib/index.js",
66
"jsnext:main": "es/index.js",
@@ -23,15 +23,15 @@
2323
},
2424
"homepage": "https://github.com/inversify/inversify-binding-decorators#readme",
2525
"dependencies": {
26-
"inversify": "^2.0.0-beta.8",
27-
"inversify-dts": "^1.0.3"
26+
"inversify": "^2.0.0-beta.10"
2827
},
2928
"devDependencies": {
29+
"inversify-dts": "^1.0.6",
3030
"browserify": "^13.0.1",
3131
"chai": "^3.5.0",
3232
"gulp": "^3.9.1",
3333
"gulp-codecov": "^2.0.1",
34-
"gulp-header": "1.8.2",
34+
"gulp-header": "1.8.7",
3535
"gulp-istanbul": "^1.0.0",
3636
"gulp-mocha": "^2.2.0",
3737
"gulp-rename": "^1.2.2",

src/decorator/fluent_provide.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
/// <reference path="../interfaces/interfaces.d.ts" />
2-
31
import ProvideInWhenOnSyntax from "../syntax/provide_in_when_on_syntax";
42
import ProvideWhenSyntax from "../syntax/provide_when_syntax";
53
import ProvideOnSyntax from "../syntax/provide_on_syntax";
64
import ProvideInSyntax from "../syntax/provide_in_syntax";
75
import ProvideDoneSyntax from "../syntax/provide_done_syntax";
86

9-
function fluentProvide(kernel: inversify.IKernel) {
7+
function fluentProvide(kernel: inversify.interfaces.Kernel) {
108

119
// function is named for testing
12-
return function _fluentProvide(serviceIdentifier: (string|Symbol|inversify.INewable<any>)) {
10+
return function _fluentProvide(serviceIdentifier: (string|Symbol|inversify.interfaces.Newable<any>)) {
1311

1412
let bindingWhenOnSyntax = kernel.bind<any>(serviceIdentifier).to(null);
1513
let binding = (<any>bindingWhenOnSyntax)._binding;

src/decorator/provide.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
/// <reference path="../interfaces/interfaces.d.ts" />
2-
31
import { decorate, injectable } from "inversify";
42

5-
function provide(kernel: inversify.IKernel) {
3+
function provide(kernel: inversify.interfaces.Kernel) {
64

75
// function is named for testing
8-
return function _provide(serviceIdentifier: (string|Symbol|inversify.INewable<any>)) {
6+
return function _provide(serviceIdentifier: (string|Symbol|inversify.interfaces.Newable<any>)) {
97
let bindingWhenOnSyntax = kernel.bind<any>(serviceIdentifier).to(null);
108
return function (target: any) {
119
decorate(injectable(), target);
12-
let binding: inversify.IBinding<any> = (<any>bindingWhenOnSyntax)._binding;
10+
let binding: inversify.interfaces.Binding<any> = (<any>bindingWhenOnSyntax)._binding;
1311
binding.implementationType = target;
1412
return target;
1513
};

src/factory/fluent_provide_decorator_factory.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
/// <reference path="../interfaces/interfaces.d.ts" />
2-
31
import fluentProvide from "../decorator/fluent_provide";
42

5-
function makeFluentProvideDecorator(kernel: inversify.IKernel) {
3+
function makeFluentProvideDecorator(kernel: inversify.interfaces.Kernel) {
64
return fluentProvide(kernel);
75
}
86

0 commit comments

Comments
 (0)