@cloudbase/framework-plugin-low-code 1.0.3-beta.1 → 1.0.3-beta.10
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 +6 -3
- package/lib/utils/dataSource.d.ts +0 -23
- package/lib/utils/dataSource.d.ts.map +1 -1
- package/lib/utils/dataSource.js +0 -155
- package/lib/utils/index.js +5 -1
- package/lib/utils/postProcess.js +5 -1
- package/package.json +11 -32
- package/scripts/build-plugin-tar.sh +31 -0
- package/scripts/generateTemplate.js +31 -0
- package/scripts/link-packages.js +11 -0
- package/scripts/link.js +91 -0
- package/scripts/postinstall.js +47 -0
- package/scripts/preinstall.js +16 -0
- package/template/src/handlers/utils/common.js +1 -0
- package/template/html/index.html.ejs +0 -456
- package/template/package.json +0 -63
- package/template/webpack/devServer.js +0 -119
- package/template/webpack/getCSSModuleLocalIdent.js +0 -28
- package/template/webpack/web.prod.js +0 -306
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.
|
|
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 ((
|
|
581
|
+
if ((e === null || e === void 0 ? void 0 : e.code) !== 'ResourceNotFound') {
|
|
579
582
|
throw e;
|
|
580
583
|
}
|
|
581
584
|
}
|
|
@@ -1,24 +1 @@
|
|
|
1
|
-
export declare const CLOUD_FUNCTION_TYPE = "cloud-function";
|
|
2
|
-
export declare const EXTERNAL_FUNCTION_TYPE = "http";
|
|
3
|
-
export declare const DATABASE_TYPE = "database";
|
|
4
|
-
export declare function getDatasourceResourceName(datasrouce: any, mode: any): string;
|
|
5
|
-
export declare function getAppDatasourceResourceName(appId: any, datasrouce: any, mode: any): string;
|
|
6
|
-
export declare function getDatasourceDatabaseName(dsConfig: any, mode: any): string | null;
|
|
7
|
-
export declare function mergeDependencies(...pkgs: any[]): {};
|
|
8
|
-
export declare function lowercaseKey(obj: any, deep?: boolean): any;
|
|
9
|
-
export declare function standardizeDataSource(ds: any): any;
|
|
10
|
-
export declare function getDatasourceProfiles(datasources: any): any;
|
|
11
|
-
export declare function getDatasetProfiles(mainAppData: {
|
|
12
|
-
dataset?: any;
|
|
13
|
-
rootPath?: string;
|
|
14
|
-
pageInstanceList?: {
|
|
15
|
-
dataset?: any;
|
|
16
|
-
}[];
|
|
17
|
-
}, apps?: {
|
|
18
|
-
dataset?: any;
|
|
19
|
-
rootPath?: string;
|
|
20
|
-
pageInstanceList?: {
|
|
21
|
-
dataset?: any;
|
|
22
|
-
}[];
|
|
23
|
-
}[]): {};
|
|
24
1
|
//# sourceMappingURL=dataSource.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataSource.d.ts","sourceRoot":"","sources":["../../src/utils/dataSource.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dataSource.d.ts","sourceRoot":"","sources":["../../src/utils/dataSource.ts"],"names":[],"mappings":""}
|
package/lib/utils/dataSource.js
CHANGED
|
@@ -1,156 +1 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
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;
|
|
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");
|
|
12
|
-
exports.CLOUD_FUNCTION_TYPE = 'cloud-function';
|
|
13
|
-
exports.EXTERNAL_FUNCTION_TYPE = 'http';
|
|
14
|
-
exports.DATABASE_TYPE = 'database';
|
|
15
|
-
function getDatasourceResourceName(datasrouce, mode) {
|
|
16
|
-
let suffix = mode === lowcode_builder_1.DEPLOY_MODE.PREVIEW ? `-preview` : '';
|
|
17
|
-
return `lcap-${datasrouce.id}-${datasrouce.name}${suffix}`;
|
|
18
|
-
}
|
|
19
|
-
exports.getDatasourceResourceName = getDatasourceResourceName;
|
|
20
|
-
function getAppDatasourceResourceName(appId, datasrouce, mode) {
|
|
21
|
-
let suffix = mode === lowcode_builder_1.DEPLOY_MODE.PREVIEW ? `-preview` : '';
|
|
22
|
-
return `lcap-${datasrouce.id}-${datasrouce.name}-${appId}${suffix}`;
|
|
23
|
-
}
|
|
24
|
-
exports.getAppDatasourceResourceName = getAppDatasourceResourceName;
|
|
25
|
-
function getDatasourceDatabaseName(dsConfig, mode) {
|
|
26
|
-
return dsConfig.type === exports.DATABASE_TYPE ? getDatasourceResourceName(dsConfig, mode) : null;
|
|
27
|
-
}
|
|
28
|
-
exports.getDatasourceDatabaseName = getDatasourceDatabaseName;
|
|
29
|
-
function mergeDependencies(...pkgs) {
|
|
30
|
-
let result = { dependencies: {} };
|
|
31
|
-
result = pkgs.reduce((acc, pkg) => {
|
|
32
|
-
var _a;
|
|
33
|
-
const formated = getDependencies(pkg);
|
|
34
|
-
for (let key in formated.dependencies) {
|
|
35
|
-
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];
|
|
37
|
-
}
|
|
38
|
-
const merged = (0, merge_package_json_1.default)(formated, acc);
|
|
39
|
-
return JSON.parse(merged);
|
|
40
|
-
}, result);
|
|
41
|
-
return result.dependencies;
|
|
42
|
-
}
|
|
43
|
-
exports.mergeDependencies = mergeDependencies;
|
|
44
|
-
function getDependencies(pkg) {
|
|
45
|
-
if (pkg.dependencies && typeof pkg.dependencies === 'object') {
|
|
46
|
-
return {
|
|
47
|
-
dependencies: pkg.dependencies,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
dependencies: pkg,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function lowercaseKey(obj, deep) {
|
|
55
|
-
if (!obj || typeof obj !== 'object')
|
|
56
|
-
return obj;
|
|
57
|
-
if (Array.isArray(obj))
|
|
58
|
-
return obj.map((item) => lowercaseKey(item, deep));
|
|
59
|
-
const result = {};
|
|
60
|
-
return Object.keys(obj).reduce((acc, key) => {
|
|
61
|
-
const smallCase = key.charAt(0).toLowerCase() + key.slice(1);
|
|
62
|
-
const val = obj[key];
|
|
63
|
-
acc[smallCase] = deep ? lowercaseKey(val, deep) : val;
|
|
64
|
-
return acc;
|
|
65
|
-
}, result);
|
|
66
|
-
}
|
|
67
|
-
exports.lowercaseKey = lowercaseKey;
|
|
68
|
-
function standardizeDataSource(ds) {
|
|
69
|
-
const transformed = lowercaseKey(ds, true);
|
|
70
|
-
try {
|
|
71
|
-
const { schema } = ds;
|
|
72
|
-
if (typeof transformed.schema === 'string') {
|
|
73
|
-
transformed.schema = JSON.parse(transformed.schema);
|
|
74
|
-
}
|
|
75
|
-
if (!transformed.schema || typeof transformed.schema !== 'object') {
|
|
76
|
-
transformed.schema = {};
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
transformed.schema = {};
|
|
81
|
-
}
|
|
82
|
-
try {
|
|
83
|
-
const { methods } = ds;
|
|
84
|
-
if (typeof transformed.methods === 'string') {
|
|
85
|
-
transformed.methods = JSON.parse(transformed.methods);
|
|
86
|
-
}
|
|
87
|
-
if (!Array.isArray(transformed.methods)) {
|
|
88
|
-
transformed.methods = [];
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
transformed.methods = [];
|
|
93
|
-
}
|
|
94
|
-
return transformed;
|
|
95
|
-
}
|
|
96
|
-
exports.standardizeDataSource = standardizeDataSource;
|
|
97
|
-
function getDatasourceProfiles(datasources) {
|
|
98
|
-
return ((datasources === null || datasources === void 0 ? void 0 : datasources.map((item) => {
|
|
99
|
-
const ds = standardizeDataSource(item);
|
|
100
|
-
return {
|
|
101
|
-
id: ds.id,
|
|
102
|
-
title: ds.title,
|
|
103
|
-
name: ds.name,
|
|
104
|
-
type: ds.type,
|
|
105
|
-
childDataSourceNames: ds.childDataSourceNames,
|
|
106
|
-
schema: ds.schema,
|
|
107
|
-
methods: ds.methods,
|
|
108
|
-
};
|
|
109
|
-
})) || []);
|
|
110
|
-
}
|
|
111
|
-
exports.getDatasourceProfiles = getDatasourceProfiles;
|
|
112
|
-
function _generateDynamicDataset(dataset) {
|
|
113
|
-
var _a;
|
|
114
|
-
let { state } = dataset;
|
|
115
|
-
if (state) {
|
|
116
|
-
for (let key in state) {
|
|
117
|
-
let config = state[key];
|
|
118
|
-
if (config.varType === 'datasource' && ((_a = config.initMethod) === null || _a === void 0 ? void 0 : _a.params)) {
|
|
119
|
-
let params = config.initMethod.params;
|
|
120
|
-
if (params) {
|
|
121
|
-
let processed = {};
|
|
122
|
-
for (let paramKey in params) {
|
|
123
|
-
let bind = params[paramKey];
|
|
124
|
-
if (!bind.type || bind.type === cals_1.PropBindType.static) {
|
|
125
|
-
let value = bind.value;
|
|
126
|
-
processed[paramKey] = `${index_1.REPLACE_SIGN}(app, $page) => (${typeof value === 'string' ? `'${value}'` : JSON.stringify(value)})${index_1.REPLACE_SIGN}`;
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
let jsExp = (0, util_1.generateDataBind)(bind);
|
|
130
|
-
processed[paramKey] = `${index_1.REPLACE_SIGN}(app, $page) => (\n${jsExp || 'undefined'}\n)${index_1.REPLACE_SIGN}`;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
config.initMethod.params = processed;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return dataset;
|
|
139
|
-
}
|
|
140
|
-
function getDatasetProfiles(mainAppData, apps) {
|
|
141
|
-
const result = {};
|
|
142
|
-
if (mainAppData.dataset) {
|
|
143
|
-
result['$global'] = _generateDynamicDataset(mainAppData.dataset);
|
|
144
|
-
}
|
|
145
|
-
(apps || []).forEach((app) => {
|
|
146
|
-
var _a;
|
|
147
|
-
(_a = app.pageInstanceList) === null || _a === void 0 ? void 0 : _a.forEach((pageInstance) => {
|
|
148
|
-
let p = pageInstance;
|
|
149
|
-
if (p.dataset) {
|
|
150
|
-
result[app.rootPath ? `${app.rootPath}/${p.id}` : p.id] = _generateDynamicDataset(p.dataset);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
return result;
|
|
155
|
-
}
|
|
156
|
-
exports.getDatasetProfiles = getDatasetProfiles;
|
package/lib/utils/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.
|
|
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/lib/utils/postProcess.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.
|
|
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.
|
|
3
|
+
"version": "1.0.3-beta.10",
|
|
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": "
|
|
40
|
+
"@cloudbase/cals": "^0.4.1",
|
|
39
41
|
"@cloudbase/framework-core": "^1.8.16",
|
|
40
42
|
"@cloudbase/framework-plugin-auth": "^1.8.16",
|
|
41
|
-
"@cloudbase/framework-plugin-mp": "
|
|
43
|
+
"@cloudbase/framework-plugin-mp": "1.9.5-beta.0",
|
|
42
44
|
"@cloudbase/framework-plugin-website": "^1.8.17",
|
|
43
|
-
"@cloudbase/lowcode-builder": "
|
|
45
|
+
"@cloudbase/lowcode-builder": "^1.0.20",
|
|
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
|
-
"
|
|
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": "^
|
|
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();
|
package/scripts/link.js
ADDED
|
@@ -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();
|