frontend-hamroun 1.0.3 → 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/bin/cli.js +6 -6
- package/package.json +1 -1
package/bin/cli.js
CHANGED
@@ -4,7 +4,7 @@ import { Command } from 'commander';
|
|
4
4
|
import { createRequire } from 'module';
|
5
5
|
import inquirer from 'inquirer';
|
6
6
|
import chalk from 'chalk';
|
7
|
-
import
|
7
|
+
import fsExtra from 'fs-extra';
|
8
8
|
import * as path from 'path';
|
9
9
|
import { createSpinner } from 'nanospinner';
|
10
10
|
import { fileURLToPath } from 'url';
|
@@ -32,7 +32,7 @@ async function createProject(projectName, options) {
|
|
32
32
|
const targetDir = path.join(process.cwd(), projectName);
|
33
33
|
|
34
34
|
// Check if directory exists
|
35
|
-
if (
|
35
|
+
if (fsExtra.existsSync(targetDir)) {
|
36
36
|
spinner.error({ text: 'Directory already exists!' });
|
37
37
|
process.exit(1);
|
38
38
|
}
|
@@ -41,19 +41,19 @@ async function createProject(projectName, options) {
|
|
41
41
|
const templatePath = path.join(__dirname, '../templates', options.template.toLowerCase());
|
42
42
|
|
43
43
|
// Ensure template exists
|
44
|
-
if (!
|
44
|
+
if (!fsExtra.existsSync(templatePath)) {
|
45
45
|
spinner.error({ text: 'Template not found!' });
|
46
46
|
process.exit(1);
|
47
47
|
}
|
48
48
|
|
49
49
|
// Copy template
|
50
|
-
await
|
50
|
+
await fsExtra.copy(templatePath, targetDir);
|
51
51
|
|
52
52
|
// Update package.json
|
53
53
|
const packageJsonPath = path.join(targetDir, 'package.json');
|
54
|
-
const packageJson = await
|
54
|
+
const packageJson = await fsExtra.readJson(packageJsonPath);
|
55
55
|
packageJson.name = projectName;
|
56
|
-
await
|
56
|
+
await fsExtra.writeJson(packageJsonPath, packageJson, { spaces: 2 });
|
57
57
|
|
58
58
|
spinner.success({ text: `Project ${chalk.green(projectName)} created successfully!` });
|
59
59
|
|