@oipage/cli 0.2.1-alpha.0 → 0.3.0-alpha.1

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 +33 -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 +83 -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 +75 -75
  17. package/bin/run +142 -134
  18. package/bin/serve.js +218 -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 +25 -25
  24. package/bin/tools/resolve404.js +83 -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
package/docs/config.md CHANGED
@@ -1,85 +1,85 @@
1
- # 可配置项
2
-
3
- ## name
4
-
5
- 服务器名称,默认OIPage。
6
-
7
- ## version
8
-
9
- 服务器版本,默认使用@oipage/cli版本。
10
-
11
- ## devServer
12
-
13
- ### open
14
-
15
- 是否自动打开浏览器,默认false,true表示打开;也可以是一段地址,比如设置open=“docs/index.html”。
16
-
17
- ### cache
18
-
19
- 是否开启304缓存,默认true,表示开启。
20
-
21
- ### port
22
-
23
- 端口,默认8080。此外,可以在执行的时候,通过命令参数覆盖(下同):
24
-
25
- ```shell
26
- oipage-cli serve --config ./oipage.config.js -p 20000
27
- ```
28
-
29
- ### baseUrl
30
-
31
- 服务器根目录,默认当前命令行目录。可以是绝对路径,如果为相对路径,则是相对当前命令行目录。
32
-
33
- ### 404
34
-
35
- 自定义 404 页面,函数接收两个参数 filePath(文件磁盘路径) 和 url(请求地址)。
36
-
37
- ```js
38
- 404: function (filePath, url) {
39
- return "<h1>自定义的 404 页面</h1><p>你访问的页面不存在!</p>";
40
- }
41
- ```
42
-
43
- ### proxy
44
-
45
- 转发功能
46
-
47
- ```js
48
- proxy: {
49
- "/apidemo": {
50
- target: "https://oi-contrib.github.io/OIPage",
51
- pathRewrite: { '^/apidemo': '' }, // 地址重写,可选
52
- }
53
- }
54
- ```
55
-
56
- ### intercept
57
-
58
- 请求拦截,可以实现针对特殊请求的自定义处理。
59
-
60
- ```js
61
- intercept: Array<{
62
- test: /\.do$/,
63
- handler(request, response) {
64
- // todo
65
- }
66
- }>
67
- ```
68
-
69
- ## module
70
-
71
- ### rules
72
-
73
- 用于处理特殊文件,其中use的参数source为原始内容,此函数返回处理后的内容。此外,此函数的this包含若干有用属性或方法,具体如下:
74
-
75
- - root: 字符串,服务器根路径。
76
-
77
- - setFileType: 函数,用于设置文件类型。比如如果希望设置为js文件:
78
-
79
- ```js
80
- this.setFileType("application/javascript")
81
- ```
82
-
83
- - path: 字符串,文件相对路径。
84
-
1
+ # 可配置项
2
+
3
+ ## name
4
+
5
+ 服务器名称,默认OIPage。
6
+
7
+ ## version
8
+
9
+ 服务器版本,默认使用@oipage/cli版本。
10
+
11
+ ## devServer
12
+
13
+ ### open
14
+
15
+ 是否自动打开浏览器,默认false,true表示打开;也可以是一段地址,比如设置open=“docs/index.html”。
16
+
17
+ ### cache
18
+
19
+ 是否开启304缓存,默认true,表示开启。
20
+
21
+ ### port
22
+
23
+ 端口,默认8080。此外,可以在执行的时候,通过命令参数覆盖(下同):
24
+
25
+ ```shell
26
+ oipage-cli serve --config ./oipage.config.js -p 20000
27
+ ```
28
+
29
+ ### baseUrl
30
+
31
+ 服务器根目录,默认当前命令行目录。可以是绝对路径,如果为相对路径,则是相对当前命令行目录。
32
+
33
+ ### 404
34
+
35
+ 自定义 404 页面,函数接收两个参数 filePath(文件磁盘路径) 和 url(请求地址)。
36
+
37
+ ```js
38
+ 404: function (filePath, url) {
39
+ return "<h1>自定义的 404 页面</h1><p>你访问的页面不存在!</p>";
40
+ }
41
+ ```
42
+
43
+ ### proxy
44
+
45
+ 转发功能
46
+
47
+ ```js
48
+ proxy: {
49
+ "/apidemo": {
50
+ target: "https://oi-contrib.github.io/OIPage",
51
+ pathRewrite: { '^/apidemo': '' }, // 地址重写,可选
52
+ }
53
+ }
54
+ ```
55
+
56
+ ### intercept
57
+
58
+ 请求拦截,可以实现针对特殊请求的自定义处理。
59
+
60
+ ```js
61
+ intercept: Array<{
62
+ test: /\.do$/,
63
+ handler(request, response) {
64
+ // todo
65
+ }
66
+ }>
67
+ ```
68
+
69
+ ## module
70
+
71
+ ### rules
72
+
73
+ 用于处理特殊文件,其中use的参数source为原始内容,此函数返回处理后的内容。此外,此函数的this包含若干有用属性或方法,具体如下:
74
+
75
+ - root: 字符串,服务器根路径。
76
+
77
+ - setFileType: 函数,用于设置文件类型。比如如果希望设置为js文件:
78
+
79
+ ```js
80
+ this.setFileType("application/javascript")
81
+ ```
82
+
83
+ - path: 字符串,文件相对路径。
84
+
85
85
  - entry: 布尔值,是否是浏览器地址栏直接访问。
