@prismatic-io/spectral
Version:
Utility library for building Prismatic connectors and code-native integrations
43 lines (42 loc) • 1.9 kB
JavaScript
;
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.getComponentSignatureWithPrism = void 0;
const child_process_1 = require("child_process");
const util_1 = require("util");
const exec = (0, util_1.promisify)(child_process_1.exec);
const getComponentSignatureWithPrism = (_a) => __awaiter(void 0, [_a], void 0, function* ({ skipSignatureVerify, }) {
if (!(yield isPrismAvailable())) {
console.log("Prism must be installed.");
process.exit(1);
}
const { stdout } = yield exec(`prism components:signature ${skipSignatureVerify ? "--skip-signature-verify" : ""}`, {
windowsHide: true,
});
const signatureKey = stdout.replace(/\n$/, "");
if (!signatureKey) {
console.log("Failed to get component signature, please verify your component has been published.");
process.exit(1);
}
return signatureKey;
});
exports.getComponentSignatureWithPrism = getComponentSignatureWithPrism;
const isPrismAvailable = () => __awaiter(void 0, void 0, void 0, function* () {
try {
yield exec("prism --version", {
windowsHide: true,
});
}
catch (_a) {
return false;
}
return true;
});