UNPKG

@apillon/cli

Version:
76 lines 3.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDeployment = exports.listDeployments = exports.deployToEnvironment = exports.uploadWebsiteFiles = exports.deployWebsite = exports.getWebsite = exports.listWebsites = void 0; const sdk_1 = require("@apillon/sdk"); const options_1 = require("../../lib/options"); const utils_1 = require("../../lib/utils"); async function listWebsites(optsWithGlobals) { await (0, utils_1.withErrorHandler)(async () => { const data = await new sdk_1.Hosting(optsWithGlobals).listWebsites((0, options_1.paginate)(optsWithGlobals)); data.items = data.items.map((w) => w.serialize()); console.log(data); }); } exports.listWebsites = listWebsites; async function getWebsite(optsWithGlobals) { await (0, utils_1.withErrorHandler)(async () => { const website = await new sdk_1.Hosting(optsWithGlobals) .website(optsWithGlobals.uuid) .get(); console.log(website.serialize()); }); } exports.getWebsite = getWebsite; async function deployWebsite(path, optsWithGlobals) { await (0, utils_1.withErrorHandler)(async () => { const website = new sdk_1.Hosting(optsWithGlobals).website(optsWithGlobals.uuid); console.log(`Uploading files from folder: ${path}`); await website.uploadFromFolder(path); const deployment = await website.deploy(optsWithGlobals.preview ? sdk_1.DeployToEnvironment.TO_STAGING : sdk_1.DeployToEnvironment.DIRECTLY_TO_PRODUCTION); console.log(`Deployment started!`); const deploymentData = await website.deployment(deployment.uuid).get(); console.log(deploymentData.serialize()); }); } exports.deployWebsite = deployWebsite; async function uploadWebsiteFiles(path, optsWithGlobals) { await (0, utils_1.withErrorHandler)(async () => { await new sdk_1.Hosting(optsWithGlobals) .website(optsWithGlobals.uuid) .uploadFromFolder(path); }); } exports.uploadWebsiteFiles = uploadWebsiteFiles; async function deployToEnvironment(optsWithGlobals) { await (0, utils_1.withErrorHandler)(async () => { await new sdk_1.Hosting(optsWithGlobals) .website(optsWithGlobals.uuid) .deploy((0, sdk_1.toInteger)(optsWithGlobals.env)); console.log('Deploy successful'); }); } exports.deployToEnvironment = deployToEnvironment; async function listDeployments(optsWithGlobals) { await (0, utils_1.withErrorHandler)(async () => { const params = Object.assign(Object.assign({}, (0, options_1.paginate)(optsWithGlobals)), { environment: (0, sdk_1.toInteger)(optsWithGlobals.env), deploymentStatus: (0, sdk_1.toInteger)(optsWithGlobals.status) }); const data = await new sdk_1.Hosting(optsWithGlobals) .website(optsWithGlobals.uuid) .listDeployments(params); data.items = data.items.map((w) => w.serialize()); console.log(data); }); } exports.listDeployments = listDeployments; async function getDeployment(optsWithGlobals) { await (0, utils_1.withErrorHandler)(async () => { const deployment = await new sdk_1.Hosting(optsWithGlobals) .website(optsWithGlobals.websiteUuid) .deployment(optsWithGlobals.deploymentUuid) .get(); console.log(deployment.serialize()); }); } exports.getDeployment = getDeployment; //# sourceMappingURL=hosting.service.js.map