fix(new-design): Handle git failures
This commit is contained in:
parent
6bef56efb7
commit
0483e6b3f8
1 changed files with 42 additions and 34 deletions
|
@ -109,8 +109,8 @@ const copyTemplate = async (config, choices) => {
|
||||||
for (const from of config.files.template) {
|
for (const from of config.files.template) {
|
||||||
const to = join(config.dest, from.slice(config.source.template.length -7))
|
const to = join(config.dest, from.slice(config.source.template.length -7))
|
||||||
if (!dirs[to]) await ensureDir(to)
|
if (!dirs[to]) await ensureDir(to)
|
||||||
if (extname(from) === '.json') {
|
if ([ 'config.js', 'kage.json'].indexOf(from.slice(-9)) !== -1) {
|
||||||
// Template out package.json
|
// Template out file rather than coy it
|
||||||
const src = await readFile(from, 'utf-8')
|
const src = await readFile(from, 'utf-8')
|
||||||
promises.push(
|
promises.push(
|
||||||
writeFile(to, mustache.render(src, { name: choices.name }))
|
writeFile(to, mustache.render(src, { name: choices.name }))
|
||||||
|
@ -218,44 +218,52 @@ export const createEnvironment = async (choices) => {
|
||||||
console.log()
|
console.log()
|
||||||
|
|
||||||
// Copy/Template files
|
// Copy/Template files
|
||||||
await oraPromise(
|
try {
|
||||||
copyTemplate(config, choices),
|
await oraPromise(
|
||||||
{
|
copyTemplate(config, choices),
|
||||||
text: chalk.white.bold('🟨⬜⬜⬜ Copying template files')+chalk.white.dim(' | Just a moment'),
|
{
|
||||||
successText: chalk.white.bold('🟩⬜⬜⬜ Copied template files'),
|
text: chalk.white.bold('🟨⬜⬜⬜ Copying template files')+chalk.white.dim(' | Just a moment'),
|
||||||
failText: chalk.white.bold(' ⚠️ Failed to copy template files'),
|
successText: chalk.white.bold('🟩⬜⬜⬜ Copied template files'),
|
||||||
}
|
failText: chalk.white.bold('🟥⬜⬜⬜ Failed to copy template files | Development environment will not function'),
|
||||||
)
|
}
|
||||||
|
)
|
||||||
|
} catch (err) { /* no feedback here */ }
|
||||||
|
|
||||||
// Install dependencies
|
// Install dependencies
|
||||||
await oraPromise(
|
try {
|
||||||
installDependencies(config, choices),
|
await oraPromise(
|
||||||
{
|
installDependencies(config, choices),
|
||||||
text: chalk.white.bold('🟩🟨⬜⬜ Installing dependencies')+chalk.white.dim(' | Please wait, this will take a while'),
|
{
|
||||||
successText: chalk.white.bold('🟩🟩⬜⬜ Installed dependencies'),
|
text: chalk.white.bold('🟩🟨⬜⬜ Installing dependencies')+chalk.white.dim(' | Please wait, this will take a while'),
|
||||||
failText: chalk.white.bold(' ⚠️ Failed to install dependencies'),
|
successText: chalk.white.bold('🟩🟩⬜⬜ Installed dependencies'),
|
||||||
}
|
failText: chalk.white.bold('🟩🟥⬜⬜ Failed to install dependencies | Development environment will not function'),
|
||||||
)
|
}
|
||||||
|
)
|
||||||
|
} catch (err) { /* no feedback here */ }
|
||||||
|
|
||||||
// Fetch web components
|
// Fetch web components
|
||||||
await oraPromise(
|
try {
|
||||||
downloadLabFiles(config),
|
await oraPromise(
|
||||||
{
|
downloadLabFiles(config),
|
||||||
text: chalk.white.bold('🟩🟩🟨⬜ Downloading web components')+chalk.white.dim(' | Almost there'),
|
{
|
||||||
successText: chalk.white.bold('🟩🟩🟩⬜ Downloaded web components'),
|
text: chalk.white.bold('🟩🟩🟨⬜ Downloading web components')+chalk.white.dim(' | Almost there'),
|
||||||
failText: chalk.white.bold(' ⚠️ Failed to download web components'),
|
successText: chalk.white.bold('🟩🟩🟩⬜ Downloaded web components'),
|
||||||
}
|
failText: chalk.white.bold('🟩🟩🟥⬜ Failed to download web components | Development environment will not function'),
|
||||||
)
|
}
|
||||||
|
)
|
||||||
|
} catch (err) { /* no feedback here */ }
|
||||||
|
|
||||||
// Initialize git repository
|
// Initialize git repository
|
||||||
await oraPromise(
|
try {
|
||||||
initGitRepo(config, choices),
|
await oraPromise(
|
||||||
{
|
initGitRepo(config, choices),
|
||||||
text: chalk.white.bold('🟩🟩🟩⬜ Initializing git repository')+chalk.white.dim(' | You have git, right?'),
|
{
|
||||||
successText: chalk.white.bold('🟩🟩🟩🟩 Initialized git repository'),
|
text: chalk.white.bold('🟩🟩🟩⬜ Initializing git repository')+chalk.white.dim(' | You have git, right?'),
|
||||||
failText: chalk.white.bold(' ⚠️ Failed to initialize git repository')+chalk.white.dim(' | This does not stop you from developing your design'),
|
successText: chalk.white.bold('🟩🟩🟩🟩 Initialized git repository'),
|
||||||
}
|
failText: chalk.white.bold('🟩🟩🟩🟥 Failed to initialize git repository')+chalk.white.dim(' | This does not stop you from developing your design'),
|
||||||
)
|
}
|
||||||
|
)
|
||||||
|
} catch (err) { /* no git no worries */ }
|
||||||
|
|
||||||
// All done. Show tips
|
// All done. Show tips
|
||||||
showTips(config, choices)
|
showTips(config, choices)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue