create-jsc-vite-react-ts 1.0.2 → 1.2.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,131 @@
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
+ });
60
+
61
+ // Make files fromthe "scripts" folder executable
62
+ const scriptsDir = path.join(targetDir, "scripts");
63
+ if (fs.existsSync(scriptsDir)) {
64
+ const scriptFiles = fs.readdirSync(scriptsDir);
65
+ scriptFiles.forEach((file) => {
66
+ const filePath = path.join(scriptsDir, file);
67
+ fs.chmodSync(filePath, 0o755);
68
+ });
69
+ }
58
70
 
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 })
71
+ const packageJsonPath = path.join(targetDir, "package.json");
72
+ const packageJson = fs.readJsonSync(packageJsonPath);
73
+ packageJson.name = projectName;
74
+ fs.writeJsonSync(packageJsonPath, packageJson, { spaces: 2 });
63
75
 
64
- console.log(chalk.green('āœ“ Project files created'))
76
+ console.log(chalk.green("āœ“ Project files created"));
65
77
 
66
- const packageManager = await detectPackageManager()
78
+ const packageManager = await detectPackageManager();
67
79
 
68
- console.log(chalk.blue(`\nšŸ“¦ Installing dependencies with ${packageManager}...\n`))
80
+ console.log(
81
+ chalk.blue(`\nšŸ“¦ Installing dependencies with ${packageManager}...\n`),
82
+ );
69
83
 
70
84
  try {
71
85
  execSync(`${packageManager} install`, {
72
86
  cwd: targetDir,
73
- stdio: 'inherit',
74
- })
75
- console.log(chalk.green('\nāœ“ Dependencies installed'))
87
+ stdio: "inherit",
88
+ });
89
+ console.log(chalk.green("\nāœ“ Dependencies installed"));
76
90
  } catch (error) {
77
- console.log(chalk.yellow('\n⚠ Failed to install dependencies automatically'))
78
- console.log(chalk.yellow(` Please run "${packageManager} install" manually\n`))
91
+ console.log(
92
+ chalk.yellow("\n⚠ Failed to install dependencies automatically"),
93
+ );
94
+ console.log(
95
+ chalk.yellow(` Please run "${packageManager} install" manually\n`),
96
+ );
79
97
  }
80
98
 
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
- }
99
+ console.log(chalk.bold.green("\n✨ Success! Your project is ready.\n"));
100
+ console.log(chalk.bold("Next steps:\n"));
101
+ console.log(chalk.cyan(` cd ${projectName}`));
102
+ console.log(chalk.cyan(` ${packageManager} dev`));
103
+ console.log();
104
+ };
87
105
 
88
106
  const detectPackageManager = async () => {
89
- const userAgent = process.env.npm_config_user_agent || ''
107
+ const userAgent = process.env.npm_config_user_agent || "";
90
108
 
91
- if (userAgent.startsWith('yarn')) return 'yarn'
92
- if (userAgent.startsWith('pnpm')) return 'pnpm'
109
+ if (userAgent.startsWith("yarn")) return "yarn";
110
+ if (userAgent.startsWith("pnpm")) return "pnpm";
93
111
 
94
112
  const response = await prompts({
95
- type: 'select',
96
- name: 'packageManager',
97
- message: 'Which package manager do you want to use?',
113
+ type: "select",
114
+ name: "packageManager",
115
+ message: "Which package manager do you want to use?",
98
116
  choices: [
99
- { title: 'npm', value: 'npm' },
100
- { title: 'yarn', value: 'yarn' },
101
- { title: 'pnpm', value: 'pnpm' },
117
+ { title: "npm", value: "npm" },
118
+ { title: "yarn", value: "yarn" },
119
+ { title: "pnpm", value: "pnpm" },
102
120
  ],
103
121
  initial: 0,
104
- })
122
+ });
105
123
 
106
- return response.packageManager || 'npm'
107
- }
124
+ return response.packageManager || "npm";
125
+ };
108
126
 
