mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 18:25:24 +00:00
Fixed wrong variables, added initialization
This commit is contained in:
@@ -65,7 +65,7 @@ async function getModelFolderContents(model: string): Promise<PartitionedBundle>
|
|||||||
const modelFilesList = await readDir(modelPath);
|
const modelFilesList = await readDir(modelPath);
|
||||||
|
|
||||||
// No dot-starting files, manifest and signature
|
// No dot-starting files, manifest and signature
|
||||||
const filteredFiles = removeHidden(modelFilesList).filter(f => !/(manifest|signature|pass)/i.test(f));
|
const filteredFiles = removeHidden(modelFilesList).filter(f => !/(manifest|signature)/i.test(f));
|
||||||
|
|
||||||
// Icon is required to proceed
|
// Icon is required to proceed
|
||||||
if (!(filteredFiles.length && filteredFiles.some(file => file.toLowerCase().includes("icon")))) {
|
if (!(filteredFiles.length && filteredFiles.some(file => file.toLowerCase().includes("icon")))) {
|
||||||
@@ -77,7 +77,7 @@ async function getModelFolderContents(model: string): Promise<PartitionedBundle>
|
|||||||
const rawBundle = filteredFiles.filter(entry => !entry.includes(".lproj"));
|
const rawBundle = filteredFiles.filter(entry => !entry.includes(".lproj"));
|
||||||
const l10nFolders = filteredFiles.filter(entry => entry.includes(".lproj"));
|
const l10nFolders = filteredFiles.filter(entry => entry.includes(".lproj"));
|
||||||
|
|
||||||
const bundleBuffers = rawBundle.map(file => readFile(path.resolve(model, file)));
|
const bundleBuffers = rawBundle.map(file => readFile(path.resolve(modelPath, file)));
|
||||||
const buffers = await Promise.all(bundleBuffers);
|
const buffers = await Promise.all(bundleBuffers);
|
||||||
|
|
||||||
const bundle: BundleUnit = Object.assign({},
|
const bundle: BundleUnit = Object.assign({},
|
||||||
@@ -89,7 +89,7 @@ async function getModelFolderContents(model: string): Promise<PartitionedBundle>
|
|||||||
const L10N_FilesListByFolder: Array<BundleUnit> = await Promise.all(
|
const L10N_FilesListByFolder: Array<BundleUnit> = await Promise.all(
|
||||||
l10nFolders.map(folderPath => {
|
l10nFolders.map(folderPath => {
|
||||||
// Reading current folder
|
// Reading current folder
|
||||||
const currentLangPath = path.join(model, folderPath);
|
const currentLangPath = path.join(modelPath, folderPath);
|
||||||
return readDir(currentLangPath)
|
return readDir(currentLangPath)
|
||||||
.then(files => {
|
.then(files => {
|
||||||
// Transforming files path to a model-relative path
|
// Transforming files path to a model-relative path
|
||||||
@@ -193,7 +193,9 @@ async function readCertificatesFromOptions(options: Certificates): Promise<Final
|
|||||||
|
|
||||||
// We read the contents
|
// We read the contents
|
||||||
const rawContentsPromises = Object.keys(flattenedDocs)
|
const rawContentsPromises = Object.keys(flattenedDocs)
|
||||||
.map(content => {
|
.map(key => {
|
||||||
|
const content = flattenedDocs[key];
|
||||||
|
|
||||||
if (!!path.parse(content).ext) {
|
if (!!path.parse(content).ext) {
|
||||||
// The content is a path to the document
|
// The content is a path to the document
|
||||||
return readFile(path.resolve(content), { encoding: "utf8"});
|
return readFile(path.resolve(content), { encoding: "utf8"});
|
||||||
|
|||||||
12
src/pass.ts
12
src/pass.ts
@@ -30,10 +30,10 @@ export class Pass implements PassIndexSignature {
|
|||||||
private bundle: schema.BundleUnit;
|
private bundle: schema.BundleUnit;
|
||||||
private l10nBundles: schema.PartitionedBundle["l10nBundle"];
|
private l10nBundles: schema.PartitionedBundle["l10nBundle"];
|
||||||
private _fields: string[];
|
private _fields: string[];
|
||||||
private _props: schema.ValidPass;
|
private _props: schema.ValidPass = {};
|
||||||
private type: string;
|
private type: string = "";
|
||||||
private fieldsKeys: Set<string>;
|
private fieldsKeys: Set<string> = new Set<string>();
|
||||||
private passCore: schema.ValidPass;
|
private passCore: schema.ValidPass = {};
|
||||||
|
|
||||||
Certificates: schema.FinalCertificates;
|
Certificates: schema.FinalCertificates;
|
||||||
l10nTranslations: { [key: string]: { [key: string]: string } } = {};
|
l10nTranslations: { [key: string]: { [key: string]: string } } = {};
|
||||||
@@ -61,8 +61,6 @@ export class Pass implements PassIndexSignature {
|
|||||||
this[transitType] = this.passCore[this.type]["transitType"];
|
this[transitType] = this.passCore[this.type]["transitType"];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fieldsKeys = new Set();
|
|
||||||
|
|
||||||
const typeFields = Object.keys(this.passCore[this.type]);
|
const typeFields = Object.keys(this.passCore[this.type]);
|
||||||
|
|
||||||
this._fields = ["primaryFields", "secondaryFields", "auxiliaryFields", "backFields", "headerFields"];
|
this._fields = ["primaryFields", "secondaryFields", "auxiliaryFields", "backFields", "headerFields"];
|
||||||
@@ -142,7 +140,7 @@ export class Pass implements PassIndexSignature {
|
|||||||
let hashFlow = forge.md.sha1.create();
|
let hashFlow = forge.md.sha1.create();
|
||||||
|
|
||||||
hashFlow.update(finalBundle[current].toString("binary"));
|
hashFlow.update(finalBundle[current].toString("binary"));
|
||||||
archive.append(current, { name: current });
|
archive.append(finalBundle[current], { name: current });
|
||||||
|
|
||||||
acc[current] = hashFlow.digest().toHex();
|
acc[current] = hashFlow.digest().toHex();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user