{"version":3,"file":"migration.mjs","sources":["../../src/plops/migration.ts"],"sourcesContent":["import type { NodePlopAPI } from 'plop';\nimport tsUtils from '@strapi/typescript-utils';\nimport validateFileNameInput from './utils/validate-file-name-input';\nimport getFormattedDate from './utils/get-formatted-date';\n\nexport default (plop: NodePlopAPI) => {\n  // Migration generator\n  plop.setGenerator('migration', {\n    description: 'Generate a migration',\n    prompts: [\n      {\n        type: 'input',\n        name: 'name',\n        message: 'Migration name',\n        validate: (input) => validateFileNameInput(input),\n      },\n    ],\n    actions() {\n      const currentDir = process.cwd();\n      const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';\n      const timestamp = getFormattedDate();\n\n      return [\n        {\n          type: 'add',\n          path: `${currentDir}/database/migrations/${timestamp}.{{ name }}.${language}`,\n          templateFile: `templates/${language}/migration.${language}.hbs`,\n        },\n      ];\n    },\n  });\n};\n"],"names":["plop","setGenerator","description","prompts","type","name","message","validate","input","validateFileNameInput","actions","currentDir","process","cwd","language","tsUtils","isUsingTypeScriptSync","timestamp","getFormattedDate","path","templateFile"],"mappings":";;;;AAKA,wBAAe,CAAA,CAACA,IAAAA,GAAAA;;IAEdA,IAAAA,CAAKC,YAAY,CAAC,WAAA,EAAa;QAC7BC,WAAAA,EAAa,sBAAA;QACbC,OAAAA,EAAS;AACP,YAAA;gBACEC,IAAAA,EAAM,OAAA;gBACNC,IAAAA,EAAM,MAAA;gBACNC,OAAAA,EAAS,gBAAA;gBACTC,QAAAA,EAAU,CAACC,QAAUC,qBAAAA,CAAsBD,KAAAA;AAC7C;AACD,SAAA;AACDE,QAAAA,OAAAA,CAAAA,GAAAA;YACE,MAAMC,UAAAA,GAAaC,QAAQC,GAAG,EAAA;AAC9B,YAAA,MAAMC,QAAAA,GAAWC,OAAAA,CAAQC,qBAAqB,CAACL,cAAc,IAAA,GAAO,IAAA;AACpE,YAAA,MAAMM,SAAAA,GAAYC,gBAAAA,EAAAA;YAElB,OAAO;AACL,gBAAA;oBACEd,IAAAA,EAAM,KAAA;AACNe,oBAAAA,IAAAA,EAAM,GAAGR,UAAAA,CAAW,qBAAqB,EAAEM,SAAAA,CAAU,YAAY,EAAEH,QAAAA,CAAAA,CAAU;oBAC7EM,YAAAA,EAAc,CAAC,UAAU,EAAEN,QAAAA,CAAS,WAAW,EAAEA,QAAAA,CAAS,IAAI;AAChE;AACD,aAAA;AACH,QAAA;AACF,KAAA,CAAA;AACF,CAAA;;;;"}