@hanzo/docs-create-app 16.0.50
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/LICENSE +21 -0
- package/README.md +11 -0
- package/dist/auto-install-CenyMuK7.js +33 -0
- package/dist/auto-install-CenyMuK7.js.map +1 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +165 -0
- package/dist/bin.js.map +1 -0
- package/dist/constants-BkYWkLHa.d.ts +22 -0
- package/dist/constants-BkYWkLHa.d.ts.map +1 -0
- package/dist/constants-CbNzssp2.js +957 -0
- package/dist/constants-CbNzssp2.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/biome.base.d.ts +40 -0
- package/dist/plugins/biome.base.d.ts.map +1 -0
- package/dist/plugins/biome.base.js +38 -0
- package/dist/plugins/biome.base.js.map +1 -0
- package/dist/plugins/biome.d.ts +7 -0
- package/dist/plugins/biome.d.ts.map +1 -0
- package/dist/plugins/biome.js +33 -0
- package/dist/plugins/biome.js.map +1 -0
- package/dist/plugins/biome.next.d.ts +41 -0
- package/dist/plugins/biome.next.d.ts.map +1 -0
- package/dist/plugins/biome.next.js +44 -0
- package/dist/plugins/biome.next.js.map +1 -0
- package/dist/plugins/eslint.d.ts +7 -0
- package/dist/plugins/eslint.d.ts.map +1 -0
- package/dist/plugins/eslint.js +47 -0
- package/dist/plugins/eslint.js.map +1 -0
- package/dist/plugins/next-use-src.d.ts +10 -0
- package/dist/plugins/next-use-src.d.ts.map +1 -0
- package/dist/plugins/next-use-src.js +37 -0
- package/dist/plugins/next-use-src.js.map +1 -0
- package/dist/plugins/orama-cloud.d.ts +7 -0
- package/dist/plugins/orama-cloud.d.ts.map +1 -0
- package/dist/plugins/orama-cloud.js +296 -0
- package/dist/plugins/orama-cloud.js.map +1 -0
- package/package.json +63 -0
- package/template/+next+fuma-docs-mdx/app/(home)/layout.tsx +6 -0
- package/template/+next+fuma-docs-mdx/app/(home)/page.tsx +16 -0
- package/template/+next+fuma-docs-mdx/app/api/search/route.ts +7 -0
- package/template/+next+fuma-docs-mdx/app/docs/[[...slug]]/page.tsx +57 -0
- package/template/+next+fuma-docs-mdx/app/docs/layout.tsx +11 -0
- package/template/+next+fuma-docs-mdx/app/global.css +3 -0
- package/template/+next+fuma-docs-mdx/app/layout.tsx +17 -0
- package/template/+next+fuma-docs-mdx/app/llms-full.txt/route.ts +10 -0
- package/template/+next+fuma-docs-mdx/app/llms.mdx/docs/[[...slug]]/route.ts +20 -0
- package/template/+next+fuma-docs-mdx/app/llms.txt/route.ts +13 -0
- package/template/+next+fuma-docs-mdx/app/og/docs/[...slug]/route.tsx +27 -0
- package/template/+next+fuma-docs-mdx/components/ai/page-actions.tsx +240 -0
- package/template/+next+fuma-docs-mdx/content/docs/index.mdx +13 -0
- package/template/+next+fuma-docs-mdx/content/docs/test.mdx +17 -0
- package/template/+next+fuma-docs-mdx/example.gitignore +26 -0
- package/template/+next+fuma-docs-mdx/lib/cn.ts +1 -0
- package/template/+next+fuma-docs-mdx/lib/layout.shared.tsx +17 -0
- package/template/+next+fuma-docs-mdx/lib/source.ts +27 -0
- package/template/+next+fuma-docs-mdx/mdx-components.tsx +9 -0
- package/template/+next+fuma-docs-mdx/next.config.mjs +18 -0
- package/template/+next+fuma-docs-mdx/package.json +31 -0
- package/template/+next+fuma-docs-mdx/postcss.config.mjs +7 -0
- package/template/+next+fuma-docs-mdx/source.config.ts +23 -0
- package/template/+next+fuma-docs-mdx/tsconfig.json +36 -0
- package/template/+next+fuma-docs-mdx+static/README.md +45 -0
- package/template/+next+fuma-docs-mdx+static/app/(home)/layout.tsx +6 -0
- package/template/+next+fuma-docs-mdx+static/app/(home)/page.tsx +16 -0
- package/template/+next+fuma-docs-mdx+static/app/api/search/route.ts +9 -0
- package/template/+next+fuma-docs-mdx+static/app/docs/[[...slug]]/page.tsx +47 -0
- package/template/+next+fuma-docs-mdx+static/app/docs/layout.tsx +11 -0
- package/template/+next+fuma-docs-mdx+static/app/global.css +3 -0
- package/template/+next+fuma-docs-mdx+static/app/layout.tsx +17 -0
- package/template/+next+fuma-docs-mdx+static/app/llms-full.txt/route.ts +10 -0
- package/template/+next+fuma-docs-mdx+static/app/og/docs/[...slug]/route.tsx +27 -0
- package/template/+next+fuma-docs-mdx+static/components/provider.tsx +8 -0
- package/template/+next+fuma-docs-mdx+static/components/search.tsx +46 -0
- package/template/+next+fuma-docs-mdx+static/content/docs/index.mdx +13 -0
- package/template/+next+fuma-docs-mdx+static/content/docs/test.mdx +17 -0
- package/template/+next+fuma-docs-mdx+static/example.gitignore +26 -0
- package/template/+next+fuma-docs-mdx+static/lib/layout.shared.tsx +9 -0
- package/template/+next+fuma-docs-mdx+static/lib/source.ts +26 -0
- package/template/+next+fuma-docs-mdx+static/mdx-components.tsx +9 -0
- package/template/+next+fuma-docs-mdx+static/next.config.mjs +11 -0
- package/template/+next+fuma-docs-mdx+static/package.json +32 -0
- package/template/+next+fuma-docs-mdx+static/postcss.config.mjs +7 -0
- package/template/+next+fuma-docs-mdx+static/source.config.ts +23 -0
- package/template/+next+fuma-docs-mdx+static/tsconfig.json +36 -0
- package/template/+next+hanzo-docs-mdx/README.md +43 -0
- package/template/+next+hanzo-docs-mdx/app/(home)/layout.tsx +6 -0
- package/template/+next+hanzo-docs-mdx/app/(home)/page.tsx +16 -0
- package/template/+next+hanzo-docs-mdx/app/api/search/route.ts +7 -0
- package/template/+next+hanzo-docs-mdx/app/docs/[[...slug]]/page.tsx +61 -0
- package/template/+next+hanzo-docs-mdx/app/docs/layout.tsx +11 -0
- package/template/+next+hanzo-docs-mdx/app/global.css +3 -0
- package/template/+next+hanzo-docs-mdx/app/layout.tsx +17 -0
- package/template/+next+hanzo-docs-mdx/app/llms-full.txt/route.ts +10 -0
- package/template/+next+hanzo-docs-mdx/app/og/docs/[...slug]/route.tsx +27 -0
- package/template/+next+hanzo-docs-mdx/content/docs/index.mdx +13 -0
- package/template/+next+hanzo-docs-mdx/content/docs/test.mdx +17 -0
- package/template/+next+hanzo-docs-mdx/example.gitignore +26 -0
- package/template/+next+hanzo-docs-mdx/lib/cn.ts +1 -0
- package/template/+next+hanzo-docs-mdx/lib/layout.shared.tsx +9 -0
- package/template/+next+hanzo-docs-mdx/lib/source.ts +27 -0
- package/template/+next+hanzo-docs-mdx/mdx-components.tsx +9 -0
- package/template/+next+hanzo-docs-mdx/next.config.mjs +18 -0
- package/template/+next+hanzo-docs-mdx/package.json +31 -0
- package/template/+next+hanzo-docs-mdx/postcss.config.mjs +5 -0
- package/template/+next+hanzo-docs-mdx/source.config.ts +23 -0
- package/template/+next+hanzo-docs-mdx/tsconfig.json +36 -0
- package/template/+orama-cloud/@app/components/search.tsx +54 -0
- package/template/+orama-cloud/@app/lib/export-static-indexes.ts +14 -0
- package/template/+orama-cloud/@root/.env.example +6 -0
- package/template/react-router/README.md +12 -0
- package/template/react-router/app/app.css +3 -0
- package/template/react-router/app/docs/page.tsx +51 -0
- package/template/react-router/app/docs/search.ts +12 -0
- package/template/react-router/app/lib/layout.shared.tsx +9 -0
- package/template/react-router/app/lib/source.ts +7 -0
- package/template/react-router/app/root.tsx +73 -0
- package/template/react-router/app/routes/home.tsx +30 -0
- package/template/react-router/app/routes.ts +7 -0
- package/template/react-router/content/docs/index.mdx +32 -0
- package/template/react-router/content/docs/meta.json +3 -0
- package/template/react-router/content/docs/test.mdx +24 -0
- package/template/react-router/example.gitignore +7 -0
- package/template/react-router/package.json +35 -0
- package/template/react-router/public/favicon.ico +0 -0
- package/template/react-router/react-router.config.ts +23 -0
- package/template/react-router/source.config.ts +7 -0
- package/template/react-router/tsconfig.json +23 -0
- package/template/react-router/vite.config.ts +17 -0
- package/template/react-router-spa/README.md +12 -0
- package/template/react-router-spa/app/app.css +3 -0
- package/template/react-router-spa/app/components/search.tsx +45 -0
- package/template/react-router-spa/app/docs/page.tsx +53 -0
- package/template/react-router-spa/app/docs/search.ts +10 -0
- package/template/react-router-spa/app/lib/layout.shared.tsx +9 -0
- package/template/react-router-spa/app/lib/source.ts +7 -0
- package/template/react-router-spa/app/root.tsx +74 -0
- package/template/react-router-spa/app/routes/home.tsx +30 -0
- package/template/react-router-spa/app/routes.ts +7 -0
- package/template/react-router-spa/content/docs/index.mdx +32 -0
- package/template/react-router-spa/content/docs/test.mdx +24 -0
- package/template/react-router-spa/example.gitignore +7 -0
- package/template/react-router-spa/package.json +36 -0
- package/template/react-router-spa/public/favicon.ico +0 -0
- package/template/react-router-spa/react-router.config.ts +23 -0
- package/template/react-router-spa/serve.json +3 -0
- package/template/react-router-spa/source.config.ts +7 -0
- package/template/react-router-spa/tsconfig.json +23 -0
- package/template/react-router-spa/vite.config.ts +17 -0
- package/template/tanstack-start/README.md +12 -0
- package/template/tanstack-start/content/docs/index.mdx +31 -0
- package/template/tanstack-start/content/docs/test.mdx +12 -0
- package/template/tanstack-start/example.gitignore +18 -0
- package/template/tanstack-start/package.json +38 -0
- package/template/tanstack-start/source.config.ts +7 -0
- package/template/tanstack-start/src/components/not-found.tsx +28 -0
- package/template/tanstack-start/src/lib/layout.shared.tsx +9 -0
- package/template/tanstack-start/src/lib/source.ts +9 -0
- package/template/tanstack-start/src/router.tsx +12 -0
- package/template/tanstack-start/src/routes/__root.tsx +45 -0
- package/template/tanstack-start/src/routes/api/search.ts +16 -0
- package/template/tanstack-start/src/routes/docs/$.tsx +72 -0
- package/template/tanstack-start/src/routes/index.tsx +26 -0
- package/template/tanstack-start/src/styles/app.css +3 -0
- package/template/tanstack-start/tsconfig.json +24 -0
- package/template/tanstack-start/vite.config.ts +33 -0
- package/template/tanstack-start-spa/README.md +12 -0
- package/template/tanstack-start-spa/content/docs/index.mdx +31 -0
- package/template/tanstack-start-spa/content/docs/test.mdx +12 -0
- package/template/tanstack-start-spa/example.gitignore +18 -0
- package/template/tanstack-start-spa/package.json +41 -0
- package/template/tanstack-start-spa/source.config.ts +7 -0
- package/template/tanstack-start-spa/src/components/not-found.tsx +28 -0
- package/template/tanstack-start-spa/src/components/search.tsx +46 -0
- package/template/tanstack-start-spa/src/lib/layout.shared.tsx +9 -0
- package/template/tanstack-start-spa/src/lib/source.ts +9 -0
- package/template/tanstack-start-spa/src/router.tsx +12 -0
- package/template/tanstack-start-spa/src/routes/__root.tsx +46 -0
- package/template/tanstack-start-spa/src/routes/api/search.ts +16 -0
- package/template/tanstack-start-spa/src/routes/docs/$.tsx +74 -0
- package/template/tanstack-start-spa/src/routes/index.tsx +26 -0
- package/template/tanstack-start-spa/src/styles/app.css +3 -0
- package/template/tanstack-start-spa/tsconfig.json +24 -0
- package/template/tanstack-start-spa/vite.config.ts +42 -0
- package/template/waku/README.md +11 -0
- package/template/waku/content/docs/index.mdx +31 -0
- package/template/waku/content/docs/test.mdx +12 -0
- package/template/waku/example.gitignore +6 -0
- package/template/waku/package.json +33 -0
- package/template/waku/source.config.ts +7 -0
- package/template/waku/src/components/provider.tsx +7 -0
- package/template/waku/src/lib/layout.shared.tsx +9 -0
- package/template/waku/src/lib/source.ts +9 -0
- package/template/waku/src/pages/(home)/_layout.tsx +7 -0
- package/template/waku/src/pages/(home)/index.tsx +21 -0
- package/template/waku/src/pages/_api/api/search.ts +4 -0
- package/template/waku/src/pages/_root.tsx +20 -0
- package/template/waku/src/pages/docs/[...slugs].tsx +45 -0
- package/template/waku/src/pages/docs/_layout.tsx +12 -0
- package/template/waku/src/styles/globals.css +9 -0
- package/template/waku/tsconfig.json +25 -0
- package/template/waku/waku.config.ts +17 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Fuma
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { x } from "tinyexec";
|
|
2
|
+
|
|
3
|
+
//#region src/auto-install.ts
|
|
4
|
+
const managers = [
|
|
5
|
+
"npm",
|
|
6
|
+
"yarn",
|
|
7
|
+
"bun",
|
|
8
|
+
"pnpm"
|
|
9
|
+
];
|
|
10
|
+
function getPackageManager() {
|
|
11
|
+
const userAgent = process.env.npm_config_user_agent ?? "";
|
|
12
|
+
if (userAgent.startsWith("yarn")) return "yarn";
|
|
13
|
+
if (userAgent.startsWith("pnpm")) return "pnpm";
|
|
14
|
+
if (userAgent.startsWith("bun")) return "bun";
|
|
15
|
+
return "npm";
|
|
16
|
+
}
|
|
17
|
+
async function autoInstall(manager, dest) {
|
|
18
|
+
await x(manager, ["install"], {
|
|
19
|
+
throwOnError: true,
|
|
20
|
+
nodeOptions: {
|
|
21
|
+
env: {
|
|
22
|
+
...process.env,
|
|
23
|
+
NODE_ENV: "development",
|
|
24
|
+
DISABLE_OPENCOLLECTIVE: "1"
|
|
25
|
+
},
|
|
26
|
+
cwd: dest
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { getPackageManager as n, managers as r, autoInstall as t };
|
|
33
|
+
//# sourceMappingURL=auto-install-CenyMuK7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-install-CenyMuK7.js","names":[],"sources":["../src/auto-install.ts"],"sourcesContent":["import { x } from 'tinyexec';\n\nexport type PackageManager = (typeof managers)[number];\n\nexport const managers = ['npm', 'yarn', 'bun', 'pnpm'] as const;\n\nexport function getPackageManager(): PackageManager {\n const userAgent = process.env.npm_config_user_agent ?? '';\n\n if (userAgent.startsWith('yarn')) {\n return 'yarn';\n }\n\n if (userAgent.startsWith('pnpm')) {\n return 'pnpm';\n }\n\n if (userAgent.startsWith('bun')) {\n return 'bun';\n }\n\n return 'npm';\n}\n\nexport async function autoInstall(manager: PackageManager, dest: string) {\n await x(manager, ['install'], {\n throwOnError: true,\n nodeOptions: {\n env: {\n ...process.env,\n NODE_ENV: 'development',\n DISABLE_OPENCOLLECTIVE: '1',\n },\n cwd: dest,\n },\n });\n}\n"],"mappings":";;;AAIA,MAAa,WAAW;CAAC;CAAO;CAAQ;CAAO;CAAO;AAEtD,SAAgB,oBAAoC;CAClD,MAAM,YAAY,QAAQ,IAAI,yBAAyB;AAEvD,KAAI,UAAU,WAAW,OAAO,CAC9B,QAAO;AAGT,KAAI,UAAU,WAAW,OAAO,CAC9B,QAAO;AAGT,KAAI,UAAU,WAAW,MAAM,CAC7B,QAAO;AAGT,QAAO;;AAGT,eAAsB,YAAY,SAAyB,MAAc;AACvE,OAAM,EAAE,SAAS,CAAC,UAAU,EAAE;EAC5B,cAAc;EACd,aAAa;GACX,KAAK;IACH,GAAG,QAAQ;IACX,UAAU;IACV,wBAAwB;IACzB;GACD,KAAK;GACN;EACF,CAAC"}
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { i as templates, n as isCI } from "./constants-CbNzssp2.js";
|
|
3
|
+
import { n as getPackageManager, r as managers } from "./auto-install-CenyMuK7.js";
|
|
4
|
+
import { create } from "./index.js";
|
|
5
|
+
import fs from "node:fs/promises";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { cancel, confirm, group, intro, isCancel, outro, select, spinner, text } from "@clack/prompts";
|
|
8
|
+
import pc from "picocolors";
|
|
9
|
+
import { Option, program } from "@commander-js/extra-typings";
|
|
10
|
+
|
|
11
|
+
//#region src/bin.ts
|
|
12
|
+
const command = program.argument("[name]", "the project name").option("--src", "(Next.js only) enable `src/` directory").option("--install", "install packages automatically").option("--no-git", "disable auto Git repository initialization").addOption(new Option("--linter <name>", "configure a linter/formatter, ESLint is currently Next.js only.").choices(["eslint", "biome"])).addOption(new Option("--search <name>", "configure a search solution").choices(["orama", "orama-cloud"])).addOption(new Option("--template <name>", "choose a template").choices(templates.map((item) => item.value))).addOption(new Option("--pm <name>", "choose a package manager").choices(managers).default(getPackageManager()));
|
|
13
|
+
async function main() {
|
|
14
|
+
command.parse(process.argv);
|
|
15
|
+
const defaultName = command.args[0];
|
|
16
|
+
const config = command.opts();
|
|
17
|
+
intro(pc.bgCyan(pc.bold("Create Hanzo Docs App")));
|
|
18
|
+
const options = await group({
|
|
19
|
+
name: async () => {
|
|
20
|
+
if (defaultName) return defaultName;
|
|
21
|
+
if (isCI) return "untitled";
|
|
22
|
+
return text({
|
|
23
|
+
message: "Project name",
|
|
24
|
+
placeholder: "my-app",
|
|
25
|
+
defaultValue: "my-app"
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
template: async () => {
|
|
29
|
+
if (config.template) return config.template;
|
|
30
|
+
if (isCI) return "+next+fuma-docs-mdx";
|
|
31
|
+
return select({
|
|
32
|
+
message: "Choose a template",
|
|
33
|
+
initialValue: "+next+fuma-docs-mdx",
|
|
34
|
+
options: templates
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
src: async ({ results }) => {
|
|
38
|
+
if (config.src !== void 0) return config.src;
|
|
39
|
+
if (isCI || !results.template?.startsWith("+next")) return false;
|
|
40
|
+
return confirm({
|
|
41
|
+
message: "Use `/src` directory?",
|
|
42
|
+
initialValue: false
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
lint: async ({ results }) => {
|
|
46
|
+
if (config.linter !== void 0) return config.linter;
|
|
47
|
+
if (isCI) return "disabled";
|
|
48
|
+
return select({
|
|
49
|
+
message: "Configure linter?",
|
|
50
|
+
options: results.template?.startsWith("+next") ? [
|
|
51
|
+
{
|
|
52
|
+
value: "disabled",
|
|
53
|
+
label: "Disabled"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
value: "eslint",
|
|
57
|
+
label: "ESLint"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
value: "biome",
|
|
61
|
+
label: "Biome"
|
|
62
|
+
}
|
|
63
|
+
] : [{
|
|
64
|
+
value: "disabled",
|
|
65
|
+
label: "Disabled"
|
|
66
|
+
}, {
|
|
67
|
+
value: "biome",
|
|
68
|
+
label: "Biome"
|
|
69
|
+
}]
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
search: async () => {
|
|
73
|
+
if (config.search !== void 0) return config.search;
|
|
74
|
+
if (isCI) return "orama";
|
|
75
|
+
return select({
|
|
76
|
+
message: "Choose a search solution?",
|
|
77
|
+
options: [{
|
|
78
|
+
value: "orama",
|
|
79
|
+
label: "Default",
|
|
80
|
+
hint: "local search powered by Orama, recommended"
|
|
81
|
+
}, {
|
|
82
|
+
value: "orama-cloud",
|
|
83
|
+
label: "Orama Cloud",
|
|
84
|
+
hint: "3rd party search solution, signup needed"
|
|
85
|
+
}]
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
installDeps: async () => {
|
|
89
|
+
if (config.install !== void 0) return config.install;
|
|
90
|
+
if (isCI) return false;
|
|
91
|
+
return confirm({ message: `Do you want to install packages automatically? (detected as ${config.pm})` });
|
|
92
|
+
}
|
|
93
|
+
}, { onCancel: () => {
|
|
94
|
+
cancel("Installation Stopped.");
|
|
95
|
+
process.exit(0);
|
|
96
|
+
} });
|
|
97
|
+
const projectName = options.name.toLowerCase().replace(/\s/, "-");
|
|
98
|
+
if (!isCI) await checkDir(projectName);
|
|
99
|
+
const info = spinner();
|
|
100
|
+
info.start(`Generating Project`);
|
|
101
|
+
const plugins = [];
|
|
102
|
+
if (options.src) {
|
|
103
|
+
const { nextUseSrc } = await import("./plugins/next-use-src.js");
|
|
104
|
+
plugins.push(nextUseSrc());
|
|
105
|
+
}
|
|
106
|
+
if (options.search === "orama-cloud") {
|
|
107
|
+
const { oramaCloud } = await import("./plugins/orama-cloud.js");
|
|
108
|
+
plugins.push(oramaCloud());
|
|
109
|
+
}
|
|
110
|
+
if (options.lint === "eslint") {
|
|
111
|
+
const { eslint } = await import("./plugins/eslint.js");
|
|
112
|
+
plugins.push(eslint());
|
|
113
|
+
}
|
|
114
|
+
if (options.lint === "biome") {
|
|
115
|
+
const { biome } = await import("./plugins/biome.js");
|
|
116
|
+
plugins.push(biome());
|
|
117
|
+
}
|
|
118
|
+
await create({
|
|
119
|
+
packageManager: config.pm,
|
|
120
|
+
template: options.template,
|
|
121
|
+
outputDir: projectName,
|
|
122
|
+
installDeps: options.installDeps,
|
|
123
|
+
initializeGit: config.git,
|
|
124
|
+
plugins,
|
|
125
|
+
log: (message) => {
|
|
126
|
+
info.message(message);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
info.stop("Project Generated");
|
|
130
|
+
outro(pc.bgGreen(pc.bold("Done")));
|
|
131
|
+
console.log(pc.bold("\nOpen the project"));
|
|
132
|
+
console.log(pc.cyan(`cd ${projectName}`));
|
|
133
|
+
console.log(pc.bold("\nRun Development Server"));
|
|
134
|
+
if (config.pm === "npm" || config.pm === "bun") console.log(pc.cyan(`${config.pm} run dev`));
|
|
135
|
+
else console.log(pc.cyan(`${config.pm} dev`));
|
|
136
|
+
console.log(pc.bold("\nYou can now open the project and start writing documents"));
|
|
137
|
+
process.exit(0);
|
|
138
|
+
}
|
|
139
|
+
async function checkDir(outputDir) {
|
|
140
|
+
const destDir = await fs.readdir(outputDir).catch(() => null);
|
|
141
|
+
if (!destDir || destDir.length === 0) return;
|
|
142
|
+
const del = await confirm({ message: `directory ${outputDir} already exists, do you want to delete its files?` });
|
|
143
|
+
if (isCancel(del)) {
|
|
144
|
+
cancel();
|
|
145
|
+
process.exit(1);
|
|
146
|
+
}
|
|
147
|
+
if (!del) return;
|
|
148
|
+
const info = spinner();
|
|
149
|
+
info.start(`Deleting files in ${outputDir}`);
|
|
150
|
+
await Promise.all(destDir.map((item) => {
|
|
151
|
+
return fs.rm(path.join(outputDir, item), {
|
|
152
|
+
recursive: true,
|
|
153
|
+
force: true
|
|
154
|
+
});
|
|
155
|
+
}));
|
|
156
|
+
info.stop(`Deleted files in ${outputDir}`);
|
|
157
|
+
}
|
|
158
|
+
main().catch((e) => {
|
|
159
|
+
console.error(e);
|
|
160
|
+
process.exit(1);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
//#endregion
|
|
164
|
+
export { };
|
|
165
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","names":[],"sources":["../src/bin.ts"],"sourcesContent":["#!/usr/bin/env node\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport {\n cancel,\n confirm,\n group,\n intro,\n isCancel,\n outro,\n select,\n spinner,\n text,\n} from '@clack/prompts';\nimport pc from 'picocolors';\nimport { getPackageManager, managers } from './auto-install';\nimport { create, type Template, type TemplatePlugin } from './index';\nimport { isCI, templates } from './constants';\nimport { Option, program } from '@commander-js/extra-typings';\n\nconst command = program\n .argument('[name]', 'the project name')\n .option('--src', '(Next.js only) enable `src/` directory')\n .option('--install', 'install packages automatically')\n .option('--no-git', 'disable auto Git repository initialization')\n .addOption(\n new Option(\n '--linter <name>',\n 'configure a linter/formatter, ESLint is currently Next.js only.',\n ).choices(['eslint', 'biome']),\n )\n .addOption(\n new Option('--search <name>', 'configure a search solution').choices(['orama', 'orama-cloud']),\n )\n .addOption(\n new Option('--template <name>', 'choose a template').choices(\n templates.map((item) => item.value),\n ),\n )\n .addOption(\n new Option('--pm <name>', 'choose a package manager')\n .choices(managers)\n .default(getPackageManager()),\n );\n\nasync function main(): Promise<void> {\n command.parse(process.argv);\n const defaultName = command.args[0];\n const config = command.opts();\n intro(pc.bgCyan(pc.bold('Create Hanzo Docs App')));\n\n const options = await group(\n {\n name: async () => {\n if (defaultName) return defaultName;\n if (isCI) return 'untitled';\n\n return text({\n message: 'Project name',\n placeholder: 'my-app',\n defaultValue: 'my-app',\n });\n },\n template: async () => {\n if (config.template) return config.template;\n if (isCI) return '+next+fuma-docs-mdx';\n\n return select<Template>({\n message: 'Choose a template',\n initialValue: '+next+fuma-docs-mdx',\n options: templates,\n });\n },\n src: async ({ results }: { results: { template?: Template } }) => {\n if (config.src !== undefined) return config.src;\n if (isCI || !results.template?.startsWith('+next')) return false;\n\n return confirm({\n message: 'Use `/src` directory?',\n initialValue: false,\n });\n },\n lint: async ({ results }: { results: { template?: Template } }) => {\n if (config.linter !== undefined) return config.linter;\n if (isCI) return 'disabled';\n\n return select({\n message: 'Configure linter?',\n options: results.template?.startsWith('+next')\n ? [\n {\n value: 'disabled',\n label: 'Disabled',\n },\n {\n value: 'eslint',\n label: 'ESLint',\n },\n {\n value: 'biome',\n label: 'Biome',\n },\n ]\n : [\n {\n value: 'disabled',\n label: 'Disabled',\n },\n {\n value: 'biome',\n label: 'Biome',\n },\n ],\n });\n },\n search: async () => {\n if (config.search !== undefined) return config.search;\n if (isCI) return 'orama';\n\n return select({\n message: 'Choose a search solution?',\n options: [\n {\n value: 'orama',\n label: 'Default',\n hint: 'local search powered by Orama, recommended',\n },\n {\n value: 'orama-cloud',\n label: 'Orama Cloud',\n hint: '3rd party search solution, signup needed',\n },\n ],\n });\n },\n installDeps: async () => {\n if (config.install !== undefined) return config.install;\n if (isCI) return false;\n\n return confirm({\n message: `Do you want to install packages automatically? (detected as ${config.pm})`,\n });\n },\n },\n {\n onCancel: () => {\n cancel('Installation Stopped.');\n process.exit(0);\n },\n },\n );\n\n const projectName = options.name.toLowerCase().replace(/\\s/, '-');\n if (!isCI) await checkDir(projectName);\n\n const info = spinner();\n info.start(`Generating Project`);\n const plugins: TemplatePlugin[] = [];\n\n if (options.src) {\n const { nextUseSrc } = await import('./plugins/next-use-src');\n plugins.push(nextUseSrc());\n }\n\n if (options.search === 'orama-cloud') {\n const { oramaCloud } = await import('./plugins/orama-cloud');\n plugins.push(oramaCloud());\n }\n\n if (options.lint === 'eslint') {\n const { eslint } = await import('./plugins/eslint');\n plugins.push(eslint());\n }\n\n if (options.lint === 'biome') {\n const { biome } = await import('./plugins/biome');\n plugins.push(biome());\n }\n\n await create({\n packageManager: config.pm,\n template: options.template,\n outputDir: projectName,\n installDeps: options.installDeps,\n initializeGit: config.git,\n plugins,\n log: (message) => {\n info.message(message);\n },\n });\n\n info.stop('Project Generated');\n\n outro(pc.bgGreen(pc.bold('Done')));\n\n console.log(pc.bold('\\nOpen the project'));\n console.log(pc.cyan(`cd ${projectName}`));\n\n console.log(pc.bold('\\nRun Development Server'));\n if (config.pm === 'npm' || config.pm === 'bun') {\n console.log(pc.cyan(`${config.pm} run dev`));\n } else {\n console.log(pc.cyan(`${config.pm} dev`));\n }\n console.log(pc.bold('\\nYou can now open the project and start writing documents'));\n\n process.exit(0);\n}\n\nasync function checkDir(outputDir: string) {\n const destDir = await fs.readdir(outputDir).catch(() => null);\n if (!destDir || destDir.length === 0) return;\n const del = await confirm({\n message: `directory ${outputDir} already exists, do you want to delete its files?`,\n });\n\n if (isCancel(del)) {\n cancel();\n process.exit(1);\n }\n\n if (!del) return;\n\n const info = spinner();\n info.start(`Deleting files in ${outputDir}`);\n\n await Promise.all(\n destDir.map((item) => {\n return fs.rm(path.join(outputDir, item), {\n recursive: true,\n force: true,\n });\n }),\n );\n\n info.stop(`Deleted files in ${outputDir}`);\n}\n\nmain().catch((e: unknown) => {\n console.error(e);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;AAoBA,MAAM,UAAU,QACb,SAAS,UAAU,mBAAmB,CACtC,OAAO,SAAS,yCAAyC,CACzD,OAAO,aAAa,iCAAiC,CACrD,OAAO,YAAY,6CAA6C,CAChE,UACC,IAAI,OACF,mBACA,kEACD,CAAC,QAAQ,CAAC,UAAU,QAAQ,CAAC,CAC/B,CACA,UACC,IAAI,OAAO,mBAAmB,8BAA8B,CAAC,QAAQ,CAAC,SAAS,cAAc,CAAC,CAC/F,CACA,UACC,IAAI,OAAO,qBAAqB,oBAAoB,CAAC,QACnD,UAAU,KAAK,SAAS,KAAK,MAAM,CACpC,CACF,CACA,UACC,IAAI,OAAO,eAAe,2BAA2B,CAClD,QAAQ,SAAS,CACjB,QAAQ,mBAAmB,CAAC,CAChC;AAEH,eAAe,OAAsB;AACnC,SAAQ,MAAM,QAAQ,KAAK;CAC3B,MAAM,cAAc,QAAQ,KAAK;CACjC,MAAM,SAAS,QAAQ,MAAM;AAC7B,OAAM,GAAG,OAAO,GAAG,KAAK,wBAAwB,CAAC,CAAC;CAElD,MAAM,UAAU,MAAM,MACpB;EACE,MAAM,YAAY;AAChB,OAAI,YAAa,QAAO;AACxB,OAAI,KAAM,QAAO;AAEjB,UAAO,KAAK;IACV,SAAS;IACT,aAAa;IACb,cAAc;IACf,CAAC;;EAEJ,UAAU,YAAY;AACpB,OAAI,OAAO,SAAU,QAAO,OAAO;AACnC,OAAI,KAAM,QAAO;AAEjB,UAAO,OAAiB;IACtB,SAAS;IACT,cAAc;IACd,SAAS;IACV,CAAC;;EAEJ,KAAK,OA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,UAAQ,KAAK,EAAE;;AAGjB,KAAI,CAAC,IAAK;CAEV,MAAM,OAAO,SAAS;AACtB,MAAK,MAAM,qBAAqB,YAAY;AAE5C,OAAM,QAAQ,IACZ,QAAQ,KAAK,SAAS;AACpB,SAAO,GAAG,GAAG,KAAK,KAAK,WAAW,KAAK,EAAE;GACvC,WAAW;GACX,OAAO;GACR,CAAC;GACF,CACH;AAED,MAAK,KAAK,oBAAoB,YAAY;;AAG5C,MAAM,CAAC,OAAO,MAAe;AAC3B,SAAQ,MAAM,EAAE;AAChB,SAAQ,KAAK,EAAE;EACf"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/auto-install.d.ts
|
|
2
|
+
type PackageManager = (typeof managers)[number];
|
|
3
|
+
declare const managers: readonly ["npm", "yarn", "bun", "pnpm"];
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/constants.d.ts
|
|
6
|
+
interface TemplateInfo {
|
|
7
|
+
value: '+next+fuma-docs-mdx' | 'waku' | 'react-router' | 'react-router-spa' | 'tanstack-start' | 'tanstack-start-spa' | '+next+fuma-docs-mdx+static';
|
|
8
|
+
label: string;
|
|
9
|
+
appDir: string;
|
|
10
|
+
/**
|
|
11
|
+
* path to root provider, relative to `appDir``
|
|
12
|
+
*/
|
|
13
|
+
rootProviderPath: string;
|
|
14
|
+
hint?: string;
|
|
15
|
+
/**
|
|
16
|
+
* rename files when copying from template
|
|
17
|
+
*/
|
|
18
|
+
rename?: (name: string) => string;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { PackageManager as n, TemplateInfo as t };
|
|
22
|
+
//# sourceMappingURL=constants-BkYWkLHa.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants-BkYWkLHa.d.ts","names":[],"sources":["../src/auto-install.ts","../src/constants.ts"],"mappings":";KAEY,cAAA,WAAyB,QAAA;AAAA,cAExB,QAAA;;;UCOI,YAAA;EACf,KAAA;EAQA,KAAA;EACA,MAAA;EDjBW;;;ECqBX,gBAAA;EACA,IAAA;;;;EAIA,MAAA,IAAU,IAAA;AAAA"}
|