nextjs-starter-kit 0.1.8 → 0.1.9

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.js +46 -41
  2. package/package.json +29 -3
package/bin/cli.js CHANGED
@@ -12,30 +12,34 @@ const __dirname = path.dirname(__filename);
12
12
 
13
13
  function runCommand(command, options = {}) {
14
14
  try {
15
- execSync(command, { stdio: "inherit", ...options });
15
+ return execSync(command, {
16
+ stdio: "pipe",
17
+ encoding: "utf-8",
18
+ ...options,
19
+ }).trim();
16
20
  } catch {
17
- console.error(chalk.red(`❌ Failed to run: ${command}`));
18
- process.exit(1);
21
+ return null;
19
22
  }
20
23
  }
21
24
 
22
25
  async function main() {
23
- // Step 1: Ask for project name
24
- const { projectName } = await prompts({
25
- type: "text",
26
- name: "projectName",
27
- message: "What is your project named?",
28
- initial: "my-app",
29
- });
26
+ let projectName = process.argv[2];
27
+ if (!projectName) {
28
+ const response = await prompts({
29
+ type: "text",
30
+ name: "projectName",
31
+ message: "What is your project named?",
32
+ initial: "my-app",
33
+ });
34
+ projectName = response.projectName;
35
+ }
30
36
 
31
37
  const projectPath = path.resolve(process.cwd(), projectName);
32
-
33
- if (existsSync(projectPath)) {
38
+ if (projectName !== "." && existsSync(projectPath)) {
34
39
  console.error(chalk.red(`❌ Folder "${projectName}" already exists.`));
35
40
  process.exit(1);
36
41
  }
37
42
 
38
- // Step 2: Ask for package manager
39
43
  const { packageManager } = await prompts({
40
44
  type: "select",
41
45
  name: "packageManager",
@@ -49,43 +53,44 @@ async function main() {
49
53
  initial: 0,
50
54
  });
51
55
 
52
- // Step 3: Start spinner
53
- const spinner = ora(
54
- `Creating Next.js app in ${chalk.cyan(projectName)}...`
55
- ).start();
56
+ console.log(`\nCreating a new Next.js app in ${chalk.cyan(projectPath)}.\n`);
57
+ console.log(`Using ${chalk.cyan(packageManager)}.\n`);
58
+ console.log(`Initializing project with template: app-tw\n`);
56
59
 
57
- mkdirSync(projectPath);
58
-
59
- // Copy template files (keeps empty folders too)
60
+ if (projectName !== ".") mkdirSync(projectPath);
60
61
  const templateDir = path.join(__dirname, "../template");
61
62
  cpSync(templateDir, projectPath, { recursive: true });
62
63
 
63
- // Init git
64
- spinner.text = "Initializing Git repository...";
64
+ const spinner = ora("Initializing git repository...").start();
65
65
  runCommand("git init", { cwd: projectPath });
66
-
67
66
  spinner.stop();
67
+ console.log(chalk.green("Initialized a git repository.\n"));
68
68
 
69
- // Step 4: Install dependencies
69
+ console.log(chalk.cyan(`Installing dependencies...\n`));
70
+ try {
71
+ if (packageManager === "npm")
72
+ runCommand("npm install", { cwd: projectPath });
73
+ else if (packageManager === "pnpm")
74
+ runCommand("pnpm install", { cwd: projectPath });
75
+ else if (packageManager === "yarn")
76
+ runCommand("yarn install", { cwd: projectPath });
77
+ else if (packageManager === "bun")
78
+ runCommand("bun install", { cwd: projectPath });
79
+ } catch {
80
+ console.log(
81
+ chalk.yellow("\n⚠ Warning: Some build scripts were ignored.\n")
82
+ );
83
+ }
70
84
  console.log(
71
- chalk.cyan(`📦 Installing dependencies with ${packageManager}...`)
85
+ chalk.green(
86
+ `Done in ${chalk.cyan("~10s")} using ${chalk.cyan(packageManager)}.`
87
+ )
88
+ );
89
+ console.log(
90
+ chalk.green(
91
+ `\n✅ Success! Created ${projectName} at ${chalk.cyan(projectPath)}`
92
+ )
72
93
  );
73
-
74
- if (packageManager === "npm") {
75
- runCommand("npm install", { cwd: projectPath });
76
- } else if (packageManager === "pnpm") {
77
- runCommand("pnpm install", { cwd: projectPath });
78
- } else if (packageManager === "yarn") {
79
- runCommand("yarn install", { cwd: projectPath });
80
- } else if (packageManager === "bun") {
81
- runCommand("bun install", { cwd: projectPath });
82
- }
83
-
84
- // Step 5: Success
85
- console.log(chalk.green("\n✅ Success!"));
86
- console.log(`\nNext steps:\n`);
87
- console.log(` ${chalk.cyan("cd")} ${projectName}`);
88
- console.log(` ${chalk.cyan(`${packageManager} dev`)}\n`);
89
94
  }
90
95
 
91
96
  main();
package/package.json CHANGED
@@ -1,18 +1,44 @@
1
1
  {
2
2
  "name": "nextjs-starter-kit",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "bin": {
5
- "create-nextjs-starter": "bin/cli.js"
5
+ "create-nextjs-starter": "@/bin/cli.js"
6
6
  },
7
+ "keywords": [
8
+ "react",
9
+ "next",
10
+ "next.js"
11
+ ],
12
+ "description": "Create Next.js-powered React apps with one command",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/harshit-ostwal/nextjs-starter-kit.git"
16
+ },
17
+ "homepage": "https://github.com/harshit-ostwal/nextjs-starter-kit.git",
18
+ "author": "Harshit Ostwal <codewithharshitjain@gmail.com>",
7
19
  "type": "module",
20
+ "bugs": {
21
+ "url": "https://github.com/harshit-ostwal/nextjs-starter-kit.git"
22
+ },
23
+ "license": "MIT",
8
24
  "files": [
9
25
  "bin",
10
26
  "template"
11
27
  ],
12
28
  "dependencies": {
13
29
  "chalk": "^5.6.0",
30
+ "commander": "^14.0.0",
14
31
  "ora": "^8.2.0",
15
32
  "prompts": "^2.4.2",
16
33
  "readline": "^1.3.0"
34
+ },
35
+ "engines": {
36
+ "node": ">=18.17.0"
37
+ },
38
+ "nextBundleAnalysis": {
39
+ "budget": 358400,
40
+ "budgetPercentIncreaseRed": 20,
41
+ "minimumChangeThreshold": 0,
42
+ "showDetails": true
17
43
  }
18
- }
44
+ }