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

feat(manifest): Add tags to Manifest #10

Merged
merged 16 commits into from
Apr 22, 2024
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/[email protected]',
'bundle/tps-0.json',
],
// data: {
// tags: {
// tps: true,
// m: true,
// },
// },
data: {
tags: {
tps: true,
m: true,
},
},
},
{
alias: ['bundle/tps-1'],
src: [
'bundle/[email protected]',
'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/[email protected]',
'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
Loading