Skip to content

Commit

Permalink
feat: add some debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Jul 21, 2020
1 parent de80c29 commit ec792e1
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
10 changes: 7 additions & 3 deletions bin/cli.js
Expand Up @@ -10,16 +10,20 @@ const cli = meow(
Options
--sequential-init Avoid hypothetical concurrent initialization collisions.
--debug Output debugging information.
--help Help info.
Examples
$ multi-semantic-release
`,
{
flags: {
/*execasync: {
sequentialInit: {
type: "boolean",
alias: "sync",
},*/
},
debug: {
type: "boolean",
},
},
}
);
Expand Down
4 changes: 4 additions & 0 deletions bin/runner.js
@@ -1,4 +1,8 @@
module.exports = (flags) => {
if (flags.debug) {
require("debug").enable("msr:*");
}

// Imports.
const getWorkspacesYarn = require("../lib/getWorkspacesYarn");
const multiSemanticRelease = require("../lib/multiSemanticRelease");
Expand Down
17 changes: 15 additions & 2 deletions lib/createInlinePluginCreator.js
@@ -1,5 +1,5 @@
const { writeFileSync } = require("fs");
const { once } = require("lodash");
const debug = require("debug")("msr:inlinePlugin");
const getCommitsFiltered = require("./getCommitsFiltered");
const { getManifest, getIndent } = require("./getManifest");
const hasChangedDeep = require("./hasChangedDeep");
Expand Down Expand Up @@ -88,7 +88,11 @@ function createInlinePluginCreator(packages, multiContext, synchronizer) {
todo().find((p) => !p._ready)
);

return plugins.verifyConditions(context);
const res = await plugins.verifyConditions(context);

debug("verified conditions: %s", pkg.name);

return res;
};

/**
Expand Down Expand Up @@ -129,6 +133,9 @@ function createInlinePluginCreator(packages, multiContext, synchronizer) {
// Make sure type is "patch" if the package has any deps that have changed.
if (!pkg._nextType && hasChangedDeep(pkg._localDeps)) pkg._nextType = "patch";

debug("commits analyzed: %s", pkg.name);
debug("release type: %s", pkg._nextType);

// Return type.
return pkg._nextType;
};
Expand Down Expand Up @@ -195,6 +202,8 @@ function createInlinePluginCreator(packages, multiContext, synchronizer) {
notes.push(bullets.join("\n"));
}

debug("notes generated: %s", pkg.name);

// Return the notes.
return notes.join("\n\n");
};
Expand All @@ -212,6 +221,8 @@ function createInlinePluginCreator(packages, multiContext, synchronizer) {

const res = await plugins.publish(context);

debug("published: %s", pkg.name);

// istanbul ignore next
return res.length ? res[0] : {};
};
Expand All @@ -232,6 +243,8 @@ function createInlinePluginCreator(packages, multiContext, synchronizer) {
})
);

debug("inlinePlugin created: %s", pkg.name);

return inlinePlugin;
}

Expand Down
6 changes: 6 additions & 0 deletions lib/getSynchronizer.js
@@ -1,5 +1,6 @@
const EventEmitter = require("promise-events");
const { identity } = require("lodash");
const debug = require("debug")("msr:synchronizer");

/**
* Cross-packages synchronization context.
Expand Down Expand Up @@ -32,6 +33,8 @@ const getSynchronizer = (packages) => {

const emit = (probe, pkg) => {
const name = getEventName(probe, pkg);
debug("ready: %s", name);

return store.evt[name] || (store.evt[name] = ee.emit(name));
};

Expand All @@ -54,6 +57,7 @@ const getSynchronizer = (packages) => {
.filter(filter)
.every((p) => p.hasOwnProperty(probe))
) {
debug("ready: %s", probe);
emit(probe);
}

Expand All @@ -65,6 +69,8 @@ const getSynchronizer = (packages) => {
if (getLucky[probe]) {
return;
}
const name = getEventName(probe, pkg);
debug("lucky: %s", name);

getLucky[probe] = emit(probe, pkg);
};
Expand Down

0 comments on commit ec792e1

Please sign in to comment.