@oipage/cli 0.2.1 → 0.3.0-alpha.2

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.
Files changed (73) hide show
  1. package/.github/FUNDING.yml +11 -11
  2. package/AUTHORS.txt +6 -6
  3. package/CHANGELOG +40 -21
  4. package/LICENSE +20 -20
  5. package/README.md +132 -132
  6. package/bin/WebSocket/decodeWsFrame.js +43 -43
  7. package/bin/WebSocket/encodeWsFrame.js +28 -28
  8. package/bin/WebSocket/headersToJSON.js +26 -26
  9. package/bin/WebSocket/index.js +106 -83
  10. package/bin/data/mineTypes.json +104 -104
  11. package/bin/disk.js +42 -42
  12. package/bin/help.js +53 -50
  13. package/bin/intercept.js +15 -15
  14. package/bin/network.js +21 -21
  15. package/bin/notebook/index.js +9 -0
  16. package/bin/proxy.js +82 -75
  17. package/bin/run +142 -134
  18. package/bin/serve.js +245 -195
  19. package/bin/template/404.html +184 -184
  20. package/bin/tools/deleteEmptyFolder.js +33 -33
  21. package/bin/tools/format.js +75 -75
  22. package/bin/tools/network.js +42 -42
  23. package/bin/tools/openBrowser.js +34 -25
  24. package/bin/tools/resolve404.js +98 -83
  25. package/bin/tools/resolveImport.js +89 -88
  26. package/bin/website-htmls/components/ui-select-file/index.html +8 -8
  27. package/bin/website-htmls/components/ui-select-file/index.js +42 -42
  28. package/bin/website-htmls/components/ui-select-file/index.scss +44 -44
  29. package/bin/website-htmls/dialogs/imageSize/index.html +54 -54
  30. package/bin/website-htmls/dialogs/imageSize/index.js +53 -53
  31. package/bin/website-htmls/dialogs/imageSize/index.scss +140 -140
  32. package/bin/website-htmls/dialogs/index.js +52 -52
  33. package/bin/website-htmls/images/addFile.svg +1 -1
  34. package/bin/website-htmls/images/img-to-pdf.svg +1 -1
  35. package/bin/website-htmls/index.html +17 -17
  36. package/bin/website-htmls/main.js +13 -13
  37. package/bin/website-htmls/pages/App/index.html +6 -6
  38. package/bin/website-htmls/pages/App/index.js +22 -22
  39. package/bin/website-htmls/pages/App/index.scss +43 -43
  40. package/bin/website-htmls/pages/appStore/index.html +7 -7
  41. package/bin/website-htmls/pages/appStore/index.js +19 -19
  42. package/bin/website-htmls/pages/appStore/index.scss +54 -54
  43. package/bin/website-htmls/pages/chart/index.html +8 -8
  44. package/bin/website-htmls/pages/chart/index.js +72 -72
  45. package/bin/website-htmls/pages/chart/index.scss +71 -71
  46. package/bin/website-htmls/pages/home/index.html +19 -19
  47. package/bin/website-htmls/pages/home/index.js +19 -19
  48. package/bin/website-htmls/pages/home/index.scss +87 -87
  49. package/bin/website-htmls/pages/image-editor/index.html +27 -27
  50. package/bin/website-htmls/pages/image-editor/index.js +106 -106
  51. package/bin/website-htmls/pages/image-editor/index.scss +69 -69
  52. package/bin/website-htmls/pages/img-to-pdf/index.html +3 -3
  53. package/bin/website-htmls/pages/img-to-pdf/index.js +44 -44
  54. package/bin/website-htmls/pages/img-to-pdf/index.scss +9 -9
  55. package/bin/website-htmls/pages/recorder-screen/index.html +15 -15
  56. package/bin/website-htmls/pages/recorder-screen/index.js +227 -227
  57. package/bin/website-htmls/pages/recorder-screen/index.scss +52 -52
  58. package/bin/website-htmls/router.config.js +29 -29
  59. package/bin/website-htmls/styles/common.css +44 -44
  60. package/bin/website-htmls/styles/normalize.css +94 -94
  61. package/bin/website-plugins/intercept/chart.js +33 -33
  62. package/bin/website-plugins/intercept/getPackage.js +17 -17
  63. package/bin/website-plugins/intercept/head.js +8 -8
  64. package/bin/website-plugins/intercept/index.js +8 -8
  65. package/bin/website-plugins/intercept/oipage-vislite-intercept.js +55 -55
  66. package/bin/website-plugins/intercept/oipage-zipaper-intercept.js +36 -36
  67. package/bin/website-plugins/loader/index.js +11 -11
  68. package/bin/website-plugins/loader/oipage-html-loader.js +7 -7
  69. package/bin/website-plugins/loader/oipage-scss-loader.js +149 -149
  70. package/docs/config.md +84 -84
  71. package/package.json +42 -42
  72. package/src/index.js +28 -28
  73. package/types/serve.d.ts +76 -76
