create-next-rkk 2.0.3 → 2.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.
Files changed (2) hide show
  1. package/dist/index.js +25 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -77,9 +77,13 @@ function cleanupProjectDir(projectPath) {
77
77
  */
78
78
  function detectPackageManager() {
79
79
  for (const pm of ['pnpm', 'yarn']) {
80
- const result = (0, child_process_1.spawnSync)(pm, ['--version'], { encoding: 'utf8', shell: true });
81
- if (result.status === 0)
80
+ try {
81
+ (0, child_process_1.execSync)(`${pm} --version`, { stdio: 'ignore' });
82
82
  return pm;
83
+ }
84
+ catch {
85
+ // not available
86
+ }
83
87
  }
84
88
  return 'npm';
85
89
  }
@@ -155,7 +159,7 @@ function buildInstallCommand(pm) {
155
159
  program
156
160
  .name('create-next-rkk')
157
161
  .description('Create a new Next.js app with rkk-next pre-configured')
158
- .version('2.0.3')
162
+ .version('2.1.0')
159
163
  .argument('[project-name]', 'name of your project')
160
164
  .action(async (projectName) => {
161
165
  console.log(chalk_1.default.bold.cyan('\nšŸš€ Create RKK Next.js App\n'));
@@ -198,6 +202,24 @@ program
198
202
  }
199
203
  const pm = detectPackageManager();
200
204
  const projectPath = path.join(process.cwd(), targetDir);
205
+ // ── Directory conflict check ─────────────────────────────────────────────
206
+ if (fs.existsSync(projectPath)) {
207
+ const { overwrite } = await inquirer_1.default.prompt([
208
+ {
209
+ type: 'confirm',
210
+ name: 'overwrite',
211
+ message: chalk_1.default.yellow(`Directory "${targetDir}" already exists. Delete it and start fresh?`),
212
+ default: false,
213
+ },
214
+ ]);
215
+ if (!overwrite) {
216
+ console.log(chalk_1.default.red('\nAborted. Choose a different project name or remove the directory.\n'));
217
+ process.exit(0);
218
+ }
219
+ // Remove the existing directory before scaffolding
220
+ fs.rmSync(projectPath, { recursive: true, force: true });
221
+ console.log(chalk_1.default.gray(` Removed existing "${targetDir}" directory.\n`));
222
+ }
201
223
  let createdProject = false;
202
224
  let activeStep = null;
203
225
  const spinner = (0, ora_1.default)('Creating Next.js application...').start();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-next-rkk",
3
- "version": "2.0.3",
3
+ "version": "2.1.0",
4
4
  "description": "CLI tool to create Next.js apps with rkk-next pre-configured",
5
5
  "author": "Rohit Kumar Kundu",
6
6
  "license": "MIT",