vite-shadcn-ui-cli 1.0.2 β†’ 1.0.4

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.
package/README.md CHANGED
@@ -8,14 +8,15 @@ You can install the CLI globally using npm:
8
8
 
9
9
  ```sh
10
10
  npm install -g vite-shadcn-ui-cli
11
- vite-shadcn-ui my-project
11
+ create-vite-shadcn-ui my-project
12
12
  ```
13
13
 
14
14
  ## Example:
15
15
 
16
16
  ```sh
17
- vite-shadcn-ui my-app
17
+ create-vite-shadcn-ui my-app
18
18
  cd my-app
19
+ npm install
19
20
  npm run dev
20
21
  ```
21
22
 
package/index.cjs ADDED
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+ const { execSync } = require('child_process');
3
+ const { Command } = require('commander');
4
+ const simpleGit = require('simple-git');
5
+
6
+ const chalk = require('chalk');
7
+ const ora = require('ora');
8
+ const path = require('path');
9
+ const fs = require('fs');
10
+ const { version } = require('./package.json');
11
+
12
+ const program = new Command();
13
+ const git = simpleGit();
14
+
15
+ program
16
+ .name('create-vite-shadcn-ui')
17
+ .description('Bootstrap a Vite project with shadcn UI components')
18
+ .version(version);
19
+
20
+ program
21
+ .argument('<project-directory>', 'Directory to create your new project')
22
+ .action((projectDirectory) => {
23
+ const repoUrl = 'https://github.com/kyrie668/vite-shadcn-ui.git';
24
+ const projectPath = path.resolve(process.cwd(), projectDirectory);
25
+
26
+ console.log(`\nπŸ“¦ Cloning project into ${projectDirectory}...\n`);
27
+
28
+ // ε…‹ιš†δ»“εΊ“
29
+ execSync(`git clone ${repoUrl} ${projectDirectory}`, { stdio: 'inherit' });
30
+
31
+ // εˆ ι™€ .git ζ–‡δ»Άε€Ή
32
+ const gitPath = path.join(projectPath, '.git');
33
+ if (fs.existsSync(gitPath)) {
34
+ fs.rmSync(gitPath, { recursive: true, force: true });
35
+ }
36
+
37
+ console.log(`\nπŸŽ‰ Project setup complete!`);
38
+ console.log(`\nNext steps:\n`);
39
+ console.log(` cd ${projectDirectory}`);
40
+ console.log(` npm install`);
41
+ console.log(` npm run dev`);
42
+ console.log(`\nTo initialize a new Git repository:\n`);
43
+ console.log(` git init`);
44
+ console.log(` git remote add origin <your-repo-url>`);
45
+ console.log(` git add .`);
46
+ console.log(` git commit -m "Initial commit"`);
47
+ console.log(` git push -u origin main\n`);
48
+ });
49
+
50
+ program.parse();
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "vite-shadcn-ui-cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "A CLI tool to bootstrap Vite projects with shadcn UI components",
5
- "type": "module",
6
- "main": "index.js",
5
+ "main": "index.cjs",
7
6
  "bin": {
8
- "vite-shadcn-ui": "./index.js"
7
+ "create-vite-shadcn-ui": "./index.cjs"
9
8
  },
10
9
  "scripts": {
11
10
  "dev": "vite",
@@ -24,7 +23,8 @@
24
23
  "tailwindcss-animate": "^1.0.7",
25
24
  "simple-git": "^3.8.0",
26
25
  "chalk": "^4.1.2",
27
- "ora": "^6.0.0"
26
+ "ora": "^6.0.0",
27
+ "commander": "^11.0.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@eslint/js": "^9.17.0",
package/index.js DELETED
@@ -1,45 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { Command } = require('commander');
4
- const simpleGit = require('simple-git');
5
- const chalk = require('chalk');
6
- const ora = require('ora');
7
- const path = require('path');
8
- const fs = require('fs');
9
-
10
- const program = new Command();
11
- const git = simpleGit();
12
-
13
- program
14
- .name('vite-shadcn-ui')
15
- .description('Bootstrap a Vite project with shadcn UI components')
16
- .version('1.0.0');
17
-
18
- program
19
- .argument('<project-directory>', 'Directory to create your new project')
20
- .action(async (dir) => {
21
- const repoUrl = 'https://github.com/kyrie668/vite-shadcn-ui.git';
22
- const projectPath = path.resolve(process.cwd(), dir);
23
-
24
- if (fs.existsSync(projectPath)) {
25
- console.log(chalk.red(`Error: Directory "${dir}" already exists.`));
26
- process.exit(1);
27
- }
28
-
29
- const spinner = ora(`Cloning ${repoUrl} into ${dir}`).start();
30
-
31
- try {
32
- await git.clone(repoUrl, projectPath);
33
- spinner.succeed(`Project cloned successfully into ${dir}`);
34
-
35
- console.log(chalk.green(`\nNext steps:`));
36
- console.log(` cd ${dir}`);
37
- console.log(` npm install`);
38
- console.log(` npm run dev\n`);
39
- } catch (error) {
40
- spinner.fail('Failed to clone the repository.');
41
- console.error(chalk.red(error));
42
- }
43
- });
44
-
45
- program.parse();