in eng/tools/spec-gen-sdk-runner/src/commands.ts [23:68]
export async function generateSdkForSingleSpec(): Promise<number> {
// Parse the arguments
const commandInput: SpecGenSdkCmdInput = parseArguments();
const specConfigPathText = `${commandInput.tspConfigPath} ${commandInput.readmePath}`;
// Construct the spec-gen-sdk command
const specGenSdkCommand = prepareSpecGenSdkCommand(commandInput);
logMessage(`Generating SDK from ${specConfigPathText}`, LogLevel.Group);
logMessage(`Runner command:${specGenSdkCommand.join(" ")}`);
let statusCode = 0;
try {
await runSpecGenSdkCommand(specGenSdkCommand);
logMessage("Runner command executed successfully");
} catch (error) {
logMessage(`Runner: error executing command:${error}`, LogLevel.Error);
statusCode = 1;
}
let executionReport;
try {
// Read the execution report to determine if the generation was successful
executionReport = getExecutionReport(commandInput);
const executionResult = executionReport.executionResult;
logMessage(`Runner command execution result:${executionResult}`);
} catch (error) {
logMessage(`Runner: error reading execution-report.json:${error}`, LogLevel.Error);
statusCode = 1;
}
if (statusCode === 0) {
// Set the pipeline variables for the SDK pull request
let packageName: string =
executionReport.packages[0]?.packageName ??
commandInput.tspConfigPath ??
commandInput.readmePath ??
"missing-package-name";
packageName = packageName.replace("/", "-");
const installationInstructions = executionReport.packages[0]?.installationInstructions;
setPipelineVariables(packageName, installationInstructions);
}
logMessage("ending group logging", LogLevel.EndGroup);
logIssuesToPipeline(executionReport?.vsoLogPath, specConfigPathText);
return statusCode;
}