UNPKG

a2r

Version:
72 lines (71 loc) 3.13 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = __importDefault(require("path")); const telemetry_1 = require("@a2r/telemetry"); const fs_1 = require("@a2r/fs"); const settings_1 = require("./settings"); // eslint-disable-next-line import/no-cycle const help_1 = require("./help"); const getProjectPath_1 = __importDefault(require("./getProjectPath")); const apiProxy_1 = require("./watcher/apiProxy"); const settings_2 = require("../settings"); const build = async (info) => { const { options } = info; if (!options.project) { telemetry_1.out.error('Missing project folder to run'); (0, help_1.printCommandUsage)('dev'); return; } if (options.settings) { await (0, settings_1.setFileName)(options.settings); } const { project: projectPath } = options; const settings = await (0, settings_1.getSettings)(); const project = settings.projects.find((p) => p.path === projectPath); if (!project) { telemetry_1.out.error(`Project ${projectPath} not found in solution`); return; } const { productionDomain } = settings; if (!productionDomain) { telemetry_1.out.error(`Can't build. Property "productionDomain" must be set in settings file`); return; } const mainProjectPath = await (0, getProjectPath_1.default)(); const optativeIntermediatePath = project.type === 'electron' ? 'renderer' : ''; const serverApiPath = path_1.default.resolve(mainProjectPath, settings_2.serverPath, settings_2.apiPath); const projectApiPath = path_1.default.resolve(mainProjectPath, projectPath, optativeIntermediatePath, settings_2.projectsInternalPath, settings_2.proxyPath, settings_2.apiPath); await (0, fs_1.ensureDir)(projectApiPath); await (0, fs_1.emptyFolder)(projectApiPath); await (0, apiProxy_1.build)(serverApiPath, projectApiPath); const serverModelPath = path_1.default.resolve(mainProjectPath, settings_2.serverPath, settings_2.modelPath); const projectModelPath = path_1.default.resolve(mainProjectPath, projectPath, optativeIntermediatePath, settings_2.projectsInternalPath, settings_2.proxyPath, settings_2.modelPath); await (0, fs_1.ensureDir)(projectModelPath); await (0, fs_1.emptyFolder)(projectModelPath); await (0, fs_1.copyContents)(serverModelPath, projectModelPath); // if (project.type === 'electron') { // const { productName } = settings; // if (!productName) { // out.error(`Can't build. Property "productName" must be set in settings file for Electron apps`); // return; // } // } }; const command = { name: 'build', description: 'Prepares project for deploy', run: build, args: [ { name: 'project', description: 'Project folder to run', type: String, typeLabel: '{underline folder name}', required: true, } ], }; exports.default = command;