Skip to content

Commit d8de0c3

Browse files
authored
Add support for deploy percentage (#83)
1 parent c12fa8a commit d8de0c3

File tree

6 files changed

+21
-3
lines changed

6 files changed

+21
-3
lines changed

cli.js

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const cli = meow(`
2828
--refresh-token OAuth2 Refresh Token (environment variable REFRESH_TOKEN)
2929
--auto-publish Can be used with the "upload" command (deprecated, use \`chrome-webstore-upload\` without a command instead)
3030
--trusted-testers Can be used with the "publish" command
31+
--deploy-percentage Can be used with the "publish" command. Defaults to 100
3132
3233
Examples
3334
Upload and publish a new version, using existing environment variables and the default value for --source
@@ -59,6 +60,7 @@ const {
5960
isPublish,
6061
autoPublish,
6162
trustedTesters,
63+
deployPercentage,
6264
} = await createConfig(cli.input[0], cli.flags);
6365

6466
const spinner = ora();
@@ -87,6 +89,7 @@ async function doAutoPublish() {
8789
const publishResponse = await publish(
8890
{ apiConfig, token },
8991
trustedTesters && 'trustedTesters',
92+
deployPercentage,
9093
);
9194
spinner.stop();
9295
handlePublishStatus(publishResponse);
@@ -113,6 +116,7 @@ async function doPublish() {
113116
const response = await publish(
114117
{ apiConfig },
115118
trustedTesters && 'trustedTesters',
119+
deployPercentage,
116120
);
117121
spinner.stop();
118122
handlePublishStatus(response);

config.js

+1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ export default async function getConfig(command, flags) {
1616
isPublish: command === 'publish',
1717
autoPublish: flags.autoPublish || !command,
1818
trustedTesters: flags.trustedTesters,
19+
deployPercentage: flags.deployPercentage,
1920
};
2021
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
]
4747
},
4848
"dependencies": {
49-
"chrome-webstore-upload": "^3.0.0",
49+
"chrome-webstore-upload": "^3.1.0",
5050
"junk": "^4.0.1",
5151
"meow": "^12.1.1",
5252
"ora": "^7.0.1",

readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ $ chrome-webstore-upload --help
4242
--refresh-token OAuth2 Refresh Token (environment variable REFRESH_TOKEN)
4343
--auto-publish Can be used with the "upload" command (deprecated, use `chrome-webstore-upload` without a command instead)
4444
--trusted-testers Can be used with the "publish" command
45+
--deploy-percentage Can be used with the "publish" command. Defaults to 100
4546
4647
Examples
4748
Upload and publish a new version, using existing environment variables and the default value for --source

test/config.js

+12
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ test('Auto Publish', async t => {
5858
t.true(config.autoPublish);
5959
});
6060

61+
test('Publish with deploy percentage', async t => {
62+
const config = await createConfig(null, { deployPercentage: 5 });
63+
64+
t.is(config.deployPercentage, 5);
65+
});
66+
67+
test('Publish without deploy percentage', async t => {
68+
const config = await createConfig(null, {});
69+
70+
t.is(config.deployPercentage, undefined);
71+
});
72+
6173
test('Auto upload and publish', async t => {
6274
const config = await createConfig('', {});
6375
t.false(config.isPublish);

wrapper.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ export async function upload({ apiConfig, zipPath, token }) {
1313
return client.uploadExisting(zipStream, token);
1414
}
1515

16-
export async function publish({ apiConfig, token }, publishTarget) {
16+
export async function publish({ apiConfig, token }, publishTarget, deployPercentage) {
1717
const client = getClient(apiConfig);
18-
return client.publish(publishTarget, token);
18+
return client.publish(publishTarget, token, deployPercentage);
1919
}
2020

2121
export async function fetchToken(apiConfig) {

0 commit comments

Comments
 (0)