mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 01:21:58 +00:00
feat: add recore project template
This commit is contained in:
parent
e906683a1a
commit
267953b82b
@ -0,0 +1,32 @@
|
||||
|
||||
import ResultFile from '../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'.editorconfig',
|
||||
'',
|
||||
`
|
||||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Tab indentation
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [[], file];
|
||||
}
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
|
||||
import ResultFile from '../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'.eslintignore',
|
||||
'',
|
||||
`
|
||||
.idea
|
||||
.vscode
|
||||
.theia
|
||||
.recore
|
||||
build/
|
||||
.*
|
||||
~*
|
||||
node_modules
|
||||
|
||||
packages/solution
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [[], file];
|
||||
}
|
||||
|
||||
@ -0,0 +1,57 @@
|
||||
|
||||
import ResultFile from '../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'.gitignore',
|
||||
'',
|
||||
`
|
||||
node_modules/
|
||||
coverage/
|
||||
build/
|
||||
dist/
|
||||
.idea/
|
||||
.vscode/
|
||||
.theia/
|
||||
.recore/
|
||||
.Trash-*/
|
||||
~*
|
||||
package-lock.json
|
||||
|
||||
# Packages #
|
||||
############
|
||||
# it's better to unpack these files and commit the raw source
|
||||
# git has its own built in compression methods
|
||||
*.7z
|
||||
*.dmg
|
||||
*.gz
|
||||
*.iso
|
||||
*.jar
|
||||
*.rar
|
||||
*.tar
|
||||
*.zip
|
||||
|
||||
# Logs and databases #
|
||||
######################
|
||||
*.log
|
||||
*.sql
|
||||
*.sqlite
|
||||
|
||||
# OS generated files #
|
||||
######################
|
||||
.DS_Store
|
||||
*.swp
|
||||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [[], file];
|
||||
}
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
|
||||
import ResultFile from '../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'.prettierrc',
|
||||
'',
|
||||
`
|
||||
{
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"printWidth": 120,
|
||||
"trailingComma": "all"
|
||||
}
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [[], file];
|
||||
}
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
|
||||
import ResultFile from '../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'README',
|
||||
'md',
|
||||
`
|
||||
# runtime-code
|
||||
|
||||
乐高接出码模块测试项目
|
||||
|
||||
|
||||
## 安装运行
|
||||
|
||||
```bash
|
||||
# install dependencies
|
||||
tnpm install
|
||||
|
||||
# serve with hot reload at localhost:8080
|
||||
npm start
|
||||
|
||||
# test projects
|
||||
npm test
|
||||
|
||||
# local build
|
||||
npm run build
|
||||
```
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [[], file];
|
||||
}
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
|
||||
import ResultFile from '../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'abc',
|
||||
'json',
|
||||
`
|
||||
{
|
||||
"name": "test",
|
||||
"assets": {
|
||||
"type": "command",
|
||||
"command": {
|
||||
"cmd": [
|
||||
"tnpm ii",
|
||||
"tnpm run build"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [[], file];
|
||||
}
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
|
||||
import ResultFile from '../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'build',
|
||||
'json',
|
||||
`
|
||||
{
|
||||
"entry": "src/index",
|
||||
"alias": {
|
||||
"@": "./src"
|
||||
},
|
||||
"publicPath": "./",
|
||||
"outputAssetsPath": {
|
||||
"js": "",
|
||||
"css": ""
|
||||
},
|
||||
"plugins": [
|
||||
"build-plugin-react-app",
|
||||
"@ali/build-plugin-recore-lowcode"
|
||||
],
|
||||
"externals": { "react": "window.React", "react-dom": "window.ReactDOM", "@ali/recore": "window.Recore" }
|
||||
}
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [[], file];
|
||||
}
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
|
||||
import ResultFile from '../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'package',
|
||||
'json',
|
||||
`
|
||||
{
|
||||
"name": "test",
|
||||
"version": "1.0.0",
|
||||
"description": "test",
|
||||
"scripts": {
|
||||
"start": "build-scripts start",
|
||||
"build": "build-scripts build",
|
||||
"test": "build-scripts test"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.9.0",
|
||||
"npm": ">=6.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ali/recore": "^1.6.10",
|
||||
"@ali/lowcode-runtime": "^0.8.0",
|
||||
"@ali/recore-renderer": "^0.0.1",
|
||||
"@ali/vc-shell": "1.3.1",
|
||||
"@ali/vc-block": "^3.0.3-beta.1",
|
||||
"@ali/vc-deep": "1.2.38",
|
||||
"@ali/vc-div": "^1.0.1",
|
||||
"@ali/vc-page": "^1.0.5",
|
||||
"@ali/vc-slot": "^2.0.1",
|
||||
"@ali/vc-text": "^4.0.1",
|
||||
"@ali/vu-dataSource": "^1.0.4",
|
||||
"@ali/vu-formatter": "^2.0.0",
|
||||
"@ali/vu-fusion": "^2.0.1-beta.0",
|
||||
"@ali/vu-legao-builtin": "^1.4.0-beta.2",
|
||||
"react": "^16"
|
||||
},
|
||||
"devDependencies": {
|
||||
"build-plugin-react-app": "^1.0.15",
|
||||
"@ali/build-plugin-recore-lowcode": "^0.0.1",
|
||||
"@alib/build-scripts": "^0.1.0",
|
||||
"@types/node": "^7",
|
||||
"@types/react": "^16",
|
||||
"eslint": "^6.5.1",
|
||||
"tslib": "^1.9.3",
|
||||
"typescript": "^3.1.3",
|
||||
"prettier": "^1.18.2"
|
||||
},
|
||||
"lint-staged": {
|
||||
"./src/**/*.{ts,tsx}": [
|
||||
"tslint --fix",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"nowa": {
|
||||
"solution": "@ali/nowa-recore-solution"
|
||||
}
|
||||
}
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [[], file];
|
||||
}
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
|
||||
import ResultFile from '../../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'index',
|
||||
'html',
|
||||
`
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, maximum-scale=1.0, user-scalable=no" />
|
||||
<title>lowcode-runtime-test</title>
|
||||
<link rel="shortcut icon" type="image/png" href="https://img.alicdn.com/tfs/TB1zgoCemrqK1RjSZK9XXXyypXa-96-96.png" />
|
||||
<link rel="stylesheet" id="" href="//g.alicdn.com/legao-comp/csxs/1.0.2/web.css?t=1f">
|
||||
<script
|
||||
src="https://g.alicdn.com/code/lib/??react/16.9.0/umd/react.production.min.js,react-dom/16.9.0/umd/react-dom.production.min.js,prop-types/15.7.2/prop-types.js"></script>
|
||||
<!-- React 非压缩版代码,可根据需要替换或通过代理替换后方便调试 -->
|
||||
<!-- <script src="https://g.alicdn.com/code/lib/??react/16.9.0/umd/react.development.js,react-dom/16.9.0/umd/react-dom.development.js,prop-types/15.7.2/prop-types.js"></script> -->
|
||||
<script src="https://g.alicdn.com/mylib/@ali/recore/1.6.8/umd/recore.min.js"></script>
|
||||
<script>
|
||||
React.PropTypes = PropTypes;
|
||||
</script>
|
||||
<style type="text/css">
|
||||
body {
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script>
|
||||
window.g_config = {
|
||||
appKey: 'test', // 乐高应用的 AppKey
|
||||
// isSectionalRender: true, // 必填,标记当前为局部使用
|
||||
// autoRender: true,
|
||||
// index: 'search_form',
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
`,
|
||||
);
|
||||
|
||||
return [['public'], file];
|
||||
}
|
||||
|
||||
@ -0,0 +1,77 @@
|
||||
|
||||
import ResultFile from '../../../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'app',
|
||||
'ts',
|
||||
`
|
||||
export default {
|
||||
"sdkVersion": "1.0.3",
|
||||
"history": "hash", // 浏览器路由:brower 哈希路由:hash
|
||||
"containerId": "app",
|
||||
"layout": {
|
||||
"componentName": "BasicLayout",
|
||||
"props": {
|
||||
"navConfig": {
|
||||
"showLanguageChange": true,
|
||||
"data": [
|
||||
{
|
||||
"hidden": false,
|
||||
"navUuid": "FORM-CP5669B1-3AW9DCLHZAY8EIY6WE6X1-GFZM3V1K-6",
|
||||
"children": [],
|
||||
"icon": "",
|
||||
"targetNew": false,
|
||||
"title": "测试基础表格",
|
||||
"inner": true,
|
||||
"relateUuid": "FORM-CP5669B1-3AW9DCLHZAY8EIY6WE6X1-GFZM3V1K-6",
|
||||
"slug": "qihfg"
|
||||
},
|
||||
{
|
||||
"hidden": false,
|
||||
"navUuid": "FORM-CP5669B1-8AW9XCUT4PCH15SMDWUM3-ZPQP3V1K-1",
|
||||
"children": [],
|
||||
"icon": "",
|
||||
"targetNew": false,
|
||||
"title": "测试查询表格",
|
||||
"inner": true,
|
||||
"relateUuid": "zqhej",
|
||||
"slug": "zqhej"
|
||||
}
|
||||
],
|
||||
"systemLink": "/my_dev_center_code/0.1.0",
|
||||
"appName": "乐高转码demo",
|
||||
"isFoldHorizontal": "n",
|
||||
"showAppTitle": true,
|
||||
"isFold": "n",
|
||||
"searchBarType": "icon",
|
||||
"singletons": {},
|
||||
"navTheme": "default",
|
||||
"type": "top_side_fold",
|
||||
"navStyle": "orange",
|
||||
"layout": "auto",
|
||||
"bgColor": "white",
|
||||
"languageChangeUrl": "/common/account/changeAccountLanguage.json",
|
||||
"showSearch": "n",
|
||||
"openSubMode": false,
|
||||
"showCrumb": true,
|
||||
"isFixed": "y",
|
||||
"showIcon": false,
|
||||
"showNav": true
|
||||
}
|
||||
},
|
||||
},
|
||||
"theme": {
|
||||
"package": "@alife/theme-fusion",
|
||||
"version": "^0.1.0"
|
||||
},
|
||||
"compDependencies": []
|
||||
}
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [['src','config'], file];
|
||||
}
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
|
||||
import ResultFile from '../../../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'components',
|
||||
'ts',
|
||||
`
|
||||
/**
|
||||
* 乐高组件
|
||||
*/
|
||||
import Div from '@ali/vc-div/build/view';
|
||||
import Text from '@ali/vc-text/build/view';
|
||||
import Slot from '@ali/vc-slot/build/view';
|
||||
import Deep from '@ali/vc-deep/build/view';
|
||||
import Page from '@ali/vc-page/build/view';
|
||||
import Block from '@ali/vc-block/build/view';
|
||||
|
||||
const components = [Div, Text, Slot, Deep, Page, Block];
|
||||
const componentsMap = {
|
||||
};
|
||||
|
||||
const processComponents = (deps) => {
|
||||
deps.forEach((dep) => {
|
||||
if (Array.isArray(dep)) {
|
||||
processComponents(dep);
|
||||
} else {
|
||||
componentsMap[dep.displayName] = dep;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
processComponents(components);
|
||||
|
||||
export default componentsMap;
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [['src','config'], file];
|
||||
}
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
|
||||
import ResultFile from '../../../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'utils',
|
||||
'ts',
|
||||
`
|
||||
import toolkit from '@ali/vu-toolkit';
|
||||
import fusion from '@ali/vu-fusion';
|
||||
import dataSource from '@ali/vu-dataSource';
|
||||
import legaoBuiltin from '@ali/vu-legao-builtin';
|
||||
import formatter from '@ali/vu-formatter';
|
||||
|
||||
export default {
|
||||
...toolkit,
|
||||
...fusion,
|
||||
legaoBuiltin,
|
||||
dataSource,
|
||||
formatter
|
||||
}
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [['src','config'], file];
|
||||
}
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
|
||||
import ResultFile from '../../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'index',
|
||||
'ts',
|
||||
`
|
||||
import { app } from '@ali/lowcode-runtime';
|
||||
import Shell from '@ali/vc-shell';
|
||||
import StaticRender from './plugins/provider';
|
||||
|
||||
// 注册布局组件,可注册多个
|
||||
app.registerLayout(Shell, {
|
||||
componentName: 'BasicLayout',
|
||||
});
|
||||
|
||||
app.registerProvider(StaticRender);
|
||||
|
||||
app.run();
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [['src'], file];
|
||||
}
|
||||
|
||||
@ -0,0 +1,89 @@
|
||||
|
||||
import ResultFile from '../../../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'provider',
|
||||
'ts',
|
||||
`
|
||||
import { ReactProvider } from '@ali/lowcode-runtime';
|
||||
import Router from '@/router';
|
||||
import appConfig from '@/config/app';
|
||||
import components from '@/config/components';
|
||||
import utils from '@/config/utils';
|
||||
|
||||
// 定制加载应用配置的逻辑
|
||||
export default class MyProvider extends ReactProvider {
|
||||
// 初始化时调用,如可以在这里注入全局API
|
||||
init() {
|
||||
const gConfig = (window as any).g_config || {};
|
||||
const LeGao = {
|
||||
__ctx__: {},
|
||||
createContext: (cfg: any) => {
|
||||
const { schema } = cfg || {};
|
||||
// 1. 根据参数拉取schema
|
||||
if (schema && typeof schema === 'string') {
|
||||
this.setHomePage(schema);
|
||||
}
|
||||
const { isSectionalRender, autoRender } = gConfig || {};
|
||||
if (isSectionalRender && !autoRender) {
|
||||
// 2. 渲染
|
||||
this.setSectionalRender();
|
||||
this.ready();
|
||||
}
|
||||
const provider = this;
|
||||
class Context {
|
||||
get utils() {
|
||||
return provider.getUtils();
|
||||
}
|
||||
get components() {
|
||||
return provider.getComponents();
|
||||
}
|
||||
}
|
||||
const ctx = new Context();
|
||||
(LeGao.__ctx__ as any)[this.getContainerId()] = ctx;
|
||||
return ctx;
|
||||
},
|
||||
getContext: (id: string) => {
|
||||
if (!id) {
|
||||
for (id in LeGao.__ctx__) {
|
||||
return (LeGao.__ctx__ as any)[id];
|
||||
}
|
||||
}
|
||||
return (LeGao.__ctx__ as any)[id];
|
||||
}
|
||||
};
|
||||
(window as any).LeGao = LeGao;
|
||||
if (gConfig.index) {
|
||||
this.setHomePage(gConfig.index);
|
||||
}
|
||||
if (gConfig.isSectionalRender) {
|
||||
this.setSectionalRender();
|
||||
if (!gConfig.autoRender) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.ready();
|
||||
}
|
||||
|
||||
// 定制获取、处理应用配置(组件、插件、路由模式、布局等)的逻辑
|
||||
getAppData() {
|
||||
return {
|
||||
...appConfig,
|
||||
components,
|
||||
utils: utils,
|
||||
}
|
||||
}
|
||||
|
||||
getRouterView() {
|
||||
return Router;
|
||||
}
|
||||
}
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [['src','plugins'], file];
|
||||
}
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
|
||||
import ResultFile from '../../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'router',
|
||||
'ts',
|
||||
`
|
||||
export default {
|
||||
baseDir: './pages',
|
||||
exact: true,
|
||||
routes: [
|
||||
{ main: './index', path: '/' },
|
||||
],
|
||||
};
|
||||
`,
|
||||
);
|
||||
|
||||
return [['src'], file];
|
||||
}
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
|
||||
import ResultFile from '../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'tsconfig',
|
||||
'json',
|
||||
`
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["es2015", "dom"],
|
||||
// Target latest version of ECMAScript.
|
||||
"target": "esnext",
|
||||
// Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'.
|
||||
"module": "esnext",
|
||||
// Search under node_modules for non-relative imports.
|
||||
"moduleResolution": "node",
|
||||
// Process & infer types from .js files.
|
||||
"allowJs": true,
|
||||
// Report errors in .js files.
|
||||
"checkJs": false,
|
||||
// Don't emit; allow Babel to transform files.
|
||||
"noEmit": true,
|
||||
// Enable strictest settings like strictNullChecks & noImplicitAny.
|
||||
"strict": true,
|
||||
// Allow default imports from modules with no default export. This does not affect code emit, just typechecking.
|
||||
"allowSyntheticDefaultImports": true,
|
||||
// Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'.
|
||||
"esModuleInterop": true,
|
||||
// Specify JSX code generation: 'preserve', 'react-native', or 'react'.
|
||||
"jsx": "preserve",
|
||||
// Import emit helpers (e.g. __extends, __rest, etc..) from tslib
|
||||
"importHelpers": true,
|
||||
// Enables experimental support for ES7 decorators.
|
||||
"experimentalDecorators": true,
|
||||
// Generates corresponding .map file.
|
||||
"sourceMap": true,
|
||||
// Disallow inconsistently-cased references to the same file.
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
// Allow json import
|
||||
"resolveJsonModule": true,
|
||||
// skip type checking of declaration files
|
||||
"skipLibCheck": true,
|
||||
}
|
||||
}
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [[], file];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user