Skip to content

Commit

Permalink
fix: remove generated_with from manifest if disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
pascal541 committed Oct 2, 2022
1 parent c7b61f9 commit 5023d2f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/components/Projects/Project/loadManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import { version as appVersion } from '/@/utils/app/version'
export async function loadManifest(app: App, manifestPath: string) {
let manifest = await app.fileSystem.readJSON(manifestPath)

let addGeneratedWith = settingsState?.projects?.addGeneratedWith ?? true
let generatedWithBridge: string[] =
manifest?.metadata?.generated_with?.bridge ?? []
let generatedWithDash: string[] =
manifest?.metadata?.generated_with?.dash ?? []

let updatedManifest = false
// Check that the user wants to add the generated_with section
if (settingsState?.projects?.addGeneratedWith ?? true) {
if (addGeneratedWith) {
// Update generated_with bridge. version
if (
!generatedWithBridge.includes(appVersion) ||
Expand All @@ -31,6 +32,10 @@ export async function loadManifest(app: App, manifestPath: string) {
generatedWithDash = [dashVersion]
updatedManifest = true
}
} else {
if (manifest?.metadata?.generated_with) {
updatedManifest = true
}
}

// If the manifest changed, save changes to disk
Expand All @@ -39,10 +44,12 @@ export async function loadManifest(app: App, manifestPath: string) {
...(manifest ?? {}),
metadata: {
...(manifest?.metadata ?? {}),
generated_with: {
...(manifest?.metadata?.generated_with ?? {}),
...{ bridge: [appVersion], dash: [dashVersion] },
},
generated_with: addGeneratedWith
? {
...(manifest?.metadata?.generated_with ?? {}),
...{ bridge: generatedWithBridge, dash: generatedWithDash },
}
: undefined,
},
}

Expand Down

0 comments on commit 5023d2f

Please sign in to comment.