monorepo-next 11.0.12 → 11.1.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": "11.0.12",
3
+ "version": "11.1.0",
4
4
  "description": "Detach monorepo packages from normal linking",
5
5
  "bin": {
6
6
  "next": "bin/next.js"
@@ -19,6 +19,14 @@ async function getPackageChangedFiles({
19
19
  fromCommit,
20
20
  toCommit,
21
21
  packageCwd,
22
+
23
+ // I had a feeling it took more time to spawn git in a loop
24
+ // than the benefit you get by getting a git diff per-package,
25
+ // especially when you are using a `fromCommit` instead of version tags.
26
+ // In a test of mine, this brought `buildChangeGraph`
27
+ // down to 25 seconds from 39 seconds.
28
+ shouldRunPerPackage = true,
29
+
22
30
  options,
23
31
  }) {
24
32
  // Be careful you don't accidentally use `...` instead of `..`.
@@ -27,11 +35,11 @@ async function getPackageChangedFiles({
27
35
  //
28
36
  // I tried using ls-tree instead of diff when it is a new package (fromCommit is first commit in repo),
29
37
  // but it took the same amount of time.
30
- let committedChanges = await git(['diff', '--name-only', `${fromCommit}..${toCommit}`, packageCwd], options);
38
+ let committedChanges = await git(['diff', '--name-only', `${fromCommit}..${toCommit}`, ...shouldRunPerPackage ? [packageCwd] : []], options);
31
39
 
32
40
  committedChanges = getLinesFromOutput(committedChanges);
33
41
 
34
- let dirtyChanges = await git(['status', '--porcelain', '--untracked-files', packageCwd], options);
42
+ let dirtyChanges = await git(['status', '--porcelain', '--untracked-files', ...shouldRunPerPackage ? [packageCwd] : []], options);
35
43
 
36
44
  dirtyChanges = getLinesFromOutput(dirtyChanges).map(line => {
37
45
  line = line.substr(3);
@@ -43,9 +51,25 @@ async function getPackageChangedFiles({
43
51
  return line;
44
52
  });
45
53
 
46
- let changedFiles = Array.from(new Set(committedChanges).union(dirtyChanges));
54
+ let changedFiles = new Set(committedChanges).union(dirtyChanges);
55
+
56
+ if (!shouldRunPerPackage) {
57
+ let packageChangedFiles = new Set();
58
+
59
+ let relativePackageCwd = path.relative(options.cwd, packageCwd);
60
+
61
+ for (let changedFile of changedFiles) {
62
+ if (!changedFile.startsWith(relativePackageCwd)) {
63
+ continue;
64
+ }
65
+
66
+ packageChangedFiles.add(changedFile);
67
+ }
68
+
69
+ changedFiles = packageChangedFiles;
70
+ }
47
71
 
48
- return changedFiles;
72
+ return Array.from(changedFiles);
49
73
  }
50
74
 
51
75
  function crawlDag(dag, packagesWithChanges) {
@@ -136,6 +160,7 @@ async function buildChangeGraph({
136
160
  fromCommit: _fromCommit,
137
161
  toCommit,
138
162
  packageCwd: _package.cwd,
163
+ shouldRunPerPackage: false,
139
164
  options: {
140
165
  cwd: workspaceMeta.cwd,
141
166
  cached,