mirror of
https://github.com/FullScreenShenanigans/ModAttachr.git
synced 2026-08-12 02:18:09 -07:00
(v0.7.0) Used shenanigans-manager@0.2 instead of Gulp
This commit is contained in:
+2
-2
@@ -1,8 +1,8 @@
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- "7"
|
||||
- "node"
|
||||
- "5"
|
||||
|
||||
script:
|
||||
node_modules/gulp/bin/gulp.js
|
||||
npm run verify
|
||||
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"editor.tabSize": 4,
|
||||
"editor.trimAutoWhitespace": true,
|
||||
"tslint.alwaysShowRuleFailuresAsWarnings": true,
|
||||
"tslint.autoFixOnSave": true,
|
||||
"typescript.tsdk": "node_modules\\typescript\\lib"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
require("gulp-shenanigans").initialize(require("gulp"));
|
||||
Generated
+2
-8714
File diff suppressed because it is too large
Load Diff
+67
-30
@@ -1,31 +1,68 @@
|
||||
{
|
||||
"name": "modattachr",
|
||||
"description": "Hookups for extensible triggered mod events.",
|
||||
"version": "0.6.3",
|
||||
"author": {
|
||||
"name": "Josh Goldberg",
|
||||
"email": "joshuakgoldberg@outlook.com"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "ssh://git@github.com:FullScreenShenanigans/ModAttachr.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/FullScreenShenanigans/ModAttachr/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"itemsholdr": "0.6.X"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-shenanigans": "^0.6.17"
|
||||
},
|
||||
"scripts": {
|
||||
"gulp": "gulp",
|
||||
"test": "gulp test"
|
||||
},
|
||||
"shenanigans": {
|
||||
"name": "ModAttachr"
|
||||
}
|
||||
}
|
||||
"author": {
|
||||
"email": "joshuakgoldberg@outlook.com",
|
||||
"name": "Josh Goldberg"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/FullScreenShenanigans/ModAttachr/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"itemsholdr": "0.6.X"
|
||||
},
|
||||
"description": "Hookups for extensible triggered mod events.",
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.0.4",
|
||||
"@types/lolex": "^1.5.32",
|
||||
"@types/mocha": "^2.2.44",
|
||||
"@types/sinon": "^4.0.0",
|
||||
"@types/sinon-chai": "^2.7.29",
|
||||
"chai": "^4.1.2",
|
||||
"glob": "^7.1.2",
|
||||
"lolex": "^2.3.0",
|
||||
"mocha": "^4.0.1",
|
||||
"mocha-headless-chrome": "^1.7.1",
|
||||
"requirejs": "^2.3.5",
|
||||
"run-for-every-file": "^1.1.0",
|
||||
"shenanigans-manager": "^0.2.0",
|
||||
"sinon": "^4.1.2",
|
||||
"sinon-chai": "^2.14.0",
|
||||
"tslint": "5.8.0",
|
||||
"typedoc": "^0.9.0",
|
||||
"typescript": "^2.6.2",
|
||||
"webpack": "^3.10.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
"name": "modattachr",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "ssh://git@github.com:FullScreenShenanigans/ModAttachr.git"
|
||||
},
|
||||
"scripts": {
|
||||
"dist": "npm run dist:webpack",
|
||||
"dist:webpack": "webpack --config webpack.config.js",
|
||||
"docs": "npm run docs:typedoc",
|
||||
"docs:typedoc": "typedoc src/ --out docs/generated",
|
||||
"init": "npm install && npm run setup && npm run verify",
|
||||
"setup": "npm run setup:copy && npm run setup:package",
|
||||
"setup:copy": "npm run setup:copy:default",
|
||||
"setup:copy:default": "run-for-every-file --dot --src \"node_modules/shenanigans-manager/setup/default/\" --file \"**/*\" --run \"mustache package.json {{src-file}} {{file}}\" --dest \".\" --only-files",
|
||||
"setup:package": "shenanigans-manager hydrate-package-json",
|
||||
"src": "npm run src:tsc && npm run src:tslint",
|
||||
"src:tsc": "tsc -p .",
|
||||
"src:tslint": "tslint -c tslint.json --exclude ./node_modules/**/*.ts* -p tsconfig.json -t stylish",
|
||||
"test": "npm run test:setup && npm run test:run",
|
||||
"test:run": "mocha-headless-chrome --file test/index.html",
|
||||
"test:setup": "npm run test:setup:copy && npm run test:setup:html && npm run test:setup:tsc",
|
||||
"test:setup:copy": "npm run test:setup:copy:default",
|
||||
"test:setup:copy:default": "run-for-every-file --dot --src \"node_modules/shenanigans-manager/setup/test/\" --file \"**/*\" --run \"mustache package.json {{src-file}} ./test/{{file}}\" --dest \".\" --only-files",
|
||||
"test:setup:html": "shenanigans-manager generate-test-html",
|
||||
"test:setup:tsc": "tsc -p test",
|
||||
"verify": "npm run src && npm run test && npm run dist && npm run docs",
|
||||
"watch": "run-p \"tsc -p . -w\" \"echo sup\""
|
||||
},
|
||||
"shenanigans": {
|
||||
"name": "ModAttachr"
|
||||
},
|
||||
"types": "./src/index.d.ts",
|
||||
"version": "0.7.0"
|
||||
}
|
||||
+2
-2
@@ -5,10 +5,10 @@ export class EventNames {
|
||||
/*
|
||||
* Key for event when a mod is enabled.
|
||||
*/
|
||||
public readonly onModEnable: string = "onModEnable";
|
||||
public readonly onModEnable = "onModEnable";
|
||||
|
||||
/*
|
||||
* Key for event when a mod is disabled.
|
||||
*/
|
||||
public readonly onModDisable: string = "onModDisable";
|
||||
public readonly onModDisable = "onModDisable";
|
||||
}
|
||||
|
||||
+4
-7
@@ -1,6 +1,7 @@
|
||||
import { IItemsHoldr } from "itemsholdr/lib/IItemsHoldr";
|
||||
import { IItemsHoldr } from "itemsholdr";
|
||||
|
||||
import { EventNames } from "./EventNames";
|
||||
|
||||
/**
|
||||
* General schema for a mod, including its name and events.
|
||||
*/
|
||||
@@ -27,9 +28,7 @@ export interface IMod {
|
||||
* @param args The arguments for the mod event.
|
||||
* @returns The result of the mod (normally ignored).
|
||||
*/
|
||||
export interface IEventCallback {
|
||||
(...args: any[]): any;
|
||||
}
|
||||
export type IEventCallback = (...args: any[]) => any;
|
||||
|
||||
/**
|
||||
* Listing of events, keying event names to all mods attached to them.
|
||||
@@ -68,9 +67,7 @@ export interface ICallbackRegister {
|
||||
* @param name Name of a mod.
|
||||
* @returns What the mod will be called in storage.
|
||||
*/
|
||||
export interface ITransformModName {
|
||||
(name: string): string;
|
||||
}
|
||||
export type ITransformModName = (name: string) => string;
|
||||
|
||||
/**
|
||||
* Settings to initialize a new IModAttachr.
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { EventNames } from "./EventNames";
|
||||
import { FakeEventNames } from "./fakes.test";
|
||||
import { ModAttachr } from "./ModAttachr";
|
||||
|
||||
it("Testing to ensure onModEnable is fired properly", (): void => {
|
||||
// Arrange
|
||||
const eventNames = new EventNames();
|
||||
const dummyMod = {
|
||||
name: "Dummy Mod",
|
||||
events: {
|
||||
[eventNames.onModEnable]: (): string => "success",
|
||||
},
|
||||
enabled: false,
|
||||
};
|
||||
const modAttachr = new ModAttachr({
|
||||
mods: [dummyMod],
|
||||
eventNames,
|
||||
});
|
||||
|
||||
// Act
|
||||
const eventResult: string = modAttachr.fireModEvent(eventNames.onModEnable, "Dummy Mod");
|
||||
|
||||
// Assert
|
||||
expect(eventResult).to.be.equal("success");
|
||||
});
|
||||
|
||||
it("Testing to ensure onModDisable is fired properly", (): void => {
|
||||
// Arrange
|
||||
const eventNames = new EventNames();
|
||||
const dummyMod = {
|
||||
name: "Dummy Mod",
|
||||
events: {
|
||||
[eventNames.onModDisable]: (): string => "success",
|
||||
},
|
||||
enabled: false,
|
||||
};
|
||||
const modAttachr = new ModAttachr({
|
||||
mods: [dummyMod],
|
||||
eventNames,
|
||||
});
|
||||
|
||||
// Act
|
||||
const eventResult: string = modAttachr.fireModEvent(eventNames.onModDisable, "Dummy Mod");
|
||||
|
||||
// Assert
|
||||
expect(eventResult).to.be.equal("success");
|
||||
});
|
||||
|
||||
it("Testing to ensure an arbitrary fake event is fired properly", (): void => {
|
||||
// Arrange
|
||||
const value = 42;
|
||||
const eventNames = new FakeEventNames();
|
||||
const dummyMod = {
|
||||
name: "Dummy Fake Mod",
|
||||
events: {
|
||||
[eventNames.fakeEvent]: (): number => value,
|
||||
},
|
||||
enabled: false,
|
||||
};
|
||||
const modAttachr = new ModAttachr({
|
||||
mods: [dummyMod],
|
||||
eventNames,
|
||||
});
|
||||
|
||||
// Act
|
||||
const eventResult: number = modAttachr.fireModEvent(eventNames.fakeEvent, "Dummy Fake Mod");
|
||||
|
||||
// Assert
|
||||
expect(eventResult).to.be.equal(value);
|
||||
});
|
||||
+21
-24
@@ -1,14 +1,28 @@
|
||||
import { IItemsHoldr } from "itemsholdr/lib/IItemsHoldr";
|
||||
|
||||
import { ItemsHoldr } from "itemsholdr/lib/ItemsHoldr";
|
||||
import { IItemsHoldr, ItemsHoldr } from "itemsholdr";
|
||||
|
||||
import { EventNames } from "./EventNames";
|
||||
|
||||
import {
|
||||
ICallbackRegister, IEventCallback, IEventsRegister, IMod,
|
||||
IModAttachr, IModAttachrSettings, IMods, ITransformModName
|
||||
IModAttachr, IModAttachrSettings, IMods, ITransformModName,
|
||||
} from "./IModAttachr";
|
||||
|
||||
/**
|
||||
* Retrieves a mod's event, or throws if it doesn't exist.
|
||||
*
|
||||
* @param name Name of a mod.
|
||||
* @param event Name of an event under the mod.
|
||||
* @returns The mod's event.
|
||||
*/
|
||||
export const retrieveModEvent = (mod: IMod, name: string): IEventCallback => {
|
||||
const eventCallback = mod.events[name];
|
||||
if (eventCallback === undefined) {
|
||||
throw new Error(`Mod '${mod.name}' does not contain event '${name}'.`);
|
||||
}
|
||||
|
||||
return eventCallback;
|
||||
};
|
||||
|
||||
/**
|
||||
* Hookups for extensible triggered mod events.
|
||||
*/
|
||||
@@ -86,7 +100,7 @@ export class ModAttachr implements IModAttachr {
|
||||
const storedKey: string = this.transformModName(mod.name);
|
||||
this.itemsHolder.addItem(storedKey, {
|
||||
valueDefault: false,
|
||||
storeLocally: true
|
||||
storeLocally: true,
|
||||
});
|
||||
|
||||
if (this.itemsHolder.getItem(storedKey)) {
|
||||
@@ -169,7 +183,7 @@ export class ModAttachr implements IModAttachr {
|
||||
|
||||
for (const mod of mods) {
|
||||
if (mod.enabled) {
|
||||
this.retrieveModEvent(mod, name)(...args);
|
||||
retrieveModEvent(mod, name)(...args);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,7 +198,7 @@ export class ModAttachr implements IModAttachr {
|
||||
*/
|
||||
public fireModEvent(eventName: string, modName: string, ...args: any[]): any {
|
||||
const mod: IMod = this.retrieveMod(modName);
|
||||
const eventCallback: IEventCallback = this.retrieveModEvent(mod, eventName);
|
||||
const eventCallback: IEventCallback = retrieveModEvent(mod, eventName);
|
||||
|
||||
return eventCallback(...args);
|
||||
}
|
||||
@@ -204,21 +218,4 @@ export class ModAttachr implements IModAttachr {
|
||||
|
||||
return mod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a mod's event, or throws if it doesn't exist.
|
||||
*
|
||||
* @param name Name of a mod.
|
||||
* @param event Name of an event under the mod.
|
||||
* @returns The mod's event.
|
||||
*/
|
||||
private retrieveModEvent(mod: IMod, name: string): IEventCallback {
|
||||
const eventCallback: IEventCallback | undefined = mod.events[name];
|
||||
|
||||
if (!eventCallback) {
|
||||
throw new Error(`Mod '${mod.name}' does not contain event '${name}'.`);
|
||||
}
|
||||
|
||||
return eventCallback;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { EventNames } from "../../src/EventNames";
|
||||
import { IModAttachr, IModAttachrSettings } from "../../src/IModAttachr";
|
||||
import { ModAttachr } from "../../src/ModAttachr";
|
||||
import { EventNames } from "./EventNames";
|
||||
import { IModAttachrSettings } from "./IModAttachr";
|
||||
import { ModAttachr } from "./ModAttachr";
|
||||
|
||||
/**
|
||||
* @param settings Settings for the ModAttachr.
|
||||
* @returns An ModAttachr instance.
|
||||
*/
|
||||
export function mockModAttachr(settings?: IModAttachrSettings): IModAttachr {
|
||||
return new ModAttachr(settings);
|
||||
}
|
||||
export const mockModAttachr = (settings?: IModAttachrSettings) =>
|
||||
new ModAttachr(settings);
|
||||
|
||||
/**
|
||||
* Holds keys for fake mod events.
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from "./IModAttachr";
|
||||
export * from "./ModAttachr";
|
||||
@@ -1,3 +0,0 @@
|
||||
import { mochaLoader } from "../main";
|
||||
|
||||
mochaLoader.it("_", (): void => { });
|
||||
@@ -1,71 +0,0 @@
|
||||
import { EventNames } from "../../src/EventNames";
|
||||
import { IMod } from "../../src/IModAttachr";
|
||||
import { ModAttachr } from "../../src/ModAttachr";
|
||||
import { mochaLoader } from "../main";
|
||||
import { FakeEventNames } from "../utils/fakes";
|
||||
|
||||
mochaLoader.it("Testing to ensure onModEnable is fired properly", (): void => {
|
||||
// Arrange
|
||||
const eventNames: EventNames = new EventNames();
|
||||
const dummyMod: IMod = {
|
||||
name: "Dummy Mod",
|
||||
events: {
|
||||
[eventNames.onModEnable]: (): string => "success"
|
||||
},
|
||||
enabled: false
|
||||
};
|
||||
const modAttachr: ModAttachr = new ModAttachr({
|
||||
mods: [dummyMod],
|
||||
eventNames
|
||||
});
|
||||
|
||||
// Act
|
||||
const eventResult: string = modAttachr.fireModEvent(modAttachr.eventNames.onModEnable, "Dummy Mod");
|
||||
|
||||
// Assert
|
||||
chai.expect(eventResult).to.be.equal("success");
|
||||
});
|
||||
|
||||
mochaLoader.it("Testing to ensure onModDisable is fired properly", (): void => {
|
||||
// Arrange
|
||||
const eventNames: EventNames = new EventNames();
|
||||
const dummyMod: IMod = {
|
||||
name: "Dummy Mod",
|
||||
events: {
|
||||
[eventNames.onModDisable]: (): string => "success"
|
||||
},
|
||||
enabled: false
|
||||
};
|
||||
const modAttachr: ModAttachr = new ModAttachr({
|
||||
mods: [dummyMod],
|
||||
eventNames
|
||||
});
|
||||
|
||||
// Act
|
||||
const eventResult: string = modAttachr.fireModEvent(modAttachr.eventNames.onModDisable, "Dummy Mod");
|
||||
|
||||
// Assert
|
||||
chai.expect(eventResult).to.be.equal("success");
|
||||
});
|
||||
|
||||
mochaLoader.it("Testing to ensure an arbitrary fake event is fired properly", (): void => {
|
||||
// Arrange
|
||||
const eventNames: FakeEventNames = new FakeEventNames();
|
||||
const dummyMod: IMod = {
|
||||
name: "Dummy Fake Mod",
|
||||
events: {
|
||||
[eventNames.fakeEvent]: (): number => 42
|
||||
},
|
||||
enabled: false
|
||||
};
|
||||
const modAttachr: ModAttachr = new ModAttachr({
|
||||
mods: [dummyMod],
|
||||
eventNames
|
||||
});
|
||||
|
||||
// Act
|
||||
const eventResult: number = modAttachr.fireModEvent((modAttachr.eventNames as FakeEventNames).fakeEvent, "Dummy Fake Mod");
|
||||
|
||||
// Assert
|
||||
chai.expect(eventResult).to.be.equal(42);
|
||||
});
|
||||
+2
-17
@@ -1,19 +1,4 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"lib": ["dom", "es2015.collection", "es2015.promise", "es5"],
|
||||
"module": "amd",
|
||||
"moduleResolution": "node",
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitReturns": true,
|
||||
"noImplicitThis": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"strictNullChecks": true,
|
||||
"target": "es5"
|
||||
},
|
||||
"include": [
|
||||
"./**/*.ts"
|
||||
]
|
||||
"extends": "../tsconfig.json",
|
||||
"include": ["*.ts"]
|
||||
}
|
||||
|
||||
+9
-3
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"experimentalDecorators": true,
|
||||
"jsx": "react",
|
||||
"lib": ["dom", "es2015.collection", "es2015.promise", "es5"],
|
||||
"module": "amd",
|
||||
"moduleResolution": "node",
|
||||
@@ -8,12 +10,16 @@
|
||||
"noImplicitReturns": true,
|
||||
"noImplicitThis": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"pretty": true,
|
||||
"strictNullChecks": true,
|
||||
"target": "es5"
|
||||
},
|
||||
"exclude": [
|
||||
"dist",
|
||||
"node_modules"
|
||||
],
|
||||
"include": [
|
||||
"./src/**/*.ts"
|
||||
"./src/**/*.ts",
|
||||
"./src/**/*.tsx"
|
||||
]
|
||||
}
|
||||
|
||||
+6
-52
@@ -1,56 +1,10 @@
|
||||
{
|
||||
"extends": "tslint:all",
|
||||
"extends": "./node_modules/shenanigans-manager/setup/tslint.json",
|
||||
"rules": {
|
||||
"array-type": [false],
|
||||
"arrow-return-shorthand": [false],
|
||||
"ban-types": [false],
|
||||
"callable-types": [false],
|
||||
"comment-format": [false],
|
||||
"completed-docs": [false],
|
||||
"cyclomatic-complexity": [false],
|
||||
"forin": [false],
|
||||
"linebreak-style": [false],
|
||||
"max-file-line-count": [false],
|
||||
"max-line-length": [true, 140],
|
||||
"member-ordering": [
|
||||
true,
|
||||
"public-before-private",
|
||||
"static-before-instance",
|
||||
"variables-before-functions"
|
||||
],
|
||||
"newline-before-return": [false],
|
||||
"no-any": [false],
|
||||
"no-bitwise": [false],
|
||||
"no-console": [false],
|
||||
"no-default-export": [false],
|
||||
"no-inferrable-types": [false],
|
||||
"no-magic-numbers": [false],
|
||||
"no-redundant-jsdoc": [false],
|
||||
"no-non-null-assertion": [false],
|
||||
"no-object-literal-type-assertion": [false],
|
||||
"no-submodule-imports": [false],
|
||||
"no-require-imports": false,
|
||||
"no-unbound-method": [false],
|
||||
"no-unsafe-any": [false],
|
||||
"no-unused-variable": [false],
|
||||
"no-void-expression": [false],
|
||||
"number-literal-format": [false],
|
||||
"object-literal-key-quotes": [false],
|
||||
"object-literal-shorthand": [false],
|
||||
"object-literal-sort-keys": [false],
|
||||
"only-arrow-functions": [false],
|
||||
"prefer-function-over-method": [false],
|
||||
"prefer-method-signature": [false],
|
||||
"prefer-switch": [false],
|
||||
"prefer-conditional-expression": [false],
|
||||
"prefer-template": [false],
|
||||
"restrict-plus-operands": [false],
|
||||
"space-before-function-paren": [false],
|
||||
"strict-boolean-expressions": [false],
|
||||
"strict-type-predicates": [false],
|
||||
"switch-final-break": [false],
|
||||
"trailing-comma": [false],
|
||||
"typedef": [false],
|
||||
"variable-name": [false]
|
||||
"ban-types": false,
|
||||
"completed-docs": false,
|
||||
"no-any": false,
|
||||
"no-unsafe-any": false,
|
||||
"strict-boolean-expressions": false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user