Open diminutivesloop opened 2 years ago
For what it's worth, this setup works for me:
yarn run contentful space migration migrations/test.ts
package.json
:
{
"private": true,
"scripts": {
"contentful": "NODE_OPTIONS=\"-r ts-node/register\" contentful"
},
"dependencies": {
"contentful-migration": "^4.9.2"
},
"devDependencies": {
"@types/node": "^18.0.0",
"contentful-cli": "^1.14.15",
"ts-node": "^10.8.1",
"typescript": "^4.7.4"
}
}
tsconfig.json
:
{
"compilerOptions": {
"target": "ES2021",
"module": "commonJS",
"moduleResolution": "node",
"lib": ["ES2021"],
"strict": true,
"types": ["node"]
},
"include": ["migrations/**/*.ts"]
}
migrations/test.ts
:
import Migration from "contentful-migration";
export = function (migration: Migration) {
// ...
};
Expected Behavior
The
contentful space migration
command should support migration scripts written in TypeScript.Actual Behavior
Passing TypeScript migration scripts causes the command to fail and report syntax errors.
Context
I'm currently using the legacy
contentful-migration
cli tool following the instructions for using it with TypeScript here. However this is inconvenient becausecontentful-migration
doesn't use the config options I've set viacontentful config
. If built-in support for TypeScript isn't feasible, then the documentation for running TypeScript migrations withcontentful-migration
should at least be updated for contentful-cli.Environment