-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Refactor GameSelectionScreen.created() #849
Merged
ebkr
merged 2 commits into
ebkr:develop
from
thunderstore-io:TS-1138-GameSelectionScreen-refactor
Oct 17, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,35 @@ | ||
import PathResolver from '../r2mm/manager/PathResolver'; | ||
import * as path from 'path'; | ||
import FsProvider from '../providers/generic/file/FsProvider'; | ||
import PathResolver from '../r2mm/manager/PathResolver'; | ||
import FileUtils from '../utils/FileUtils'; | ||
import CacheUtil from '../r2mm/mods/CacheUtil'; | ||
|
||
export default class FolderMigration { | ||
/** | ||
* Mod directory structure was changed when support for other games | ||
* besides RoR2 was added. Update the dir structure if the old one is | ||
* still in use. | ||
*/ | ||
export class FolderMigration { | ||
|
||
public static async needsMigration(): Promise<boolean> { | ||
public static async needsMigration() { | ||
const fs = FsProvider.instance; | ||
return await fs.exists(path.join(PathResolver.ROOT, "mods")); | ||
} | ||
|
||
public static async runMigration(): Promise<void> { | ||
console.log("Started migration"); | ||
public static async runMigration() { | ||
if (!await this.needsMigration()) { | ||
return; | ||
} | ||
|
||
console.log("Started legacy directory migration"); | ||
const fs = FsProvider.instance; | ||
await CacheUtil.clean(); | ||
if ((await fs.exists(path.join(PathResolver.ROOT, "RiskOfRain2")))) { | ||
await FileUtils.emptyDirectory(path.join(PathResolver.ROOT, "RiskOfRain2")); | ||
await fs.rmdir(path.join(PathResolver.ROOT, "RiskOfRain2")); | ||
const rorPath = path.join(PathResolver.ROOT, "RiskOfRain2"); | ||
|
||
if (await fs.exists(rorPath)) { | ||
await FileUtils.emptyDirectory(rorPath); | ||
await fs.rmdir(rorPath); | ||
} | ||
await fs.rename(path.join(PathResolver.ROOT, "mods"), path.join(PathResolver.ROOT, "RiskOfRain2")); | ||
} | ||
|
||
await fs.rename(path.join(PathResolver.ROOT, "mods"), rorPath); | ||
console.log("Directory migration done"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import GameManager from "../model/game/GameManager"; | ||
import ManagerSettings from "../r2mm/manager/ManagerSettings"; | ||
|
||
|
||
/** | ||
* Return default game selection needed to skip the game selection screen. | ||
*/ | ||
export const getDefaults = (settings: ManagerSettings) => { | ||
const globals = settings.getContext().global; | ||
const defaultGame = GameManager.findByFolderName(globals.defaultGame); | ||
const platforms = defaultGame ? defaultGame.storePlatformMetadata : []; | ||
const defaultPlat = platforms.find(x => x.storePlatform === globals.defaultStore); | ||
|
||
return { | ||
defaultGame, | ||
defaultPlatform: defaultPlat ? defaultPlat.storePlatform : undefined | ||
}; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the policy with console.logging in this project? My initial reaction was to clean them out. Then I thought they might help users to debug stuff. But then again, they don't have access to the console in production, do they?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging is accessible during production.
Ctrl + Shift + I
for r2modman, and accessible via logs in TMM.Generally the rule I've mostly followed is that if a user can't see it, we should still be able to track progress via logs.