UNPKG

humpty

Version:

Makes sure your changelogs mention your breaking changes

52 lines (43 loc) 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _changeTypes = require("./changeTypes"); var changeTypes = _interopRequireWildcard(_changeTypes); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } const findReactApiChanges = (oldExport, newExport) => { const { api: newApi } = newExport; const apiChanges = []; oldExport.api.props.forEach(oldProp => { const newProp = newApi.props.find(p => p.name === oldProp.name); if (!newProp) { apiChanges.push({ propName: oldProp.name, changeType: changeTypes.PROP_REMOVED }); return; } if (oldProp.type.name !== newProp.type.name) { apiChanges.push({ propName: oldProp.name, changeType: changeTypes.PROP_TYPE_CHANGED, oldType: oldProp.type.name, newType: newProp.type.name }); } if (!oldProp.required && newProp.required) { apiChanges.push({ propName: oldProp.name, changeType: changeTypes.PROP_MADE_REQUIRED }); } if (oldProp.required && !newProp.required) { apiChanges.push({ propName: oldProp.name, changeType: changeTypes.PROP_MADE_OPTIONAL }); } }); return apiChanges; }; exports.default = findReactApiChanges;