@cloudbase/framework-plugin-low-code 1.0.3-beta.0 → 1.0.3-beta.11

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,3 +1,4 @@
1
+ import { IWebRuntimeAppData } from 'src/weapps-core';
1
2
  export declare const CLOUD_FUNCTION_TYPE = "cloud-function";
2
3
  export declare const EXTERNAL_FUNCTION_TYPE = "http";
3
4
  export declare const DATABASE_TYPE = "database";
@@ -8,6 +9,9 @@ export declare function mergeDependencies(...pkgs: any[]): {};
8
9
  export declare function lowercaseKey(obj: any, deep?: boolean): any;
9
10
  export declare function standardizeDataSource(ds: any): any;
10
11
  export declare function getDatasourceProfiles(datasources: any): any;
12
+ export declare function getDataVarProfiles(appData: IWebRuntimeAppData): {
13
+ $global: any[];
14
+ };
11
15
  export declare function getDatasetProfiles(mainAppData: {
12
16
  dataset?: any;
13
17
  rootPath?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"dataSource.d.ts","sourceRoot":"","sources":["../../src/utils/dataSource.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AACpD,eAAO,MAAM,sBAAsB,SAAS,CAAC;AAC7C,eAAO,MAAM,aAAa,aAAa,CAAC;AAMxC,wBAAgB,yBAAyB,CAAC,UAAU,KAAA,EAAE,IAAI,KAAA,UAGzD;AAED,wBAAgB,4BAA4B,CAAC,KAAK,KAAA,EAAE,UAAU,KAAA,EAAE,IAAI,KAAA,UAGnE;AAMD,wBAAgB,yBAAyB,CAAC,QAAQ,KAAA,EAAE,IAAI,KAAA,iBAEvD;AAMD,wBAAgB,iBAAiB,CAAC,GAAG,IAAI,OAAA,MAaxC;AAmBD,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,GAAG,CAU1D;AAOD,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,GAAG,OA6C5C;AAOD,wBAAgB,qBAAqB,CAAC,WAAW,KAAA,OAehD;AA+BD,wBAAgB,kBAAkB,CAChC,WAAW,EAAE;IACX,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,GAAG,CAAA;KAAE,EAAE,CAAC;CACxC,EACD,IAAI,CAAC,EAAE;IACL,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,GAAG,CAAA;KAAE,EAAE,CAAC;CACxC,EAAE,MAeJ"}
1
+ {"version":3,"file":"dataSource.d.ts","sourceRoot":"","sources":["../../src/utils/dataSource.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAiB,MAAM,iBAAiB,CAAC;AAMpE,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AACpD,eAAO,MAAM,sBAAsB,SAAS,CAAC;AAC7C,eAAO,MAAM,aAAa,aAAa,CAAC;AAMxC,wBAAgB,yBAAyB,CAAC,UAAU,KAAA,EAAE,IAAI,KAAA,UAGzD;AAED,wBAAgB,4BAA4B,CAAC,KAAK,KAAA,EAAE,UAAU,KAAA,EAAE,IAAI,KAAA,UAGnE;AAMD,wBAAgB,yBAAyB,CAAC,QAAQ,KAAA,EAAE,IAAI,KAAA,iBAIvD;AAMD,wBAAgB,iBAAiB,CAAC,GAAG,IAAI,OAAA,MAexC;AAmBD,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,GAAG,CAU1D;AAOD,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,GAAG,OA6C5C;AAOD,wBAAgB,qBAAqB,CAAC,WAAW,KAAA,OAehD;AAOD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB;;EAU7D;AAiCD,wBAAgB,kBAAkB,CAChC,WAAW,EAAE;IACX,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,GAAG,CAAA;KAAE,EAAE,CAAC;CACxC,EACD,IAAI,CAAC,EAAE;IACL,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,GAAG,CAAA;KAAE,EAAE,CAAC;CACxC,EAAE,MAiBJ"}
@@ -3,27 +3,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getDatasetProfiles = exports.getDatasourceProfiles = exports.standardizeDataSource = exports.lowercaseKey = exports.mergeDependencies = exports.getDatasourceDatabaseName = exports.getAppDatasourceResourceName = exports.getDatasourceResourceName = exports.DATABASE_TYPE = exports.EXTERNAL_FUNCTION_TYPE = exports.CLOUD_FUNCTION_TYPE = void 0;
6
+ exports.getDatasetProfiles = exports.getDataVarProfiles = exports.getDatasourceProfiles = exports.standardizeDataSource = exports.lowercaseKey = exports.mergeDependencies = exports.getDatasourceDatabaseName = exports.getAppDatasourceResourceName = exports.getDatasourceResourceName = exports.DATABASE_TYPE = exports.EXTERNAL_FUNCTION_TYPE = exports.CLOUD_FUNCTION_TYPE = void 0;
7
7
  const merge_package_json_1 = __importDefault(require("merge-package-json"));
8
- const lowcode_builder_1 = require("@cloudbase/lowcode-builder");
9
- const cals_1 = require("@cloudbase/cals");
10
- const util_1 = require("@cloudbase/lowcode-builder/lib/builder/mp/util");
11
- const index_1 = require("@cloudbase/lowcode-builder/lib/builder/config/index");
8
+ const types_1 = require("../types");
9
+ const expression_1 = require("@cloudbase/cals/lib/parser/expression");
10
+ const util_1 = require("../builder/mp/util");
11
+ const config_1 = require("../builder/config");
12
12
  exports.CLOUD_FUNCTION_TYPE = 'cloud-function';
13
13
  exports.EXTERNAL_FUNCTION_TYPE = 'http';
14
14
  exports.DATABASE_TYPE = 'database';
15
15
  function getDatasourceResourceName(datasrouce, mode) {
16
- let suffix = mode === lowcode_builder_1.DEPLOY_MODE.PREVIEW ? `-preview` : '';
16
+ let suffix = mode === types_1.DEPLOY_MODE.PREVIEW ? `-preview` : '';
17
17
  return `lcap-${datasrouce.id}-${datasrouce.name}${suffix}`;
18
18
  }
19
19
  exports.getDatasourceResourceName = getDatasourceResourceName;
20
20
  function getAppDatasourceResourceName(appId, datasrouce, mode) {
21
- let suffix = mode === lowcode_builder_1.DEPLOY_MODE.PREVIEW ? `-preview` : '';
21
+ let suffix = mode === types_1.DEPLOY_MODE.PREVIEW ? `-preview` : '';
22
22
  return `lcap-${datasrouce.id}-${datasrouce.name}-${appId}${suffix}`;
23
23
  }
24
24
  exports.getAppDatasourceResourceName = getAppDatasourceResourceName;
25
25
  function getDatasourceDatabaseName(dsConfig, mode) {
26
- return dsConfig.type === exports.DATABASE_TYPE ? getDatasourceResourceName(dsConfig, mode) : null;
26
+ return dsConfig.type === exports.DATABASE_TYPE
27
+ ? getDatasourceResourceName(dsConfig, mode)
28
+ : null;
27
29
  }
28
30
  exports.getDatasourceDatabaseName = getDatasourceDatabaseName;
29
31
  function mergeDependencies(...pkgs) {
@@ -33,7 +35,9 @@ function mergeDependencies(...pkgs) {
33
35
  const formated = getDependencies(pkg);
34
36
  for (let key in formated.dependencies) {
35
37
  formated.dependencies[key] =
36
- formated.dependencies[key] === '*' && ((_a = acc === null || acc === void 0 ? void 0 : acc.dependencies) === null || _a === void 0 ? void 0 : _a[key]) === '*' ? 'latest' : formated.dependencies[key];
38
+ formated.dependencies[key] === '*' && ((_a = acc === null || acc === void 0 ? void 0 : acc.dependencies) === null || _a === void 0 ? void 0 : _a[key]) === '*'
39
+ ? 'latest'
40
+ : formated.dependencies[key];
37
41
  }
38
42
  const merged = (0, merge_package_json_1.default)(formated, acc);
39
43
  return JSON.parse(merged);
@@ -109,6 +113,17 @@ function getDatasourceProfiles(datasources) {
109
113
  })) || []);
110
114
  }
111
115
  exports.getDatasourceProfiles = getDatasourceProfiles;
116
+ function getDataVarProfiles(appData) {
117
+ const result = {
118
+ $global: (appData.vars && appData.vars.data) || [],
119
+ };
120
+ appData.pageInstanceList.forEach((pageInstance) => {
121
+ let p = pageInstance;
122
+ result[p.id] = (p.vars && p.vars.data) || [];
123
+ });
124
+ return result;
125
+ }
126
+ exports.getDataVarProfiles = getDataVarProfiles;
112
127
  function _generateDynamicDataset(dataset) {
113
128
  var _a;
114
129
  let { state } = dataset;
@@ -121,13 +136,13 @@ function _generateDynamicDataset(dataset) {
121
136
  let processed = {};
122
137
  for (let paramKey in params) {
123
138
  let bind = params[paramKey];
124
- if (!bind.type || bind.type === cals_1.PropBindType.static) {
139
+ if (!bind.type || bind.type === expression_1.PropBindType.static) {
125
140
  let value = bind.value;
126
- processed[paramKey] = `${index_1.REPLACE_SIGN}(app, $page) => (${typeof value === 'string' ? `'${value}'` : JSON.stringify(value)})${index_1.REPLACE_SIGN}`;
141
+ processed[paramKey] = `${config_1.REPLACE_SIGN}(app, $page) => (${typeof value === 'string' ? `'${value}'` : JSON.stringify(value)})${config_1.REPLACE_SIGN}`;
127
142
  }
128
143
  else {
129
144
  let jsExp = (0, util_1.generateDataBind)(bind);
130
- processed[paramKey] = `${index_1.REPLACE_SIGN}(app, $page) => (\n${jsExp || 'undefined'}\n)${index_1.REPLACE_SIGN}`;
145
+ processed[paramKey] = `${config_1.REPLACE_SIGN}(app, $page) => (\n${jsExp || 'undefined'}\n)${config_1.REPLACE_SIGN}`;
131
146
  }
132
147
  }
133
148
  config.initMethod.params = processed;
@@ -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];
@@ -6,7 +6,7 @@ export declare function originJsonToFileList(appData: IWeAppData): (import("../t
6
6
  code: string;
7
7
  pageId: string;
8
8
  })[];
9
- export declare function getExtByType(type: CodeType): ".js" | ".json" | ".less";
9
+ export declare function getExtByType(type: CodeType): ".less" | ".js" | ".json";
10
10
  export declare function HACK_FIX_LOWCODE_IN(code?: string): string;
11
11
  export declare function HACK_FIX_LOWCODE_OUT(code?: string): string;
12
12
  //# sourceMappingURL=file.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/framework-plugin-low-code",
3
- "version": "1.0.3-beta.0",
3
+ "version": "1.0.3-beta.11",
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.34",
40
+ "@cloudbase/cals": "^0.4.2",
39
41
  "@cloudbase/framework-core": "^1.8.16",
40
42
  "@cloudbase/framework-plugin-auth": "^1.8.16",
41
- "@cloudbase/framework-plugin-mp": "v1.3.6-beta.9",
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.9",
45
+ "@cloudbase/lowcode-builder": "^1.0.21",
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();