chore(repo): remove project configuration and source files
- Delete all project configuration files, including ESLint, Prettier, and TypeScript settings. - Remove GitHub workflows for CI/CD and documentation deployment. - Delete source files, tests, and scripts related to the project. - Clean up package.json and associated scripts. Signed-off-by: Max P. <Mail@MPassarello.de>
This commit is contained in:
@@ -1,13 +0,0 @@
|
|||||||
node_modules/
|
|
||||||
|
|
||||||
main.js
|
|
||||||
|
|
||||||
**/*.js
|
|
||||||
*.js
|
|
||||||
|
|
||||||
**/*.mjs
|
|
||||||
*.mjs
|
|
||||||
|
|
||||||
dist/*
|
|
||||||
|
|
||||||
*.cjs
|
|
299
.eslintrc
299
.eslintrc
@@ -1,299 +0,0 @@
|
|||||||
{
|
|
||||||
"root": true,
|
|
||||||
"parser": "@typescript-eslint/parser",
|
|
||||||
"env": {
|
|
||||||
"node": true
|
|
||||||
},
|
|
||||||
"plugins": [
|
|
||||||
"@typescript-eslint",
|
|
||||||
"deprecation",
|
|
||||||
"prettier",
|
|
||||||
"import",
|
|
||||||
"jsdoc",
|
|
||||||
"override",
|
|
||||||
"@stylistic"
|
|
||||||
],
|
|
||||||
"extends": [
|
|
||||||
"eslint:recommended",
|
|
||||||
"plugin:@typescript-eslint/eslint-recommended",
|
|
||||||
"plugin:@typescript-eslint/recommended",
|
|
||||||
"plugin:jsdoc/recommended-typescript"
|
|
||||||
],
|
|
||||||
"parserOptions": {
|
|
||||||
"sourceType": "module",
|
|
||||||
"project": "./tsconfig.json"
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
"override/require-override": "error",
|
|
||||||
"override/require-static-override": "off",
|
|
||||||
"prettier/prettier": "warn",
|
|
||||||
"array-callback-return": [
|
|
||||||
"error"
|
|
||||||
],
|
|
||||||
"@typescript-eslint/no-unused-vars": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"argsIgnorePattern": "^_",
|
|
||||||
"varsIgnorePattern": "^_",
|
|
||||||
"caughtErrorsIgnorePattern": "^_",
|
|
||||||
"args": "none"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"no-warning-comments": [
|
|
||||||
"warn",
|
|
||||||
{
|
|
||||||
"terms": [
|
|
||||||
"@todo"
|
|
||||||
],
|
|
||||||
"location": "anywhere"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"no-unused-vars": "off",
|
|
||||||
"@typescript-eslint/ban-ts-comment": "off",
|
|
||||||
"no-prototype-builtins": "off",
|
|
||||||
"@typescript-eslint/no-empty-function": "off",
|
|
||||||
"deprecation/deprecation": "warn",
|
|
||||||
"no-console": "off",
|
|
||||||
"@typescript-eslint/naming-convention": [
|
|
||||||
"warn",
|
|
||||||
{
|
|
||||||
"selector": "classProperty",
|
|
||||||
"modifiers": [
|
|
||||||
"private"
|
|
||||||
],
|
|
||||||
"format": [],
|
|
||||||
"custom": {
|
|
||||||
"regex": "^(_{1,2}I[A-Z][a-zA-Z0-9]*_?|_{1,2}[a-z][a-zA-Z0-9]*)$",
|
|
||||||
"match": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"selector": "classProperty",
|
|
||||||
"modifiers": [
|
|
||||||
"protected"
|
|
||||||
],
|
|
||||||
"format": [],
|
|
||||||
"custom": {
|
|
||||||
"regex": "^(_{1,2}I[A-Z][a-zA-Z0-9]*_?|_{1,2}[a-z][a-zA-Z0-9]*)$",
|
|
||||||
"match": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"selector": [
|
|
||||||
"typeProperty",
|
|
||||||
"classProperty"
|
|
||||||
],
|
|
||||||
"types": [
|
|
||||||
"boolean"
|
|
||||||
],
|
|
||||||
"format": [
|
|
||||||
"PascalCase"
|
|
||||||
],
|
|
||||||
"prefix": [
|
|
||||||
"is",
|
|
||||||
"has",
|
|
||||||
"can",
|
|
||||||
"did",
|
|
||||||
"will",
|
|
||||||
"should"
|
|
||||||
],
|
|
||||||
"leadingUnderscore": "allow"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"selector": "memberLike",
|
|
||||||
"modifiers": [
|
|
||||||
"public"
|
|
||||||
],
|
|
||||||
"format": [
|
|
||||||
"camelCase"
|
|
||||||
],
|
|
||||||
"leadingUnderscore": "forbid",
|
|
||||||
"filter": {
|
|
||||||
"regex": "^(Events|Styles|Classes|Then)$",
|
|
||||||
"match": false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"selector": "typeProperty",
|
|
||||||
"modifiers": [
|
|
||||||
"public"
|
|
||||||
],
|
|
||||||
"format": null,
|
|
||||||
"filter": {
|
|
||||||
"regex": ".*-event$",
|
|
||||||
"match": true
|
|
||||||
},
|
|
||||||
"custom": {
|
|
||||||
"regex": "^[a-z]+(-[a-z]+)*-event$",
|
|
||||||
"match": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"selector": "typeProperty",
|
|
||||||
"modifiers": [
|
|
||||||
"public"
|
|
||||||
],
|
|
||||||
"format": [
|
|
||||||
"camelCase"
|
|
||||||
],
|
|
||||||
"filter": {
|
|
||||||
"regex": ".*-event$|^(Events|Styles|Classes|Then)$",
|
|
||||||
"match": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"@typescript-eslint/no-unused-expressions": "off",
|
|
||||||
"@stylistic/padding-line-between-statements": [
|
|
||||||
"warn",
|
|
||||||
{
|
|
||||||
"blankLine": "always",
|
|
||||||
"prev": "*",
|
|
||||||
"next": [
|
|
||||||
"return",
|
|
||||||
"if",
|
|
||||||
"multiline-const",
|
|
||||||
"function",
|
|
||||||
"multiline-expression",
|
|
||||||
"multiline-let",
|
|
||||||
"block-like"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"blankLine": "always",
|
|
||||||
"prev": [
|
|
||||||
"function"
|
|
||||||
],
|
|
||||||
"next": "*"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"import/order": [
|
|
||||||
"warn",
|
|
||||||
{
|
|
||||||
"groups": [
|
|
||||||
[
|
|
||||||
"builtin",
|
|
||||||
"external"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"internal"
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"parent",
|
|
||||||
"sibling"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"newlines-between": "never",
|
|
||||||
"alphabetize": {
|
|
||||||
"order": "asc",
|
|
||||||
"caseInsensitive": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"jsdoc/no-undefined-types": [
|
|
||||||
"warn",
|
|
||||||
{
|
|
||||||
"disableReporting": true,
|
|
||||||
"markVariablesAsUsed": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"jsdoc/require-jsdoc": [
|
|
||||||
"warn",
|
|
||||||
{
|
|
||||||
"require": {
|
|
||||||
"FunctionDeclaration": true,
|
|
||||||
"MethodDefinition": true,
|
|
||||||
"ClassDeclaration": true,
|
|
||||||
"ArrowFunctionExpression": false,
|
|
||||||
"FunctionExpression": false
|
|
||||||
},
|
|
||||||
"minLineCount": 10
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"jsdoc/require-param": [
|
|
||||||
"warn",
|
|
||||||
{
|
|
||||||
"exemptedBy": [
|
|
||||||
"deprecated",
|
|
||||||
"inheritdoc"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"jsdoc/require-description": [
|
|
||||||
"warn",
|
|
||||||
{
|
|
||||||
"contexts": [
|
|
||||||
"FunctionDeclaration",
|
|
||||||
"MethodDefinition",
|
|
||||||
"ClassDeclaration",
|
|
||||||
"ClassExpression"
|
|
||||||
],
|
|
||||||
"descriptionStyle": "body",
|
|
||||||
"exemptedBy": [
|
|
||||||
"deprecated",
|
|
||||||
"inheritdoc"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"jsdoc/require-returns": [
|
|
||||||
"warn",
|
|
||||||
{
|
|
||||||
"checkGetters": false,
|
|
||||||
"exemptedBy": [
|
|
||||||
"deprecated",
|
|
||||||
"inheritdoc"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"jsdoc/check-tag-names": [
|
|
||||||
"warn",
|
|
||||||
{
|
|
||||||
"definedTags": [
|
|
||||||
"remarks",
|
|
||||||
"jest-environment",
|
|
||||||
"singleton"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"jsdoc/check-alignment": "warn",
|
|
||||||
"jsdoc/check-indentation": "warn",
|
|
||||||
"jsdoc/no-restricted-syntax": [
|
|
||||||
"error",
|
|
||||||
{
|
|
||||||
"contexts": [
|
|
||||||
{
|
|
||||||
"context": "MethodDefinition[kind='get']",
|
|
||||||
"comment": "JsdocBlock:has(JsdocTag[tag='returns'])",
|
|
||||||
"message": "JSDoc @returns comments are not allowed in getters."
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"@typescript-eslint/prefer-readonly": "warn",
|
|
||||||
"@typescript-eslint/explicit-function-return-type": [
|
|
||||||
"warn",
|
|
||||||
{
|
|
||||||
"allowExpressions": true,
|
|
||||||
"allowTypedFunctionExpressions": true,
|
|
||||||
"allowHigherOrderFunctions": true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"@typescript-eslint/prefer-string-starts-ends-with": "warn",
|
|
||||||
"@typescript-eslint/no-misused-promises": "warn",
|
|
||||||
"@typescript-eslint/prefer-optional-chain": "warn"
|
|
||||||
},
|
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"files": [
|
|
||||||
"*.test.ts",
|
|
||||||
"*.spec.ts"
|
|
||||||
],
|
|
||||||
"rules": {
|
|
||||||
"jsdoc/require-jsdoc": "off",
|
|
||||||
"jsdoc/require-param": "off",
|
|
||||||
"jsdoc/require-description": "off",
|
|
||||||
"jsdoc/require-returns": "off",
|
|
||||||
"@typescript-eslint/explicit-function-return-type": "off"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
12
.github/dependabot.yml
vendored
12
.github/dependabot.yml
vendored
@@ -1,12 +0,0 @@
|
|||||||
# To get started with Dependabot version updates, you'll need to specify which
|
|
||||||
# package ecosystems to update and where the package manifests are located.
|
|
||||||
# Please see the documentation for all configuration options:
|
|
||||||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
|
||||||
|
|
||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: "npm" # See documentation for possible values
|
|
||||||
directory: "/" # Location of package manifests
|
|
||||||
open-pull-requests-limit: 10
|
|
||||||
schedule:
|
|
||||||
interval: "weekly"
|
|
117
.github/workflows/CreateRelease.yml
vendored
117
.github/workflows/CreateRelease.yml
vendored
@@ -1,117 +0,0 @@
|
|||||||
name: Create Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- 'dev/*'
|
|
||||||
paths:
|
|
||||||
- 'package.json'
|
|
||||||
workflow_dispatch: # Allows manual execution of the workflow.
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '20.8.0'
|
|
||||||
|
|
||||||
- name: Install dependencies, run tests and build
|
|
||||||
run: npm run prepare:deploy
|
|
||||||
|
|
||||||
- name: Get the version
|
|
||||||
id: get_version
|
|
||||||
run: |
|
|
||||||
VERSION=$(npm run version:show | tail -n 1)
|
|
||||||
echo "VERSION=v$VERSION" >> $GITHUB_ENV
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Get previous release tag
|
|
||||||
id: get_previous_release
|
|
||||||
run: |
|
|
||||||
echo "Fetching previous release tag..."
|
|
||||||
previous_tag=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
|
|
||||||
if [ -z "$previous_tag" ]; then
|
|
||||||
echo "No previous tag found, using initial commit."
|
|
||||||
previous_tag=$(git rev-list --max-parents=0 HEAD)
|
|
||||||
fi
|
|
||||||
echo "Previous tag: $previous_tag"
|
|
||||||
echo "PREVIOUS_TAG=$previous_tag" >> $GITHUB_ENV
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Check if version changed
|
|
||||||
id: check_version
|
|
||||||
run: |
|
|
||||||
# Check if the version already exists as a tag
|
|
||||||
if git rev-parse "refs/tags/${{ env.VERSION }}" >/dev/null 2>&1; then
|
|
||||||
echo "skip_release=true" >> $GITHUB_OUTPUT
|
|
||||||
echo "Version ${{ env.VERSION }} already exists as a tag. No release will be created."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Compare current version with previous tag
|
|
||||||
if [ "${{ env.VERSION }}" == "${{ env.PREVIOUS_TAG }}" ]; then
|
|
||||||
echo "skip_release=true" >> $GITHUB_OUTPUT
|
|
||||||
echo "Version has not changed. No release will be created."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
echo "skip_release=false" >> $GITHUB_OUTPUT
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Generate release notes
|
|
||||||
id: generate_notes
|
|
||||||
if: steps.check_version.outputs.skip_release == 'false'
|
|
||||||
run: |
|
|
||||||
echo "Generating release notes from ${{ env.PREVIOUS_TAG }} to HEAD..."
|
|
||||||
repo_url=$(git config --get remote.origin.url)
|
|
||||||
notes=$(git log ${{ env.PREVIOUS_TAG }}..HEAD --pretty=format:"- [\`%h\`]($repo_url/commit/%H): %s%n")
|
|
||||||
echo "See [CHANGELOG.md](./CHANGELOG.md) for more details."
|
|
||||||
echo "$notes"
|
|
||||||
echo ""
|
|
||||||
echo "### Changes in this release" > release_notes.md
|
|
||||||
echo "$notes" >> release_notes.md
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Set Git user
|
|
||||||
if: steps.check_version.outputs.skip_release == 'false'
|
|
||||||
run: |
|
|
||||||
git config --local user.name "GitHub Actions"
|
|
||||||
git config --local user.email "actions@github.com"
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Create and push tag
|
|
||||||
id: create_tag
|
|
||||||
if: steps.check_version.outputs.skip_release == 'false'
|
|
||||||
run: |
|
|
||||||
git tag ${{ env.VERSION }}
|
|
||||||
git push origin ${{ env.VERSION }}
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
- name: Set Release Prerelease Flag
|
|
||||||
id: set_prerelease_flag
|
|
||||||
run: |
|
|
||||||
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
|
|
||||||
echo "PRE_RELEASE=false" >> $GITHUB_ENV
|
|
||||||
elif [[ "${{ github.ref }}" == refs/heads/dev/* ]]; then
|
|
||||||
echo "PRE_RELEASE=true" >> $GITHUB_ENV
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Release
|
|
||||||
if: steps.check_version.outputs.skip_release == 'false'
|
|
||||||
uses: softprops/action-gh-release@v2
|
|
||||||
with:
|
|
||||||
tag_name: ${{ env.VERSION }}
|
|
||||||
name: Release ${{ env.VERSION }}
|
|
||||||
body_path: release_notes.md
|
|
||||||
prerelease: ${{ env.PRE_RELEASE }}
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
44
.github/workflows/DeployTypeDoc.yml
vendored
44
.github/workflows/DeployTypeDoc.yml
vendored
@@ -1,44 +0,0 @@
|
|||||||
name: Deploy Documentation
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
workflow_dispatch: # Allows manual execution of the workflow.
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '20.8.0'
|
|
||||||
|
|
||||||
- name: Install Dependencies
|
|
||||||
run: npm install
|
|
||||||
|
|
||||||
- name: Run TypeDoc Generation (TypeDoc, Test Coverage, fixes and badges)
|
|
||||||
run: npm run docs:generate
|
|
||||||
|
|
||||||
- name: Deploy to GitHub Pages
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
run: |
|
|
||||||
git config --global user.name 'github-actions[bot]'
|
|
||||||
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
|
||||||
git clone --single-branch --branch gh-pages https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} gh-pages
|
|
||||||
rm -rf gh-pages/*
|
|
||||||
cp -r .locale/docs/* gh-pages/
|
|
||||||
mkdir -p gh-pages/coverage
|
|
||||||
cp -r .locale/coverage/* gh-pages/coverage/
|
|
||||||
cd gh-pages
|
|
||||||
git add .
|
|
||||||
git commit -m 'Deploy documentation and coverage'
|
|
||||||
git push origin gh-pages
|
|
31
.github/workflows/PullRequestTest.yml
vendored
31
.github/workflows/PullRequestTest.yml
vendored
@@ -1,31 +0,0 @@
|
|||||||
name: Run Build and Tests on Pull Request
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
workflow_dispatch: # Allows manual execution of the workflow.
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-and-test:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout Repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '20.8.0'
|
|
||||||
|
|
||||||
- name: Install Dependencies
|
|
||||||
run: npm install
|
|
||||||
|
|
||||||
- name: Run Tests
|
|
||||||
run: npm run test:verbose
|
|
||||||
|
|
||||||
- name: Build the Project
|
|
||||||
run: npm run build:tsc
|
|
23
.github/workflows/ValidateBranchName.yml
vendored
23
.github/workflows/ValidateBranchName.yml
vendored
@@ -1,23 +0,0 @@
|
|||||||
name: Validate Branch Name on Pull Request
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- UNDEFINED
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
validate-branch-name-on-pull-request:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Check out repository
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Validate Branch Name on Pull Request
|
|
||||||
run: |
|
|
||||||
BRANCH_NAME=${GITHUB_HEAD_REF}
|
|
||||||
if [[ ! "$BRANCH_NAME" =~ ^(feature\/|fix\/|refactoring\/|testing\/|dependabot\/|gh-pages) ]]; then
|
|
||||||
echo "Invalid branch name: $BRANCH_NAME"
|
|
||||||
echo "Branch name must start with 'feature/', 'fix/', 'refactoring/', 'testing/', dependabot/" or "gh-pages"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
@@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"printWidth": 80,
|
|
||||||
"semi": true,
|
|
||||||
"singleQuote": true,
|
|
||||||
"bracketSpacing": true,
|
|
||||||
"useTabs": false,
|
|
||||||
"tabWidth": 4,
|
|
||||||
"endOfLine": "auto",
|
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"files": [
|
|
||||||
".prettierrc",
|
|
||||||
".eslintrc"
|
|
||||||
],
|
|
||||||
"options": {
|
|
||||||
"parser": "json"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
34
README.md
34
README.md
@@ -1,34 +0,0 @@
|
|||||||

|
|
||||||
|
|
||||||
[    ](https://pxammaxp.github.io/TSinjex/coverage/lcov-report/index.html)
|
|
||||||
|
|
||||||
# TSinjex
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
### Identifiers
|
|
||||||
|
|
||||||
Strings and symbols are possible for the **identifiers**.
|
|
||||||
|
|
||||||
### Jest
|
|
||||||
|
|
||||||
For the use of TSinjex with Jest, the corresponding source files can be found under `./src` of the TSinjex node_module folder. To use these files, the `moduleNameMapper` must be configured in the Jest configuration file. The following example shows how to configure the Jest configuration file to use the source files of TSinjex.
|
|
||||||
|
|
||||||
#### Example jest setup
|
|
||||||
|
|
||||||
```ts
|
|
||||||
module.exports = {
|
|
||||||
setupFilesAfterEnv: ['./scripts/jest.setup.js'],
|
|
||||||
preset: 'ts-jest',
|
|
||||||
testEnvironment: 'node',
|
|
||||||
testMatch: ['**/__tests__/**/*.test.ts', '**/?(*.)+(test).ts'],
|
|
||||||
moduleDirectories: ['node_modules', 'src'],
|
|
||||||
moduleNameMapper: {
|
|
||||||
'^src/(.*)$': '<rootDir>/src/$1', // Map src to the source folder
|
|
||||||
'^ts-injex$': '<rootDir>/node_modules/ts-injex/src', // Map ts-injex to the source folder
|
|
||||||
},
|
|
||||||
transformIgnorePatterns: [
|
|
||||||
'node_modules/(?!ts-injex)' // **Dont** ignore ts-injex on preset `ts-jest`
|
|
||||||
],
|
|
||||||
};
|
|
||||||
```
|
|
@@ -1,122 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const yargs = require('yargs');
|
|
||||||
|
|
||||||
// CLI argument parsing
|
|
||||||
const argv = yargs
|
|
||||||
.option('src', {
|
|
||||||
alias: 's',
|
|
||||||
type: 'string',
|
|
||||||
description: 'Directory to search for files',
|
|
||||||
default: 'src',
|
|
||||||
})
|
|
||||||
.option('output', {
|
|
||||||
alias: 'o',
|
|
||||||
type: 'string',
|
|
||||||
description: 'Path to the output file',
|
|
||||||
default: 'src/auto-imports.ts',
|
|
||||||
})
|
|
||||||
.option('pattern', {
|
|
||||||
alias: 'p',
|
|
||||||
type: 'string',
|
|
||||||
description: 'File pattern to search for (e.g., .ts, .js)',
|
|
||||||
default: '.ts',
|
|
||||||
})
|
|
||||||
.option('without-extension', {
|
|
||||||
alias: 'x',
|
|
||||||
type: 'boolean',
|
|
||||||
description: 'Omit file extension in import paths',
|
|
||||||
default: false,
|
|
||||||
})
|
|
||||||
.help()
|
|
||||||
.argv;
|
|
||||||
|
|
||||||
// Fixed RegEx patterns for decorator detection
|
|
||||||
const SEARCH_PATTERNS = [
|
|
||||||
/^@Register(?:<(.+)?>)?\(\s*["']{1}(.+)?["']{1}\s*,?\s*(true|false)?\s*\)/m,
|
|
||||||
/^@RegisterInstance(?:<(.+)?>)?\(\s*["']{1}(.+)?["']{1}\s*,?\s*(.+)?\s*\)/m,
|
|
||||||
];
|
|
||||||
|
|
||||||
const FILE_PATTERN = argv.pattern.startsWith('.') ? argv.pattern : `.${argv.pattern}`;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recursively collects all files with a specific extension.
|
|
||||||
* @param {string} dirPath - Root directory
|
|
||||||
* @returns {string[]} List of file paths
|
|
||||||
*/
|
|
||||||
function getAllFiles(dirPath) {
|
|
||||||
let files = fs.readdirSync(dirPath);
|
|
||||||
let arrayOfFiles = [];
|
|
||||||
|
|
||||||
files.forEach((file) => {
|
|
||||||
const fullPath = path.join(dirPath, file);
|
|
||||||
if (fs.statSync(fullPath).isDirectory()) {
|
|
||||||
arrayOfFiles = arrayOfFiles.concat(getAllFiles(fullPath));
|
|
||||||
} else if (file.endsWith(FILE_PATTERN)) {
|
|
||||||
arrayOfFiles.push(fullPath);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return arrayOfFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks files for decorator usage.
|
|
||||||
* @param {string[]} files
|
|
||||||
* @returns {string[]} Filtered files
|
|
||||||
*/
|
|
||||||
function findFilesWithPattern(files) {
|
|
||||||
return files.filter((file) => {
|
|
||||||
const content = fs.readFileSync(file, 'utf8');
|
|
||||||
return SEARCH_PATTERNS.some((pattern) => pattern.test(content));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates ES-style import statements from file paths.
|
|
||||||
* @param {string[]} files
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
function generateImports(files) {
|
|
||||||
return files.map((file) => {
|
|
||||||
const relative = './' + path.relative(argv.src, file).replace(/\\/g, '/');
|
|
||||||
const noExt = relative.replace(FILE_PATTERN, '');
|
|
||||||
const finalPath = argv['without-extension'] ? noExt : `${noExt}${FILE_PATTERN}`;
|
|
||||||
return `import '${finalPath}';`;
|
|
||||||
}).join('\n') + '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Script entry point.
|
|
||||||
*/
|
|
||||||
function main() {
|
|
||||||
try {
|
|
||||||
const srcDir = path.resolve(process.cwd(), argv.src);
|
|
||||||
const outputFile = path.resolve(process.cwd(), argv.output);
|
|
||||||
|
|
||||||
if (!fs.existsSync(srcDir)) {
|
|
||||||
console.error(`❌ Error: The directory '${srcDir}' does not exist.`);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
const allFiles = getAllFiles(srcDir);
|
|
||||||
const filesWithPattern = findFilesWithPattern(allFiles);
|
|
||||||
|
|
||||||
if (filesWithPattern.length === 0) {
|
|
||||||
console.log(`ℹ️ No ${FILE_PATTERN} files found matching the specified decorator patterns.`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const importContent = generateImports(filesWithPattern);
|
|
||||||
fs.writeFileSync(outputFile, importContent);
|
|
||||||
|
|
||||||
console.log(`✅ Imports successfully generated: ${outputFile}`);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('❌ An error occurred:', error.message);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
main();
|
|
@@ -1,28 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
setupFilesAfterEnv: ['./scripts/jest.setup.js'],
|
|
||||||
preset: 'ts-jest',
|
|
||||||
testEnvironment: 'node',
|
|
||||||
extensionsToTreatAsEsm: ['.ts'],
|
|
||||||
transform: {
|
|
||||||
'^.+\\.ts$': ['ts-jest', { useESM: true }],
|
|
||||||
},
|
|
||||||
testMatch: ['**/__tests__/**/*.test.ts', '**/?(*.)+(test).ts'],
|
|
||||||
testPathIgnorePatterns: ['\\.spec\\.ts$', '\\.performance\\.test\\.ts$'],
|
|
||||||
moduleDirectories: ['node_modules', 'src'],
|
|
||||||
moduleNameMapper: {
|
|
||||||
'^src/(.*)\\.js$': '<rootDir>/src/$1',
|
|
||||||
'^src/(.*)$': '<rootDir>/src/$1',
|
|
||||||
'^(\\.{1,2}/.*)\\.js$': '$1',
|
|
||||||
},
|
|
||||||
collectCoverage: true,
|
|
||||||
coverageDirectory: '.locale/coverage',
|
|
||||||
coverageReporters: ['text', 'lcov'],
|
|
||||||
coverageThreshold: {
|
|
||||||
global: {
|
|
||||||
branches: 70,
|
|
||||||
functions: 70,
|
|
||||||
lines: 70,
|
|
||||||
statements: 70,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
@@ -1,39 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
setupFilesAfterEnv: ['./scripts/jest.setup.js'],
|
|
||||||
testEnvironment: 'node',
|
|
||||||
transform: {
|
|
||||||
'^.+\\.ts$': ['ts-jest', { useESM: true }],
|
|
||||||
},
|
|
||||||
extensionsToTreatAsEsm: ['.ts'],
|
|
||||||
testMatch: ['**/__tests__/**/*.test.ts', '**/?(*.)+(test).ts'],
|
|
||||||
testPathIgnorePatterns: ['\\.spec\\.ts$', '\\.performance\\.test\\.ts$'],
|
|
||||||
moduleDirectories: ['node_modules', 'src'],
|
|
||||||
moduleNameMapper: {
|
|
||||||
'^src/(.*)\\.js$': '<rootDir>/src/$1',
|
|
||||||
'^src/(.*)$': '<rootDir>/src/$1',
|
|
||||||
'^(\\.{1,2}/.*)\\.js$': '$1',
|
|
||||||
},
|
|
||||||
collectCoverage: true,
|
|
||||||
coverageDirectory: '.locale/coverage',
|
|
||||||
coverageReporters: [
|
|
||||||
'text',
|
|
||||||
['lcov', { projectRoot: '..' }],
|
|
||||||
'json-summary',
|
|
||||||
],
|
|
||||||
collectCoverageFrom: [
|
|
||||||
'src/**/*.{ts,tsx}',
|
|
||||||
'!src/**/*.d.ts',
|
|
||||||
'!src/**/*.performance.test.ts',
|
|
||||||
'!src/**/*.spec.ts',
|
|
||||||
'!src/**/*.test.ts',
|
|
||||||
'!src/auto-imports.ts',
|
|
||||||
],
|
|
||||||
coverageThreshold: {
|
|
||||||
global: {
|
|
||||||
branches: 90,
|
|
||||||
functions: 90,
|
|
||||||
lines: 90,
|
|
||||||
statements: 90,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
7172
package-lock.json
generated
7172
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
66
package.json
66
package.json
@@ -1,66 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "ts-injex",
|
|
||||||
"version": "1.2.0",
|
|
||||||
"description": "Simple boilerplate code free dependency injection system for TypeScript.",
|
|
||||||
"type": "module",
|
|
||||||
"main": "./dist/index.js",
|
|
||||||
"types": "./dist/index.d.ts",
|
|
||||||
"bin": {
|
|
||||||
"tsinjex-generate": "./bin/generate-imports.cjs"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"prepare": "npm run build",
|
|
||||||
"build": "npm run build:tsc",
|
|
||||||
"build:tsc": "tsc",
|
|
||||||
"lint": "eslint --ext .ts .",
|
|
||||||
"lint:fix": "eslint --fix --ext .ts .",
|
|
||||||
"test": "jest",
|
|
||||||
"test:watch": "jest --watch --onlyChanged",
|
|
||||||
"test:file": "jest --watch --onlyChanged --coverage=true --verbose",
|
|
||||||
"test:verbose": "jest --verbose",
|
|
||||||
"test:coverage": "jest --config jest.config.coverage.cjs --coverage",
|
|
||||||
"docs": "typedoc",
|
|
||||||
"docs:generate": "npm run docs && npm run docs:generate:coverage && npm run docs:fix:coverage && npm run docs:generate:badge && npm run docs:fix:escape",
|
|
||||||
"docs:generate:coverage": "npm run test:coverage || exit 0",
|
|
||||||
"docs:fix:coverage": "node scripts/fix-coverage-paths.cjs",
|
|
||||||
"docs:generate:badge": "node scripts/generate-badge.cjs",
|
|
||||||
"docs:fix:escape": "node scripts/replace-doc-escaping.cjs",
|
|
||||||
"version:show": "node -e \"console.log(require('./package.json').version)\"",
|
|
||||||
"prepare:deploy": "npm install && npm run test:verbose && npm run build:tsc"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/PxaMMaxP/TSinjex.git"
|
|
||||||
},
|
|
||||||
"keywords": [],
|
|
||||||
"author": "Max P. (@Github: PxaMMaxP)",
|
|
||||||
"license": "MIT",
|
|
||||||
"devDependencies": {
|
|
||||||
"typescript": "^5.5.4",
|
|
||||||
"@types/jest": "^29.5.12",
|
|
||||||
"@types/node": "^20.14.11",
|
|
||||||
"@stylistic/eslint-plugin": "^2.6.2",
|
|
||||||
"@typescript-eslint/eslint-plugin": "^8.1.0",
|
|
||||||
"@typescript-eslint/parser": "^8.1.0",
|
|
||||||
"eslint-plugin-deprecation": "^3.0.0",
|
|
||||||
"eslint-plugin-import": "^2.29.1",
|
|
||||||
"eslint-plugin-jsdoc": "^50.2.2",
|
|
||||||
"eslint-plugin-override": "https://github.com/PxaMMaxP/eslint-plugin-override",
|
|
||||||
"jest": "^29.7.0",
|
|
||||||
"ts-jest": "^29.2.3",
|
|
||||||
"typedoc": "^0.26.5",
|
|
||||||
"istanbul-badges-readme": "^1.9.0",
|
|
||||||
"axios": "^1.7.2"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"eslint-plugin-prettier": "^5.2.1",
|
|
||||||
"jest-environment-jsdom": "^29.7.0"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"dist/**/*",
|
|
||||||
"src/**/*",
|
|
||||||
"README.md",
|
|
||||||
"LICENSE",
|
|
||||||
"package.json"
|
|
||||||
]
|
|
||||||
}
|
|
@@ -1,46 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const coverageDir = path.join(__dirname, '..', '.locale', 'coverage');
|
|
||||||
const typedocUrl = '../../';
|
|
||||||
|
|
||||||
const getAllFiles = (dir, files = []) => {
|
|
||||||
fs.readdirSync(dir).forEach(file => {
|
|
||||||
const fullPath = path.join(dir, file);
|
|
||||||
if (fs.statSync(fullPath).isDirectory()) {
|
|
||||||
getAllFiles(fullPath, files);
|
|
||||||
} else {
|
|
||||||
files.push(fullPath);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return files;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Alle HTML-Dateien im coverage-Ordner finden
|
|
||||||
const htmlFiles = getAllFiles(coverageDir).filter(file => file.endsWith('.html'));
|
|
||||||
|
|
||||||
// Alle HTML-Dateien bearbeiten
|
|
||||||
htmlFiles.forEach(filePath => {
|
|
||||||
fs.readFile(filePath, 'utf8', (err, data) => {
|
|
||||||
if (err) {
|
|
||||||
console.error(`Error reading file ${filePath}:`, err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Relative Pfade anpassen
|
|
||||||
let fixedData = data.replace(/(src|href)="(?!\.)/g, '$1="./');
|
|
||||||
|
|
||||||
// Link zur TypeDoc-Dokumentation hinzufügen
|
|
||||||
const linkHtml = `<div style="position: fixed; bottom: 10px; right: 10px;"><a href="${typedocUrl}">Zur TypeDoc-Dokumentation</a></div>`;
|
|
||||||
fixedData = fixedData.replace('</body>', `${linkHtml}</body>`);
|
|
||||||
|
|
||||||
fs.writeFile(filePath, fixedData, 'utf8', (err) => {
|
|
||||||
if (err) {
|
|
||||||
console.error(`Error writing file ${filePath}:`, err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`Fixed paths and added link in ${filePath}`);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,55 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const { exec } = require('child_process');
|
|
||||||
const axios = require('axios');
|
|
||||||
|
|
||||||
// Step 1: Create README.md in the coverage directory
|
|
||||||
const coverageReadmePath = path.join(__dirname, '..', '.locale', 'coverage', 'README.md');
|
|
||||||
const readmeContent = `
|
|
||||||

