@backbase/generator-container
Advanced tools
Comparing version 1.0.6 to 2.0.0
104
index.js
@@ -6,47 +6,63 @@ var flow = require('lodash/flow'); | ||
function isMandatory(name) { | ||
return function(input) { | ||
if (!input) { | ||
return name + ' is mandatory'; | ||
} else if (Array.isArray(input)) { | ||
if (input.length === 0 || (input.length === 1 && !input[0])) { | ||
return name + ' is mandatory'; | ||
} | ||
} | ||
return true; | ||
} | ||
}; | ||
const prompts = (api, presets) => { | ||
const name = Object.assign({}, presets.name, { filter: flow(deburr, kebabCase) }); | ||
module.exports = { | ||
additionalQuestions: function() { | ||
return [ | ||
{ | ||
type: 'input', | ||
name: 'name', | ||
message: 'Name:', | ||
validate: isMandatory('Name'), | ||
filter: flow(deburr, kebabCase) | ||
}, { | ||
name: 'tags', | ||
message: 'Tags', | ||
filter: function(str){ | ||
return str.split(/\s*,\s*/); | ||
}, | ||
validate: isMandatory('Tags') | ||
}, { | ||
name: 'sectionTag', | ||
message: 'Section Tag', | ||
validate: isMandatory('Section Tag') | ||
}, { | ||
name: 'render_type', | ||
message: 'Render type', | ||
choices: ['csr', 'ssr'], | ||
default: 'ssr' | ||
}, { | ||
name: 'template_name', | ||
message: 'Template name', | ||
filter: flow(deburr, kebabCase), | ||
validate: isMandatory('Template name') | ||
}]; | ||
} | ||
const title = { | ||
type: 'input', | ||
name: 'title', | ||
message: 'Title', | ||
validate: value => api.validate.isRequired(value, 'Title is required'), | ||
filter: api.filter.trim, | ||
}; | ||
const tags = { | ||
name: 'tags', | ||
message: 'Tags', | ||
validate: value => api.validate.isRequired(value, 'Tags is required'), | ||
filter: (str) => str && str.split(/\s*,\s*/), | ||
}; | ||
const sectionTag = { | ||
name: 'sectionTag', | ||
message: 'Section Tag', | ||
validate: value => api.validate.isRequired(value, 'Section tags is required'), | ||
}; | ||
const renderType = { | ||
name: 'render_type', | ||
message: 'Render type', | ||
choices: ['csr', 'ssr'], | ||
default: 'ssr' | ||
}; | ||
const templateName = { | ||
name: 'template_name', | ||
message: 'Template name', | ||
filter: flow(deburr, kebabCase), | ||
validate: value => api.validate.isRequired(value, 'Template name is required') | ||
}; | ||
return [ | ||
name, | ||
title, | ||
tags, | ||
sectionTag, | ||
renderType, | ||
templateName | ||
]; | ||
} | ||
const config = (api) => ({ | ||
hooks: { | ||
preTransform: data => Object.assign(data, { | ||
transforms: { template_name: { camelCase: api.filter.camelCase(data.template_name) } } | ||
}) | ||
} | ||
}); | ||
module.exports = function(api, presets) { | ||
return api( | ||
prompts(api, presets), | ||
config(api) | ||
); | ||
}; |
{ | ||
"name": "@backbase/generator-container", | ||
"version": "1.0.6", | ||
"version": "2.0.0", | ||
"description": "Backbase generator for containers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
5987
91
9
1