@cloudbase/framework-plugin-low-code 1.0.3-beta.4 → 1.0.3-beta.7

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/lib/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -547,7 +551,6 @@ class LowCodePlugin extends framework_core_1.Plugin {
547
551
  });
548
552
  }
549
553
  deploy() {
550
- var _a;
551
554
  return __awaiter(this, void 0, void 0, function* () {
552
555
  try {
553
556
  this._time("DEPLOY");
@@ -575,7 +578,7 @@ class LowCodePlugin extends framework_core_1.Plugin {
575
578
  }
576
579
  catch (e) {
577
580
  this.api.logger.error(`${this.api.emoji('🚀')} custom publish fail: ${JSON.stringify(e)}`);
578
- if (((_a = e) === null || _a === void 0 ? void 0 : _a.code) !== 'ResourceNotFound') {
581
+ if ((e === null || e === void 0 ? void 0 : e.code) !== 'ResourceNotFound') {
579
582
  throw e;
580
583
  }
581
584
  }
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/framework-plugin-low-code",
3
- "version": "1.0.3-beta.4",
3
+ "version": "1.0.3-beta.7",
4
4
  "description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
5
5
  "author": "yhsunshining@gmail.com",
6
6
  "homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
@@ -13,7 +13,8 @@
13
13
  },
14
14
  "files": [
15
15
  "lib",
16
- "template"
16
+ "template",
17
+ "scripts"
17
18
  ],
18
19
  "publishConfig": {
19
20
  "access": "public"
@@ -29,63 +30,41 @@
29
30
  "prebuild": "rm -rf ./lib && rm -rf ./tsconfig.tsbuildinfo && npm run template",
30
31
  "build": "tsc",
31
32
  "test": "jest",
32
- "link": "node scripts/link-packages.js"
33
+ "link": "node scripts/link-packages.js",
34
+ "postinstall": "node scripts/postinstall.js"
33
35
  },
34
36
  "bugs": {
35
37
  "url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
36
38
  },
37
39
  "dependencies": {
38
- "@cloudbase/cals": "^0.3.35",
40
+ "@cloudbase/cals": "^0.3.37",
39
41
  "@cloudbase/framework-core": "^1.8.16",
40
42
  "@cloudbase/framework-plugin-auth": "^1.8.16",
41
- "@cloudbase/framework-plugin-mp": "^1.9.5-beta.0",
43
+ "@cloudbase/framework-plugin-mp": "1.9.5-beta.0",
42
44
  "@cloudbase/framework-plugin-website": "^1.8.17",
43
- "@cloudbase/lowcode-builder": "^1.0.10",
45
+ "@cloudbase/lowcode-builder": "^1.0.16",
44
46
  "@formily/react-schema-renderer": "1.1.7",
45
47
  "archiver": "^4.0.1",
46
- "axios": "^0.21.0",
47
- "chalk": "^2.4.2",
48
- "command-exists": "^1.2.9",
49
48
  "compressing": "^1.4.0",
50
49
  "cos-nodejs-sdk-v5": "^2.8.2",
51
50
  "cross-spawn": "^6.0.5",
52
51
  "fs-extra": "^7.0.1",
53
- "json-schema-defaults": "^0.4.0",
54
52
  "less": "^4.0.0",
55
53
  "lodash": "^4.17.11",
56
- "lodash.clone": "^4.5.0",
57
- "lodash.get": "^4.4.2",
58
- "lodash.set": "^4.3.2",
59
- "lodash.template": "^4.5.0",
60
- "lodash.uniqby": "^4.7.0",
61
54
  "merge-package-json": "^0.1.3",
62
55
  "miniprogram-ci": "^1.8.0",
63
- "postcss": "^8.3.6",
64
- "postcss-pxtorem": "^6.0.0",
65
- "prettier": "^2.0.5",
66
- "qrcode": "^1.4.4",
67
- "react": "^16.12.0",
68
- "react-dom": "^16.8.6",
69
- "react-eva": "^1.1.12",
70
- "symlink-dir": "^3.1.1",
71
- "webpack": "^4.41.4",
72
- "xml-js": "^1.6.11"
56
+ "qrcode": "^1.4.4"
73
57
  },
74
58
  "devDependencies": {
75
59
  "@lerna/create-symlink": "^4.0.0",
76
60
  "@types/archiver": "^3.1.0",
77
- "@types/command-exists": "^1.2.0",
78
61
  "@types/cross-spawn": "^6.0.2",
79
62
  "@types/fs-extra": "^9.0.1",
80
63
  "@types/less": "^3.0.1",
81
- "@types/lodash.get": "^4.4.6",
82
- "@types/lodash.template": "^4.5.0",
83
64
  "@types/node": "^13.9.8",
84
- "@types/react": "^16.9.49",
85
- "@types/webpack": "^4.41.22",
86
65
  "@types/weixin-app": "^2.9.0",
87
66
  "csstype": "^2.6.10",
88
67
  "jest": "^26.0.1",
89
- "typescript": "^3.8.3"
68
+ "typescript": "^4.7.4"
90
69
  }
91
70
  }
@@ -0,0 +1,31 @@
1
+ #!/bin/bash
2
+ set -x
3
+
4
+ NPM_VERSION=$(node -e "(function () { console.log(require('./package.json').version) })()")
5
+ NPM_NAME=$(node -e "(function () { console.log(require('./package.json').name) })()")
6
+ # 现网版本号
7
+ VERSION=0.6.17
8
+ # 产出文件名
9
+ NAME=plugin.tar.gz
10
+ # 产出目录,默认:脚本执行目录
11
+ DIST_PATH=`pwd`
12
+
13
+ cd $TMPDIR
14
+ # 清理历史目录
15
+ rm -rf $NPM_NAME/$NPM_VERSION
16
+ # 创建产出目录
17
+ mkdir -p $NPM_NAME/$NPM_VERSION
18
+ cd $NPM_NAME/$NPM_VERSION
19
+ pwd
20
+ # 安装包,@todo 目前保持老打包逻辑(安装方式),这块是否可以考虑不安装直接使用项目构建产出
21
+ npm i $NPM_NAME@$NPM_VERSION
22
+ cd node_modules/$NPM_NAME
23
+ pwd
24
+ # 安装生产依赖
25
+ yarn --production
26
+ # 更换版本号为现网版本号 0.6.17
27
+ npm version $VERSION
28
+ # 打包
29
+ tar -zcvf $NAME ./*
30
+ # 拷贝到产出目录
31
+ mv ./$NAME $DIST_PATH
@@ -0,0 +1,31 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const glob = require('glob');
4
+
5
+ const chokidar = require('chokidar');
6
+ const TEMPLATE_PATH = path.join(__dirname, '../template/generator');
7
+
8
+ // One-liner for current directory
9
+ generateTemplate();
10
+ if (process.env.npm_config_watch) {
11
+ chokidar.watch(TEMPLATE_PATH).on('all', (event, path) => {
12
+ console.log(event, path);
13
+ generateTemplate();
14
+ });
15
+ }
16
+
17
+ function generateTemplate() {
18
+ const files = glob.sync('**/*', { cwd: TEMPLATE_PATH, nodir: true });
19
+ const filesObj = files.reduce((obj, file) => {
20
+ obj[`/src/${file}`] = {
21
+ code: fs.readFileSync(path.join(TEMPLATE_PATH, file), {
22
+ encoding: 'utf8',
23
+ }),
24
+ };
25
+ return obj;
26
+ }, {});
27
+ fs.writeFileSync(
28
+ path.join(__dirname, '../src/generator/template.ts'),
29
+ `export default ${JSON.stringify(filesObj, null, 2)}`
30
+ );
31
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Tencent is pleased to support the open source community by making CloudBaseFramework - 云原生一体化部署工具 available.
3
+ *
4
+ * Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
5
+ *
6
+ * Please refer to license text included with this package for license details.
7
+ */
8
+
9
+ const link = require('./link');
10
+
11
+ link();
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Tencent is pleased to support the open source community by making CloudBaseFramework - 云原生一体化部署工具 available.
3
+ *
4
+ * Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
5
+ *
6
+ * Please refer to license text included with this package for license details.
7
+ */
8
+
9
+ const os = require('os');
10
+ const fs = require('fs');
11
+ const del = require('del');
12
+ const path = require('path');
13
+ const mkdirp = require('mkdirp');
14
+ const { execSync } = require('child_process');
15
+ const { createSymlink } = require('@lerna/create-symlink');
16
+
17
+ const globalNpmPath = execSync('npm root -g', {
18
+ encoding: 'utf-8',
19
+ }).trim();
20
+ // 如果不支持workspace 可以用下面写死
21
+ // const globalNpmPath = '/usr/local/lib/node_modules';
22
+
23
+ const pluginRegistry = path.join(os.homedir(), 'cloudbase-framework/registry');
24
+
25
+ module.exports = async function main() {
26
+ // await linkCore();
27
+ initRegistry();
28
+ await linkPlugins();
29
+ };
30
+
31
+ async function linkCore() {
32
+ await link(
33
+ path.join(process.cwd(), 'packages/framework-core'),
34
+ path.join(globalNpmPath, '@cloudbase/cli'),
35
+ '@cloudbase/framework-core'
36
+ );
37
+ }
38
+
39
+ function initRegistry() {
40
+ if (!fs.existsSync(pluginRegistry)) {
41
+ mkdirp.sync(pluginRegistry, { recursive: true });
42
+ }
43
+ const packageJSON = path.join(pluginRegistry, 'package.json');
44
+ if (!fs.existsSync(packageJSON)) {
45
+ fs.writeFileSync(
46
+ packageJSON,
47
+ JSON.stringify({
48
+ name: 'cloudbase-framework-registry',
49
+ })
50
+ );
51
+ }
52
+ }
53
+
54
+ async function linkPlugins() {
55
+ const files = ['framework-plugin-low-code'];
56
+
57
+ const plugins = files.filter((file) => file.includes('plugin'));
58
+ // 插件列表
59
+ console.log(plugins);
60
+
61
+ for (const plugin of plugins) {
62
+ console.log('\n', 'Link Plugin', plugin, '\n');
63
+ // 创建软连接
64
+ await link(
65
+ path.join(process.cwd()),
66
+ pluginRegistry,
67
+ `@cloudbase/${plugin}`
68
+ );
69
+ }
70
+ }
71
+
72
+ // 将 global tcb cli 工具中的 framework-core link 到 packages/framework-core
73
+ async function link(src, dest, packageName) {
74
+ const prevCwd = process.cwd();
75
+ const destPlugin = path.join(dest, 'node_modules', '@cloudbase');
76
+ // 确保目录存在
77
+ mkdirp.sync(destPlugin);
78
+ // 切换 cwd
79
+ process.chdir(destPlugin);
80
+ console.log('创建软连接:', process.cwd());
81
+ const pathName = packageName.replace('@cloudbase/', '');
82
+ // 删除已存在的文件
83
+ if (fs.existsSync(pathName)) {
84
+ del.sync([pathName]);
85
+ }
86
+ console.log('src', src);
87
+ console.log('pathName', pathName);
88
+ await createSymlink(src, pathName, 'junction');
89
+ // 切回源目录
90
+ process.chdir(prevCwd);
91
+ }
@@ -0,0 +1,47 @@
1
+ const spawn = require('cross-spawn');
2
+ const fs = require('fs-extra');
3
+ const path = require('path');
4
+
5
+ const packageName = 'postcss@^8';
6
+ function installDependencies(targetDir) {
7
+ if (!process.env.CLOUDBASE_CIID) {
8
+ return;
9
+ }
10
+
11
+ // try {
12
+ // let { stdout } = spawn.sync('yarn', ['-v']);
13
+ // let str = stdout.toString();
14
+ // if (Number(str.split('.')?.[0]) <= 1) {
15
+ // yarnExists = true;
16
+ // }
17
+ // } catch (e) {}
18
+ try {
19
+ let yarnExists = false;
20
+
21
+ const npmOptions = ['--prefer-offline', '--no-audit', '--progress=false', '--production', '--no-package-lock'];
22
+
23
+ let installProcess;
24
+ // 云端构建, 选用 npm
25
+ const installlProcessOptions = {
26
+ cwd: targetDir,
27
+ env: { ...process.env, NODE_ENV: '' },
28
+ stdio: 'inherit',
29
+ };
30
+
31
+ console.log('post install postcss in ' + targetDir);
32
+
33
+ if (yarnExists && !process.env.CLOUDBASE_CIID) {
34
+ const addPackage = packageName ? ['add', packageName] : [];
35
+
36
+ installProcess = spawn.sync('yarn', [...addPackage], installlProcessOptions);
37
+ } else {
38
+ installProcess = spawn.sync('npm', ['install', packageName, ...npmOptions], installlProcessOptions);
39
+ }
40
+ fs.removeSync(path.join(path.join(targetDir, 'yarn.lock')));
41
+ } catch (e) {
42
+ console.log(e.message);
43
+ }
44
+ }
45
+
46
+ // installDependencies(path.join(__dirname, '../'));
47
+ installDependencies('/root/cloudbase-framework/registry');
@@ -0,0 +1,16 @@
1
+ const fs = require('fs-extra');
2
+ const path = require('path');
3
+
4
+ function installDependencies(targetDir) {
5
+ if (!process.env.CLOUDBASE_CIID) {
6
+ return;
7
+ }
8
+
9
+ try {
10
+ const lockPath = path.join(path.join(targetDir, 'package-lock.json'));
11
+ console.log('delete ' + lockPath);
12
+ fs.removeSync(lockPath);
13
+ } catch (e) {}
14
+ }
15
+
16
+ installDependencies(path.resolve('~/test/aaa/ttt/registry'));
@@ -218,6 +218,7 @@ export async function checkAnonymous() {
218
218
  * 检查页面权限
219
219
  **/
220
220
  export async function checkAuth(app, appId, $page) {
221
+ return true
221
222
  <% if (isAdminPortal || isXPage) { %>return true;<% } %>
222
223
  app.showNavigationBarLoading();
223
224
  const { loginConfigVersion } = app.__internal__.getConfig();
@@ -1,456 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="zh-cn">
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta http-equiv="X-UA-Compatible" content="IE=9" />
6
- <meta name="renderer" content="webkit|ie-stand" />
7
- <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no,viewport-fit=cover" />
8
- <meta name="format-detection" content="telephone=no" />
9
- <meta name="description" content="<%= meta.desc %>" />
10
- <script crossorigin="anonymous" src="https://cdn-go.cn/aegis/aegis-sdk/latest/aegis.min.js?v=1"></script>
11
- <script>
12
- <% if(!isAdminPortal){ %>
13
- const _aegis = new Aegis({
14
- id: 'lXHFsBpTjIzNADiczY', // 项目ID,即上报key
15
- reportApiSpeed: true, // 接口测速
16
- reportAssetSpeed: true, // 静态资源测速
17
- spa: true,
18
- ext1: '<%=appId%>',
19
- });
20
- <% } else {%>
21
- const _aegis = new Aegis({
22
- id: 'lXHFsBpTrKcnOMqTRQ', // 项目ID,即上报key
23
- reportApiSpeed: false, // 接口测速
24
- reportAssetSpeed: false, // 静态资源测速
25
- spa: true,
26
- ext1: '<%=appId%>',
27
- });
28
- <% }%>
29
- window._aegis = _aegis;
30
- window._aegis_inited = Date.now()
31
- </script>
32
- <title><%= meta.title %></title>
33
- <% if(delevopment){ %>
34
- <!-- <script src="https://cdn.jsdelivr.net/npm/eruda"></script>
35
- <script>
36
- eruda.init();
37
- </script> -->
38
- <% }%> <% Array.isArray(meta.jsApis) && meta.jsApis.filter(function(item){return !!item}).forEach(function(jsApi){%>
39
- <script src="<%=jsApi %>"></script>
40
- <% })%>
41
-
42
- <!-- 重置浏览器样式 -->
43
- <style type="text/css">
44
- .clearfix::before,
45
- .clearfix::after {
46
- content: '';
47
- display: table;
48
- }
49
-
50
- .clearfix::after {
51
- clear: both;
52
- }
53
-
54
- html {
55
- -ms-text-size-adjust: 100%;
56
- -webkit-text-size-adjust: 100%;
57
- -webkit-tap-highlight-color: transparent;
58
- height: 100%;
59
- }
60
-
61
- body {
62
- margin: 0;
63
- font-size: 14px;
64
- font-family: 'Helvetica Neue', Helvetica, 'Microsoft Yahei', STHeiTi, Arial, sans-serif;
65
- line-height: 1.5;
66
- color: #333;
67
- background-color: #fff;
68
- min-height: 100%;
69
- }
70
-
71
- body > #react-body {
72
- height: 100%;
73
- }
74
-
75
- .weapps-page {
76
- min-height: 100%;
77
- }
78
-
79
- article,
80
- aside,
81
- details,
82
- figcaption,
83
- figure,
84
- footer,
85
- header,
86
- hgroup,
87
- main,
88
- menu,
89
- nav,
90
- section,
91
- summary {
92
- display: block;
93
- }
94
-
95
- audio,
96
- canvas,
97
- progress,
98
- video {
99
- display: inline-block;
100
- }
101
-
102
- audio:not([controls]) {
103
- display: none;
104
- height: 0;
105
- }
106
-
107
- progress {
108
- vertical-align: baseline;
109
- }
110
-
111
- [hidden],
112
- template {
113
- display: none;
114
- }
115
-
116
- a {
117
- background: transparent;
118
- text-decoration: none;
119
- color: #08c;
120
- }
121
-
122
- a:active {
123
- outline: 0;
124
- }
125
-
126
- abbr[title] {
127
- border-bottom: 1px dotted;
128
- }
129
-
130
- b,
131
- strong {
132
- font-weight: bold;
133
- }
134
-
135
- dfn {
136
- font-style: italic;
137
- }
138
-
139
- mark {
140
- background: #ff0;
141
- color: #000;
142
- }
143
-
144
- small {
145
- font-size: 80%;
146
- }
147
-
148
- sub,
149
- sup {
150
- font-size: 75%;
151
- line-height: 0;
152
- position: relative;
153
- vertical-align: baseline;
154
- }
155
-
156
- sup {
157
- top: -0.5em;
158
- }
159
-
160
- sub {
161
- bottom: -0.25em;
162
- }
163
-
164
- img {
165
- border: 0;
166
- vertical-align: middle;
167
- }
168
-
169
- svg:not(:root) {
170
- overflow: hidden;
171
- }
172
-
173
- pre {
174
- overflow: auto;
175
- white-space: pre;
176
- white-space: pre-wrap;
177
- word-wrap: break-word;
178
- }
179
-
180
- code,
181
- kbd,
182
- pre,
183
- samp {
184
- font-family: monospace, monospace;
185
- font-size: 1em;
186
- }
187
-
188
- button,
189
- input,
190
- optgroup,
191
- select,
192
- textarea {
193
- color: inherit;
194
- font: inherit;
195
- margin: 0;
196
- vertical-align: middle;
197
- }
198
-
199
- button,
200
- input,
201
- select {
202
- overflow: visible;
203
- }
204
-
205
- button,
206
- select {
207
- text-transform: none;
208
- }
209
-
210
- button,
211
- html input[type='button'],
212
- input[type='reset'],
213
- input[type='submit'] {
214
- -webkit-appearance: button;
215
- cursor: pointer;
216
- }
217
-
218
- [disabled] {
219
- cursor: default;
220
- }
221
-
222
- button::-moz-focus-inner,
223
- input::-moz-focus-inner {
224
- border: 0;
225
- padding: 0;
226
- }
227
-
228
- input {
229
- line-height: normal;
230
- }
231
-
232
- input[type='checkbox'],
233
- input[type='radio'] {
234
- box-sizing: border-box;
235
- padding: 0;
236
- }
237
-
238
- input[type='number']::-webkit-inner-spin-button,
239
- input[type='number']::-webkit-outer-spin-button {
240
- height: auto;
241
- }
242
-
243
- input[type='search'] {
244
- -webkit-appearance: textfield;
245
- box-sizing: border-box;
246
- }
247
-
248
- input[type='search']::-webkit-search-cancel-button,
249
- input[type='search']::-webkit-search-decoration {
250
- -webkit-appearance: none;
251
- }
252
-
253
- fieldset {
254
- border: 1px solid #c0c0c0;
255
- margin: 0 2px;
256
- padding: 0.35em 0.625em 0.75em;
257
- }
258
-
259
- legend {
260
- border: 0;
261
- padding: 0;
262
- }
263
-
264
- textarea {
265
- overflow: auto;
266
- resize: vertical;
267
- vertical-align: top;
268
- }
269
-
270
- optgroup {
271
- font-weight: bold;
272
- }
273
-
274
- input,
275
- select,
276
- textarea {
277
- outline: 0;
278
- }
279
-
280
- textarea,
281
- input {
282
- -webkit-user-modify: read-write-plaintext-only;
283
- }
284
-
285
- input::-ms-clear,
286
- input::-ms-reveal {
287
- display: none;
288
- }
289
-
290
- input::-moz-placeholder,
291
- textarea::-moz-placeholder {
292
- color: #999;
293
- }
294
-
295
- input:-ms-input-placeholder,
296
- textarea:-ms-input-placeholder {
297
- color: #999;
298
- }
299
-
300
- input::-webkit-input-placeholder,
301
- textarea::-webkit-input-placeholder {
302
- color: #999;
303
- }
304
-
305
- .placeholder {
306
- color: #999;
307
- }
308
-
309
- table {
310
- border-collapse: collapse;
311
- border-spacing: 0;
312
- }
313
-
314
- td,
315
- th {
316
- padding: 0;
317
- }
318
-
319
- h1,
320
- h2,
321
- h3,
322
- h4,
323
- h5,
324
- h6,
325
- p,
326
- figure,
327
- form,
328
- blockquote {
329
- margin: 0;
330
- }
331
-
332
- ul,
333
- ol,
334
- li,
335
- dl,
336
- dd {
337
- margin: 0;
338
- padding: 0;
339
- }
340
-
341
- ul,
342
- ol {
343
- list-style: none outside none;
344
- }
345
-
346
- h1,
347
- h2,
348
- h3 {
349
- line-height: 2;
350
- font-weight: normal;
351
- }
352
-
353
- h1 {
354
- font-size: 18px;
355
- }
356
-
357
- h2 {
358
- font-size: 16px;
359
- }
360
-
361
- h3 {
362
- font-size: 14px;
363
- }
364
-
365
- i {
366
- font-style: normal;
367
- }
368
-
369
- * {
370
- box-sizing: border-box;
371
- }
372
-
373
- .hide {
374
- display: none;
375
- }
376
- </style>
377
- </head>
378
-
379
- <body data-weui-theme="light">
380
- <div id="react-body" class="main-wrap"></div>
381
- <% if(!isAdminPortal){ %>
382
- <script src="/weda-config/weda-private.js"></script>
383
- <script src="//static.cloudbase.net/cloudbase-js-sdk/2.4.0-alpha.0/cloudbase.full.js?v=1"></script>
384
- <% }%>
385
- <script>
386
- if (window.cloudbase) {
387
- const _callFunction = window.cloudbase.__proto__.callFunction;
388
- window.cloudbase.__proto__.callFunction = function (args) {
389
- let promise = _callFunction.call(window.cloudbase, ...arguments);
390
- if (promise instanceof Promise) {
391
- return promise
392
- .then(function (res) {
393
- const { name, data = {} } = args || {};
394
- try {
395
- if (res.result && res.result.code) {
396
- _aegis.report({
397
- msg: '[' + name + ':' + data.methodName + ']: ' + (res.result.message || '函数调用失败'),
398
- level: '16',
399
- ext2: res.result.code,
400
- ext3: res.requestId,
401
- trace: 'trace',
402
- });
403
- }
404
- } catch (e) {}
405
- return res;
406
- })
407
- .catch(function (e) {
408
- try {
409
- _aegis.report({
410
- msg: '[' + name + ':' + data.methodName + ']: ' + (e.message || '函数调用失败'),
411
- level: '16',
412
- ext2: e.code,
413
- ext3: e.requestId,
414
- trace: 'trace',
415
- });
416
- } catch (e) {}
417
- throw e;
418
- });
419
- } else {
420
- return promise;
421
- }
422
- };
423
- }
424
- </script>
425
- <script
426
- crossorigin
427
- src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_npm/react@16.14.0/umd/react.production.min.js"
428
- ></script>
429
- <script
430
- crossorigin
431
- src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_npm/react-dom@16.14.0/umd/react-dom.production.min.js"
432
- ></script>
433
- <script
434
- src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.2/_url/ajax/libs/mobx/5.15.7/mobx.umd.js"
435
- crossorigin="anonymous"
436
- ></script>
437
- <script
438
- crossorigin="anonymous"
439
- src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.12/dist/h5.browser.js"
440
- ></script>
441
- <script>
442
- // zxing polifill
443
- if (!this.globalThis) {
444
- this.globalThis = this;
445
- }
446
- </script>
447
- <script
448
- crossorigin="anonymous"
449
- src="https://qbase.cdn-go.cn/lcap/lcap-resource-cdngo/-/0.1.2/_url/npm/@zxing/library@0.18.6/umd/index.min.js"
450
- ></script>
451
- <script
452
- crossorigin="anonymous"
453
- src="https://qbase.cdn-go.cn//lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-client@0.2.15/dist/web.browser.js"
454
- ></script>
455
- </body>
456
- </html>
@@ -1,63 +0,0 @@
1
- {
2
- "name": "lcap-<%= appId%>",
3
- "version": "1.0.0",
4
- "scripts": {
5
- "build-web": "webpack --config ./webpack/webpack.web.prod.js"
6
- },
7
- "dependencies": {
8
- "@cloudbase/js-sdk": "2.4.0-alpha.0",
9
- "@cloudbase/weda-client": "0.2.12",
10
- "@tcwd/weapps-core": "2.2.6",
11
- "@tcwd/weapps-sdk": "1.2.10",
12
- "@zxing/library": "^0.18.6",
13
- "lodash": "^4.17.19",
14
- "mobx": "^5.15.4",
15
- "mobx-react-lite": "^2.0.7",
16
- "path-to-regexp": "^1.7.0",
17
- "react": "^16.12.0",
18
- "react-dom": "^16.8.6",
19
- "react-router-dom": "^5.1.2",
20
- "regenerator-runtime": "^0.13.5"
21
- },
22
- "devDependencies": {
23
- "@types/react": "^16.9.49",
24
- "autoprefixer": "^9.5.1",
25
- "babel-loader": "^8.1.0",
26
- "@babel/core": "^7.11.6",
27
- "@babel/polyfill": "^7.7.0",
28
- "@babel/preset-env": "^7.4.4",
29
- "@babel/preset-react": "^7.0.0",
30
- "@babel/plugin-proposal-decorators": "^7.4.4",
31
- "@babel/plugin-proposal-export-default-from": "^7.5.2",
32
- "@babel/plugin-proposal-export-namespace-from": "^7.5.2",
33
- "@babel/plugin-proposal-partial-application": "^7.4.4",
34
- "@babel/plugin-proposal-pipeline-operator": "^7.5.0",
35
- "@babel/plugin-transform-modules-commonjs": "^7.10.4",
36
- "babel-plugin-import": "^1.13.0",
37
- "base64-inline-loader": "^1.1.1",
38
- "copy-webpack-plugin": "^6.2.1",
39
- "css-loader": "^5",
40
- "happypack": "^5.0.1",
41
- "dart-sass": "^1.24.0",
42
- "postcss": "^8.3.6",
43
- "postcss-pxtorem": "^6.0.0",
44
- "postcss-loader": "^4.0.3",
45
- "postcss-css-variables": "^0.16.0",
46
- "qiankun": "^2.7.0",
47
- "less": "^4.0.0",
48
- "less-loader": "^7.0.1",
49
- "loader-utils": "^3.2.0",
50
- "sass-loader": "^8.0.0",
51
- "terser-webpack-plugin": "^3.0.2",
52
- "mini-css-extract-plugin": "^0.8.0",
53
- "hard-source-webpack-plugin": "^0.13.1",
54
- "html-webpack-plugin": "^3.2.0",
55
- "ts-loader": "^8.3.0",
56
- "typescript": "^4.4.4",
57
- "vue-loader": "14",
58
- "vue-template-compiler": "^2.6.14",
59
- "webpack": "^4.41.4",
60
- "webpack-cli": "^4.2.0",
61
- "webpack-dev-server": "^3.11.0"
62
- }
63
- }
@@ -1,119 +0,0 @@
1
- const webpackDevServer = require('webpack-dev-server')
2
- const webpack = require('webpack')
3
- const os = require('os')
4
- const fs = require('fs')
5
- const path = require('path')
6
- const argv = require('yargs').argv
7
- const config = require('./webpack.web.prod')
8
- const { appConfig } = require('../mainAppData.json')
9
- const { window = {} } = appConfig
10
- const isApp = <%=isApp %>
11
-
12
-
13
- function getDevServerConf() {
14
- if (!argv.devServerConf) {
15
- return {}
16
- }
17
- if (!argv.devServerConf.endsWith('.js')) {
18
- console.error('参数请输入 --devServerConf config.js')
19
- } else {
20
- const devServerConfPath = path.resolve(process.cwd(), argv.devServerConf || '')
21
- if (!fs.existsSync(devServerConfPath)) {
22
- console.error(devServerConfPath, 'does not exists')
23
- return {}
24
- }
25
- let conf = require(devServerConfPath)
26
- if (!conf || typeof conf !== 'object') {
27
- console.error(devServerConfPath, 'must have module.exports={}')
28
- } else {
29
- return conf
30
- }
31
- }
32
- return {}
33
- }
34
-
35
- // const openBrowser = require('open');
36
- function getIPAdress() {
37
- const interfaces = os.networkInterfaces()
38
- for (const devName in interfaces) {
39
- const iface = interfaces[devName]
40
- for (let i = 0; i < iface.length; i++) {
41
- const alias = iface[i]
42
- if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) {
43
- return alias.address
44
- }
45
- }
46
- }
47
- }
48
-
49
- const port = 8001
50
- const ip = getIPAdress()
51
- let basename = ''
52
- let publicPath = ''
53
- if (!isApp) {
54
- basename = window.basename || ''
55
- if (basename.startsWith('/')) {
56
- basename = basename.replace('/', '')
57
- }
58
- publicPath = window.publicPath || ''
59
- }
60
-
61
- console.log('>>>>>>>>>>>>>>>>>>>>> basename is ', basename)
62
- console.log('>>>>>>>>>>>>>>>>>>>>> publicPath is:', publicPath)
63
- const options = {
64
- hot: true,
65
- host: ip,
66
- hotOnly: true,
67
- historyApiFallback: {
68
- verbose: true,
69
- rewrites: [
70
- {
71
- from: /^\/(.*)\.(css|js)$/,
72
- to: function(context) {
73
- // /^\/([^\.]*)\.(css|js)$/
74
- console.log('>>>>>>>>>>>>>>>>> got in css|js!', context.parsedUrl.pathname)
75
- const { assets = [] } = window
76
- const isInAssets = assets.includes(context.parsedUrl.pathname)
77
- return context.parsedUrl.pathname.replace(publicPath, '/')
78
- },
79
- },
80
- {
81
- from: new RegExp(`${basename}\/?(.*)$`),
82
- to: function(context) {
83
- console.log('>>>>>>>>>>>>>>>>> got in html!')
84
- return 'index.html'
85
- },
86
- },
87
- ],
88
- },
89
- contentBase: [path.join(__dirname, 'assets')],
90
- watchOptions: {
91
- poll: 600,
92
- ignored: /node_modules|preview|dist|html|webpack|gsd-kbone-react/,
93
- },
94
- open: {
95
- app: ['Google Chrome', '--incognito', '--other-flag'],
96
- },
97
- openPage: basename,
98
- disableHostCheck: true,
99
- compress: true
100
- }
101
-
102
- function startDevServer(conf) {
103
- console.log('start startDevServer in webpack, env:', process.env.NODE_PATH)
104
- let _options = Object.assign(options, conf)
105
- console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>')
106
- console.log('Current webpack-dev-server config is: ')
107
- console.log(_options)
108
- console.log('<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<')
109
- webpackDevServer.addDevServerEntrypoints(config, _options)
110
-
111
- const compiler = webpack(config)
112
- const server = new webpackDevServer(compiler, _options)
113
-
114
- server.listen(port, '0.0.0.0', () => {
115
- console.log(`调试环境端口启动在 http://${ip}:${port}/${basename}`)
116
- })
117
- }
118
-
119
- startDevServer(getDevServerConf())
@@ -1,28 +0,0 @@
1
- // Stolen from https://github.com/facebook/create-react-app/blob/cee26589ff919e946030a5651a93ccba78a93293/packages/react-dev-utils/getCSSModuleLocalIdent.js
2
- /**
3
- * Copyright (c) 2015-present, Facebook, Inc.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
-
9
- 'use strict';
10
-
11
- const loaderUtils = require('loader-utils');
12
- const path = require('path');
13
-
14
- module.exports = function getLocalIdent(context, localIdentName, localName, options) {
15
- // Use the filename or folder name, based on some uses the index.js / index.module.(css|scss|sass) project style
16
- const fileNameOrFolder = context.resourcePath.match(/index\.module\.(css|scss|sass)$/) ? '[folder]' : '[name]';
17
- // Create a hash based on a the file location and class name. Will be unique across a project, and close to globally unique.
18
- const hash = loaderUtils.getHashDigest(
19
- path.posix.relative(context.rootContext, context.resourcePath) + localName,
20
- 'md5',
21
- 'base64',
22
- 5,
23
- );
24
- // Use loaderUtils to find the file or folder name
25
- const className = loaderUtils.interpolateName(context, fileNameOrFolder + '_' + localName + '__' + hash, options);
26
- // Remove the .module that appears in every classname when based on the file and replace all "." with "_".
27
- return className.replace('.module_', '_').replace(/\./g, '_');
28
- };
@@ -1,306 +0,0 @@
1
- const path = require('path');
2
- const webpack = require('webpack');
3
- const TerserPlugin = require('terser-webpack-plugin');
4
- const HtmlWebpackPlugin = require('html-webpack-plugin');
5
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
6
- const CopyWebpackPlugin = require('copy-webpack-plugin');
7
- const themeVars = require('./themeVars');
8
- const getCSSModuleLocalIdent = require('./getCSSModuleLocalIdent');
9
- const HappyPack = require('happypack');
10
- const core = 4;
11
- const happyThreadPool = HappyPack.ThreadPool({ size: core });
12
-
13
- const TS_LOADER_ID = 'ts-loader';
14
- module.exports = function (options) {
15
- const {
16
- context,
17
- entry,
18
- output,
19
- watch,
20
- externals,
21
- resolveModules,
22
- htmlTemplatePath,
23
- htmlTemplateData = {
24
- meta: {},
25
- },
26
- definePlugin = {},
27
- devtool = false,
28
- } = options;
29
-
30
- const babelLoader = {
31
- loader: 'babel-loader',
32
- options: {
33
- compact: false,
34
- cacheDirectory: true,
35
- cwd: context,
36
- presets: [
37
- [
38
- '@babel/preset-env',
39
- {
40
- modules: false,
41
- targets: {
42
- // esmodules: true,
43
- browsers: ['defaults', 'iOS >= 10', 'safari >= 10'],
44
- },
45
- },
46
- ],
47
- '@babel/preset-react',
48
- ],
49
- plugins: [
50
- [
51
- 'babel-plugin-import',
52
- {
53
- libraryName: '@govcloud/gsd-kbone-react',
54
- libraryDirectory: 'lib/components',
55
- camel2DashComponentName: false,
56
- },
57
- ],
58
- '@babel/plugin-proposal-class-properties',
59
- ['@babel/plugin-proposal-decorators', { legacy: true }],
60
- '@babel/plugin-proposal-export-default-from',
61
- '@babel/plugin-proposal-export-namespace-from',
62
- '@babel/plugin-proposal-optional-chaining',
63
- '@babel/plugin-proposal-partial-application',
64
- ['@babel/plugin-proposal-pipeline-operator', { proposal: 'minimal' }],
65
- ].filter(Boolean),
66
- },
67
- };
68
- const typescriptLoader = {
69
- loader: 'ts-loader',
70
- options: {
71
- compilerOptions: {
72
- target: 'ESNext',
73
- module: 'ESNext',
74
- esModuleInterop: true,
75
- },
76
- happyPackMode: true,
77
- transpileOnly: true,
78
- },
79
- };
80
-
81
- let plugins = [
82
- new HappyPack({
83
- id: 'vue',
84
- cache: true,
85
- verbose: true,
86
- loaders: [
87
- babelLoader,
88
- typescriptLoader,
89
- {
90
- loader: 'vue-loader',
91
- options: {
92
- threadMode: true,
93
- loaders: {
94
- js: [babelLoader],
95
- ts: [babelLoader, typescriptLoader],
96
- },
97
- },
98
- },
99
- ],
100
- threadPool: happyThreadPool,
101
- }),
102
- new HappyPack({
103
- id: TS_LOADER_ID,
104
- loaders: [babelLoader, typescriptLoader],
105
- threadPool: happyThreadPool,
106
- }),
107
- new HappyPack({
108
- id: 'babel',
109
- loaders: [babelLoader],
110
- threadPool: happyThreadPool,
111
- }),
112
- new HtmlWebpackPlugin({
113
- template: htmlTemplatePath,
114
- filename: 'index.html',
115
- cache: false,
116
- templateParameters: htmlTemplateData,
117
- }),
118
- new MiniCssExtractPlugin({
119
- filename: '[name].[contenthash].css',
120
- chunkFilename: '[id].[contenthash].css',
121
- }),
122
- new webpack.DefinePlugin(
123
- Object.assign(
124
- {
125
- 'process.env.isMiniprogram': false, // 注入环境变量,用于业务代码判断
126
- 'process.env.SSR': false,
127
- },
128
- definePlugin,
129
- ),
130
- ),
131
- new CopyWebpackPlugin({
132
- patterns: [
133
- {
134
- from: path.resolve(__dirname, '../assets'),
135
- to: '.',
136
- noErrorOnMissing: true,
137
- },
138
- ],
139
- }),
140
- new webpack.HashedModuleIdsPlugin({
141
- hashFunction: 'sha256',
142
- hashDigest: 'hex',
143
- hashDigestLength: 20,
144
- }),
145
- new webpack.EnvironmentPlugin({
146
- SSR: false,
147
- WEBPACK_ENV: 'production',
148
- }),
149
- ];
150
-
151
- const cssLoaders = [
152
- MiniCssExtractPlugin.loader,
153
- {
154
- loader: 'css-loader',
155
- options: {
156
- modules: {
157
- auto: true,
158
- getLocalIdent: getCSSModuleLocalIdent,
159
- },
160
- importLoaders: 2,
161
- },
162
- },
163
- {
164
- loader: 'postcss-loader',
165
- options: {
166
- postcssOptions: {
167
- plugins: [
168
- [
169
- 'postcss-pxtorem',
170
- {
171
- rootValue: 14,
172
- propList: ['*'],
173
- // todo
174
- selectorBlackList: ['.weui-picker__indicator'],
175
- },
176
- ],
177
- ],
178
- },
179
- },
180
- },
181
- ];
182
-
183
- return {
184
- context,
185
- entry,
186
- /**
187
- * 只要是构建都开启 production 以使用精简
188
- */
189
- mode: 'production',
190
- watch,
191
- output,
192
- externals,
193
- cache: {
194
- type: 'memory',
195
- },
196
- devtool: devtool,
197
- resolve: {
198
- extensions: ['.js', '.jsx', '.ts', '.tsx', '.json', '.scss', '.css'],
199
- modules: [...resolveModules],
200
- symlinks: false,
201
- cacheWithContext: false,
202
- alias: {
203
- '@': path.resolve(__dirname, '../src'),
204
- // react: 'preact/compat',
205
- // 'react-dom/test-utils': 'preact/test-utils',
206
- // 'react-dom': 'preact/compat',
207
- },
208
- },
209
- module: {
210
- rules: [
211
- {
212
- test: /\.vue$/,
213
- loader: 'happypack/loader?id=vue',
214
- },
215
- {
216
- test: /\.tsx?$/,
217
- exclude: /node_modules\/(?!@cloudbase\/weda-ui)|gsd-kbone-react/,
218
- use: [`happypack/loader?id=${TS_LOADER_ID}`],
219
- },
220
- {
221
- test: /\.(js|jsx)$/,
222
- exclude:
223
- /node_modules\/(?!(@cloudbase\/weda-ui)|(@tcwd\/vuera)|(@tcwd\/weapps-core)|(@tcwd\/weapps-core))|gsd-kbone-react/,
224
- use: ['happypack/loader?id=babel'],
225
- },
226
- {
227
- test: /\.(scss|sass)$/,
228
- use: [
229
- ...cssLoaders,
230
- {
231
- loader: 'sass-loader',
232
- options: {
233
- implementation: require('dart-sass'),
234
- },
235
- },
236
- ],
237
- },
238
- {
239
- test: /\.css$/,
240
- use: [...cssLoaders],
241
- },
242
- {
243
- test: /\.less$/,
244
- use: [
245
- ...cssLoaders,
246
- {
247
- loader: 'less-loader',
248
- options: {
249
- lessOptions: {
250
- modifyVars: themeVars,
251
- javascriptEnabled: true,
252
- },
253
- },
254
- },
255
- ],
256
- },
257
- {
258
- test: /\.(jpe?g|png|gif|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/,
259
- loader: 'base64-inline-loader',
260
- },
261
- ],
262
- },
263
- plugins,
264
- optimization: {
265
- concatenateModules: true,
266
- noEmitOnErrors: true,
267
- splitChunks: {
268
- maxSize: 3000000,
269
- cacheGroups: {
270
- base: {
271
- test: /(react|react-dom|react-router|react-router-dom|mobx|mobx-react-lite|@cloudbase\/js-sdk)/,
272
- chunks: 'all',
273
- minSize: 500000,
274
- priority: 100, // 优先级
275
- },
276
- utils: {
277
- test: /(lodash|dayjs|axios|kbone-api)/,
278
- chunks: 'all',
279
- priority: 100, // 优先级
280
- },
281
- 'async-commons': {
282
- chunks: 'async',
283
- minChunks: 2,
284
- priority: 20,
285
- },
286
- commons: {
287
- chunks: 'all',
288
- minChunks: 2,
289
- priority: 20,
290
- },
291
- },
292
- },
293
- minimizer: [
294
- new TerserPlugin({
295
- test: /\.js(\?.*)?$/i,
296
- cache: false,
297
- parallel: true,
298
- sourceMap: false,
299
- terserOptions: {
300
- safari10: true,
301
- },
302
- }),
303
- ],
304
- },
305
- };
306
- };