Added react,nextJs build support and reinstall node modules support
This commit is contained in:
parent
20f6329556
commit
502aa30e33
|
@ -27,6 +27,11 @@ MONGODB_URI=mongodb://xxx.xxx.xxx.xxx/node-deployer
|
|||
yarn run prod
|
||||
```
|
||||
|
||||
## Things to keep in mind while using
|
||||
|
||||
* Must use nodemon for the changes to automatically reload the server
|
||||
* pm2 is recommended for production
|
||||
|
||||
## Author
|
||||
|
||||
👤 **Bravo68web**
|
||||
|
|
|
@ -99,17 +99,26 @@ export const deploy = ({
|
|||
.then(notFound(res))
|
||||
.then((postJob) => {
|
||||
if (postJob) {
|
||||
exec(`cd ${postJob.deployLocation} && git fetch --all && git reset --hard origin/${postJob.gitBranch} && git pull `, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log(`error: ${error.message}`);
|
||||
return;
|
||||
exec(
|
||||
`cd ${
|
||||
postJob.deployLocation
|
||||
} && git fetch --all && git reset --hard origin/${
|
||||
postJob.gitBranch
|
||||
} && git pull ${
|
||||
postJob.buildRequired ? "&& rm -rf node_modules " : ""
|
||||
} && yarn ${postJob.buildRequired ? "&& yarn build " : ""}`,
|
||||
(error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log(`error: ${error.message}`);
|
||||
return;
|
||||
}
|
||||
if (stderr) {
|
||||
console.log(`stderr: ${stderr}`);
|
||||
return;
|
||||
}
|
||||
console.log(`stdout: ${stdout}`);
|
||||
}
|
||||
if (stderr) {
|
||||
console.log(`stderr: ${stderr}`);
|
||||
return;
|
||||
}
|
||||
console.log(`stdout: ${stdout}`);
|
||||
});
|
||||
);
|
||||
res.sendStatus(200);
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,30 +1,43 @@
|
|||
import mongoose, { Schema } from 'mongoose'
|
||||
|
||||
const postJobSchema = new Schema({
|
||||
gitUrl: {
|
||||
type: String
|
||||
const postJobSchema = new Schema(
|
||||
{
|
||||
gitUrl: {
|
||||
type: String,
|
||||
},
|
||||
deployLocation: {
|
||||
type: String,
|
||||
},
|
||||
deploySys: {
|
||||
type: String,
|
||||
},
|
||||
active: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
gitBranch: {
|
||||
type: String,
|
||||
default: "master",
|
||||
},
|
||||
buildRequired: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
removeNodeModules: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
deployLocation: {
|
||||
type: String
|
||||
},
|
||||
deploySys: {
|
||||
type: String
|
||||
},
|
||||
active: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
gitBranch: {
|
||||
type: String,
|
||||
default: 'master'
|
||||
{
|
||||
timestamps: true,
|
||||
toJSON: {
|
||||
virtuals: true,
|
||||
transform: (obj, ret) => {
|
||||
delete ret._id;
|
||||
},
|
||||
},
|
||||
}
|
||||
}, {
|
||||
timestamps: true,
|
||||
toJSON: {
|
||||
virtuals: true,
|
||||
transform: (obj, ret) => { delete ret._id }
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
postJobSchema.methods = {
|
||||
view (full) {
|
||||
|
|
Loading…
Reference in New Issue