@@ -1,185 +1,185 @@
1
- <!DOCTYPE html>
2
- <html lang="zh-cn">
3
-
4
- <head>
5
- <meta charset="UTF-8">
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
8
- <title>404 Not Found</title>
9
- <link rel="shortcut icon" href="/_oipage_cli_website_/logo.png">
10
- <style>
11
- body {
12
- margin: 0px;
13
- background-color: #ffffff;
14
- display: flex;
15
- flex-wrap: wrap;
16
- padding: 100px;
17
- }
18
-
19
- a {
20
- text-decoration: none;
21
- color: #284259;
22
- }
23
-
24
- a:hover {
25
- text-decoration: underline;
26
- }
27
-
28
- .fork {
29
- line-height: 30px;
30
- position: fixed;
31
- background-color: #607D8B;
32
- text-align: center;
33
- color: white;
34
- outline: 2px dashed #607D8B;
35
- width: 200px;
36
- transform: rotate(45deg);
37
- right: -45px;
38
- top: 45px;
39
- z-index: 1;
40
- }
41
-
42
- .current {
43
- box-sizing: border-box;
44
- position: fixed;
45
- left: 0;
46
- top: 0;
47
- line-height: 50px;
48
- padding-left: 20px;
49
- font-size: 14px;
50
- color: #000000;
51
- font-style: italic;
52
- }
53
-
54
- .filelist {
55
- box-sizing: border-box;
56
- position: fixed;
57
- left: 20px;
58
- top: 50px;
59
- outline: 1px solid #9E9E9E;
60
- width: calc(100vw - 40px);
61
-
62
- /* 2025年9月17日 于南京 */
63
- /* 100vh改成100%是为了解决手机端显示问题 */
64
- height: calc(100% - 100px);
65
-
66
- overflow: auto;
67
- padding: 20px;
68
- border-radius: 5px;
69
- background-color: #fcfcfc;
70
- }
71
-
72
- .filelist>table {
73
- width: 100%;
74
- text-align: left;
75
- border-collapse: collapse;
76
- }
77
-
78
- .filelist>table tr>th {
79
- white-space: nowrap;
80
- padding: 0 10px;
81
- }
82
-
83
- .filelist>table>thead>tr>th {
84
- color: #284259;
85
- font-size: 13px;
86
- line-height: 40px;
87
- }
88
-
89
- .filelist>table>tbody>tr>th {
90
- text-decoration: none;
91
- font-size: 12px;
92
- color: #3c3c3c;
93
- word-break: break-all;
94
- font-weight: 400;
95
- line-height: 30px;
96
- border-top: 1px solid #e4e4e4;
97
- }
98
-
99
- .filelist>table>tbody>tr>th>.btn {
100
- color: white;
101
- background-color: #2196F3;
102
- padding: 2px 5px;
103
- border-radius: 5px;
104
- }
105
-
106
- .filelist>table>tbody>tr>th.name {
107
- background-repeat: no-repeat;
108
- background-position: left center;
109
- background-size: auto 90%;
110
- padding-left: 30px;
111
- color: #000000;
112
- }
113
-
114
- .filelist>table>tbody>tr>th.name>span {
115
- white-space: nowrap;
116
- }
117
-
118
- .filelist>table>tbody>tr.file>th.name {
119
- background-image: url('${img_file}');
120
- }
121
-
122
- .filelist>table>tbody>tr.folder>th.name {
123
- background-image: url('${img_folder}');
124
- }
125
-
126
- .website-link {
127
- position: fixed;
128
- bottom: 10px;
129
- line-height: 30px;
130
- left: 16px;
131
- font-size: 14px;
132
- text-decoration: underline;
133
- font-weight: 800;
134
- }
135
- </style>
136
- </head>
137
-
138
- <body>
139
- <a href="https://github.com/oi-contrib/oipage-cli" target="_blank" class="fork">
140
- Fork me on Github
141
- </a>
142
- <div class="current">
143
- 当前位置:${current}
144
- </div>
145
- <div class="filelist">
146
- <table>
147
- <thead>
148
- <tr>
149
- <th>
150
- 名称
151
- </th>
152
- <th>
153
- 修改日期
154
- </th>
155
- <th>
156
- 类型
157
- </th>
158
- <th>
159
- 大小
160
- </th>
161
- <th>
162
- 操作
163
- </th>
164
- </tr>
165
- </thead>
166
- <tbody>
167
- <tr class="folder">
168
- <th class="name"><a href='../'>..</a></th>
169
- <th>-</th>
170
- <th>
171
- 文件夹
172
- </th>
173
- <th>-</th>
174
- <th>
175
- <a href='../' class="btn">打开</a>
176
- </th>
177
- </tr>
178
- ${template}
179
- </tbody>
180
- </table>
181
- </div>
182
- ${website}
183
- </body>
184
-
1
+ <!DOCTYPE html>
2
+ <html lang="zh-cn">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
8
+ <title>404 Not Found</title>
9
+ <link rel="shortcut icon" href="/@website/logo.png">
10
+ <style>
11
+ body {
12
+ margin: 0px;
13
+ background-color: #ffffff;
14
+ display: flex;
15
+ flex-wrap: wrap;
16
+ padding: 100px;
17
+ }
18
+
19
+ a {
20
+ text-decoration: none;
21
+ color: #284259;
22
+ }
23
+
24
+ a:hover {
25
+ text-decoration: underline;
26
+ }
27
+
28
+ .fork {
29
+ line-height: 30px;
30
+ position: fixed;
31
+ background-color: #607D8B;
32
+ text-align: center;
33
+ color: white;
34
+ outline: 2px dashed #607D8B;
35
+ width: 200px;
36
+ transform: rotate(45deg);
37
+ right: -45px;
38
+ top: 45px;
39
+ z-index: 1;
40
+ }
41
+
42
+ .current {
43
+ box-sizing: border-box;
44
+ position: fixed;
45
+ left: 0;
46
+ top: 0;
47
+ line-height: 50px;
48
+ padding-left: 20px;
49
+ font-size: 14px;
50
+ color: #000000;
51
+ font-style: italic;
52
+ }
53
+
54
+ .filelist {
55
+ box-sizing: border-box;
56
+ position: fixed;
57
+ left: 20px;
58
+ top: 50px;
59
+ outline: 1px solid #9E9E9E;
60
+ width: calc(100vw - 40px);
61
+
62
+ /* 2025年9月17日 于南京 */
63
+ /* 100vh改成100%是为了解决手机端显示问题 */
64
+ height: calc(100% - 100px);
65
+
66
+ overflow: auto;
67
+ padding: 20px;
68
+ border-radius: 5px;
69
+ background-color: #fcfcfc;
70
+ }
71
+
72
+ .filelist>table {
73
+ width: 100%;
74
+ text-align: left;
75
+ border-collapse: collapse;
76
+ }
77
+
78
+ .filelist>table tr>th {
79
+ white-space: nowrap;
80
+ padding: 0 10px;
81
+ }
82
+
83
+ .filelist>table>thead>tr>th {
84
+ color: #284259;
85
+ font-size: 13px;
86
+ line-height: 40px;
87
+ }
88
+
89
+ .filelist>table>tbody>tr>th {
90
+ text-decoration: none;
91
+ font-size: 12px;
92
+ color: #3c3c3c;
93
+ word-break: break-all;
94
+ font-weight: 400;
95
+ line-height: 30px;
96
+ border-top: 1px solid #e4e4e4;
97
+ }
98
+
99
+ .filelist>table>tbody>tr>th>.btn {
100
+ color: white;
101
+ background-color: #2196F3;
102
+ padding: 2px 5px;
103
+ border-radius: 5px;
104
+ }
105
+
106
+ .filelist>table>tbody>tr>th.name {
107
+ background-repeat: no-repeat;
108
+ background-position: left center;
109
+ background-size: auto 90%;
110
+ padding-left: 30px;
111
+ color: #000000;
112
+ }
113
+
114
+ .filelist>table>tbody>tr>th.name>span {
115
+ white-space: nowrap;
116
+ }
117
+
118
+ .filelist>table>tbody>tr.file>th.name {
119
+ background-image: url('${img_file}');
120
+ }
121
+
122
+ .filelist>table>tbody>tr.folder>th.name {
123
+ background-image: url('${img_folder}');
124
+ }
125
+
126
+ .website-link {
127
+ position: fixed;
128
+ bottom: 10px;
129
+ line-height: 30px;
130
+ left: 16px;
131
+ font-size: 14px;
132
+ text-decoration: underline;
133
+ font-weight: 800;
134
+ }
135
+ </style>
136
+ </head>
137
+
138
+ <body>
139
+ <a href="https://github.com/oi-contrib/oipage-cli" target="_blank" class="fork">
140
+ Fork me on Github
141
+ </a>
142
+ <div class="current">
143
+ 当前位置:${current}
144
+ </div>
145
+ <div class="filelist">
146
+ <table>
147
+ <thead>
148
+ <tr>
149
+ <th>
150
+ 名称
151
+ </th>
152
+ <th>
153
+ 修改日期
154
+ </th>
155
+ <th>
156
+ 类型
157
+ </th>
158
+ <th>
159
+ 大小
160
+ </th>
161
+ <th>
162
+ 操作
163
+ </th>
164
+ </tr>
165
+ </thead>
166
+ <tbody>
167
+ <tr class="folder">
168
+ <th class="name"><a href='../'>..</a></th>
169
+ <th>-</th>
170
+ <th>
171
+ 文件夹
172
+ </th>
173
+ <th>-</th>
174
+ <th>
175
+ <a href='../' class="btn">打开</a>
176
+ </th>
177
+ </tr>
178
+ ${template}
179
+ </tbody>
180
+ </table>
181
+ </div>
182
+ ${website}
183
+ </body>
184
+
185
185
  </html>
