monorepo-next 9.3.5 → 9.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monorepo-next",
3
- "version": "9.3.5",
3
+ "version": "9.4.0",
4
4
  "description": "Detach monorepo packages from normal linking",
5
5
  "bin": {
6
6
  "next": "bin/next.js"
@@ -10,6 +10,8 @@ const { trackNewVersion } = require('./version');
10
10
  const semver = require('semver');
11
11
  const dependencyTypes = require('./dependency-types');
12
12
  const { loadPackageConfig } = require('./config');
13
+ const debug = require('./debug');
14
+ const { createLogger } = require('./log');
13
15
 
14
16
  const defaultReleaseType = 'patch';
15
17
 
@@ -298,21 +300,24 @@ function fourthPass({
298
300
  }
299
301
 
300
302
  async function buildReleaseGraph({
303
+ debug: _debug = debug,
301
304
  packagesWithChanges,
302
305
  shouldBumpInRangeDependencies,
303
306
  shouldInheritGreaterReleaseType,
304
307
  shouldExcludeDevChanges,
305
308
  }) {
309
+ let log = createLogger(_debug);
310
+
306
311
  let releaseTrees = {};
307
312
 
308
- await firstPass({
313
+ await log(firstPass, {
309
314
  releaseTrees,
310
315
  packagesWithChanges,
311
316
  });
312
317
 
313
318
  // only packages with changes have been analyzed
314
319
 
315
- await secondPass({
320
+ await log(secondPass, {
316
321
  releaseTrees,
317
322
  packagesWithChanges,
318
323
  shouldBumpInRangeDependencies,
@@ -322,7 +327,7 @@ async function buildReleaseGraph({
322
327
 
323
328
  // packages without changes, but need to be analyzed because of options
324
329
 
325
- thirdPass({
330
+ log(thirdPass, {
326
331
  releaseTrees,
327
332
  packagesWithChanges,
328
333
  shouldInheritGreaterReleaseType,
@@ -331,7 +336,7 @@ async function buildReleaseGraph({
331
336
 
332
337
  // dependents have now inherited release type
333
338
 
334
- fourthPass({
339
+ log(fourthPass, {
335
340
  releaseTrees,
336
341
  packagesWithChanges,
337
342
  shouldBumpInRangeDependencies,
package/src/debug.js CHANGED
@@ -1,10 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const _debug = require('debug');
3
+ const debug = require('debug');
4
4
  const { name } = require('../package');
5
5
 
6
- function debug(scope) {
7
- return _debug(`${name}:${scope}`);
8
- }
9
-
10
- module.exports = debug;
6
+ module.exports = debug(name);
package/src/git.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const execa = require('execa');
4
- const debug = require('./debug')('git');
4
+ const debug = require('./debug').extend('git');
5
5
 
6
6
  let cache = {};
7
7
 
package/src/log.js ADDED
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ const _debug = require('./debug');
4
+
5
+ function createLogger(debug = _debug) {
6
+ return async function log(callback, ...args) {
7
+ let _debug = debug.extend(callback.name);
8
+
9
+ _debug('begin');
10
+
11
+ let before = new Date();
12
+
13
+ try {
14
+ return await callback(...args);
15
+ } finally {
16
+ let elapsed = new Date() - before;
17
+
18
+ _debug(`end in ${elapsed}ms`);
19
+ }
20
+ };
21
+ }
22
+
23
+ module.exports = {
24
+ createLogger,
25
+ };
package/src/release.js CHANGED
@@ -17,6 +17,8 @@ const {
17
17
  } = require('./git');
18
18
  const semver = require('semver');
19
19
  const { builder } = require('../bin/commands/release');
20
+ const debug = require('./debug');
21
+ const { createLogger } = require('./log');
20
22
 
21
23
  async function release({
22
24
  cwd = process.cwd(),
@@ -40,6 +42,9 @@ async function release({
40
42
  publishOverride,
41
43
  cached,
42
44
  } = {}) {
45
+ let _debug = debug.extend(release.name);
46
+ let log = createLogger(_debug);
47
+
43
48
  let currentBranch = await getCurrentBranch(cwd);
44
49
  if (currentBranch !== defaultBranch) {
45
50
  return;
@@ -47,9 +52,9 @@ async function release({
47
52
 
48
53
  let workspaceCwd = await getWorkspaceCwd(cwd);
49
54
 
50
- let workspaceMeta = await buildDepGraph({ workspaceCwd });
55
+ let workspaceMeta = await log(buildDepGraph, { workspaceCwd });
51
56
 
52
- let packagesWithChanges = await buildChangeGraph({
57
+ let packagesWithChanges = await log(buildChangeGraph, {
53
58
  workspaceMeta,
54
59
  shouldExcludeDevChanges,
55
60
  cached,
@@ -64,7 +69,8 @@ async function release({
64
69
  return;
65
70
  }
66
71
 
67
- let releaseTrees = await buildReleaseGraph({
72
+ let releaseTrees = await log(buildReleaseGraph, {
73
+ debug: _debug,
68
74
  packagesWithChanges,
69
75
  shouldBumpInRangeDependencies,
70
76
  shouldInheritGreaterReleaseType,
@@ -79,7 +85,7 @@ async function release({
79
85
  let packageJson = await readJson(packageJsonPath);
80
86
 
81
87
  if (releaseTree.oldVersion && releaseTree.oldVersion !== packageJson.version) {
82
- log(`Updating ${packageJson.name} from ${packageJson.version} to ${releaseTree.oldVersion}.`);
88
+ _log(`Updating ${packageJson.name} from ${packageJson.version} to ${releaseTree.oldVersion}.`);
83
89
 
84
90
  packageJson.version = releaseTree.oldVersion;
85
91
  }
@@ -91,7 +97,7 @@ async function release({
91
97
  let oldRange = packageJson[type][name];
92
98
 
93
99
  if (newRange !== oldRange) {
94
- log(`Updating ${packageJson.name} ${type} ${name} from ${oldRange} to ${newRange}.`);
100
+ _log(`Updating ${packageJson.name} ${type} ${name} from ${oldRange} to ${newRange}.`);
95
101
 
96
102
  packageJson[type][name] = newRange;
97
103
  }
@@ -191,7 +197,7 @@ async function release({
191
197
 
192
198
  async function originalPush() {
193
199
  if (dryRun) {
194
- log('push');
200
+ _log('push');
195
201
  } else {
196
202
  await push({ cwd: workspaceCwd });
197
203
  }
@@ -233,7 +239,7 @@ async function release({
233
239
  // eslint-disable-next-line no-inner-declarations
234
240
  async function originalPublish() {
235
241
  if (dryRun) {
236
- log('publish');
242
+ _log('publish');
237
243
  } else {
238
244
  await publish({ cwd });
239
245
  }
@@ -253,13 +259,13 @@ async function release({
253
259
 
254
260
  function exec(execa, ...args) {
255
261
  if (dryRun) {
256
- log(...args);
262
+ _log(...args);
257
263
  } else {
258
264
  return execa.apply(this, args);
259
265
  }
260
266
  }
261
267
 
262
- function log() {
268
+ function _log() {
263
269
  if (silent) {
264
270
  return;
265
271
  }