create-jsc-vite-react-ts 1.0.1 → 1.1.0

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/bin/cli.js CHANGED
@@ -1,113 +1,121 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { execSync } from 'child_process'
4
- import fs from 'fs-extra'
5
- import path from 'path'
6
- import { fileURLToPath } from 'url'
7
- import prompts from 'prompts'
8
- import chalk from 'chalk'
3
+ import { execSync } from "child_process";
4
+ import fs from "fs-extra";
5
+ import path from "path";
6
+ import { fileURLToPath } from "url";
7
+ import prompts from "prompts";
8
+ import chalk from "chalk";
9
9
 
10
- const __filename = fileURLToPath(import.meta.url)
11
- const __dirname = path.dirname(__filename)
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = path.dirname(__filename);
12
12
 
13
13
  const run = async () => {
14
- console.log(chalk.bold.cyan('\nšŸš€ Create React + TypeScript + Vite App\n'))
14
+ console.log(chalk.bold.cyan("\nšŸš€ Create React + TypeScript + Vite App\n"));
15
15
 
16
- const args = process.argv.slice(2)
17
- let projectName = args[0]
16
+ const args = process.argv.slice(2);
17
+ let projectName = args[0];
18
18
 
19
19
  if (!projectName) {
20
20
  const response = await prompts({
21
- type: 'text',
22
- name: 'projectName',
23
- message: 'What is your project named?',
24
- initial: 'my-app',
21
+ type: "text",
22
+ name: "projectName",
23
+ message: "What is your project named?",
24
+ initial: "my-app",
25
25
  validate: (value) => {
26
- if (!value) return 'Project name is required'
26
+ if (!value) return "Project name is required";
27
27
  if (!/^[a-z0-9-_]+$/.test(value)) {
28
- return 'Project name can only contain lowercase letters, numbers, hyphens, and underscores'
28
+ return "Project name can only contain lowercase letters, numbers, hyphens, and underscores";
29
29
  }
30
- return true
30
+ return true;
31
31
  },
32
- })
32
+ });
33
33
 
34
34
  if (!response.projectName) {
35
- console.log(chalk.red('\nāœ– Project creation cancelled\n'))
36
- process.exit(1)
35
+ console.log(chalk.red("\nāœ– Project creation cancelled\n"));
36
+ process.exit(1);
37
37
  }
38
38
 
39
- projectName = response.projectName
39
+ projectName = response.projectName;
40
40
  }
41
41
 
42
- const targetDir = path.resolve(process.cwd(), projectName)
42
+ const targetDir = path.resolve(process.cwd(), projectName);
43
43
 
44
44
  if (fs.existsSync(targetDir)) {
45
- console.log(chalk.red(`\nāœ– Directory ${projectName} already exists\n`))
46
- process.exit(1)
45
+ console.log(chalk.red(`\nāœ– Directory ${projectName} already exists\n`));
46
+ process.exit(1);
47
47
  }
48
48
 
49
- console.log(chalk.blue(`\nšŸ“ Creating project in ${targetDir}...\n`))
49
+ console.log(chalk.blue(`\nšŸ“ Creating project in ${targetDir}...\n`));
50
50
 
51
- const templateDir = path.resolve(__dirname, '../template')
51
+ const templateDir = path.resolve(__dirname, "../template");
52
52
  fs.copySync(templateDir, targetDir, {
53
53
  filter: (src) => {
54
- const basename = path.basename(src)
55
- return !['node_modules', 'dist', 'coverage', '.claude', 'plan.md', 'CLAUDE.md', 'yarn.lock'].includes(basename)
54
+ const basename = path.basename(src);
55
+ return !["node_modules", "dist", "coverage", "yarn.lock"].includes(
56
+ basename
57
+ );
56
58
  },
57
- })
59
+ });
58
60
 
59
- const packageJsonPath = path.join(targetDir, 'package.json')
60
- const packageJson = fs.readJsonSync(packageJsonPath)
61
- packageJson.name = projectName
62
- fs.writeJsonSync(packageJsonPath, packageJson, { spaces: 2 })
61
+ const packageJsonPath = path.join(targetDir, "package.json");
62
+ const packageJson = fs.readJsonSync(packageJsonPath);
63
+ packageJson.name = projectName;
64
+ fs.writeJsonSync(packageJsonPath, packageJson, { spaces: 2 });
63
65
 
64
- console.log(chalk.green('āœ“ Project files created'))
66
+ console.log(chalk.green("āœ“ Project files created"));
65
67
 
66
- const packageManager = await detectPackageManager()
68
+ const packageManager = await detectPackageManager();
67
69
 
68
- console.log(chalk.blue(`\nšŸ“¦ Installing dependencies with ${packageManager}...\n`))
70
+ console.log(
71
+ chalk.blue(`\nšŸ“¦ Installing dependencies with ${packageManager}...\n`)
72
+ );
69
73
 
