Skip to content

Commit

Permalink
Add verbose flag to publish command (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
skarahoda committed Nov 16, 2021
1 parent 1015d44 commit f427da2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
10 changes: 8 additions & 2 deletions src/commands/publish/apiClient.js
Expand Up @@ -6,8 +6,14 @@ const { apiBaseUrl, apiClientId } = require("../../config/constants");
const { ClientError, ServerError } = require("../../errors");

function createError(response) {
const { statusCode, body } = response;
const extra = { response: response.toJSON() };
const { statusCode, body, headers } = response;
const extra = {
response: {
statusCode,
body,
headers
}
};

if (statusCode >= BAD_REQUEST && statusCode < INTERNAL_SERVER_ERROR) {
const { message, title } = body;
Expand Down
7 changes: 5 additions & 2 deletions src/commands/publish/index.js
Expand Up @@ -95,7 +95,7 @@ async function validateReadme({ hasOptions }) {
}
}

module.exports = async function (buildPath) {
module.exports = async function ({ buildPath, verbose }) {
console.log("Publishing the extension...\n");

pathResolver.init(buildPath);
Expand Down Expand Up @@ -140,6 +140,9 @@ module.exports = async function (buildPath) {
} catch (error) {
console.log(chalk.red("Publishing extension failed:"));
console.error(error.message || error);
if (verbose && error.extra) {
console.error(JSON.stringify(error.extra, null, 2));
}
throw error;
}
};
};
7 changes: 4 additions & 3 deletions src/index.js
Expand Up @@ -93,10 +93,11 @@ program
.command("publish")
.description(`Publish extension, submitting it for review to be listed on ${chalk.underline("https://extensions.zeplin.io.")}`)
.option("--path <build-path>", `Path for the extension build to be published`)
.action(async command => {
.option("--verbose", "Enables verbose logs")
.action(async ({ path: buildPath, verbose }) => {
const publish = require("./commands/publish");
try {
await publish(command.path);
await publish({ buildPath, verbose });
} catch (_) {
process.exitCode = 1;
}
Expand All @@ -117,4 +118,4 @@ program.on("command:*", () => {
});

beforeCommand();
program.parse(process.argv);
program.parse(process.argv);

0 comments on commit f427da2

Please sign in to comment.