Skip to content

Commit

Permalink
fix up metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodBoyDigital committed Apr 22, 2024
1 parent 3778125 commit 397e839
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 25 deletions.
12 changes: 10 additions & 2 deletions packages/manifest/src/pixiManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface PixiManifestOptions
output?: string;
createShortcuts?: boolean;
trimExtensions?: boolean;
includeMetaData?: boolean;
}

// TODO EXPORT this out! But don't want to create a dependency on the atlas plugin just yet..
Expand Down Expand Up @@ -68,6 +69,7 @@ export function pixiManifest(_options: PixiManifestOptions = {}): AssetPipe<Pixi
output: 'manifest.json',
createShortcuts: false,
trimExtensions: false,
includeMetaData: true,
..._options
};

Expand Down Expand Up @@ -135,7 +137,10 @@ function collectAssets(
alias: getShortNames(stripTags(path.relative(entryPath, `${asset.path}-${pageIndex}`)), options),
src: pages
.map((finalAsset) => path.relative(outputPath, finalAsset.path))
.sort((a, b) => b.localeCompare(a))
.sort((a, b) => b.localeCompare(a)),
data: options.includeMetaData ? {
tags: asset.allMetaData
} : undefined
});
});
}
Expand All @@ -145,7 +150,10 @@ function collectAssets(
alias: getShortNames(stripTags(path.relative(entryPath, asset.path)), options),
src: finalAssets
.map((finalAsset) => path.relative(outputPath, finalAsset.path))
.sort((a, b) => b.localeCompare(a))
.sort((a, b) => b.localeCompare(a)),
data: options.includeMetaData ? {
tags: asset.allMetaData
} : undefined
});
}
}
Expand Down
71 changes: 48 additions & 23 deletions packages/manifest/test/Manifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,20 @@ describe('Manifest', () =>
{
alias: ['bundle/json.json'],
src: ['bundle/json.json'],
data: {
tags: {
m: true,
},
},
},
{
alias: ['bundle/json.json5'],
src: ['bundle/json.json5'],
data: {
tags: {
m: true,
},
},
},
{
alias: ['bundle/sprite.png'],
Expand All @@ -159,37 +169,37 @@ describe('Manifest', () =>
'bundle/sprite.webp',
'bundle/sprite.png',
],
// data: {
// tags: {
// m: true,
// },
// },
data: {
tags: {
m: true,
},
},
},
{
alias: ['bundle/tps-0'],
src: [
'bundle/tps-0@0.5x.json',
'bundle/tps-0.json',
],
// data: {
// tags: {
// tps: true,
// m: true,
// },
// },
data: {
tags: {
tps: true,
m: true,
},
},
},
{
alias: ['bundle/tps-1'],
src: [
'bundle/tps-1@0.5x.json',
'bundle/tps-1.json',
],
// data: {
// tags: {
// tps: true,
// m: true,
// },
// },
data: {
tags: {
tps: true,
m: true,
},
},
},
],
});
Expand All @@ -199,26 +209,35 @@ describe('Manifest', () =>
{
alias: ['defaultFolder/1.mp3'],
src: ['defaultFolder/1.ogg', 'defaultFolder/1.mp3'],
data: {
tags: {},
},
},
{
alias: ['defaultFolder/3.wav'],
src: ['defaultFolder/3.ogg', 'defaultFolder/3.mp3'],
data: {
tags: {},
},
},
{
alias: ['spine/dragon.json'],
src: ['spine/dragon.json'],
data: {
tags: {}
},
},
{
alias: ['spine/dragon.atlas'],
src: [
'spine/dragon@0.5x.atlas',
'spine/dragon.atlas',
],
// data: {
// tags: {
// spine: true,
// },
// },
data: {
tags: {
spine: true,
},
},
},
],
});
Expand Down Expand Up @@ -319,6 +338,7 @@ describe('Manifest', () =>
pixiManifest({
createShortcuts: true,
trimExtensions: true,
includeMetaData: false
}),
],
});
Expand Down Expand Up @@ -463,6 +483,7 @@ describe('Manifest', () =>
pixiManifest({
createShortcuts: true,
trimExtensions: false,
includeMetaData: false
}),
],
});
Expand Down Expand Up @@ -585,6 +606,7 @@ describe('Manifest', () =>
pixiManifest({
createShortcuts: true,
trimExtensions: false,
includeMetaData: false
}),
],
});
Expand Down Expand Up @@ -729,6 +751,7 @@ describe('Manifest', () =>
pixiManifest({
createShortcuts: false,
trimExtensions: true,
includeMetaData: false
}),
],
});
Expand Down Expand Up @@ -894,7 +917,9 @@ describe('Manifest', () =>
output: outputDir,
cache: false,
pipes: [
pixiManifest(),
pixiManifest({
includeMetaData: false
}),
],
});

Expand Down

0 comments on commit 397e839

Please sign in to comment.