contentful-migration
Version:
Migration tooling for contentful
50 lines • 1.84 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const base_intent_1 = __importDefault(require("./base-intent"));
const field_update_1 = require("../action/field-update");
const chalk_1 = __importDefault(require("chalk"));
const lodash_1 = require("lodash");
class FieldUpdateIntent extends base_intent_1.default {
isFieldUpdate() {
return true;
}
groupsWith(other) {
const sameContentType = other.getContentTypeId() === this.getContentTypeId();
return ((other.isContentTypeUpdate() ||
other.isContentTypeCreate() ||
other.isContentTypeAnnotate() ||
other.isContentTypeTaxonomyValidation() ||
other.isFieldCreate() ||
other.isFieldUpdate() ||
other.isFieldMove()) &&
sameContentType);
}
endsGroup() {
return false;
}
toActions() {
return [
new field_update_1.FieldUpdateAction(this.getContentTypeId(), this.payload.fieldId, this.payload.props)
];
}
toPlanMessage() {
const details = (0, lodash_1.entries)(this.payload.props).map(([key, value]) => {
return (0, chalk_1.default) `{italic ${key}}: ${JSON.stringify(value)}`;
});
return {
heading: (0, chalk_1.default) `Update Content Type {bold.yellow ${this.getContentTypeId()}}`,
sections: [
{
heading: (0, chalk_1.default) `Update field {yellow ${this.getFieldId()}}`,
details
}
],
details: []
};
}
}
exports.default = FieldUpdateIntent;
//# sourceMappingURL=field-update.js.map