Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Commit c845ed3

Browse files
committed
fix(website): support lowcode prepay
1 parent 69605e2 commit c845ed3

6 files changed

Lines changed: 75 additions & 30 deletions

File tree

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"build": "lerna run build",
1010
"prepublishOnly": "npm run build && lerna run prepublishOnly",
1111
"publish": "lerna publish --registry https://registry.npmjs.org/",
12+
"postpublish": "node scripts/sync-mirrors.js",
1213
"publish:beta": "lerna publish --canary --preid beta --pre-dist-tag beta",
1314
"test": "lerna run test",
1415
"lint": "npx eslint . --fix",
@@ -37,6 +38,7 @@
3738
"@cloudbase/toolbox": "^0.6.0",
3839
"del": "^5.1.0",
3940
"eslint-config-tencent": "^1.0.0",
41+
"got": "^11.8.1",
4042
"mdmod": "^0.4.0",
4143
"rimraf": "^3.0.2"
4244
},

packages/framework-plugin-website/src/index.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ const DEFAULT_INPUTS = {
2424
},
2525
};
2626

27+
enum PAYMODE {
28+
POSTPAID = 'postpaid',
29+
PREPAYMENT = 'prepayment',
30+
}
31+
32+
enum ENV_CHANNEL {
33+
LOWCODE = 'low_code',
34+
}
35+
2736
/**
2837
* 导出接口用于生成 JSON Schema 来进行智能提示
2938
*/
@@ -79,6 +88,10 @@ class WebsitePlugin extends Plugin {
7988
protected zipBuilder: ZipBuilder;
8089
protected resolvedInputs: ResolvedInputs;
8190
protected buildOutput: BuildResult;
91+
protected env?: {
92+
PayMode: PAYMODE;
93+
EnvChanel: string;
94+
};
8295
// 静态托管信息
8396
protected website: any;
8497

@@ -124,7 +137,7 @@ class WebsitePlugin extends Plugin {
124137
const [website, staticConfig] = uploadResults as any;
125138

126139
return {
127-
EnvType: 'PostPay',
140+
EnvType: this.env?.PayMode === PAYMODE.PREPAYMENT ? 'PrePay' : 'PostPay',
128141
Resources: Object.assign(
129142
{},
130143
this.getStaticResourceSam(
@@ -322,11 +335,15 @@ class WebsitePlugin extends Plugin {
322335
throw new Error(`当前账号下不存在 ${this.api.envId} 环境`);
323336
}
324337

325-
if (env.PayMode !== 'postpaid') {
338+
if (
339+
env.PayMode !== PAYMODE.POSTPAID &&
340+
env.EnvChanel !== ENV_CHANNEL.LOWCODE
341+
) {
326342
throw new Error(
327343
'网站托管当前只能部署到按量付费的环境下,请先在控制台切换计费方式'
328344
);
329345
}
346+
this.env = env;
330347
}
331348

332349
/**

scripts/build-runner/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const promisifyGlob = promisify(glob);
3636
return prev;
3737
},
3838
{
39-
'@cloudbase/framework-plugin-low-code': 'release',
39+
'@cloudbase/framework-plugin-low-code': '0.2.1',
4040
}
4141
),
4242
};

scripts/build-runner/src/Jenkinsfile

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,6 @@ pipeline {
3434
stage("登录") {
3535
steps {
3636
sh '''
37-
# 设置腾讯云镜像源
38-
npm config set registry http://mirrors.cloud.tencent.com/npm/
39-
40-
# yarn 优先使用缓存
41-
yarn config set install.prefer-offline true
42-
43-
# pnpm 全局缓存目录设置
44-
pnpm config set store-dir /root/.pnpm-store
45-
46-
# npm 默认优先使用缓存
47-
npm config set prefer-offline true
48-
4937
# 使用临时密钥登录
5038
cloudbase login --apiKeyId "$API_SECRET_ID" --apiKey "$API_SECRET_KEY" --token "$API_TOKEN"
5139
@@ -64,9 +52,6 @@ pipeline {
6452
steps {
6553
sh '''
6654
cd /root/cloudbase-workspace
67-
cd "$PROJ_DIR"
68-
ls -al
69-
pwd
7055
CI=true cloudbase framework deploy -e "$ENV_ID" --verbose
7156
'''
7257
}
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
22
"name": "cloudbase-framework-registry",
33
"dependencies": {
4-
"@cloudbase/framework-plugin-low-code": "release",
5-
"@cloudbase/framework-plugin-auth": "^1.6.5",
6-
"@cloudbase/framework-plugin-container": "^1.6.5",
7-
"@cloudbase/framework-plugin-dart": "^1.6.5",
8-
"@cloudbase/framework-plugin-database": "^1.6.5",
9-
"@cloudbase/framework-plugin-deno": "^1.6.5",
10-
"@cloudbase/framework-plugin-function": "^1.6.5",
11-
"@cloudbase/framework-plugin-mp": "^1.6.5",
12-
"@cloudbase/framework-plugin-next": "^1.6.5",
13-
"@cloudbase/framework-plugin-node": "^1.6.5",
14-
"@cloudbase/framework-plugin-nuxt": "^1.6.5",
15-
"@cloudbase/framework-plugin-website": "^1.6.5"
4+
"@cloudbase/framework-plugin-low-code": "0.2.1",
5+
"@cloudbase/framework-plugin-auth": "^1.6.12",
6+
"@cloudbase/framework-plugin-container": "^1.6.12",
7+
"@cloudbase/framework-plugin-dart": "^1.6.12",
8+
"@cloudbase/framework-plugin-database": "^1.6.12",
9+
"@cloudbase/framework-plugin-deno": "^1.6.12",
10+
"@cloudbase/framework-plugin-function": "^1.6.12",
11+
"@cloudbase/framework-plugin-mp": "^1.6.12",
12+
"@cloudbase/framework-plugin-next": "^1.6.12",
13+
"@cloudbase/framework-plugin-node": "^1.6.12",
14+
"@cloudbase/framework-plugin-nuxt": "^1.6.12",
15+
"@cloudbase/framework-plugin-website": "^1.6.12"
1616
}
1717
}

scripts/sync-mirrors.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Tencent is pleased to support the open source community by making CloudBaseFramework - 云原生一体化部署工具 available.
3+
*
4+
* Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
5+
*
6+
* Please refer to license text included with this package for license details.
7+
*/
8+
9+
const fs = require('fs');
10+
const path = require('path');
11+
const { promisify } = require('util');
12+
const got = require('got');
13+
14+
const allDeps = {};
15+
16+
main();
17+
18+
async function main() {
19+
let files = await promisify(fs.readdir)(path.join(process.cwd(), 'packages'));
20+
Promise.all(
21+
files
22+
.filter((file) => {
23+
return file.match(/^[^.]/);
24+
})
25+
.map(async (file) => {
26+
const packageJson = require(path.join(
27+
process.cwd(),
28+
'packages',
29+
file,
30+
'package.json'
31+
));
32+
const name = packageJson.name;
33+
const url = `http://mirrors.tencent.com/npm/${name}`;
34+
35+
const response = await got(url, { responseType: 'json' });
36+
const isUpdated = !!response.body.versions[packageJson.version];
37+
38+
console.log(packageJson.name, isUpdated ? '已经更新' : '未更新');
39+
})
40+
);
41+
}

0 commit comments

Comments
 (0)