mirror of
https://github.com/strapi/strapi.git
synced 2025-07-30 04:20:34 +00:00
update : fixed lint error
This commit is contained in:
parent
acdc56b296
commit
11923a820f
@ -1,46 +1,43 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const tsUtils = require('@strapi/typescript-utils');
|
const moment = require('moment');
|
||||||
|
const tsUtils = require('@strapi/typescript-utils');
|
||||||
const getDestinationPrompts = require('./prompts/get-destination-prompts');
|
|
||||||
const getFilePath = require('./utils/get-file-path');
|
|
||||||
const moment = require('moment/moment');
|
const validateInput = (input) => {
|
||||||
|
const regex = /^[A-Za-z-_0-9]+$/g;
|
||||||
const validateInput = (input) => {
|
|
||||||
const regex = /^[A-Za-z-\_0-9]+$/g;
|
if (!input) {
|
||||||
|
return 'You must provide an input';
|
||||||
if (!input) {
|
}
|
||||||
return 'You must provide an input';
|
|
||||||
}
|
return regex.test(input) || "Please use only letters and number, '-' or '_' and no spaces";
|
||||||
|
};
|
||||||
return regex.test(input) || "Please use only letters and number, '-' or '_' and no spaces";
|
|
||||||
};
|
module.exports = (plop) => {
|
||||||
|
// Migration generator
|
||||||
module.exports = (plop) => {
|
plop.setGenerator('migration', {
|
||||||
// Migration generator
|
description: 'Generate a migration',
|
||||||
plop.setGenerator('migration', {
|
prompts: [
|
||||||
description: 'Generate a migration',
|
{
|
||||||
prompts: [
|
type: 'input',
|
||||||
{
|
name: 'id',
|
||||||
type: 'input',
|
message: 'Migration name',
|
||||||
name: 'id',
|
validate: (input) => validateInput(input),
|
||||||
message: 'Migration name',
|
},
|
||||||
validate: (input) => validateInput(input),
|
],
|
||||||
},
|
actions(answers) {
|
||||||
],
|
const currentDir = process.cwd();
|
||||||
actions(answers) {
|
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
||||||
const filePath = getFilePath(answers.destination);
|
const timestamp = moment().format('YYYY_MM_DD_HH_mm_ss');
|
||||||
const currentDir = process.cwd();
|
|
||||||
const language = tsUtils.isUsingTypeScriptSync(currentDir) ? 'ts' : 'js';
|
return [
|
||||||
const timestamp = moment().format('YYYY_MM_DD_HH_mm_ss');
|
{
|
||||||
|
type: 'add',
|
||||||
return [
|
path: `${currentDir}/database/migrations/${timestamp}_{{ id }}.${language}`,
|
||||||
{
|
templateFile: `templates/${language}/migration.${language}.hbs`,
|
||||||
type: 'add',
|
},
|
||||||
path: `${currentDir}/database/migrations/${timestamp}_{{ id }}.${language}`,
|
];
|
||||||
templateFile: `templates/${language}/migration.${language}.hbs`,
|
},
|
||||||
},
|
});
|
||||||
];
|
};
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user