// import { normalizePath } from '@cirrusct/fs'; // import { Logger } from '@cirrusct/logging'; // import { createError, MrPackage, shellExecCommandSettingsToCommandLine } from '@cirrusct/mr-core'; // import { templateReplace } from '@cirrusct/templates'; // import * as path from 'path'; // import { BuildSpecConfigSettings, BuildSpecConfigStartCommandSettings } from '../config'; // // TODO: not robust at all, but brute force for now.. // const outputToSrcEntryPath = (settings: BuildSpecConfigSettings, mrPackage: MrPackage) => { // const entry = mrPackage.main; // if (entry) { // const srcMappedPath = path.join(settings.paths.src, path.relative(settings.paths.output, mrPackage.main)); // // TODO: Can't assume it's ts... // const srcPath = srcMappedPath.substr(0, srcMappedPath.lastIndexOf('.')) + '.ts'; // return normalizePath(srcPath); // } // return undefined; // }; // interface StartCommandTemplateModel { // srcEntry: string; // outputEntry: string; // } // const buildNodeCommandLine = ( // settings: BuildSpecConfigStartCommandSettings, // options: { [name: string]: any }, // mrPackage: MrPackage, // isDev: boolean, // model: StartCommandTemplateModel // ): string => { // const cmdLineArgs = `${(settings.runtimeArgs || []).join(' ')} ${(settings.args || []).join(' ')}`.trim(); // let cmdLine = `node ${cmdLineArgs}`; // if ((settings.optionDefinitions || []).length > 0) { // const passedOptionNames = Object.keys(options); // const opts = settings.optionDefinitions.reduce((acc, curr) => { // if (passedOptionNames.indexOf(curr.name) >= 0) { // acc.push(`--${curr.name} ${options[curr.name] || ''}`.trim()); // } // return acc; // }, []); // cmdLine += opts.length > 0 ? ' ' + opts.join(' ') : ''; // } // return cmdLine; // }; // export const startCommandSettingsToCommandLine = ( // settings: BuildSpecConfigSettings, // options: { [name: string]: any }, // mrPackage: MrPackage, // logger: Logger // ): string => { // const isDev = process.env.NODE_ENV !== 'production'; // const srcEntry = outputToSrcEntryPath(settings, mrPackage); // const outputEntry = mrPackage.main; // const startCommandSettings = settings.startCommand; // if (!startCommandSettings) { // throw createError(`Start Command Settings not defined`); // } // const type = startCommandSettings.type || 'node'; // if (!(type === 'node')) { // throw createError(`Unsupported Start Command type: ${type}`); // } // const model: StartCommandTemplateModel = { // srcEntry, // outputEntry, // }; // logger.trace( // { // isDev, // ...model, // }, // 'startCommandSettingsToCommandLine' // ); // let cmdLine = buildNodeCommandLine(startCommandSettings, options, mrPackage, isDev, model); // cmdLine = templateReplace(cmdLine, model); // return cmdLine; // };