|
|
@ -1,6 +1,6 @@ |
|
|
const CouchDB = require("pouchdb") |
|
|
const CouchDB = require("pouchdb") |
|
|
const PouchDB = require("../../../db") |
|
|
const PouchDB = require("../../../db") |
|
|
const newid = require("../../../db/newid") |
|
|
|
|
|
const env = require("../../../environment") |
|
|
const env = require("../../../environment") |
|
|
const deployment = env.SELF_HOSTED |
|
|
const deployment = env.SELF_HOSTED |
|
|
? require("./selfDeploy") |
|
|
? require("./selfDeploy") |
|
|
@ -69,7 +69,7 @@ async function storeLocalDeploymentHistory(deployment) { |
|
|
deploymentDoc = { _id: "_local/deployments", history: {} } |
|
|
deploymentDoc = { _id: "_local/deployments", history: {} } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const deploymentId = deploymentJSON._id || newid() |
|
|
const deploymentId = deploymentJSON._id |
|
|
|
|
|
|
|
|
// first time deployment
|
|
|
// first time deployment
|
|
|
if (!deploymentDoc.history[deploymentId]) |
|
|
if (!deploymentDoc.history[deploymentId]) |
|
|
@ -82,14 +82,12 @@ async function storeLocalDeploymentHistory(deployment) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
await db.put(deploymentDoc) |
|
|
await db.put(deploymentDoc) |
|
|
return { |
|
|
deployment.fromJSON(deploymentDoc.history[deploymentId]) |
|
|
_id: deploymentId, |
|
|
return deployment |
|
|
...deploymentDoc.history[deploymentId], |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async function deployApp({ appId, deploymentId }) { |
|
|
async function deployApp(deployment) { |
|
|
const deployment = new Deployment(deploymentId, appId) |
|
|
const appId = deployment.getAppId() |
|
|
try { |
|
|
try { |
|
|
await deployment.init() |
|
|
await deployment.init() |
|
|
deployment.setVerification(await preDeployment(deployment)) |
|
|
deployment.setVerification(await preDeployment(deployment)) |
|
|
@ -144,15 +142,11 @@ exports.deploymentProgress = async function(ctx) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
exports.deployApp = async function(ctx) { |
|
|
exports.deployApp = async function(ctx) { |
|
|
const deployment = await storeLocalDeploymentHistory({ |
|
|
let deployment = new Deployment(ctx.user.appId) |
|
|
appId: ctx.user.appId, |
|
|
deployment.setStatus(DeploymentStatus.PENDING) |
|
|
status: DeploymentStatus.PENDING, |
|
|
deployment = await storeLocalDeploymentHistory(deployment) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
await deployApp({ |
|
|
await deployApp(deployment) |
|
|
...ctx.user, |
|
|
|
|
|
deploymentId: deployment._id, |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
ctx.body = deployment |
|
|
ctx.body = deployment |
|
|
} |
|
|
} |
|
|
|