UNPKG

@lerna/publish

Version:

Publish packages in the current project

70 lines (69 loc) 2.87 kB
var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var create_github_client_exports = {}; __export(create_github_client_exports, { createGitHubClient: () => createGitHubClient, parseGitRepo: () => parseGitRepo }); module.exports = __toCommonJS(create_github_client_exports); var import_npmlog = __toESM(require("npmlog")); var import_rest = require("@octokit/rest"); var import_git_url_parse = __toESM(require("git-url-parse")); const childProcess = require("@lerna/child-process"); function createGitHubClient() { import_npmlog.default.silly("createGitHubClient"); const { GH_TOKEN, GHE_API_URL, GHE_VERSION } = process.env; if (!GH_TOKEN) { throw new Error("A GH_TOKEN environment variable is required."); } if (GHE_VERSION) { import_rest.Octokit.plugin(require(`@octokit/plugin-enterprise-rest/ghe-${GHE_VERSION}`)); } const options = { auth: `token ${GH_TOKEN}` }; if (GHE_API_URL) { options.baseUrl = GHE_API_URL; } return new import_rest.Octokit(options); } function parseGitRepo(remote = "origin", opts) { import_npmlog.default.silly("parseGitRepo"); const args = ["config", "--get", `remote.${remote}.url`]; import_npmlog.default.verbose("git", args); const url = childProcess.execSync("git", args, opts); if (!url) { throw new Error(`Git remote URL could not be found using "${remote}".`); } return (0, import_git_url_parse.default)(url); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { createGitHubClient, parseGitRepo });