Skip to content

Commit

Permalink
🚑 Fixed root entrance error
Browse files Browse the repository at this point in the history
Organized types, optimized their application and removed old types file as if project continues to scale. Types would be better identified in a folder basis.

octokit#584
octokit#583
octokit#106 - Related by setting up tests for proper editing. As before users could not test properly due to project configuration. Will come back to this one once the FATAL error above is confirmed fixed after new release.
  • Loading branch information
HeavenlyEntity committed Apr 21, 2023
1 parent 6b9a0f0 commit 4b97ce1
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 67 deletions.
18 changes: 9 additions & 9 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ export default {
// maxWorkers: "50%",

// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],
moduleDirectories: [
"node_modules"
],

// An array of file extensions your modules use
// moduleFileExtensions: [
Expand Down Expand Up @@ -121,11 +121,11 @@ export default {
// restoreMocks: false,

// The root directory that Jest should scan for tests and modules within
// rootDir: undefined,
// rootDir: "test",

// A list of paths to directories that Jest should use to search for files in
// roots: [
// "<rootDir>"
// "src/test/**/*.ts"
// ],

// Allows you to use a custom runner instead of Jest's default test runner
Expand Down Expand Up @@ -153,10 +153,10 @@ export default {
// testLocationInResults: false,

// The glob patterns Jest uses to detect test files
// testMatch: [
// "**/__tests__/**/*.[jt]s?(x)",
// "**/?(*.)+(spec|test).[tj]s?(x)"
// ],
testMatch: [
"**/test/**/*.[jt]s?(x)",
"**/?(*.)+(spec|test).[tj]s?(x)"
],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
Expand Down
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
import BottleneckLight from "bottleneck/light";
import { Octokit } from "@octokit/core";
import { OctokitOptions } from "@octokit/core/dist-types/types.d";
import { Groups } from "./types";
import { Groups } from "./types/bottle-neck";
import { VERSION } from "./version";

import { wrapRequest } from "./wrap-request";
import triggersNotificationPaths from "./generated/triggers-notification-paths";
import { routeMatcher } from "./route-matcher";
import Bottleneck from "bottleneck";

// Workaround to allow tests to directly access the triggersNotification function.
const regex = routeMatcher(triggersNotificationPaths);
const triggersNotification = regex.test.bind(regex);

const groups: Groups = {};

// @ts-expect-error
const createGroups = function (Bottleneck, common) {
const createGroups = function (Bottleneck: Bottleneck | any, common: Object) {
groups.global = new Bottleneck.Group({
id: "octokit-global",
maxConcurrent: 10,
Expand Down Expand Up @@ -192,3 +192,5 @@ export function throttling(octokit: Octokit, octokitOptions: OctokitOptions) {
}
throttling.VERSION = VERSION;
throttling.triggersNotification = triggersNotification;

export default throttling;
55 changes: 0 additions & 55 deletions src/types.ts

This file was deleted.

8 changes: 8 additions & 0 deletions src/types/bottle-neck.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Bottleneck from "bottleneck";

export interface Groups {
global?: Bottleneck.Group;
write?: Bottleneck.Group;
search?: Bottleneck.Group;
notifications?: Bottleneck.Group;
}
Empty file added src/types/throttle-options.ts
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 4b97ce1

Please sign in to comment.