Skip to content

Commit b9288e3

Browse files
committed
chore: 优化生成引擎版本号的逻辑
1 parent 4f4ac51 commit b9288e3

File tree

7 files changed

+52
-18
lines changed

7 files changed

+52
-18
lines changed

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,21 @@ init(document.getElementById('lce'));
9090
```
9191

9292
### cdn 可选方式:
93-
#### 方式 1:unpkg
93+
#### 方式 1:alifd cdn
94+
```html
95+
https://alifd.alicdn.com/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js
96+
97+
https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js
98+
```
99+
100+
#### 方式 2:unpkg
94101
```html
95102
https://unpkg.com/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js
96103

97104
https://unpkg.com/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js
98105
```
99106

100-
#### 方式 2:jsdelivr
107+
#### 方式 3:jsdelivr
101108
```html
102109
https://cdn.jsdelivr.net/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js
103110

@@ -127,10 +134,12 @@ $ npm run setup
127134
$ npm start
128135
```
129136

137+
> 📢 npm 访问速度较慢,阿里员工可以使用 tnpm,其他同学建议使用 cnpm 或者指定镜像 registry。
138+
130139
lowcode-engine 启动后,提供了几个 umd 文件,可以结合 [lowcode-demo](https://github.com/alibaba/lowcode-demo) 项目做调试,文件代理规则参考这里。
131140

132141
## 🤝 参与共建
133142

134-
请先阅读 [贡献指南 WIP](http://lowcode-engine.cn/docs/react/contributing-cn).
143+
请先阅读 [贡献指南 WIP](http://lowcode-engine.cn/?docs#/doc?url=contributing).
135144

136145
> 强烈推荐阅读 [《提问的智慧》](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),更好的问题更容易获得帮助。

packages/engine/README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@
1616

1717
[npm-image]: https://img.shields.io/npm/v/@alilc/lowcode-engine.svg?style=flat-square
1818
[npm-url]: http://npmjs.org/package/@alilc/lowcode-engine
19-
[github-action-image]: https://github.com/ant-design/ant-design/workflows/%E2%9C%85%20test/badge.svg
20-
[github-action-url]: https://github.com/ant-design/ant-design/actions?query=workflow%3A%22%E2%9C%85+test%22
2119

2220
[download-image]: https://img.shields.io/npm/dm/@alilc/lowcode-engine.svg?style=flat-square
2321
[download-url]: https://npmjs.org/package/@alilc/lowcode-engine
24-
[help-wanted-image]: https://flat.badgen.net/github/label-issues/ant-design/ant-design/help%20wanted/open
22+
[help-wanted-image]: https://flat.badgen.net/github/label-issues/alibaba/lowcode-engine/help%20wanted/open
2523
[help-wanted-url]: https://github.com/alibaba/lowcode-engine/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22
2624
[discussions-image]: https://img.shields.io/badge/discussions-on%20github-blue?style=flat-square
27-
[discussions-url]: https://github.com/ant-design/ant-design/discussions
25+
[discussions-url]: https://github.com/alibaba/lowcode-engine/discussions
2826

2927
[issues-helper-image]: https://img.shields.io/badge/using-issues--helper-orange?style=flat-square
3028
[issues-helper-url]: https://github.com/actions-cool/issues-helper
@@ -92,14 +90,21 @@ init(document.getElementById('lce'));
9290
```
9391

9492
### cdn 可选方式:
95-
#### 方式 1:unpkg
93+
#### 方式 1:alifd cdn
94+
```html
95+
https://alifd.alicdn.com/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js
96+
97+
https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js
98+
```
99+
100+
#### 方式 2:unpkg
96101
```html
97102
https://unpkg.com/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js
98103

99104
https://unpkg.com/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js
100105
```
101106

102-
#### 方式 2:jsdelivr
107+
#### 方式 3:jsdelivr
103108
```html
104109
https://cdn.jsdelivr.net/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js
105110

@@ -129,10 +134,12 @@ $ npm run setup
129134
$ npm start
130135
```
131136

