File tree Expand file tree Collapse file tree 6 files changed +140
-10
lines changed Expand file tree Collapse file tree 6 files changed +140
-10
lines changed Original file line number Diff line number Diff line change 1+ node_modules /
2+ dist /
3+ .git /
4+ .gitignore
5+ * .log
6+ .DS_Store
7+ .vscode /
8+ .idea /
Original file line number Diff line number Diff line change 1+ # 发布到npm指南
2+
3+ ## 发布步骤
4+
5+ 1 . ** 确保你有npm账号**
6+ ``` bash
7+ npm login
8+ ```
9+
10+ 2 . ** 检查包名是否可用**
11+ ``` bash
12+ npm view create-userscript
13+ ```
14+ 如果显示404错误,说明包名可用。
15+
16+ 3 . ** 发布到npm**
17+ ``` bash
18+ npm publish
19+ ```
20+
21+ 4 . ** 验证发布成功**
22+ ``` bash
23+ npm view create-userscript
24+ ```
25+
26+ ## 使用方式
27+
28+ 发布成功后,用户可以通过以下方式使用:
29+
30+ ``` bash
31+ # 方式1:使用npm create
32+ npm create @javascript-reverse-engineering-infrastructure/userscript my-project
33+
34+ # 方式2:使用npx
35+ npx @javascript-reverse-engineering-infrastructure/create-userscript my-project
36+ ```
37+
38+ ## 更新版本
39+
40+ 当需要更新模板时:
41+
42+ 1 . 修改代码
43+ 2 . 更新版本号:
44+ ``` bash
45+ npm version patch # 补丁版本 (0.0.1 -> 0.0.2)
46+ npm version minor # 次版本 (0.0.1 -> 0.1.0)
47+ npm version major # 主版本 (0.0.1 -> 1.0.0)
48+ ```
49+ 3 . 重新发布:
50+ ``` bash
51+ npm publish
52+ ```
53+
54+ ## 注意事项
55+
56+ - 包名 ` create-userscript ` 需要在npm上是唯一的
57+ - 如果包名已被占用,需要修改 ` package.json ` 中的 ` name ` 字段
58+ - 建议使用语义化版本号
59+ - 发布前确保所有文件都在 ` files ` 字段中正确配置
Original file line number Diff line number Diff line change 1616
1717# 三、快速开始
1818
19- 在当前仓库(https://github.com/JSREI/userscript-template)选择“`Use this template` ” --> “ ` Create a new repository`”,从这个模板仓库创建一个新的仓库:
19+ ## 方式一:使用npm命令创建(推荐)
20+
21+ 使用npm命令直接创建新项目:
22+
23+ ``` bash
24+ npm create @javascript-reverse-engineering-infrastructure/userscript my-userscript
25+ ```
26+
27+ 或者使用npx:
28+
29+ ``` bash
30+ npx @javascript-reverse-engineering-infrastructure/create-userscript my-userscript
31+ ```
32+
33+ 然后进入项目目录并安装依赖:
34+
35+ ``` bash
36+ cd my-userscript
37+ npm install
38+ ```
39+
40+ ## 方式二:从GitHub模板创建
41+
42+ 在当前仓库(https://github.com/JSREI/userscript-template)选择“`Use this template` ” --> “ ` Create a new repository`”,从这个模板仓库创建一个新的仓库:
2043
2144![ image-20230816233501101] ( README.assets/image-20230816233501101.png )
2245
Original file line number Diff line number Diff line change @@ -14,6 +14,29 @@ A plan for using `Node.js` + `Webpack` for modular development of Tampermonkey s
1414
1515# 3. Quick Start
1616
17+ ## Method 1: Using npm command (Recommended)
18+
19+ Create a new project directly using npm command:
20+
21+ ``` bash
22+ npm create @javascript-reverse-engineering-infrastructure/userscript my-userscript
23+ ```
24+
25+ Or using npx:
26+
27+ ``` bash
28+ npx @javascript-reverse-engineering-infrastructure/create-userscript my-userscript
29+ ```
30+
31+ Then enter the project directory and install dependencies:
32+
33+ ``` bash
34+ cd my-userscript
35+ npm install
36+ ```
37+
38+ ## Method 2: Create from GitHub template
39+
1740To quickly get started with the project template, follow these steps:
1841
19421 . Go to the repository at [ https://github.com/JSREI/userscript-template ] ( https://github.com/JSREI/userscript-template ) .
Original file line number Diff line number Diff line change 11{
2- "name" : " userscript-foo " ,
3- "version" : " 0 .0.1 " ,
4- "description" : " this is userscript's description " ,
2+ "name" : " @javascript-reverse-engineering-infrastructure/create-userscript " ,
3+ "version" : " 1 .0.0 " ,
4+ "description" : " A template for developing userscripts with Node.js and Webpack " ,
55 "main" : " index.js" ,
6+ "bin" : {
7+ "create-userscript-template" : " ./bin/create-userscript.js"
8+ },
69 "repository" : " https://github.com/JSREI/userscript-template.git" ,
710 "namespace" : " https://github.com/JSREI/userscript-template.git" ,
811 "document" : " https://github.com/JSREI/userscript-template.git" ,
12+ "keywords" : [
13+ " userscript" ,
14+ " tampermonkey" ,
15+ " greasemonkey" ,
16+ " template" ,
17+ " webpack" ,
18+ " create"
19+ ],
920 "scripts" : {
1021 "build" : " webpack --config webpack.prod.js" ,
1122 "watch" : " webpack --watch --config webpack.dev.js"
1627 "webpack" : " ^5.88.2" ,
1728 "webpack-cli" : " ^5.1.4" ,
1829 "webpack-merge" : " ^5.9.0"
19- }
30+ },
31+ "files" : [
32+ " bin/" ,
33+ " template/" ,
34+ " README.md" ,
35+ " LICENSE"
36+ ]
2037}
Original file line number Diff line number Diff line change 962962 < h1 > UserScript Template</ h1 >
963963 < p > 使用 Node.js + Webpack 模块化开发油猴脚本的高效方案</ p >
964964 < div class ="nav-container ">
965- < nav >
966- < ul >
965+ < nav >
966+ < ul >
967967 < li > < a href ="#features " class ="active "> 核心特性</ a >
968- < li > < a href ="#quick-start "> 快速开始</ a > </ li >
968+ < li > < a href ="#quick-start "> 快速开始</ a > </ li >
969969 < li > < a href ="#usage "> 调试指南</ a > </ li >
970- </ ul >
971- </ nav >
970+ </ ul >
971+ </ nav >
972972 </ div >
973973</ header >
974974
You can’t perform that action at this time.
0 commit comments