semantic-release-nuget
Version:
A semantic-release plugin for building and publishing NuGet packages.
79 lines • 3.67 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.verifyConditions = void 0;
const options_1 = require("./options");
const child = __importStar(require("child_process"));
function verifyConditions(options, config) {
return __awaiter(this, void 0, void 0, function* () {
// Resolve the options and make sure we have them all populated.
const resolved = options_1.resolveOptions(options, config);
// Set up debugging.
const { logger } = config;
const debug = resolved.debug ? logger.debug : () => { };
logger.debug = debug;
debug("options", resolved);
// Verify the conditions.
let errors = [];
if (!resolved.pushUrl || resolved.pushUrl === "") {
errors.push("NUGET_PUSH_URL or the pushUrl options must be set");
}
if (!resolved.apiKey || resolved.apiKey === "") {
errors.push("NUGET_TOKEN or apiKey option must be set");
}
// Make sure we have access to the `dotnet nuget` command.
try {
const output = child.spawnSync("dotnet", ["nuget", "--version"]);
if (output.status !== 0) {
errors.push("The `dotnet nuget --version` responded with an error code");
}
else {
const lines = output.stdout.toString().trim().split(/\n/);
if (lines[0] !== "NuGet Command Line") {
errors.push("`dotnet nuget --version` didn't respond as expected: " +
lines.join(", "));
}
logger.info("Using NuGet version " + lines[1]);
}
}
catch (_a) {
errors.push("Cannot run the `dotnet` process");
}
// If we have any errors, throw a combined error.
if (errors.length > 0) {
for (const error of errors) {
logger.error(error);
}
throw new Error("Could not verify conditions for NuGet");
}
});
}
exports.verifyConditions = verifyConditions;
//# sourceMappingURL=verify.js.map