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
|
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
|
## Author
|
||||||
|
|
||||||
👤 **Bravo68web**
|
👤 **Bravo68web**
|
||||||
|
|
|
@ -99,17 +99,26 @@ export const deploy = ({
|
||||||
.then(notFound(res))
|
.then(notFound(res))
|
||||||
.then((postJob) => {
|
.then((postJob) => {
|
||||||
if (postJob) {
|
if (postJob) {
|
||||||
exec(`cd ${postJob.deployLocation} && git fetch --all && git reset --hard origin/${postJob.gitBranch} && git pull `, (error, stdout, stderr) => {
|
exec(
|
||||||
if (error) {
|
`cd ${
|
||||||
console.log(`error: ${error.message}`);
|
postJob.deployLocation
|
||||||
return;
|
} && 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);
|
res.sendStatus(200);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,30 +1,43 @@
|
||||||
import mongoose, { Schema } from 'mongoose'
|
import mongoose, { Schema } from 'mongoose'
|
||||||
|
|
||||||
const postJobSchema = new Schema({
|
const postJobSchema = new Schema(
|
||||||
gitUrl: {
|
{
|
||||||
type: String
|
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
|
timestamps: true,
|
||||||
},
|
toJSON: {
|
||||||
deploySys: {
|
virtuals: true,
|
||||||
type: String
|
transform: (obj, ret) => {
|
||||||
},
|
delete ret._id;
|
||||||
active: {
|
},
|
||||||
type: Boolean,
|
},
|
||||||
default: false
|
|
||||||
},
|
|
||||||
gitBranch: {
|
|
||||||
type: String,
|
|
||||||
default: 'master'
|
|
||||||
}
|
}
|
||||||
}, {
|
);
|
||||||
timestamps: true,
|
|
||||||
toJSON: {
|
|
||||||
virtuals: true,
|
|
||||||
transform: (obj, ret) => { delete ret._id }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
postJobSchema.methods = {
|
postJobSchema.methods = {
|
||||||
view (full) {
|
view (full) {
|
||||||
|
|
Loading…
Reference in New Issue