UNPKG

alwaysai

Version:

The alwaysAI command-line interface (CLI)

49 lines 1.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const difference = require("lodash.difference"); const install_models_1 = require("./install-models"); const path_1 = require("path"); const REQUIREMENTS_FILE_NAME = 'requirements.txt'; const VENV = 'venv'; exports.ACTIVATE = path_1.posix.join(VENV, 'bin', 'activate'); const IGNORED_FILE_NAMES = ['models', 'node_modules', '.git', 'venv']; function AppInstaller(target) { const installModels = install_models_1.InstallModels(target); return { installSource, installModels, installVirtualenv, installPythonDeps, }; async function installSource(source) { const allFileNames = await source.readdir(); const filteredFileNames = difference(allFileNames, IGNORED_FILE_NAMES); const readable = await source.tar(...filteredFileNames); await target.untar(readable); } async function installVirtualenv() { let changed = false; if (!(await target.exists(VENV))) { changed = true; await target.run({ exe: 'virtualenv', args: ['--system-site-packages', VENV], cwd: '.', }); } return { changed }; } async function installPythonDeps() { let changed = false; if (await target.exists(REQUIREMENTS_FILE_NAME)) { changed = true; await target.run({ exe: target.resolvePath(VENV, 'bin', 'pip'), args: ['install', '--requirement', target.resolvePath(REQUIREMENTS_FILE_NAME)], }); } return changed; } } exports.AppInstaller = AppInstaller; //# sourceMappingURL=index.js.map