137+
> 📢 npm 访问速度较慢,阿里员工可以使用 tnpm,其他同学建议使用 cnpm 或者指定镜像 registry。
138+
132139
lowcode-engine 启动后,提供了几个 umd 文件,可以结合 [lowcode-demo](https://github.com/alibaba/lowcode-demo) 项目做调试,文件代理规则参考这里。
133140

134141
## 🤝 参与共建
135142

136-
请先阅读 [贡献指南 WIP](http://lowcode-engine.cn/docs/react/contributing-cn).
143+
请先阅读 [贡献指南 WIP](http://lowcode-engine.cn/?docs#/doc?url=contributing).
137144

138145
> 强烈推荐阅读 [《提问的智慧》](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),更好的问题更容易获得帮助。

packages/engine/build.plugin.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
2+
const fse = require('fs-extra');
3+
// read from lerna
4+
const lernaConfig = JSON.parse(fse.readFileSync('../../lerna.json', 'utf8'));
5+
const { version } = lernaConfig;
26

3-
module.exports = ({ onGetWebpackConfig }) => {
7+
module.exports = ({ context, onGetWebpackConfig }) => {
48
onGetWebpackConfig((config) => {
59
config.resolve
610
.plugin('tsconfigpaths')
711
.use(TsconfigPathsPlugin, [{
812
configFile: './tsconfig.json',
913
}]);
14+
config
15+
.plugin('define')
16+
.use(context.webpack.DefinePlugin, [{
17+
VERSION_PLACEHOLDER: JSON.stringify(version),
18+
}]);
1019
config.plugins.delete('hot');
1120
config.devServer.hot(false);
1221
});

packages/engine/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"start": "build-scripts start",
1414
"version:update": "node ./scripts/version.js",
1515
"build": "NODE_OPTIONS=--max_old_space_size=8192 build-scripts build --skip-demo",
16-
"build:umd": "NODE_OPTIONS=--max_old_space_size=8192 build-scripts build --config build.umd.json && npm run version:update",
16+
"build:umd": "NODE_OPTIONS=--max_old_space_size=8192 build-scripts build --config build.umd.json",
1717
"test": "build-scripts test --config build.test.json --jest-passWithNoTests"
1818
},
1919
"license": "MIT",
@@ -41,7 +41,7 @@
4141
"build-plugin-fusion": "0.1.17-beta.0",
4242
"build-plugin-moment-locales": "^0.1.0",
4343
"build-plugin-react-app": "^1.8.0",
44-
"fs-extra": "^9.0.1",
44+
"fs-extra": "^10.0.0",
4545
"prop-types": "^15.7.2",
4646
"tsconfig-paths-webpack-plugin": "^3.2.0"
4747
},

packages/engine/src/engine-core.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,9 @@ export {
176176
})();
177177

178178
let engineInited = false;
179-
export const version = '{{VERSION_PLACEHOLDER}}';
180-
const DEFAULT_VERSION = '1.0.0';
181-
const runtimeVersion = version.indexOf('VERSION_PLACEHOLDER') > -1 ? DEFAULT_VERSION : version;
182-
engineConfig.set('ENGINE_VERSION', runtimeVersion);
179+
// @ts-ignore webpack Define variable
180+
export const version = VERSION_PLACEHOLDER;
181+
engineConfig.set('ENGINE_VERSION', version);
183182
export async function init(
184183
container?: HTMLElement,
185184
options?: EngineOptions,

packages/ignitor/build.plugin.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
2+
const fse = require('fs-extra');
3+
// read from lerna
4+
const lernaConfig = JSON.parse(fse.readFileSync('../../lerna.json', 'utf8'));
5+
const { version } = lernaConfig;
26

37
module.exports = ({ context, onGetWebpackConfig }) => {
48
onGetWebpackConfig((config) => {
@@ -7,6 +11,11 @@ module.exports = ({ context, onGetWebpackConfig }) => {
711
configFile: './tsconfig.json',
812
},
913
]);
14+
config
15+
.plugin('define')
16+
.use(context.webpack.DefinePlugin, [{
17+
VERSION_PLACEHOLDER: JSON.stringify(version),
18+
}]);
1019
config.plugins.delete('hot');
1120
config.devServer.hot(false);
1221
if (context.command === 'start') {

packages/ignitor/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
},
1515
"license": "MIT",
1616
"devDependencies": {
17-
"@alib/build-scripts": "^0.1.18"
17+
"@alib/build-scripts": "^0.1.18",
18+
"fs-extra": "^10.0.0"
1819
}
1920
}

0 commit comments

Comments
 (0)