maoberlehner / storyblok-migrate

Storyblok schema migrations
MIT License
30 stars 7 forks source link

storyblok-migrate crashes when display_name is null #1

Closed AnasBoulmane closed 5 years ago

AnasBoulmane commented 5 years ago

Current behavior

storyblok-migrate crashes when display_name is null after the question 'Migrate all components? '

// storyblok/new.js
module.exports = {
  name: "new",
  display_name: null,
  schema: {
    title: {
      pos: 0,
      type: 'text',
    },
  },
  image: null,
  preview_field: null,
  is_root: false,
  is_nestable: true,
  all_presets: [],
  preset_id: null,
  real_name: "new",
  component_group_uuid: null
};
#  npx storyblok-migrate or
$ npx storyblok-migrate --component-migrations --components new
null component has been updated
✔ Do you want to run component migrations? · No / Yes
✔ Migrate all components? · No / Yes
(node:20516) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'choices' of null
    at reset (/Users/aboulmane/.project/CMS/storyblok-migrate/node_modules/enquirer/lib/types/array.js:646:30)
    at MultiSelect.get choices [as choices] (/Users/aboulmane/.project/CMS/storyblok-migrate/node_modules/enquirer/lib/types/array.js:582:12)
    at MultiSelect.get focused [as focused] (/Users/aboulmane/.project/CMS/storyblok-migrate/node_modules/enquirer/lib/types/array.js:623:23)
    at MultiSelect.submit (/Users/aboulmane/.project/CMS/storyblok-migrate/node_modules/enquirer/lib/types/array.js:530:23)
    at Promise (/Users/aboulmane/.project/CMS/storyblok-migrate/node_modules/enquirer/lib/prompt.js:234:21)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:20516) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:20516) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Expected behavior

no crash

Environment

node --version: v10.15.3 storyblok-migrate: ^0.3.1

maoberlehner commented 5 years ago

Thank you for your detailed bug report!

I'll think about using the name as a fallback if display_name is not specified to fix this. Thanks!