mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 18:25:24 +00:00
Removed config.json from files, added validation for config output and models dir paths as promise in init() function
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@@ -2,9 +2,6 @@
|
|||||||
node_modules
|
node_modules
|
||||||
output/
|
output/
|
||||||
passModels/
|
passModels/
|
||||||
certificates/pass.cer
|
certificates/
|
||||||
certificates/passCertificate-exported.p12
|
|
||||||
certificates/passcertificate.pem
|
|
||||||
certificates/passkey.pem
|
|
||||||
certificates/source-AppleWWDRCA.cer
|
|
||||||
improvements.rtf
|
improvements.rtf
|
||||||
|
config.json
|
||||||
|
|||||||
19
config.json
19
config.json
@@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"certificates": {
|
|
||||||
"dir": "certificates",
|
|
||||||
"files": {
|
|
||||||
"wwdr": "WWDR.pem",
|
|
||||||
"signerCert": "passcertificate.pem",
|
|
||||||
"signerKey": "passkey.pem"
|
|
||||||
},
|
|
||||||
"credentials": {
|
|
||||||
"privateKeySecret": "123456"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"output": {
|
|
||||||
"dir": "output"
|
|
||||||
},
|
|
||||||
"models": {
|
|
||||||
"dir": "passModels"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
41
index.js
41
index.js
@@ -391,20 +391,41 @@ function init(configPath) {
|
|||||||
|
|
||||||
let setup = require(configPathResolved);
|
let setup = require(configPathResolved);
|
||||||
|
|
||||||
loadConfiguration(setup).then(function(config) {
|
let queue = [
|
||||||
Certificates.wwdr = config[0];
|
new Promise(function(success, reject) {
|
||||||
Certificates.signerCert = config[1];
|
fs.access(path.resolve(setup.models.dir), function(err) {
|
||||||
Certificates.signerKey = config[2];
|
if (err) {
|
||||||
|
return reject("A valid pass model directory is required. Please provide one in the configuration file under voice 'models.dir'.")
|
||||||
|
}
|
||||||
|
|
||||||
|
return success(null);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
new Promise((success) => fs.access(path.resolve(setup.output.dir), success)),
|
||||||
|
loadConfiguration(setup)
|
||||||
|
];
|
||||||
|
|
||||||
|
Promise.all(queue)
|
||||||
|
.then(function(results) {
|
||||||
|
let paths = results.slice(0, 2);
|
||||||
|
let certs = results[results.length-1];
|
||||||
|
|
||||||
|
if (!paths[0]) {
|
||||||
|
Configuration.passModelsDir = setup.models.dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!paths[1] && setup.output.shouldWrite) {
|
||||||
|
Configuration.output.dir = setup.output.dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
Certificates.wwdr = certs[0];
|
||||||
|
Certificates.signerCert = certs[1];
|
||||||
|
Certificates.signerKey = certs[2];
|
||||||
Certificates.status = true;
|
Certificates.status = true;
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
throw new Error(`Error: ${error}`);
|
throw new Error(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
Configuration.passModelsDir = setup.models.dir;
|
|
||||||
Configuration.output.dir = setup.output.dir;
|
|
||||||
// for a future implementation
|
|
||||||
Configuration.output.shouldWrite = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { init, RequestHandler };
|
module.exports = { init, RequestHandler };
|
||||||
|
|||||||
Reference in New Issue
Block a user