Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript Support for migration scripts #1417

Open
diminutivesloop opened this issue Apr 1, 2022 · 1 comment
Open

TypeScript Support for migration scripts #1417

diminutivesloop opened this issue Apr 1, 2022 · 1 comment

Comments

@diminutivesloop
Copy link

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 because contentful-migration doesn't use the config options I've set via contentful config. If built-in support for TypeScript isn't feasible, then the documentation for running TypeScript migrations with contentful-migration should at least be updated for contentful-cli.

Environment

  • Node Version: v16.13.2
  • Package Manager Version: Yarn 3.1.1
  • Operating System: Mac OS 11.6.5
  • Package Version: 1.12.5 (installed via Homebrew)
@samhanes-glooko
Copy link

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) {
    // ...
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants