Merge pull request #2 from alibaba/chore/d1

chore: 优化生成引擎版本号的逻辑
This commit is contained in:
JackLian 2022-02-16 15:35:06 +08:00 committed by GitHub
commit b8b265866b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 52 additions and 18 deletions

View File

@ -90,14 +90,21 @@ init(document.getElementById('lce'));
``` ```
### cdn 可选方式: ### cdn 可选方式:
#### 方式 1unpkg #### 方式 1alifd cdn
```html
https://alifd.alicdn.com/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js
https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js
```
#### 方式 2unpkg
```html ```html
https://unpkg.com/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js https://unpkg.com/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js
https://unpkg.com/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js https://unpkg.com/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js
``` ```
#### 方式 2jsdelivr #### 方式 3jsdelivr
```html ```html
https://cdn.jsdelivr.net/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js https://cdn.jsdelivr.net/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js
@ -127,10 +134,12 @@ $ npm run setup
$ npm start $ npm start
``` ```
> 📢 npm 访问速度较慢,阿里员工可以使用 tnpm其他同学建议使用 cnpm 或者指定镜像 registry。
lowcode-engine 启动后,提供了几个 umd 文件,可以结合 [lowcode-demo](https://github.com/alibaba/lowcode-demo) 项目做调试,文件代理规则参考这里。 lowcode-engine 启动后,提供了几个 umd 文件,可以结合 [lowcode-demo](https://github.com/alibaba/lowcode-demo) 项目做调试,文件代理规则参考这里。
## 🤝 参与共建 ## 🤝 参与共建
请先阅读 [贡献指南 WIP](http://lowcode-engine.cn/docs/react/contributing-cn). 请先阅读 [贡献指南 WIP](http://lowcode-engine.cn/?docs#/doc?url=contributing).
> 强烈推荐阅读 [《提问的智慧》](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way)、[《如何向开源社区提问题》](https://github.com/seajs/seajs/issues/545) 和 [《如何有效地报告 Bug》](http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html)、[《如何向开源项目提交无法解答的问题》](https://zhuanlan.zhihu.com/p/25795393),更好的问题更容易获得帮助。 > 强烈推荐阅读 [《提问的智慧》](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way)、[《如何向开源社区提问题》](https://github.com/seajs/seajs/issues/545) 和 [《如何有效地报告 Bug》](http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html)、[《如何向开源项目提交无法解答的问题》](https://zhuanlan.zhihu.com/p/25795393),更好的问题更容易获得帮助。

View File

@ -16,15 +16,13 @@
[npm-image]: https://img.shields.io/npm/v/@alilc/lowcode-engine.svg?style=flat-square [npm-image]: https://img.shields.io/npm/v/@alilc/lowcode-engine.svg?style=flat-square
[npm-url]: http://npmjs.org/package/@alilc/lowcode-engine [npm-url]: http://npmjs.org/package/@alilc/lowcode-engine
[github-action-image]: https://github.com/ant-design/ant-design/workflows/%E2%9C%85%20test/badge.svg
[github-action-url]: https://github.com/ant-design/ant-design/actions?query=workflow%3A%22%E2%9C%85+test%22
[download-image]: https://img.shields.io/npm/dm/@alilc/lowcode-engine.svg?style=flat-square [download-image]: https://img.shields.io/npm/dm/@alilc/lowcode-engine.svg?style=flat-square
[download-url]: https://npmjs.org/package/@alilc/lowcode-engine [download-url]: https://npmjs.org/package/@alilc/lowcode-engine
[help-wanted-image]: https://flat.badgen.net/github/label-issues/ant-design/ant-design/help%20wanted/open [help-wanted-image]: https://flat.badgen.net/github/label-issues/alibaba/lowcode-engine/help%20wanted/open
[help-wanted-url]: https://github.com/alibaba/lowcode-engine/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22 [help-wanted-url]: https://github.com/alibaba/lowcode-engine/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22
[discussions-image]: https://img.shields.io/badge/discussions-on%20github-blue?style=flat-square [discussions-image]: https://img.shields.io/badge/discussions-on%20github-blue?style=flat-square
[discussions-url]: https://github.com/ant-design/ant-design/discussions [discussions-url]: https://github.com/alibaba/lowcode-engine/discussions
[issues-helper-image]: https://img.shields.io/badge/using-issues--helper-orange?style=flat-square [issues-helper-image]: https://img.shields.io/badge/using-issues--helper-orange?style=flat-square
[issues-helper-url]: https://github.com/actions-cool/issues-helper [issues-helper-url]: https://github.com/actions-cool/issues-helper
@ -92,14 +90,21 @@ init(document.getElementById('lce'));
``` ```
### cdn 可选方式: ### cdn 可选方式:
#### 方式 1unpkg #### 方式 1alifd cdn
```html
https://alifd.alicdn.com/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js
https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js
```
#### 方式 2unpkg
```html ```html
https://unpkg.com/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js https://unpkg.com/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js
https://unpkg.com/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js https://unpkg.com/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js
``` ```
#### 方式 2jsdelivr #### 方式 3jsdelivr
```html ```html
https://cdn.jsdelivr.net/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js https://cdn.jsdelivr.net/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js
@ -129,10 +134,12 @@ $ npm run setup
$ npm start $ npm start
``` ```
> 📢 npm 访问速度较慢,阿里员工可以使用 tnpm其他同学建议使用 cnpm 或者指定镜像 registry。
lowcode-engine 启动后,提供了几个 umd 文件,可以结合 [lowcode-demo](https://github.com/alibaba/lowcode-demo) 项目做调试,文件代理规则参考这里。 lowcode-engine 启动后,提供了几个 umd 文件,可以结合 [lowcode-demo](https://github.com/alibaba/lowcode-demo) 项目做调试,文件代理规则参考这里。
## 🤝 参与共建 ## 🤝 参与共建
请先阅读 [贡献指南 WIP](http://lowcode-engine.cn/docs/react/contributing-cn). 请先阅读 [贡献指南 WIP](http://lowcode-engine.cn/?docs#/doc?url=contributing).
> 强烈推荐阅读 [《提问的智慧》](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way)、[《如何向开源社区提问题》](https://github.com/seajs/seajs/issues/545) 和 [《如何有效地报告 Bug》](http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html)、[《如何向开源项目提交无法解答的问题》](https://zhuanlan.zhihu.com/p/25795393),更好的问题更容易获得帮助。 > 强烈推荐阅读 [《提问的智慧》](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way)、[《如何向开源社区提问题》](https://github.com/seajs/seajs/issues/545) 和 [《如何有效地报告 Bug》](http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html)、[《如何向开源项目提交无法解答的问题》](https://zhuanlan.zhihu.com/p/25795393),更好的问题更容易获得帮助。

View File

@ -1,12 +1,21 @@
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const fse = require('fs-extra');
// read from lerna
const lernaConfig = JSON.parse(fse.readFileSync('../../lerna.json', 'utf8'));
const { version } = lernaConfig;
module.exports = ({ onGetWebpackConfig }) => { module.exports = ({ context, onGetWebpackConfig }) => {
onGetWebpackConfig((config) => { onGetWebpackConfig((config) => {
config.resolve config.resolve
.plugin('tsconfigpaths') .plugin('tsconfigpaths')
.use(TsconfigPathsPlugin, [{ .use(TsconfigPathsPlugin, [{
configFile: './tsconfig.json', configFile: './tsconfig.json',
}]); }]);
config
.plugin('define')
.use(context.webpack.DefinePlugin, [{
VERSION_PLACEHOLDER: JSON.stringify(version),
}]);
config.plugins.delete('hot'); config.plugins.delete('hot');
config.devServer.hot(false); config.devServer.hot(false);
}); });

View File

@ -13,7 +13,7 @@
"start": "build-scripts start", "start": "build-scripts start",
"version:update": "node ./scripts/version.js", "version:update": "node ./scripts/version.js",
"build": "NODE_OPTIONS=--max_old_space_size=8192 build-scripts build --skip-demo", "build": "NODE_OPTIONS=--max_old_space_size=8192 build-scripts build --skip-demo",
"build:umd": "NODE_OPTIONS=--max_old_space_size=8192 build-scripts build --config build.umd.json && npm run version:update", "build:umd": "NODE_OPTIONS=--max_old_space_size=8192 build-scripts build --config build.umd.json",
"test": "build-scripts test --config build.test.json --jest-passWithNoTests" "test": "build-scripts test --config build.test.json --jest-passWithNoTests"
}, },
"license": "MIT", "license": "MIT",
@ -41,7 +41,7 @@
"build-plugin-fusion": "0.1.17-beta.0", "build-plugin-fusion": "0.1.17-beta.0",
"build-plugin-moment-locales": "^0.1.0", "build-plugin-moment-locales": "^0.1.0",
"build-plugin-react-app": "^1.8.0", "build-plugin-react-app": "^1.8.0",
"fs-extra": "^9.0.1", "fs-extra": "^10.0.0",
"prop-types": "^15.7.2", "prop-types": "^15.7.2",
"tsconfig-paths-webpack-plugin": "^3.2.0" "tsconfig-paths-webpack-plugin": "^3.2.0"
}, },

View File

@ -176,10 +176,9 @@ export {
})(); })();
let engineInited = false; let engineInited = false;
export const version = '{{VERSION_PLACEHOLDER}}'; // @ts-ignore webpack Define variable
const DEFAULT_VERSION = '1.0.0'; export const version = VERSION_PLACEHOLDER;
const runtimeVersion = version.indexOf('VERSION_PLACEHOLDER') > -1 ? DEFAULT_VERSION : version; engineConfig.set('ENGINE_VERSION', version);
engineConfig.set('ENGINE_VERSION', runtimeVersion);
export async function init( export async function init(
container?: HTMLElement, container?: HTMLElement,
options?: EngineOptions, options?: EngineOptions,

View File

@ -1,4 +1,8 @@
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const fse = require('fs-extra');
// read from lerna
const lernaConfig = JSON.parse(fse.readFileSync('../../lerna.json', 'utf8'));
const { version } = lernaConfig;
module.exports = ({ context, onGetWebpackConfig }) => { module.exports = ({ context, onGetWebpackConfig }) => {
onGetWebpackConfig((config) => { onGetWebpackConfig((config) => {
@ -7,6 +11,11 @@ module.exports = ({ context, onGetWebpackConfig }) => {
configFile: './tsconfig.json', configFile: './tsconfig.json',
}, },
]); ]);
config
.plugin('define')
.use(context.webpack.DefinePlugin, [{
VERSION_PLACEHOLDER: JSON.stringify(version),
}]);
config.plugins.delete('hot'); config.plugins.delete('hot');
config.devServer.hot(false); config.devServer.hot(false);
if (context.command === 'start') { if (context.command === 'start') {

View File

@ -14,6 +14,7 @@
}, },
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@alib/build-scripts": "^0.1.18" "@alib/build-scripts": "^0.1.18",
"fs-extra": "^10.0.0"
} }
} }