Skip to content

Commit fdf4e0c

Browse files
author
dfounderliu
committed
fix prePublishComponnet & postPublishComponent
1 parent fcdd1cc commit fdf4e0c

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

sdk/serverless/index.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Serverless {
6464

6565
async getComponentVersion(name, version) {
6666
const componentVersion = {
67-
ComponentName: name,
67+
ComponentName: name,
6868
ComponentVersion: version
6969
}
7070
const req = new SlsModels.GetComponentVersionRequest();
@@ -73,8 +73,13 @@ class Serverless {
7373
}
7474

7575

76-
async prePublishComponent(body) {
76+
async prePublishComponent(body = {}) {
77+
if(!body.component || !body.component.componentName || !body.component.version){
78+
throw new Error('componentName and version are required.')
79+
}
7780
const pubComponent = {
81+
ComponentName:body.component.componentName,
82+
ComponentVersion: body.component.version,
7883
Body: body
7984
}
8085

@@ -84,8 +89,13 @@ class Serverless {
8489
}
8590

8691

87-
async postPublishComponent(body) {
92+
async postPublishComponent(body = {}) {
93+
if(!body.componentName || !body.componentVersion){
94+
throw new Error('componentName and componentVersion are required.')
95+
}
8896
const pubComponent = {
97+
ComponentName:body.componentName,
98+
ComponentVersion: body.componentVersion,
8999
Body: body
90100
}
91101
const req = new SlsModels.PostPublishComponentRequest();
@@ -156,19 +166,19 @@ class Serverless {
156166

157167
// async unpublishComponentVersion(name, version) {
158168
// const componentVersion = {
159-
// Name: name,
169+
// Name: name,
160170
// ComponentVersion: version
161171
// }
162172
// const req = new SlsModels.UnpublishComponentVersionRequest();
163173
// req.from_json_string(JSON.stringify(componentVersion));
164174
// return await this._call('UnpublishComponentVersion', req);
165175
// }
166-
176+
167177

168178
// async publishComponentVersion({name, componentVersion, org, author, description, keywords, license}) {
169-
179+
170180
// const camRole = new BindRole.BindRole({
171-
// SecretId: this.secret_id,
181+
// SecretId: this.secret_id,
172182
// SecretKey: this.secret_key,
173183
// token: this.options.token
174184
// });
@@ -193,7 +203,7 @@ class Serverless {
193203

194204
// async fetchComponentMetadata(name, version) {
195205
// const componentVersion = {
196-
// Name: name,
206+
// Name: name,
197207
// ComponentVersion: version
198208
// }
199209
// const req = new SlsModels.FetchComponentMetadataRequest();
@@ -202,4 +212,4 @@ class Serverless {
202212
// }
203213
}
204214

205-
module.exports = Serverless;
215+
module.exports = Serverless;

0 commit comments

Comments
 (0)