create-open17-blog 1.0.0

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.
Files changed (3) hide show
  1. package/README.md +65 -0
  2. package/dist/index.js +93 -0
  3. package/package.json +47 -0
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # create-open17-blog
2
+
3
+ A CLI tool for quickly setting up VitePress blog with `vitepress-theme-open17`
4
+
5
+ ## Usage
6
+
7
+ ```bash
8
+ npm create open17-blog my-blog
9
+ # or
10
+ yarn create open17-blog my-blog
11
+ # or
12
+ pnpm create open17-blog my-blog
13
+ # or
14
+ bun create open17-blog my-blog
15
+ ```
16
+
17
+ You can also run it without arguments to create a blog in current directory:
18
+
19
+ ```bash
20
+ npm create open17-blog
21
+ ```
22
+
23
+ ## Features
24
+
25
+ - 🚀 Quick scaffolding with minimal setup
26
+ - 📁 Generates proper project structure
27
+ - 🎨 Preconfigured with open17 theme defaults
28
+ - 📝 Sample blog post included
29
+ - ⚙️ Type-safe configuration
30
+ - 🔧 Works with npm/yarn/pnpm/bun
31
+
32
+ ## What it creates
33
+
34
+ ```
35
+ my-blog/
36
+ ├── docs/
37
+ │ ├── .vitepress/
38
+ │ │ ├── config.ts # VitePress config with theme
39
+ │ │ └── theme/
40
+ │ │ └── index.ts # Theme entry
41
+ │ ├── posts/
42
+ │ │ └── 2024-xx-xx-hello-open17.md # Sample post
43
+ │ ├── index.md # Homepage with <blog /> component
44
+ │ └── public/ # Static assets
45
+ ├── package.json
46
+ └── .gitignore
47
+ ```
48
+
49
+ ## After scaffolding
50
+
51
+ ```bash
52
+ cd my-blog
53
+ npm install
54
+ npm run dev
55
+ ```
56
+
57
+ Your blog will be available at http://localhost:8090
58
+
59
+ ## Options
60
+
61
+ - `-f, --force` - Overwrite target directory if it exists
62
+
63
+ ## License
64
+
65
+ Apache-2.0
package/dist/index.js ADDED
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env node
2
+ import{Command as w}from"commander";import v from"inquirer";import t from"path";import r from"fs-extra";import n from"chalk";import b from"ora";import y from"validate-npm-package-name";var f=new w;f.name("create-open17-blog").description("Create a VitePress blog preconfigured with vitepress-theme-open17").version("1.0.0").argument("[project-name]","Folder to create the project in").option("-f, --force","Overwrite target directory if it exists",!1).action(async(e,c)=>{var i,s;try{let o=process.cwd(),l=e?t.resolve(o,e):o,a=e;a||(a=(await v.prompt([{name:"name",type:"input",message:"Project name:",default:"my-open17-blog"}])).name);let m=y(a);m.validForNewPackages||(console.error(n.red("Invalid project name: "+a)),(i=m.errors)==null||i.forEach(g=>console.error(n.red(" "+g))),(s=m.warnings)==null||s.forEach(g=>console.error(n.yellow(" "+g))),process.exit(1));let p=e?l:t.resolve(o,a);if(r.existsSync(p)){if(!((await r.readdir(p)).length===0)&&!c.force){let{overwrite:u}=await v.prompt([{name:"overwrite",type:"confirm",message:`Target directory ${n.cyan(p)} is not empty. Overwrite?`,default:!1}]);u||process.exit(1),await r.emptyDir(p)}}else await r.ensureDir(p);let h=b("Scaffolding project...").start();await j(p,a),h.succeed("Project scaffolded");let d=k();console.log(),console.log(n.green("Done. Now run:")),e&&console.log(" cd "+n.cyan(e)),console.log(` ${d} install`),console.log(` ${d} run dev`),console.log()}catch(o){console.error(n.red(o.message)),process.exit(1)}});f.parse();async function j(e,c){let i=t.join(e,"docs"),s=t.join(i,".vitepress"),o=t.join(s,"theme");await r.ensureDir(o);let l={name:c,private:!0,type:"module",scripts:{dev:"vitepress dev docs --port 8090",build:"vitepress build docs",preview:"vitepress preview docs"},dependencies:{vite:"^5.2.14",vitepress:"^1.3.4",vue:"^3.4.21","@giscus/vue":"^3.0.0","vitepress-sidebar":"^1.22.0","vitepress-theme-open17":"^1.3.5"},devDependencies:{}};await r.writeJSON(t.join(e,"package.json"),l,{spaces:2}),await r.writeFile(t.join(e,".gitignore"),`node_modules
3
+ dist
4
+ docs/.vitepress/cache/*
5
+ `),await r.writeFile(t.join(i,"index.md"),x()),await r.ensureDir(t.join(i,"posts")),await r.writeFile(t.join(i,"posts",`${D(new Date)}-hello-open17.md`),T()),await r.ensureDir(t.join(i,"page")),await r.writeFile(t.join(i,"page","tags.md"),I()),await r.writeFile(t.join(i,"page","archive.md"),C()),await r.writeFile(t.join(s,"config.ts"),P()),await r.writeFile(t.join(o,"index.ts"),F()),await r.ensureDir(t.join(i,"public"))}function k(){let e=process.env.npm_config_user_agent||"";return e.startsWith("yarn")?"yarn":e.startsWith("pnpm")?"pnpm":e.startsWith("bun")?"bun":"npm"}function D(e){let c=e.getFullYear(),i=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return`${c}-${i}-${s}`}function x(){return`---
6
+ layout: blog
7
+ bgImage:
8
+ light: "https://vitepress.open17.vip/bg.jpg"
9
+ dark: "https://vitepress.open17.vip/bg2_dark.jpg"
10
+ ---
11
+ `}function T(){return`---
12
+ title: Hello,World!
13
+ date: 2025-08-11
14
+ tags:
15
+ - Hello World
16
+
17
+ ---
18
+
19
+
20
+ \u8FD9\u662F\u4F60\u7684\u7B2C\u4E00\u7BC7\u6587\u7AE0\uFF0C\u6765\u81EA vitepress-theme-open17 CLI \u521D\u59CB\u5316\u3002
21
+
22
+ ---
23
+
24
+ :::tip \u2728 \u4E3A\u4EC0\u4E48\u9009\u62E9 Open17\uFF1F
25
+
26
+ **\u65E0\u7F1D\u6CBF\u7528 VitePress \u9ED8\u8BA4\u914D\u7F6E\uFF0C\u8F7B\u677E\u6784\u5EFA\u4F60\u7684\u4E2A\u6027\u5316\u535A\u5BA2**
27
+
28
+ Open17 \u662F\u4E00\u6B3E\u4E13\u4E3A VitePress \u8BBE\u8BA1\u7684\u73B0\u4EE3\u5316\u535A\u5BA2\u4E3B\u9898\uFF0C\u5728\u4FDD\u6301\u539F\u6709\u5F3A\u5927\u529F\u80FD\u7684\u57FA\u7840\u4E0A\uFF0C\u4E3A\u4F60\u5E26\u6765\u5168\u65B0\u7684\u535A\u5BA2\u4F53\u9A8C\u3002
29
+ :::
30
+
31
+ ## \u4F7F\u7528\u8BF4\u660E
32
+
33
+ - \u4F7F\u7528 /docs/posts \u4E0B\u7684 md \u6587\u4EF6\u4F5C\u4E3A\u535A\u5BA2\u6587\u7AE0
34
+
35
+
36
+
37
+ ## \u{1F4DA} \u5B8C\u6574\u6307\u5357
38
+
39
+ - \u{1F4D6} [\u5FEB\u901F\u5F00\u59CB](https://vitepress.open17.vip/blog-docs/0-intro/0-start.html) - 5\u5206\u949F\u4E0A\u624B\u6307\u5357
40
+ - \u2699\uFE0F [\u4E3B\u9898\u914D\u7F6E](https://vitepress.open17.vip/blog-docs/1-config/) - \u8BE6\u7EC6\u914D\u7F6E\u8BF4\u660E
41
+ - \u{1F3A8} [\u6837\u5F0F\u5B9A\u5236](https://vitepress.open17.vip/blog-docs/1-config/2-style.html) - \u6253\u9020\u4E13\u5C5E\u98CE\u683C
42
+ - \u{1F527} [\u8FDB\u9636\u4F7F\u7528](https://vitepress.open17.vip/blog-docs/2-more/) - \u9AD8\u7EA7\u529F\u80FD\u63A2\u7D22
43
+ `}function P(){return`import { defineConfigWithTheme } from 'vitepress'
44
+ import type { ThemeConfig } from 'vitepress-theme-open17/config'
45
+
46
+ export default defineConfigWithTheme<ThemeConfig>({
47
+ title: 'Blog Demo',
48
+ description: 'A VitePress Site',
49
+ themeConfig: {
50
+ search: { provider: 'local' },
51
+ blog: {
52
+ direct: 'rgt',
53
+ user: {
54
+ name: 'Open17',
55
+ avatar: 'https://vitepress.open17.vip/ava.jpg',
56
+ describe: 'Made with \u2764\uFE0F by open17',
57
+ },
58
+ tagPageLink: '/page/tags',
59
+ bgImage: { dark: "https://vitepress.open17.vip/bg_dark.jpg" },
60
+ },
61
+ nav: [
62
+ { text: "Home", link: "/" },
63
+ {
64
+ text: "Others",
65
+ items: [
66
+ { text: "Tags", link: "/page/tags" },
67
+ { text: "Archive", link: " /page/archive" },
68
+ ],
69
+ },
70
+ ],
71
+ home: {
72
+ maxTagsDisplayed: 20,
73
+ postsPerPage: 3
74
+ },
75
+ }
76
+ })
77
+ `}function F(){return`import Theme from 'vitepress-theme-open17'
78
+ export default Theme
79
+ `}function I(){return`---
80
+ layout: tags
81
+ lastUpdated: false
82
+ bgImage:
83
+ light: "https://vitepress.open17.vip/bg.jpg"
84
+ dark: "https://vitepress.open17.vip/bg2_dark.jpg"
85
+ ---
86
+ `}function C(){return`---
87
+ layout: archive
88
+ lastUpdated: false
89
+ bgImage:
90
+ light: "https://vitepress.open17.vip/bg.jpg"
91
+ dark: "https://vitepress.open17.vip/bg2_dark.jpg"
92
+ ---
93
+ `}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "create-open17-blog",
3
+ "version": "1.0.0",
4
+ "description": "CLI tool for quickly setting up vitepress-theme-open17 blog",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "bin": {
8
+ "create-open17-blog": "./dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "keywords": [
14
+ "vitepress",
15
+ "blog",
16
+ "cli",
17
+ "scaffolding",
18
+ "open17"
19
+ ],
20
+ "author": "open17 <opensci@163.com>",
21
+ "license": "Apache-2.0",
22
+ "repository": "https://github.com/open17/vitepress-theme-open17.git",
23
+ "homepage": "https://vitepress.open17.vip",
24
+ "dependencies": {
25
+ "commander": "^11.1.0",
26
+ "inquirer": "^9.2.11",
27
+ "chalk": "^5.3.0",
28
+ "ora": "^7.0.1",
29
+ "fs-extra": "^11.1.1",
30
+ "validate-npm-package-name": "^5.0.0"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^22.9.0",
34
+ "@types/inquirer": "^9.0.7",
35
+ "@types/fs-extra": "^11.0.4",
36
+ "typescript": "^5.6.3",
37
+ "tsup": "^8.0.1"
38
+ },
39
+ "scripts": {
40
+ "build": "tsup src/index.ts --format esm --target node16 --minify",
41
+ "dev": "tsup src/index.ts --format esm --target node16 --watch",
42
+ "prepublishOnly": "npm run build"
43
+ },
44
+ "engines": {
45
+ "node": ">=16.0.0"
46
+ }
47
+ }