monorepo-next 10.1.0 → 10.2.1

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": "10.1.0",
3
+ "version": "10.2.1",
4
4
  "description": "Detach monorepo packages from normal linking",
5
5
  "bin": {
6
6
  "next": "bin/next.js"
@@ -96,6 +96,6 @@
96
96
  "sinon": "^15.0.0",
97
97
  "sinon-chai": "^3.5.0",
98
98
  "standard-node-template": "4.0.1",
99
- "yargs-help-output": "^3.0.0"
99
+ "yargs-help-output": "^4.0.0"
100
100
  }
101
101
  }
package/src/releasable.js CHANGED
@@ -9,6 +9,7 @@ const { createPatch } = require('rfc6902');
9
9
  const {
10
10
  getFileAtCommit,
11
11
  } = require('./git');
12
+ const { replaceJsonFile } = require('./fs');
12
13
 
13
14
  const filesContributingToReleasability = new Set([
14
15
  '.gitignore',
@@ -53,13 +54,30 @@ async function prepareTmpPackage({
53
54
 
54
55
  await fs.mkdir(path.dirname(to), { recursive: true });
55
56
 
57
+ let doesExist;
58
+
56
59
  try {
57
60
  await fs.copyFile(from, to);
61
+
62
+ doesExist = true;
58
63
  } catch (err) {
59
64
  if (err.code !== 'ENOENT') {
60
65
  throw err;
61
66
  }
62
67
  }
68
+
69
+ if (fileName === 'package.json' && doesExist) {
70
+ await replaceJsonFile(to, packageJson => {
71
+ // If complete packages are deleted that still match our current workspaces globs,
72
+ // AND their path basenames happen to be the same (because we zerod out their package.json names below),
73
+ // packlist will think the packages are duplicates without this line (when it's the monorepo root package).
74
+ // We already filtered out current package changes before we got to this point,
75
+ // so everything remaining shouldn't be considered packages anyways.
76
+ if (packageJson.workspaces) {
77
+ packageJson.workspaces = [];
78
+ }
79
+ });
80
+ }
63
81
  }
64
82
 
65
83
  let remainingFiles = changedFiles.diff(filesContributingToReleasability);
package/src/release.js CHANGED
@@ -198,11 +198,7 @@ async function release({
198
198
  await handleLifecycleScript('posttag');
199
199
 
200
200
  async function originalPush() {
201
- if (dryRun) {
202
- _log('push');
203
- } else {
204
- await push({ cwd: workspaceCwd });
205
- }
201
+ await push({ cwd: workspaceCwd, silent, dryRun });
206
202
  }
207
203
 
208
204
  if (shouldPush) {
@@ -240,11 +236,7 @@ async function release({
240
236
  if (shouldPublish && _shouldPublish) {
241
237
  // eslint-disable-next-line no-inner-declarations
242
238
  async function originalPublish() {
243
- if (dryRun) {
244
- _log('publish');
245
- } else {
246
- await publish({ cwd });
247
- }
239
+ await publish({ cwd, silent, dryRun });
248
240
  }
249
241
 
250
242
  if (publishOverride) {
@@ -268,8 +260,10 @@ async function release({
268
260
  }
269
261
  }
270
262
 
271
- async function push({ cwd }) {
272
- let remoteUrl = (await execa('git', ['config', '--get', 'remote.origin.url'], { cwd })).stdout;
263
+ async function push({ cwd, silent, dryRun }) {
264
+ let remoteUrl = (await execa('git', ['config', '--get', 'remote.origin.url'], { cwd, silent: true })).stdout;
265
+
266
+ let dryRunArgs = dryRun ? ['--dry-run'] : [];
273
267
 
274
268
  // https://stackoverflow.com/a/55586434
275
269
  let doesntSupportAtomic = remoteUrl.includes('https://');
@@ -278,9 +272,9 @@ async function push({ cwd }) {
278
272
 
279
273
  try {
280
274
  if (doesntSupportAtomic) {
281
- await execa('git', ['push'], { cwd });
275
+ await execa('git', ['push', ...dryRunArgs], { cwd, silent });
282
276
  } else {
283
- await execa('git', ['push', '--follow-tags', '--atomic'], { cwd });
277
+ await execa('git', ['push', '--follow-tags', '--atomic', ...dryRunArgs], { cwd, silent });
284
278
  }
285
279
 
286
280
  success = true;
@@ -296,12 +290,14 @@ async function push({ cwd }) {
296
290
  if (doesntSupportAtomic && success) {
297
291
  // only push tags after the commit
298
292
  // and hard error if there is a tag collision
299
- await execa('git', ['push', '--follow-tags'], { cwd });
293
+ await execa('git', ['push', '--follow-tags', ...dryRunArgs], { cwd, silent });
300
294
  }
301
295
  }
302
296
 
303
- async function publish({ cwd }) {
304
- await execa('npm', ['publish'], { cwd });
297
+ async function publish({ cwd, silent, dryRun }) {
298
+ let dryRunArgs = dryRun ? ['--dry-run'] : [];
299
+
300
+ await execa('npm', ['publish', ...dryRunArgs], { cwd, silent });
305
301
  }
306
302
 
307
303
  module.exports = release;