@heyo-sh/create-heyo-docs 0.1.0 → 0.1.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/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@heyo-sh/create-heyo-docs",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Create a standalone Heyo Docs documentation project.",
5
5
  "homepage": "https://heyo.sh",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "git+https://github.com/heyo/heyo-docs.git"
8
+ "url": "git+https://github.com/heyo-sh/heyo-docs.git"
9
9
  },
10
10
  "bugs": {
11
- "url": "https://github.com/heyo/heyo-docs/issues"
11
+ "url": "https://github.com/heyo-sh/heyo-docs/issues"
12
12
  },
13
13
  "license": "MIT",
14
14
  "type": "module",
@@ -21,7 +21,7 @@ Every component below is available without an import. The examples show every vi
21
21
 
22
22
  <Button
23
23
  align="right"
24
- href="https://github.com/heyo/heyo-docs"
24
+ href="https://github.com/heyo-sh/heyo-docs"
25
25
  target="_blank"
26
26
  variant="ghost"
27
27
  size="xs"
@@ -262,7 +262,7 @@ export function CompactExample() {
262
262
 
263
263
  <GitHub href="https://github.com/react/react" variant="inset" />
264
264
 
265
- <GitHub href="https://github.com/heyo/heyo-docs" />
265
+ <GitHub href="https://github.com/heyo-sh/heyo-docs" />
266
266
 
267
267
  ## Steps
268
268
 
package/dist/index.d.ts DELETED
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env bun
2
- import type { CreateOptions } from "./types";
3
- export { detectPackageManager, packageManagerField, packageManagerRunCommand, } from "./package-manager";
4
- export { scaffoldProject } from "./scaffold";
5
- export { mergePackageJson, replacePlaceholders } from "./utils";
6
- export type * from "./types";
7
- export declare function run(argv?: string[]): Promise<void>;
8
- export declare function parseArguments(argv: string[]): {
9
- options: CreateOptions;
10
- interactive: boolean;
11
- showHelp: boolean;
12
- };
13
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAChE,mBAAmB,SAAS,CAAC;AA2C7B,wBAAsB,GAAG,CAAC,IAAI,WAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBrE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG;IAC9C,OAAO,EAAE,aAAa,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAsDA"}
package/dist/index.js DELETED
@@ -1,328 +0,0 @@
1
- #!/usr/bin/env bun
2
- // @bun
3
-
4
- // src/index.ts
5
- import * as p from "@clack/prompts";
6
-
7
- // src/package-manager.ts
8
- var FALLBACK_VERSIONS = {
9
- bun: "1.3.1",
10
- pnpm: "10.17.0",
11
- npm: "11.6.0",
12
- yarn: "4.9.4"
13
- };
14
- function detectPackageManager(userAgent = process.env.npm_config_user_agent ?? "") {
15
- const match = userAgent.match(/(?:^|\s)(bun|pnpm|npm|yarn)\/([^\s]+)/);
16
- if (!match)
17
- return { name: "bun", version: Bun.version };
18
- return { name: match[1], version: match[2] };
19
- }
20
- function packageManagerField(manager, detected = detectPackageManager()) {
21
- if (manager === detected.name && detected.version)
22
- return `${manager}@${detected.version}`;
23
- const executable = manager === "yarn" ? "yarn" : manager;
24
- try {
25
- const result = Bun.spawnSync([executable, "--version"]);
26
- const version = new TextDecoder().decode(result.stdout).trim();
27
- if (result.exitCode === 0 && /^\d+(?:\.\d+)+/.test(version))
28
- return `${manager}@${version}`;
29
- } catch {}
30
- return `${manager}@${FALLBACK_VERSIONS[manager]}`;
31
- }
32
- function packageManagerInstallCommand(manager) {
33
- return manager === "yarn" ? ["yarn"] : [manager, "install"];
34
- }
35
- function packageManagerRunCommand(manager, script) {
36
- if (manager === "npm")
37
- return `npm run ${script}`;
38
- if (manager === "yarn")
39
- return `yarn ${script}`;
40
- return `${manager} run ${script}`;
41
- }
42
-
43
- // src/project-name.ts
44
- var PROJECT_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/i;
45
- function projectNameError(value) {
46
- if (!value.trim())
47
- return "Enter a project name.";
48
- if (!PROJECT_NAME_PATTERN.test(value))
49
- return "Use letters, numbers and hyphens only.";
50
- }
51
- function assertProjectName(value) {
52
- const error = projectNameError(value);
53
- if (error)
54
- throw new Error(error);
55
- return value.trim();
56
- }
57
-
58
- // src/scaffold.ts
59
- import { existsSync } from "fs";
60
- import { mkdir as mkdir2, readdir as readdir2 } from "fs/promises";
61
- import { join as join2, resolve } from "path";
62
-
63
- // src/utils.ts
64
- import {
65
- cp,
66
- mkdir,
67
- readFile,
68
- readdir,
69
- rm,
70
- stat,
71
- writeFile
72
- } from "fs/promises";
73
- import { dirname, join } from "path";
74
- function replacePlaceholders(source, values) {
75
- return source.replace(/\{\{([A-Z0-9_]+)\}\}/g, (placeholder, key) => values[key] ?? placeholder);
76
- }
77
- function mergePackageJson(base, overlay) {
78
- const merged = { ...base };
79
- for (const [key, value] of Object.entries(overlay)) {
80
- const current = merged[key];
81
- if (isRecord(current) && isRecord(value))
82
- merged[key] = mergePackageJson(current, value);
83
- else
84
- merged[key] = value;
85
- }
86
- return merged;
87
- }
88
- async function copyTemplate(source, destination, placeholders) {
89
- await cp(source, destination, { recursive: true, force: true });
90
- await replacePlaceholdersAtPath(destination, placeholders);
91
- }
92
- async function replacePlaceholdersAtPath(path, values) {
93
- if (!(await stat(path)).isDirectory()) {
94
- const contents = await readFile(path, "utf8");
95
- await writeFile(path, replacePlaceholders(contents, values));
96
- return;
97
- }
98
- const entries = await readdir(path, { withFileTypes: true });
99
- await Promise.all(entries.map((entry) => replacePlaceholdersAtPath(join(path, entry.name), values)));
100
- }
101
- async function writeJson(path, data) {
102
- await mkdir(dirname(path), { recursive: true });
103
- await writeFile(path, `${JSON.stringify(data, null, 2)}
104
- `);
105
- }
106
- async function readJson(path) {
107
- return JSON.parse(await readFile(path, "utf8"));
108
- }
109
- function isRecord(value) {
110
- return typeof value === "object" && value !== null && !Array.isArray(value);
111
- }
112
-
113
- // src/scaffold.ts
114
- var packageRoot = resolve(import.meta.dirname, "..");
115
- async function scaffoldProject(options) {
116
- const cwd = options.cwd ?? process.cwd();
117
- const projectName = assertProjectName(options.projectName);
118
- const projectPath = resolve(cwd, projectName);
119
- if (existsSync(projectPath))
120
- throw new Error(`Directory already exists: ${projectPath}`);
121
- const placeholders = {
122
- PROJECT_NAME: projectName,
123
- HEYO_DOCS_VERSION: options.heyoDocsVersion ?? "0.1.0",
124
- PACKAGE_MANAGER: packageManagerField(options.packageManager),
125
- THEME: options.theme
126
- };
127
- const templatePath = join2(packageRoot, "templates", options.template);
128
- const deploymentPath = join2(packageRoot, "deployments", options.deployment, options.template);
129
- await mkdir2(projectPath, { recursive: true });
130
- await copyTemplate(templatePath, projectPath, placeholders);
131
- const basePackage = await readJson(join2(projectPath, "package.json"));
132
- const overlayPackage = options.deployment === "later" ? {} : await readJson(join2(deploymentPath, "package.json"));
133
- if (options.deployment !== "later") {
134
- await copyOverlay(deploymentPath, projectPath, placeholders);
135
- }
136
- await writeJson(join2(projectPath, "package.json"), mergePackageJson(basePackage, overlayPackage));
137
- if (options.install)
138
- await installDependencies(projectPath, options.packageManager);
139
- return { projectPath };
140
- }
141
- async function copyOverlay(source, destination, placeholders) {
142
- const entries = await readdir2(source, { withFileTypes: true });
143
- await Promise.all(entries.filter((entry) => entry.name !== "package.json").map(async (entry) => {
144
- const sourcePath = join2(source, entry.name);
145
- const destinationPath = join2(destination, entry.name);
146
- return copyTemplate(sourcePath, destinationPath, placeholders);
147
- }));
148
- }
149
- async function installDependencies(projectPath, packageManager) {
150
- const command = packageManagerInstallCommand(packageManager);
151
- const process2 = Bun.spawn(command, {
152
- cwd: projectPath,
153
- stdout: "inherit",
154
- stderr: "inherit"
155
- });
156
- if (await process2.exited !== 0)
157
- throw new Error(`Dependency installation failed with ${command.join(" ")}.`);
158
- }
159
-
160
- // src/index.ts
161
- var USAGE = "Usage: create-heyo-docs [project-name] [--template react-router|next|astro] [--deployment cloudflare|vercel|later] [--theme grain|shade|moss] [--package-manager bun|pnpm|npm|yarn] [--no-install]";
162
- var TEMPLATE_OPTIONS = [
163
- { value: "react-router", label: "React Router" },
164
- { value: "next", label: "Next.js" },
165
- { value: "astro", label: "Astro" }
166
- ];
167
- var DEPLOYMENT_OPTIONS = [
168
- { value: "cloudflare", label: "Cloudflare" },
169
- { value: "vercel", label: "Vercel" },
170
- { value: "later", label: "Configure later" }
171
- ];
172
- var THEME_OPTIONS = [
173
- { value: "grain", label: "Grain" },
174
- { value: "shade", label: "Shade" },
175
- { value: "moss", label: "Moss" },
176
- {
177
- value: "dripper",
178
- label: "Dripper \u2014 Soon",
179
- hint: "Unavailable in this MVP"
180
- },
181
- {
182
- value: "fixed-gear",
183
- label: "Fixed Gear \u2014 Soon",
184
- hint: "Unavailable in this MVP"
185
- }
186
- ];
187
- var PACKAGE_MANAGER_OPTIONS = [
188
- { value: "bun", label: "bun" },
189
- { value: "pnpm", label: "pnpm" },
190
- { value: "npm", label: "npm" },
191
- { value: "yarn", label: "yarn" }
192
- ];
193
- if (import.meta.main) {
194
- run(process.argv.slice(2)).catch((error) => {
195
- p.log.error(error instanceof Error ? error.message : String(error));
196
- process.exitCode = 1;
197
- });
198
- }
199
- async function run(argv = process.argv.slice(2)) {
200
- const parsed = parseArguments(argv);
201
- if (parsed.showHelp) {
202
- p.note(USAGE, "@heyo-sh/create-heyo-docs");
203
- return;
204
- }
205
- const options = parsed.interactive ? await askQuestions(parsed.options) : parsed.options;
206
- const spinner2 = p.spinner();
207
- spinner2.start("Creating your Heyo Docs project");
208
- try {
209
- await scaffoldProject(options);
210
- } catch (error) {
211
- spinner2.stop("Unable to create your documentation project");
212
- throw error;
213
- }
214
- spinner2.stop("Your documentation project is ready");
215
- const install = options.install ? "" : `
216
- ${options.packageManager} install`;
217
- p.note(`cd ${options.projectName}${install}
218
- ${packageManagerRunCommand(options.packageManager, "dev")}`, "Next steps");
219
- p.outro("Happy documenting.");
220
- }
221
- function parseArguments(argv) {
222
- const detected = detectPackageManager();
223
- const options = {
224
- projectName: "",
225
- template: "react-router",
226
- deployment: "later",
227
- theme: "grain",
228
- packageManager: detected.name,
229
- install: true
230
- };
231
- let explicit = false;
232
- let showHelp = false;
233
- for (let index = 0;index < argv.length; index += 1) {
234
- const value = argv[index];
235
- if (!value.startsWith("-")) {
236
- options.projectName ||= value;
237
- continue;
238
- }
239
- explicit = true;
240
- if (value === "--template") {
241
- options.template = readEnum(argv[++index], ["react-router", "next", "astro"], "template");
242
- } else if (value === "--deployment") {
243
- options.deployment = readEnum(argv[++index], ["cloudflare", "vercel", "later"], "deployment");
244
- } else if (value === "--theme") {
245
- options.theme = readEnum(argv[++index], ["grain", "shade", "moss"], "theme");
246
- } else if (value === "--package-manager") {
247
- options.packageManager = readEnum(argv[++index], ["bun", "pnpm", "npm", "yarn"], "package manager");
248
- } else if (value === "--no-install") {
249
- options.install = false;
250
- } else if (value === "--install") {
251
- options.install = true;
252
- } else if (value === "--help" || value === "-h") {
253
- showHelp = true;
254
- } else {
255
- throw new Error(`Unknown option: ${value}`);
256
- }
257
- }
258
- return { options, interactive: !explicit && !options.projectName, showHelp };
259
- }
260
- async function askQuestions(defaults) {
261
- p.intro("Create Heyo Docs");
262
- const projectName = await p.text({
263
- message: "Project name",
264
- placeholder: "my-docs",
265
- defaultValue: "my-docs",
266
- validate: projectNameError
267
- });
268
- if (p.isCancel(projectName))
269
- cancelCreation();
270
- const template = await selectAvailable("Template", TEMPLATE_OPTIONS, [
271
- "react-router",
272
- "next",
273
- "astro"
274
- ]);
275
- const deployment = await selectAvailable("Deployment", DEPLOYMENT_OPTIONS, ["cloudflare", "vercel", "later"], defaults.deployment);
276
- const theme = await selectAvailable("Theme", THEME_OPTIONS, [
277
- "grain",
278
- "shade",
279
- "moss"
280
- ]);
281
- const packageManager = await selectAvailable("Package manager", PACKAGE_MANAGER_OPTIONS, ["bun", "pnpm", "npm", "yarn"], defaults.packageManager);
282
- const install = await p.confirm({
283
- message: "Install dependencies?",
284
- initialValue: true
285
- });
286
- if (p.isCancel(install))
287
- cancelCreation();
288
- return {
289
- projectName,
290
- template,
291
- deployment,
292
- theme,
293
- packageManager,
294
- install
295
- };
296
- }
297
- async function selectAvailable(message, options, available, initialValue) {
298
- for (;; ) {
299
- const answer = await p.select({ message, options, initialValue });
300
- if (p.isCancel(answer))
301
- cancelCreation();
302
- if (isOneOf(answer, available))
303
- return answer;
304
- p.log.warn("That option is planned but not available in this MVP.");
305
- }
306
- }
307
- function isOneOf(value, values) {
308
- return values.some((candidate) => candidate === value);
309
- }
310
- function cancelCreation() {
311
- p.cancel("Creation cancelled.");
312
- process.exit(0);
313
- }
314
- function readEnum(value, allowed, label) {
315
- if (value && isOneOf(value, allowed))
316
- return value;
317
- throw new Error(`Use one of ${allowed.join(", ")} for ${label}.`);
318
- }
319
- export {
320
- scaffoldProject,
321
- run,
322
- replacePlaceholders,
323
- parseArguments,
324
- packageManagerRunCommand,
325
- packageManagerField,
326
- mergePackageJson,
327
- detectPackageManager
328
- };
@@ -1,6 +0,0 @@
1
- import type { DetectedPackageManager, PackageManager } from "./types";
2
- export declare function detectPackageManager(userAgent?: string): DetectedPackageManager;
3
- export declare function packageManagerField(manager: PackageManager, detected?: DetectedPackageManager): string;
4
- export declare function packageManagerInstallCommand(manager: PackageManager): string[];
5
- export declare function packageManagerRunCommand(manager: PackageManager, script: string): string;
6
- //# sourceMappingURL=package-manager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../src/package-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAStE,wBAAgB,oBAAoB,CAClC,SAAS,SAA0C,GAClD,sBAAsB,CAIxB;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,cAAc,EACvB,QAAQ,yBAAyB,GAChC,MAAM,CAaR;AAED,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,cAAc,GACtB,MAAM,EAAE,CAEV;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,MAAM,GACb,MAAM,CAIR"}
@@ -1,3 +0,0 @@
1
- export declare function projectNameError(value: string): string | undefined;
2
- export declare function assertProjectName(value: string): string;
3
- //# sourceMappingURL=project-name.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"project-name.d.ts","sourceRoot":"","sources":["../src/project-name.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIlE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIvD"}
@@ -1,5 +0,0 @@
1
- import type { CreateOptions } from "./types";
2
- export declare function scaffoldProject(options: CreateOptions): Promise<{
3
- projectPath: string;
4
- }>;
5
- //# sourceMappingURL=scaffold.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../src/scaffold.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAK7C,wBAAsB,eAAe,CACnC,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CA0ClC"}
package/dist/types.d.ts DELETED
@@ -1,19 +0,0 @@
1
- export type Template = "react-router" | "next" | "astro";
2
- export type Deployment = "cloudflare" | "vercel" | "later";
3
- export type Theme = "grain" | "shade" | "moss";
4
- export type PackageManager = "bun" | "pnpm" | "npm" | "yarn";
5
- export interface CreateOptions {
6
- projectName: string;
7
- template: Template;
8
- deployment: Deployment;
9
- theme: Theme;
10
- packageManager: PackageManager;
11
- install: boolean;
12
- cwd?: string;
13
- heyoDocsVersion?: string;
14
- }
15
- export interface DetectedPackageManager {
16
- name: PackageManager;
17
- version?: string;
18
- }
19
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;AACzD,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,QAAQ,GAAG,OAAO,CAAC;AAC3D,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAC/C,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;AAE7D,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC;IACb,cAAc,EAAE,cAAc,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
package/dist/utils.d.ts DELETED
@@ -1,8 +0,0 @@
1
- export declare function replacePlaceholders(source: string, values: Record<string, string>): string;
2
- export declare function mergePackageJson<T extends Record<string, unknown>>(base: T, overlay: Record<string, unknown>): T;
3
- export declare function copyTemplate(source: string, destination: string, placeholders: Record<string, string>): Promise<void>;
4
- export declare function replacePlaceholdersInDirectory(directory: string, values: Record<string, string>): Promise<void>;
5
- export declare function writeJson(path: string, data: unknown): Promise<void>;
6
- export declare function readJson<T>(path: string): Promise<T>;
7
- export declare function emptyDirectory(path: string): Promise<void>;
8
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAWA,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,MAAM,CAKR;AAED,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,CAAC,CASH;AAED,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACnC,OAAO,CAAC,IAAI,CAAC,CAGf;AAED,wBAAsB,8BAA8B,CAClD,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,OAAO,CAAC,IAAI,CAAC,CAOf;AAoBD,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAG1E;AAED,wBAAsB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAE1D;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhE"}