deluan / contentful-migrate

🐎 Schema migration tooling for Contentful, with state management
https://www.contentful.com/blog/2018/09/13/content-model-changes-scale-telus-cms-as-code/
MIT License
60 stars 37 forks source link

Bootstrap script fails. eslint config not found #29

Closed f0rr0 closed 4 years ago

f0rr0 commented 5 years ago
  🚨  Failed to perform bootstrap : Error: No ESLint configuration found.
Error: No ESLint configuration found.
    at Config.getLocalConfigHierarchy (/Users/sid/dev/kult-contentful/node_modules/contentful-migrate/node_modules/eslint/lib/config.js:256:39)
    at Config.getConfigHierarchy (/Users/sid/dev/kult-contentful/node_modules/contentful-migrate/node_modules/eslint/lib/config.js:180:43)
    at Config.getConfigVector (/Users/sid/dev/kult-contentful/node_modules/contentful-migrate/node_modules/eslint/lib/config.js:287:21)
    at Config.getConfig (/Users/sid/dev/kult-contentful/node_modules/contentful-migrate/node_modules/eslint/lib/config.js:330:29)
    at processText (/Users/sid/dev/kult-contentful/node_modules/contentful-migrate/node_modules/eslint/lib/cli-engine.js:162:33)
    at CLIEngine.executeOnText (/Users/sid/dev/kult-contentful/node_modules/contentful-migrate/node_modules/eslint/lib/cli-engine.js:668:26)
    at jsonToScript (/Users/sid/dev/kult-contentful/node_modules/contentful-migrate/lib/bootstrap/jsonToScript.js:70:17)
    at /Users/sid/dev/kult-contentful/node_modules/contentful-migrate/lib/bootstrap/generateScripts.js:30:11
    at processTicksAndRejections (internal/process/task_queues.js:89:5) {
  messageTemplate: 'no-config-found',
  messageData: {
    directory: '/Users/sid/dev/kult-contentful',
    filesExamined: Object [Generator] {}
  }
}
jmparsons commented 4 years ago

Same error here, created an empty one and got a bunch of undefined models back.

deluan commented 4 years ago

This error is probably related to issue https://github.com/deluan/contentful-migrate/issues/52. The dependency on eslint is causing some issues in some circumstances. What usually helps is add contentful-migrate to your devDependencies, and call it with npx.

Can you try this?

Edit: I'm thinking about refactoring this eslint relationship, and maybe even making it optional. It is used to always generate properly formatted scripts.

jmparsons commented 4 years ago

@deluan thanks for getting back to me!

I've tried quite a bit of things. I did the eslint --init. Also cloned and npm link everything, so I can see the unformattedScript inside of the jsonToScript block. Everything looks great there.

I created a new project with just eslint and the CLIEngine and am not able to get any string output from it. If there are errors, I get the error messages. Then I read through the docs and it says CLIEngine - "This object will read the filesystem for configuration and file information but will not output any results."

I can return the return unformattedScript; in jsonToScript and everything works great. I've got it parsing my Contentful backend and generating all the proper files, then reran the up to see if it works, and that did perfectly as well. With the CLIEngine as the last line however, I get undefined as a response every time.

jmparsons commented 4 years ago

For us the formatting doesn't matter anyways since we use typescript eslint -> prettier on everything, but I can understand how it would be nice to have it ready to go on output.

jmparsons commented 4 years ago

I see what you're saying now. We pulled it out of our silo into our main project and our parser completly blow up - using parser: '@typescript-eslint/parser'. Our rules are a bit crazy. I'd definitely decouple it from eslint.

deluan commented 4 years ago

Hey @jmparsons I pushed a fix to this in the eslint branch. Can you give it a try before I merge it back to master? Thanks.

jmparsons commented 4 years ago

@deluan I'll give it a shot now.

jmparsons commented 4 years ago

@deluan It's working for me.

Default output using standard looks good as well:

module.exports.description = 'Create content model for Cars'

module.exports.up = (migration) => {
  const cars = migration.createContentType('cars')
    .name('Cars')
    .displayField('internalName')
    .description('')

  cars.createField('internalName')
    .name('Internal Name')
    .type('Symbol')

  cars.createField('carName')
    .name('Car Name')
    .type('Symbol')

  cars.changeEditorInterface('internalName', 'singleLine')
  cars.changeEditorInterface('carName', 'singleLine')
}

module.exports.down = migration => migration.deleteContentType('cars')
deluan commented 4 years ago

Thanks! I'll merge, release a new version and close this issue