@docubook/create 1.7.0 → 1.8.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 +2 -34
- package/create.js +150 -67
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
> **Note**: This application is a fork of [AriaDocs](https://github.com/nisabmohd/Aria-Docs), created by [Nisab Mohd](https://github.com/nisabmohd). DocuBook provides an alternative to the documentation solution found on [Mintlify](https://mintlify.com/), utilizing `.mdx` (Markdown + JSX) for content creation and management.
|
|
6
6
|
|
|
7
|
-
[](https://vercel.com/import/project?template=https://github.com/gitfromwildan/docubook)
|
|
8
9
|
|
|
9
10
|
## Features
|
|
10
11
|
|
|
@@ -36,36 +37,3 @@ Next steps:
|
|
|
36
37
|
3. Start the development server:
|
|
37
38
|
npm run dev
|
|
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
|
-
Access the app on => http://localhost:3000
|
package/create.js
CHANGED
|
@@ -1,121 +1,204 @@
|
|
|
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
|
-
//
|
|
13
|
-
|
|
14
|
+
// Logging util
|
|
15
|
+
const log = {
|
|
16
|
+
info: (msg) => console.log(chalk.cyan("ℹ️ " + msg)),
|
|
17
|
+
success: (msg) => console.log(chalk.green("✔ " + msg)),
|
|
18
|
+
warn: (msg) => console.log(chalk.yellow("⚠️ " + msg)),
|
|
19
|
+
error: (msg) => console.log(chalk.red("✖ " + msg)),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Cek CLI dependency
|
|
23
|
+
function checkInstalled(command) {
|
|
14
24
|
try {
|
|
15
|
-
execSync(
|
|
25
|
+
execSync(`${command} --version`, { stdio: "ignore" });
|
|
16
26
|
return true;
|
|
17
27
|
} catch {
|
|
18
28
|
return false;
|
|
19
29
|
}
|
|
20
30
|
}
|
|
21
31
|
|
|
22
|
-
//
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
// Rename postcss.config.js → .cjs (untuk Bun)
|
|
33
|
+
function updatePostcssConfig(projectPath) {
|
|
34
|
+
const oldPath = path.join(projectPath, "postcss.config.js");
|
|
35
|
+
const newPath = path.join(projectPath, "postcss.config.cjs");
|
|
36
|
+
if (fs.existsSync(oldPath)) {
|
|
37
|
+
fs.renameSync(oldPath, newPath);
|
|
38
|
+
log.info("Renamed postcss.config.js → .cjs for bun compatibility");
|
|
29
39
|
}
|
|
30
40
|
}
|
|
31
41
|
|
|
32
|
-
//
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
+
// Tampilan awal
|
|
43
|
+
function displayAsciiArt() {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
figlet.text("DocuBook", { horizontalLayout: "full" }, (err, data) => {
|
|
46
|
+
if (err) return reject(err);
|
|
47
|
+
console.log(chalk.green(data));
|
|
48
|
+
resolve();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function displayWelcomeMessage() {
|
|
54
|
+
console.log(chalk.white("DocuBook Installer"));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Simulasi progress bar setup
|
|
58
|
+
async function simulateInstallation() {
|
|
59
|
+
const bar = new cliProgress.SingleBar(
|
|
60
|
+
{
|
|
61
|
+
format: 'Finishing Setup |' + chalk.green('{bar}') + '| {percentage}% || {value}/{total}',
|
|
62
|
+
barCompleteChar: '\u2588',
|
|
63
|
+
barIncompleteChar: '\u2591',
|
|
64
|
+
},
|
|
65
|
+
cliProgress.Presets.shades_classic
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
bar.start(100, 0);
|
|
69
|
+
for (let i = 0; i <= 100; i++) {
|
|
70
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
71
|
+
bar.update(i);
|
|
42
72
|
}
|
|
73
|
+
bar.stop();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function manualSteps(projectDirectory, packageManager) {
|
|
77
|
+
const manualInstructions = `
|
|
78
|
+
You chose not to continue with the installation.
|
|
79
|
+
Please follow these steps manually to finish setting up your project:
|
|
80
|
+
|
|
81
|
+
1. ${chalk.cyan(`cd ${projectDirectory}`)}
|
|
82
|
+
2. ${chalk.cyan(`${packageManager} install`)}
|
|
83
|
+
3. ${chalk.cyan(`${packageManager} run dev`)}
|
|
84
|
+
`;
|
|
85
|
+
|
|
86
|
+
console.log(
|
|
87
|
+
boxen(manualInstructions, {
|
|
88
|
+
padding: 1,
|
|
89
|
+
borderStyle: "round",
|
|
90
|
+
borderColor: "cyan",
|
|
91
|
+
})
|
|
92
|
+
);
|
|
43
93
|
}
|
|
44
94
|
|
|
45
95
|
program
|
|
46
|
-
.version("1.
|
|
96
|
+
.version("1.8.5")
|
|
47
97
|
.description("CLI to create a new Docubook project")
|
|
48
98
|
.argument("[project-directory]", "Directory to create the new Docubook project")
|
|
49
99
|
.action(async (projectDirectory) => {
|
|
100
|
+
await displayAsciiArt();
|
|
101
|
+
displayWelcomeMessage();
|
|
102
|
+
|
|
50
103
|
if (!projectDirectory) {
|
|
51
104
|
const { directoryName } = await inquirer.prompt([
|
|
52
105
|
{
|
|
53
106
|
type: "input",
|
|
54
107
|
name: "directoryName",
|
|
55
|
-
message: "Enter
|
|
108
|
+
message: "Enter your project directory name:",
|
|
56
109
|
default: "docubook",
|
|
57
110
|
},
|
|
58
111
|
]);
|
|
59
112
|
projectDirectory = directoryName;
|
|
60
113
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
114
|
+
|
|
115
|
+
let { packageManager } = await inquirer.prompt([
|
|
116
|
+
{
|
|
117
|
+
type: "list",
|
|
118
|
+
name: "packageManager",
|
|
119
|
+
message: "Choose a package manager:",
|
|
120
|
+
choices: ["npm", "pnpm", "yarn", "bun"],
|
|
121
|
+
default: "npm",
|
|
122
|
+
},
|
|
123
|
+
]);
|
|
124
|
+
|
|
125
|
+
if (!checkInstalled(packageManager)) {
|
|
126
|
+
log.warn(`${packageManager} is not installed. Falling back to npm.`);
|
|
127
|
+
packageManager = "npm";
|
|
128
|
+
}
|
|
129
|
+
|
|
73
130
|
const repo = "https://gitlab.com/mywildancloud/docubook.git";
|
|
74
131
|
const branch = "starter";
|
|
75
132
|
const projectPath = path.resolve(process.cwd(), projectDirectory);
|
|
76
|
-
const cloneCommand = `git clone --branch ${branch} ${repo} ${projectPath}`;
|
|
133
|
+
const cloneCommand = `git clone --quiet --branch ${branch} ${repo} ${projectPath}`;
|
|
134
|
+
const spinner = ora("Cloning DocuBook starter...").start();
|
|
77
135
|
|
|
78
|
-
const spinner = ora(`Cloning ${chalk.yellow(branch)} from GitLab...`).start();
|
|
79
136
|
try {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
137
|
+
execSync(cloneCommand);
|
|
138
|
+
spinner.succeed(`Project created in ${projectDirectory}/`);
|
|
139
|
+
|
|
140
|
+
if (packageManager === "bun" && checkInstalled("bun")) {
|
|
141
|
+
updatePostcssConfig(projectPath);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const pkgPath = path.join(projectPath, "package.json");
|
|
145
|
+
if (fs.existsSync(pkgPath)) {
|
|
146
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
147
|
+
console.log(
|
|
148
|
+
chalk.green(
|
|
149
|
+
`=================\nDocuBook v${pkg.version}\n=================`
|
|
150
|
+
)
|
|
151
|
+
);
|
|
89
152
|
}
|
|
90
153
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
console.log(`2. Install dependencies:`);
|
|
154
|
+
// Tanya apakah pengguna ingin melanjutkan instalasi
|
|
155
|
+
const { continueInstallation } = await inquirer.prompt([
|
|
156
|
+
{
|
|
157
|
+
type: "confirm",
|
|
158
|
+
name: "continueInstallation",
|
|
159
|
+
message: "Do you want to continue with the installation of dependencies?",
|
|
160
|
+
default: true,
|
|
161
|
+
},
|
|
162
|
+
]);
|
|
101
163
|
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
console.log(` ${chalk.green("npm install or pnpm install or yarn install")}`);
|
|
164
|
+
if (!continueInstallation) {
|
|
165
|
+
manualSteps(projectDirectory, packageManager);
|
|
166
|
+
return;
|
|
106
167
|
}
|
|
107
|
-
console.log(`3. Start the development server:`);
|
|
108
168
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
169
|
+
log.info("Installing dependencies...");
|
|
170
|
+
console.log(chalk.yellow("This is a joke for you:"));
|
|
171
|
+
console.log(chalk.white("When you install the package manager, the installation speed depends on the device and hardware you have."));
|
|
172
|
+
const installSpinner = ora(`Using ${packageManager}...`).start();
|
|
173
|
+
|
|
174
|
+
try {
|
|
175
|
+
execSync(`${packageManager} install`, { cwd: projectPath, stdio: "ignore" });
|
|
176
|
+
installSpinner.succeed("Dependencies installed.");
|
|
177
|
+
} catch {
|
|
178
|
+
installSpinner.fail("Failed to install dependencies.");
|
|
179
|
+
process.exit(1);
|
|
113
180
|
}
|
|
114
181
|
|
|
182
|
+
await simulateInstallation();
|
|
183
|
+
|
|
184
|
+
console.log(
|
|
185
|
+
boxen(
|
|
186
|
+
`Next Steps:\n\n` +
|
|
187
|
+
`1. ${chalk.cyan(`cd ${projectDirectory}`)}\n` +
|
|
188
|
+
`2. ${chalk.cyan(`${packageManager} install (if not automatically installed)`)}\n` +
|
|
189
|
+
`3. ${chalk.cyan(`${packageManager} run dev`)}`,
|
|
190
|
+
{
|
|
191
|
+
padding: 1,
|
|
192
|
+
borderStyle: "round",
|
|
193
|
+
borderColor: "cyan",
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
);
|
|
197
|
+
|
|
115
198
|
process.exit(0);
|
|
116
199
|
} catch (err) {
|
|
117
|
-
spinner.fail("
|
|
118
|
-
|
|
200
|
+
spinner.fail("Failed to create project.");
|
|
201
|
+
log.error(err.message);
|
|
119
202
|
process.exit(1);
|
|
120
203
|
}
|
|
121
204
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docubook/create",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.5",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -15,10 +15,14 @@
|
|
|
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
|
+
},
|
|
27
|
+
"packageManager": "pnpm@10.10.0"
|
|
24
28
|
}
|