@ardly/bunext 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/cli.mjs +29 -5
  2. package/package.json +1 -1
package/bin/cli.mjs CHANGED
@@ -23,11 +23,35 @@ const args = process.argv.slice(2)
23
23
  const useVSCode = args.includes('--vs')
24
24
  const useCursor = args.includes('--cursor')
25
25
 
26
+ const validateRepoName = (name) => {
27
+ const validNameRegex = /^[a-z0-9-]+$/
28
+ return validNameRegex.test(name)
29
+ }
30
+
31
+ const promptForValidRepoName = (callback) => {
32
+ rl.question(
33
+ 'Please enter a name for your project (lowercase letters, numbers and hyphens only): ',
34
+ (answer) => {
35
+ if (validateRepoName(answer)) {
36
+ repoName = answer
37
+ callback()
38
+ } else {
39
+ console.error(
40
+ 'Invalid project name. Please use only lowercase letters, numbers and hyphens.'
41
+ )
42
+ promptForValidRepoName(callback)
43
+ }
44
+ }
45
+ )
46
+ }
47
+
26
48
  if (!repoName || repoName.startsWith('--')) {
27
- rl.question('Please enter a name for your project: ', (answer) => {
28
- repoName = answer
29
- initializeProject()
30
- })
49
+ promptForValidRepoName(initializeProject)
50
+ } else if (!validateRepoName(repoName)) {
51
+ console.error(
52
+ 'Invalid project name. Please use only lowercase letters, numbers and hyphens.'
53
+ )
54
+ promptForValidRepoName(initializeProject)
31
55
  } else {
32
56
  initializeProject()
33
57
  }
@@ -49,7 +73,7 @@ function initializeProject() {
49
73
  packageManager = 'bun'
50
74
  }
51
75
 
52
- const installDeps = `cd ${repoName} && ${packageManager} install`
76
+ const installDeps = `cd ${repoName} && ${packageManager}${packageManager === 'npm' ? ' install --legacy-peer-deps' : ' install'}`
53
77
 
54
78
  console.log(`Creating project template in ./${repoName}`)
55
79
  const checkedOut = runCommand(gitCheckout)
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@ardly/bunext",
3
3
  "description": "Bunext - A Next.js 15 template with Tailwind CSS, shadcn ui and Bun with some utilities built in",
4
4
  "author": "Ard Astroid <ardastroid@gmail.com>",
5
- "version": "1.0.4",
5
+ "version": "1.0.6",
6
6
  "bin": "./bin/cli.mjs",
7
7
  "keywords": [
8
8
  "next.js",