"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const supi_1 = require("supi");
const createStoreController_1 = require("../createStoreController");
const readImporterManifest_1 = require("../readImporterManifest");
async function default_1(args, opts, command) {
    const store = await createStoreController_1.default(opts);
    const rebuildOpts = Object.assign(opts, {
        storeController: store.ctrl,
        storeDir: store.dir,
    });
    if (args.length === 0) {
        await supi_1.rebuild([
            {
                buildIndex: 0,
                manifest: await readImporterManifest_1.readImporterManifestOnly(rebuildOpts.dir, opts),
                rootDir: rebuildOpts.dir,
            },
        ], rebuildOpts);
    }
    await supi_1.rebuildPkgs([
        {
            manifest: await readImporterManifest_1.readImporterManifestOnly(rebuildOpts.dir, opts),
            rootDir: rebuildOpts.dir,
        },
    ], args, rebuildOpts);
}
exports.default = default_1;
