Skip to content

Commit

Permalink
fix: add options to specify platform by plugin options
Browse files Browse the repository at this point in the history
  • Loading branch information
wangwenlu committed Feb 14, 2023
1 parent 5784070 commit 6fc85da
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
7 changes: 7 additions & 0 deletions docs/docs/bundle/plugin-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ interface Options {
*/
project?: string

/**
* Your Perfsee platform url.
*
* Used for private deployment of Perfsee, equivalent to setting `PERFSEE_PLATFORM_HOST`.
*/
platform?: string

/**
* Authentication token used for uploading build to remote server.
* will also read from env `PERFSEE_TOKEN` if not provided.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ type Options = {
* Perfsee 平台对应的项目 ID。
*
* **如果想要上传打包产物到平台进行分析,则该选项必填。**
* **Required if you want ot upload the build to Perfsee platform for further analysis.**
*/
project?: string

/**
* Perfsee 平台对应的 url。
*
* 用于私有部署 perfsee,等同于设置 `PERFSEE_PLATFORM_HOST`。
*/
platform?: string

/**
* 用于产物上传流程鉴权的凭证。
*
Expand Down
3 changes: 2 additions & 1 deletion packages/plugins/utils/src/build-upload-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ export class BuildUploadClient {
})
.join('&')

const res = await fetch(`${getBuildEnv().platform}/api/v1/artifacts?${query}`, {
const platform = this.options.platform ?? getBuildEnv().platform
const res = await fetch(`${platform}/api/v1/artifacts?${query}`, {
method: 'POST',
body: stream,
headers: {
Expand Down
5 changes: 5 additions & 0 deletions packages/plugins/utils/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ export interface CommonPluginOptions {
*/
project?: string

/**
* Your Perfsee platform url.
*/
platform?: string

/**
* Give a uniq name for the bundled artifact.
*
Expand Down

0 comments on commit 6fc85da

Please sign in to comment.