Skip to content

Commit

Permalink
Merge pull request #4 from bdbch/feature/2-user-flow
Browse files Browse the repository at this point in the history
Add better user flow after project creation
  • Loading branch information
bdbch committed Feb 26, 2023
2 parents 6c7b246 + 3bbe11f commit 3ee19b7
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { copyProjectTemplate } from './lib/copyProjectTemplate.js'
import { createProjectDir } from './lib/createProjectDir.js'
import { initializeGit } from './lib/initalizeGit.js'
import { renameGitignore } from './lib/renameGitignore.js'
import { showCLIOutput } from './lib/showCLIOutput.js'
import { updatePackageJson } from './lib/updatePackageJson.js'
import { updateReadme } from './lib/updateReadme.js'

Expand Down Expand Up @@ -78,12 +79,24 @@ async function init() {

console.log(chalk.green('Copied project template.'))

console.log('\n\nUpdating package.json...')

updatePackageJson(relativeDirPath, projectName, projectPackage)

console.log(chalk.green('Updated package.json.'))

console.log('\n\nUpdating README.md...')

updateReadme(relativeDirPath, projectName, projectPackage)

console.log(chalk.green('Updated README.md.'))

console.log('\n\nRenaming .gitignore...')

renameGitignore(relativeDirPath)

console.log(chalk.green('Renamed .gitignore.'))

const { shouldInitializeGit } = await prompts({
type: 'confirm',
name: 'shouldInitializeGit',
Expand All @@ -97,6 +110,7 @@ async function init() {
console.log(chalk.green('Initialized git repository.'))
}

showCLIOutput(relativeDirPath)
} catch (e: any) {
console.log(e)
return
Expand Down
15 changes: 14 additions & 1 deletion src/lib/initalizeGit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,21 @@ export const initializeGit = async (dir: string) => {
resolve(true)
}
})
})

if (!gitExists) {
return
}

console.log(gitExists)
// initialize git
await new Promise((resolve, reject) => {
exec("git init", { cwd: dir }, (error) => {
if (error) {
reject(error)
} else {
resolve(true)
}
})
})
} catch (e) {
console.error(e)
Expand Down
1 change: 0 additions & 1 deletion src/lib/renameGitignore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import path from 'path'
export const renameGitignore = (projectPath: string) => {
const resolvedPath = path.resolve(process.cwd(), projectPath)

console.log('Renaming .gitignore...', resolvedPath)
fs.renameSync( `${resolvedPath}/_gitignore`, `${resolvedPath}/.gitignore`)

return projectPath
Expand Down
8 changes: 8 additions & 0 deletions src/lib/showCLIOutput.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import chalk from "chalk"

export const showCLIOutput = (outputPath: string) => {
console.log('\n')
console.log(chalk.bgGreen('Your Tiptap extension has been created.'))
console.log(`cd ${outputPath}`)
console.log(`npm install\n\n`)
}

0 comments on commit 3ee19b7

Please sign in to comment.