pug-site-core 1.0.10 → 1.0.12
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/index.js +33 -33
- package/lib/devServer.js +6 -5
- package/package.json +47 -47
package/index.js
CHANGED
|
@@ -18,37 +18,37 @@ export const pugSiteCore = {
|
|
|
18
18
|
translateLanguageData
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
let curCmd = process.env.npm_lifecycle_event;
|
|
21
|
+
// let curCmd = process.env.npm_lifecycle_event;
|
|
22
22
|
|
|
23
|
-
try {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
} catch (error) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
23
|
+
// try {
|
|
24
|
+
// switch (curCmd) {
|
|
25
|
+
// case "getFun":
|
|
26
|
+
// await generateGetDataFn();
|
|
27
|
+
// break;
|
|
28
|
+
// case "getData":
|
|
29
|
+
// await generateGetDataFn();
|
|
30
|
+
// const args = process.argv.slice(2);
|
|
31
|
+
// await fetchDataToJsonFile(args);
|
|
32
|
+
// break;
|
|
33
|
+
// case "dev":
|
|
34
|
+
// startDevServer();
|
|
35
|
+
// break;
|
|
36
|
+
// case "compileFn":
|
|
37
|
+
// await compilePagesPugToFn();
|
|
38
|
+
// break;
|
|
39
|
+
// case "buildFn":
|
|
40
|
+
// await buildFn();
|
|
41
|
+
// break;
|
|
42
|
+
// case "buildStatic":
|
|
43
|
+
// await buildStatic();
|
|
44
|
+
// break;
|
|
45
|
+
// case "lang":
|
|
46
|
+
// await translateLanguageData();
|
|
47
|
+
// break;
|
|
48
|
+
// default:
|
|
49
|
+
// console.log(`未知的命令: ${curCmd}`);
|
|
50
|
+
// }
|
|
51
|
+
// } catch (error) {
|
|
52
|
+
// console.error(`执行命令 ${curCmd} 时发生错误:`, error);
|
|
53
|
+
// process.exit(1);
|
|
54
|
+
// }
|
package/lib/devServer.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
pagesPathFilter,
|
|
9
9
|
getIdleProt,
|
|
10
10
|
matchESI,
|
|
11
|
-
pathSymbol
|
|
11
|
+
pathSymbol,
|
|
12
12
|
} from "./utils.js";
|
|
13
13
|
import http from "http";
|
|
14
14
|
import WebSocket, { WebSocketServer } from "ws";
|
|
@@ -17,8 +17,9 @@ import { paths } from "./paths.js";
|
|
|
17
17
|
|
|
18
18
|
const { config } = await import(paths.config);
|
|
19
19
|
const pagsTemplatePath = paths.template.pages;
|
|
20
|
-
const localIp = ip.address();
|
|
21
|
-
const port =
|
|
20
|
+
const localIp = process.env._localIp || ip.address();
|
|
21
|
+
const port =
|
|
22
|
+
process.env._port || (await getIdleProt(config.devServer.port, localIp));
|
|
22
23
|
process.env._port = port;
|
|
23
24
|
process.env._localIp = localIp;
|
|
24
25
|
|
|
@@ -144,7 +145,7 @@ function setupRoutes(app, wss) {
|
|
|
144
145
|
{
|
|
145
146
|
data,
|
|
146
147
|
_pagePath: pugPath.split(pathSymbol + "pages")[1],
|
|
147
|
-
common: _.merge(commonData, config.commonData)
|
|
148
|
+
common: _.merge(commonData, config.commonData),
|
|
148
149
|
},
|
|
149
150
|
{ filters: getCompilePugFilter() }
|
|
150
151
|
),
|
|
@@ -201,7 +202,7 @@ async function matchFileMapTable(reqPath, language, device) {
|
|
|
201
202
|
return {
|
|
202
203
|
pugPath: obj.pugPath,
|
|
203
204
|
data,
|
|
204
|
-
getDataFn: obj.getDataFn
|
|
205
|
+
getDataFn: obj.getDataFn,
|
|
205
206
|
};
|
|
206
207
|
}
|
|
207
208
|
}
|
package/package.json
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "pug-site-core",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"main": "index.js",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "nodemon --ext js --ignore node_modules/ --ignore template/ index.js",
|
|
8
|
-
"getData": "node index.js",
|
|
9
|
-
"getFun": "node index.js",
|
|
10
|
-
"compileFn": "node index.js",
|
|
11
|
-
"buildFn": "node index.js",
|
|
12
|
-
"buildStatic": "node index.js",
|
|
13
|
-
"lang": "node index.js",
|
|
14
|
-
"build": "npm run getData && npm run buildFn"
|
|
15
|
-
},
|
|
16
|
-
"keywords": [],
|
|
17
|
-
"author": "xy",
|
|
18
|
-
"dependencies": {
|
|
19
|
-
"@google-cloud/translate": "^8.5.0",
|
|
20
|
-
"async": "^3.2.6",
|
|
21
|
-
"chokidar": "^3.6.0",
|
|
22
|
-
"express": "^4.19.2",
|
|
23
|
-
"express-useragent": "^1.0.15",
|
|
24
|
-
"fs-extra": "^11.2.0",
|
|
25
|
-
"ip": "^2.0.1",
|
|
26
|
-
"javascript-obfuscator": "^4.1.1",
|
|
27
|
-
"jstransformer-autoprefixer": "^2.0.0",
|
|
28
|
-
"jstransformer-less": "^2.3.0",
|
|
29
|
-
"jstransformer-scss": "^2.0.0",
|
|
30
|
-
"less": "^4.2.0",
|
|
31
|
-
"lodash": "^4.17.21",
|
|
32
|
-
"nodemon": "^3.1.4",
|
|
33
|
-
"pug": "^3.0.3",
|
|
34
|
-
"tcp-port-used": "^1.0.2",
|
|
35
|
-
"uglify-js": "^3.19.3",
|
|
36
|
-
"ws": "^8.18.0",
|
|
37
|
-
"axios": "^1.7.7"
|
|
38
|
-
},
|
|
39
|
-
"license": "ISC",
|
|
40
|
-
"description": "
|
|
41
|
-
"files": [
|
|
42
|
-
"lib/",
|
|
43
|
-
"index.js"
|
|
44
|
-
],
|
|
45
|
-
"exports": {
|
|
46
|
-
".": "./index.js"
|
|
47
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "pug-site-core",
|
|
3
|
+
"version": "1.0.12",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "nodemon --ext js --ignore node_modules/ --ignore template/ index.js",
|
|
8
|
+
"getData": "node index.js",
|
|
9
|
+
"getFun": "node index.js",
|
|
10
|
+
"compileFn": "node index.js",
|
|
11
|
+
"buildFn": "node index.js",
|
|
12
|
+
"buildStatic": "node index.js",
|
|
13
|
+
"lang": "node index.js",
|
|
14
|
+
"build": "npm run getData && npm run buildFn"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [],
|
|
17
|
+
"author": "xy",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@google-cloud/translate": "^8.5.0",
|
|
20
|
+
"async": "^3.2.6",
|
|
21
|
+
"chokidar": "^3.6.0",
|
|
22
|
+
"express": "^4.19.2",
|
|
23
|
+
"express-useragent": "^1.0.15",
|
|
24
|
+
"fs-extra": "^11.2.0",
|
|
25
|
+
"ip": "^2.0.1",
|
|
26
|
+
"javascript-obfuscator": "^4.1.1",
|
|
27
|
+
"jstransformer-autoprefixer": "^2.0.0",
|
|
28
|
+
"jstransformer-less": "^2.3.0",
|
|
29
|
+
"jstransformer-scss": "^2.0.0",
|
|
30
|
+
"less": "^4.2.0",
|
|
31
|
+
"lodash": "^4.17.21",
|
|
32
|
+
"nodemon": "^3.1.4",
|
|
33
|
+
"pug": "^3.0.3",
|
|
34
|
+
"tcp-port-used": "^1.0.2",
|
|
35
|
+
"uglify-js": "^3.19.3",
|
|
36
|
+
"ws": "^8.18.0",
|
|
37
|
+
"axios": "^1.7.7"
|
|
38
|
+
},
|
|
39
|
+
"license": "ISC",
|
|
40
|
+
"description": "修复刷新代码切换端口bug",
|
|
41
|
+
"files": [
|
|
42
|
+
"lib/",
|
|
43
|
+
"index.js"
|
|
44
|
+
],
|
|
45
|
+
"exports": {
|
|
46
|
+
".": "./index.js"
|
|
47
|
+
}
|
|
48
48
|
}
|