-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sascha Braun
committed
Nov 22, 2018
0 parents
commit 25bf58e
Showing
33 changed files
with
605 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Javascript Node CircleCI 2.0 configuration file | ||
# | ||
# Check https://circleci.com/docs/2.0/language-javascript/ for more details | ||
# | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
- image: circleci/node:8.9.4 | ||
steps: | ||
- checkout | ||
|
||
# Download and cache dependencies | ||
- restore_cache: | ||
keys: | ||
- v1-dependencies-{{ checksum "package.json" }} | ||
# fallback to using the latest cache if no exact match is found | ||
- v1-dependencies- | ||
|
||
- run: yarn install | ||
|
||
- save_cache: | ||
paths: | ||
- node_modules | ||
key: v1-dependencies-{{ checksum "package.json" }} | ||
|
||
# run tests! | ||
- run: yarn test:unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
end_of_line = lf | ||
# editorconfig-tools is unable to ignore longs strings or urls | ||
max_line_length = null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
- **I'm submitting a ...** | ||
[ ] bug report | ||
[ ] feature request | ||
[ ] question about the decisions made in the repository | ||
[ ] question about how to use this project | ||
|
||
- **Summary** | ||
|
||
* **Other information** (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
- **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...) | ||
|
||
* **What is the current behavior?** (You can also link to an open issue here) | ||
|
||
- **What is the new behavior (if this is a feature change)?** | ||
|
||
* **Other information**: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
node_modules | ||
/build | ||
|
||
# local env files | ||
.env.local | ||
.env.*.local | ||
|
||
# Log files | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Editor directories and files | ||
.idea | ||
.vscode | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw* | ||
|
||
yarn.lock | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.vscode | ||
.github | ||
/node_modules | ||
/public | ||
/samples | ||
/build/tests | ||
/build/samples | ||
/src | ||
/tests | ||
|
||
.prettierignore | ||
.prettierrc | ||
.editorconfig | ||
.postcssrc.js | ||
babel.config.js | ||
jest.config.js | ||
tsconfig.json | ||
tsconfig.prod.json | ||
tslint.json | ||
.circleci | ||
|
||
# Log files | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
yarn.lock | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
plugins: { | ||
autoprefixer: {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# package.json is formatted by package managers, so we ignore it here | ||
package.json | ||
**/*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"singleQuote": true, | ||
"printWidth": 100 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Sascha Braun | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
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. 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# vue-typedi | ||
|
||
Use [typedi](http://github.com/pleerock/typedi) injections in Vue components | ||
|
||
## Usage | ||
|
||
1. Install module: | ||
|
||
`npm install vue-typedi --save` | ||
|
||
2. Install reflect-metadata package: | ||
|
||
`npm install reflect-metadata --save` | ||
|
||
and import it somewhere in the global place of your app before any service declaration or import (for example in app.ts): | ||
|
||
`import "reflect-metadata";` | ||
|
||
3. Enabled following settings in tsconfig.json: | ||
|
||
```json | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
``` | ||
|
||
4. Use the module: | ||
```ts | ||
import Vue from 'vue' | ||
import VueTypedi from 'vue-typedi' | ||
|
||
Vue.use(VueTypedi); | ||
``` | ||
|
||
## Example | ||
|
||
```ts | ||
|
||
import { Container, Inject } from 'vue-typedi'; | ||
import MyService from '...'; | ||
|
||
@Component | ||
export default class MyComponent extends Vue { | ||
|
||
@Inject() | ||
public myService!: MyService; | ||
} | ||
|
||
``` | ||
|
||
## Decorators | ||
|
||
- `@Inject()` only targets and works in Vue components. If you wish to inject a service somewhere else, use the `@Inject` provided by typedi. | ||
|
||
- `@Injectable()` implements a feature missing in typedi, that will inject the service in the classes prototype. This allows us to automatically inject services in non service classes. | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
presets: [ | ||
'@vue/app' | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module.exports = { | ||
moduleFileExtensions: ["js", "jsx", "json", "vue", "ts", "tsx"], | ||
transform: { | ||
"^.+\\.vue$": "vue-jest", | ||
".+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$": | ||
"jest-transform-stub", | ||
"^.+\\.tsx?$": "ts-jest" | ||
}, | ||
moduleNameMapper: { | ||
"^@/(.*)$": "<rootDir>/src/$1" | ||
}, | ||
snapshotSerializers: ["jest-serializer-vue"], | ||
testMatch: [ | ||
"**/tests/unit/**/*.spec.(ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)" | ||
], | ||
testURL: "http://localhost/" | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"name": "vue-typedi", | ||
"version": "1.0.0", | ||
"description": "Use typedi injections in Vue components", | ||
"main": "build/src/index.js", | ||
"typings": "build/src/index.d.ts", | ||
"repository": "https://github.com/sascha245/vue-typedi", | ||
"license": "MIT", | ||
"keywords": [ | ||
"vue", | ||
"typedi" | ||
], | ||
"scripts": { | ||
"serve": "vue-cli-service serve ./samples/main.ts", | ||
"build": "rimraf ./build && tsc -p tsconfig.prod.json", | ||
"lint": "vue-cli-service lint", | ||
"test:unit": "vue-cli-service test:unit --verbose", | ||
"validate": "npm run build && npm run test:unit && npm pack --dry-run" | ||
}, | ||
"dependencies": { | ||
"reflect-metadata": "^0.1.12", | ||
"typedi": "^0.8.0" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^23.1.4", | ||
"@vue/cli-plugin-babel": "^3.0.4", | ||
"@vue/cli-plugin-typescript": "^3.0.4", | ||
"@vue/cli-plugin-unit-jest": "^3.0.4", | ||
"@vue/cli-service": "^3.0.4", | ||
"@vue/test-utils": "^1.0.0-beta.20", | ||
"babel-core": "7.0.0-bridge.0", | ||
"lint-staged": "^7.2.2", | ||
"rimraf": "^2.6.2", | ||
"ts-jest": "^23.0.0", | ||
"tslint-config-prettier": "^1.15.0", | ||
"typescript": "^3.0.0", | ||
"vue": "^2.5.17", | ||
"vue-class-component": "^6.3.2", | ||
"vue-property-decorator": "^7.0.0", | ||
"vue-router": "^3.0.1", | ||
"vue-template-compiler": "^2.5.17" | ||
}, | ||
"gitHooks": { | ||
"pre-commit": "lint-staged" | ||
}, | ||
"lint-staged": { | ||
"*.ts": [ | ||
"vue-cli-service lint", | ||
"git add" | ||
], | ||
"*.vue": [ | ||
"vue-cli-service lint", | ||
"git add" | ||
] | ||
}, | ||
"peerDependencies": { | ||
"vue": "^2.5.17", | ||
"vue-class-component": "^6.3.2" | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1.0"> | ||
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> | ||
<title>vuex-simple</title> | ||
</head> | ||
|
||
<body> | ||
<noscript> | ||
<strong>We're sorry but vue-three doesn't work properly without JavaScript enabled. Please enable it to continue.</strong> | ||
</noscript> | ||
<div id="app"></div> | ||
<!-- built files will be auto injected --> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<template> | ||
<div id="app"> | ||
<div id="nav"> | ||
<router-link to="/">Home</router-link> | | ||
<router-link to="/about">About</router-link> | ||
</div> | ||
<router-view/> | ||
</div> | ||
</template> | ||
|
||
<style> | ||
#app { | ||
font-family: "Avenir", Helvetica, Arial, sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
text-align: center; | ||
color: #2c3e50; | ||
} | ||
#nav { | ||
padding: 30px; | ||
} | ||
#nav a { | ||
font-weight: bold; | ||
color: #2c3e50; | ||
} | ||
#nav a.router-link-exact-active { | ||
color: #42b983; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'reflect-metadata'; | ||
|
||
import Vue from 'vue'; | ||
|
||
import VueTypedi from '../src'; | ||
import App from './App.vue'; | ||
import router from './router'; | ||
|
||
Vue.config.productionTip = false; | ||
|
||
Vue.use(VueTypedi); | ||
|
||
new Vue({ | ||
render: h => h(App), | ||
router | ||
}).$mount('#app'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Vue from "vue"; | ||
import Router from "vue-router"; | ||
|
||
import About from "./views/About"; | ||
import Home from "./views/Home"; | ||
|
||
Vue.use(Router); | ||
|
||
export default new Router({ | ||
routes: [ | ||
{ | ||
component: Home, | ||
name: "home", | ||
path: "/", | ||
}, | ||
{ | ||
component: About, | ||
name: "about", | ||
path: "/about", | ||
} | ||
] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Service } from 'typedi'; | ||
|
||
@Service() | ||
export class TestService { | ||
public random(min, max) { | ||
const diff = max - min; | ||
return Math.random() * diff + min; | ||
} | ||
} |
Oops, something went wrong.