Skip to content

Commit edebc01

Browse files
authored
Merge pull request #7 from Lin-arm/main
docs: Switch the npm image acceleration to Cloudflare
2 parents c7a7422 + 958383e commit edebc01

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

README.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ pnpm install --registry=https://registry.npmmirror.com
6060

6161
另外您必须修改 订阅详情 [./src/subscription.ts](./src/subscription.ts) 下的 id 字段, 否则可能会和其它订阅冲突, 填一个较大的随机数字即可
6262

63+
可以在 github 查找下方代码块 ([快捷链接](https://github.com/search?q=export+default+defineGkdSubscription%28%7B+++id%3A+&type=code)), 查看您的订阅id是否跟已有项目重复
64+
65+
```ts
66+
export default defineGkdSubscription({
67+
id:
68+
```
69+
6370
## 格式修复
6471
6572
我们使用 [prettier](https://github.com/prettier/prettier) 来格式化代码 和 [eslint](https://github.com/eslint/eslint) 来检测并修复代码错误
@@ -104,48 +111,43 @@ raw.githubusercontent.com 在大陆的访问常常无法访问
104111
105112
如果无法访问 raw.githubusercontent.com 和 fastly.jsdelivr.net
106113
107-
您可以将本仓库发布到 npm 上, 然后通过 registry.npmmirror.com 加速访问
114+
您可以将本仓库的构建产物发布到 cloudflare Pages 上, 然后通过 cloudflare 加速访问
108115
109-
要发布到 npm 上, 必须先将 [./package.json](./package.json) 的 name 字段改成未使用的包名, 否则发布失败
116+
您需要先使用 github 登录 <https://dash.cloudflare.com>, 然后在左边菜单栏依次选择 **Build** --> **Compute** --> **Workers & Pages** , 接着点击页面右上角 **Create application**
110117
111-
您可以改成 `gkd-subscription-xxxx` 其中 `xxxx` 是订阅的 id 或者随机字母数字, 总之不冲突就行
118+
![1](https://github.com/user-attachments/assets/6d11b8ef-bef3-4582-8aa7-0c1b1535e2f5)
112119
113-
或者改成 `@your_npm_name/subscription`, 这种类型是 scope 名称, 其中 `your_npm_name` 是你下面要注册的 npm 用户名
120+
接着选择创建 Pages
114121
115-
![image](https://github.com/gkd-kit/gkd/assets/38517192/79817967-6f97-4935-9bf3-179bbf50b3aa)
122+
![2](https://github.com/user-attachments/assets/47ab6768-d363-49c2-98a2-e5eb82e58391)
116123
117-
接下来获取 token, 你需要先注册 <https://www.npmjs.com>, 然后到 Access Tokens 界面点击 Generate New Token 选择 Classic Token 后随便输入 Name 选择 Publish 即可生成并复制
124+
导入一个现有的Git仓库
118125
119-
![image](https://github.com/gkd-kit/gkd/assets/38517192/ca5eaf26-3705-4dc7-9584-4a235bbefde2)
126+
![3](https://github.com/user-attachments/assets/376bbbf5-4e85-4f04-9e5c-c4a5a51ff469)
120127
121-
![image](https://github.com/gkd-kit/gkd/assets/38517192/6da188ab-e415-44de-b2f7-3f985ab4d401)
128+
选择您的GKD订阅仓库, 如果仓库未显示, 点击跳转到github授权访问您的gkd订阅仓库。保存授权后会跳转回cloudflare, 重新走一遍前面的流程。
122129
123-
![image](https://github.com/gkd-kit/gkd/assets/38517192/55db57f6-1021-4d85-afd0-fe7df1f9bbcf)
130+
![4](https://github.com/user-attachments/assets/c16fc2a3-fd14-4ec8-866b-77d36c58692d)
124131
125-
复制后打开 <https://github.com/username/subscription/settings/secrets/actions/new>
132+
![5](https://github.com/user-attachments/assets/9566ea89-0772-4332-ad7c-17ad5d55ef08)
126133
127-
在 Name 输入 `NPM_TOKEN`, 在 Secret 输入刚刚复制的 token, 点击 Add secret 即可添加成功
134+
前面选好仓库后, 下一步接着填您的项目名和订阅文件路径
128135
129-
![image](https://github.com/gkd-kit/gkd/assets/38517192/72b062d8-4540-4602-82fe-416ea5348014)
136+
项目名可以改成 `gkd-subscription-xxxx` 其中 `xxxx` 是订阅的 id 或者随机字母数字, 总之不冲突就行
130137
131-
然后只需要重复上面的 构建订阅 步骤即可发布, 发布后得到的镜像加速链接如下
138+
![6](https://github.com/user-attachments/assets/b59fa5f2-e7bb-40d8-8855-b1a847fdc397)
132139
133-
```txt
134-
https://registry.npmmirror.com/gkd-subscription-xxxx/latest/files/dist/gkd.json5
135-
```
140+
填完后保存并部署, 等待部署完回到 **Workers & Pages** 页
141+
142+
![7](https://github.com/user-attachments/assets/64d0d6de-e11d-433d-8f87-3e6849f755be)
136143
137-
注: 将 gkd-subscription-xxxx 换成您的包名
138144
139-
如果你的包名是 `@your_npm_name/subscription` 这种类型, 加速链接是
145+
这时您会得到一个网址 `gkd-subscription-233.pages.dev`, 加上前缀后缀就得到的镜像加速链接如下 (链接仅供参考)
140146
141147
```txt
142-
https://registry.npmmirror.com/@your_npm_name/subscription/latest/files/dist/gkd.json5
148+
https://gkd-subscription-233.pages.dev/gkd.json5
143149
```
144150
145-
由于 npmmirror 被恶意刷流量后已经改为白名单模式, 不在白名单内的包, 上面的链接无法正常加速访问
146-
147-
因此要使上面的链接被正常访问, 你需要向 <https://github.com/cnpm/unpkg-white-list> 提交 pr 将你的包添加到白名单
148-
149151
## 自定义配置文件
150152
151153
注意: **大多数情况下, 你不需要自定义, 使用默认配置时, 下面此节教程无需了解**

0 commit comments

Comments
 (0)