@docubook/create 1.7.0 → 1.7.5
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/README.md +0 -31
- package/create.js +104 -44
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -37,35 +37,4 @@ Next steps:
|
|
|
37
37
|
npm run dev
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
## Update
|
|
41
|
-
### How to Update DocuBook?
|
|
42
|
-
- **Open a New Terminal**: Please open a new terminal on the desktop that has DocuBook installed.
|
|
43
|
-
- **Move Directory**: for example, if the directory name is docubook, then write `cd docubook` and press enter.
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
npx @docubook/update@latest
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
#### command output
|
|
50
|
-
|
|
51
|
-
```bash
|
|
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:
|
|
64
|
-
1. Verify your changes in the current directory.
|
|
65
|
-
2. Run the install script to check for package updates:
|
|
66
|
-
npm install
|
|
67
|
-
3. Run the development server:
|
|
68
|
-
npm run dev
|
|
69
|
-
```
|
|
70
|
-
|
|
71
40
|
Access the app on => http://localhost:3000
|
package/create.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { program } from "commander";
|
|
4
|
-
// import degit from "degit";
|
|
5
4
|
import path from "path";
|
|
6
5
|
import fs from "fs";
|
|
7
6
|
import ora from "ora";
|
|
8
7
|
import chalk from "chalk";
|
|
9
8
|
import inquirer from "inquirer";
|
|
9
|
+
import boxen from "boxen";
|
|
10
|
+
import figlet from "figlet";
|
|
11
|
+
import cliProgress from "cli-progress";
|
|
10
12
|
import { execSync } from "child_process";
|
|
11
13
|
|
|
12
14
|
// Cek apakah Node.js sudah terinstal
|
|
@@ -33,7 +35,6 @@ function checkBunInstalled() {
|
|
|
33
35
|
function updatePostcssConfig(projectPath) {
|
|
34
36
|
const oldConfigPath = path.join(projectPath, "postcss.config.js");
|
|
35
37
|
const newConfigPath = path.join(projectPath, "postcss.config.cjs");
|
|
36
|
-
|
|
37
38
|
if (fs.existsSync(oldConfigPath)) {
|
|
38
39
|
fs.renameSync(oldConfigPath, newConfigPath);
|
|
39
40
|
console.log(chalk.yellow("Renamed postcss.config.js to postcss.config.cjs for Bun compatibility."));
|
|
@@ -42,79 +43,138 @@ function updatePostcssConfig(projectPath) {
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
|
|
46
|
+
// Menampilkan ASCII Art untuk branding
|
|
47
|
+
function displayAsciiArt() {
|
|
48
|
+
console.log(
|
|
49
|
+
chalk.green(
|
|
50
|
+
figlet.textSync("DocuBook", {
|
|
51
|
+
horizontalLayout: "full",
|
|
52
|
+
})
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Menampilkan kotak pesan selamat datang
|
|
58
|
+
function displayWelcomeMessage() {
|
|
59
|
+
const welcomeMessage = boxen("DocuBook CLI Installer!", {
|
|
60
|
+
padding: 1,
|
|
61
|
+
margin: 1,
|
|
62
|
+
borderStyle: "round",
|
|
63
|
+
borderColor: "green",
|
|
64
|
+
});
|
|
65
|
+
console.log(welcomeMessage);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Simulasi progress bar untuk instalasi
|
|
69
|
+
async function simulateInstallation() {
|
|
70
|
+
const progressBar = new cliProgress.SingleBar(
|
|
71
|
+
{
|
|
72
|
+
format: 'Installation |' + chalk.green('{bar}') + '| {percentage}% || {value}/{total}',
|
|
73
|
+
barCompleteChar: '\u2588',
|
|
74
|
+
barIncompleteChar: '\u2591',
|
|
75
|
+
},
|
|
76
|
+
cliProgress.Presets.shades_classic
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
progressBar.start(100, 0);
|
|
80
|
+
|
|
81
|
+
for (let i = 0; i <= 100; i++) {
|
|
82
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
83
|
+
progressBar.update(i);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
progressBar.stop();
|
|
87
|
+
}
|
|
88
|
+
|
|
45
89
|
program
|
|
46
|
-
.version("1.7.
|
|
90
|
+
.version("1.7.5")
|
|
47
91
|
.description("CLI to create a new Docubook project")
|
|
48
92
|
.argument("[project-directory]", "Directory to create the new Docubook project")
|
|
49
93
|
.action(async (projectDirectory) => {
|
|
94
|
+
displayAsciiArt();
|
|
95
|
+
displayWelcomeMessage();
|
|
96
|
+
|
|
50
97
|
if (!projectDirectory) {
|
|
51
98
|
const { directoryName } = await inquirer.prompt([
|
|
52
99
|
{
|
|
53
100
|
type: "input",
|
|
54
101
|
name: "directoryName",
|
|
55
|
-
message: "Enter
|
|
102
|
+
message: "Enter your project directory name:",
|
|
56
103
|
default: "docubook",
|
|
57
104
|
},
|
|
58
105
|
]);
|
|
59
106
|
projectDirectory = directoryName;
|
|
60
107
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// --- clone from gitlab ---
|
|
108
|
+
|
|
109
|
+
const { packageManager } = await inquirer.prompt([
|
|
110
|
+
{
|
|
111
|
+
type: "list",
|
|
112
|
+
name: "packageManager",
|
|
113
|
+
message: "Choose a package manager:",
|
|
114
|
+
choices: ["npm", "pnpm", "yarn", "bun"],
|
|
115
|
+
default: "npm",
|
|
116
|
+
},
|
|
117
|
+
]);
|
|
118
|
+
// --- cloning from gitlab ---
|
|
73
119
|
const repo = "https://gitlab.com/mywildancloud/docubook.git";
|
|
74
120
|
const branch = "starter";
|
|
75
121
|
const projectPath = path.resolve(process.cwd(), projectDirectory);
|
|
76
122
|
const cloneCommand = `git clone --branch ${branch} ${repo} ${projectPath}`;
|
|
77
|
-
|
|
78
123
|
const spinner = ora(`Cloning ${chalk.yellow(branch)} from GitLab...`).start();
|
|
124
|
+
|
|
79
125
|
try {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// --- clone from gitlab ---
|
|
126
|
+
execSync(cloneCommand, { stdio: "inherit" });
|
|
127
|
+
spinner.succeed(`Docubook project successfully created in ${projectPath}!`);
|
|
83
128
|
|
|
84
|
-
// Jalankan rename hanya jika Bun terdeteksi
|
|
85
129
|
if (checkBunInstalled()) {
|
|
86
130
|
updatePostcssConfig(projectPath);
|
|
87
131
|
} else {
|
|
88
|
-
console.log(chalk.yellow("Skipping postcss.config.js
|
|
132
|
+
console.log(chalk.yellow("Skipping rename postcss.config.js because Bun is not installed."));
|
|
89
133
|
}
|
|
90
134
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
135
|
+
// Baca versi Docubook dari package.json
|
|
136
|
+
const packageJsonPath = path.join(projectPath, "package.json");
|
|
137
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
138
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
139
|
+
const versionMessage = boxen(
|
|
140
|
+
chalk.yellow("DocuBook Version") + "\n\n" + chalk.white(`v${packageJson.version}`),
|
|
141
|
+
{
|
|
142
|
+
padding: 1,
|
|
143
|
+
margin: 1,
|
|
144
|
+
borderStyle: "round",
|
|
145
|
+
borderColor: "yellow",
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
console.log(versionMessage);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
console.log(chalk.yellow("\nStarting the installation process..."));
|
|
152
|
+
await simulateInstallation();
|
|
153
|
+
|
|
154
|
+
try {
|
|
155
|
+
execSync(`${packageManager} install`, { cwd: projectPath, stdio: "inherit" });
|
|
156
|
+
console.log(chalk.green(`Dependencies installed successfully using ${packageManager}!`));
|
|
157
|
+
} catch (err) {
|
|
158
|
+
console.error(chalk.red(`Failed to install dependencies using ${packageManager}.`));
|
|
95
159
|
}
|
|
96
160
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
console.log(` ${chalk.green("bun run dev")}`);
|
|
111
|
-
} else {
|
|
112
|
-
console.log(` ${chalk.green("npm run dev or pnpm run dev or yarn dev")}`);
|
|
113
|
-
}
|
|
161
|
+
const nextStepsMessage = boxen(
|
|
162
|
+
`Next Steps:\n\n` +
|
|
163
|
+
`1. Navigate to your project directory:\n ${chalk.green(`cd ${projectDirectory}`)}\n\n` +
|
|
164
|
+
`2. Install dependencies (if not installed automatically):\n ${chalk.green(`${packageManager} install`)}\n\n` +
|
|
165
|
+
`3. Start the development server:\n ${chalk.green(`${packageManager} run dev`)}`,
|
|
166
|
+
{
|
|
167
|
+
padding: 1,
|
|
168
|
+
margin: 1,
|
|
169
|
+
borderStyle: "round",
|
|
170
|
+
borderColor: "blue",
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
console.log(nextStepsMessage);
|
|
114
174
|
|
|
115
175
|
process.exit(0);
|
|
116
176
|
} catch (err) {
|
|
117
|
-
spinner.fail("
|
|
177
|
+
spinner.fail("Failed to create project:");
|
|
118
178
|
console.error(err.message);
|
|
119
179
|
process.exit(1);
|
|
120
180
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docubook/create",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.5",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -15,9 +15,12 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"description": "CLI to create DocuBook projects",
|
|
17
17
|
"dependencies": {
|
|
18
|
+
"boxen": "^8.0.1",
|
|
18
19
|
"chalk": "^5.3.0",
|
|
20
|
+
"cli-progress": "^3.12.0",
|
|
19
21
|
"commander": "^12.1.0",
|
|
20
22
|
"degit": "^2.8.4",
|
|
23
|
+
"figlet": "^1.8.0",
|
|
21
24
|
"inquirer": "^11.0.2",
|
|
22
25
|
"ora": "^8.1.0"
|
|
23
26
|
}
|