mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 20:25:26 +00:00
Uniformed factory cross-functions naming
This commit is contained in:
@@ -116,15 +116,15 @@ async function getModelFolderContents(model: string): Promise<PartitionedBundle>
|
||||
}
|
||||
|
||||
// Splitting files from localization folders
|
||||
const bundle = filteredFiles.filter(entry => !entry.includes(".lproj"));
|
||||
const rawBundle = filteredFiles.filter(entry => !entry.includes(".lproj"));
|
||||
const l10nFolders = filteredFiles.filter(entry => entry.includes(".lproj"));
|
||||
|
||||
const bundleBuffers = bundle.map(file => readFile(path.resolve(model, file)));
|
||||
const bundleBuffers = rawBundle.map(file => readFile(path.resolve(model, file)));
|
||||
const buffers = await Promise.all(bundleBuffers);
|
||||
|
||||
const bundleMap = Object.assign({},
|
||||
...bundle.map((fileName, index) => ({ [fileName]: buffers[index] }))
|
||||
) as BundleUnit;
|
||||
const bundle: BundleUnit = Object.assign({},
|
||||
...rawBundle.map((fileName, index) => ({ [fileName]: buffers[index] }))
|
||||
);
|
||||
|
||||
// Reading concurrently localizations folder
|
||||
// and their files and their buffers
|
||||
@@ -158,7 +158,7 @@ async function getModelFolderContents(model: string): Promise<PartitionedBundle>
|
||||
);
|
||||
|
||||
return {
|
||||
bundle: bundleMap,
|
||||
bundle,
|
||||
l10nBundle
|
||||
};
|
||||
}
|
||||
@@ -170,17 +170,17 @@ async function getModelFolderContents(model: string): Promise<PartitionedBundle>
|
||||
*/
|
||||
|
||||
function getModelBufferContents(model: BundleUnit): PartitionedBundle {
|
||||
const bundle = removeHidden(Object.keys(model)).reduce<BundleUnit>((acc, current) => {
|
||||
const rawBundle = removeHidden(Object.keys(model)).reduce<BundleUnit>((acc, current) => {
|
||||
// Checking if current file is one of the autogenerated ones or if its
|
||||
// content is not available
|
||||
if (/(manifest|signature)/.test(current) || !bundle[current]) {
|
||||
if (/(manifest|signature)/.test(current) || !rawBundle[current]) {
|
||||
return acc;
|
||||
}
|
||||
|
||||
return { ...acc, [current]: model[current] };
|
||||
}, {});
|
||||
|
||||
const bundleKeys = Object.keys(bundle);
|
||||
const bundleKeys = Object.keys(rawBundle);
|
||||
|
||||
if (!bundleKeys.length) {
|
||||
throw new Error("Cannot proceed with pass creation: bundle initialized")
|
||||
@@ -189,19 +189,19 @@ function getModelBufferContents(model: BundleUnit): PartitionedBundle {
|
||||
// separing localization folders
|
||||
const l10nFolders = bundleKeys.filter(file => file.includes(".lproj"));
|
||||
const l10nBundle: PartitionedBundle["l10nBundle"] = Object.assign({},
|
||||
...l10nFolders.map(folder =>
|
||||
({ [folder]: bundle[folder] }) as BundleUnit
|
||||
...l10nFolders.map<BundleUnit>(folder =>
|
||||
({ [folder]: rawBundle[folder] })
|
||||
)
|
||||
);
|
||||
|
||||
const unLocalizedBundle: BundleUnit = Object.assign({},
|
||||
const bundle: BundleUnit = Object.assign({},
|
||||
...bundleKeys
|
||||
.filter(file => !file.includes(".lproj"))
|
||||
.map(file => ({ [file]: bundle[file] }))
|
||||
.map(file => ({ [file]: rawBundle[file] }))
|
||||
);
|
||||
|
||||
return {
|
||||
bundle: unLocalizedBundle,
|
||||
bundle,
|
||||
l10nBundle
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user