Skip to content

Commit b3938b6

Browse files
JackLianliujuping
authored andcommitted
chore: add new cdn support
1 parent 3fe9882 commit b3938b6

File tree

9 files changed

+148
-30
lines changed

9 files changed

+148
-30
lines changed

docs/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ $ yarn build
2727
1. npm run build
2828
2. npm publish # 记得改下版本号,比如 1.0.1
2929

30-
# 发布完后执行 tnpm sync
31-
3. tnpm sync
30+
# 发布完后执行 tnpm syncOss 同步到 uipaas CDN
31+
3. tnpm syncOss
3232

3333
4. 更新 diamond 版本 1.0.1
3434
5. lowcode-engine.cn 站点生效
@@ -37,10 +37,9 @@ $ yarn build
3737

3838
## 功能
3939
- [x] 支持本地离线搜搜
40-
- [x] 版本化文档管理
40+
- [x] 版本化文档管理
4141
- [x] 离线静态部署
4242
- [x] 主题(fork 宜搭开发者中心)
4343

4444
## 使用文档
4545
https://docusaurus.io/zh-CN/docs/docs-introduction
46-

docs/docs/guide/create/useEditor.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ sidebar_position: 0
8080
<!-- 低代码引擎官方扩展的主包 -->
8181
<script crossorigin="anonymous" src="https://alifd.alicdn.com/npm/@alilc/lowcode-engine-ext@latest/dist/js/engine-ext.js"></script>
8282
```
83-
> 注:如果 unpkg 的服务比较缓慢,您可以使用 alicdn 来获得确定版本的低代码引擎,如对于引擎的 1.0.1 版本,可用 [https://alifd.alicdn.com/npm/@alilc/lowcode-engine@1.0.1/dist/js/engine-core.js](https://alifd.alicdn.com/npm/@alilc/lowcode-engine@1.0.1/dist/js/engine-core.js)
83+
> 注:如果 unpkg 的服务比较缓慢,您可以使用 alicdn 来获得确定版本的低代码引擎,如对于引擎的 1.0.18 版本,可用以下官方 cdn 替代
84+
> - [https://alifd.alicdn.com/npm/@alilc/lowcode-engine@1.0.18/dist/js/engine-core.js](https://alifd.alicdn.com/npm/@alilc/lowcode-engine@1.0.18/dist/js/engine-core.js)
85+
> - [https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.0.18/dist/js/engine-core.js](https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.0.18/dist/js/engine-core.js)
8486
8587

8688
### 配置打包

docs/docs/participate/flow.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ sidebar_position: 2
7070
```bash
7171
npm run pub
7272
```
73-
5. 同步到 tnpm 源 & alifd CDN(此步骤将发布在 npm 源的包同步到阿里内网源,因为 alifd cdn 将依赖内网 npm 源)
73+
5. 同步到 tnpm 源 & alifd CDN & uipaas CDN(此步骤将发布在 npm 源的包同步到阿里内网源,因为 alifd cdn 将依赖内网 npm 源)
7474
```bash
7575
tnpm run sync
76+
tnpm run syncOss
7677
```
7778
6. 更新[发布日志](https://github.com/alibaba/lowcode-engine/releases)
7879
7. 合并 release/x.x.x 到 main 分支
@@ -102,9 +103,10 @@ sidebar_position: 2
102103
```bash
103104
npm run pub:preminor
104105
```
105-
5. 同步到 tnpm 源 & alifd CDN
106+
5. 同步到 tnpm 源 & alifd CDN & uipaas CDN
106107
```bash
107108
tnpm run sync
109+
tnpm run syncOss
108110
```
109111

110112
#### 发某 z 位版本首个 beta,如 1.0.1-beta.0
@@ -129,9 +131,10 @@ sidebar_position: 2
129131
```bash
130132
npm run pub:prepatch
131133
```
132-
5. 同步到 tnpm 源 & alifd CDN
134+
5. 同步到 tnpm 源 & alifd CDN & uipaas CDN
133135
```bash
134136
tnpm run sync
137+
tnpm run syncOss
135138
```
136139

137140
#### 发某版本非首个 beta,如 1.0.1-beta.0 -> 1.0.1-beta.1
@@ -151,9 +154,10 @@ sidebar_position: 2
151154
```bash
152155
npm run pub:prerelease
153156
```
154-
5. 同步到 tnpm 源 & alifd CDN
157+
5. 同步到 tnpm 源 & alifd CDN & uipaas CDN
155158
```bash
156159
tnpm run sync
160+
tnpm run syncOss
157161
```
158162

159163

@@ -173,9 +177,10 @@ sidebar_position: 2
173177
```bash
174178
npm publish --tag beta
175179
```
176-
4. 同步到 tnpm 源 & alifd CDN
180+
4. 同步到 tnpm 源 & alifd CDN & uipaas CDN
177181
```bash
178182
tnpm run sync
183+
tnpm run syncOss
179184
```
180185

181186
**官网生效**

docs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"serve": "docusaurus serve",
1717
"write-translations": "docusaurus write-translations",
1818
"write-heading-ids": "docusaurus write-heading-ids",
19-
"typecheck": "tsc"
19+
"typecheck": "tsc",
20+
"syncOss": "node ./scripts/sync-oss.js"
2021
},
2122
"dependencies": {
2223
"@docusaurus/core": "^2.2.0",

docs/scripts/sync-oss.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env node
2+
const http = require('http');
3+
const package = require('../package.json');
4+
const { version, name } = package;
5+
const options = {
6+
method: 'PUT',
7+
// 暂时使用 日常环境的 uipaas-node,上线后可切换成线上环境 https://uipaas-node.alibaba-inc.com
8+
hostname: 'uipaas-node.alibaba.net',
9+
path: '/staticAssets/cdn/packages',
10+
headers: {
11+
'Content-Type': 'application/json',
12+
Cookie: 'locale=en-us',
13+
},
14+
maxRedirects: 20,
15+
};
16+
17+
const onResponse = function (res) {
18+
const chunks = [];
19+
res.on('data', (chunk) => {
20+
chunks.push(chunk);
21+
});
22+
23+
res.on('end', (chunk) => {
24+
const body = Buffer.concat(chunks);
25+
console.table(JSON.stringify(JSON.parse(body.toString()), null, 2));
26+
});
27+
28+
res.on('error', (error) => {
29+
console.error(error);
30+
});
31+
};
32+
33+
const req = http.request(options, onResponse);
34+
35+
const postData = JSON.stringify({
36+
packages: [
37+
{
38+
packageName: name,
39+
version,
40+
},
41+
],
42+
// 可以发布指定源的 npm 包,默认公网 npm
43+
useTnpm: false,
44+
});
45+
46+
req.write(postData);
47+
48+
req.end();

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"test": "lerna run test --stream",
3333
"test:snapshot": "lerna run test:snapshot",
3434
"watchdog:build": "node ./scripts/watchdog.js",
35-
"sync": "./scripts/sync.sh"
35+
"sync": "./scripts/sync.sh",
36+
"syncOss": "node ./scripts/sync-oss.js"
3637
},
3738
"husky": {
3839
"hooks": {

packages/engine/README-zh_CN.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,26 +97,33 @@ init(document.getElementById('lce'));
9797
### cdn 可选方式:
9898
#### 方式 1(推荐):alifd cdn
9999
```html
100-
https://alifd.alicdn.com/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js
100+
https://alifd.alicdn.com/npm/@alilc/lowcode-engine@1.0.18/dist/js/engine-core.js
101101

