UNPKG

alwaysai

Version:

The alwaysAI command-line interface (CLI)

57 lines 2.84 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.appPackageComponent = void 0; const alwayscli_1 = require("@alwaysai/alwayscli"); const constants_1 = require("../../constants"); const docker_1 = require("../docker"); const util_1 = require("../../util"); const app_check_component_1 = require("./app-check-component"); const project_1 = require("../../core/project"); const app_1 = require("../../core/app"); const paths_1 = require("../../paths"); async function appPackageComponent(props) { const { yes } = props; await (0, app_check_component_1.appCheckComponent)(); await (0, project_1.requirePaidPlan)(); const targetJsonFile = (0, app_1.TargetJsonFile)(); const targetConfig = targetJsonFile.read(); switch (targetConfig.targetProtocol) { case 'docker:': case 'ssh+docker:': { if (!(await targetJsonFile.readHostSpawner().exists(paths_1.VENV))) { throw new alwayscli_1.CliTerseError(`Python virtualenv not found! Did you run ${constants_1.ALWAYSAI_CLI_EXECUTABLE_NAME} app install?`); } await (0, docker_1.writeStandaloneDockerfileComponent)(); if (targetConfig.targetProtocol === 'ssh+docker:') { await (0, util_1.copyFile)((0, util_1.JsSpawner)(), targetJsonFile.readHostSpawner(), paths_1.DOCKERFILE_STANDALONE); } let dockerImageTag = props.dockerImageTag; if (!yes && !dockerImageTag) { const tagAnswer = await (0, util_1.promptForInput)({ purpose: 'to set a Docker image tag', questions: [ { type: 'text', name: 'tag', message: 'Enter a tag for the application Docker image. Format: <dockerhub-user>/<img-name>:<version>' } ] }); dockerImageTag = tagAnswer.tag; } const targetHostSpawner = targetJsonFile.readHostSpawner(); const appDockerImageId = await (0, docker_1.buildDockerImageComponent)({ targetHostSpawner, targetHardware: targetConfig.targetHardware, dockerImageTag, dockerfilePath: paths_1.DOCKERFILE_STANDALONE }); return dockerImageTag !== null && dockerImageTag !== void 0 ? dockerImageTag : appDockerImageId; } case 'native:': default: throw new alwayscli_1.CliTerseError(`Package can only be used with docker. Please run \`${constants_1.ALWAYSAI_CLI_EXECUTABLE_NAME} app configure\` and select a remote device`); } } exports.appPackageComponent = appPackageComponent; //# sourceMappingURL=app-package-component.js.map