@docubook/create 1.4.0 → 1.4.1
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/create.js +41 -5
- package/package.json +1 -1
package/create.js
CHANGED
|
@@ -19,6 +19,29 @@ function checkNodeInstalled() {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
// Cek apakah Bun sudah terinstal
|
|
23
|
+
function checkBunInstalled() {
|
|
24
|
+
try {
|
|
25
|
+
execSync("bun --version", { stdio: "ignore" });
|
|
26
|
+
return true;
|
|
27
|
+
} catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Fungsi untuk mengganti nama file postcss
|
|
33
|
+
function updatePostcssConfig(projectPath) {
|
|
34
|
+
const oldConfigPath = path.join(projectPath, "postcss.config.js");
|
|
35
|
+
const newConfigPath = path.join(projectPath, "postcss.config.cjs");
|
|
36
|
+
|
|
37
|
+
if (fs.existsSync(oldConfigPath)) {
|
|
38
|
+
fs.renameSync(oldConfigPath, newConfigPath);
|
|
39
|
+
console.log(chalk.green("Renamed postcss.config.js to postcss.config.cjs for Bun compatibility."));
|
|
40
|
+
} else {
|
|
41
|
+
console.log(chalk.yellow("No postcss.config.js file found. Skipping rename."));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
22
45
|
async function promptInstallNode() {
|
|
23
46
|
const { installNode } = await inquirer.prompt([
|
|
24
47
|
{
|
|
@@ -44,7 +67,7 @@ async function promptInstallNode() {
|
|
|
44
67
|
}
|
|
45
68
|
|
|
46
69
|
program
|
|
47
|
-
.version("1.4.
|
|
70
|
+
.version("1.4.1")
|
|
48
71
|
.description("CLI to create a new Docubook project")
|
|
49
72
|
.argument("[project-directory]", "Directory to create the new Docubook project")
|
|
50
73
|
.action(async (projectDirectory) => {
|
|
@@ -73,6 +96,16 @@ program
|
|
|
73
96
|
await emitter.clone(projectPath);
|
|
74
97
|
spinner.succeed(`Docubook project successfully created in ${projectPath}!`);
|
|
75
98
|
|
|
99
|
+
updatePostcssConfig(projectPath);
|
|
100
|
+
|
|
101
|
+
if (checkBunInstalled()) {
|
|
102
|
+
console.log(chalk.green("\nBun detected. Installing dependencies with Bun..."));
|
|
103
|
+
execSync("bun install", { cwd: projectPath, stdio: "inherit" });
|
|
104
|
+
} else {
|
|
105
|
+
console.log(chalk.yellow("\nBun not found. Using npm for installation..."));
|
|
106
|
+
execSync("npm install", { cwd: projectPath, stdio: "inherit" });
|
|
107
|
+
}
|
|
108
|
+
|
|
76
109
|
const packageJsonPath = path.join(projectPath, "package.json");
|
|
77
110
|
if (fs.existsSync(packageJsonPath)) {
|
|
78
111
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
@@ -82,10 +115,13 @@ program
|
|
|
82
115
|
console.log(chalk.magenta("\nNext steps:"));
|
|
83
116
|
console.log(`1. Navigate to your project directory:`);
|
|
84
117
|
console.log(` cd ${projectDirectory}`);
|
|
85
|
-
console.log(`2.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
118
|
+
console.log(`2. Start the development server:`);
|
|
119
|
+
|
|
120
|
+
if (checkBunInstalled()) {
|
|
121
|
+
console.log(` bun run dev`);
|
|
122
|
+
} else {
|
|
123
|
+
console.log(` npm run dev`);
|
|
124
|
+
}
|
|
89
125
|
|
|
90
126
|
process.exit(0);
|
|
91
127
|
} catch (err) {
|