|
|
||||||

|
|
||||||

|
|
||||||

|
|
||||||
`;
|
|
||||||
|
|
||||||
fs.writeFileSync(coverageReadmePath, readmeContent, 'utf8');
|
|
||||||
|
|
||||||
// Step 2: Execute the istanbul-badges-readme tool
|
|
||||||
exec('npx istanbul-badges-readme --coverageDir=./.locale/coverage --readmeDir=./.locale/coverage', (err, stdout, stderr) => {
|
|
||||||
if (err) {
|
|
||||||
console.error(`Error executing istanbul-badges-readme: ${stderr}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log('Badges generated successfully.');
|
|
||||||
|
|
||||||
// Step 3: Extract the badge links from README.md
|
|
||||||
const updatedReadmeContent = fs.readFileSync(coverageReadmePath, 'utf8');
|
|
||||||
const badgeLines = updatedReadmeContent.split('\n').filter(line => line.includes('https://img.shields.io'));
|
|
||||||
|
|
||||||
// Ensure the target directory exists
|
|
||||||
const badgesDir = path.join(__dirname, '..', '.locale', 'coverage', 'badges');
|
|
||||||
if (!fs.existsSync(badgesDir)) {
|
|
||||||
fs.mkdirSync(badgesDir, { recursive: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Badge types and their order
|
|
||||||
const badgeTypes = ['statements', 'branches', 'functions', 'lines'];
|
|
||||||
|
|
||||||
// Save the badge images
|
|
||||||
badgeLines.forEach(async (line, index) => {
|
|
||||||
const match = line.match(/\((https:\/\/img\.shields\.io\/badge\/[^)]+)\)/);
|
|
||||||
if (match) {
|
|
||||||
const url = match[1];
|
|
||||||
const response = await axios.get(url, { responseType: 'arraybuffer' });
|
|
||||||
const buffer = Buffer.from(response.data, 'binary');
|
|
||||||
const fileName = `badge-${badgeTypes[index]}.svg`;
|
|
||||||
const filePath = path.join(badgesDir, fileName);
|
|
||||||
fs.writeFileSync(filePath, buffer);
|
|
||||||
console.log(`Saved ${fileName}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Step 4: Delete the README.md file
|
|
||||||
fs.unlinkSync(coverageReadmePath);
|
|
||||||
console.log('README.md file deleted.');
|
|
||||||
});
|
|
@@ -1,17 +0,0 @@
|
|||||||
// jest.setup.js
|
|
||||||
const getCircularReplacer = () => {
|
|
||||||
const seen = new WeakSet();
|
|
||||||
return (key, value) => {
|
|
||||||
if (typeof value === 'object' && value !== null) {
|
|
||||||
if (seen.has(value)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
seen.add(value);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
global.customJSONStringify = (object) => {
|
|
||||||
return JSON.stringify(object, getCircularReplacer());
|
|
||||||
};
|
|
@@ -1,42 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const docsDir = path.join(__dirname, '..', '.locale', 'docs');
|
|
||||||
|
|
||||||
const getAllFiles = (dir, files = []) => {
|
|
||||||
fs.readdirSync(dir).forEach(file => {
|
|
||||||
const fullPath = path.join(dir, file);
|
|
||||||
if (fs.statSync(fullPath).isDirectory()) {
|
|
||||||
getAllFiles(fullPath, files);
|
|
||||||
} else {
|
|
||||||
files.push(fullPath);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return files;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Alle HTML-Dateien im docs-Ordner finden
|
|
||||||
const htmlFiles = getAllFiles(docsDir).filter(file => file.endsWith('.html'));
|
|
||||||
|
|
||||||
// Alle HTML-Dateien bearbeiten
|
|
||||||
htmlFiles.forEach(filePath => {
|
|
||||||
fs.readFile(filePath, 'utf8', (err, data) => {
|
|
||||||
if (err) {
|
|
||||||
console.error(`Error reading file ${filePath}:`, err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// `\@` durch `@` ersetzen
|
|
||||||
let fixedData = data.replace(/\\@/g, '@');
|
|
||||||
|
|
||||||
fs.writeFile(filePath, fixedData, 'utf8', (err) => {
|
|
||||||
if (err) {
|
|
||||||
console.error(`Error writing file ${filePath}:`, err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`Fixed escaping in ${filePath}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
@@ -1,394 +0,0 @@
|
|||||||
/* istanbul ignore file */
|
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
import { Inject } from '../decorators/Inject.js';
|
|
||||||
import { DependencyResolutionError } from '../interfaces/Exceptions.js';
|
|
||||||
import { ITSinjex_, ITSinjex } from '../interfaces/ITSinjex.js';
|
|
||||||
import { ForceConstructor } from '../types/GenericContructor.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test the Inject decorator.
|
|
||||||
* @param Container The implementation to test.
|
|
||||||
* @param inject The Inject decorator to test.
|
|
||||||
*/
|
|
||||||
export function test_InjectDecorator(
|
|
||||||
Container: ITSinjex_,
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
||||||
inject: Function,
|
|
||||||
): void {
|
|
||||||
describe('Inject Decorator Tests', () => {
|
|
||||||
let container: ITSinjex;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
(Container as any)['_instance'] = undefined;
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
(Container as any)['_dependencies'] = undefined;
|
|
||||||
container = Container.getInstance();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should inject dependency when necessary is true', () => {
|
|
||||||
container.register('MockDependencyIdentifier', {
|
|
||||||
value: 'test-value',
|
|
||||||
});
|
|
||||||
|
|
||||||
class TestClass {
|
|
||||||
@Inject('MockDependencyIdentifier')
|
|
||||||
private readonly _dependency!: any;
|
|
||||||
|
|
||||||
public getDependency() {
|
|
||||||
return this._dependency;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const instance = new TestClass();
|
|
||||||
expect(instance.getDependency().value).toBe('test-value');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should inject dependency and run initializer', () => {
|
|
||||||
container.register('MockDependencyIdentifier', {
|
|
||||||
value: 'test-value',
|
|
||||||
});
|
|
||||||
|
|
||||||
class TestClass {
|
|
||||||
@Inject('MockDependencyIdentifier', (x: string) => {
|
|
||||||
(x as unknown as { value: string }).value =
|
|
||||||
'test-value-init';
|
|
||||||
|
|
||||||
return x;
|
|
||||||
})
|
|
||||||
dependency!: any;
|
|
||||||
|
|
||||||
public getDependency() {
|
|
||||||
return this.dependency;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const instance = new TestClass();
|
|
||||||
expect(instance.getDependency().value).toBe('test-value-init');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw an error when necessary is true and the initializer throws an error', () => {
|
|
||||||
let _error: Error | undefined = undefined;
|
|
||||||
|
|
||||||
container.register('InitThrowDependencie', {
|
|
||||||
value: 'test-value',
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
class TestClass {
|
|
||||||
@Inject(
|
|
||||||
'InitThrowDependencie',
|
|
||||||
() => {
|
|
||||||
throw new Error('Initializer error');
|
|
||||||
},
|
|
||||||
true,
|
|
||||||
)
|
|
||||||
dependency!: any;
|
|
||||||
|
|
||||||
public getDependency() {
|
|
||||||
return this.dependency;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const _instance = new TestClass();
|
|
||||||
console.log(_instance.getDependency());
|
|
||||||
} catch (error) {
|
|
||||||
_error = error;
|
|
||||||
}
|
|
||||||
expect(_error).toBeInstanceOf(Error);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw an error when necessary is true and dependency is not found', () => {
|
|
||||||
let _error: Error | undefined = undefined;
|
|
||||||
|
|
||||||
try {
|
|
||||||
class TestClass {
|
|
||||||
@Inject('NonExistentDependencyIdentifier')
|
|
||||||
private readonly _dependency!: any;
|
|
||||||
|
|
||||||
public getDependency() {
|
|
||||||
return this._dependency;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const _instance = new TestClass();
|
|
||||||
console.log(_instance.getDependency());
|
|
||||||
} catch (error) {
|
|
||||||
_error = error;
|
|
||||||
}
|
|
||||||
expect(_error).toBeInstanceOf(DependencyResolutionError);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should replace the property with the resolved dependency', () => {
|
|
||||||
container.register('MockDependencyIdentifier', {
|
|
||||||
value: 'test-value',
|
|
||||||
});
|
|
||||||
|
|
||||||
class TestClass {
|
|
||||||
@Inject('MockDependencyIdentifier')
|
|
||||||
private readonly _dependency!: any;
|
|
||||||
|
|
||||||
public getDependency() {
|
|
||||||
return this._dependency;
|
|
||||||
}
|
|
||||||
|
|
||||||
public isDependencyTypeofFunction() {
|
|
||||||
return typeof this._dependency === 'function';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const instance = new TestClass();
|
|
||||||
|
|
||||||
expect(instance.getDependency().value).toBe('test-value');
|
|
||||||
|
|
||||||
expect(instance.isDependencyTypeofFunction()).toBe(false);
|
|
||||||
expect(instance.getDependency().value).toBe('test-value');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should use a empty initializer when none is provided but true', () => {
|
|
||||||
container.register(
|
|
||||||
'MockDependencyIdentifier',
|
|
||||||
class X {
|
|
||||||
public value: string = 'test-value';
|
|
||||||
constructor() {}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
class TestClass {
|
|
||||||
@Inject('MockDependencyIdentifier', true)
|
|
||||||
private readonly _dependency!: any;
|
|
||||||
|
|
||||||
public getDependency() {
|
|
||||||
return this._dependency;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const instance = new TestClass();
|
|
||||||
expect(instance.getDependency().value).toBe('test-value');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw an error when the dependency has no instantiation method', () => {
|
|
||||||
container.register('MockDependencyIdentifier', {
|
|
||||||
value: 'test-value',
|
|
||||||
});
|
|
||||||
|
|
||||||
class TestClass {
|
|
||||||
@Inject('MockDependencyIdentifier', true)
|
|
||||||
private readonly _dependency!: any;
|
|
||||||
|
|
||||||
public getDependency() {
|
|
||||||
return this._dependency;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(() => {
|
|
||||||
const instance = new TestClass();
|
|
||||||
instance.getDependency();
|
|
||||||
}).toThrow(new RegExp('No instantiation method found for.*'));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not throw an error when the dependency has no instantiation method if not necessary', () => {
|
|
||||||
container.register('MockDependencyIdentifier', {
|
|
||||||
value: 'test-value',
|
|
||||||
});
|
|
||||||
|
|
||||||
class TestClass {
|
|
||||||
@Inject('MockDependencyIdentifier', true, false)
|
|
||||||
private readonly _dependency!: any;
|
|
||||||
|
|
||||||
public getDependency() {
|
|
||||||
return this._dependency;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(() => {
|
|
||||||
const instance = new TestClass();
|
|
||||||
instance.getDependency();
|
|
||||||
}).not.toThrow(new RegExp('No instantiation method found for.*'));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw an error when the dependency cannot be resolved', () => {
|
|
||||||
container.register('MockDependencyIdentifier', null);
|
|
||||||
|
|
||||||
class TestClass {
|
|
||||||
@Inject('MockDependencyIdentifier', true)
|
|
||||||
private readonly _dependency!: any;
|
|
||||||
|
|
||||||
public getDependency() {
|
|
||||||
return this._dependency;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(() => {
|
|
||||||
const instance = new TestClass();
|
|
||||||
instance.getDependency();
|
|
||||||
}).toThrow(new RegExp('.*could not be resolved.*'));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not throw an error when the dependency cannot be resolved if not necessary', () => {
|
|
||||||
container.register('MockDependencyIdentifier', null);
|
|
||||||
|
|
||||||
class TestClass {
|
|
||||||
@Inject('MockDependencyIdentifier', true, false)
|
|
||||||
private readonly _dependency!: any;
|
|
||||||
|
|
||||||
public getDependency() {
|
|
||||||
return this._dependency;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(() => {
|
|
||||||
const instance = new TestClass();
|
|
||||||
instance.getDependency();
|
|
||||||
}).not.toThrow(new RegExp('.*could not be resolved.*'));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function test_RegisterDecorator(
|
|
||||||
Container: ITSinjex_,
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
||||||
register: Function,
|
|
||||||
): void {
|
|
||||||
describe('Register Decorator Tests', () => {
|
|
||||||
let container: ITSinjex;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
(Container as any)['_instance'] = undefined;
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
(Container as any)['_dependencies'] = undefined;
|
|
||||||
container = Container.getInstance();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should register a dependency', () => {
|
|
||||||
@register('MockDependencyIdentifier')
|
|
||||||
class TestClass {
|
|
||||||
private readonly _dependency!: any;
|
|
||||||
|
|
||||||
public getDependency() {
|
|
||||||
return this._dependency;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(container.resolve('MockDependencyIdentifier')).toBe(
|
|
||||||
TestClass,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function test_RegisterInstanceDecorator(
|
|
||||||
Container: ITSinjex_,
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
||||||
registerInstance: Function,
|
|
||||||
mode: 'instance' | 'standalone' = 'standalone',
|
|
||||||
): void {
|
|
||||||
describe('RegisterInstance Decorator Tests', () => {
|
|
||||||
let container: ITSinjex;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
(Container as any)['_instance'] = undefined;
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
(Container as any)['_dependencies'] = undefined;
|
|
||||||
container = Container.getInstance();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should register an instance of a dependency', () => {
|
|
||||||
@registerInstance(
|
|
||||||
'InstanceIdentifier',
|
|
||||||
mode === 'instance' ? 'instance' : undefined,
|
|
||||||
)
|
|
||||||
class TestClass {
|
|
||||||
private readonly _dependency!: any;
|
|
||||||
|
|
||||||
public getDependency() {
|
|
||||||
return this._dependency;
|
|
||||||
}
|
|
||||||
|
|
||||||
public mark: string = 'instance';
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(
|
|
||||||
container.resolve<TestClass>('InstanceIdentifier').mark,
|
|
||||||
).toBe('instance');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should register an instance of a dependency an run the init function', () => {
|
|
||||||
@registerInstance(
|
|
||||||
'InstanceIdentifier',
|
|
||||||
(x: ForceConstructor<TestClass>) => {
|
|
||||||
const instance = new x();
|
|
||||||
instance.mark = 'init';
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
},
|
|
||||||
)
|
|
||||||
class TestClass {
|
|
||||||
private readonly _dependency!: any;
|
|
||||||
|
|
||||||
public getDependency() {
|
|
||||||
return this._dependency;
|
|
||||||
}
|
|
||||||
|
|
||||||
public mark: string = 'instance';
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(
|
|
||||||
container.resolve<TestClass>('InstanceIdentifier').mark,
|
|
||||||
).toBe('init');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should register an instance of a dependency and get it on set', () => {
|
|
||||||
@registerInstance(
|
|
||||||
'InstanceIdentifier',
|
|
||||||
mode === 'instance' ? 'instance' : undefined,
|
|
||||||
)
|
|
||||||
class TestClass {
|
|
||||||
private readonly _dependency!: any;
|
|
||||||
|
|
||||||
public getDependency() {
|
|
||||||
return this._dependency;
|
|
||||||
}
|
|
||||||
|
|
||||||
public mark: string = 'instance';
|
|
||||||
public test: string = 'test';
|
|
||||||
}
|
|
||||||
|
|
||||||
container.resolve<TestClass>('InstanceIdentifier').test = 'test2';
|
|
||||||
|
|
||||||
expect(
|
|
||||||
container.resolve<TestClass>('InstanceIdentifier').test,
|
|
||||||
).toBe('test2');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should register an instance of a dependency an run the init function on set', () => {
|
|
||||||
@registerInstance(
|
|
||||||
'InstanceIdentifier',
|
|
||||||
(x: ForceConstructor<TestClass>) => {
|
|
||||||
const instance = new x();
|
|
||||||
instance.mark = 'init';
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
},
|
|
||||||
)
|
|
||||||
class TestClass {
|
|
||||||
private readonly _dependency!: any;
|
|
||||||
|
|
||||||
public getDependency() {
|
|
||||||
return this._dependency;
|
|
||||||
}
|
|
||||||
|
|
||||||
public mark: string = 'instance';
|
|
||||||
public test: string = 'test';
|
|
||||||
}
|
|
||||||
|
|
||||||
container.resolve<TestClass>('InstanceIdentifier').test = 'test2';
|
|
||||||
|
|
||||||
expect(
|
|
||||||
container.resolve<TestClass>('InstanceIdentifier').test,
|
|
||||||
).toBe('test2');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
@@ -1,18 +0,0 @@
|
|||||||
/* eslint-disable deprecation/deprecation */
|
|
||||||
import { TSinjex } from 'src/classes/TSinjex.js';
|
|
||||||
import { Inject } from 'src/decorators/Inject.js';
|
|
||||||
import { Register } from 'src/decorators/Register.js';
|
|
||||||
import { RegisterInstance } from 'src/decorators/RegisterInstance.js';
|
|
||||||
import {
|
|
||||||
test_InjectDecorator,
|
|
||||||
test_RegisterDecorator,
|
|
||||||
test_RegisterInstanceDecorator,
|
|
||||||
} from './Decorators.spec.js';
|
|
||||||
|
|
||||||
test_InjectDecorator(TSinjex, Inject);
|
|
||||||
|
|
||||||
test_RegisterDecorator(TSinjex, Register);
|
|
||||||
|
|
||||||
test_RegisterInstanceDecorator(TSinjex, RegisterInstance);
|
|
||||||
|
|
||||||
test_RegisterInstanceDecorator(TSinjex, Register, 'instance');
|
|
@@ -1,184 +0,0 @@
|
|||||||
/* istanbul ignore file */
|
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
import {
|
|
||||||
DependencyResolutionError,
|
|
||||||
InitializationError,
|
|
||||||
NoInstantiationMethodError,
|
|
||||||
} from '../interfaces/Exceptions.js';
|
|
||||||
import { ITSinjex, ITSinjex_ } from '../interfaces/ITSinjex.js';
|
|
||||||
|
|
||||||
export function test_RegisterFunction(
|
|
||||||
Container: ITSinjex_,
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
||||||
register: Function,
|
|
||||||
): void {
|
|
||||||
describe('Register Function Tests', () => {
|
|
||||||
let container: ITSinjex;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
(Container as any)['_instance'] = undefined;
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
(Container as any)['_dependencies'] = undefined;
|
|
||||||
container = Container.getInstance();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should register a dependency', () => {
|
|
||||||
const identifier = 'MockDependencyIdentifier';
|
|
||||||
class TestClass {
|
|
||||||
private readonly _dependency!: any;
|
|
||||||
|
|
||||||
public getDependency() {
|
|
||||||
return this._dependency;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
register(identifier, TestClass, false);
|
|
||||||
|
|
||||||
const resolvedDependency = container.resolve(identifier);
|
|
||||||
expect(resolvedDependency).toBe(TestClass);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function test_ResolveFunction(
|
|
||||||
Container: ITSinjex_,
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
||||||
resolve: Function,
|
|
||||||
): void {
|
|
||||||
describe('Resolve Function Tests', () => {
|
|
||||||
let container: ITSinjex;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
(Container as any)['_instance'] = undefined;
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
(Container as any)['_dependencies'] = undefined;
|
|
||||||
container = Container.getInstance();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should resolve a dependency', () => {
|
|
||||||
const identifier = 'MockDependencyIdentifier';
|
|
||||||
class TestClass {
|
|
||||||
private readonly _dependency!: any;
|
|
||||||
|
|
||||||
public getDependency() {
|
|
||||||
return this._dependency;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
container.register(identifier, TestClass);
|
|
||||||
|
|
||||||
const resolvedDependency = resolve(identifier);
|
|
||||||
expect(resolvedDependency).toBe(TestClass);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test the inject function.
|
|
||||||
* @param Container The DI container implementation to test against.
|
|
||||||
* @param inject The inject function to test.
|
|
||||||
*/
|
|
||||||
export function test_injectFunction(
|
|
||||||
Container: ITSinjex_,
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
||||||
inject: Function,
|
|
||||||
): void {
|
|
||||||
describe('inject Function Tests', () => {
|
|
||||||
let container: ITSinjex;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
// Reset singleton
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
(Container as any)['_instance'] = undefined;
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
(Container as any)['_dependencies'] = undefined;
|
|
||||||
container = Container.getInstance();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should resolve and return the dependency as is', () => {
|
|
||||||
container.register('SimpleDep', { value: 'test' });
|
|
||||||
|
|
||||||
const resolved = inject('SimpleDep');
|
|
||||||
expect(resolved.value).toBe('test');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should resolve and run the initializer function', () => {
|
|
||||||
container.register('DepWithInit', { value: 'before' });
|
|
||||||
|
|
||||||
const resolved = inject('DepWithInit', (dep: any) => {
|
|
||||||
dep.value = 'after';
|
|
||||||
|
|
||||||
return dep;
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(resolved.value).toBe('after');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should resolve and instantiate the dependency if init is true and constructor exists', () => {
|
|
||||||
class WithConstructor {
|
|
||||||
value = 'constructed';
|
|
||||||
}
|
|
||||||
|
|
||||||
container.register('Constructable', WithConstructor);
|
|
||||||
|
|
||||||
const resolved = inject('Constructable', true);
|
|
||||||
expect(resolved.value).toBe('constructed');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return undefined if dependency is not found and not necessary', () => {
|
|
||||||
const resolved = inject('NonExistentDep', undefined, false);
|
|
||||||
expect(resolved).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw DependencyResolutionError if dependency is not found and necessary', () => {
|
|
||||||
expect(() => inject('MissingDep')).toThrow(
|
|
||||||
DependencyResolutionError,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw InitializationError if init function throws', () => {
|
|
||||||
container.register('InitThrows', {});
|
|
||||||
|
|
||||||
expect(() =>
|
|
||||||
inject('InitThrows', () => {
|
|
||||||
throw new Error('fail');
|
|
||||||
}),
|
|
||||||
).toThrow(InitializationError);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw NoInstantiationMethodError if init = true and no constructor exists', () => {
|
|
||||||
container.register('NonConstructable', {});
|
|
||||||
|
|
||||||
expect(() => inject('NonConstructable', true)).toThrow(
|
|
||||||
NoInstantiationMethodError,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not throw if no constructor and necessary = false', () => {
|
|
||||||
container.register('SafeSkip', {});
|
|
||||||
expect(() => inject('SafeSkip', true, false)).not.toThrow();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return undefined if initializer fails and not necessary', () => {
|
|
||||||
container.register('InitErrorOptional', {});
|
|
||||||
|
|
||||||
const result = inject(
|
|
||||||
'InitErrorOptional',
|
|
||||||
() => {
|
|
||||||
throw new Error('ignored');
|
|
||||||
},
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(result).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return undefined if dependency is null and not necessary', () => {
|
|
||||||
container.register('NullDep', null);
|
|
||||||
const result = inject('NullDep', true, false);
|
|
||||||
expect(result).toBeUndefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
@@ -1,13 +0,0 @@
|
|||||||
import {
|
|
||||||
test_injectFunction,
|
|
||||||
test_RegisterFunction,
|
|
||||||
test_ResolveFunction,
|
|
||||||
} from './Functions.spec.js';
|
|
||||||
import { TSinjex } from '../classes/TSinjex.js';
|
|
||||||
import { inject } from '../functions/inject.js';
|
|
||||||
import { register } from '../functions/register.js';
|
|
||||||
import { resolve } from '../functions/resolve.js';
|
|
||||||
|
|
||||||
test_RegisterFunction(TSinjex, register);
|
|
||||||
test_ResolveFunction(TSinjex, resolve);
|
|
||||||
test_injectFunction(TSinjex, inject);
|
|
@@ -1,79 +0,0 @@
|
|||||||
/* istanbul ignore file */
|
|
||||||
import { ITSinjex_, ITSinjex } from '../interfaces/ITSinjex.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test the implementation of the `ITSinjex` interface.
|
|
||||||
* @param Container The implementation to test.
|
|
||||||
* Must implement {@link ITSinjex}, {@link ITSinjex_}
|
|
||||||
*/
|
|
||||||
export function test_ITSinjex(Container: ITSinjex_): void {
|
|
||||||
describe('IDIContainer Implementation Tests', () => {
|
|
||||||
let container: ITSinjex;
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
(Container as any)['_instance'] = undefined;
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
(Container as any)['_dependencies'] = undefined;
|
|
||||||
container = Container.getInstance();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should register and resolve a dependency', () => {
|
|
||||||
const identifier = 'myDependency';
|
|
||||||
const dependency = { value: 42 };
|
|
||||||
|
|
||||||
container.register(identifier, dependency);
|
|
||||||
|
|
||||||
const resolvedDependency =
|
|
||||||
container.resolve<typeof dependency>(identifier);
|
|
||||||
expect(resolvedDependency).toBe(dependency);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should register and resolve a dependency static', () => {
|
|
||||||
const identifier = 'myDependency';
|
|
||||||
const dependency = { value: 42 };
|
|
||||||
|
|
||||||
Container.register(identifier, dependency);
|
|
||||||
|
|
||||||
const resolvedDependency =
|
|
||||||
Container.resolve<typeof dependency>(identifier);
|
|
||||||
expect(resolvedDependency).toBe(dependency);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should throw an error when resolving a non-registered dependency static', () => {
|
|
||||||
const identifier = 'nonExistentDependency';
|
|
||||||
|
|
||||||
expect(() => Container.resolve<unknown>(identifier)).toThrow();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return undefined when resolving a non-registered, non-necessary dependency', () => {
|
|
||||||
const resolvedDependency = Container.resolve<unknown>(
|
|
||||||
'nonExistentDependency',
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
expect(resolvedDependency).toBe(undefined);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should warn when resolving a deprecated dependency', () => {
|
|
||||||
const identifier = 'deprecatedDependency';
|
|
||||||
const dependency = { value: 42 };
|
|
||||||
|
|
||||||
// Spy on console.warn
|
|
||||||
const warnSpy = jest
|
|
||||||
.spyOn(console, 'warn')
|
|
||||||
.mockImplementation(() => {});
|
|
||||||
|
|
||||||
Container.register(identifier, dependency, true);
|
|
||||||
|
|
||||||
const resolvedDependency =
|
|
||||||
Container.resolve<typeof dependency>(identifier);
|
|
||||||
expect(resolvedDependency).toBe(dependency);
|
|
||||||
|
|
||||||
// Expect console.warn to be called
|
|
||||||
expect(warnSpy).toHaveBeenCalled();
|
|
||||||
|
|
||||||
// Restore the original console.warn
|
|
||||||
warnSpy.mockRestore();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
@@ -1,4 +0,0 @@
|
|||||||
import { test_ITSinjex } from './ITSinjex.spec.js';
|
|
||||||
import { TSinjex } from '../classes/TSinjex.js';
|
|
||||||
|
|
||||||
test_ITSinjex(TSinjex);
|
|
@@ -1,39 +0,0 @@
|
|||||||
import { Register } from './Register.js';
|
|
||||||
import { Identifier } from '../types/Identifier.js';
|
|
||||||
import { InitDelegate } from '../types/InitDelegate.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A decorator to register an instance of a class in the DI (Dependency Injection) container.
|
|
||||||
* @template TargetType The type of the class whose instance is to be registered.
|
|
||||||
* @param identifier The identifier used to register the instance in the DI container.
|
|
||||||
* @see {@link Identifier} for more information on identifiers.
|
|
||||||
* @param init An optional initializer function which get the constructor of the class
|
|
||||||
* as input and returns an instance of the class.
|
|
||||||
* @param deprecated If true, the dependency is deprecated and a warning
|
|
||||||
* is logged only once upon the first resolution of the dependency.
|
|
||||||
* @see {@link InitDelegate} for more information on initializer functions.
|
|
||||||
* @returns The decorator function to be applied on the class.
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* \@RegisterInstance('MyClassInstanceIdentifier', (constructor) => new constructor())
|
|
||||||
* class MyClass {
|
|
||||||
* // ...
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
* @deprecated Use {@link Register} instead. This decorator already uses the {@link Register} decorator internally.
|
|
||||||
*/
|
|
||||||
export function RegisterInstance<
|
|
||||||
TargetType extends new (..._args: unknown[]) => InstanceType<TargetType>,
|
|
||||||
>(
|
|
||||||
identifier: Identifier,
|
|
||||||
init?: InitDelegate<
|
|
||||||
TargetType & { new (..._args: unknown[]): InstanceType<TargetType> },
|
|
||||||
InstanceType<TargetType>
|
|
||||||
>,
|
|
||||||
deprecated?: boolean,
|
|
||||||
): (constructor: TargetType, ...args: unknown[]) => void {
|
|
||||||
const initDelegate = typeof init === 'function' ? init : undefined;
|
|
||||||
|
|
||||||
if (initDelegate) return Register(identifier, initDelegate, deprecated);
|
|
||||||
else return Register(identifier, 'instance', deprecated);
|
|
||||||
}
|
|
@@ -1,220 +0,0 @@
|
|||||||
import { TSinjex } from '../classes/TSinjex.js';
|
|
||||||
import {
|
|
||||||
DependencyResolutionError,
|
|
||||||
InitializationError,
|
|
||||||
InjectorError,
|
|
||||||
NoInstantiationMethodError,
|
|
||||||
} from '../interfaces/Exceptions.js';
|
|
||||||
import { Identifier } from '../types/Identifier.js';
|
|
||||||
import { InitDelegate } from '../types/InitDelegate.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolves a dependency by its identifier without initialization or instantiation.
|
|
||||||
* @template T The expected type of the dependency.
|
|
||||||
* @param identifier The identifier used to resolve the dependency from the container.
|
|
||||||
* @returns The resolved dependency.
|
|
||||||
* @throws A {@link DependencyResolutionError} if the dependency is not found.
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const logger = inject<Logger>('Logger');
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export function inject<T>(identifier: Identifier): T;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolves and instantiates a dependency using its constructor.
|
|
||||||
* @template T The expected class type of the dependency.
|
|
||||||
* @param identifier The identifier used to resolve the dependency from the container.
|
|
||||||
* @param shouldInit Set to `true` to instantiate the dependency after resolution.
|
|
||||||
* @returns The resolved and instantiated dependency.
|
|
||||||
* @throws A {@link DependencyResolutionError} if the dependency is not found.
|
|
||||||
* @throws A {@link NoInstantiationMethodError} if the dependency has no constructor.
|
|
||||||
* @throws An {@link InitializationError} if instantiation fails.
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const instance = inject<Service>('Service', true);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export function inject<T>(identifier: Identifier, shouldInit: true): T;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolves and instantiates a dependency using its constructor, optionally failing silently.
|
|
||||||
* @template T The expected class type of the dependency.
|
|
||||||
* @param identifier The identifier used to resolve the dependency from the container.
|
|
||||||
* @param shouldInit Set to `true` to instantiate the dependency.
|
|
||||||
* @param isNecessary If `false`, resolution or instantiation errors return `undefined` instead of throwing.
|
|
||||||
* @returns The resolved and instantiated dependency, or `undefined` if resolution or instantiation fails.
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const instance = inject<Service>('OptionalService', true, false);
|
|
||||||
* if (instance) instance.doSomething();
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export function inject<T>(
|
|
||||||
identifier: Identifier,
|
|
||||||
shouldInit: true,
|
|
||||||
isNecessary: false,
|
|
||||||
): T | undefined;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolves a dependency without instantiating it, optionally failing silently.
|
|
||||||
* @template T The expected type of the dependency.
|
|
||||||
* @param identifier The identifier used to resolve the dependency from the container.
|
|
||||||
* @param shouldInit Set to `false` to skip instantiation.
|
|
||||||
* @param isNecessary If `false`, resolution errors return `undefined` instead of throwing.
|
|
||||||
* @returns The resolved dependency, or `undefined` if not found.
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const config = inject<Config>('Config', false, false) ?? getDefaultConfig();
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export function inject<T>(
|
|
||||||
identifier: Identifier,
|
|
||||||
shouldInit: false,
|
|
||||||
isNecessary: false,
|
|
||||||
): T | undefined;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolves a dependency and applies a custom initializer function to transform the result.
|
|
||||||
* @template T The original dependency type.
|
|
||||||
* @template U The final return type after initialization.
|
|
||||||
* @param identifier The identifier used to resolve the dependency.
|
|
||||||
* @param init A function to transform or initialize the dependency.
|
|
||||||
* @returns The transformed dependency.
|
|
||||||
* @throws A {@link DependencyResolutionError} if the dependency is not found.
|
|
||||||
* @throws An {@link InitializationError} if the initializer throws.
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const client = inject<Api>('Api', (api) => api.getClient());
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export function inject<T, U>(
|
|
||||||
identifier: Identifier,
|
|
||||||
init: InitDelegate<T, U>,
|
|
||||||
): U;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolves a dependency and applies a custom initializer function, optionally failing silently.
|
|
||||||
* @template T The original dependency type.
|
|
||||||
* @template U The final return type after initialization.
|
|
||||||
* @param identifier The identifier used to resolve the dependency.
|
|
||||||
* @param init A function to transform or initialize the dependency.
|
|
||||||
* @param isNecessary If `false`, resolution or initializer errors return `undefined` instead of throwing.
|
|
||||||
* @returns The transformed dependency, or `undefined` if resolution or initialization fails.
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const db = inject<Database, Pool>('Database', (d) => d.getPool(), false);
|
|
||||||
* if (db) db.query('SELECT * FROM users');
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export function inject<T, U>(
|
|
||||||
identifier: Identifier,
|
|
||||||
init: InitDelegate<T, U>,
|
|
||||||
isNecessary: false,
|
|
||||||
): U | undefined;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A function to inject a dependency from a DI (Dependency Injection) container into a variable.
|
|
||||||
* This is the actual implementation that handles all overload variants.
|
|
||||||
* @template T The original dependency type.
|
|
||||||
* @template U The final return type after optional initialization or transformation.
|
|
||||||
* @param identifier The identifier used to resolve the dependency.
|
|
||||||
* @see {@link Identifier} for more information on identifiers.
|
|
||||||
* @param init Optional: either `true` to instantiate via constructor, `false` to skip, or a function to transform the dependency.
|
|
||||||
* @see {@link InitDelegate} for more information on initializer functions.
|
|
||||||
* @param isNecessary If `true`, throws on failure; if `false`, returns `undefined` on resolution or initialization errors.
|
|
||||||
* @returns The resolved dependency or result of initialization, or `undefined` if not necessary and resolution fails.
|
|
||||||
* @throws A {@link DependencyResolutionError} if the dependency is not found (and necessary).
|
|
||||||
* @throws A {@link NoInstantiationMethodError} if instantiation is requested but no constructor exists.
|
|
||||||
* @throws An {@link InitializationError} if the initializer throws an error.
|
|
||||||
* @throws A {@link InjectorError} for unknown errors during resolution or transformation.
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const service = inject<Service>('Service');
|
|
||||||
* ```
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const instance = inject<Service>('Service', true);
|
|
||||||
* ```
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const logger = inject<ILogger>('ILogger_', (x) => x.getLogger('Module'), false);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export function inject<T, U>(
|
|
||||||
identifier: Identifier,
|
|
||||||
init?: InitDelegate<T, U> | true | false,
|
|
||||||
isNecessary = true,
|
|
||||||
): T | U | undefined {
|
|
||||||
let instance: T | U | undefined;
|
|
||||||
|
|
||||||
const dependency: T | undefined = tryAndCatch(
|
|
||||||
() => TSinjex.getInstance().resolve<T>(identifier, isNecessary),
|
|
||||||
isNecessary,
|
|
||||||
identifier,
|
|
||||||
DependencyResolutionError,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (dependency != null) {
|
|
||||||
const initFunction: (() => U) | undefined =
|
|
||||||
typeof init === 'function' && dependency != null
|
|
||||||
? (): U => init(dependency)
|
|
||||||
: init === true && hasConstructor(dependency)
|
|
||||||
? (): U => new dependency() as U
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
if (init == null || init === false) instance = dependency;
|
|
||||||
else if (initFunction != null)
|
|
||||||
instance = tryAndCatch(
|
|
||||||
initFunction,
|
|
||||||
isNecessary,
|
|
||||||
identifier,
|
|
||||||
InitializationError,
|
|
||||||
);
|
|
||||||
else if (isNecessary) throw new NoInstantiationMethodError(identifier);
|
|
||||||
} else if (isNecessary) throw new DependencyResolutionError(identifier);
|
|
||||||
|
|
||||||
return instance as T | U;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tries to execute a function and catches any errors that occur.
|
|
||||||
* If the function is necessary and an error occurs, it throws the error
|
|
||||||
* with the specified error class and identifier.
|
|
||||||
* @param fn The function to execute.
|
|
||||||
* @param necessary If true, throws an error if an error occurs.
|
|
||||||
* @param identifier The identifier of the dependency.
|
|
||||||
* @param errorClass The error class to throw if an error occurs.
|
|
||||||
* @returns The result of the function or undefined if an error occurs and the function is not necessary.
|
|
||||||
*/
|
|
||||||
function tryAndCatch<ReturnType, ErrorType>(
|
|
||||||
fn: () => ReturnType,
|
|
||||||
necessary: boolean,
|
|
||||||
identifier?: Identifier,
|
|
||||||
errorClass?: ErrorType,
|
|
||||||
): ReturnType | undefined {
|
|
||||||
try {
|
|
||||||
return fn();
|
|
||||||
} catch (error) {
|
|
||||||
if (necessary)
|
|
||||||
throw new (errorClass != null ? errorClass : error)(
|
|
||||||
identifier ?? 'not specified',
|
|
||||||
error,
|
|
||||||
);
|
|
||||||
else return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if an object has a constructor.
|
|
||||||
* @param obj The object to check.
|
|
||||||
* @returns True if the object has a constructor, false otherwise.
|
|
||||||
*/
|
|
||||||
function hasConstructor<T>(obj: T): obj is T & { new (): unknown } {
|
|
||||||
const _obj = obj as unknown as { prototype?: { constructor?: unknown } };
|
|
||||||
|
|
||||||
return (
|
|
||||||
_obj?.prototype != null &&
|
|
||||||
typeof _obj.prototype.constructor === 'function'
|
|
||||||
);
|
|
||||||
}
|
|
@@ -1,39 +0,0 @@
|
|||||||
import { TSinjex } from '../classes/TSinjex.js';
|
|
||||||
import { Identifier } from '../types/Identifier.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a dependency.
|
|
||||||
* @param identifier The identifier used to register the class in the DI container.
|
|
||||||
* @see {@link Identifier} for more information on identifiers..
|
|
||||||
* @param dependency The dependency to register.
|
|
||||||
*/
|
|
||||||
export function register<T>(identifier: Identifier, dependency: T): void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a dependency.
|
|
||||||
* @param identifier The identifier used to register the class in the DI container.
|
|
||||||
* @see {@link Identifier} for more information on identifiers.
|
|
||||||
* @param dependency The dependency to register.
|
|
||||||
* @param deprecated A warning is logged when the dependency is resolved.
|
|
||||||
*/
|
|
||||||
export function register<T>(
|
|
||||||
identifier: Identifier,
|
|
||||||
dependency: T,
|
|
||||||
deprecated?: true,
|
|
||||||
): void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register a dependency.
|
|
||||||
* @param identifier The identifier used to register the class in the DI container.
|
|
||||||
* @see {@link Identifier} for more information on identifiers.
|
|
||||||
* @param dependency The dependency to register.
|
|
||||||
* @param deprecated If true, the dependency is deprecated => a warning
|
|
||||||
* is logged when the dependency is resolved.
|
|
||||||
*/
|
|
||||||
export function register<T>(
|
|
||||||
identifier: Identifier,
|
|
||||||
dependency: T,
|
|
||||||
deprecated?: boolean,
|
|
||||||
): void {
|
|
||||||
TSinjex.getInstance().register(identifier, dependency, deprecated);
|
|
||||||
}
|
|
@@ -1,40 +0,0 @@
|
|||||||
import { TSinjex } from '../classes/TSinjex.js';
|
|
||||||
import { DependencyResolutionError } from '../interfaces/Exceptions.js';
|
|
||||||
import { Identifier } from '../types/Identifier.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolve a dependency.
|
|
||||||
* @param identifier The identifier used to register the class in the DI container.
|
|
||||||
* @see {@link Identifier} for more information on identifiers.
|
|
||||||
* @returns The resolved dependency.
|
|
||||||
* @throws A {@link DependencyResolutionError} if the dependency is not found.
|
|
||||||
*/
|
|
||||||
export function resolve<T>(identifier: Identifier): T;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolve a dependency
|
|
||||||
* @param identifier The identifier used to register the class in the DI container.
|
|
||||||
* @see {@link Identifier} for more information on identifiers.
|
|
||||||
* @param isNecessary The dependency is **not** necessary.
|
|
||||||
* @returns The resolved dependency or undefined if the dependency is not found.
|
|
||||||
*/
|
|
||||||
export function resolve<T>(
|
|
||||||
identifier: Identifier,
|
|
||||||
isNecessary: false,
|
|
||||||
): T | undefined;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolve a dependency.
|
|
||||||
* @param identifier The identifier used to register the class in the DI container.
|
|
||||||
* @see {@link Identifier} for more information on identifiers.
|
|
||||||
* @param necessary If true, throws an error if the dependency is not found.
|
|
||||||
* @returns The resolved dependency or undefined if the dependency is not necessary
|
|
||||||
* and not found, or throws an error if the dependency is necessary and not found.
|
|
||||||
* @throws A {@link DependencyResolutionError} if the dependency is not found and necessary.
|
|
||||||
*/
|
|
||||||
export function resolve<T>(
|
|
||||||
identifier: Identifier,
|
|
||||||
necessary?: boolean,
|
|
||||||
): T | undefined {
|
|
||||||
return TSinjex.getInstance().resolve<T>(identifier, necessary);
|
|
||||||
}
|
|
22
src/index.ts
22
src/index.ts
@@ -1,22 +0,0 @@
|
|||||||
/* istanbul ignore file */
|
|
||||||
|
|
||||||
// Main
|
|
||||||
export * from './classes/TSinjex.js';
|
|
||||||
|
|
||||||
// Decorators
|
|
||||||
export * from './decorators/Inject.js';
|
|
||||||
export * from './decorators/Register.js';
|
|
||||||
export * from './decorators/RegisterInstance.js';
|
|
||||||
|
|
||||||
// Helper
|
|
||||||
export * from './helper/ImplementsStatic.js';
|
|
||||||
|
|
||||||
// Functions
|
|
||||||
export * from './functions/resolve.js';
|
|
||||||
export * from './functions/register.js';
|
|
||||||
export * from './functions/inject.js';
|
|
||||||
|
|
||||||
// Interfaces & Types
|
|
||||||
export type * from './interfaces/ITSinjex.js';
|
|
||||||
export type * from './types/InitDelegate.js';
|
|
||||||
export type * from './types/GenericContructor.js';
|
|
@@ -1,13 +0,0 @@
|
|||||||
/**
|
|
||||||
* Generic constructor type.
|
|
||||||
* This type is used to define a constructor of a class.
|
|
||||||
*/
|
|
||||||
export type GenericConstructor<
|
|
||||||
T extends abstract new (...args: unknown[]) => InstanceType<T>,
|
|
||||||
> = new (...args: ConstructorParameters<T>) => T;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Force generic constructor type.
|
|
||||||
* This type is used to force a class to has a constructor.
|
|
||||||
*/
|
|
||||||
export type ForceConstructor<T> = new (...args: unknown[]) => T;
|
|
@@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"baseUrl": ".",
|
|
||||||
"inlineSourceMap": false,
|
|
||||||
"sourceMap": true,
|
|
||||||
"inlineSources": true,
|
|
||||||
"declaration": true,
|
|
||||||
"declarationMap": true,
|
|
||||||
"outDir": "./dist",
|
|
||||||
"module": "NodeNext",
|
|
||||||
"target": "ES2020",
|
|
||||||
"allowJs": true,
|
|
||||||
"noUnusedLocals": false,
|
|
||||||
"noUnusedParameters": false,
|
|
||||||
"noImplicitAny": true,
|
|
||||||
"moduleResolution": "NodeNext",
|
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
"importHelpers": true,
|
|
||||||
"isolatedModules": true,
|
|
||||||
"resolveJsonModule": true,
|
|
||||||
"experimentalDecorators": true,
|
|
||||||
"emitDecoratorMetadata": true,
|
|
||||||
"strictNullChecks": true,
|
|
||||||
"strictPropertyInitialization": true,
|
|
||||||
"lib": [
|
|
||||||
"DOM",
|
|
||||||
"ES5",
|
|
||||||
"ES6",
|
|
||||||
"ES7",
|
|
||||||
"ES2021.WeakRef"
|
|
||||||
],
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"forceConsistentCasingInFileNames": true
|
|
||||||
},
|
|
||||||
"include": [
|
|
||||||
"src/**/*.ts"
|
|
||||||
],
|
|
||||||
"exclude": [
|
|
||||||
"node_modules"
|
|
||||||
]
|
|
||||||
}
|
|
18
typedoc.json
18
typedoc.json
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"entryPoints": [
|
|
||||||
"src/**/*.ts"
|
|
||||||
],
|
|
||||||
"out": ".locale/docs",
|
|
||||||
"tsconfig": "tsconfig.json",
|
|
||||||
"excludePrivate": false,
|
|
||||||
"excludeProtected": false,
|
|
||||||
"excludeExternals": false,
|
|
||||||
"includeVersion": true,
|
|
||||||
"readme": "README.md",
|
|
||||||
"exclude": [
|
|
||||||
"**/*.test.ts",
|
|
||||||
"**/*.spec.ts"
|
|
||||||
],
|
|
||||||
"theme": "default",
|
|
||||||
"hideGenerator": true
|
|
||||||
}
|
|
Reference in New Issue
Block a user