Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes LUNA-218 add path to tauri project metadata #377

Merged
merged 5 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/app/src/io/TauriIOProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class TauriIOProvider implements IOProvider {

async loadProjectDataNoPrompt(path: string): Promise<{ project: Project; testData: TrivetData }> {
const data = await readTextFile(path);
const [projectData, attachedData] = deserializeProject(data);
const [projectData, attachedData] = deserializeProject(data, path);

const trivetData = attachedData.trivet
? deserializeTrivetData(attachedData.trivet as SerializedTrivetData)
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/model/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type Project = {
title: string;
description: string;
mainGraphId?: GraphId;
path?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to serialize the path of the project in the project itself, which I'd like to avoid :/

Can you change the project metadata serialization to ignore this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pushed a change!

};

plugins?: PluginLoadSpec[];
Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/utils/serialization/serialization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ export function serializeProject(project: Project, attachedData?: AttachedData):
return projectV4Serializer(project, attachedData);
}

export function deserializeProject(serializedProject: unknown): [Project, AttachedData] {
export function deserializeProject(serializedProject: unknown, path: string | null = null): [Project, AttachedData] {
try {
return projectV4Deserializer(serializedProject);
const result = projectV4Deserializer(serializedProject);
if (path !== null)
result[0].metadata.path = path;
return result;
} catch (err) {
if (err instanceof yaml.YAMLError) {
yamlProblem(err);
Expand Down
6 changes: 3 additions & 3 deletions packages/core/test/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export async function loadTestGraphInProcessor(graphName: string) {

export async function loadProjectFromFile(path: string): Promise<Project> {
const content = await readFile(path, { encoding: 'utf8' });
return loadProjectFromString(content);
return loadProjectFromString(content, path);
}

export function loadProjectFromString(content: string): Project {
const [project] = deserializeProject(content);
export function loadProjectFromString(content: string, path: string | null = null): Project {
const [project] = deserializeProject(content, path);
return project;
}

Expand Down
Loading