"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const core_1 = require("@oclif/core");
const command_base_tenantless_1 = require("../../command-base-tenantless");
class DepCreate extends command_base_tenantless_1.CommandBaseTenantless {
    run() {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve, reject) => tslib_1.__awaiter(this, void 0, void 0, function* () {
                try {
                    this.bootstrap();
                    const { args, flags } = yield this.parse(DepCreate);
                    let cloneUrl;
                    if (args.url) {
                        cloneUrl = args.url;
                    }
                    else {
                        cloneUrl = (yield this._ui.prompt("cloneUrl", `Please enter the clone url of your new repository (CTRL-C to cancel): `, true));
                    }
                    yield this._ops.dependencyAuthorNew(cloneUrl, flags.pkgName, undefined, flags.version);
                    resolve();
                }
                catch (err) {
                    this.handleError(err);
                    reject(err);
                }
            }));
        });
    }
}
exports.default = DepCreate;
DepCreate.description = 'Sources a new dependency into the project from an existing repo url, initializes it with the package repository, and publishes the initial version if it is not already.  If the package repository is already initialized, the latest package version is used.';
DepCreate.flags = {
    help: core_1.Flags.help({ char: 'h' }),
    pkgName: core_1.Flags.string({ char: 'n', required: true, description: "Package name including any scope prefix (eg: @codiac.io/)" }),
    version: core_1.Flags.string({ char: 'v', required: false, description: "Version to apply to the dependency package if it has not yet been initialized." })
};
DepCreate.args = {
    url: core_1.Args.string({ description: 'The official clone url for the repository.', required: false })
};
//# sourceMappingURL=create.js.map