Skip to content

Commit a83ef70

Browse files
committed
fix: bucket name contain appid bug
1 parent e6d9a7c commit a83ef70

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"dependencies": {
33
"download": "^8.0.0",
4-
"tencent-component-toolkit": "^1.13.0",
4+
"tencent-component-toolkit": "^1.14.5",
55
"type": "^2.0.0"
66
}
77
}

src/utils.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const generateId = () =>
1111
.substring(6)
1212

1313
const getCodeZipPath = async (instance, code) => {
14-
console.log(`Packaging ${CONFIGS.frameworkFullname} application...`)
14+
console.log(`Packaging ${CONFIGS.compFullname} application...`)
1515

1616
// unzip source zip file
1717
let zipPath
@@ -20,7 +20,7 @@ const getCodeZipPath = async (instance, code) => {
2020
const downloadPath = `/tmp/${generateId()}`
2121
const filename = 'template'
2222

23-
console.log(`Installing Default ${CONFIGS.frameworkFullname} App...`)
23+
console.log(`Installing Default ${CONFIGS.compFullname} App...`)
2424
await download(CONFIGS.templateUrl, downloadPath, {
2525
filename: `${filename}.zip`
2626
})
@@ -32,6 +32,14 @@ const getCodeZipPath = async (instance, code) => {
3232
return zipPath
3333
}
3434

35+
const removeAppid = (str, appid) => {
36+
const suffix = `-${appid}`
37+
if (!str || str.indexOf(suffix) === -1) {
38+
return str
39+
}
40+
return str.slice(0, -suffix.length)
41+
}
42+
3543
const prepareInputs = async (instance, inputs) => {
3644
let code = inputs.src || ''
3745
code =
@@ -53,6 +61,8 @@ const prepareInputs = async (instance, inputs) => {
5361
console.log(`Files unzipped into ${sourceDirectory}...`)
5462

5563
const region = inputs.region || CONFIGS.region
64+
const bucketName =
65+
removeAppid(inputs.bucketName, appId) || `sls-website-${region}-${generateId()}`
5666

5767
return {
5868
useDefault: !code.src,
@@ -63,7 +73,7 @@ const prepareInputs = async (instance, inputs) => {
6373
envPath: path.join(sourceDirectory, envPath)
6474
},
6575
env: inputs.env,
66-
bucket: `${inputs.bucketName || `sls-website-${region}-${generateId()}`}-${appId}`,
76+
bucket: `${bucketName}-${appId}`,
6777
region: region,
6878
protocol: inputs.protocol || CONFIGS.protocol,
6979
cors: inputs.cors

0 commit comments

Comments
 (0)