@oipage/cli 0.1.0-alpha.0

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 (81) hide show
  1. package/.github/FUNDING.yml +12 -0
  2. package/.mailmap +1 -0
  3. package/AUTHORS.txt +6 -0
  4. package/CHANGELOG +5 -0
  5. package/LICENSE +21 -0
  6. package/README.md +184 -0
  7. package/bin/WebSocket/decodeWsFrame.js +43 -0
  8. package/bin/WebSocket/encodeWsFrame.js +28 -0
  9. package/bin/WebSocket/headersToJSON.js +26 -0
  10. package/bin/WebSocket/index.js +80 -0
  11. package/bin/data/mineTypes.json +105 -0
  12. package/bin/disk.js +43 -0
  13. package/bin/help.js +51 -0
  14. package/bin/images/file.png +0 -0
  15. package/bin/images/folder.png +0 -0
  16. package/bin/intercept.js +16 -0
  17. package/bin/network.js +22 -0
  18. package/bin/proxy.js +75 -0
  19. package/bin/run +134 -0
  20. package/bin/serve.js +189 -0
  21. package/bin/template/404.html +185 -0
  22. package/bin/tools/deleteEmptyFolder.js +34 -0
  23. package/bin/tools/format.js +76 -0
  24. package/bin/tools/network.js +43 -0
  25. package/bin/tools/openBrowser.js +26 -0
  26. package/bin/tools/resolve404.js +84 -0
  27. package/bin/tools/resolveImport.js +89 -0
  28. package/bin/website-htmls/components/ui-select-file/index.html +9 -0
  29. package/bin/website-htmls/components/ui-select-file/index.js +43 -0
  30. package/bin/website-htmls/components/ui-select-file/index.scss +45 -0
  31. package/bin/website-htmls/dialogs/imageSize/index.html +55 -0
  32. package/bin/website-htmls/dialogs/imageSize/index.js +53 -0
  33. package/bin/website-htmls/dialogs/imageSize/index.scss +141 -0
  34. package/bin/website-htmls/dialogs/index.js +53 -0
  35. package/bin/website-htmls/images/addFile.svg +1 -0
  36. package/bin/website-htmls/images/chart.png +0 -0
  37. package/bin/website-htmls/images/image-editor.png +0 -0
  38. package/bin/website-htmls/images/img-to-pdf.svg +1 -0
  39. package/bin/website-htmls/images/lock.png +0 -0
  40. package/bin/website-htmls/images/logo.png +0 -0
  41. package/bin/website-htmls/images/mosaic.png +0 -0
  42. package/bin/website-htmls/images/recorder-screen.png +0 -0
  43. package/bin/website-htmls/images/size.png +0 -0
  44. package/bin/website-htmls/images/video-player.jpeg +0 -0
  45. package/bin/website-htmls/index.html +18 -0
  46. package/bin/website-htmls/main.js +14 -0
  47. package/bin/website-htmls/pages/App/index.html +7 -0
  48. package/bin/website-htmls/pages/App/index.js +23 -0
  49. package/bin/website-htmls/pages/App/index.scss +44 -0
  50. package/bin/website-htmls/pages/appStore/index.html +6 -0
  51. package/bin/website-htmls/pages/appStore/index.js +20 -0
  52. package/bin/website-htmls/pages/appStore/index.scss +44 -0
  53. package/bin/website-htmls/pages/chart/index.html +9 -0
  54. package/bin/website-htmls/pages/chart/index.js +73 -0
  55. package/bin/website-htmls/pages/chart/index.scss +72 -0
  56. package/bin/website-htmls/pages/home/index.html +20 -0
  57. package/bin/website-htmls/pages/home/index.js +20 -0
  58. package/bin/website-htmls/pages/home/index.scss +88 -0
  59. package/bin/website-htmls/pages/image-editor/index.html +28 -0
  60. package/bin/website-htmls/pages/image-editor/index.js +107 -0
  61. package/bin/website-htmls/pages/image-editor/index.scss +70 -0
  62. package/bin/website-htmls/pages/img-to-pdf/index.html +4 -0
  63. package/bin/website-htmls/pages/img-to-pdf/index.js +45 -0
  64. package/bin/website-htmls/pages/img-to-pdf/index.scss +10 -0
  65. package/bin/website-htmls/pages/recorder-screen/index.html +16 -0
  66. package/bin/website-htmls/pages/recorder-screen/index.js +228 -0
  67. package/bin/website-htmls/pages/recorder-screen/index.scss +53 -0
  68. package/bin/website-htmls/router.config.js +30 -0
  69. package/bin/website-htmls/styles/common.css +44 -0
  70. package/bin/website-htmls/styles/normalize.css +95 -0
  71. package/bin/website-plugins/intercept/chart.js +34 -0
  72. package/bin/website-plugins/intercept/getPackage.js +18 -0
  73. package/bin/website-plugins/intercept/head.js +9 -0
  74. package/bin/website-plugins/intercept/index.js +9 -0
  75. package/bin/website-plugins/intercept/oipage-vislite-intercept.js +31 -0
  76. package/bin/website-plugins/intercept/oipage-zipaper-intercept.js +37 -0
  77. package/bin/website-plugins/loader/index.js +12 -0
  78. package/bin/website-plugins/loader/oipage-html-loader.js +8 -0
  79. package/bin/website-plugins/loader/oipage-scss-loader.js +150 -0
  80. package/package.json +43 -0
  81. package/types/index.d.ts +77 -0
