Skip to content

Commit

Permalink
Merge pull request #120 - Alias Imports
Browse files Browse the repository at this point in the history
  • Loading branch information
ctsstc committed Apr 26, 2020
2 parents 3f538a9 + c77d701 commit cca963a
Show file tree
Hide file tree
Showing 40 changed files with 106 additions and 57 deletions.
2 changes: 1 addition & 1 deletion __tests__/commands/add.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Add from '../../src/commands/add';
import Add from '@/commands/add';
import { message as mockMessage, MockedMessage } from '../mocks/discord';

let sendMock: MockedMessage;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/commands/format.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Format from '../../src/commands/format';
import Format from '@/commands/format';

import { message as mockMessage, MockedMessage } from '../mocks/discord';

Expand Down
2 changes: 1 addition & 1 deletion __tests__/commands/gitProfile.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GitProfile from '../../src/commands/gitProfile';
import GitProfile from '@/commands/gitProfile';
import axiosMock from '../__mocks__/axios';
import mockGithubProfile from '../mockData/githubProfile';
import { message as mockMessage, MockedMessage } from '../mocks/discord';
Expand Down
4 changes: 2 additions & 2 deletions __tests__/commands/help.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Help from '../../src/commands/help';
import Commands from '../../src/library/commands';
import Help from '@/commands/help';
import Commands from '@/library/commands';
import { message as mockMessage, MockedMessage } from '../mocks/discord';

// TODO: These should be in a factory/mock
Expand Down
2 changes: 1 addition & 1 deletion __tests__/commands/lmgtfy.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Lmgtfy from '../../src/commands/lmgtfy';
import Lmgtfy from '@/commands/lmgtfy';
import { message as mockMessage, MockedMessage } from '../mocks/discord';

let sendMock: MockedMessage;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/commands/magic8ball.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Magic8Ball from '../../src/commands/magic8ball';
import Magic8Ball from '@/commands/magic8ball';
import { message as mockMessage, MockedMessage } from '../mocks/discord';

let sendMock: MockedMessage;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/commands/rules.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Rules from '../../src/commands/rules';
import Rules from '@/commands/rules';

import { message as mockMessage, MockedMessage } from '../mocks/discord';

Expand Down
2 changes: 1 addition & 1 deletion __tests__/commands/say.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Say from '../../src/commands/say';
import Say from '@/commands/say';

import { message as mockMessage, MockedMessage } from '../mocks/discord';

Expand Down
6 changes: 3 additions & 3 deletions __tests__/commands/search.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Search from '../../src/commands/search';
import config from '../../src/config';
import Search from '@/commands/search';
import config from '@/config';
import axiosMock from '../__mocks__/axios';
import { message as mockMessage, MockedMessage } from '../mocks/discord';
import { noResults, results } from './../mockData/search';

jest.mock('axios');
jest.mock('../../src/config.ts');
jest.mock('@/config.ts');

let sendMock: MockedMessage;
beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/commands/source.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { message as mockMessage, MockedMessage } from '../mocks/discord';
import Source from './../../src/commands/source';
import Source from '@/commands/source';

let sendMock: MockedMessage;
beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/commands/version.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Message } from 'discord.js';
import { message as mockMessage, MockedMessage } from '../mocks/discord';
import Version from './../../src/commands/version';
import Version from '@/commands/version';

let sendMock: MockedMessage;
beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/commands/xmas.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Xmas from '../../src/commands/xmas';
import Xmas from '@/commands/xmas';
import { message as mockMessage, MockedMessage } from '../mocks/discord';

let sendMock: MockedMessage;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/library/commandLoader.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import glob from 'glob';
import CommandLoader, { ICommandClasses } from '../../src/library/commandLoader';
import CommandLoader, { ICommandClasses } from '@/library/commandLoader';

describe('CommandLoader', () => {
let commandClasses: ICommandClasses;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/library/commandParser.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CommandParser from '../../src/library/commandParser';
import CommandParser from '@/library/commandParser';

describe('CommandParser', () => {
const messagePrefix = 'FAKE';
Expand Down
6 changes: 3 additions & 3 deletions __tests__/library/commands.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ICommandClasses } from '../../src/library/commandLoader';
import Commands from '../../src/library/commands';
import ICommand from '../../src/library/iCommand';
import { ICommandClasses } from '@/library/commandLoader';
import Commands from '@/library/commands';
import ICommand from '@/library/interfaces/iCommand';

describe('Commands', () => {
let mockHelloCommand: ICommand;
Expand Down
2 changes: 1 addition & 1 deletion __tests__/mockData/githubProfile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import IGithubProfile from "../../src/commands/interfaces/iGithubProfile";
import IGithubProfile from '@/commands/interfaces/iGithubProfile';

export default {
login: "ctsstc",
Expand Down
6 changes: 5 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@ module.exports = {
"jsx",
"json",
"node"
]
],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
'@root/(.*)$': '<rootDir>/$1'
}
};
37 changes: 36 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "hackbot",
"version": "2.1.1",
"version": "2.2.0",
"description": "Discord bot for the Cascades Tech Club Discord server.",
"repository": {
"type": "git",
"url": "https://github.com/osu-cascades/hackbot.git"
},
"main": "hackbot.js",
"scripts": {
"start": "ts-node src/index.ts",
"start": "ts-node -r tsconfig-paths/register src/index.ts",
"start:dev": "ts-node src/index.ts --type-check",
"bs": "npm run build && npm start",
"watch": "nodemon build/hackbot.js",
Expand Down Expand Up @@ -43,6 +43,7 @@
"devDependencies": {
"jest": "^25.1.0",
"ts-jest": "^25.1.0",
"tsconfig-paths": "^3.9.0",
"tslint": "^5.11.0"
}
}
2 changes: 1 addition & 1 deletion src/commands/_template.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ICommand from '@/library/interfaces/iCommand';
import { Message } from 'discord.js';
import ICommand from '../library/iCommand';

// Hack for implementing with static properties/methods
let CommandName: ICommand;
Expand Down
2 changes: 1 addition & 1 deletion src/commands/add.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Message } from "discord.js";
import ICommand from "../library/iCommand";
import ICommand from "@/library/interfaces/iCommand";

let Add: ICommand;

Expand Down
2 changes: 1 addition & 1 deletion src/commands/format.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Message } from 'discord.js';
import ICommand from '../library/iCommand';
import ICommand from '@/library/interfaces/iCommand';

// Hack for implementing with static properties/methods
let Format: ICommand;
Expand Down
2 changes: 1 addition & 1 deletion src/commands/gitProfile.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios';
import { Message } from 'discord.js';
import moment from 'moment';
import ICommand from '../library/iCommand';
import ICommand from '@/library/interfaces/iCommand';
import IGithubProfile from './interfaces/iGithubProfile';

let GitProfile: ICommand;
Expand Down
6 changes: 3 additions & 3 deletions src/commands/help.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Message } from 'discord.js';
import config from '../config';
import Commands from '../library/commands';
import ICommand from '../library/iCommand';
import config from '@/config';
import Commands from '@/library/commands';
import ICommand from '@/library/interfaces/iCommand';

