Skip to content

Commit

Permalink
Add support for deploy percentage (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
remdash authored Jun 11, 2024
1 parent c12fa8a commit d8de0c3
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const cli = meow(`
--refresh-token OAuth2 Refresh Token (environment variable REFRESH_TOKEN)
--auto-publish Can be used with the "upload" command (deprecated, use \`chrome-webstore-upload\` without a command instead)
--trusted-testers Can be used with the "publish" command
--deploy-percentage Can be used with the "publish" command. Defaults to 100
Examples
Upload and publish a new version, using existing environment variables and the default value for --source
Expand Down Expand Up @@ -59,6 +60,7 @@ const {
isPublish,
autoPublish,
trustedTesters,
deployPercentage,
} = await createConfig(cli.input[0], cli.flags);

const spinner = ora();
Expand Down Expand Up @@ -87,6 +89,7 @@ async function doAutoPublish() {
const publishResponse = await publish(
{ apiConfig, token },
trustedTesters && 'trustedTesters',
deployPercentage,
);
spinner.stop();
handlePublishStatus(publishResponse);
Expand All @@ -113,6 +116,7 @@ async function doPublish() {
const response = await publish(
{ apiConfig },
trustedTesters && 'trustedTesters',
deployPercentage,
);
spinner.stop();
handlePublishStatus(response);
Expand Down
1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export default async function getConfig(command, flags) {
isPublish: command === 'publish',
autoPublish: flags.autoPublish || !command,
trustedTesters: flags.trustedTesters,
deployPercentage: flags.deployPercentage,
};
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
]
},
"dependencies": {
"chrome-webstore-upload": "^3.0.0",
"chrome-webstore-upload": "^3.1.0",
"junk": "^4.0.1",
"meow": "^12.1.1",
"ora": "^7.0.1",
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ $ chrome-webstore-upload --help
--refresh-token OAuth2 Refresh Token (environment variable REFRESH_TOKEN)
--auto-publish Can be used with the "upload" command (deprecated, use `chrome-webstore-upload` without a command instead)
--trusted-testers Can be used with the "publish" command
--deploy-percentage Can be used with the "publish" command. Defaults to 100
Examples
Upload and publish a new version, using existing environment variables and the default value for --source
Expand Down
12 changes: 12 additions & 0 deletions test/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ test('Auto Publish', async t => {
t.true(config.autoPublish);
});

test('Publish with deploy percentage', async t => {
const config = await createConfig(null, { deployPercentage: 5 });

t.is(config.deployPercentage, 5);
});

test('Publish without deploy percentage', async t => {
const config = await createConfig(null, {});

t.is(config.deployPercentage, undefined);
});

test('Auto upload and publish', async t => {
const config = await createConfig('', {});
t.false(config.isPublish);
Expand Down
4 changes: 2 additions & 2 deletions wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export async function upload({ apiConfig, zipPath, token }) {
return client.uploadExisting(zipStream, token);
}

export async function publish({ apiConfig, token }, publishTarget) {
export async function publish({ apiConfig, token }, publishTarget, deployPercentage) {
const client = getClient(apiConfig);
return client.publish(publishTarget, token);
return client.publish(publishTarget, token, deployPercentage);
}

export async function fetchToken(apiConfig) {
Expand Down

0 comments on commit d8de0c3

Please sign in to comment.