package/package.json CHANGED
@@ -1,43 +1,43 @@
1
- {
2
- "name": "@oipage/cli",
3
- "version": "0.2.1-alpha.0",
4
- "description": "开发快速助手,一个包含常用功能的命令行工具,旨在提升开发效率",
5
- "sideEffects": false,
6
- "main": "./src/index.js",
7
- "typings": "./types/index.d.ts",
8
- "scripts": {
9
- "serve": "node ./bin/run serve --config ./oipage.config.js --open"
10
- },
11
- "bin": {
12
- "oipage-cli": "bin/run"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "git+https://github.com/oi-contrib/oipage-cli.git"
17
- },
18
- "keywords": [
19
- "dev",
20
- "server",
21
- "style",
22
- "css",
23
- "nodejs",
24
- "core",
25
- "oipage",
26
- "browser"
27
- ],
28
- "author": {
29
- "name": "zxl20070701",
30
- "url": "https://zxl20070701.github.io/notebook/home.html"
31
- },
32
- "license": "MIT",
33
- "bugs": {
34
- "url": "https://github.com/oi-contrib/oipage-cli/issues"
35
- },
36
- "homepage": "https://github.com/oi-contrib/oipage-cli",
37
- "dependencies": {
38
- "oipage": "^2.0.0",
39
- "vislite": "^1.9.1",
40
- "xhtml-to-json": "^0.2.1",
41
- "zipaper": "^0.4.0"
42
- }
1
+ {
2
+ "name": "@oipage/cli",
3
+ "version": "0.3.0-alpha.1",
4
+ "description": "开发快速助手,一个包含常用功能的命令行工具,旨在提升开发效率",
5
+ "sideEffects": false,
6
+ "main": "./src/index.js",
7
+ "typings": "./types/index.d.ts",
8
+ "scripts": {
9
+ "serve": "node ./bin/run serve --config ./oipage.config.js --open -p 20000"
10
+ },
11
+ "bin": {
12
+ "oipage-cli": "bin/run"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/oi-contrib/oipage-cli.git"
17
+ },
18
+ "keywords": [
19
+ "dev",
20
+ "server",
21
+ "style",
22
+ "css",
23
+ "nodejs",
24
+ "core",
25
+ "oipage",
26
+ "browser"
27
+ ],
28
+ "author": {
29
+ "name": "zxl20070701",
30
+ "url": "https://zxl20070701.github.io/notebook/home.html"
31
+ },
32
+ "license": "MIT",
33
+ "bugs": {
34
+ "url": "https://github.com/oi-contrib/oipage-cli/issues"
35
+ },
36
+ "homepage": "https://github.com/oi-contrib/oipage-cli",
37
+ "dependencies": {
38
+ "oipage": "^2.0.0",
39
+ "vislite": "^1.9.1",
40
+ "xhtml-to-json": "^0.2.1",
41
+ "zipaper": "^0.4.0"
42
+ }
43
43
  }
package/src/index.js CHANGED
@@ -1,29 +1,29 @@
1
- const { mergeOption } = require("oipage/nodejs/option/index");
2
-
3
- // 开发服务器
4
- exports.serve = function (config) {
5
- let option = {
6
- devServer: {
7
- port: 8080,
8
- baseUrl: "./",
9
- open: false,
10
- cache: true,
11
- proxy: {},
12
- intercept: [],
13
- 404: null,
14
- website: false
15
- },
16
- module: {
17
- rules: []
18
- }
19
- };
20
-
21
- mergeOption(option, config);
22
- require("../bin/serve")(option);
23
- };
24
-
25
- exports.ZipaperIntercept = require("../bin/website-plugins/intercept/oipage-zipaper-intercept.js");
26
- exports.VISLiteIntercept = require("../bin/website-plugins/intercept/oipage-vislite-intercept.js");
27
-
28
- exports.ScssLoader = require("../bin/website-plugins/loader/oipage-scss-loader.js");
1
+ const { mergeOption } = require("oipage/nodejs/option/index");
2
+
3
+ // 开发服务器
4
+ exports.serve = function (config) {
5
+ let option = {
6
+ devServer: {
7
+ port: 8080,
8
+ baseUrl: "./",
9
+ open: false,
10
+ cache: true,
11
+ proxy: {},
12
+ intercept: [],
13
+ 404: null,
14
+ website: false
15
+ },
16
+ module: {
17
+ rules: []
18
+ }
19
+ };
20
+
21
+ mergeOption(option, config);
22
+ require("../bin/serve")(option);
23
+ };
24
+
25
+ exports.ZipaperIntercept = require("../bin/website-plugins/intercept/oipage-zipaper-intercept.js");
26
+ exports.VISLiteIntercept = require("../bin/website-plugins/intercept/oipage-vislite-intercept.js");
27
+
28
+ exports.ScssLoader = require("../bin/website-plugins/loader/oipage-scss-loader.js");
29
29
  exports.HtmlLoader = require("../bin/website-plugins/loader/oipage-html-loader.js");
package/types/serve.d.ts CHANGED
@@ -1,77 +1,77 @@
1
-
2
- interface DevServerType {
3
-
4
- /**
5
- * 是否自动打开浏览器,默认false,true表示打开
6
- *
7
- * 也可以是一段地址,比如设置open=“docs/index.html”
8
- */
9
- open?: boolean | string
10
-
11
- /**
12
- * 服务器端口号
13
- */
14
- port: number
15
-
16
- /**
17
- * 服务器根路径
18
- */
19
- baseUrl: string
20
-
21
- /**
22
- * 是否开启304缓存,默认开启
23
- */
24
- cache: boolean
25
-
26
- /**
27
- * 是否开启应用市场,默认true表示开启
28
- */
29
- website: boolean
30
-
31
- intercept?: Array<InterceptType>
32
-
33
- proxy?: {
34
- [key: string]: {
35
- target: string
36
- pathRewrite?: {
37
- [key: string]: string
38
- }
39
- }
40
- }
41
- }
42
-
43
- interface InterceptType {
44
- test: RegExp
45
- handler(request: any, response: any): void
46
- }
47
-
48
- interface LoaderType {
49
- (source: string): string
50
- }
51
-
52
- interface ConfigType {
53
-
54
- /**
55
- * 服务器名称
56
- */
57
- name?: string
58
-
59
- /**
60
- * 服务器版本
61
- */
62
- version?: string
63
-
64
- /**
65
- * 服务器运行配置
66
- */
67
- devServer: DevServerType
68
-
69
- module?: {
70
- rules: Array<{
71
- test: RegExp
72
- use: LoaderType
73
- }>
74
- }
75
- }
76
-
1
+
2
+ interface DevServerType {
3
+
4
+ /**
5
+ * 是否自动打开浏览器,默认false,true表示打开
6
+ *
7
+ * 也可以是一段地址,比如设置open=“docs/index.html”
8
+ */
9
+ open?: boolean | string
10
+
11
+ /**
12
+ * 服务器端口号
13
+ */
14
+ port: number
15
+
16
+ /**
17
+ * 服务器根路径
18
+ */
19
+ baseUrl: string
20
+
21
+ /**
22
+ * 是否开启304缓存,默认开启
23
+ */
24
+ cache: boolean
25
+
26
+ /**
27
+ * 是否开启应用市场,默认true表示开启
28
+ */
29
+ website: boolean
30
+
31
+ intercept?: Array<InterceptType>
32
+
33
+ proxy?: {
34
+ [key: string]: {
35
+ target: string
36
+ pathRewrite?: {
37
+ [key: string]: string
38
+ }
39
+ }
40
+ }
41
+ }
42
+
43
+ interface InterceptType {
44
+ test: RegExp
45
+ handler(request: any, response: any): void
46
+ }
47
+
48
+ interface LoaderType {
49
+ (source: string): string
50
+ }
51
+
52
+ interface ConfigType {
53
+
54
+ /**
55
+ * 服务器名称
56
+ */
57
+ name?: string
58
+
59
+ /**
60
+ * 服务器版本
61
+ */
62
+ version?: string
63
+
64
+ /**
65
+ * 服务器运行配置
66
+ */
67
+ devServer: DevServerType
68
+
69
+ module?: {
70
+ rules: Array<{
71
+ test: RegExp
72
+ use: LoaderType
73
+ }>
74
+ }
75
+ }
76
+
77
77
  export default function (config?: ConfigType): void