mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 17:48:13 +00:00
feat: 🎸 优化完善 Rax 出码相关的模板和插件
This commit is contained in:
parent
d834653b20
commit
c3d909aaf5
@ -17,6 +17,7 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
||||
|
||||
const ir = next.ir as IRouterInfo;
|
||||
|
||||
// TODO: 如何生成路由?
|
||||
next.chunks.push({
|
||||
type: ChunkType.STRING,
|
||||
fileType: FileType.JSON,
|
||||
|
||||
@ -19,7 +19,7 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
||||
|
||||
next.chunks.push({
|
||||
type: ChunkType.STRING,
|
||||
fileType: FileType.SCSS,
|
||||
fileType: FileType.SCSS, // TODO: 样式文件的类型定制化?
|
||||
name: COMMON_CHUNK_NAME.StyleDepsImport,
|
||||
content: `
|
||||
// TODO: 引入默认全局样式
|
||||
|
||||
@ -10,17 +10,6 @@ import {
|
||||
IProjectInfo,
|
||||
} from '../../../../../types';
|
||||
|
||||
interface IIceJsPackageJSON extends IPackageJSON {
|
||||
ideMode: {
|
||||
name: string;
|
||||
};
|
||||
iceworks: {
|
||||
type: string;
|
||||
adapter: string;
|
||||
};
|
||||
originTemplate: string;
|
||||
}
|
||||
|
||||
const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
||||
const plugin: BuilderComponentPlugin = async (pre: ICodeStruct) => {
|
||||
const next: ICodeStruct = {
|
||||
@ -29,48 +18,36 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
||||
|
||||
const ir = next.ir as IProjectInfo;
|
||||
|
||||
const packageJson: IIceJsPackageJSON = {
|
||||
name: '@alifd/scaffold-lite-js',
|
||||
version: '0.1.5',
|
||||
description: '轻量级模板,使用 JavaScript,仅包含基础的 Layout。',
|
||||
const packageJson: IPackageJSON = {
|
||||
name: '@ali/rax-component-demo',
|
||||
version: '1.0.0',
|
||||
scripts: {
|
||||
build:
|
||||
'rm -f ./dist/miniapp.tar.gz && npm run build:miniapp && cd build/miniapp && tar czf ../../dist/miniapp.tar.gz *',
|
||||
'build:miniapp': 'build-scripts build',
|
||||
start: 'build-scripts start',
|
||||
lint: 'eslint --ext .js --ext .jsx ./',
|
||||
},
|
||||
dependencies: {
|
||||
moment: '^2.24.0',
|
||||
react: '^16.4.1',
|
||||
'react-dom': '^16.4.1',
|
||||
'@alifd/theme-design-pro': '^0.x',
|
||||
rax: '^1.1.0',
|
||||
'rax-app': '^2.0.0',
|
||||
'rax-document': '^0.1.0',
|
||||
'rax-text': '^1.0.0',
|
||||
'rax-view': '^1.0.0',
|
||||
},
|
||||
devDependencies: {
|
||||
'@ice/spec': '^1.0.0',
|
||||
'build-plugin-fusion': '^0.1.0',
|
||||
'build-plugin-moment-locales': '^0.1.0',
|
||||
eslint: '^6.0.1',
|
||||
'ice.js': '^1.0.0',
|
||||
stylelint: '^13.2.0',
|
||||
'@ali/build-plugin-ice-def': '^0.1.0',
|
||||
'build-plugin-rax-app': '^5.0.0',
|
||||
'@alib/build-scripts': '^0.1.0',
|
||||
'@typescript-eslint/eslint-plugin': '^2.11.0',
|
||||
'@typescript-eslint/parser': '^2.11.0',
|
||||
'babel-eslint': '^10.0.3',
|
||||
eslint: '^6.8.0',
|
||||
'eslint-config-rax': '^0.1.0',
|
||||
'eslint-plugin-import': '^2.20.0',
|
||||
'eslint-plugin-module': '^0.1.0',
|
||||
'eslint-plugin-react': '^7.18.0',
|
||||
'@ali/build-plugin-rax-app-def': '^1.0.0',
|
||||
},
|
||||
scripts: {
|
||||
start: 'icejs start',
|
||||
build: 'icejs build',
|
||||
lint: 'npm run eslint && npm run stylelint',
|
||||
eslint: 'eslint --cache --ext .js,.jsx ./',
|
||||
stylelint: 'stylelint ./**/*.scss',
|
||||
},
|
||||
ideMode: {
|
||||
name: 'ice-react',
|
||||
},
|
||||
iceworks: {
|
||||
type: 'react',
|
||||
adapter: 'adapter-react-v3',
|
||||
},
|
||||
engines: {
|
||||
node: '>=8.0.0',
|
||||
},
|
||||
repository: {
|
||||
type: 'git',
|
||||
url: 'http://gitlab.alibaba-inc.com/msd/leak-scan/tree/master',
|
||||
},
|
||||
private: true,
|
||||
originTemplate: '@alifd/scaffold-lite-js',
|
||||
};
|
||||
|
||||
next.chunks.push({
|
||||
|
||||
@ -6,8 +6,7 @@ export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'.editorconfig',
|
||||
'',
|
||||
`
|
||||
# http://editorconfig.org
|
||||
`# http://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
@ -19,10 +18,8 @@ insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
`,
|
||||
`,
|
||||
);
|
||||
|
||||
return [[], file];
|
||||
}
|
||||
|
||||
@ -6,8 +6,7 @@ export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'.eslintignore',
|
||||
'',
|
||||
`
|
||||
# 忽略目录
|
||||
`# 忽略目录
|
||||
build/
|
||||
tests/
|
||||
demo/
|
||||
@ -18,10 +17,8 @@ coverage/
|
||||
# 忽略文件
|
||||
**/*-min.js
|
||||
**/*.min.js
|
||||
|
||||
`,
|
||||
`,
|
||||
);
|
||||
|
||||
return [[], file];
|
||||
}
|
||||
|
||||
@ -6,14 +6,11 @@ export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'.eslintrc',
|
||||
'js',
|
||||
`
|
||||
module.exports = {
|
||||
`module.exports = {
|
||||
extends: ['rax'],
|
||||
};
|
||||
|
||||
`,
|
||||
`,
|
||||
);
|
||||
|
||||
return [[], file];
|
||||
}
|
||||
|
||||
@ -6,8 +6,7 @@ export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'.gitignore',
|
||||
'',
|
||||
`
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
`# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
*~
|
||||
*.swp
|
||||
@ -24,10 +23,8 @@ coverage/
|
||||
node_modules/
|
||||
|
||||
template.yml
|
||||
|
||||
`,
|
||||
`,
|
||||
);
|
||||
|
||||
return [[], file];
|
||||
}
|
||||
|
||||
@ -6,12 +6,11 @@ export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'README',
|
||||
'md',
|
||||
`
|
||||
# @ali/rax-component-demo
|
||||
`# @ali/rax-component-demo
|
||||
|
||||
## Getting Started
|
||||
|
||||
### `npm run start`
|
||||
### \`npm run start\`
|
||||
|
||||
Runs the app in development mode.
|
||||
|
||||
@ -19,13 +18,11 @@ Open [http://localhost:9999](http://localhost:9999) to view it in the browser.
|
||||
|
||||
The page will reload if you make edits.
|
||||
|
||||
### `npm run build`
|
||||
### \`npm run build\`
|
||||
|
||||
Builds the app for production to the `build` folder.
|
||||
|
||||
`,
|
||||
Builds the app for production to the \`build\` folder.
|
||||
`,
|
||||
);
|
||||
|
||||
return [[], file];
|
||||
}
|
||||
|
||||
@ -6,18 +6,15 @@ export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'abc',
|
||||
'json',
|
||||
`
|
||||
{
|
||||
`{
|
||||
"type": "rax",
|
||||
"builder": "@ali/builder-rax-v1",
|
||||
"info": {
|
||||
"raxVersion": "1.x"
|
||||
}
|
||||
}
|
||||
|
||||
`,
|
||||
`,
|
||||
);
|
||||
|
||||
return [[], file];
|
||||
}
|
||||
|
||||
@ -6,8 +6,7 @@ export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'build',
|
||||
'json',
|
||||
`
|
||||
{
|
||||
`{
|
||||
"inlineStyle": false,
|
||||
"plugins": [
|
||||
[
|
||||
@ -19,10 +18,8 @@ export default function getFile(): [string[], IResultFile] {
|
||||
"@ali/build-plugin-rax-app-def"
|
||||
]
|
||||
}
|
||||
|
||||
`,
|
||||
`,
|
||||
);
|
||||
|
||||
return [[], file];
|
||||
}
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
|
||||
import ResultFile from '../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'package',
|
||||
'json',
|
||||
`
|
||||
{
|
||||
"name": "@ali/rax-component-demo",
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"build": "rm -f ./dist/miniapp.tar.gz && npm run build:miniapp && cd build/miniapp && tar czf ../../dist/miniapp.tar.gz *",
|
||||
"build:miniapp": "build-scripts build",
|
||||
"start": "build-scripts start",
|
||||
"lint": "eslint --ext .js --ext .jsx ./"
|
||||
},
|
||||
"dependencies": {
|
||||
"rax": "^1.1.0",
|
||||
"rax-app": "^2.0.0",
|
||||
"rax-document": "^0.1.0",
|
||||
"rax-text": "^1.0.0",
|
||||
"rax-view": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"build-plugin-rax-app": "^5.0.0",
|
||||
"@alib/build-scripts": "^0.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.11.0",
|
||||
"@typescript-eslint/parser": "^2.11.0",
|
||||
"babel-eslint": "^10.0.3",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-rax": "^0.1.0",
|
||||
"eslint-plugin-import": "^2.20.0",
|
||||
"eslint-plugin-module": "^0.1.0",
|
||||
"eslint-plugin-react": "^7.18.0",
|
||||
"@ali/build-plugin-rax-app-def": "^1.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [[], file];
|
||||
}
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
|
||||
import ResultFile from '../../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'app',
|
||||
'js',
|
||||
`
|
||||
import { runApp } from 'rax-app';
|
||||
import appConfig from './app.json';
|
||||
|
||||
runApp(appConfig);
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [['src'], file];
|
||||
}
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
|
||||
import ResultFile from '../../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'app',
|
||||
'json',
|
||||
`
|
||||
{
|
||||
"routes": [
|
||||
{
|
||||
"path": "/",
|
||||
"source": "pages/Home/index"
|
||||
}
|
||||
],
|
||||
"window": {
|
||||
"title": "Rax App Demo"
|
||||
}
|
||||
}
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [['src'], file];
|
||||
}
|
||||
|
||||
@ -1,40 +0,0 @@
|
||||
|
||||
import ResultFile from '../../../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'index',
|
||||
'jsx',
|
||||
`
|
||||
import { createElement } from 'rax';
|
||||
import { Root, Style, Script } from 'rax-document';
|
||||
|
||||
function Document() {
|
||||
return (
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no,viewport-fit=cover"
|
||||
/>
|
||||
<title>Rax App Demo</title>
|
||||
<Style />
|
||||
</head>
|
||||
<body>
|
||||
{/* root container */}
|
||||
<Root />
|
||||
<Script />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
||||
export default Document;
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [['src','document'], file];
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
|
||||
import ResultFile from '../../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'global',
|
||||
'less',
|
||||
`
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [['src'], file];
|
||||
}
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
|
||||
import ResultFile from '../../../../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'index',
|
||||
'css',
|
||||
`
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [['src','pages','Home'], file];
|
||||
}
|
||||
|
||||
@ -1,34 +0,0 @@
|
||||
|
||||
import ResultFile from '../../../../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'index',
|
||||
'jsx',
|
||||
`
|
||||
import { createElement, Component } from 'rax';
|
||||
|
||||
import Page from 'rax-view';
|
||||
import Text from 'rax-text';
|
||||
|
||||
import './index.css';
|
||||
|
||||
class Home$$Page extends Component {
|
||||
render() {
|
||||
return (
|
||||
<Page>
|
||||
<Text>Hello world!</Text>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Home$$Page;
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [['src','pages','Home'], file];
|
||||
}
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
|
||||
import ResultFile from '../../../../../../../model/ResultFile';
|
||||
import { IResultFile } from '../../../../../../../types';
|
||||
|
||||
export default function getFile(): [string[], IResultFile] {
|
||||
const file = new ResultFile(
|
||||
'utils',
|
||||
'js',
|
||||
`
|
||||
export default {};
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
return [['src'], file];
|
||||
}
|
||||
|
||||
@ -1,26 +1,15 @@
|
||||
import ResultDir from '../../../../../model/ResultDir';
|
||||
import {
|
||||
IProjectTemplate,
|
||||
IResultDir,
|
||||
} from '../../../../../types';
|
||||
import { IProjectTemplate, IResultDir } from '../../../../../types';
|
||||
|
||||
import { runFileGenerator } from '../../../../../utils/templateHelper';
|
||||
|
||||
import file0 from './files/.editorconfig'
|
||||
import file1 from './files/.eslintignore'
|
||||
import file2 from './files/.eslintrc.js'
|
||||
import file3 from './files/.gitignore'
|
||||
import file4 from './files/README.md'
|
||||
import file5 from './files/abc.json'
|
||||
import file6 from './files/build.json'
|
||||
import file7 from './files/package.json'
|
||||
import file8 from './files/src/app.js'
|
||||
import file9 from './files/src/app.json'
|
||||
import file10 from './files/src/document/index.jsx'
|
||||
import file11 from './files/src/global.less'
|
||||
import file12 from './files/src/pages/Home/index.css'
|
||||
import file13 from './files/src/pages/Home/index.jsx'
|
||||
import file14 from './files/src/utils.js'
|
||||
import file0 from './files/.editorconfig';
|
||||
import file1 from './files/.eslintignore';
|
||||
import file2 from './files/.eslintrc.js';
|
||||
import file3 from './files/.gitignore';
|
||||
import file4 from './files/README.md';
|
||||
import file5 from './files/abc.json';
|
||||
import file6 from './files/build.json';
|
||||
|
||||
const raxAppTemplate: IProjectTemplate = {
|
||||
slots: {
|
||||
@ -78,14 +67,6 @@ const raxAppTemplate: IProjectTemplate = {
|
||||
runFileGenerator(root, file4);
|
||||
runFileGenerator(root, file5);
|
||||
runFileGenerator(root, file6);
|
||||
runFileGenerator(root, file7);
|
||||
runFileGenerator(root, file8);
|
||||
runFileGenerator(root, file9);
|
||||
runFileGenerator(root, file10);
|
||||
runFileGenerator(root, file11);
|
||||
runFileGenerator(root, file12);
|
||||
runFileGenerator(root, file13);
|
||||
runFileGenerator(root, file14);
|
||||
|
||||
return root;
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user