monorepo-next 8.3.0 → 8.4.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 +1 -2
- package/src/build-change-graph.js +8 -3
- package/src/build-dep-graph.js +3 -29
- package/src/get-workspaces-paths.js +33 -0
- package/src/path.js +13 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "monorepo-next",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.4.1",
|
4
4
|
"description": "Detach monorepo packages from normal linking",
|
5
5
|
"bin": {
|
6
6
|
"next": "bin/next.js"
|
@@ -62,7 +62,6 @@
|
|
62
62
|
"conventional-recommended-bump": "6.1.0",
|
63
63
|
"debug": "^4.3.1",
|
64
64
|
"execa": "^5.0.0",
|
65
|
-
"glob": "^8.0.0",
|
66
65
|
"inquirer": "^8.0.0",
|
67
66
|
"minimatch": "^5.0.0",
|
68
67
|
"npm-packlist": "^5.0.0",
|
@@ -9,10 +9,11 @@ const {
|
|
9
9
|
getCommitSinceLastRelease,
|
10
10
|
} = require('./git');
|
11
11
|
const { collectPackages } = require('./build-dep-graph');
|
12
|
-
const
|
12
|
+
const { isSubDir } = require('./path');
|
13
13
|
const { getChangedReleasableFiles } = require('./releasable');
|
14
14
|
const Set = require('superset');
|
15
15
|
const { loadPackageConfig } = require('./config');
|
16
|
+
const path = require('path');
|
16
17
|
|
17
18
|
async function getPackageChangedFiles({
|
18
19
|
fromCommit,
|
@@ -72,6 +73,10 @@ async function buildChangeGraph({
|
|
72
73
|
let packagesWithChanges = {};
|
73
74
|
let sinceBranchCommit;
|
74
75
|
|
76
|
+
let packagePaths = Object.values(workspaceMeta.packages).map(({ cwd }) => {
|
77
|
+
return path.relative(workspaceMeta.cwd, cwd);
|
78
|
+
});
|
79
|
+
|
75
80
|
for (let _package of collectPackages(workspaceMeta)) {
|
76
81
|
if (!_package.packageName || !_package.version) {
|
77
82
|
continue;
|
@@ -136,8 +141,8 @@ async function buildChangeGraph({
|
|
136
141
|
// remove package changes from the workspace root's changed files
|
137
142
|
if (_package.cwd === workspaceMeta.cwd) {
|
138
143
|
newFiles = newFiles.filter(file => {
|
139
|
-
return !
|
140
|
-
return
|
144
|
+
return !packagePaths.some((packagePath) => {
|
145
|
+
return isSubDir(packagePath, file);
|
141
146
|
});
|
142
147
|
});
|
143
148
|
}
|
package/src/build-dep-graph.js
CHANGED
@@ -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,36 +77,12 @@ async function buildDepGraph({
|
|
79
77
|
}) {
|
80
78
|
let workspacePackageJson = await readJson(path.join(workspaceCwd, 'package.json'));
|
81
79
|
|
82
|
-
let {
|
80
|
+
let workspaces = await getWorkspacesPaths({ workspaceCwd });
|
83
81
|
|
84
|
-
let
|
85
|
-
|
86
|
-
let _1dFilesArray;
|
87
|
-
if (!workspaces) {
|
88
|
-
_1dFilesArray = (await execa('pnpm', ['recursive', 'exec', '--', 'node', '-e', 'console.log(process.cwd())'], { cwd: workspaceCwd })).stdout
|
89
|
-
.split(/\r?\n/)
|
90
|
-
.map(workspace => path.relative(workspaceCwd, workspace));
|
91
|
-
|
92
|
-
packagesGlobs = [];
|
93
|
-
} else {
|
94
|
-
packagesGlobs = workspaces.packages || workspaces;
|
95
|
-
|
96
|
-
let _2dFilesArray = await Promise.all(packagesGlobs.map(packagesGlob => {
|
97
|
-
return glob(packagesGlob, {
|
98
|
-
cwd: workspaceCwd,
|
99
|
-
});
|
100
|
-
}));
|
101
|
-
|
102
|
-
_1dFilesArray = Array.prototype.concat.apply([], _2dFilesArray);
|
103
|
-
}
|
104
|
-
|
105
|
-
let uniqueFiles = [...new Set(_1dFilesArray)];
|
106
|
-
|
107
|
-
let packageDirs = uniqueFiles.map(file => path.join(workspaceCwd, file));
|
82
|
+
let packageDirs = workspaces.map(dir => path.join(workspaceCwd, dir));
|
108
83
|
|
109
84
|
let workspaceMeta = {
|
110
85
|
cwd: workspaceCwd,
|
111
|
-
packagesGlobs,
|
112
86
|
};
|
113
87
|
|
114
88
|
await firstPass(workspaceMeta, workspacePackageJson, packageDirs);
|
@@ -0,0 +1,33 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const execa = require('execa');
|
4
|
+
const path = require('path');
|
5
|
+
const readJson = require('./json').read;
|
6
|
+
|
7
|
+
async function getWorkspacesPaths({
|
8
|
+
workspaceCwd,
|
9
|
+
}) {
|
10
|
+
let workspacePackageJson = await readJson(path.join(workspaceCwd, 'package.json'));
|
11
|
+
|
12
|
+
let { workspaces } = workspacePackageJson;
|
13
|
+
|
14
|
+
if (!workspaces) {
|
15
|
+
workspaces = (await execa('pnpm', ['recursive', 'exec', '--', 'node', '-e', 'console.log(process.cwd())'], { cwd: workspaceCwd })).stdout
|
16
|
+
.split(/\r?\n/)
|
17
|
+
.map(workspace => path.relative(workspaceCwd, workspace));
|
18
|
+
} else {
|
19
|
+
let jsonString = (
|
20
|
+
await execa('yarn', ['--silent', 'workspaces', 'info'], {
|
21
|
+
cwd: workspaceCwd,
|
22
|
+
})
|
23
|
+
).stdout;
|
24
|
+
|
25
|
+
let workspacesJson = JSON.parse(jsonString);
|
26
|
+
|
27
|
+
workspaces = Object.values(workspacesJson).map(({ location }) => location);
|
28
|
+
}
|
29
|
+
|
30
|
+
return workspaces;
|
31
|
+
}
|
32
|
+
|
33
|
+
module.exports = getWorkspacesPaths;
|