message: CLI - WIP support for plugin build, remove plugin build step from codegen
diff: @@ -13,6 +13,10 @@ import {
  parseClientConfigOption,
  parseManifestFileOption,
  parseLogFileOption,
  + getProjectFromManifest,
  + isPolywrapManifestLanguage,
  + isPluginManifestLanguage,
  + generateWrapFile,
  } from "../lib";
  import {
  DockerVMBuildStrategy,
  @@ -22,6 +26,7 @@ import {
  LocalBuildStrategy,
  } from "../lib/build-strategies";
  +import fs from "fs";
  import path from "path";
  import readline from "readline";
  import { PolywrapClient } from "@polywrap/client-js";
  @@ -146,26 +151,34 @@ async function run(options: BuildCommandOptions) {
  // Get Client
  const client = new PolywrapClient(clientConfig);
  - const project = new PolywrapProject({
  - rootDir: path.dirname(manifestFile),
  - polywrapManifestPath: manifestFile,
  - logger,
  - });
  - await project.validate();
  + const project = await getProjectFromManifest(manifestFile, logger);
  - const polywrapManifest = await project.getManifest();
  - await validateManifestModules(polywrapManifest);
  + if (!project) {
  + return;
  + }
  +
  + await project.validate();
  - const buildStrategy = createBuildStrategy(strategy, outputDir, project);
  + const manifest = await project.getManifest();
  + const language = manifest.project.type;
  const schemaComposer = new SchemaComposer({
  project,
  client,
  });
  + if (isPolywrapManifestLanguage(language)) {
  + await validateManifestModules(manifest as PolywrapManifest);
  +
  + const buildStrategy = createBuildStrategy(
  + strategy,
  + outputDir,
  + project as PolywrapProject
  + );
  +
  const execute = async (): Promise<boolean> => {
  const compiler = new Compiler({
  - project,
  + project: project as PolywrapProject,
  outputDir,
  schemaComposer,
  buildStrategy,
  @@ -237,6 +250,24 @@ async function run(options: BuildCommandOptions) {
  },
  });
  }
  + } else if (isPluginManifestLanguage(language)){
  + // Output the built manifest
  + const manifestPath = path.join(outputDir, "wrap.info");
  +
  + if (!fs.existsSync(outputDir)) {
  + fs.mkdirSync(outputDir);
  + }
  +
  + await generateWrapFile(
  + await schemaComposer.getComposedAbis(),
  + await project.getName(),
  + "plugin",
  + manifestPath,
  + logger
  + );
  + } else {
  + console.log("Unsupported project type!");
  + }
  process.exit(0);
  }
  