Comparing version 0.1.4 to 0.1.5
@@ -14,3 +14,3 @@ #!/usr/bin/env node | ||
const { initialPrompt } = require('./lib/initial-prompt'); | ||
const { addTemplate } = require('./lib/add-template.js'); | ||
const { addTemplate, addTemplateAfter } = require('./lib/add-template.js'); | ||
@@ -68,3 +68,3 @@ opts | ||
try { | ||
const { pathToDestination, pathToRepo } = await initialPrompt(opts, choices); | ||
const { pathToDestination, pathToRepo, isNewRepo } = await initialPrompt(opts, choices); | ||
throwIfNotClean(ROOT_PATH, pathToDestination, opts); | ||
@@ -78,2 +78,5 @@ await deleteTemp(TEMP_PATH); | ||
await runPostInstall(templateCfg, path.resolve(ROOT_PATH, pathToDestination)); | ||
if (isNewRepo) { | ||
await addTemplateAfter(pathToRepo, config, path.resolve(__dirname, 'config.json')); | ||
} | ||
console.log('\nGo to your project by running'); | ||
@@ -80,0 +83,0 @@ console.log(chalk.cyan(`\n\tcd ${pathToDestination}\t`)); |
@@ -86,4 +86,58 @@ const inquirer = require('inquirer'); | ||
async function addTemplateAfter(repo, config, path) { | ||
const shouldAdd = await inquirer | ||
.prompt([ | ||
{ | ||
name: 'shouldAdd', | ||
message: 'Do you want to add this repo as a template for later use?', | ||
type: 'confirm', | ||
}, | ||
]) | ||
.then(res => res.shouldAdd); | ||
if (!shouldAdd) { | ||
return; | ||
} | ||
const newRepo = { | ||
value: repo, | ||
}; | ||
newRepo.name = await retryablePrompt( | ||
[ | ||
{ | ||
name: 'value', | ||
message: 'Enter a name for the template:', | ||
type: 'input', | ||
}, | ||
], | ||
'\n', | ||
chalk.yellow('Warning:'), | ||
'Name cannot be empty.', | ||
); | ||
newRepo.isDefault = await inquirer | ||
.prompt([ | ||
{ | ||
name: 'isDefault', | ||
message: 'Set as default template?', | ||
type: 'confirm', | ||
}, | ||
]) | ||
.then(res => res.isDefault); | ||
if (newRepo.isDefault) { | ||
const newTemplates = config.templates | ||
.slice() | ||
.map(template => Object.assign(template, { isDefault: false })); | ||
newTemplates.push(newRepo); | ||
await writeNewTemplates(newRepo.name, newTemplates, config, path); | ||
} else { | ||
const newTemplates = config.templates.slice(); | ||
newTemplates.push(newRepo); | ||
await writeNewTemplates(newRepo.name, newTemplates, config, path); | ||
} | ||
} | ||
module.exports = { | ||
addTemplate, | ||
addTemplateAfter, | ||
}; |
@@ -8,2 +8,3 @@ const inquirer = require('inquirer'); | ||
let pathToDestination = opts.dest; | ||
let isNewRepo = false; | ||
const templates = choices.filter(choice => choice.value !== 'custom'); | ||
@@ -27,2 +28,3 @@ | ||
if (pathToRepo === 'custom') { | ||
isNewRepo = true; | ||
console.log(); | ||
@@ -71,3 +73,3 @@ pathToRepo = await retryablePrompt( | ||
} | ||
return { pathToRepo, pathToDestination }; | ||
return { pathToRepo, pathToDestination, isNewRepo }; | ||
} | ||
@@ -74,0 +76,0 @@ |
{ | ||
"name": "insj", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "A no excuses project scaffolding tool", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40430
448