import BuildParameters from '../../../build-parameters'; import { OrchestratorSystem } from '../../services/core/orchestrator-system'; import OrchestratorEnvironmentVariable from '../../options/orchestrator-environment-variable'; import OrchestratorLogger from '../../services/core/orchestrator-logger'; import { ProviderInterface } from '../provider-interface'; import OrchestratorSecret from '../../options/orchestrator-secret'; import { ProviderResource } from '../provider-resource'; import { ProviderWorkflow } from '../provider-workflow'; import { quote } from 'shell-quote'; class LocalOrchestrator implements ProviderInterface { listResources(): Promise { throw new Error('Method not implemented.'); } listWorkflow(): Promise { throw new Error('Method not implemented.'); } watchWorkflow(): Promise { throw new Error('Method not implemented.'); } garbageCollect( // eslint-disable-next-line no-unused-vars filter: string, // eslint-disable-next-line no-unused-vars previewOnly: boolean, // eslint-disable-next-line no-unused-vars olderThan: Number, // eslint-disable-next-line no-unused-vars fullCache: boolean, // eslint-disable-next-line no-unused-vars baseDependencies: boolean, ): Promise { throw new Error('Method not implemented.'); } cleanupWorkflow( // eslint-disable-next-line no-unused-vars buildParameters: BuildParameters, // eslint-disable-next-line no-unused-vars branchName: string, // eslint-disable-next-line no-unused-vars defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[], ) {} public setupWorkflow( // eslint-disable-next-line no-unused-vars buildGuid: string, // eslint-disable-next-line no-unused-vars buildParameters: BuildParameters, // eslint-disable-next-line no-unused-vars branchName: string, // eslint-disable-next-line no-unused-vars defaultSecretsArray: { ParameterKey: string; EnvironmentVariable: string; ParameterValue: string }[], ) {} public async runTaskInWorkflow( buildGuid: string, image: string, commands: string, // eslint-disable-next-line no-unused-vars mountdir: string, // eslint-disable-next-line no-unused-vars workingdir: string, // eslint-disable-next-line no-unused-vars environment: OrchestratorEnvironmentVariable[], // eslint-disable-next-line no-unused-vars secrets: OrchestratorSecret[], ): Promise { OrchestratorLogger.log(image); OrchestratorLogger.log(buildGuid); OrchestratorLogger.log(commands); // On Windows, many built-in hooks use POSIX shell syntax. Execute via bash if available. if (process.platform === 'win32') { const inline = commands .replace(/\r/g, '') .split('\n') .filter((x) => x.trim().length > 0) .join(' ; '); // Use shell-quote to properly escape the command string, preventing command injection const bashWrapped = `bash -lc ${quote([inline])}`; return await OrchestratorSystem.Run(bashWrapped); } return await OrchestratorSystem.Run(commands); } } export default LocalOrchestrator;