diff --git a/package.json b/package.json index 2f69cd1..aeef353 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,9 @@ "type": "module", "main": "dist/index.js", "types": "dist/index.d.ts", + "files": [ + "dist" + ], "scripts": { "build:clean": "del-cli dist", "build:check": "tsc --noEmit", @@ -20,15 +23,14 @@ "dev": "node --enable-source-maps dist/index.js", "test": "yarn build && node --enable-source-maps --test", "test:only": "yarn test --test-only", - "prepare": "is-ci || husky install" + "prepare": "is-ci || husky install", + "prepublish": "tsc" }, "dependencies": { "chevrotain": "^11.0.3", "octokit": "^3.1.2", "re2": "^1.20.9", "readdirp": "^3.6.0", - "reflect-metadata": "^0.2.1", - "tsyringe": "^4.8.0", "yaml": "^2.3.4" }, "devDependencies": { @@ -47,5 +49,8 @@ "rimraf": "^5.0.5", "typescript": "^5.3.3" }, + "engines": { + "node": ">=21.0.0" + }, "packageManager": "yarn@4.0.2" } diff --git a/src/index.ts b/src/index.ts index d3cdf51..adde805 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,4 @@ export { evaluateOmega } from "./omega.js"; export * from "./rules.js"; export * from "./types/omega.js"; -export { kRules } from "./utils/symbols.js"; export * from "./utils/validator.js"; diff --git a/src/rules.ts b/src/rules.ts index 679e851..a93213a 100644 --- a/src/rules.ts +++ b/src/rules.ts @@ -1,30 +1,8 @@ import { readFile } from "node:fs/promises"; import { Octokit } from "octokit"; import readdirp from "readdirp"; -import { container } from "tsyringe"; import { parse } from "yaml"; -import type { Rule } from "./types/omega.js"; -import { kRules } from "./utils/symbols.js"; - -/** - * Create a rule cache - * - * @returns A reference to the rule cache - */ -export function createRuleCache() { - const rules = new Map(); - container.register(kRules, { useValue: rules }); - return rules; -} - -/** - * Get the registered rule cache - * - * @returns A reference to the rule cache - */ -export function getRuleChache() { - return container.resolve>(kRules); -} +import type { Rule, RuleCache } from "./types/omega.js"; /** * Load rules from a defined directory and all sub directories into the provided cache @@ -33,7 +11,7 @@ export function getRuleChache() { * @param cache - The rule cache to load rules into * @returns A reference to the rule cache */ -export async function loadRulesInto(path: string, cache: Map) { +export async function loadRulesInto(path: string, cache: RuleCache) { const ruleDir = readdirp(path, { fileFilter: "*.yml", }); @@ -100,7 +78,7 @@ export async function loadRuleRepositoryInto( owner: string, repository: string, path: string, - cache: Map, + cache: RuleCache, ) { const result = await fetchRepositoryContents(owner, repository, path, []); diff --git a/src/tests/rules.test.ts b/src/tests/rules.test.ts index 6a60672..b5fbbc9 100644 --- a/src/tests/rules.test.ts +++ b/src/tests/rules.test.ts @@ -1,5 +1,4 @@ /* eslint-disable id-length */ -import "reflect-metadata"; import assert from "node:assert"; import { fileURLToPath, URL } from "node:url"; import { describe, it } from "node:test"; diff --git a/src/tests/validator.test.ts b/src/tests/validator.test.ts index 51794a3..f300790 100644 --- a/src/tests/validator.test.ts +++ b/src/tests/validator.test.ts @@ -1,4 +1,3 @@ -import "reflect-metadata"; import assert from "node:assert"; import { fileURLToPath, URL } from "node:url"; import { describe, it } from "node:test"; diff --git a/src/types/omega.ts b/src/types/omega.ts index afd34a4..44ed557 100644 --- a/src/types/omega.ts +++ b/src/types/omega.ts @@ -36,6 +36,8 @@ export type Rule = { title: string; }; +export type RuleCache = Map; + export type OmegaResult = { matches: boolean; rule: Rule; diff --git a/src/utils/symbols.ts b/src/utils/symbols.ts deleted file mode 100644 index fa760eb..0000000 --- a/src/utils/symbols.ts +++ /dev/null @@ -1 +0,0 @@ -export const kRules = Symbol("OmegaRules"); diff --git a/yarn.lock b/yarn.lock index 1f4b6d9..a89688a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6631,9 +6631,7 @@ __metadata: prettier: "npm:^3.1.1" re2: "npm:^1.20.9" readdirp: "npm:^3.6.0" - reflect-metadata: "npm:^0.2.1" rimraf: "npm:^5.0.5" - tsyringe: "npm:^4.8.0" typescript: "npm:^5.3.3" yaml: "npm:^2.3.4" languageName: unknown @@ -7185,13 +7183,6 @@ __metadata: languageName: node linkType: hard -"reflect-metadata@npm:^0.2.1": - version: 0.2.1 - resolution: "reflect-metadata@npm:0.2.1" - checksum: 6ca3c674bb43cf8ec3a3f5f38c8730a6116335f8e562fcdcdf3a492af168c5a7f0e8f17476a5710c3fe6bf9b5d22e8a463f14c0e26e326339cab65e099900ef7 - languageName: node - linkType: hard - "reflect.getprototypeof@npm:^1.0.4": version: 1.0.4 resolution: "reflect.getprototypeof@npm:1.0.4" @@ -8209,7 +8200,7 @@ __metadata: languageName: node linkType: hard -"tslib@npm:^1.8.1, tslib@npm:^1.9.3": +"tslib@npm:^1.8.1": version: 1.14.1 resolution: "tslib@npm:1.14.1" checksum: 69ae09c49eea644bc5ebe1bca4fa4cc2c82b7b3e02f43b84bd891504edf66dbc6b2ec0eef31a957042de2269139e4acff911e6d186a258fb14069cd7f6febce2 @@ -8250,15 +8241,6 @@ __metadata: languageName: node linkType: hard -"tsyringe@npm:^4.8.0": - version: 4.8.0 - resolution: "tsyringe@npm:4.8.0" - dependencies: - tslib: "npm:^1.9.3" - checksum: e13810e8ff39c4093acd0649bc5db3c164825827631e1522cd9d5ca8694a018447fa1c24f059ea54e93b1020767b1131b9dc9ce598dabfc9aa41c11544bbfe19 - languageName: node - linkType: hard - "type-check@npm:^0.4.0, type-check@npm:~0.4.0": version: 0.4.0 resolution: "type-check@npm:0.4.0"