Skip to content

Commit 637222a

Browse files
committed
disable checking isComplete for functions
1 parent 88ac51d commit 637222a

File tree

2 files changed

+38
-49
lines changed

2 files changed

+38
-49
lines changed

routes/app-routing.js

+2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ module.exports = function(wagner) {
8484
result.then(function(response){
8585
if(response) {
8686
res.send("Microservice created! If you did not provide your Deployment information in the Client-Request Crowd Microservices is using the default GitHub repository, you can access microservice at https://microservice-template-2.herokuapp.com/endpoints/{endpoint}");
87+
}else {
88+
res.send("Deploying failed. Make sure the infomrmation is correct and project is define correctly");
8789
}
8890

8991
}).catch(function(err){

util/deployment_service.js

+36-49
Original file line numberDiff line numberDiff line change
@@ -14,51 +14,37 @@ module.exports = function (FirebaseService, ExpressGenerator, Config, Q) {
1414
//Fetch the project from firebase
1515
var project_promise = FirebaseService.retrieveProject(project_id);
1616
return result = project_promise.then(function (project) {
17-
var functions = project.artifacts.Functions;
18-
// read GitHub credential from Config file in Config directory
19-
var deploymentInfo = {
20-
repoName: Config.github["repoName"],
21-
token: Config.github["token"],
22-
firstName: Config.github["firstName"],
23-
lastName: Config.github["lastName"],
24-
email: Config.github["email"],
25-
userId: Config.github["username"],
26-
27-
};
28-
//if in the client request deployment info are inserted, it overwrite the deployment info, otherwise it reads data from the Config file
29-
if (project.deploymentInfo && project.deploymentInfo !== 'undefined' && project.deploymentInfo.gitUserId !== "" && project.deploymentInfo.gitToken !== "" && project.deploymentInfo.gitRepoName !== "" &&
30-
project.deploymentInfo.firstName !== "" && project.deploymentInfo.lastName !== "" && project.deploymentInfo.gitEmail !== "" ) {
31-
console.log("it used the client request github credential");
32-
for (var credential in project.deploymentInfo) {
33-
deploymentInfo.userId = project.deploymentInfo[credential].gitUserName;
34-
deploymentInfo.token = project.deploymentInfo[credential].gitToken;
35-
deploymentInfo.firstName = project.deploymentInfo[credential].gitUserFirstName;
36-
deploymentInfo.lastName = project.deploymentInfo[credential].gitUserLastName;
37-
deploymentInfo.email = project.deploymentInfo[credential].gitEmail;
38-
deploymentInfo.repoName = project.deploymentInfo[credential].gitRepoName;
17+
if (project != null) {
18+
var functions = project.artifacts.Functions;
19+
// read GitHub credential from Config file in Config directory
20+
var deploymentInfo = {
21+
repoName: Config.github["repoName"],
22+
token: Config.github["token"],
23+
firstName: Config.github["firstName"],
24+
lastName: Config.github["lastName"],
25+
email: Config.github["email"],
26+
userId: Config.github["username"],
27+
28+
};
29+
//if in the client request deployment info are inserted, it overwrite the deployment info, otherwise it reads data from the Config file
30+
if (project.deploymentInfo && project.deploymentInfo !== 'undefined' && project.deploymentInfo.gitUserId !== "" && project.deploymentInfo.gitToken !== "" && project.deploymentInfo.gitRepoName !== "" &&
31+
project.deploymentInfo.firstName !== "" && project.deploymentInfo.lastName !== "" && project.deploymentInfo.gitEmail !== "") {
32+
console.log("it used the client request github credential");
33+
for (var credential in project.deploymentInfo) {
34+
deploymentInfo.userId = project.deploymentInfo[credential].gitUserName;
35+
deploymentInfo.token = project.deploymentInfo[credential].gitToken;
36+
deploymentInfo.firstName = project.deploymentInfo[credential].gitUserFirstName;
37+
deploymentInfo.lastName = project.deploymentInfo[credential].gitUserLastName;
38+
deploymentInfo.email = project.deploymentInfo[credential].gitEmail;
39+
deploymentInfo.repoName = project.deploymentInfo[credential].gitRepoName;
40+
}
3941
}
40-
}
41-
var isComplete = false;
42-
43-
//Check if all the end points are complete
44-
for (var func in functions) {
45-
if (functions[func].isApiArtifact) {
46-
isComplete = functions[func].isComplete;
47-
}
48-
}
49-
//if end points are complete, create a template express app
50-
if (isComplete) {
51-
//if the template is created, add the code and routing
52-
// if (ExpressGenerator.createEndPints(project_id, path, port)) {
53-
5442
ExpressGenerator.createDir(rootPath + '/' + project_id);
5543
//return new Promise(function (resolve, reject) {
56-
var resultTmp = initGit(project_id, rootPath + '/' + project_id, deploymentInfo, functions);
44+
var resultTmp = initGit(project_id, rootPath + '/' + project_id, deploymentInfo, functions);
5745

58-
// });
5946
return true;
60-
}
61-
else {
47+
}else{
6248
return false;
6349
}
6450
}
@@ -69,6 +55,7 @@ module.exports = function (FirebaseService, ExpressGenerator, Config, Q) {
6955

7056

7157
}
58+
7259
// it pull the code from repo then add 2 files to the repo and push it back
7360
function initGit(project_id, projectPath, deploymentInfo, functions) {
7461
// return new Promise(function (resolve, reject) {
@@ -97,13 +84,13 @@ module.exports = function (FirebaseService, ExpressGenerator, Config, Q) {
9784
Git.init()
9885
.then(function (res) {
9986
console.log("user name set");
100-
return Git.direct('config user.name "' +deploymentInfo.firstName +' '+deploymentInfo.firstName + '"'); //Set user name for the repo commits
87+
return Git.direct('config user.name "' + deploymentInfo.firstName + ' ' + deploymentInfo.firstName + '"'); //Set user name for the repo commits
10188

10289
}).then(function (res) {
10390
console.log(res);
10491
console.log("mail set");
10592
return Git.direct('config user.email "' + deploymentInfo.email + '"'); //Set user email for repo commits
106-
}). then(function (res) {
93+
}).then(function (res) {
10794
// console.log("user name set");
10895

10996
return Git.pull('https://' + deploymentInfo.token + '@github.com/' + deploymentInfo.userId + '/' + deploymentInfo.repoName + '.git/ master --allow-unrelated-histories'); //Create a remote named origin
@@ -148,26 +135,26 @@ module.exports = function (FirebaseService, ExpressGenerator, Config, Q) {
148135
}
149136

150137

151-
function buildMicroserviceFiles(project_id, functions) {
138+
function buildMicroserviceFiles(project_id, functions) {
152139
var code = '';
153140
var routes = '';
154141
var exports = 'module.exports = {';
155142

156143
//create a single object with code from all complete functions
157144
for (var func in functions) {
158-
if (functions[func].isComplete) {
159-
code += "\n\n\n" + functions[func].header + '\n' + functions[func].code;
160-
exports += "\n" + functions[func].name + ":" + functions[func].name + ",";
161-
}
145+
// if (functions[func].isComplete) {
146+
code += "\n\n\n" + functions[func].header + '\n' + functions[func].code;
147+
exports += "\n" + functions[func].name + ":" + functions[func].name + ",";
148+
// }
162149
}
163150
exports = exports.substr(0, exports.length - 1) + " }";
164151
//Create the file with all the functions in the project
165-
ExpressGenerator.createServiceFile(project_id, rootPath, code + "\n" + exports +"\n"+"//"+new Date());
152+
ExpressGenerator.createServiceFile(project_id, rootPath, code + "\n" + exports + "\n" + "//" + new Date());
166153

167154
//create both get and post handlers for each end point
168155

169156
for (var func in functions) {
170-
if (functions[func].isApiArtifact && functions[func].isComplete) {
157+
if (functions[func].isApiArtifact /*&& functions[func].isComplete*/) {
171158
var get_parameters = '';
172159
var post_parameters = '';
173160
//Generate all parameters to be passed

0 commit comments

Comments
 (0)