{"id":47309,"library":"contentful-smart-migration","title":"Contentful Smart Migration","description":"Contentful Smart Migration (v1.3.1) is a wrapper around the official Contentful migration CLI that simplifies writing migration scripts that work across multiple Contentful environments. It provides an `OperateOn` class that automatically determines whether a content type or field is new (creates) or existing (edits), reducing boilerplate and making migration scripts reusable. The package is authored by caesarbell, last updated in 2018, with no recent releases. It relies on `contentful-migration` and is intended for Node.js projects using Contentful's Content Management API.","status":"active","version":"1.3.1","language":"javascript","source_language":"en","source_url":"https://github.com/caesarbell/contentful-smart-migration","tags":["javascript","npm","contentful","migration","js"],"install":[{"cmd":"npm install contentful-smart-migration","lang":"bash","label":"npm"},{"cmd":"yarn add contentful-smart-migration","lang":"bash","label":"yarn"},{"cmd":"pnpm add contentful-smart-migration","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency for Contentful migration functionality; this package wraps it.","package":"contentful-migration","optional":false}],"imports":[{"note":"Package is ESM-only; named export. CommonJS require will fail.","wrong":"const OperateOn = require('contentful-smart-migration')","symbol":"OperateOn","correct":"import { OperateOn } from 'contentful-smart-migration'"},{"note":"Utility function to execute migration scripts; not documented in README but available in source.","symbol":"RunMigration","correct":"import { RunMigration } from 'contentful-smart-migration'"},{"note":"The class constructor expects four arguments: migration object from contentful-migration, context, content type definition object, and fields array. Not instantiated with 'new'.","wrong":"new OperateOn(migration, context, contentTypeDef, fields)","symbol":"migration","correct":"operateOn(migration, context, contentTypeDef, fields)"}],"quickstart":{"code":"const { OperateOn } = require('contentful-smart-migration');\nconst migration = require('contentful-migration').default;\n\nconst migrationFunction = (migration, context) => {\n  const contentTypeDef = {\n    id: 'componentExample',\n    opts: {\n      name: 'Component > Example',\n      description: 'Component Link that accepts xyz',\n      displayField: 'title',\n    },\n  };\n\n  const fields = [\n    {\n      id: 'title',\n      name: 'Title',\n    },\n  ];\n\n  const component = new OperateOn(migration, context, contentTypeDef, fields);\n  await component.operationOnContent;\n  await component.operationOnField;\n};\n\nmodule.exports = migrationFunction;","lang":"javascript","description":"Create a Content Type and its fields using OperateOn class, handling both creation and editing across environments."},"warnings":[{"fix":"Pin contentful-migration to v1.x or fork and update.","message":"Package relies on outdated contentful-migration v1; breaking changes in contentful-migration v2+ may cause runtime errors.","severity":"breaking","affected_versions":">=0.9.0"},{"fix":"Use await component.operationOnContent as shown; no parentheses.","message":"Class OperateOn uses property accessor syntax (e.g., await component.operationOnContent; this is a getter that returns a Promise, not a method).","severity":"deprecated","affected_versions":">=0.0.1"},{"fix":"Ensure you pass an object with `id` and `opts` keys, not just the id string.","message":"The constructor expects contentTypeExample as an object with `id` and `opts` properties, but the README uses `contentTypeExample` as variable name but parameter name is different.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Always include `type` key in field objects for non-Symbol fields (e.g., 'Text', 'Integer').","message":"Fields array items must have `id` and `name` for simple Symbol fields; for other types, `type` must be specified.","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"search_vec":"'2018':64 'across':24 'api':86 'around':11 'author':58 'automat':34 'boilerpl':49 'caesarbel':60 'class':32 'cli':16 'content':1,4,14,26,38,73,82,84,89 'contentful-migr':72 'creat':44 'determin':35 'edit':47 'environ':27 'exist':46 'field':41 'intend':77 'javascript':87 'js':91 'last':61 'make':51 'manag':85 'migrat':3,6,15,20,52,74,90 'multipl':25 'new':43 'node.js':79 'npm':88 'offici':13 'operateon':31 'packag':56 'project':80 'provid':29 'recent':67 'reduc':48 'releas':68 'reli':70 'reusabl':54 'script':21,53 'simplifi':18 'smart':2,5 'type':39 'updat':62 'use':81 'v1.3.1':7 'whether':36 'work':23 'wrapper':10 'write':19","created_at":"2026-06-07T16:50:51.583060+00:00","updated_at":"2026-06-07T16:50:51.583060+00:00","problems":[{"fix":"Downgrade contentful-migration to v1.x or patch migration object.","cause":"Using contentful-migration v2+ which changed API; smart-migration expects v1 API.","error":"TypeError: migration.createContentType is not a function"},{"fix":"Install with 'npm i contentful-smart-migration' and use import syntax.","cause":"Package is not installed or is ESM-only but used with CommonJS require.","error":"Cannot find module 'contentful-smart-migration'"},{"fix":"Use 'await component.operationOnContent' without parentheses.","cause":"Using method call syntax with parentheses; operationOnContent is a getter that returns a Promise.","error":"Uncaught TypeError: component.operationOnContent is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/caesarbell/contentful-smart-migration#readme","github":"https://github.com/caesarbell/contentful-smart-migration","docs":null,"changelog":null,"pypi":null,"npm":"contentful-smart-migration","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}