Disable templates prompt

This commit is contained in:
Rémi de Juvigny 2021-10-28 18:50:41 +02:00
parent 8109ef9bb2
commit 0609389b5a
3 changed files with 15 additions and 10 deletions

View File

@ -61,7 +61,7 @@ async function getTemplateQuestion() {
* @param {string|null} template - The template the project should use
* @returns Array of prompt question objects
*/
async function getPromptQuestions(projectName, template) {
async function getPromptQuestions(projectName /*, template*/) {
return [
{
type: 'input',
@ -85,13 +85,14 @@ async function getPromptQuestions(projectName, template) {
},
],
},
{
type: 'confirm',
name: 'useTemplate',
when: !template,
message:
'Would you like to use a template? (Templates are Strapi configurations designed for a specific use case)',
},
// TODO: re-enable once we know where to list the official compatible templates
// {
// type: 'confirm',
// name: 'useTemplate',
// when: !template,
// message:
// 'Would you like to use a template? (Templates are Strapi configurations designed for a specific use case)',
// },
];
}

View File

@ -4,6 +4,7 @@ const { resolve, join, basename } = require('path');
const fse = require('fs-extra');
const chalk = require('chalk');
const inquirer = require('inquirer');
const _ = require('lodash/fp');
// All directories that a template could need
const TEMPLATE_CONTENT = ['api', 'components', 'config/functions/bootstrap.js', 'data'];
@ -55,7 +56,8 @@ async function writeTemplateJson(rootPath) {
*/
async function templateConfigExists(rootPath) {
const jsonConfig = await fse.pathExists(join(rootPath, 'template.json'));
return Boolean(jsonConfig);
const configExists = !_.isNil(jsonConfig);
return configExists;
}
module.exports = async function generateTemplate(directory) {

View File

@ -30,7 +30,9 @@ module.exports = async function mergeTemplate(scope, rootPath) {
let templatePath;
let templateParentPath;
let templatePackageInfo = {};
const isLocalTemplate = ['./', '../'].some(filePrefix => scope.template.startsWith(filePrefix));
const isLocalTemplate = ['./', '../', '/'].some(filePrefix =>
scope.template.startsWith(filePrefix)
);
if (isLocalTemplate) {
// Template is a local directory