Skip to content

Commit

Permalink
refactor: Moved to absolute imports
Browse files Browse the repository at this point in the history
fix: Fixed ConfigFile not parsing themeFolderPath
  • Loading branch information
colin969 committed Jan 12, 2020
1 parent f1cd298 commit 519eb67
Show file tree
Hide file tree
Showing 86 changed files with 403 additions and 931 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ package-lock.json
/preferences.json
/.installed
/.version
/upgrade.json
/upgrade_launcher.json
/secret.txt

# Jest related files
/.coveralls.yml
/coverage
/coverage
/tests/result
16 changes: 4 additions & 12 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ const config = {

/* ------ Watch ------ */

gulp.task('watch-main', (done) => {
execute(`npx tsc --project "${config.main.src}" --pretty --watch`, done);
});

gulp.task('watch-back', (done) => {
execute(`npx tsc --project "${config.back.src}" --pretty --watch`, done);
execute('npx ttsc --project tsconfig.backend.json --pretty --watch', done);
});

gulp.task('watch-renderer', (done) => {
Expand All @@ -44,12 +40,8 @@ gulp.task('watch-static', () => {

/* ------ Build ------ */

gulp.task('build-main', (done) => {
execute(`npx tsc --project "${config.main.src}" --pretty`, done);
});

gulp.task('build-back', (done) => {
execute(`npx tsc --project "${config.back.src}" --pretty`, done);
execute('npx ttsc --project tsconfig.backend.json --pretty', done);
});

gulp.task('build-renderer', (done) => {
Expand Down Expand Up @@ -112,9 +104,9 @@ gulp.task('pack', (done) => {

/* ------ Meta Tasks ------*/

gulp.task('watch', gulp.parallel('watch-main', 'watch-back', 'watch-renderer', 'watch-static', 'copy-static'));
gulp.task('watch', gulp.parallel('watch-back', 'watch-renderer', 'watch-static', 'copy-static'));

gulp.task('build', gulp.parallel('build-main', 'build-back', 'build-renderer', 'copy-static', 'config-install', 'config-version'));
gulp.task('build', gulp.parallel('build-back', 'build-renderer', 'copy-static', 'config-install', 'config-version'));

/* ------ Misc ------*/

Expand Down
9 changes: 8 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'jsdom'
testEnvironment: 'jsdom',
moduleNameMapper: {
'^@shared(.*)$': '<rootDir>/src/shared/$1',
'^@main(.*)$': '<rootDir>/src/main/$1',
'^@renderer(.*)$': '<rootDir>/src/renderer/$1',
'^@back(.*)$': '<rootDir>/src/back/$1',
'^@tests(.*)$': '<rootDir>/tests/$1'
}
};
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@
"jest": "24.8.0",
"ts-jest": "24.0.2",
"ts-loader": "6.0.4",
"ts-transform-paths": "2.0.0",
"tsconfig-paths-webpack-plugin": "3.2.0",
"tslint": "5.18.0",
"ttypescript": "1.5.10",
"typescript": "3.5.3",
"webpack": "4.39.1",
"webpack-cli": "3.3.6"
Expand Down
6 changes: 3 additions & 3 deletions src/back/ConfigFile.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from 'fs';
import { IAppConfigData } from '../shared/config/interfaces';
import { deepCopy, readJsonFile, stringifyJsonDataFile } from '../shared/Util';
import { getDefaultConfigData, overwriteConfigData } from '../shared/config/util';
import { IAppConfigData } from '@shared/config/interfaces';
import { deepCopy, readJsonFile, stringifyJsonDataFile } from '@shared/Util';
import { getDefaultConfigData, overwriteConfigData } from '@shared/config/util';

export namespace ConfigFile {
/** Get the config file path (or throw and error if it is not set). */
Expand Down
8 changes: 4 additions & 4 deletions src/back/Execs.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as path from 'path';
import { ExecMapping } from '../shared/interfaces';
import { parseVarStr, readJsonFile } from '../shared/Util';
import { Coerce } from '../shared/utils/Coerce';
import { IObjectParserProp, ObjectParser } from '../shared/utils/ObjectParser';
import { ExecMapping } from '@shared/interfaces';
import { parseVarStr, readJsonFile } from '@shared/Util';
import { Coerce } from '@shared/utils/Coerce';
import { IObjectParserProp, ObjectParser } from '@shared/utils/ObjectParser';

const { str } = Coerce;

Expand Down
8 changes: 4 additions & 4 deletions src/back/GameLauncher.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ChildProcess, exec, ExecOptions } from 'child_process';
import { EventEmitter } from 'events';
import * as path from 'path';
import { IAdditionalApplicationInfo, IGameInfo } from '../shared/game/interfaces';
import { ExecMapping } from '../shared/interfaces';
import { LangContainer } from '../shared/lang';
import { fixSlashes, padStart, stringifyArray } from '../shared/Util';
import { IAdditionalApplicationInfo, IGameInfo } from '@shared/game/interfaces';
import { ExecMapping } from '@shared/interfaces';
import { LangContainer } from '@shared/lang';
import { fixSlashes, padStart, stringifyArray } from '@shared/Util';
import { LogFunc, OpenDialogFunc, OpenExternalFunc } from './types';

export type LaunchAddAppOpts = LaunchBaseOpts & {
Expand Down
6 changes: 3 additions & 3 deletions src/back/ManagedChildProcess.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ChildProcess, spawn } from 'child_process';
import { EventEmitter } from 'events';
import { IBackProcessInfo, ProcessState } from '../shared/interfaces';
import { ILogPreEntry } from '../shared/Log/interface';
import { Coerce } from '../shared/utils/Coerce';
import { IBackProcessInfo, ProcessState } from '@shared/interfaces';
import { ILogPreEntry } from '@shared/Log/interface';
import { Coerce } from '@shared/utils/Coerce';

const { str } = Coerce;

Expand Down
8 changes: 4 additions & 4 deletions src/back/PlaylistFile.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as fs from 'fs';
import { promisify } from 'util';
import { GamePlaylistContent, GamePlaylistEntry } from '../shared/interfaces';
import { stringifyJsonDataFile } from '../shared/Util';
import { Coerce } from '../shared/utils/Coerce';
import { IObjectParserProp, ObjectParser } from '../shared/utils/ObjectParser';
import { GamePlaylistContent, GamePlaylistEntry } from '@shared/interfaces';
import { stringifyJsonDataFile } from '@shared/Util';
import { Coerce } from '@shared/utils/Coerce';
import { IObjectParserProp, ObjectParser } from '@shared/utils/ObjectParser';

const writeFile = promisify(fs.writeFile);

Expand Down
8 changes: 4 additions & 4 deletions src/back/ServicesFile.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as path from 'path';
import { IBackProcessInfo } from '../shared/interfaces';
import { parseVarStr, readJsonFile } from '../shared/Util';
import { Coerce } from '../shared/utils/Coerce';
import { IObjectParserProp, ObjectParser } from '../shared/utils/ObjectParser';
import { IBackProcessInfo } from '@shared/interfaces';
import { parseVarStr, readJsonFile } from '@shared/Util';
import { Coerce } from '@shared/utils/Coerce';
import { IObjectParserProp, ObjectParser } from '@shared/utils/ObjectParser';

const { str } = Coerce;

Expand Down
6 changes: 3 additions & 3 deletions src/back/game/GameManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import * as fastXmlParser from 'fast-xml-parser';
import * as fs from 'fs';
import * as path from 'path';
import { promisify } from 'util';
import { GameParser } from '../../shared/game/GameParser';
import { IAdditionalApplicationInfo, IGameCollection, IGameInfo, MetaUpdate } from '../../shared/game/interfaces';
import { GamePlatform, IRawPlatformFile } from '../../shared/platform/interfaces';
import { GameParser } from '@shared/game/GameParser';
import { IAdditionalApplicationInfo, IGameCollection, IGameInfo, MetaUpdate } from '@shared/game/interfaces';
import { GamePlatform, IRawPlatformFile } from '@shared/platform/interfaces';
import { copyError } from '../util/misc';
import { GameManagerState, LoadPlatformError } from './types';

Expand Down
8 changes: 4 additions & 4 deletions src/back/game/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { OrderGamesOpts } from '../../shared/game/GameFilter';
import { IGameInfo } from '../../shared/game/interfaces';
import { GamePlaylist } from '../../shared/interfaces';
import { GamePlatform } from '../../shared/platform/interfaces';
import { OrderGamesOpts } from '@shared/game/GameFilter';
import { IGameInfo } from '@shared/game/interfaces';
import { GamePlaylist } from '@shared/interfaces';
import { GamePlatform } from '@shared/platform/interfaces';
import { EventQueue } from '../util/EventQueue';
import { ErrorCopy } from '../util/misc';

Expand Down
14 changes: 7 additions & 7 deletions src/back/importGame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { copy } from 'fs-extra';
import * as path from 'path';
import { promisify } from 'util';
import * as YAML from 'yaml';
import { htdocsPath, LOGOS, SCREENSHOTS } from '../shared/constants';
import { convertEditToCurationMeta } from '../shared/curate/metaToMeta';
import { CurationIndexImage, EditAddAppCuration, EditAddAppCurationMeta, EditCuration, EditCurationMeta } from '../shared/curate/types';
import { getContentFolderByKey, getCurationFolder, indexContentFolder } from '../shared/curate/util';
import { IAdditionalApplicationInfo, IGameInfo } from '../shared/game/interfaces';
import { formatDate, sizeToString } from '../shared/Util';
import { Coerce } from '../shared/utils/Coerce';
import { htdocsPath, LOGOS, SCREENSHOTS } from '@shared/constants';
import { convertEditToCurationMeta } from '@shared/curate/metaToMeta';
import { CurationIndexImage, EditAddAppCuration, EditAddAppCurationMeta, EditCuration, EditCurationMeta } from '@shared/curate/types';
import { getContentFolderByKey, getCurationFolder, indexContentFolder } from '@shared/curate/util';
import { IAdditionalApplicationInfo, IGameInfo } from '@shared/game/interfaces';
import { formatDate, sizeToString } from '@shared/Util';
import { Coerce } from '@shared/utils/Coerce';
import { GameManager } from './game/GameManager';
import { GameManagerState } from './game/types';
import { GameLauncher, LaunchAddAppOpts, LaunchGameOpts } from './GameLauncher';
Expand Down
34 changes: 17 additions & 17 deletions src/back/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ import * as http from 'http';
import * as path from 'path';
import * as util from 'util';
import * as WebSocket from 'ws';
import { AddLogData, BackIn, BackInit, BackInitArgs, BackOut, BrowseChangeData, BrowseViewIndexData, BrowseViewIndexResponseData, BrowseViewPageData, BrowseViewPageResponseData, DeleteGameData, DeleteImageData, DeletePlaylistData, DuplicateGameData, ExportGameData, GetAllGamesResponseData, GetExecData, GetGameData, GetGameResponseData, GetGamesTotalResponseData, GetMainInitDataResponse, GetPlaylistResponse, GetRendererInitDataResponse, GetSuggestionsResponseData, ImageChangeData, ImportCurationData, ImportCurationResponseData, InitEventData, LanguageChangeData, LanguageListChangeData, LaunchAddAppData, LaunchCurationAddAppData, LaunchCurationData, LaunchGameData, LocaleUpdateData, OpenDialogData, OpenDialogResponseData, OpenExternalData, OpenExternalResponseData, PlaylistRemoveData, PlaylistUpdateData, QuickSearchData, QuickSearchResponseData, RandomGamesData, RandomGamesResponseData, SaveGameData, SaveImageData, SavePlaylistData, ServiceActionData, SetLocaleData, ThemeChangeData, ThemeListChangeData, UpdateConfigData, ViewGame, WrappedRequest, WrappedResponse } from '../shared/back/types';
import { overwriteConfigData } from '../shared/config/util';
import { LOGOS, SCREENSHOTS } from '../shared/constants';
import { findMostUsedApplicationPaths } from '../shared/curate/defaultValues';
import { stringifyCurationFormat } from '../shared/curate/format/stringifier';
import { convertToCurationMeta } from '../shared/curate/metaToMeta';
import { FilterGameOpts, filterGames, orderGames, orderGamesInPlaylist } from '../shared/game/GameFilter';
import { IAdditionalApplicationInfo, IGameInfo } from '../shared/game/interfaces';
import { DeepPartial, GamePlaylist, IBackProcessInfo, IService, ProcessAction, RecursivePartial } from '../shared/interfaces';
import { autoCode, getDefaultLocalization, LangContainer, LangFile, LangFileContent } from '../shared/lang';
import { ILogEntry, ILogPreEntry } from '../shared/Log/interface';
import { GameOrderBy, GameOrderReverse } from '../shared/order/interfaces';
import { PreferencesFile } from '../shared/preferences/PreferencesFile';
import { defaultPreferencesData, overwritePreferenceData } from '../shared/preferences/util';
import { parseThemeMetaData, themeEntryFilename, ThemeMeta } from '../shared/ThemeFile';
import { createErrorProxy, deepCopy, isErrorProxy, recursiveReplace, removeFileExtension, stringifyArray } from '../shared/Util';
import { Coerce } from '../shared/utils/Coerce';
import { AddLogData, BackIn, BackInit, BackInitArgs, BackOut, BrowseChangeData, BrowseViewIndexData, BrowseViewIndexResponseData, BrowseViewPageData, BrowseViewPageResponseData, DeleteGameData, DeleteImageData, DeletePlaylistData, DuplicateGameData, ExportGameData, GetAllGamesResponseData, GetExecData, GetGameData, GetGameResponseData, GetGamesTotalResponseData, GetMainInitDataResponse, GetPlaylistResponse, GetRendererInitDataResponse, GetSuggestionsResponseData, ImageChangeData, ImportCurationData, ImportCurationResponseData, InitEventData, LanguageChangeData, LanguageListChangeData, LaunchAddAppData, LaunchCurationAddAppData, LaunchCurationData, LaunchGameData, LocaleUpdateData, OpenDialogData, OpenDialogResponseData, OpenExternalData, OpenExternalResponseData, PlaylistRemoveData, PlaylistUpdateData, QuickSearchData, QuickSearchResponseData, RandomGamesData, RandomGamesResponseData, SaveGameData, SaveImageData, SavePlaylistData, ServiceActionData, SetLocaleData, ThemeChangeData, ThemeListChangeData, UpdateConfigData, ViewGame, WrappedRequest, WrappedResponse } from '@shared/back/types';
import { overwriteConfigData } from '@shared/config/util';
import { LOGOS, SCREENSHOTS } from '@shared/constants';
import { findMostUsedApplicationPaths } from '@shared/curate/defaultValues';
import { stringifyCurationFormat } from '@shared/curate/format/stringifier';
import { convertToCurationMeta } from '@shared/curate/metaToMeta';
import { FilterGameOpts, filterGames, orderGames, orderGamesInPlaylist } from '@shared/game/GameFilter';
import { IAdditionalApplicationInfo, IGameInfo } from '@shared/game/interfaces';
import { DeepPartial, GamePlaylist, IBackProcessInfo, IService, ProcessAction, RecursivePartial } from '@shared/interfaces';
import { autoCode, getDefaultLocalization, LangContainer, LangFile, LangFileContent } from '@shared/lang';
import { ILogEntry, ILogPreEntry } from '@shared/Log/interface';
import { GameOrderBy, GameOrderReverse } from '@shared/order/interfaces';
import { PreferencesFile } from '@shared/preferences/PreferencesFile';
import { defaultPreferencesData, overwritePreferenceData } from '@shared/preferences/util';
import { parseThemeMetaData, themeEntryFilename, ThemeMeta } from '@shared/ThemeFile';
import { createErrorProxy, deepCopy, isErrorProxy, recursiveReplace, removeFileExtension, stringifyArray } from '@shared/Util';
import { Coerce } from '@shared/utils/Coerce';
import { ConfigFile } from './ConfigFile';
import { loadExecMappingsFile } from './Execs';
import { GameManager } from './game/GameManager';
Expand Down
4 changes: 2 additions & 2 deletions src/back/suggestions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IGameInfo } from '../shared/game/interfaces';
import { GamePropSuggestions, GamePropSuggestionsMap, SuggestionProps } from '../shared/interfaces';
import { IGameInfo } from '@shared/game/interfaces';
import { GamePropSuggestions, GamePropSuggestionsMap, SuggestionProps } from '@shared/interfaces';

export function getSuggestions(games: IGameInfo[] = [], libraryTitles: string[] = []): Partial<GamePropSuggestions> {
// Get the values from the game collection & libraries
Expand Down
10 changes: 0 additions & 10 deletions src/back/tsconfig.json

This file was deleted.

18 changes: 9 additions & 9 deletions src/back/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { MessageBoxOptions, OpenExternalOptions } from 'electron';
import { EventEmitter } from 'events';
import { Server } from 'http';
import * as WebSocket from 'ws';
import { BackInit, ViewGame, WrappedRequest } from '../shared/back/types';
import { IAppConfigData } from '../shared/config/interfaces';
import { IGameInfo } from '../shared/game/interfaces';
import { ExecMapping, GamePlaylist, IBackProcessInfo } from '../shared/interfaces';
import { LangContainer, LangFile } from '../shared/lang';
import { ILogEntry, ILogPreEntry } from '../shared/Log/interface';
import { GameOrderBy, GameOrderReverse } from '../shared/order/interfaces';
import { IAppPreferencesData } from '../shared/preferences/interfaces';
import { Theme } from '../shared/ThemeFile';
import { BackInit, ViewGame, WrappedRequest } from '@shared/back/types';
import { IAppConfigData } from '@shared/config/interfaces';
import { IGameInfo } from '@shared/game/interfaces';
import { ExecMapping, GamePlaylist, IBackProcessInfo } from '@shared/interfaces';
import { LangContainer, LangFile } from '@shared/lang';
import { ILogEntry, ILogPreEntry } from '@shared/Log/interface';
import { GameOrderBy, GameOrderReverse } from '@shared/order/interfaces';
import { IAppPreferencesData } from '@shared/preferences/interfaces';
import { Theme } from '@shared/ThemeFile';
import { GameManagerState } from './game/types';
import { ManagedChildProcess } from './ManagedChildProcess';
import { EventQueue } from './util/EventQueue';
Expand Down
4 changes: 2 additions & 2 deletions src/back/util/debounce.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AnyFunction, ArgumentTypesOf } from '../../shared/interfaces';
import { shallowStrictEquals } from '../../shared/Util';
import { AnyFunction, ArgumentTypesOf } from '@shared/interfaces';
import { shallowStrictEquals } from '@shared/Util';

/** A callable object that has the same argument types as T (and void as the return type). */
interface CallableCopy<T extends AnyFunction> extends Function {
Expand Down
10 changes: 5 additions & 5 deletions src/main/MainWindowPreload.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as electron from 'electron';
import { OpenDialogOptions } from 'electron';
import * as path from 'path';
import { SharedSocket } from '../shared/back/SharedSocket';
import { BackIn, BackOut, GetRendererInitDataResponse, OpenDialogData, OpenDialogResponseData, OpenExternalData, OpenExternalResponseData, WrappedResponse } from '../shared/back/types';
import { InitRendererChannel, InitRendererData } from '../shared/IPC';
import { setTheme } from '../shared/Theme';
import { createErrorProxy } from '../shared/Util';
import { SharedSocket } from '@shared/back/SharedSocket';
import { BackIn, BackOut, GetRendererInitDataResponse, OpenDialogData, OpenDialogResponseData, OpenExternalData, OpenExternalResponseData, WrappedResponse } from '@shared/back/types';
import { InitRendererChannel, InitRendererData } from '@shared/IPC';
import { setTheme } from '@shared/Theme';
import { createErrorProxy } from '@shared/Util';
import { isDev } from './Util';

/**
Expand Down
16 changes: 8 additions & 8 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import * as fs from 'fs';
import * as path from 'path';
import { promisify } from 'util';
import * as WebSocket from 'ws';
import { SharedSocket } from '../shared/back/SharedSocket';
import { BackIn, BackInitArgs, BackOut, GetMainInitDataResponse, SetLocaleData, WrappedRequest, WrappedResponse } from '../shared/back/types';
import { IAppConfigData } from '../shared/config/interfaces';
import { APP_TITLE } from '../shared/constants';
import { WindowIPC } from '../shared/interfaces';
import { InitRendererChannel, InitRendererData } from '../shared/IPC';
import { IAppPreferencesData } from '../shared/preferences/interfaces';
import { Coerce } from '../shared/utils/Coerce';
import { SharedSocket } from '@shared/back/SharedSocket';
import { BackIn, BackInitArgs, BackOut, GetMainInitDataResponse, SetLocaleData, WrappedRequest, WrappedResponse } from '@shared/back/types';
import { IAppConfigData } from '@shared/config/interfaces';
import { APP_TITLE } from '@shared/constants';
import { WindowIPC } from '@shared/interfaces';
import { InitRendererChannel, InitRendererData } from '@shared/IPC';
import { IAppPreferencesData } from '@shared/preferences/interfaces';
import { Coerce } from '@shared/utils/Coerce';
import * as Util from './Util';

const readFile = promisify(fs.readFile);
Expand Down
10 changes: 0 additions & 10 deletions src/main/tsconfig.json

This file was deleted.

8 changes: 4 additions & 4 deletions src/renderer/Util.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { remote } from 'electron';
import * as fs from 'fs';
import * as path from 'path';
import { AddLogData, BackIn } from '../shared/back/types';
import { htdocsPath } from '../shared/constants';
import { IGameInfo } from '../shared/game/interfaces';
import { getFileServerURL } from '../shared/Util';
import { AddLogData, BackIn } from '@shared/back/types';
import { htdocsPath } from '@shared/constants';
import { IGameInfo } from '@shared/game/interfaces';
import { getFileServerURL } from '@shared/Util';
import { Paths } from './Paths';

export const gameIdDataType: string = 'text/game-id';
Expand Down
Loading

0 comments on commit 519eb67

Please sign in to comment.