@@ -1,34 +1,34 @@
1
- const { readdirSync, lstatSync, rmdirSync, existsSync } = require("fs");
2
- const { join } = require("path");
3
-
4
- module.exports = function (rootPath) {
5
-
6
- // 命令地方已经确保是全路径
7
- // rootPath = path.resolve(rootPath);
8
-
9
- // 路径不存在,什么也不用干
10
- if (!existsSync(rootPath)) {
11
- console.log("路径不存在:\x1b[31m" + rootPath + "\x1b[0m");
12
- return;
13
- }
14
-
15
- ; (function deleteEmptyFolder(folderPath) {
16
- let subItems = readdirSync(folderPath);
17
- if (subItems.length > 0) {
18
- for (let i = 0; i < subItems.length; i++) {
19
- let itemPath = join(folderPath, subItems[i]);
20
- if (lstatSync(itemPath).isDirectory()) deleteEmptyFolder(itemPath);
21
- }
22
- } else {
23
- rmdirSync(folderPath);
24
-
25
- folderPath = join(folderPath, "..");
26
- while (folderPath.length >= rootPath.length) {
27
- subItems = readdirSync(folderPath);
28
- if (readdirSync(folderPath).length > 0) break;
29
- rmdirSync(folderPath);
30
- folderPath = join(folderPath, "..");
31
- }
32
- }
33
- })(rootPath);
1
+ const { readdirSync, lstatSync, rmdirSync, existsSync } = require("fs");
2
+ const { join } = require("path");
3
+
4
+ module.exports = function (rootPath) {
5
+
6
+ // 命令地方已经确保是全路径
7
+ // rootPath = path.resolve(rootPath);
8
+
9
+ // 路径不存在,什么也不用干
10
+ if (!existsSync(rootPath)) {
11
+ console.log("路径不存在:\x1b[31m" + rootPath + "\x1b[0m");
12
+ return;
13
+ }
14
+
15
+ ; (function deleteEmptyFolder(folderPath) {
16
+ let subItems = readdirSync(folderPath);
17
+ if (subItems.length > 0) {
18
+ for (let i = 0; i < subItems.length; i++) {
19
+ let itemPath = join(folderPath, subItems[i]);
20
+ if (lstatSync(itemPath).isDirectory()) deleteEmptyFolder(itemPath);
21
+ }
22
+ } else {
23
+ rmdirSync(folderPath);
24
+
25
+ folderPath = join(folderPath, "..");
26
+ while (folderPath.length >= rootPath.length) {
27
+ subItems = readdirSync(folderPath);
28
+ if (readdirSync(folderPath).length > 0) break;
29
+ rmdirSync(folderPath);
30
+ folderPath = join(folderPath, "..");
31
+ }
32
+ }
33
+ })(rootPath);
34
34
  };
@@ -1,76 +1,76 @@
1
- /**
2
- * 把字节转换成更可读的内容
3
- * @param {*} value
4
- * @returns
5
- */
6
- exports.formatByte = function (value) {
7
- if (value < 1024) return value + "Byte";
8
-
9
- let kb = value / 1024;
10
- if (kb < 1024) return kb.toFixed(1) + "KB";
11
-
12
- let mb = kb / 1024;
13
- if (mb < 1024) return mb.toFixed(1) + "MB";
14
-
15
- let gb = mb / 1024;
16
- return gb.toFixed(1) + "GB";
17
- };
18
-
19
- /**
20
- * 把时间变成更可读的格式
21
- * @param {*} value
22
- * @returns
23
- */
24
- exports.formatTime = function (value) {
25
- let year = value.getFullYear();
26
- let month = value.getMonth() + 1;
27
- let day = value.getDate();
28
-
29
- let hour = value.getHours();
30
- let minutes = value.getMinutes();
31
-
32
- let today = new Date();
33
- if (year == today.getFullYear() && month == today.getMonth() + 1 && day == today.getDate()) {
34
- return "今天 " + hour + ":" + minutes;
35
- } else {
36
- return year + "年" + month + "月" + day + "日 " + hour + ":" + minutes;
37
- }
38
- };
39
-
40
- /**
41
- * 命令行参数解析
42
- * @param {*} argvs
43
- * @param {*} shorts
44
- * @param {*} isArray 是否按序号记录
45
- * @returns
46
- */
47
- exports.formatArgv = function (argvs, shorts, isArray) {
48
- let result = {}, keyName = "args", value = [];
49
- if (isArray) result["value"] = [];
50
-
51
- let pushValue = function () {
52
- if (isArray && keyName !== "args") {
53
- result["value"].push({
54
- name: keyName,
55
- value
56
- });
57
- } else {
58
- result[keyName] = value;
59
- }
60
- };
61
-
62
- for (let index = 3; index < argvs.length; index++) {
63
- let argv = argvs[index];
64
-
65
- if (/^\-/.test(argv)) {
66
- pushValue();
67
- keyName = shorts[argv] || argv;
68
- value = [];
69
- } else {
70
- value.push(argv);
71
- }
72
- }
73
- pushValue();
74
-
75
- return result;
1
+ /**
2
+ * 把字节转换成更可读的内容
3
+ * @param {*} value
4
+ * @returns
5
+ */
6
+ exports.formatByte = function (value) {
7
+ if (value < 1024) return value + "Byte";
8
+
9
+ let kb = value / 1024;
10
+ if (kb < 1024) return kb.toFixed(1) + "KB";
11
+
12
+ let mb = kb / 1024;
13
+ if (mb < 1024) return mb.toFixed(1) + "MB";
14
+
15
+ let gb = mb / 1024;
16
+ return gb.toFixed(1) + "GB";
17
+ };
18
+
19
+ /**
20
+ * 把时间变成更可读的格式
21
+ * @param {*} value
22
+ * @returns
23
+ */
24
+ exports.formatTime = function (value) {
25
+ let year = value.getFullYear();
26
+ let month = value.getMonth() + 1;
27
+ let day = value.getDate();
28
+
29
+ let hour = value.getHours();
30
+ let minutes = value.getMinutes();
31
+
32
+ let today = new Date();
33
+ if (year == today.getFullYear() && month == today.getMonth() + 1 && day == today.getDate()) {
34
+ return "今天 " + hour + ":" + minutes;
35
+ } else {
36
+ return year + "年" + month + "月" + day + "日 " + hour + ":" + minutes;
37
+ }
38
+ };
39
+
40
+ /**
41
+ * 命令行参数解析
42
+ * @param {*} argvs
43
+ * @param {*} shorts
44
+ * @param {*} isArray 是否按序号记录
45
+ * @returns
46
+ */
47
+ exports.formatArgv = function (argvs, shorts, isArray) {
48
+ let result = {}, keyName = "args", value = [];
49
+ if (isArray) result["value"] = [];
50
+
51
+ let pushValue = function () {
52
+ if (isArray && keyName !== "args") {
53
+ result["value"].push({
54
+ name: keyName,
55
+ value
56
+ });
57
+ } else {
58
+ result[keyName] = value;
59
+ }
60
+ };
61
+
62
+ for (let index = 3; index < argvs.length; index++) {
63
+ let argv = argvs[index];
64
+
65
+ if (/^\-/.test(argv)) {
66
+ pushValue();
67
+ keyName = shorts[argv] || argv;
68
+ value = [];
69
+ } else {
70
+ value.push(argv);
71
+ }
72
+ }
73
+ pushValue();
74
+
75
+ return result;
76
76
  };
@@ -1,43 +1,43 @@
1
- const { networkInterfaces } = require("os");
2
-
3
- // 网络信息
4
- module.exports = function (isAll) {
5
-
6
- let infomation = {
7
- IPv4: [],
8
- IPv6: []
9
- };
10
-
11
- let networks = networkInterfaces();
12
-
13
- let IPv4Had = {}, IPv6Had = {};
14
-
15
- for (let typeName in networks) {
16
- let network = networks[typeName]
17
- for (let index = 0; index < network.length; index++) {
18
- if (network[index].mac != "00:00:00:00:00:00" || isAll) {
19
- if (network[index].family == 'IPv4') {
20
- if (!IPv4Had[network[index].mac]) {
21
- infomation.IPv4.push({
22
- address: network[index].address,
23
- mac: network[index].mac
24
- });
25
-
26
- IPv4Had[network[index].mac] = true;
27
- }
28
- } else if (network[index].family == 'IPv6') {
29
- if (!IPv6Had[network[index].mac]) {
30
- infomation.IPv6.push({
31
- address: network[index].address,
32
- mac: network[index].mac
33
- });
34
-
35
- IPv6Had[network[index].mac] = true;
36
- }
37
- }
38
- }
39
- }
40
- }
41
-
42
- return infomation;
1
+ const { networkInterfaces } = require("os");
2
+
3
+ // 网络信息
4
+ module.exports = function (isAll) {
5
+
6
+ let infomation = {
7
+ IPv4: [],
8
+ IPv6: []
9
+ };
10
+
11
+ let networks = networkInterfaces();
12
+
13
+ let IPv4Had = {}, IPv6Had = {};
14
+
15
+ for (let typeName in networks) {
16
+ let network = networks[typeName]
17
+ for (let index = 0; index < network.length; index++) {
18
+ if (network[index].mac != "00:00:00:00:00:00" || isAll) {
19
+ if (network[index].family == 'IPv4') {
20
+ if (!IPv4Had[network[index].mac]) {
21
+ infomation.IPv4.push({
22
+ address: network[index].address,
23
+ mac: network[index].mac
24
+ });
25
+
26
+ IPv4Had[network[index].mac] = true;
27
+ }
28
+ } else if (network[index].family == 'IPv6') {
29
+ if (!IPv6Had[network[index].mac]) {
30
+ infomation.IPv6.push({
31
+ address: network[index].address,
32
+ mac: network[index].mac
33
+ });
34
+
35
+ IPv6Had[network[index].mac] = true;
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+
42
+ return infomation;
43
43
  };