let Help: ICommand;

Expand Down
2 changes: 1 addition & 1 deletion src/commands/lmgtfy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Message } from 'discord.js';
import ICommand from '../library/iCommand';
import ICommand from '@/library/interfaces/iCommand';

let Lmgtfy: ICommand;

Expand Down
2 changes: 1 addition & 1 deletion src/commands/magic8ball.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Message } from 'discord.js';
import ICommand from '../library/iCommand';
import ICommand from '@/library/interfaces/iCommand';

let Magic8Ball: ICommand;

Expand Down
2 changes: 1 addition & 1 deletion src/commands/purge.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ICommand from '@/library/interfaces/iCommand';
import { Client, DMChannel, Message } from 'discord.js';
import ICommand from '../library/iCommand';

let Purge: ICommand;

Expand Down
2 changes: 1 addition & 1 deletion src/commands/rules.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Message } from 'discord.js';
import ICommand from '../library/iCommand';
import ICommand from '@/library/interfaces/iCommand';

let Rules: ICommand;

Expand Down
2 changes: 1 addition & 1 deletion src/commands/say.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Message } from 'discord.js';
import ICommand from '../library/iCommand';
import ICommand from '@/library/interfaces/iCommand';

let Say: ICommand;

Expand Down
4 changes: 2 additions & 2 deletions src/commands/search.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import config from '@/config';
import ICommand from '@/library/interfaces/iCommand';
import axios, { AxiosResponse } from 'axios';
import { Message } from 'discord.js';
import config from '../config';
import ICommand from '../library/iCommand';

let Search: ICommand;

Expand Down
2 changes: 1 addition & 1 deletion src/commands/source.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Message } from 'discord.js';
import ICommand from '../library/iCommand';
import ICommand from '@/library/interfaces/iCommand';

let Source: ICommand;

Expand Down
6 changes: 3 additions & 3 deletions src/commands/version.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import config from '@/config';
import { version } from '@root/package.json';
import { Message } from 'discord.js';
import { version } from '../../package.json';
import config from '../config';
import ICommand from '../library/iCommand';
import ICommand from '@/library/interfaces/iCommand';

let Version: ICommand;

Expand Down
4 changes: 2 additions & 2 deletions src/commands/weather.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios, { AxiosResponse } from 'axios';
import { Message } from 'discord.js';
import config from '../config';
import ICommand from '../library/iCommand';
import config from '@/config';
import ICommand from '@/library/interfaces/iCommand';

let Weather: ICommand;

Expand Down
2 changes: 1 addition & 1 deletion src/commands/xmas.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Message } from 'discord.js';
import ICommand from '../library/iCommand';
import ICommand from '@/library/interfaces/iCommand';

let Xmas: ICommand;

Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import config from '@/config';
import Core from '@/library/core';
import { Client } from 'discord.js';
import config from './config';
import Core from './library/core';

const client = new Client();
const core = new Core(client);
Expand Down
2 changes: 1 addition & 1 deletion src/library/commandLoader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import camelCase from 'lodash.camelcase';
import path from 'path';
import Command from './iCommand';
import Command from './interfaces/iCommand';

export interface ICommandClasses { [key: string]: Command; }

Expand Down
2 changes: 1 addition & 1 deletion src/library/commands.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ICommandClasses } from './commandLoader';
import Command from './iCommand';
import Command from './interfaces/iCommand';

// TODO: debateable whether we even need this wrapper class
/**
Expand Down
2 changes: 1 addition & 1 deletion src/library/core.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import config from '@/config';
import { Client, GuildMember, Message, TextChannel } from 'discord.js';
import glob from 'glob';
import config from '../config';
import CommandLoader from './commandLoader';
import CommandParser from './commandParser';
import Commands from './commands';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Client, Message } from "discord.js";
import Commands from "./commands";
import Commands from "@/commands";

/**
* An interface for all commands to extend, representing the API that all
Expand Down
Loading

0 comments on commit cca963a

Please sign in to comment.