@apillon/cli
Version:
▶◀ Apillon CLI tools ▶◀
86 lines • 4.74 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createHostingCommands = void 0;
const commander_1 = require("commander");
const options_1 = require("../../lib/options");
const hosting_service_1 = require("./hosting.service");
const sdk_1 = require("@apillon/sdk");
const utils_1 = require("../../lib/utils");
function createHostingCommands(cli) {
const hosting = cli
.command('hosting')
.description('Commands for managing websites on Apillon hosting');
hosting
.command('deploy-website')
.description('Deploys website directly from local folder to Apillon hosting production environment')
.argument('<path>', 'path to folder with website files')
.requiredOption('--uuid <website uuid>', 'UUID of website to deploy')
.option('-p, --preview', 'deploys to staging environment')
.action(async function (path) {
await (0, hosting_service_1.deployWebsite)(path, this.optsWithGlobals());
});
const hostingList = hosting
.command('list-websites')
.description('List websites on Apillon hosting')
.action(async function () {
await (0, hosting_service_1.listWebsites)(this.optsWithGlobals());
});
(0, options_1.addPaginationOptions)(hostingList);
hosting
.command('get-website')
.description('Returns website data')
.requiredOption('--uuid <website uuid>', 'UUID of website to get')
.action(async function () {
await (0, hosting_service_1.getWebsite)(this.optsWithGlobals());
});
hosting
.command('upload')
.description(`Uploads a local folder's contents to a website deployment bucket.`)
.argument('<path>', 'path to folder with website files')
.requiredOption('--uuid <website uuid>', 'UUID of website to upload files to')
.action(async function (path) {
await (0, hosting_service_1.uploadWebsiteFiles)(path, this.optsWithGlobals());
});
hosting
.command('start-deployment')
.description('Starts deployment of website from uploaded files in deployment bucket')
.requiredOption('--uuid <website uuid>', 'UUID of website to deploy')
.addOption(new commander_1.Option('--env <environment>', 'Sets the environment to deploy the files to. Choose from:\n' +
` ${sdk_1.DeployToEnvironment.TO_STAGING}: To Staging\n` +
` ${sdk_1.DeployToEnvironment.STAGING_TO_PRODUCTION}: Staging to Production\n` +
` ${sdk_1.DeployToEnvironment.DIRECTLY_TO_PRODUCTION}: Directly to Production\n`)
.choices((0, utils_1.enumValues)(sdk_1.DeployToEnvironment))
.makeOptionMandatory(true))
.action(async function () {
await (0, hosting_service_1.deployToEnvironment)(this.optsWithGlobals());
});
const hostingListDeployments = hosting
.command('list-deployments')
.description('Returns list of started deployments')
.requiredOption('--uuid <website uuid>', 'UUID of website to list deployments for')
.addOption(new commander_1.Option('--env <environment>', 'Sets the environment to deploy the files to. Choose from:\n' +
` ${sdk_1.DeployToEnvironment.TO_STAGING}: To Staging\n` +
` ${sdk_1.DeployToEnvironment.STAGING_TO_PRODUCTION}: Staging to Production\n` +
` ${sdk_1.DeployToEnvironment.DIRECTLY_TO_PRODUCTION}: Directly to Production\n`).choices((0, utils_1.enumValues)(sdk_1.DeployToEnvironment)))
.addOption(new commander_1.Option('--status <deployment-status>', 'Status of the deployment (optional) Choose from:\n' +
` ${sdk_1.DeploymentStatus.INITIATED}: Initiated\n` +
` ${sdk_1.DeploymentStatus.IN_PROGRESS}: In progress\n` +
` ${sdk_1.DeploymentStatus.IN_REVIEW}: In review\n` +
` ${sdk_1.DeploymentStatus.APPROVED}: Approved\n` +
` ${sdk_1.DeploymentStatus.SUCCESSFUL}: Successful\n` +
` ${sdk_1.DeploymentStatus.FAILED}: Failed\n`).choices((0, utils_1.enumValues)(sdk_1.DeploymentStatus)))
.action(async function () {
await (0, hosting_service_1.listDeployments)(this.optsWithGlobals());
});
(0, options_1.addPaginationOptions)(hostingListDeployments);
hosting
.command('get-deployment')
.description('Returns deployment data')
.requiredOption('-w, --website-uuid <website uuid>', 'UUID of website')
.requiredOption('-d, --deployment-uuid <deployment uuid>', 'UUID of deployment to get')
.action(async function () {
await (0, hosting_service_1.getDeployment)(this.optsWithGlobals());
});
}
exports.createHostingCommands = createHostingCommands;
//# sourceMappingURL=hosting.commands.js.map