102-
https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js
102+
https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@1.0.18/dist/js/react-simulator-renderer.js
103103
```
104104

105-
#### 方式 2:unpkg
105+
#### 方式 2(推荐):uipaas cdn
106106
```html
107-
https://unpkg.com/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js
107+
https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.0.18/dist/js/engine-core.js
108108

109-
https://unpkg.com/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js
109+
https://uipaas-assets.com/prod/npm/@alilc/lowcode-react-simulator-renderer/1.0.18/dist/js/react-simulator-renderer.js
110110
```
111111

112-
#### 方式 3:jsdelivr
112+
#### 方式 3:unpkg
113113
```html
114-
https://cdn.jsdelivr.net/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js
114+
https://unpkg.com/@alilc/lowcode-engine@1.0.18/dist/js/engine-core.js
115115

116-
https://cdn.jsdelivr.net/npm/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js
116+
https://unpkg.com/@alilc/lowcode-react-simulator-renderer@1.0.18/dist/js/react-simulator-renderer.js
117117
```
118118

119-
#### 方式 4:使用自有 cdn
119+
#### 方式 4:jsdelivr
120+
```html
121+
https://cdn.jsdelivr.net/npm/@alilc/lowcode-engine@1.0.18/dist/js/engine-core.js
122+
123+
https://cdn.jsdelivr.net/npm/@alilc/lowcode-react-simulator-renderer@1.0.18/dist/js/react-simulator-renderer.js
124+
```
125+
126+
#### 方式 5:使用自有 cdn
120127
将源码中 packages/engine/dist 和 packages/(react|rax)-simulator-renderer/dist 下的文件传至你的 cdn 提供商
121128

122129
## 🔗 相关链接

packages/engine/README.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,26 +97,33 @@ init(document.getElementById('lce'));
9797
### cdn optional method:
9898
#### Method 1: alifd cdn
9999
```html
100-
https://alifd.alicdn.com/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js
100+
https://alifd.alicdn.com/npm/@alilc/lowcode-engine@1.0.18/dist/js/engine-core.js
101101

