chore: add new cdn support

This commit is contained in:
JackLian 2022-12-20 21:33:13 +08:00 committed by 刘菊萍(絮黎)
parent 3fe9882f9d
commit b3938b69a1
9 changed files with 148 additions and 30 deletions

View File

@ -27,8 +27,8 @@ $ yarn build
1. npm run build 1. npm run build
2. npm publish # 记得改下版本号,比如 1.0.1 2. npm publish # 记得改下版本号,比如 1.0.1
# 发布完后执行 tnpm sync # 发布完后执行 tnpm syncOss 同步到 uipaas CDN
3. tnpm sync 3. tnpm syncOss
4. 更新 diamond 版本 1.0.1 4. 更新 diamond 版本 1.0.1
5. lowcode-engine.cn 站点生效 5. lowcode-engine.cn 站点生效
@ -37,10 +37,9 @@ $ yarn build
## 功能 ## 功能
- [x] 支持本地离线搜搜 - [x] 支持本地离线搜搜
- [x] 版本化文档管理 - [x] 版本化文档管理
- [x] 离线静态部署 - [x] 离线静态部署
- [x] 主题fork 宜搭开发者中心) - [x] 主题fork 宜搭开发者中心)
## 使用文档 ## 使用文档
https://docusaurus.io/zh-CN/docs/docs-introduction https://docusaurus.io/zh-CN/docs/docs-introduction

View File

@ -80,7 +80,9 @@ sidebar_position: 0
<!-- 低代码引擎官方扩展的主包 --> <!-- 低代码引擎官方扩展的主包 -->
<script crossorigin="anonymous" src="https://alifd.alicdn.com/npm/@alilc/lowcode-engine-ext@latest/dist/js/engine-ext.js"></script> <script crossorigin="anonymous" src="https://alifd.alicdn.com/npm/@alilc/lowcode-engine-ext@latest/dist/js/engine-ext.js"></script>
``` ```
> 注:如果 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) > 注:如果 unpkg 的服务比较缓慢,您可以使用 alicdn 来获得确定版本的低代码引擎,如对于引擎的 1.0.18 版本,可用以下官方 cdn 替代
> - [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)
> - [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)
### 配置打包 ### 配置打包

View File

