From b3938b69a1f9548b25bc7357f8020f217c46733e Mon Sep 17 00:00:00 2001 From: JackLian Date: Tue, 20 Dec 2022 21:33:13 +0800 Subject: [PATCH] chore: add new cdn support --- docs/README.md | 7 ++--- docs/docs/guide/create/useEditor.md | 4 ++- docs/docs/participate/flow.md | 15 ++++++--- docs/package.json | 3 +- docs/scripts/sync-oss.js | 48 +++++++++++++++++++++++++++++ package.json | 3 +- packages/engine/README-zh_CN.md | 25 +++++++++------ packages/engine/README.md | 25 +++++++++------ scripts/sync-oss.js | 48 +++++++++++++++++++++++++++++ 9 files changed, 148 insertions(+), 30 deletions(-) create mode 100644 docs/scripts/sync-oss.js create mode 100644 scripts/sync-oss.js diff --git a/docs/README.md b/docs/README.md index 12c8f1fbe..85da75163 100644 --- a/docs/README.md +++ b/docs/README.md @@ -27,8 +27,8 @@ $ yarn build 1. npm run build 2. npm publish # 记得改下版本号,比如 1.0.1 -# 发布完后执行 tnpm sync -3. tnpm sync +# 发布完后执行 tnpm syncOss 同步到 uipaas CDN +3. tnpm syncOss 4. 更新 diamond 版本 1.0.1 5. lowcode-engine.cn 站点生效 @@ -37,10 +37,9 @@ $ yarn build ## 功能 - [x] 支持本地离线搜搜 -- [x] 版本化文档管理 +- [x] 版本化文档管理 - [x] 离线静态部署 - [x] 主题(fork 宜搭开发者中心) ## 使用文档 https://docusaurus.io/zh-CN/docs/docs-introduction - diff --git a/docs/docs/guide/create/useEditor.md b/docs/docs/guide/create/useEditor.md index 21de39108..7a778e02d 100644 --- a/docs/docs/guide/create/useEditor.md +++ b/docs/docs/guide/create/useEditor.md @@ -80,7 +80,9 @@ sidebar_position: 0 ``` -> 注:如果 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) ### 配置打包 diff --git a/docs/docs/participate/flow.md b/docs/docs/participate/flow.md index 0a088807a..b8b804e12 100644 --- a/docs/docs/participate/flow.md +++ b/docs/docs/participate/flow.md @@ -70,9 +70,10 @@ sidebar_position: 2 ```bash npm run pub ``` -5. 同步到 tnpm 源 & alifd CDN(此步骤将发布在 npm 源的包同步到阿里内网源,因为 alifd cdn 将依赖内网 npm 源) +5. 同步到 tnpm 源 & alifd CDN & uipaas CDN(此步骤将发布在 npm 源的包同步到阿里内网源,因为 alifd cdn 将依赖内网 npm 源) ```bash tnpm run sync + tnpm run syncOss ``` 6. 更新[发布日志](https://github.com/alibaba/lowcode-engine/releases) 7. 合并 release/x.x.x 到 main 分支 @@ -102,9 +103,10 @@ sidebar_position: 2 ```bash npm run pub:preminor ``` -5. 同步到 tnpm 源 & alifd CDN +5. 同步到 tnpm 源 & alifd CDN & uipaas CDN ```bash tnpm run sync + tnpm run syncOss ``` #### 发某 z 位版本首个 beta,如 1.0.1-beta.0 @@ -129,9 +131,10 @@ sidebar_position: 2 ```bash npm run pub:prepatch ``` -5. 同步到 tnpm 源 & alifd CDN +5. 同步到 tnpm 源 & alifd CDN & uipaas CDN ```bash tnpm run sync + tnpm run syncOss ``` #### 发某版本非首个 beta,如 1.0.1-beta.0 -> 1.0.1-beta.1 @@ -151,9 +154,10 @@ sidebar_position: 2 ```bash npm run pub:prerelease ``` -5. 同步到 tnpm 源 & alifd CDN +5. 同步到 tnpm 源 & alifd CDN & uipaas CDN ```bash tnpm run sync + tnpm run syncOss ``` @@ -173,9 +177,10 @@ sidebar_position: 2 ```bash npm publish --tag beta ``` -4. 同步到 tnpm 源 & alifd CDN +4. 同步到 tnpm 源 & alifd CDN & uipaas CDN ```bash tnpm run sync + tnpm run syncOss ``` **官网生效** diff --git a/docs/package.json b/docs/package.json index d03668ad9..1cf731345 100644 --- a/docs/package.json +++ b/docs/package.json @@ -16,7 +16,8 @@ "serve": "docusaurus serve", "write-translations": "docusaurus write-translations", "write-heading-ids": "docusaurus write-heading-ids", - "typecheck": "tsc" + "typecheck": "tsc", + "syncOss": "node ./scripts/sync-oss.js" }, "dependencies": { "@docusaurus/core": "^2.2.0", diff --git a/docs/scripts/sync-oss.js b/docs/scripts/sync-oss.js new file mode 100644 index 000000000..407f113bd --- /dev/null +++ b/docs/scripts/sync-oss.js @@ -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(); \ No newline at end of file diff --git a/package.json b/package.json index 08e649a3f..572958d82 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,8 @@ "test": "lerna run test --stream", "test:snapshot": "lerna run test:snapshot", "watchdog:build": "node ./scripts/watchdog.js", - "sync": "./scripts/sync.sh" + "sync": "./scripts/sync.sh", + "syncOss": "node ./scripts/sync-oss.js" }, "husky": { "hooks": { diff --git a/packages/engine/README-zh_CN.md b/packages/engine/README-zh_CN.md index 000a711f5..793ee050b 100644 --- a/packages/engine/README-zh_CN.md +++ b/packages/engine/README-zh_CN.md @@ -97,26 +97,33 @@ init(document.getElementById('lce')); ### cdn 可选方式: #### 方式 1(推荐):alifd 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-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 ``` -#### 方式 2:unpkg +#### 方式 2(推荐):uipaas cdn ```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 ``` -#### 方式 3:jsdelivr +#### 方式 3:unpkg ```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 +#### 方式 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 +``` + +#### 方式 5:使用自有 cdn 将源码中 packages/engine/dist 和 packages/(react|rax)-simulator-renderer/dist 下的文件传至你的 cdn 提供商 ## 🔗 相关链接 diff --git a/packages/engine/README.md b/packages/engine/README.md index 8b11e5a1a..8ce675923 100644 --- a/packages/engine/README.md +++ b/packages/engine/README.md @@ -97,26 +97,33 @@ init(document.getElementById('lce')); ### cdn optional method: #### Method 1: alifd 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-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 -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 -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 ## 🔗 Related Links diff --git a/scripts/sync-oss.js b/scripts/sync-oss.js new file mode 100644 index 000000000..422f7162d --- /dev/null +++ b/scripts/sync-oss.js @@ -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(); \ No newline at end of file