Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for deploy percentage #83

Merged
merged 4 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.falsy(config.deployPercentage);
});

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