102-
https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js
102+
https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@1.0.18/dist/js/react-simulator-renderer.js
103103
```
104104

105-
#### Method 2: unpkg
105+
#### Method 2: uipaas cdn
106106
```html
107-
https://unpkg.com/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js
107+
https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.0.18/dist/js/engine-core.js
108108

109-
https://unpkg.com/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js
109+
https://uipaas-assets.com/prod/npm/@alilc/lowcode-react-simulator-renderer/1.0.18/dist/js/react-simulator-renderer.js
110110
```
111111

112-
#### Method 3: jsdelivr
112+
#### Method 3: unpkg
113113
```html
114-
https://cdn.jsdelivr.net/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js
114+
https://unpkg.com/@alilc/lowcode-engine@1.0.18/dist/js/engine-core.js
115115

116-
https://cdn.jsdelivr.net/npm/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js
116+
https://unpkg.com/@alilc/lowcode-react-simulator-renderer@1.0.18/dist/js/react-simulator-renderer.js
117117
```
118118

119-
#### Method 4: Use your own cdn
119+
#### Method 4: jsdelivr
120+
```html
121+
https://cdn.jsdelivr.net/npm/@alilc/lowcode-engine@1.0.18/dist/js/engine-core.js
122+
123+
https://cdn.jsdelivr.net/npm/@alilc/lowcode-react-simulator-renderer@1.0.18/dist/js/react-simulator-renderer.js
124+
```
125+
126+
#### Method 5: Use your own cdn
120127
Pass the files under packages/engine/dist and packages/(react|rax)-simulator-renderer/dist in the source code to your cdn provider
121128

122129
## 🔗 Related Links

scripts/sync-oss.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env node
2+
const http = require('http');
3+
const package = require('../packages/engine/package.json');
4+
const { version, name } = package;
5+
const options = {
6+
method: 'PUT',
7+
// 暂时使用 日常环境的 uipaas-node,上线后可切换成线上环境 https://uipaas-node.alibaba-inc.com
8+
hostname: 'uipaas-node.alibaba.net',
9+
path: '/staticAssets/cdn/packages',
10+
headers: {
11+
'Content-Type': 'application/json',
12+
Cookie: 'locale=en-us',
13+
},
14+
maxRedirects: 20,
15+
};
16+
17+
const onResponse = function (res) {
18+
const chunks = [];
19+
res.on('data', (chunk) => {
20+
chunks.push(chunk);
21+
});
22+
23+
res.on('end', (chunk) => {
24+
const body = Buffer.concat(chunks);
25+
console.table(JSON.stringify(JSON.parse(body.toString()), null, 2));
26+
});
27+
28+
res.on('error', (error) => {
29+
console.error(error);
30+
});
31+
};
32+
33+
const req = http.request(options, onResponse);
34+
35+
const postData = JSON.stringify({
36+
packages: [
37+
{
38+
packageName: name,
39+
version,
40+
},
41+
],
42+
// 可以发布指定源的 npm 包,默认公网 npm
43+
useTnpm: false,
44+
});
45+
46+
req.write(postData);
47+
48+
req.end();

0 commit comments

Comments
 (0)