hexo-swpp 4.0.1 → 4.0.3
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/README.md +15 -6
- package/dist/index.js +1 -28
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
这是 `swpp-backends` 的 hexo 端实现,绝大多数功能由 [swpp-backends](https://github.com/EmptyDreams/swpp-backends) 提供。
|
|
2
2
|
|
|
3
|
+
文档:
|
|
4
|
+
|
|
5
|
+
1. swpp-backends 文档:https://swpp.kmar.top/
|
|
6
|
+
2. hexo-swpp 文档:https://swpp.kmar.top/quickstart/hexo
|
|
7
|
+
|
|
3
8
|
## 安装
|
|
4
9
|
|
|
5
10
|
使用时需要同时安装 `hexo-swpp` 和 `swpp-backends`:
|
|
6
11
|
|
|
7
12
|
```bash
|
|
8
|
-
npm install hexo-swpp swpp-backends
|
|
13
|
+
npm install hexo-swpp swpp-backends
|
|
9
14
|
```
|
|
10
15
|
|
|
11
16
|
当 `swpp-backends` 存在版本更新时,可以直接更新 `swpp-backends` 版本,不需要更新 `hexo-swpp` 的版本。(不过 `hexo-swpp` 有更新的话最好也跟进一下。)
|
|
@@ -19,6 +24,8 @@ npm install hexo-swpp swpp-backends@3.0.0-alpha.100
|
|
|
19
24
|
| ~3.2 | ^2.0.0 |
|
|
20
25
|
| ~3.3 | ^2.1.2 |
|
|
21
26
|
| 4.0-alpha | 3.0.0-alpha |
|
|
27
|
+
| 4.0.0 | ^3.0.0 |
|
|
28
|
+
| ^4.0.1 | ^3.1.0 |
|
|
22
29
|
|
|
23
30
|
## 使用
|
|
24
31
|
|
|
@@ -69,20 +76,22 @@ swpp:
|
|
|
69
76
|
+ 如果你的网站发布过程不使用 `hexo deploy` 指令,则不要启用 `auto_exec` 选项。
|
|
70
77
|
+ 将 `npm_url` 调整为非官方 URL 后检查版本时可能会出现 404 错误。
|
|
71
78
|
|
|
72
|
-
SWPP v3 的文档尚未完成,敬请期待。
|
|
73
|
-
|
|
74
79
|
### 指令
|
|
75
80
|
|
|
76
81
|
1. `hexo swpp` - 构建 json 文件
|
|
77
82
|
2. `hexo swpp -b` / `hexo swpp --build` - 构建 json 文件,同 `hexo swpp`
|
|
78
|
-
3. `hexo swpp -t [URL]` / `hexo swpp --test [URL]` - 尝试拉取指定 URL,使用时将 `[URL]` 替换为有效的 HTTP/HTTPS 链接(需要附带协议头)
|
|
79
83
|
|
|
80
84
|
## 更新日志
|
|
81
85
|
|
|
82
86
|
+ 4.0+
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
|
|
88
|
+
该版本与 V3 不兼容,请注意修改配置文件!
|
|
89
|
+
|
|
90
|
+
1. 适配 `swpp-backends@3` \[4.0.0]
|
|
91
|
+
2. 修复无法与 `hexo8` 一同工作的问题 \[4.0.0]
|
|
85
92
|
3. 修复不支持 `swpp-backends@3.1.0+` 的问题 \[4.0.1]
|
|
93
|
+
4. 修复 `gen_dom` 默认值处理错误的问题 \[4.0.2]
|
|
94
|
+
5. 移除 `-t/-test` 命令 \[4.0.2]
|
|
86
95
|
|
|
87
96
|
+ 3.3+
|
|
88
97
|
1. 版本检查改为仅在执行 `hexo server` 时执行 \[3.3.0]
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,6 @@ const path_1 = __importDefault(require("path"));
|
|
|
31
31
|
const swpp_backends_1 = require("swpp-backends");
|
|
32
32
|
const logger = require('hexo-log').default();
|
|
33
33
|
const CONSOLE_OPTIONS = [
|
|
34
|
-
{ name: '-t, --test', desc: '尝试拉取指定链接' },
|
|
35
34
|
{ name: '-b, --build', desc: '构建 swpp,留空参数与使用该参数效果一致' }
|
|
36
35
|
];
|
|
37
36
|
let actions;
|
|
@@ -54,7 +53,6 @@ function checkHexoConfig(config) {
|
|
|
54
53
|
'auto_exec': 'boolean',
|
|
55
54
|
'npm_url': 'string',
|
|
56
55
|
'sort_rules': 'object',
|
|
57
|
-
'track_link': 'boolean',
|
|
58
56
|
};
|
|
59
57
|
for (let configKey in config) {
|
|
60
58
|
const type = typeMap[configKey];
|
|
@@ -95,36 +93,12 @@ async function start(hexo) {
|
|
|
95
93
|
hexo.extend.console.register('swpp', 'Hexo Swpp 的相关指令', {
|
|
96
94
|
options: CONSOLE_OPTIONS
|
|
97
95
|
}, async (args) => {
|
|
98
|
-
const test = args.t ?? args.test;
|
|
99
96
|
// noinspection JSUnresolvedReference
|
|
100
97
|
const build = args.b ?? args.build;
|
|
101
|
-
if (test) {
|
|
102
|
-
if (typeof test == 'boolean' || Array.isArray(test) || !/^(https?):\/\/(\S*?)\.(\S*?)(\S*)$/i.test(test)) {
|
|
103
|
-
logger.error('[SWPP][CONSOLE] --test/-t 后应跟随一个有效 URL');
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
await initRules(hexo, pluginConfig);
|
|
107
|
-
try {
|
|
108
|
-
const compilationData = actions.compilationData;
|
|
109
|
-
const response = await fetchUrl(compilationData, test);
|
|
110
|
-
if ([200, 301, 302, 307, 308].includes(response.status)) {
|
|
111
|
-
logger.info('[SWPP][LINK TEST] 资源拉取成功,状态码:' + response.status);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
logger.warn('[SWPP][LINK TEST] 资源拉取失败,状态码:' + response.status);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
catch (e) {
|
|
118
|
-
logger.warn('[SWPP][LINK TEST] 资源拉取失败', e);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
98
|
if (build) {
|
|
123
99
|
if (typeof build !== 'boolean') {
|
|
124
100
|
logger.warn('[SWPP][CONSOLE] -build/-b 后方不应跟随参数');
|
|
125
101
|
}
|
|
126
|
-
}
|
|
127
|
-
if (build || !test) {
|
|
128
102
|
try {
|
|
129
103
|
await runSwpp(hexo, pluginConfig);
|
|
130
104
|
}
|
|
@@ -216,9 +190,8 @@ async function loadConfig(hexo, pluginConfig) {
|
|
|
216
190
|
context: 'prod',
|
|
217
191
|
publicPath: /[/\\]$/.test(publishPath) ? publishPath : publishPath + '/',
|
|
218
192
|
isServiceWorker: pluginConfig.serviceWorker ?? true,
|
|
219
|
-
domJsPath: pluginConfig.gen_dom ? 'sw-dom.js' : undefined,
|
|
193
|
+
domJsPath: pluginConfig.gen_dom ?? true ? 'sw-dom.js' : undefined,
|
|
220
194
|
diffJsonPath: pluginConfig.gen_diff,
|
|
221
|
-
trackLink: pluginConfig.track_link
|
|
222
195
|
});
|
|
223
196
|
await actions.loadConfig({
|
|
224
197
|
compilationEnv: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hexo-swpp",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"type": "git",
|
|
21
21
|
"url": "https://github.com/EmptyDreams/hexo-swpp.git"
|
|
22
22
|
},
|
|
23
|
-
"homepage": "https://kmar.top/
|
|
23
|
+
"homepage": "https://swpp.kmar.top/",
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^22.0.2",
|
|
26
26
|
"hexo": "^7.3.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"hexo-log": "^4.1.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"swpp-backends": "^3.
|
|
33
|
+
"swpp-backends": "^3.1.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {}
|
|
36
36
|
}
|