Skip to content

Commit a29dd65

Browse files
kochrterickzhaogeorgexu99
authored
feat(publisher-gcs): only include provided upload options (#3576)
* Separate config properties out and only include provided upload options * exclamation point * run prettier --------- Co-authored-by: Erick Zhao <[email protected]> Co-authored-by: George Xu <[email protected]>
1 parent 04945d5 commit a29dd65

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

Diff for: packages/publisher/gcs/src/PublisherGCS.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,26 @@ export default class PublisherGCS extends PublisherStatic<PublisherGCSConfig> {
2323
async publish({ makeResults, setStatusLine }: PublisherOptions): Promise<void> {
2424
const artifacts: GCSArtifact[] = [];
2525

26-
if (!this.config.bucket) {
26+
const { storageOptions, bucket: configBucket, folder, ...uploadOptions } = this.config;
27+
28+
if (!configBucket) {
2729
throw new Error('In order to publish to Google Cloud Storage you must set the "bucket" property in your Forge config.');
2830
}
2931

3032
for (const makeResult of makeResults) {
3133
artifacts.push(
3234
...makeResult.artifacts.map((artifact) => ({
3335
path: artifact,
34-
keyPrefix: this.config.folder || this.GCSKeySafe(makeResult.packageJSON.name),
36+
keyPrefix: folder || this.GCSKeySafe(makeResult.packageJSON.name),
3537
platform: makeResult.platform,
3638
arch: makeResult.arch,
3739
}))
3840
);
3941
}
4042

41-
const storage = new Storage(this.config.storageOptions);
43+
const storage = new Storage(storageOptions);
4244

43-
const bucket = storage.bucket(this.config.bucket);
45+
const bucket = storage.bucket(configBucket);
4446

4547
d('creating Google Cloud Storage client with options:', this.config);
4648

@@ -51,14 +53,11 @@ export default class PublisherGCS extends PublisherStatic<PublisherGCSConfig> {
5153
await Promise.all(
5254
artifacts.map(async (artifact) => {
5355
d('uploading:', artifact.path);
54-
5556
await bucket.upload(artifact.path, {
5657
metadata: this.config.metadataGenerator ? this.config.metadataGenerator(artifact) : {},
5758
gzip: true,
5859
destination: this.keyForArtifact(artifact),
59-
predefinedAcl: this.config.predefinedAcl,
60-
public: this.config.public,
61-
private: this.config.private,
60+
...uploadOptions,
6261
});
6362

6463
uploaded += 1;

0 commit comments

Comments
 (0)