Skip to content

Commit d0ee452

Browse files
committed
docs: Update README files with npm package usage
- Add npm package installation as the primary method - Include npm package link and information - Reorganize quick start section with two methods - Update both Chinese and English README files - Provide complete installation instructions for npm package
1 parent 57c8eda commit d0ee452

File tree

2 files changed

+74
-2
lines changed

2 files changed

+74
-2
lines changed

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
使用 `Node.js` + `Webpack` 模块化开发油猴脚本的方案,用于提升油猴开发体验,降低开发时的心智负担,让油猴脚本也能当做一个普通的模块化的前端项目来开发,要不然一个 `JavaScript` 文件几千行来回改本人真的有点顶不住......
88

9+
**📦 NPM 包**: [typescript-userscript-template-jsrei](https://www.npmjs.com/package/typescript-userscript-template-jsrei)
10+
911
---
1012

1113
## 二、优势
@@ -20,7 +22,41 @@
2022

2123
## 三、快速开始
2224

23-
在当前仓库(https://github.com/JSREI/userscript-template)选择 "`Use this template`" --> "`Create a new repository`",从这个模板仓库创建一个新的仓库:
25+
### 方式一:使用 npm 包(推荐)
26+
27+
直接使用我们发布的 npm 包来创建新项目:
28+
29+
```bash
30+
# 创建新项目目录
31+
mkdir my-userscript
32+
cd my-userscript
33+
34+
# 使用 npm 初始化项目
35+
npm init -y
36+
37+
# 安装模板包
38+
npm install typescript-userscript-template-jsrei
39+
40+
# 复制模板文件到当前目录
41+
cp -r node_modules/typescript-userscript-template-jsrei/* .
42+
cp -r node_modules/typescript-userscript-template-jsrei/.* . 2>/dev/null || true
43+
44+
# 安装依赖
45+
npm install
46+
47+
# 清理不需要的文件
48+
rm -rf node_modules/typescript-userscript-template-jsrei
49+
```
50+
51+
或者使用 npx 一键创建(如果支持):
52+
53+
```bash
54+
npx typescript-userscript-template-jsrei create my-userscript
55+
```
56+
57+
### 方式二:使用 GitHub 模板
58+
59+
在当前仓库(https://github.com/JSREI/typescript-userscript-template)选择 "`Use this template`" --> "`Create a new repository`",从这个模板仓库创建一个新的仓库:
2460

2561
![创建新仓库](README.assets/image-20230816233501101.png)
2662

README_en.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
A plan for using `Node.js` + `Webpack` for modular development of Tampermonkey scripts, aimed at improving the development experience of Tampermonkey, reducing the mental burden during development, and allowing Tampermonkey scripts to be developed like a regular modular front-end project. Otherwise, a `JavaScript` file with thousands of lines to be modified back and forth is really too much to handle...
88

9+
**📦 NPM Package**: [typescript-userscript-template-jsrei](https://www.npmjs.com/package/typescript-userscript-template-jsrei)
10+
911
# 2. Advantages
1012

1113
- Modular development of Tampermonkey projects can greatly enhance both the development experience and efficiency. You no longer have to worry about how to organize code within a single `JavaScript` file (Tampermonkey scripts uploaded to the Tampermonkey store must be single files without obfuscation or compression, and the JS files produced by modular development and packaging also meet the requirements for uploading).
@@ -14,9 +16,43 @@ A plan for using `Node.js` + `Webpack` for modular development of Tampermonkey s
1416

1517
# 3. Quick Start
1618

19+
## Method 1: Using npm Package (Recommended)
20+
21+
Use our published npm package to create a new project directly:
22+
23+
```bash
24+
# Create new project directory
25+
mkdir my-userscript
26+
cd my-userscript
27+
28+
# Initialize project with npm
29+
npm init -y
30+
31+
# Install template package
32+
npm install typescript-userscript-template-jsrei
33+
34+
# Copy template files to current directory
35+
cp -r node_modules/typescript-userscript-template-jsrei/* .
36+
cp -r node_modules/typescript-userscript-template-jsrei/.* . 2>/dev/null || true
37+
38+
# Install dependencies
39+
npm install
40+
41+
# Clean up unnecessary files
42+
rm -rf node_modules/typescript-userscript-template-jsrei
43+
```
44+
45+
Or use npx for one-command creation (if supported):
46+
47+
```bash
48+
npx typescript-userscript-template-jsrei create my-userscript
49+
```
50+
51+
## Method 2: Using GitHub Template
52+
1753
To quickly get started with the project template, follow these steps:
1854

19-
1. Go to the repository at [https://github.com/JSREI/userscript-template](https://github.com/JSREI/userscript-template).
55+
1. Go to the repository at [https://github.com/JSREI/typescript-userscript-template](https://github.com/JSREI/typescript-userscript-template).
2056
2. Click on the "Use this template" button.
2157
3. Then, select "Create a new repository" to create a new repository from this template.
2258

0 commit comments

Comments
 (0)