109
127
  run().catch((error) => {
110
- console.error(chalk.red('\nāœ– An error occurred:\n'))
111
- console.error(error)
112
- process.exit(1)
113
- })
128
+ console.error(chalk.red("\nāœ– An error occurred:\n"));
129
+ console.error(error);
130
+ process.exit(1);
131
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-jsc-vite-react-ts",
3
- "version": "1.0.2",
3
+ "version": "1.2.0",
4
4
  "description": "Create a modern React app with TypeScript, Vite, Tailwind CSS, and Vitest",
5
5
  "type": "module",
6
6
  "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,11 @@
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 .",
15
+ "update-version": "./update-version.sh",
16
+ "create-tag": "./create-tag.sh",
17
+ "full-tag": "yarn update-version && yarn create-tag"
14
18
  },
15
19
  "dependencies": {
16
20
  "react": "^19.2.0",
@@ -34,6 +38,8 @@
34
38
  "eslint-plugin-react-refresh": "^0.4.24",
35
39
  "globals": "^16.5.0",
36
40
  "jsdom": "^27.3.0",
41
+ "prettier": "^3.7.4",
42
+ "prettier-plugin-organize-imports": "^4.3.0",
37
43
  "tailwindcss": "^4.0.0",
38
44
  "typescript": "~5.9.3",
39
45
  "typescript-eslint": "^8.46.4",
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+ echo "šŸ·ļø Creating new git tag"
3
+
4
+ . "$(dirname "$0")/get-tag.sh"
5
+ git tag "v$NEW_TAG"
6
+ echo "šŸ”– New tag created: v$NEW_TAG"
7
+ git push origin
8
+ git push origin "v$NEW_TAG"
9
+ echo "šŸš€ Tag creation completed."
@@ -0,0 +1,17 @@
1
+ #!/bin/bash
2
+
3
+ # Get the latest git tag that starts with 'v'
4
+ LATEST_TAG=$(git tag -l --sort=version:refname | grep "^v" | tail -1)
5
+
6
+ # Increment the patch version of the latest tag
7
+ if [ -z "$LATEST_TAG" ]; then
8
+ NEW_TAG="0.0.1"
9
+ else
10
+ MAJOR=$(echo "$LATEST_TAG" | sed 's/^v//' | awk -F"." '{print $1}')
11
+ MINOR=$(echo "$LATEST_TAG" | sed 's/^v//' | awk -F"." '{print $2}')
12
+ PATCH=$(echo "$LATEST_TAG" | sed 's/^v//' | awk -F"." '{print $3}')
13
+ PATCH=$((PATCH + 1))
14
+ NEW_TAG="$MAJOR.$MINOR.$PATCH"
15
+ fi
16
+
17
+ export NEW_TAG
@@ -0,0 +1,24 @@
1
+ # !/bin/bash
2
+
3
+ echo "šŸš€ Updating version"
4
+
5
+ . "$(dirname "$0")/get-tag.sh"
6
+
7
+ # Echo the new tag version
8
+ echo "šŸ†• New tag version will be: $NEW_TAG"
9
+
10
+ # Update the version field in package.json
11
+ PACKAGE_JSON_PATH="package.json"
12
+ if [ -f "$PACKAGE_JSON_PATH" ]; then
13
+ # Use jq to update the version field
14
+ jq --arg new_version "$NEW_TAG" '.version = $new_version' "$PACKAGE_JSON_PATH" > "${PACKAGE_JSON_PATH}.tmp" && mv "${PACKAGE_JSON_PATH}.tmp" "$PACKAGE_JSON_PATH"
15
+ echo "šŸ“¦ Updated package.json version to $NEW_TAG"
16
+ fi
17
+
18
+ git add "$PACKAGE_JSON_PATH"
19
+ git commit -m "chore: bump version to $NEW_TAG"
20
+
21
+ # Echo a message indicating the pre-push hook is running with emoji
22
+ echo "šŸš€ Version updated."
23
+
24
+ exit 0