70
74
  try {
71
75
  execSync(`${packageManager} install`, {
72
76
  cwd: targetDir,
73
- stdio: 'inherit',
74
- })
75
- console.log(chalk.green('\nāœ“ Dependencies installed'))
77
+ stdio: "inherit",
78
+ });
79
+ console.log(chalk.green("\nāœ“ Dependencies installed"));
76
80
  } catch (error) {
77
- console.log(chalk.yellow('\n⚠ Failed to install dependencies automatically'))
78
- console.log(chalk.yellow(` Please run "${packageManager} install" manually\n`))
81
+ console.log(
82
+ chalk.yellow("\n⚠ Failed to install dependencies automatically")
83
+ );
84
+ console.log(
85
+ chalk.yellow(` Please run "${packageManager} install" manually\n`)
86
+ );
79
87
  }
80
88
 
81
- console.log(chalk.bold.green('\n✨ Success! Your project is ready.\n'))
82
- console.log(chalk.bold('Next steps:\n'))
83
- console.log(chalk.cyan(` cd ${projectName}`))
84
- console.log(chalk.cyan(` ${packageManager} dev`))
85
- console.log()
86
- }
89
+ console.log(chalk.bold.green("\n✨ Success! Your project is ready.\n"));
90
+ console.log(chalk.bold("Next steps:\n"));
91
+ console.log(chalk.cyan(` cd ${projectName}`));
92
+ console.log(chalk.cyan(` ${packageManager} dev`));
93
+ console.log();
94
+ };
87
95
 
88
96
  const detectPackageManager = async () => {
89
- const userAgent = process.env.npm_config_user_agent || ''
97
+ const userAgent = process.env.npm_config_user_agent || "";
90
98
 
91
- if (userAgent.startsWith('yarn')) return 'yarn'
92
- if (userAgent.startsWith('pnpm')) return 'pnpm'
99
+ if (userAgent.startsWith("yarn")) return "yarn";
100
+ if (userAgent.startsWith("pnpm")) return "pnpm";
93
101
 
94
102
  const response = await prompts({
95
- type: 'select',
96
- name: 'packageManager',
97
- message: 'Which package manager do you want to use?',
103
+ type: "select",
104
+ name: "packageManager",
105
+ message: "Which package manager do you want to use?",
98
106
  choices: [
99
- { title: 'npm', value: 'npm' },
100
- { title: 'yarn', value: 'yarn' },
101
- { title: 'pnpm', value: 'pnpm' },
107
+ { title: "npm", value: "npm" },
108
+ { title: "yarn", value: "yarn" },
109
+ { title: "pnpm", value: "pnpm" },
102
110
  ],
103
111
  initial: 0,
104
- })
112
+ });
105
113
 
106
- return response.packageManager || 'npm'
107
- }
114
+ return response.packageManager || "npm";
115
+ };
108
116
 
109
117
  run().catch((error) => {
110
- console.error(chalk.red('\nāœ– An error occurred:\n'))
111
- console.error(error)
112
- process.exit(1)
113
- })
118
+ console.error(chalk.red("\nāœ– An error occurred:\n"));
119
+ console.error(error);
120
+ process.exit(1);
121
+ });
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "create-jsc-vite-react-ts",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Create a modern React app with TypeScript, Vite, Tailwind CSS, and Vitest",
5
5
  "type": "module",
6
6
  "bin": {
7
- "create-create-jsc-vite-react-ts": "./bin/cli.js"
7
+ "create-jsc-vite-react-ts": "./bin/cli.js"
8
8
  },
9
9
  "files": [
10
10
  "bin",
@@ -0,0 +1,7 @@
1
+ {
2
+ "semi": false,
3
+ "trailingComma": "all",
4
+ "singleQuote": true,
5
+ "printWidth": 80,
6
+ "plugins": ["prettier-plugin-organize-imports"]
7
+ }
@@ -10,7 +10,8 @@
10
10
  "preview": "vite preview",
11
11
  "test": "vitest",
12
12
  "test:ui": "vitest --ui",
13
- "test:coverage": "vitest --coverage"
13
+ "test:coverage": "vitest --coverage",
14
+ "format": "prettier --write ."
14
15
  },
15
16
  "dependencies": {
16
17
  "react": "^19.2.0",
@@ -34,6 +35,8 @@
34
35
  "eslint-plugin-react-refresh": "^0.4.24",
35
36
  "globals": "^16.5.0",
36
37
  "jsdom": "^27.3.0",
38
+ "prettier": "^3.7.4",
39
+ "prettier-plugin-organize-imports": "^4.3.0",
37
40
  "tailwindcss": "^4.0.0",
38
41
  "typescript": "~5.9.3",
39
42
  "typescript-eslint": "^8.46.4",