mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 18:25:24 +00:00
Removed _checkReqs, moved back its checks into generate()
This commit is contained in:
74
index.js
74
index.js
@@ -22,12 +22,10 @@ class Pass {
|
|||||||
this.passTypes = ["boardingPass", "eventTicket", "coupon", "generic", "storeCard"];
|
this.passTypes = ["boardingPass", "eventTicket", "coupon", "generic", "storeCard"];
|
||||||
this.overrides = options.overrides || {};
|
this.overrides = options.overrides || {};
|
||||||
this.Certificates = {};
|
this.Certificates = {};
|
||||||
this.model = null;
|
this.model = "";
|
||||||
|
|
||||||
this._parseSettings(options)
|
this._parseSettings(options)
|
||||||
.then(() => {
|
.catch(e => console.log(e));
|
||||||
this._checkReqs()
|
|
||||||
.catch(e => { throw new Error(e.error.message) });
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,9 +41,27 @@ class Pass {
|
|||||||
|
|
||||||
return new Promise((success, reject) => {
|
return new Promise((success, reject) => {
|
||||||
fs.readdir(this.model, (err, files) => {
|
fs.readdir(this.model, (err, files) => {
|
||||||
|
if (err) {
|
||||||
|
return reject({
|
||||||
|
status: false,
|
||||||
|
error: {
|
||||||
|
message: "Model not found. Provide a valid one to continue."
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// list without dynamic components like manifest, signature or pass files (will be added later in the flow) and hidden files.
|
// list without dynamic components like manifest, signature or pass files (will be added later in the flow) and hidden files.
|
||||||
let noDynList = removeHidden(files).filter(f => !/(manifest|signature|pass)/i.test(f));
|
let noDynList = removeHidden(files).filter(f => !/(manifest|signature|pass)/i.test(f));
|
||||||
|
|
||||||
|
if (!noDynList.length) {
|
||||||
|
return reject({
|
||||||
|
status: false,
|
||||||
|
error: {
|
||||||
|
message: "Model provided matched but unitialized. Refer to https://apple.co/2IhJr0Q and documentation to fill the model correctly."
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// list without localization files (they will be added later in the flow)
|
// list without localization files (they will be added later in the flow)
|
||||||
let bundleList = noDynList.filter(f => !f.includes(".lproj"));
|
let bundleList = noDynList.filter(f => !f.includes(".lproj"));
|
||||||
|
|
||||||
@@ -188,54 +204,6 @@ class Pass {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Check if the requirements are satisfied
|
|
||||||
|
|
||||||
@method _checkReqs
|
|
||||||
@returns {Promise} - success if requirements are satisfied, reject otherwise
|
|
||||||
*/
|
|
||||||
|
|
||||||
_checkReqs() {
|
|
||||||
return new Promise((success, reject) => {
|
|
||||||
fs.readdir(this.model, function(err, files) {
|
|
||||||
if (err) {
|
|
||||||
return reject({
|
|
||||||
status: false,
|
|
||||||
error: {
|
|
||||||
message: "Provided model name doesn't match with any model in the folder.",
|
|
||||||
ecode: 418
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Removing hidden files and folders
|
|
||||||
let list = removeHidden(files);
|
|
||||||
|
|
||||||
if (!list.length) {
|
|
||||||
return reject({
|
|
||||||
status: false,
|
|
||||||
error: {
|
|
||||||
message: "Model provided matched but unitialized. Refer to https://apple.co/2IhJr0Q to fill the model correctly.",
|
|
||||||
ecode: 418
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!list.includes("pass.json")) {
|
|
||||||
return reject({
|
|
||||||
status: false,
|
|
||||||
error: {
|
|
||||||
message: "I'm a teapot. How am I supposed to serve you pass without pass.json in the chosen model as tea without water?",
|
|
||||||
ecode: 418
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return success();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Checks if pass model type is one of the supported ones
|
Checks if pass model type is one of the supported ones
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user