'use strict';

var path = require('path');
var utility = require('./utility-CsspJYjU.cjs.js');
var discovery = require('@backstage/backend-defaults/discovery');
var pluginTechdocsNode = require('@backstage/plugin-techdocs-node');
var PublisherConfig = require('./PublisherConfig-Cn5i8vF5.cjs.js');
require('winston');
require('stream');
require('process');
require('@backstage/config');

async function publish(opts) {
  const logger = utility.createLogger({ verbose: opts.verbose });
  const config = PublisherConfig.PublisherConfig.getValidConfig(opts);
  const discovery$1 = discovery.HostDiscovery.fromConfig(config);
  const publisher = await pluginTechdocsNode.Publisher.fromConfig(config, { logger, discovery: discovery$1 });
  const { isAvailable } = await publisher.getReadiness();
  if (!isAvailable) {
    return Promise.reject(new Error(""));
  }
  const [namespace, kind, name] = opts.entity.split("/");
  const entity = {
    kind,
    metadata: {
      namespace,
      name
    }
  };
  const directory = path.resolve(opts.directory);
  await publisher.publish({ entity, directory });
  return true;
}

exports.default = publish;
//# sourceMappingURL=publish-DH7Mbt7b.cjs.js.map
