Skip to content

Commit 8545ead

Browse files
committed
fix: optimize traffic config outputs
1 parent eafcc02 commit 8545ead

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"license": "MIT",
1313
"dependencies": {
1414
"download": "^8.0.0",
15-
"tencent-component-toolkit": "^1.12.3",
15+
"tencent-component-toolkit": "^1.12.6",
1616
"type": "^2.0.0"
1717
}
1818
}

src/serverless.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,25 @@ class ServerlessComponent extends Component {
6464
...outputs[curRegion]
6565
}
6666

67-
if (scfOutput.LastVersion) {
68-
outputs[curRegion].lastVersion = scfOutput.LastVersion
69-
this.state.lastVersion = scfOutput.LastVersion
67+
// default version is $LATEST
68+
outputs[curRegion].lastVersion = scfOutput.LastVersion
69+
? scfOutput.LastVersion
70+
: this.state.lastVersion || '$LATEST'
71+
72+
// default traffic is 1.0, it can also be 0, so we should compare to undefined
73+
outputs[curRegion].traffic = scfOutput.Traffic
74+
? scfOutput.Traffic
75+
: this.state.traffic !== undefined
76+
? this.state.traffic
77+
: 1
78+
79+
if (outputs[curRegion].traffic !== 1 && scfOutput.ConfigTrafficVersion) {
80+
outputs[curRegion].configTrafficVersion = scfOutput.ConfigTrafficVersion
81+
this.state.configTrafficVersion = scfOutput.ConfigTrafficVersion
7082
}
7183

72-
if (scfOutput.Traffic) {
73-
outputs[curRegion].traffic = scfOutput.Traffic
74-
this.state.functionTraffic = scfOutput.Traffic
75-
}
84+
this.state.lastVersion = outputs[curRegion].lastVersion
85+
this.state.traffic = outputs[curRegion].traffic
7686
}
7787
uploadCodeHandler.push(funcDeployer())
7888
}

0 commit comments

Comments
 (0)