Compute project path dynamically from file metadata (#8215)

Don't show in changelog
This commit is contained in:
Florian Rival
2026-02-07 12:56:33 +01:00
committed by GitHub
parent a9a99039cb
commit ccf636cb5b
2 changed files with 9 additions and 9 deletions
+7 -6
View File
@@ -200,7 +200,10 @@ import { QuickCustomizationDialog } from '../QuickCustomization/QuickCustomizati
import { type ObjectWithContext } from '../ObjectsList/EnumerateObjects';
import useGamesList from '../GameDashboard/UseGamesList';
import useCapturesManager from './UseCapturesManager';
import { readProjectSettings } from '../Utils/ProjectSettingsReader';
import {
readProjectSettings,
getProjectDirectory,
} from '../Utils/ProjectSettingsReader';
import { type ToolbarButtonConfig } from './CustomToolbarButton';
import { applyProjectPreferences } from '../Utils/ApplyProjectPreferences';
import {
@@ -315,7 +318,6 @@ export type State = {|
saveToStorageProviderDialogOpen: boolean,
gdjsDevelopmentWatcherEnabled: boolean,
toolbarButtons: Array<ToolbarButtonConfig>,
projectPath: ?string,
|};
const initialPreviewState: PreviewState = {
@@ -394,7 +396,6 @@ const MainFrame = (props: Props) => {
saveToStorageProviderDialogOpen: false,
gdjsDevelopmentWatcherEnabled: false,
toolbarButtons: [],
projectPath: null,
}: State)
);
const authenticatedUser = React.useContext(AuthenticatedUserContext);
@@ -1003,7 +1004,6 @@ const MainFrame = (props: Props) => {
currentFileMetadata: null,
editorTabs: closeProjectTabs(state.editorTabs, currentProject),
toolbarButtons: [],
projectPath: null,
}));
// Delete the project from memory. All references to it have been dropped previously
@@ -1116,7 +1116,6 @@ const MainFrame = (props: Props) => {
setState(currentState => ({
...currentState,
toolbarButtons: rawSettings.toolbarButtons || [],
projectPath: rawSettings.projectPath,
}));
}
} catch (error) {
@@ -4873,7 +4872,9 @@ const MainFrame = (props: Props) => {
onRestartInGameEditor,
showRestartInGameEditorAfterErrorButton,
toolbarButtons: state.toolbarButtons,
projectPath: state.projectPath,
projectPath: currentFileMetadata
? getProjectDirectory(currentFileMetadata.fileIdentifier)
: null,
};
const hasEditorsInLeftPane = hasEditorsInPane(state.editorTabs, 'left');
@@ -11,7 +11,6 @@ const path = optionalRequire('path');
export type ParsedProjectSettings = {
preferences?: { [string]: boolean | string | number },
toolbarButtons?: Array<ToolbarButtonConfig>,
projectPath: string,
};
const SETTINGS_FILE_NAME = 'gdevelop-settings.yaml';
@@ -19,7 +18,7 @@ const SETTINGS_FILE_NAME = 'gdevelop-settings.yaml';
// Only allow safe characters in npm script names to prevent command injection
const SAFE_SCRIPT_NAME_PATTERN = /^[a-zA-Z0-9_:-]+$/;
const getProjectDirectory = (projectFilePath: string): string | null => {
export const getProjectDirectory = (projectFilePath: string): string | null => {
if (!path) return null;
return path.dirname(projectFilePath);
};
@@ -133,7 +132,7 @@ export const readProjectSettings = async (
} preferences, ${toolbarButtons.length} buttons`
);
const result: ParsedProjectSettings = { projectPath: projectDirectory };
const result: ParsedProjectSettings = {};
if (Object.keys(preferences).length > 0) {
result.preferences = preferences;
}