generate method

Future<void> generate({
  1. bool recompile = false,
})

Implementation

Future<void> generate({bool recompile = false}) async {
  final root = await rootOf(initialDirectory);
  logger.detail('Root: ${root.path}');

  final constructProgress = logger.progress('Retrieving constructs');
  final constructs = await constructHandler.constructDepsFrom(root);

  constructProgress.complete('Retrieved constructs');

  logger.detail('Constructs Dependencies: ${constructs.length}');
  for (final dep in constructs) {
    logger.detail('Package: ${dep.packageName}');
    for (final construct in dep.constructs) {
      logger.detail(' - ${construct.name}');
    }
  }

  final needsNewKernel = await checkAssets(constructs, root);

  if (!recompile && !needsNewKernel) {
    final kernel = await root.getInternalRevaliFile(kernelFile);

    if (await kernel.exists()) {
      logger
        ..detail('Skipping entrypoint generation, using existing kernel')
        ..success('Constructs entrypoint is up to date');
      return;
    }
  }

  if (recompile) {
    logger.detail('Forcing entrypoint recompile');
  }

  final entrypointProgress =
      logger.progress('Generating constructs entrypoint');

  await createEntrypoint(
    root,
    constructs: constructs,
  );
  entrypointProgress.complete('Generated constructs entrypoint');

  final compileProgress = logger.progress('Compiling constructs entrypoint');
  await compile(root: root);
  compileProgress.complete('Compiled constructs entrypoint');
}