@docubook/create 1.9.0 → 1.11.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.
- package/README.md +1 -3
- package/package.json +7 -7
- package/src/cli/program.js +32 -0
- package/src/cli/promptHandler.js +73 -0
- package/src/dist/LICENSE +21 -0
- package/src/dist/README.md +37 -0
- package/src/dist/app/docs/[[...slug]]/page.tsx +105 -0
- package/src/dist/app/docs/layout.tsx +16 -0
- package/src/dist/app/error.tsx +44 -0
- package/src/dist/app/layout.tsx +96 -0
- package/src/dist/app/not-found.tsx +19 -0
- package/src/dist/app/page.tsx +96 -0
- package/src/dist/components/GithubStart.tsx +44 -0
- package/src/dist/components/Sponsor.tsx +69 -0
- package/src/dist/components/anchor.tsx +84 -0
- package/src/dist/components/contexts/theme-provider.tsx +9 -0
- package/src/dist/components/docs-breadcrumb.tsx +47 -0
- package/src/dist/components/docs-menu.tsx +45 -0
- package/src/dist/components/edit-on-github.tsx +33 -0
- package/src/dist/components/footer.tsx +85 -0
- package/src/dist/components/leftbar.tsx +95 -0
- package/src/dist/components/markdown/AccordionMdx.tsx +47 -0
- package/src/dist/components/markdown/ButtonMdx.tsx +52 -0
- package/src/dist/components/markdown/CardGroupMdx.tsx +28 -0
- package/src/dist/components/markdown/CardMdx.tsx +41 -0
- package/src/dist/components/markdown/CopyMdx.tsx +33 -0
- package/src/dist/components/markdown/ImageMdx.tsx +25 -0
- package/src/dist/components/markdown/KeyboardMdx.tsx +102 -0
- package/src/dist/components/markdown/LinkMdx.tsx +14 -0
- package/src/dist/components/markdown/NoteMdx.tsx +52 -0
- package/src/dist/components/markdown/OutletMdx.tsx +29 -0
- package/src/dist/components/markdown/PreMdx.tsx +19 -0
- package/src/dist/components/markdown/ReleaseMdx.tsx +109 -0
- package/src/dist/components/markdown/StepperMdx.tsx +41 -0
- package/src/dist/components/markdown/TooltipsMdx.tsx +28 -0
- package/src/dist/components/markdown/YoutubeMdx.tsx +22 -0
- package/src/dist/components/markdown/mdx-provider.tsx +29 -0
- package/src/dist/components/mob-toc.tsx +128 -0
- package/src/dist/components/navbar.tsx +87 -0
- package/src/dist/components/pagination.tsx +49 -0
- package/src/dist/components/scroll-to-top.tsx +86 -0
- package/src/dist/components/search.tsx +214 -0
- package/src/dist/components/sublink.tsx +133 -0
- package/src/dist/components/theme-toggle.tsx +71 -0
- package/src/dist/components/toc-observer.tsx +264 -0
- package/src/dist/components/toc.tsx +27 -0
- package/src/dist/components/typography.tsx +9 -0
- package/src/dist/components/ui/accordion.tsx +58 -0
- package/src/dist/components/ui/animated-shiny-text.tsx +40 -0
- package/src/dist/components/ui/aurora.tsx +45 -0
- package/src/dist/components/ui/avatar.tsx +50 -0
- package/src/dist/components/ui/badge.tsx +37 -0
- package/src/dist/components/ui/breadcrumb.tsx +115 -0
- package/src/dist/components/ui/button.tsx +57 -0
- package/src/dist/components/ui/card.tsx +76 -0
- package/src/dist/components/ui/collapsible.tsx +11 -0
- package/src/dist/components/ui/command.tsx +153 -0
- package/src/dist/components/ui/dialog.tsx +124 -0
- package/src/dist/components/ui/dropdown-menu.tsx +200 -0
- package/src/dist/components/ui/icon-cloud.tsx +324 -0
- package/src/dist/components/ui/input.tsx +25 -0
- package/src/dist/components/ui/interactive-hover-button.tsx +35 -0
- package/src/dist/components/ui/popover.tsx +33 -0
- package/src/dist/components/ui/scroll-area.tsx +48 -0
- package/src/dist/components/ui/separator.tsx +30 -0
- package/src/dist/components/ui/sheet.tsx +140 -0
- package/src/dist/components/ui/shine-border.tsx +64 -0
- package/src/dist/components/ui/skeleton.tsx +15 -0
- package/src/dist/components/ui/sonner.tsx +31 -0
- package/src/dist/components/ui/table.tsx +117 -0
- package/src/dist/components/ui/tabs.tsx +55 -0
- package/src/dist/components/ui/toggle-group.tsx +61 -0
- package/src/dist/components/ui/toggle.tsx +46 -0
- package/src/dist/components.json +17 -0
- package/src/dist/contents/docs/getting-started/changelog/index.mdx +512 -0
- package/src/dist/contents/docs/getting-started/components/accordion/index.mdx +72 -0
- package/src/dist/contents/docs/getting-started/components/button/index.mdx +42 -0
- package/src/dist/contents/docs/getting-started/components/card/index.mdx +70 -0
- package/src/dist/contents/docs/getting-started/components/card-group/index.mdx +49 -0
- package/src/dist/contents/docs/getting-started/components/code-block/index.mdx +41 -0
- package/src/dist/contents/docs/getting-started/components/custom/index.mdx +38 -0
- package/src/dist/contents/docs/getting-started/components/image/index.mdx +37 -0
- package/src/dist/contents/docs/getting-started/components/index.mdx +9 -0
- package/src/dist/contents/docs/getting-started/components/keyboard/index.mdx +117 -0
- package/src/dist/contents/docs/getting-started/components/link/index.mdx +34 -0
- package/src/dist/contents/docs/getting-started/components/note/index.mdx +46 -0
- package/src/dist/contents/docs/getting-started/components/release-note/index.mdx +130 -0
- package/src/dist/contents/docs/getting-started/components/stepper/index.mdx +47 -0
- package/src/dist/contents/docs/getting-started/components/tabs/index.mdx +70 -0
- package/src/dist/contents/docs/getting-started/components/tooltips/index.mdx +22 -0
- package/src/dist/contents/docs/getting-started/components/youtube/index.mdx +21 -0
- package/src/dist/contents/docs/getting-started/customize/index.mdx +94 -0
- package/src/dist/contents/docs/getting-started/installation/index.mdx +84 -0
- package/src/dist/contents/docs/getting-started/introduction/index.mdx +50 -0
- package/src/dist/contents/docs/getting-started/project-structure/index.mdx +87 -0
- package/src/dist/contents/docs/getting-started/quick-start-guide/index.mdx +127 -0
- package/src/dist/docu.json +100 -0
- package/src/dist/hooks/index.ts +2 -0
- package/src/dist/hooks/useActiveSection.ts +68 -0
- package/src/dist/hooks/useScrollPosition.ts +28 -0
- package/src/dist/lib/markdown.ts +244 -0
- package/src/dist/lib/routes-config.ts +28 -0
- package/src/dist/lib/toc.ts +9 -0
- package/src/dist/lib/utils.ts +80 -0
- package/src/dist/next-env.d.ts +5 -0
- package/src/dist/next.config.mjs +14 -0
- package/src/dist/package.json +58 -0
- package/src/dist/postcss.config.js +6 -0
- package/src/dist/public/favicon.ico +0 -0
- package/src/dist/public/images/docu.svg +6 -0
- package/src/dist/public/images/example-img.png +0 -0
- package/src/dist/public/images/img-playground.png +0 -0
- package/src/dist/public/images/new-editor.png +0 -0
- package/src/dist/public/images/og-image.png +0 -0
- package/src/dist/public/images/release-note.png +0 -0
- package/src/dist/public/images/snippet.png +0 -0
- package/src/dist/public/images/vercel.png +0 -0
- package/src/dist/public/images/view-changelog.png +0 -0
- package/src/dist/styles/editor.css +57 -0
- package/src/dist/styles/globals.css +156 -0
- package/src/dist/styles/syntax.css +100 -0
- package/src/dist/tailwind.config.ts +112 -0
- package/src/dist/tsconfig.json +26 -0
- package/src/index.js +19 -0
- package/src/installer/projectInstaller.js +125 -0
- package/src/utils/display.js +83 -0
- package/src/utils/logger.js +11 -0
- package/src/utils/packageManager.js +54 -0
- package/create.js +0 -223
package/create.js
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { program } from "commander";
|
|
4
|
-
import path from "path";
|
|
5
|
-
import fs from "fs";
|
|
6
|
-
import ora from "ora";
|
|
7
|
-
import chalk from "chalk";
|
|
8
|
-
import inquirer from "inquirer";
|
|
9
|
-
import boxen from "boxen";
|
|
10
|
-
import figlet from "figlet";
|
|
11
|
-
import cliProgress from "cli-progress";
|
|
12
|
-
import { execSync } from "child_process";
|
|
13
|
-
|
|
14
|
-
// Logging helper with styles
|
|
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 apakah package manager terinstal di sistem
|
|
23
|
-
function isInstalled(command) {
|
|
24
|
-
try {
|
|
25
|
-
execSync(`${command} --version`, { stdio: "ignore" });
|
|
26
|
-
return true;
|
|
27
|
-
} catch {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Ambil versi package manager
|
|
33
|
-
function getPackageManagerVersion(pm) {
|
|
34
|
-
try {
|
|
35
|
-
return execSync(`${pm} --version`).toString().trim();
|
|
36
|
-
} catch {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Rename file postcss.config.js → .cjs jika menggunakan bun
|
|
42
|
-
function updatePostcssConfig(projectPath) {
|
|
43
|
-
const oldPath = path.join(projectPath, "postcss.config.js");
|
|
44
|
-
const newPath = path.join(projectPath, "postcss.config.cjs");
|
|
45
|
-
if (fs.existsSync(oldPath)) {
|
|
46
|
-
fs.renameSync(oldPath, newPath);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Menampilkan ASCII art "DocuBook" saat CLI dijalankan
|
|
51
|
-
function displayAsciiArt() {
|
|
52
|
-
return new Promise((resolve, reject) => {
|
|
53
|
-
figlet.text("DocuBook", { horizontalLayout: "full" }, (err, data) => {
|
|
54
|
-
if (err) return reject(err);
|
|
55
|
-
console.log(chalk.green(data));
|
|
56
|
-
resolve();
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Menampilkan progress bar saat simulasi setup akhir
|
|
62
|
-
async function simulateInstallation() {
|
|
63
|
-
const bar = new cliProgress.SingleBar(
|
|
64
|
-
{
|
|
65
|
-
format: 'Finishing Setup |' + chalk.green('{bar}') + '| {percentage}% || {value}/{total}',
|
|
66
|
-
barCompleteChar: '\u2588',
|
|
67
|
-
barIncompleteChar: '\u2591',
|
|
68
|
-
},
|
|
69
|
-
cliProgress.Presets.shades_classic
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
bar.start(100, 0);
|
|
73
|
-
for (let i = 0; i <= 100; i++) {
|
|
74
|
-
await new Promise((r) => setTimeout(r, 50));
|
|
75
|
-
bar.update(i);
|
|
76
|
-
}
|
|
77
|
-
bar.stop();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Menampilkan langkah manual jika instalasi otomatis dibatalkan/gagal
|
|
81
|
-
function manualSteps(projectDirectory, packageManager) {
|
|
82
|
-
const manualInstructions = `
|
|
83
|
-
Please follow these steps manually to finish setting up your project:
|
|
84
|
-
|
|
85
|
-
1. ${chalk.cyan(`cd ${projectDirectory}`)}
|
|
86
|
-
2. ${chalk.cyan(`${packageManager} install`)}
|
|
87
|
-
3. ${chalk.cyan(`${packageManager} run dev`)}
|
|
88
|
-
`;
|
|
89
|
-
|
|
90
|
-
console.log(
|
|
91
|
-
boxen(manualInstructions, {
|
|
92
|
-
padding: 0.5,
|
|
93
|
-
borderStyle: "round",
|
|
94
|
-
borderColor: "cyan",
|
|
95
|
-
})
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// Mendeteksi default package manager dari environment user
|
|
100
|
-
function detectDefaultPackageManager() {
|
|
101
|
-
const userAgent = process.env.npm_config_user_agent || "";
|
|
102
|
-
if (userAgent.includes("pnpm")) return "pnpm";
|
|
103
|
-
if (userAgent.includes("yarn")) return "yarn";
|
|
104
|
-
if (userAgent.includes("bun")) return "bun";
|
|
105
|
-
return "npm";
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Entry point utama CLI
|
|
109
|
-
program
|
|
110
|
-
.version("1.9.0")
|
|
111
|
-
.description("CLI to create a new Docubook project")
|
|
112
|
-
.action(async () => {
|
|
113
|
-
await displayAsciiArt();
|
|
114
|
-
console.log(chalk.white("DocuBook Installer\n"));
|
|
115
|
-
|
|
116
|
-
// Multistep prompt: nama project, package manager, content source, dan pilihan install
|
|
117
|
-
const answers = await inquirer.prompt([
|
|
118
|
-
{
|
|
119
|
-
type: "input",
|
|
120
|
-
name: "directoryName",
|
|
121
|
-
message: "📁 Project name",
|
|
122
|
-
default: "docubook",
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
type: "list",
|
|
126
|
-
name: "packageManager",
|
|
127
|
-
message: "📦 Package manager",
|
|
128
|
-
choices: ["npm", "pnpm", "yarn", "bun"],
|
|
129
|
-
default: detectDefaultPackageManager(),
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
type: "confirm",
|
|
133
|
-
name: "installNow",
|
|
134
|
-
message: "🛠️ Install dependencies now?",
|
|
135
|
-
default: true,
|
|
136
|
-
},
|
|
137
|
-
]);
|
|
138
|
-
|
|
139
|
-
const { directoryName, packageManager, installNow } = answers;
|
|
140
|
-
const projectPath = path.resolve(process.cwd(), directoryName);
|
|
141
|
-
const version = getPackageManagerVersion(packageManager);
|
|
142
|
-
|
|
143
|
-
if (!version) {
|
|
144
|
-
log.error(`${packageManager} is not installed on your system.`);
|
|
145
|
-
process.exit(1);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const repo = "https://gitlab.com/mywildancloud/docubook.git";
|
|
149
|
-
const branch = "starter";
|
|
150
|
-
const cloneCommand = `git clone --quiet --branch ${branch} ${repo} ${projectPath}`;
|
|
151
|
-
const spinner = ora("Creating your DocuBook project...").start();
|
|
152
|
-
|
|
153
|
-
try {
|
|
154
|
-
execSync(cloneCommand);
|
|
155
|
-
|
|
156
|
-
// Rename config jika pakai bun
|
|
157
|
-
if (packageManager === "bun") updatePostcssConfig(projectPath);
|
|
158
|
-
|
|
159
|
-
// Update packageManager di package.json
|
|
160
|
-
const pkgPath = path.join(projectPath, "package.json");
|
|
161
|
-
let pkgVersion = "";
|
|
162
|
-
if (fs.existsSync(pkgPath)) {
|
|
163
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
164
|
-
pkg.packageManager = `${packageManager}@${version}`;
|
|
165
|
-
pkgVersion = pkg.version || "";
|
|
166
|
-
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
spinner.succeed();
|
|
170
|
-
log.success(`DocuBook v${pkgVersion} in \"${directoryName}\" using \"${packageManager}\"`);
|
|
171
|
-
|
|
172
|
-
if (!installNow) {
|
|
173
|
-
manualSteps(directoryName, packageManager);
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
log.info("Installing dependencies...");
|
|
178
|
-
console.log(chalk.yellow("This is a joke for you:"));
|
|
179
|
-
console.log(
|
|
180
|
-
chalk.white(
|
|
181
|
-
"When you install the package manager, the installation speed depends on the hardware you have."
|
|
182
|
-
)
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
const installSpinner = ora(`Using ${packageManager}...`).start();
|
|
186
|
-
|
|
187
|
-
if (packageManager === "yarn") {
|
|
188
|
-
const yarnrcPath = path.join(projectPath, ".yarnrc.yml");
|
|
189
|
-
fs.writeFileSync(yarnrcPath, "nodeLinker: node-modules\n");
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
try {
|
|
193
|
-
execSync(`${packageManager} install`, { cwd: projectPath, stdio: "ignore" });
|
|
194
|
-
installSpinner.succeed("Dependencies installed.");
|
|
195
|
-
} catch {
|
|
196
|
-
installSpinner.fail("Failed to install dependencies.");
|
|
197
|
-
manualSteps(directoryName, packageManager);
|
|
198
|
-
process.exit(1);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
await simulateInstallation();
|
|
202
|
-
|
|
203
|
-
// Tampilkan langkah selanjutnya setelah setup selesai
|
|
204
|
-
console.log(
|
|
205
|
-
boxen(
|
|
206
|
-
`Next Steps:\n\n` +
|
|
207
|
-
`1. ${chalk.cyan(`cd ${directoryName}`)}\n` +
|
|
208
|
-
`2. ${chalk.cyan(`${packageManager} run dev`)}`,
|
|
209
|
-
{
|
|
210
|
-
padding: 0.5,
|
|
211
|
-
borderStyle: "round",
|
|
212
|
-
borderColor: "cyan",
|
|
213
|
-
}
|
|
214
|
-
)
|
|
215
|
-
);
|
|
216
|
-
} catch (err) {
|
|
217
|
-
spinner.fail("Failed to create project.");
|
|
218
|
-
log.error(err.message);
|
|
219
|
-
process.exit(1);
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
program.parse(process.argv);
|