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 verbose flag to publish command #45

Merged
merged 1 commit into from Nov 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);