diff --git a/src/chrome/chrome-api.ts b/src/chrome/chrome-api.ts index 0df3d4c..8ec5a98 100644 --- a/src/chrome/chrome-api.ts +++ b/src/chrome/chrome-api.ts @@ -1,7 +1,5 @@ -import { createFetch } from 'ofetch'; import { FormData } from 'formdata-node'; import { fileFromPath } from 'formdata-node/file-from-path'; -import consola from 'consola'; import { fetch } from '../utils/fetch'; export interface CwsApiOptions { @@ -61,12 +59,24 @@ export class CwsApi { extensionId: string; publishTarget: 'default' | 'trustedTesters'; token: CwsTokenDetails; + deployPercentage?: number; + reviewExemption?: boolean; }) { const Authorization = await this.getAuthHeader(params.token); const endpoint = this.publishEndpoint(params.extensionId); if (params.publishTarget) endpoint.searchParams.append('publishTarget', params.publishTarget); + if (params.deployPercentage != null) + endpoint.searchParams.set( + 'deployPercentage', + String(params.deployPercentage), + ); + if (params.reviewExemption != null) + endpoint.searchParams.set( + 'reviewExemption', + String(params.reviewExemption), + ); await fetch(endpoint.href, { method: 'POST', diff --git a/src/chrome/chrome-web-store.ts b/src/chrome/chrome-web-store.ts index 7969782..9e12424 100644 --- a/src/chrome/chrome-web-store.ts +++ b/src/chrome/chrome-web-store.ts @@ -11,6 +11,8 @@ export const ChromeWebStoreOptions = z.object({ clientSecret: z.string().min(1), refreshToken: z.string().min(1), publishTarget: z.enum(['default', 'trustedTesters']).default('default'), + deployPercentage: z.number().int().min(1).max(100).optional(), + reviewExemption: z.boolean().default(false), skipSubmitReview: z.boolean().default(false), }); export type ChromeWebStoreOptions = z.infer; diff --git a/src/config.ts b/src/config.ts index 95f35b5..68e57a1 100644 --- a/src/config.ts +++ b/src/config.ts @@ -35,6 +35,13 @@ export function resolveConfig( config.chrome?.publishTarget ?? stringEnv('CHROME_PUBLISH_TARGET') ?? 'default', + deployPercentage: + config.chrome?.deployPercentage ?? + intEnv('CHROME_DEPLOY_PERCENTAGE'), + reviewExemption: + config.chrome?.reviewExemption ?? + booleanEnv('CHROME_REVIEW_EXEMPTION') ?? + false, skipSubmitReview: config.chrome?.skipSubmitReview ?? booleanEnv('CHROME_SKIP_SUBMIT_REVIEW') ?? @@ -109,6 +116,10 @@ function stringEnv( return !process.env[name] ? undefined : (process.env[name] as T); } +function intEnv(name: keyof CustomEnv): number | undefined { + return !process.env[name] ? undefined : parseInt(process.env[name]!); +} + export const InlineConfig = z.object({ /** * When true, just check authentication, don't upload any zip files or submit any updates. @@ -142,9 +153,11 @@ interface CustomEnv { CHROME_CLIENT_ID: string | undefined; CHROME_CLIENT_SECRET: string | undefined; + CHROME_DEPLOY_PERCENTAGE: string | undefined; CHROME_EXTENSION_ID: string | undefined; CHROME_PUBLISH_TARGET: string | undefined; CHROME_REFRESH_TOKEN: string | undefined; + CHROME_REVIEW_EXEMPTION: string | undefined; CHROME_SKIP_SUBMIT_REVIEW: string | undefined; CHROME_ZIP: string | undefined;