@@ -0,0 +1,12 @@
1
+ const OIPageScssLoader = require("./oipage-scss-loader.js");
2
+ const OIPageHtmlLoader = require("./oipage-html-loader.js");
3
+
4
+ module.exports = {
5
+ rules: [{
6
+ test: /\.scss$/,
7
+ use: OIPageScssLoader
8
+ }, {
9
+ test: /\.html$/,
10
+ use: OIPageHtmlLoader
11
+ }]
12
+ };
@@ -0,0 +1,8 @@
1
+ const { parseTemplate } = require("xhtml-to-json");
2
+
3
+ module.exports = function (source) {
4
+ if (this.entry) return source;
5
+
6
+ this.setFileType("application/javascript");
7
+ return `export default ${JSON.stringify(parseTemplate(source).toJson())}`;
8
+ };
@@ -0,0 +1,150 @@
1
+ // 参考:https://github.com/zxl20070701/zxl20070701.github.io/blob/master/bin/loader/scss.js
2
+ let toSelector = function (preSelectorArray, deep) {
3
+ let selectors = preSelectorArray[0], i, j, k;
4
+ for (i = 1; i < deep; i++) {
5
+ let temp = [];
6
+ for (j = 0; j < selectors.length; j++) {
7
+ for (k = 0; k < preSelectorArray[i].length; k++) {
8
+ temp.push(selectors[j] + preSelectorArray[i][k]);
9
+ }
10
+ }
11
+ selectors = temp;
12
+ }
13
+ return "\n" + (selectors.join(',')) + "{\n";
14
+ };
15
+ let analyseBlock = function (source) {
16
+ let i = -1, currentChar = null;
17
+ let next = function () {
18
+ currentChar = i++ < source.length - 1 ? source[i] : null;
19
+ return currentChar;
20
+ }
21
+ let nextNValue = function (n) {
22
+ return source.substring(i, n + i > source.length ? source.length : n + i);
23
+ }
24
+ let blocks = [];
25
+ let currentBlock = "";
26
+ next();
27
+ while (true) {
28
+ while (new RegExp("[\\x20\\t\\r\\n\\f]").test(currentChar)) {
29
+ next();
30
+ }
31
+ if (currentChar == null) break;
32
+ if (nextNValue(2) == '/*') {
33
+
34
+ next();
35
+ next();
36
+ currentBlock = "/*";
37
+
38
+ while (nextNValue(2) != '*/' && currentChar != null) {
39
+ currentBlock += currentChar;
40
+ next();
41
+ }
42
+ if (currentChar == null) {
43
+ throw new Error('The comment is not closed.');
44
+ }
45
+ currentBlock += "*/";
46
+ next();
47
+ next();
48
+ blocks.push({
49
+ value: currentBlock,
50
+ type: "comment-double"
51
+ });
52
+ }
53
+ else if (nextNValue(2) == '//') {
54
+ currentBlock = '';
55
+
56
+ while (currentChar != '\n' && currentChar != null) {
57
+ currentBlock += currentChar;
58
+ next();
59
+ }
60
+
61
+ blocks.push({
62
+ value: currentBlock,
63
+ type: "comment-single"
64
+ });
65
+
66
+ }
67
+ else if (currentChar == '}') {
68
+
69
+ blocks.push({
70
+ value: "}",
71
+ type: "end"
72
+ });
73
+
74
+ next();
75
+
76
+ }
77
+ else {
78
+
79
+ currentBlock = '';
80
+ while (currentChar != '{' && currentChar != ';' && currentChar != null) {
81
+ currentBlock += currentChar;
82
+ next();
83
+ }
84
+ if (currentChar == null) {
85
+ throw new Error('Statement or code block missing closure.');
86
+ }
87
+ blocks.push({
88
+ value: currentBlock + currentChar,
89
+ type: {
90
+ '{': "begin",
91
+ ';': 'statement'
92
+ }[currentChar]
93
+ });
94
+ next();
95
+ }
96
+ }
97
+ return blocks;
98
+ };
99
+ module.exports = function (source) {
100
+ this.setFileType("application/javascript");
101
+ let blocks = analyseBlock(source + "");
102
+ let i, j, cssCode = "", preSelectorArray = [], deep = 0;
103
+ for (i = 0; i < blocks.length; i++) {
104
+ if (blocks[i].type == 'comment-double') {
105
+ cssCode += blocks[i].value;
106
+ }
107
+ else if (blocks[i].type == 'comment-single') {
108
+ cssCode += "\n/* " + blocks[i].value + " */\n";
109
+ }
110
+ else if (blocks[i].type == 'begin') {
111
+ let preSplit = blocks[i].value.split(',');
112
+ let preSelect = [];
113
+ for (j = 0; j < preSplit.length; j++) {
114
+ preSelect[j] = preSplit[j].replace(/\{$/, '').trim();
115
+ if (/^&/.test(preSelect[j])) {
116
+ preSelect[j] = preSelect[j].replace(/^&/, '');
117
+ } else {
118
+ preSelect[j] = " " + preSelect[j];
119
+ }
120
+ }
121
+ preSelectorArray[deep] = preSelect;
122
+ deep += 1;
123
+ }
124
+ else if (blocks[i].type == 'end') {
125
+ deep -= 1;
126
+ }
127
+ else if (blocks[i].type == 'statement') {
128
+ j = 1;
129
+ let preType = blocks[i - j].type;
130
+ while (['comment-double', 'comment-single'].indexOf(preType) > -1) {
131
+ j += 1;
132
+ preType = blocks[i - j].type;
133
+ }
134
+ if (['end', 'begin'].indexOf(preType) > -1) {
135
+ cssCode += toSelector(preSelectorArray, deep);
136
+ }
137
+ cssCode += "\n" + blocks[i].value + "\n";
138
+ j = 1;
139
+ let nextType = blocks[i + j].type;
140
+ while (['comment-double', 'comment-single'].indexOf(nextType) > -1) {
141
+ j += 1;
142
+ nextType = blocks[i + j].type;
143
+ }
144
+ if (['end', 'begin'].indexOf(nextType) > -1) {
145
+ cssCode += "\n}\n";
146
+ }
147
+ }
148
+ }
149
+ return `export default ${JSON.stringify(cssCode)}`;
150
+ };
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@oipage/cli",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "开发快速助手,一个包含常用功能的命令行工具,旨在提升开发效率",
5
+ "sideEffects": false,
6
+ "main": "./bin/serve.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-alpha.0",
39
+ "vislite": "^1.9.1",
40
+ "xhtml-to-json": "^0.2.1",
41
+ "zipaper": "^0.3.1"
42
+ }
43
+ }
@@ -0,0 +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
+
77
+ export default function (config?: ConfigType): void