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

feat: make printing Markdown to the Terminal optional #2937

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Usage:
.option("p", { alias: "plugins", describe: "Plugins", ...stringList, group: "Options" })
.option("e", { alias: "extends", describe: "Shareable configurations", ...stringList, group: "Options" })
.option("ci", { describe: "Toggle CI verifications", type: "boolean", group: "Options" })
.option("marked", { describe: "Enable printing Markdown to the Terminal", type: "boolean", group: "Options" })
.option("silent", { describe: "Disable logging output.", type: "boolean", group: "Options" })
.option("verify-conditions", { ...stringList, group: "Plugins" })
.option("analyze-commits", { type: "string", group: "Plugins" })
.option("verify-release", { ...stringList, group: "Plugins" })
Expand Down
13 changes: 11 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ async function terminalOutput(text) {
if (!markedOptionsSet) {
const { default: TerminalRenderer } = await import("marked-terminal"); // eslint-disable-line node/no-unsupported-features/es-syntax
marked.setOptions({ renderer: new TerminalRenderer() });
marked.use({
mangle: false,
headerIds: false,
});
markedOptionsSet = true;
}

Expand Down Expand Up @@ -224,7 +228,12 @@ async function run(context, plugins) {
if (options.dryRun) {
logger.log(`Release note for version ${nextRelease.version}:`);
if (nextRelease.notes) {
context.stdout.write(await terminalOutput(nextRelease.notes));
if (options.marked) {
context.stdout.write(await terminalOutput(nextRelease.notes));
}
else {
context.stdout.write(nextRelease.notes);
}
}
}

Expand Down Expand Up @@ -268,7 +277,7 @@ export default async (cliOptions = {}, { cwd = process.cwd(), env = process.env,
stderr: stderr || process.stderr,
envCi: envCi({ env, cwd }),
};
context.logger = getLogger(context);
context.logger = getLogger(context, cliOptions.silent);
context.logger.log(`Running ${pkg.name} version ${pkg.version}`);
try {
const { plugins, options } = await getConfig(context, cliOptions);
Expand Down
2 changes: 2 additions & 0 deletions lib/get-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ export default async (context, cliOptions) => {
],
repositoryUrl: (await pkgRepoUrl({ normalize: false, cwd })) || (await repoUrl({ cwd, env })),
tagFormat: `v\${version}`,
marked: true,
silent: false,
plugins: [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
Expand Down
10 changes: 6 additions & 4 deletions lib/get-logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import figures from "figures";

const { Signale } = signale;

export default ({ stdout, stderr }) =>
new Signale({
export default (context, disabled = false) => {
const { stdout, stderr } = context;
return new Signale({
config: { displayTimestamp: true, underlineMessage: false, displayLabel: false },
disabled: false,
disabled: disabled,
interactive: false,
scope: "semantic-release",
stream: [stdout],
Expand All @@ -15,4 +16,5 @@ export default ({ stdout, stderr }) =>
log: { badge: figures.info, color: "magenta", label: "", stream: [stdout] },
success: { badge: figures.tick, color: "green", label: "", stream: [stdout] },
},
});
})
};