Skip to content

Commit 5d08f15

Browse files
committed
Fix #319 keep unknown files when importing and downloading a project
1 parent 394beea commit 5d08f15

File tree

5 files changed

+23
-9
lines changed

5 files changed

+23
-9
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"deepslate-1.18": "npm:deepslate@0.9.0-beta.9",
4040
"deepslate-1.18.2": "npm:deepslate@0.9.0",
4141
"deepslate-1.20.4": "npm:deepslate@0.20.1",
42-
"deepslate": "^0.22.1",
42+
"deepslate": "^0.22.2",
4343
"highlight.js": "^11.5.1",
4444
"howler": "^2.2.3",
4545
"js-yaml": "^3.14.1",

src/app/components/generator/ProjectCreation.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,15 @@ export function ProjectCreation({ onClose }: Props) {
5050
try {
5151
const data = await parseSource(entry[1], 'json')
5252
project.files!.push({ ...file, data })
53+
return
5354
} catch (e) {
54-
console.error(`Failed parsing ${file.type} ${file.id}: ${message(e)}`)
55+
console.warn(`Failed parsing ${file.type} ${file.id}: ${message(e)}`)
5556
}
5657
}
58+
if (project.unknownFiles === undefined) {
59+
project.unknownFiles = []
60+
}
61+
project.unknownFiles.push({ path: entry[0], data: entry[1] })
5762
}))
5863
projectUpdater.current(project)
5964
onClose()

src/app/components/generator/ProjectPanel.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ export function ProjectPanel({ onRename, onCreate, onDeleteProject }: Props) {
7777
if (path === 'pack.mcmeta') hasPack = true
7878
return [[path, stringifySource(file.data)]] as [string, string][]
7979
})
80+
project.unknownFiles?.forEach(({ path, data }) => {
81+
entries.push([path, data])
82+
})
8083
if (!hasPack) {
8184
const pack_format = config.versions.find(v => v.id === version)!.pack_format
8285
entries.push(['pack.mcmeta', stringifySource({ pack: { pack_format, description: '' } })])

src/app/contexts/Project.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export type Project = {
1313
namespace?: string,
1414
version?: VersionId,
1515
files: ProjectFile[],
16+
unknownFiles?: UnknownFile[],
1617
}
1718
export const DRAFT_PROJECT: Project = {
1819
name: 'Drafts',
@@ -26,6 +27,11 @@ export type ProjectFile = {
2627
data: any,
2728
}
2829

30+
export type UnknownFile = {
31+
path: string,
32+
data: string,
33+
}
34+
2935
export const FilePatterns = [
3036
'worldgen/[a-z_]+',
3137
'tags/worldgen/[a-z_]+',

0 commit comments

Comments
 (0)