-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from inversify/feat/add-reflect-metadata-utils…
…-package Add reflect metadata utils package
- Loading branch information
Showing
28 changed files
with
407 additions
and
15 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,5 @@ | ||
--- | ||
"@inversifyjs/reflect-metadata-utils": minor | ||
--- | ||
|
||
Added `getReflectMetadata`. |
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 @@ | ||
--- | ||
"@inversifyjs/reflect-metadata-utils": minor | ||
--- | ||
|
||
Added `updateReflectMetadata`. |
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
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
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"eslint.workingDirectories": [ | ||
{ "pattern": "./packages/container/libraries/*" }, | ||
{ "pattern": "./packages/foundation/libraries/*" }, | ||
{ "pattern": "./packages/foundation/tools/*" } | ||
] | ||
} |
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
19 changes: 19 additions & 0 deletions
19
packages/foundation/libraries/reflect-metadata-utils/.gitignore
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,19 @@ | ||
# Typescript compiled files | ||
/lib/** | ||
|
||
/tsconfig.tsbuildinfo | ||
/tsconfig.cjs.tsbuildinfo | ||
/tsconfig.esm.tsbuildinfo | ||
|
||
# Test coverage report | ||
/coverage | ||
|
||
# Test mutation report | ||
/reports | ||
|
||
# node modules | ||
/node_modules/ | ||
|
||
# Turborepo files | ||
.turbo/ | ||
|
9 changes: 9 additions & 0 deletions
9
packages/foundation/libraries/reflect-metadata-utils/.lintstagedrc.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,9 @@ | ||
{ | ||
"*.js": [ | ||
"prettier --write" | ||
], | ||
"*.ts": [ | ||
"prettier --write", | ||
"eslint" | ||
] | ||
} |
18 changes: 18 additions & 0 deletions
18
packages/foundation/libraries/reflect-metadata-utils/.npmignore
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,18 @@ | ||
**/*.spec.js | ||
**/*.spec.js.map | ||
**/*.ts | ||
!lib/**/*.d.ts | ||
lib/**/*.spec.d.ts | ||
|
||
.lintstagedrc.json | ||
eslint.config.mjs | ||
jest.config.mjs | ||
jest.config.stryker.mjs | ||
jest.js.config.mjs | ||
prettier.config.mjs | ||
stryker.config.mjs | ||
tsconfig.json | ||
tsconfig.cjs.json | ||
tsconfig.esm.json | ||
tsconfig.cjs.tsbuildinfo | ||
tsconfig.esm.tsbuildinfo |
6 changes: 6 additions & 0 deletions
6
packages/foundation/libraries/reflect-metadata-utils/README.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,6 @@ | ||
[![Test coverage](https://codecov.io/gh/inversify/monorepo/branch/main/graph/badge.svg?flag=%40inversifyjs%2Freflect-metadata-utils)](https://codecov.io/gh/inversify/monorepo/branch/main/graph/badge.svg?flag=%40inversifyjs%2Freflect-metadata-utils) | ||
[![npm version](https://img.shields.io/github/package-json/v/inversify/monorepo?filename=packages%2Ffoundation%2Flibraries%2Freflect-metadata-utils%2Fpackage.json&style=plastic)](https://www.npmjs.com/package/@inversifyjs/reflect-metadata-utils) | ||
|
||
# @inversifyjs/reflect-metadata-utils | ||
|
||
Inversify reflect metadata utils package. |
3 changes: 3 additions & 0 deletions
3
packages/foundation/libraries/reflect-metadata-utils/eslint.config.mjs
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 @@ | ||
import myconfig from '@inversifyjs/foundation-eslint-config'; | ||
|
||
export default [...myconfig]; |
3 changes: 3 additions & 0 deletions
3
packages/foundation/libraries/reflect-metadata-utils/jest.config.mjs
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 @@ | ||
import { tsGlobalConfig } from '@inversifyjs/foundation-jest-config'; | ||
|
||
export default tsGlobalConfig; |
9 changes: 9 additions & 0 deletions
9
packages/foundation/libraries/reflect-metadata-utils/jest.config.stryker.mjs
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 { getJestTsProjectConfig } from '@inversifyjs/foundation-jest-config'; | ||
|
||
const tsGlobalConfig = getJestTsProjectConfig( | ||
'All', | ||
['/node_modules', '.int.spec.ts'], | ||
'.spec.ts', | ||
); | ||
|
||
export default tsGlobalConfig; |
3 changes: 3 additions & 0 deletions
3
packages/foundation/libraries/reflect-metadata-utils/jest.js.config.mjs
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 @@ | ||
import { jsGlobalConfig } from '@inversifyjs/foundation-jest-config'; | ||
|
||
export default jsGlobalConfig; |
81 changes: 81 additions & 0 deletions
81
packages/foundation/libraries/reflect-metadata-utils/package.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,81 @@ | ||
{ | ||
"name": "@inversifyjs/reflect-metadata-utils", | ||
"version": "0.1.0", | ||
"description": "Reflect metadata utils", | ||
"main": "lib/cjs/index.js", | ||
"module": "lib/esm/index.js", | ||
"exports": { | ||
".": { | ||
"import": "./lib/esm/index.js", | ||
"require": "./lib/cjs/index.js" | ||
} | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/inversify/monorepo.git" | ||
}, | ||
"keywords": [ | ||
"dependency injection", | ||
"dependency inversion", | ||
"di", | ||
"inversion of control container", | ||
"ioc", | ||
"javascript", | ||
"node", | ||
"reflect-metadata", | ||
"typescript" | ||
], | ||
"author": "Roberto Pintos López", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/inversify/monorepo/issues" | ||
}, | ||
"devDependencies": { | ||
"@eslint/js": "9.13.0", | ||
"@jest/globals": "29.7.0", | ||
"@stryker-mutator/core": "8.6.0", | ||
"@stryker-mutator/jest-runner": "8.6.0", | ||
"@stryker-mutator/typescript-checker": "8.6.0", | ||
"@types/node": "20.17.0", | ||
"@typescript-eslint/eslint-plugin": "8.11.0", | ||
"@typescript-eslint/parser": "8.11.0", | ||
"jest": "29.7.0", | ||
"prettier": "3.3.3", | ||
"rimraf": "6.0.1", | ||
"ts-jest": "29.2.5", | ||
"ts-node": "10.9.2", | ||
"typescript": "5.6.3" | ||
}, | ||
"devEngines": { | ||
"node": "^20.18.0", | ||
"pnpm": "^9.12.1" | ||
}, | ||
"homepage": "https://inversify.io", | ||
"os": [ | ||
"darwin", | ||
"linux" | ||
], | ||
"peerDependencies": { | ||
"reflect-metadata": "0.2.2" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"build": "pnpm run build:cjs && pnpm run build:esm", | ||
"build:cjs": "tsc --build tsconfig.cjs.json && pnpm exec foundation-ts-package-cjs ./lib/cjs", | ||
"build:esm": "tsc --build tsconfig.esm.json && pnpm exec foundation-ts-package-esm ./lib/esm", | ||
"build:clean": "rimraf lib", | ||
"format": "prettier --write ./src/**/*.ts", | ||
"lint": "eslint ./src", | ||
"prebuild": "pnpm run build:clean", | ||
"test": "jest --config=jest.config.mjs --runInBand", | ||
"test:integration:js": "pnpm run test:js --selectProjects Integration", | ||
"test:js": "jest --config=jest.js.config.mjs --runInBand", | ||
"test:js:coverage": "pnpm run test:unit:js --coverage", | ||
"test:mutation": "stryker run", | ||
"test:uncommitted": "pnpm run test --changedSince=HEAD", | ||
"test:unit:js": "pnpm run test:js --selectProjects Unit" | ||
}, | ||
"sideEffects": false | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/foundation/libraries/reflect-metadata-utils/prettier.config.mjs
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 @@ | ||
import config from '@inversifyjs/foundation-prettier-config'; | ||
|
||
export default config; |
4 changes: 4 additions & 0 deletions
4
packages/foundation/libraries/reflect-metadata-utils/src/index.ts
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 @@ | ||
import { getReflectMetadata } from './reflectMetadata/utils/getReflectMetadata'; | ||
import { updateReflectMetadata } from './reflectMetadata/utils/updateReflectMetadata'; | ||
|
||
export { getReflectMetadata, updateReflectMetadata }; |
45 changes: 45 additions & 0 deletions
45
...ion/libraries/reflect-metadata-utils/src/reflectMetadata/utils/getReflectMetadata.spec.ts
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,45 @@ | ||
import { beforeAll, describe, expect, it } from '@jest/globals'; | ||
|
||
import 'reflect-metadata'; | ||
|
||
import { getReflectMetadata } from './getReflectMetadata'; | ||
|
||
describe(getReflectMetadata.name, () => { | ||
describe('when called, and no metadata is registered', () => { | ||
let result: unknown; | ||
|
||
beforeAll(() => { | ||
result = getReflectMetadata(class {}, 'sample-key'); | ||
}); | ||
|
||
it('should return undefined', () => { | ||
expect(result).toBeUndefined(); | ||
}); | ||
}); | ||
|
||
describe('when called, and metadata is registered', () => { | ||
let result: unknown; | ||
|
||
let metadataFixture: unknown; | ||
|
||
beforeAll(() => { | ||
metadataFixture = 'sample-metadata'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type | ||
const targetFixture: Function = class {}; | ||
const metadataKeyFixture: unknown = 'sample-key'; | ||
|
||
Reflect.defineMetadata( | ||
metadataKeyFixture, | ||
metadataFixture, | ||
targetFixture, | ||
); | ||
|
||
result = getReflectMetadata(targetFixture, metadataKeyFixture); | ||
}); | ||
|
||
it('should return metadata', () => { | ||
expect(result).toBe(metadataFixture); | ||
}); | ||
}); | ||
}); |
7 changes: 7 additions & 0 deletions
7
...undation/libraries/reflect-metadata-utils/src/reflectMetadata/utils/getReflectMetadata.ts
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 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters | ||
export function getReflectMetadata<TMetadata>( | ||
target: object, | ||
metadataKey: unknown, | ||
): TMetadata | undefined { | ||
return Reflect.getMetadata(metadataKey, target) as TMetadata | undefined; | ||
} |
Oops, something went wrong.