Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Sep 19, 2021
1 parent 5b715f8 commit 6cc1a08
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 78 deletions.
21 changes: 0 additions & 21 deletions LICENSE.md

This file was deleted.

4 changes: 2 additions & 2 deletions Travis autoupload guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ With this setup, you can automatically deploy your extension when creating a tag
```json
{
"devDependencies": {
"chrome-webstore-upload-cli": "^1.0.0"
"chrome-webstore-upload-cli": "^2.0.0"
},
"scripts": {
"release": "webstore upload --source=path/to/extension --auto-publish"
"release": "chrome-webstore-upload upload --source=path/to/extension --auto-publish"
}
}
```
Expand Down
38 changes: 26 additions & 12 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const cli = meow(`

const preliminaryValidation = validateInput(cli.input, cli.flags);
if (preliminaryValidation.error) {
console.error((preliminaryValidation.error));
console.error(preliminaryValidation.error);
cli.showHelp(1);
}

Expand Down Expand Up @@ -83,7 +83,10 @@ async function doAutoPublish() {
}

spinnerStart('Publishing');
const publishResponse = await publish({ apiConfig, token }, trustedTesters && 'trustedTesters');
const publishResponse = await publish(
{ apiConfig, token },
trustedTesters && 'trustedTesters',
);
spinner.stop();
handlePublishStatus(publishResponse);
}
Expand All @@ -106,7 +109,10 @@ async function doUpload() {
async function doPublish() {
spinnerStart('Publishing');

const response = await publish({ apiConfig }, trustedTesters && 'trustedTesters');
const response = await publish(
{ apiConfig },
trustedTesters && 'trustedTesters',
);
spinner.stop();
handlePublishStatus(response);
}
Expand All @@ -118,19 +124,27 @@ function errorHandler(error) {
const response = JSON.parse(error?.response?.body ?? '{}');
const { clientId, refreshToken } = apiConfig;
if (response.error_description === 'The OAuth client was not found.') {
console.error(('Error: `The OAuth client was not found`'));
console.error(('Probably the provided client ID is not valid. Try following the guide again'));
console.error(('https://github.com/fregante/chrome-webstore-upload/blob/main/How%20to%20generate%20Google%20API%20keys.md'));
console.error('Error: `The OAuth client was not found`');
console.error(
'Probably the provided client ID is not valid. Try following the guide again',
);
console.error(
'https://github.com/fregante/chrome-webstore-upload/blob/main/How%20to%20generate%20Google%20API%20keys.md',
);
console.error({ clientId });
process.exitCode = 1;
return;
}

if (response.error_description === 'Bad Request') {
const { clientId } = apiConfig;
console.error(('Error: `invalid_grant`'));
console.error(('Probably the provided refresh token is not valid. Try following the guide again'));
console.error(('https://github.com/fregante/chrome-webstore-upload/blob/main/How%20to%20generate%20Google%20API%20keys.md'));
console.error('Error: `invalid_grant`');
console.error(
'Probably the provided refresh token is not valid. Try following the guide again',
);
console.error(
'https://github.com/fregante/chrome-webstore-upload/blob/main/How%20to%20generate%20Google%20API%20keys.md',
);
console.error({ clientId, refreshToken });
process.exitCode = 1;
return;
Expand All @@ -139,15 +153,15 @@ function errorHandler(error) {

if (error?.itemError?.length > 0) {
for (const itemError of error.itemError) {
console.error(('Error: ' + itemError.error_code));
console.error((itemError.error_detail));
console.error('Error: ' + itemError.error_code);
console.error(itemError.error_detail);
}

process.exitCode = 1;
return;
}

console.error(('Error'));
console.error('Error');
console.error(error);
process.exitCode = 1;
}
Expand Down
10 changes: 10 additions & 0 deletions license
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
The MIT License (MIT)

Copyright (c) Federico Brigante <me@fregante.com> (https://fregante.com)
Copyright (c) 2020 Andrew Levine

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
71 changes: 36 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,63 +1,64 @@
{
"name": "chrome-webstore-upload-cli",
"version": "2.0.0",
"license": "MIT",
"description": "CLI Utility to quickly upload + publish extensions to the Chrome Web Store",
"repository": "fregante/chrome-webstore-upload-cli",
"bin": {
"chrome-webstore-upload": "cli.js"
},
"type": "module",
"scripts": {
"test": "xo && ava"
},
"description": "CLI tool to upload Chrome Extensions to the Chrome Web Store",
"keywords": [
"chrome",
"publish",
"webstore",
"store",
"extension",
"deploy",
"update",
"upload",
"cli"
],
"repository": "fregante/chrome-webstore-upload-cli",
"funding": "https://github.com/sponsors/fregante",
"license": "MIT",
"author": "Andrew Levine",
"devDependencies": {
"ava": "^3.15.0",
"execa": "^5.1.1",
"is-stream": "^3.0.0",
"xo": "^0.44.0"
},
"dependencies": {
"chrome-webstore-upload": "^0.5.0",
"junk": "^4.0.0",
"meow": "^10.1.1",
"ora": "^6.0.1",
"recursive-readdir": "^2.2.2",
"yazl": "^2.5.1"
},
"engines": {
"node": "^14.13.1 || >=16.0.0"
},
"contributors": [
"Andrew Levine",
"Federico Brigante <me@fregante.com> (https://fregante.com)"
],
"ava": {
"files": [
"!test/fixtures/**",
"!test/helpers/**"
]
"type": "module",
"bin": {
"chrome-webstore-upload": "cli.js"
},
"scripts": {
"test": "xo && ava"
},
"xo": {
"space": 4,
"rules": {
"object-curly-spacing": [
"error",
"always"
],
"camelcase": "off",
"unicorn/no-process-exit": "off"
}
},
"space": 4
},
"ava": {
"files": [
"!test/fixtures/**",
"!test/helpers/**"
]
},
"dependencies": {
"chrome-webstore-upload": "^0.5.0",
"junk": "^4.0.0",
"meow": "^10.1.1",
"ora": "^6.0.1",
"recursive-readdir": "^2.2.2",
"yazl": "^2.5.1"
},
"devDependencies": {
"ava": "^3.15.0",
"execa": "^5.1.1",
"is-stream": "^3.0.0",
"xo": "^0.44.0"
},
"engines": {
"node": "^14.13.1 || >=16.0.0"
}
}
11 changes: 6 additions & 5 deletions README.md → readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ You can also automatically upload your extension on:
## Usage

```
$ webstore --help
$ chrome-webstore-upload --help
CLI Utility to quickly upload + publish extensions to the Chrome Web Store
Usage
$ webstore <command>
$ chrome-webstore-upload <command>
where <command> is one of
upload, publish
Expand All @@ -45,15 +45,16 @@ $ webstore --help
Examples
Upload new extension archive to the Chrome Web Store
$ webstore upload --source extension.zip --extension-id $EXTENSION_ID --client-id $CLIENT_ID --client-secret $CLIENT_SECRET --refresh-token $REFRESH_TOKEN
$ chrome-webstore-upload upload --source extension.zip --extension-id $EXTENSION_ID --client-id $CLIENT_ID --client-secret $CLIENT_SECRET --refresh-token $REFRESH_TOKEN
Publish extension (with CLIENT_ID, CLIENT_SECRET, and REFRESH_TOKEN set as env variables)
$ webstore publish --extension-id elomekmlfonmdhmpmdfldcjgdoacjcba
$ chrome-webstore-upload publish --extension-id elomekmlfonmdhmpmdfldcjgdoacjcba
```

## Examples

The following projects use this package to facilitate auto-deployment of extensions

- [GifHub](https://github.com/DrewML/GifHub)
- [Octo Preview](https://github.com/DrewML/octo-preview)
- [GhostText](https://github.com/fregante/GhostText)
Expand All @@ -67,4 +68,4 @@ The following projects use this package to facilitate auto-deployment of extensi
- [webext-storage-cache](https://github.com/fregante/webext-storage-cache) - Map-like promised cache storage with expiration. Chrome and Firefox
- [webext-dynamic-content-scripts](https://github.com/fregante/webext-dynamic-content-scripts) - Automatically registers your content_scripts on domains added via permission.request
- [Awesome-WebExtensions](https://github.com/fregante/Awesome-WebExtensions) - A curated list of awesome resources for WebExtensions development.
- [More…](https://github.dihe.moe/fregante/webext-fun)
- [More…](https://github.com/fregante/webext-fun)
1 change: 0 additions & 1 deletion test/helpers/stubs.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ export function stubConsoleLog(stub) {
console.log = old;
};
}

1 change: 0 additions & 1 deletion util.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ export function validateInput(input) {
export function zipPath(root, file) {
return relative(root, file);
}

1 change: 0 additions & 1 deletion wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ export async function fetchToken(apiConfig) {
const client = getClient(apiConfig);
return client.fetchToken();
}

0 comments on commit 6cc1a08

Please sign in to comment.