export async function driveResynthesis()

in packages/utils/blueprint-cli/src/resynth-drivers/resynth-driver.ts [31:93]


export async function driveResynthesis(log: pino.BaseLogger, options: ResynthDriverCliOptions): Promise<void> {
  // todo validate input

  // we want one driver file that we execute multiple times with different options
  const { synthDriver, resynthDriver } = await makeDriverFile(log, {
    blueprint: options.blueprint,
    cache: options.cache,
  });

  try {
    //figure out which options we have, call synthesis for each of these options
    const wizardConfigurations = getWizardOptions(log, {
      defaultOptionsLocation: options.defaultOptions,
      additionalOptionsLocation: options.additionalOptions,
    });

    for (const wizardOption of wizardConfigurations) {
      const jobname = `${'00.resynth.'}${path.parse(wizardOption.path).base}`;
      const outputDir = path.join(options.outdir, `${jobname}`);
      let priorOptions = getPriorOptions(log, [
        options.priorOptions,
        options.existingBundle && path.join(options.existingBundle, 'options.json'),
        path.join(outputDir, EXISTING_BUNDLE_SUBPATH, 'options.json'),
      ]);
      const existingBundle = options.existingBundle || path.join(outputDir, EXISTING_BUNDLE_SUBPATH);

      log.info('==========================================');
      log.info(`[${jobname}]`);
      log.info(
        [
          'npx blueprint resynth',
          `--options merge[${options.defaultOptions},${wizardOption.path}]`,
          `--blueprint ${options.blueprint}`,
          `--outdir ${outputDir}`,
          `--existing-bundle ${existingBundle}`,
          `--prior-blueprint ${options.blueprint}`,
          `--prior-options ${priorOptions?.path || `--options merge[${options.defaultOptions},${wizardOption.path}]`}`,
          `${(options.cache && '--cache') || ''}`,
        ].join(' '),
      );
      log.info('==========================================');
      void (await resynthesize(log, {
        synthDriver,
        resynthDriver,
        jobname,
        outdir: outputDir,
        blueprint: options.blueprint,
        options: wizardOption.option,
        priorBlueprint: options.blueprint,
        priorOptions: priorOptions?.option || wizardOption.option,
        existingBundleLocation: existingBundle,
        cleanUp: false,
      }));
    }
  } catch (error) {
    log.error(error as any);
  } finally {
    if (options.cleanUp === true) {
      cleanUpDriver(log, synthDriver);
      cleanUpDriver(log, resynthDriver);
    }
  }
}