Skip to content

Commit

Permalink
refactored code into seperate files
Browse files Browse the repository at this point in the history
  • Loading branch information
insomnious committed Dec 19, 2023
1 parent bc4b13f commit 48b7f6f
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 223 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"scripts": {
"dev": "ts-node-dev --exit-child src/index.ts",
"update-extensions-manifest": "ts-node src/update-extensions-manifest.ts",
"add-extension": "ts-node src/add-extension.ts",
"test-slack": "ts-node src/test-slack.ts",
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down
41 changes: 41 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { ExtensionType } from './types';

// static urls
export const LIVE_MANIFEST_URL:string = 'https://raw.githubusercontent.com/Nexus-Mods/Vortex-Backend/main/extensions-manifest.json';
export const DOWNLOAD_STATS_URL = 'https://staticstats.nexusmods.com/live_download_counts/mods/2295.csv';

// emojis for slack messages
export const GAME_EMOJI = ':joystick:';
export const THEME_EMOJI = ':art:';
export const TRANSLATION_EMOJI = ':earth_africa:';
export const UNKNOWN_EMOJI = ':question:';

// time constants
export const ONE_DAY = 1000 * 60 * 60 * 24;

// slack constants
export const SLACK_CHANNEL = 'C06B8H5TGGG'; // this is bot-test-slack and bot-github-vortex is channel id C05009EK5R6

// files and paths
export const MANIFEST_FILENAME = 'extensions-manifest.json';

// nexus category to extension type mapping
export const CATEGORIES: { [id: number]: ExtensionType } = {
4: 'game',
7: 'translation',
13: 'theme'
}

// site versioning constants
export const HTML_REGEX = new RegExp('&[lg]t;', 'g');
export const VERSION_MATCH_REGEX = new RegExp('^requires vortex ([><=-^~0-9\. ]*[0-9])', 'i');
export const htmlMap: { [entity: string]: string } = {
'&gt;': '>',
'&lt;': '<',
};

// excluded games
export const GAME_EXCLUSIONLIST = [
'game-subnautica',
'game-subnauticabelowzero',
];
29 changes: 28 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type ExtensionType = 'game' | 'translation' | 'theme';
export type ExtensionType = 'game' | 'translation' | 'theme' | null;

export interface IExtensionDownloadInfo {
name?: string;
Expand Down Expand Up @@ -93,3 +93,30 @@ export interface IGitHubRelease {
url: string;
zipball_url: string;
}

/**
* Extra info we need that isn't store in the mod's nexus metadata. Previously manually added in the electron app when a new extension was created.
* gameName is a human readable name that links the extension to the game it is managing so we can display in Vortex's games page.
* language is a country code i.e. 'en-US' or 'de' to specify the translation language
*/
export interface IExtraInfo {
language?: string;
gameName?: string;
}

export class Rejected extends Error {
constructor() {
super('Update rejected');
Error.captureStackTrace(this, this.constructor);

this.name = this.constructor.name;
}
}

export type DownloadStats = { [modId: string]: { unique: number, total: number } };

export type ModDownloadStats = {
modId: string;
total: number;
unique: number;
};
Loading

0 comments on commit 48b7f6f

Please sign in to comment.