monorepo-next 8.3.1 → 8.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": "8.3.1",
3
+ "version": "8.4.0",
4
4
  "description": "Detach monorepo packages from normal linking",
5
5
  "bin": {
6
6
  "next": "bin/next.js"
@@ -1,12 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  const path = require('path');
4
- const { promisify } = require('util');
5
- const glob = promisify(require('glob'));
6
4
  const semver = require('semver');
7
5
  const dependencyTypes = require('./dependency-types');
8
- const execa = require('execa');
9
6
  const readJson = require('./json').read;
7
+ const getWorkspacesPaths = require('./get-workspaces-paths');
10
8
 
11
9
  function copyDeps(left, right) {
12
10
  for (let dependencyType of dependencyTypes) {
@@ -79,28 +77,9 @@ async function buildDepGraph({
79
77
  }) {
80
78
  let workspacePackageJson = await readJson(path.join(workspaceCwd, 'package.json'));
81
79
 
82
- let { workspaces } = workspacePackageJson;
80
+ let workspaces = await getWorkspacesPaths({ workspaceCwd });
83
81
 
84
- let _1dFilesArray;
85
- if (!workspaces) {
86
- _1dFilesArray = (await execa('pnpm', ['recursive', 'exec', '--', 'node', '-e', 'console.log(process.cwd())'], { cwd: workspaceCwd })).stdout
87
- .split(/\r?\n/)
88
- .map(workspace => path.relative(workspaceCwd, workspace));
89
- } else {
90
- let packagesGlobs = workspaces.packages || workspaces;
91
-
92
- let _2dFilesArray = await Promise.all(packagesGlobs.map(packagesGlob => {
93
- return glob(packagesGlob, {
94
- cwd: workspaceCwd,
95
- });
96
- }));
97
-
98
- _1dFilesArray = Array.prototype.concat.apply([], _2dFilesArray);
99
- }
100
-
101
- let uniqueFiles = [...new Set(_1dFilesArray)];
102
-
103
- let packageDirs = uniqueFiles.map(file => path.join(workspaceCwd, file));
82
+ let packageDirs = workspaces.map(dir => path.join(workspaceCwd, dir));
104
83
 
105
84
  let workspaceMeta = {
106
85
  cwd: workspaceCwd,
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ const execa = require('execa');
4
+ const { promisify } = require('util');
5
+ const glob = promisify(require('glob'));
6
+ const path = require('path');
7
+ const readJson = require('./json').read;
8
+
9
+ async function getWorkspacesPaths({
10
+ workspaceCwd,
11
+ }) {
12
+ let workspacePackageJson = await readJson(path.join(workspaceCwd, 'package.json'));
13
+
14
+ let { workspaces } = workspacePackageJson;
15
+
16
+ let _1dFilesArray;
17
+
18
+ if (!workspaces) {
19
+ _1dFilesArray = (await execa('pnpm', ['recursive', 'exec', '--', 'node', '-e', 'console.log(process.cwd())'], { cwd: workspaceCwd })).stdout
20
+ .split(/\r?\n/)
21
+ .map(workspace => path.relative(workspaceCwd, workspace));
22
+
23
+ } else {
24
+ let packagesGlobs = workspaces.packages || workspaces;
25
+
26
+ let _2dFilesArray = await Promise.all(packagesGlobs.map(packagesGlob => {
27
+ return glob(packagesGlob, {
28
+ cwd: workspaceCwd,
29
+ });
30
+ }));
31
+
32
+ _1dFilesArray = Array.prototype.concat.apply([], _2dFilesArray);
33
+ }
34
+
35
+ workspaces = [...new Set(_1dFilesArray)];
36
+
37
+ return workspaces;
38
+ }
39
+
40
+ module.exports = getWorkspacesPaths;