@ -70,9 +70,10 @@ sidebar_position: 2
```bash ```bash
npm run pub npm run pub
``` ```
5. 同步到 tnpm 源 & alifd CDN此步骤将发布在 npm 源的包同步到阿里内网源,因为 alifd cdn 将依赖内网 npm 源) 5. 同步到 tnpm 源 & alifd CDN & uipaas CDN(此步骤将发布在 npm 源的包同步到阿里内网源,因为 alifd cdn 将依赖内网 npm 源)
```bash ```bash
tnpm run sync tnpm run sync
tnpm run syncOss
``` ```
6. 更新[发布日志](https://github.com/alibaba/lowcode-engine/releases) 6. 更新[发布日志](https://github.com/alibaba/lowcode-engine/releases)
7. 合并 release/x.x.x 到 main 分支 7. 合并 release/x.x.x 到 main 分支
@ -102,9 +103,10 @@ sidebar_position: 2
```bash ```bash
npm run pub:preminor npm run pub:preminor
``` ```
5. 同步到 tnpm 源 & alifd CDN 5. 同步到 tnpm 源 & alifd CDN & uipaas CDN
```bash ```bash
tnpm run sync tnpm run sync
tnpm run syncOss
``` ```
#### 发某 z 位版本首个 beta如 1.0.1-beta.0 #### 发某 z 位版本首个 beta如 1.0.1-beta.0
@ -129,9 +131,10 @@ sidebar_position: 2
```bash ```bash
npm run pub:prepatch npm run pub:prepatch
``` ```
5. 同步到 tnpm 源 & alifd CDN 5. 同步到 tnpm 源 & alifd CDN & uipaas CDN
```bash ```bash
tnpm run sync tnpm run sync
tnpm run syncOss
``` ```
#### 发某版本非首个 beta如 1.0.1-beta.0 -> 1.0.1-beta.1 #### 发某版本非首个 beta如 1.0.1-beta.0 -> 1.0.1-beta.1
@ -151,9 +154,10 @@ sidebar_position: 2
```bash ```bash
npm run pub:prerelease npm run pub:prerelease
``` ```
5. 同步到 tnpm 源 & alifd CDN 5. 同步到 tnpm 源 & alifd CDN & uipaas CDN
```bash ```bash
tnpm run sync tnpm run sync
tnpm run syncOss
``` ```
@ -173,9 +177,10 @@ sidebar_position: 2
```bash ```bash
npm publish --tag beta npm publish --tag beta
``` ```
4. 同步到 tnpm 源 & alifd CDN 4. 同步到 tnpm 源 & alifd CDN & uipaas CDN
```bash ```bash
tnpm run sync tnpm run sync
tnpm run syncOss
``` ```
**官网生效** **官网生效**

View File

@ -16,7 +16,8 @@
"serve": "docusaurus serve", "serve": "docusaurus serve",
"write-translations": "docusaurus write-translations", "write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids", "write-heading-ids": "docusaurus write-heading-ids",
"typecheck": "tsc" "typecheck": "tsc",
"syncOss": "node ./scripts/sync-oss.js"
}, },
"dependencies": { "dependencies": {
"@docusaurus/core": "^2.2.0", "@docusaurus/core": "^2.2.0",

48
docs/scripts/sync-oss.js Normal file
View File

@ -0,0 +1,48 @@
#!/usr/bin/env node
const http = require('http');
const package = require('../package.json');
const { version, name } = package;
const options = {
method: 'PUT',
// 暂时使用 日常环境的 uipaas-node上线后可切换成线上环境 https://uipaas-node.alibaba-inc.com
hostname: 'uipaas-node.alibaba.net',
path: '/staticAssets/cdn/packages',
headers: {
'Content-Type': 'application/json',
Cookie: 'locale=en-us',
},
maxRedirects: 20,
};
const onResponse = function (res) {
const chunks = [];
res.on('data', (chunk) => {
chunks.push(chunk);
});
res.on('end', (chunk) => {
const body = Buffer.concat(chunks);
console.table(JSON.stringify(JSON.parse(body.toString()), null, 2));
});
res.on('error', (error) => {
console.error(error);
});
};
const req = http.request(options, onResponse);
const postData = JSON.stringify({
packages: [
{
packageName: name,
version,
},
],
// 可以发布指定源的 npm 包,默认公网 npm
useTnpm: false,
});
req.write(postData);
req.end();

View File

@ -32,7 +32,8 @@
"test": "lerna run test --stream", "test": "lerna run test --stream",
"test:snapshot": "lerna run test:snapshot", "test:snapshot": "lerna run test:snapshot",
"watchdog:build": "node ./scripts/watchdog.js", "watchdog:build": "node ./scripts/watchdog.js",
"sync": "./scripts/sync.sh" "sync": "./scripts/sync.sh",
"syncOss": "node ./scripts/sync-oss.js"
}, },
"husky": { "husky": {
"hooks": { "hooks": {

View File

@ -97,26 +97,33 @@ init(document.getElementById('lce'));
### cdn 可选方式: ### cdn 可选方式:
#### 方式 1推荐alifd cdn #### 方式 1推荐alifd cdn
```html ```html
https://alifd.alicdn.com/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js https://alifd.alicdn.com/npm/@alilc/lowcode-engine@1.0.18/dist/js/engine-core.js
https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@1.0.18/dist/js/react-simulator-renderer.js
``` ```
#### 方式 2unpkg #### 方式 2(推荐)uipaas cdn
```html ```html
https://unpkg.com/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.0.18/dist/js/engine-core.js
https://unpkg.com/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js https://uipaas-assets.com/prod/npm/@alilc/lowcode-react-simulator-renderer/1.0.18/dist/js/react-simulator-renderer.js
``` ```
#### 方式 3jsdelivr #### 方式 3unpkg
```html ```html
https://cdn.jsdelivr.net/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js https://unpkg.com/@alilc/lowcode-engine@1.0.18/dist/js/engine-core.js
https://cdn.jsdelivr.net/npm/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js https://unpkg.com/@alilc/lowcode-react-simulator-renderer@1.0.18/dist/js/react-simulator-renderer.js
``` ```
#### 方式 4使用自有 cdn #### 方式 4jsdelivr
```html
https://cdn.jsdelivr.net/npm/@alilc/lowcode-engine@1.0.18/dist/js/engine-core.js
https://cdn.jsdelivr.net/npm/@alilc/lowcode-react-simulator-renderer@1.0.18/dist/js/react-simulator-renderer.js
```
#### 方式 5使用自有 cdn
将源码中 packages/engine/dist 和 packages/(react|rax)-simulator-renderer/dist 下的文件传至你的 cdn 提供商 将源码中 packages/engine/dist 和 packages/(react|rax)-simulator-renderer/dist 下的文件传至你的 cdn 提供商
## 🔗 相关链接 ## 🔗 相关链接

View File

@ -97,26 +97,33 @@ init(document.getElementById('lce'));
### cdn optional method: ### cdn optional method:
#### Method 1: alifd cdn #### Method 1: alifd cdn
```html ```html
https://alifd.alicdn.com/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js https://alifd.alicdn.com/npm/@alilc/lowcode-engine@1.0.18/dist/js/engine-core.js
https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@1.0.18/dist/js/react-simulator-renderer.js
``` ```
#### Method 2: unpkg #### Method 2: uipaas cdn
```html ```html
https://unpkg.com/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js https://uipaas-assets.com/prod/npm/@alilc/lowcode-engine/1.0.18/dist/js/engine-core.js
https://unpkg.com/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js https://uipaas-assets.com/prod/npm/@alilc/lowcode-react-simulator-renderer/1.0.18/dist/js/react-simulator-renderer.js
``` ```
#### Method 3: jsdelivr #### Method 3: unpkg
```html ```html
https://cdn.jsdelivr.net/npm/@alilc/lowcode-engine@1.0.0/dist/js/engine-core.js https://unpkg.com/@alilc/lowcode-engine@1.0.18/dist/js/engine-core.js
https://cdn.jsdelivr.net/npm/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/js/react-simulator-renderer.js https://unpkg.com/@alilc/lowcode-react-simulator-renderer@1.0.18/dist/js/react-simulator-renderer.js
``` ```
#### Method 4: Use your own cdn #### Method 4: jsdelivr
```html
https://cdn.jsdelivr.net/npm/@alilc/lowcode-engine@1.0.18/dist/js/engine-core.js
https://cdn.jsdelivr.net/npm/@alilc/lowcode-react-simulator-renderer@1.0.18/dist/js/react-simulator-renderer.js
```
#### Method 5: Use your own cdn
Pass the files under packages/engine/dist and packages/(react|rax)-simulator-renderer/dist in the source code to your cdn provider Pass the files under packages/engine/dist and packages/(react|rax)-simulator-renderer/dist in the source code to your cdn provider
## 🔗 Related Links ## 🔗 Related Links

48
scripts/sync-oss.js Normal file
View File

@ -0,0 +1,48 @@
#!/usr/bin/env node
const http = require('http');
const package = require('../packages/engine/package.json');
const { version, name } = package;
const options = {
method: 'PUT',
// 暂时使用 日常环境的 uipaas-node上线后可切换成线上环境 https://uipaas-node.alibaba-inc.com
hostname: 'uipaas-node.alibaba.net',
path: '/staticAssets/cdn/packages',
headers: {
'Content-Type': 'application/json',
Cookie: 'locale=en-us',
},
maxRedirects: 20,
};
const onResponse = function (res) {
const chunks = [];
res.on('data', (chunk) => {
chunks.push(chunk);
});
res.on('end', (chunk) => {
const body = Buffer.concat(chunks);
console.table(JSON.stringify(JSON.parse(body.toString()), null, 2));
});
res.on('error', (error) => {
console.error(error);
});
};
const req = http.request(options, onResponse);
const postData = JSON.stringify({
packages: [
{
packageName: name,
version,
},
],
// 可以发布指定源的 npm 包,默认公网 npm
useTnpm: false,
});
req.write(postData);
req.end();