@docubook/create 1.4.0 → 1.4.2

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 (3) hide show
  1. package/README.md +17 -13
  2. package/create.js +47 -39
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -17,7 +17,7 @@
17
17
  ## Installation
18
18
 
19
19
  ```bash
20
- npx create_docu
20
+ npx @docubook/create@latest
21
21
  ```
22
22
 
23
23
  #### command output
@@ -41,26 +41,30 @@ Next steps:
41
41
  ### How to Update DocuBook?
42
42
  - **Open a New Terminal**: Please open a new terminal on the desktop that has DocuBook installed.
43
43
  - **Move Directory**: for example, if the directory name is docubook, then write `cd docubook` and press enter.
44
- - **npx update_docu**: run `npx update_docu` bash script.
45
44
 
46
45
  ```bash
47
- npx update_docu@latest
46
+ npx @docubook/update@latest
48
47
  ```
49
48
 
50
49
  #### command output
51
50
 
52
51
  ```bash
53
- Updating Docubook project in /path/your/docubook...
54
- ℹ Skipped public
55
- ℹ Skipped styles
56
- ℹ Skipped contents
57
- ℹ Skipped app/page.tsx
58
- ℹ Skipped app/hire-me
59
- Docubook project successfully updated in /path/your/docubook!
60
-
61
- Next steps:
52
+ 📂 Updating Docubook project in /Users/wildan/Public/docubook...
53
+
54
+ Skipped public
55
+ Skipped contents
56
+ Skipped app/page.tsx
57
+ Skipped docu.json
58
+ Skipped CHANGELOG.md
59
+ ✨ Replacing styles folder...
60
+ Replaced all CSS files in styles folder
61
+ ✔ ✅ Docubook v1.4.2 successfully updated in /Users/wildan/Public/docubook!
62
+
63
+ 🎯 Next steps:
62
64
  1. Verify your changes in the current directory.
63
- 2. Run the development server:
65
+ 2. Run the install script to check for package updates:
66
+ npm install
67
+ 3. Run the development server:
64
68
  npm run dev
65
69
  ```
66
70
 
package/create.js CHANGED
@@ -19,49 +19,44 @@ function checkNodeInstalled() {
19
19
  }
20
20
  }
21
21
 
22
- async function promptInstallNode() {
23
- const { installNode } = await inquirer.prompt([
24
- {
25
- type: "confirm",
26
- name: "installNode",
27
- message: "Node.js is not installed. Do you want to install it now?",
28
- default: true,
29
- },
30
- ]);
31
- if (installNode) {
32
- console.log(chalk.green("Installing Node.js..."));
33
- try {
34
- execSync("curl -fsSL https://install-node.vercel.app | bash", { stdio: "inherit" });
35
- console.log(chalk.green("Node.js installed successfully. Please rerun the command."));
36
- } catch (error) {
37
- console.error(chalk.red("Failed to install Node.js automatically. Please install it manually."));
38
- }
39
- process.exit(1);
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
40
  } else {
41
- console.log(chalk.yellow("Node.js is required to continue. Exiting."));
42
- process.exit(1);
41
+ console.log(chalk.yellow("No postcss.config.js file found. Skipping rename."));
43
42
  }
44
43
  }
45
44
 
46
45
  program
47
- .version("1.4.0")
48
- .description("CLI to create a new Docubook project")
49
- .argument("[project-directory]", "Directory to create the new Docubook project")
50
- .action(async (projectDirectory) => {
51
- if (!checkNodeInstalled()) {
52
- await promptInstallNode();
53
- }
54
-
46
+ .version("1.4.2")
47
+ .description("CLI to create a new Docubook project")
48
+ .argument("[project-directory]", "Directory to create the new Docubook project")
49
+ .action(async (projectDirectory) => {
55
50
  if (!projectDirectory) {
56
- const { directoryName } = await inquirer.prompt([
51
+ const { directoryName } = await inquirer.prompt([
57
52
  {
58
- type: "input",
59
- name: "directoryName",
60
- message: "Enter a name for your project directory:",
61
- default: "docubook",
53
+ type: "input",
54
+ name: "directoryName",
55
+ message: "Enter a name for your project directory:",
56
+ default: "docubook",
62
57
  },
63
- ]);
64
- projectDirectory = directoryName;
58
+ ]);
59
+ projectDirectory = directoryName;
65
60
  }
66
61
 
67
62
  const repo = "github:mywildancloud/docubook#starter";
@@ -73,6 +68,16 @@ program
73
68
  await emitter.clone(projectPath);
74
69
  spinner.succeed(`Docubook project successfully created in ${projectPath}!`);
75
70
 
71
+ updatePostcssConfig(projectPath);
72
+
73
+ if (checkBunInstalled()) {
74
+ console.log(chalk.green("\nBun detected. Installing dependencies with Bun..."));
75
+ execSync("bun install", { cwd: projectPath, stdio: "inherit" });
76
+ } else {
77
+ console.log(chalk.yellow("\nBun not found. Using npm for installation..."));
78
+ execSync("npm install", { cwd: projectPath, stdio: "inherit" });
79
+ }
80
+
76
81
  const packageJsonPath = path.join(projectPath, "package.json");
77
82
  if (fs.existsSync(packageJsonPath)) {
78
83
  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
@@ -82,10 +87,13 @@ program
82
87
  console.log(chalk.magenta("\nNext steps:"));
83
88
  console.log(`1. Navigate to your project directory:`);
84
89
  console.log(` cd ${projectDirectory}`);
85
- console.log(`2. Install dependencies:`);
86
- console.log(` npm install`);
87
- console.log(`3. Start the development server:`);
88
- console.log(` npm run dev`);
90
+ console.log(`2. Start the development server:`);
91
+
92
+ if (checkBunInstalled()) {
93
+ console.log(` bun run dev`);
94
+ } else {
95
+ console.log(` npm run dev`);
96
+ }
89
97
 
90
98
  process.exit(0);
91
99
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docubook/create",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "bin": {