@cloudbase/framework-plugin-low-code 1.0.3-alpha.2 → 1.0.3-alpha.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/framework-plugin-low-code",
3
- "version": "1.0.3-alpha.2",
3
+ "version": "1.0.3-alpha.5",
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"
@@ -39,7 +40,7 @@
39
40
  "@cloudbase/cals": "^0.3.35",
40
41
  "@cloudbase/framework-core": "^1.8.16",
41
42
  "@cloudbase/framework-plugin-auth": "^1.8.16",
42
- "@cloudbase/framework-plugin-mp": "1.9.5-beta.1",
43
+ "@cloudbase/framework-plugin-mp": "1.9.5-beta.0",
43
44
  "@cloudbase/framework-plugin-website": "^1.8.17",
44
45
  "@cloudbase/lowcode-builder": "^1.0.12",
45
46
  "@formily/react-schema-renderer": "1.1.7",
@@ -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,44 @@
1
+ const spawn = require('cross-spawn');
2
+ const fs = require('fs-extra');
3
+ const path = require('path');
4
+
5
+ const packageName = 'miniprogram-ci@^1.8.0';
6
+ async function installDependencies(targetDir) {
7
+ if (!process.env.CLOUDBASE_CIID) {
8
+ return;
9
+ }
10
+
11
+ let yarnExists = false;
12
+ try {
13
+ let { stdout } = spawn.sync('yarn', ['-v']);
14
+ let str = stdout.toString();
15
+ if (Number(str.split('.')?.[0]) <= 1) {
16
+ yarnExists = true;
17
+ }
18
+ } catch (e) {}
19
+
20
+ const npmOptions = ['--prefer-offline', '--no-audit', '--progress=false'];
21
+
22
+ let installProcess;
23
+ // 云端构建, 选用 npm
24
+ const installlProcessOptions = {
25
+ cwd: targetDir,
26
+ env: { ...process.env, NODE_ENV: '' },
27
+ stdio: 'inherit',
28
+ };
29
+
30
+ if (yarnExists && process.env.CLOUDBASE_CIID) {
31
+ const addPackage = packageName ? ['add', packageName] : [];
32
+
33
+ installProcess = spawn.sync('yarn', [...addPackage, registry], installlProcessOptions);
34
+ } else {
35
+ installProcess = spawn.sync('npm', ['install', packageName, ...npmOptions], installlProcessOptions);
36
+ }
37
+
38
+ try {
39
+ await fs.remove(path.join(path.join(targetDir, 'package-lock.json')));
40
+ await fs.remove(path.join(path.join(targetDir, 'yarn.lock')));
41
+ } catch (e) {}
42
+ }
43
+
44
+ installDependencies(path.join(__dirname, '../'));