monorepo-next 8.6.0 → 8.6.2
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 +2 -2
- package/src/attach.js +1 -2
- package/src/build-dag.js +6 -24
- package/src/build-dep-graph.js +37 -14
- package/src/build-release-graph.js +3 -4
- package/src/changed-files.js +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "monorepo-next",
|
3
|
-
"version": "8.6.
|
3
|
+
"version": "8.6.2",
|
4
4
|
"description": "Detach monorepo packages from normal linking",
|
5
5
|
"bin": {
|
6
6
|
"next": "bin/next.js"
|
@@ -80,7 +80,7 @@
|
|
80
80
|
"chai-as-promised": "^7.1.1",
|
81
81
|
"common-tags": "^1.8.2",
|
82
82
|
"eslint": "^8.0.0",
|
83
|
-
"eslint-config-crowdstrike": "^
|
83
|
+
"eslint-config-crowdstrike": "^8.0.0",
|
84
84
|
"eslint-config-crowdstrike-node": "^3.0.0",
|
85
85
|
"eslint-plugin-json-files": "^1.0.0",
|
86
86
|
"eslint-plugin-mocha": "^10.0.0",
|
package/src/attach.js
CHANGED
@@ -4,7 +4,6 @@ const path = require('path');
|
|
4
4
|
const writeJson = require('./json').write;
|
5
5
|
const buildDepGraph = require('./build-dep-graph');
|
6
6
|
const buildDAG = require('./build-dag');
|
7
|
-
const { isCycle } = buildDAG;
|
8
7
|
const dependencyTypes = require('./dependency-types');
|
9
8
|
const {
|
10
9
|
getWorkspaceCwd,
|
@@ -84,7 +83,7 @@ async function attach({
|
|
84
83
|
// don't mutate package.json until after DAG is built
|
85
84
|
myPackageJson.version = matches[1];
|
86
85
|
|
87
|
-
if (!isCycle
|
86
|
+
if (!dag.isCycle) {
|
88
87
|
await detachDependents(dag);
|
89
88
|
}
|
90
89
|
}
|
package/src/build-dag.js
CHANGED
@@ -40,10 +40,13 @@ function thirdPass({
|
|
40
40
|
let visitedNode = visitedNodes[_package.packageName];
|
41
41
|
|
42
42
|
if (visitedNode) {
|
43
|
+
let isCycle = branch.includes(_package.packageName);
|
44
|
+
|
43
45
|
group.node.dependents.push({
|
44
46
|
parent,
|
45
47
|
dependencyType,
|
46
48
|
dependencyRange,
|
49
|
+
isCycle,
|
47
50
|
node: visitedNode,
|
48
51
|
});
|
49
52
|
|
@@ -64,7 +67,7 @@ function thirdPass({
|
|
64
67
|
|
65
68
|
group.node.dependents.push(newGroup);
|
66
69
|
|
67
|
-
if (group.node.isPackage
|
70
|
+
if (group.node.isPackage) {
|
68
71
|
thirdPass({
|
69
72
|
workspaceMeta,
|
70
73
|
group: newGroup,
|
@@ -76,22 +79,6 @@ function thirdPass({
|
|
76
79
|
}
|
77
80
|
}
|
78
81
|
|
79
|
-
function isCycle(group) {
|
80
|
-
let current = group;
|
81
|
-
|
82
|
-
do {
|
83
|
-
current = current.parent;
|
84
|
-
|
85
|
-
if (!current) {
|
86
|
-
return false;
|
87
|
-
}
|
88
|
-
|
89
|
-
if (current.node === group.node) {
|
90
|
-
return true;
|
91
|
-
}
|
92
|
-
} while (true);
|
93
|
-
}
|
94
|
-
|
95
82
|
function createPackageNode({
|
96
83
|
workspaceMeta,
|
97
84
|
packageName,
|
@@ -107,19 +94,17 @@ function createPackageNode({
|
|
107
94
|
cwd: _package ? _package.cwd : workspaceMeta.cwd,
|
108
95
|
packageName,
|
109
96
|
version: _package ? _package.version : workspaceMeta.version,
|
97
|
+
dependents: [],
|
110
98
|
};
|
111
99
|
|
112
100
|
let group = {
|
113
101
|
parent,
|
114
102
|
dependencyType,
|
115
103
|
dependencyRange,
|
104
|
+
isCycle: false,
|
116
105
|
node,
|
117
106
|
};
|
118
107
|
|
119
|
-
if (!isCycle(group)) {
|
120
|
-
node.dependents = [];
|
121
|
-
}
|
122
|
-
|
123
108
|
let newBranch = [...branch, packageName].filter(Boolean);
|
124
109
|
|
125
110
|
return {
|
@@ -151,6 +136,3 @@ function buildDAG(workspaceMeta, packageName) {
|
|
151
136
|
}
|
152
137
|
|
153
138
|
module.exports = buildDAG;
|
154
|
-
Object.assign(module.exports, {
|
155
|
-
isCycle,
|
156
|
-
});
|
package/src/build-dep-graph.js
CHANGED
@@ -12,23 +12,16 @@ function copyDeps(left, right) {
|
|
12
12
|
}
|
13
13
|
}
|
14
14
|
|
15
|
-
|
15
|
+
function firstPass(workspaceMeta, workspacePackageJson, workspacesPackageJsons) {
|
16
16
|
workspaceMeta.packageName = workspacePackageJson.name || 'Workspace Root';
|
17
17
|
workspaceMeta.version = workspacePackageJson.version;
|
18
18
|
workspaceMeta.isPrivate = true;
|
19
19
|
workspaceMeta.packages = {};
|
20
20
|
copyDeps(workspaceMeta, workspacePackageJson);
|
21
|
-
for (let
|
22
|
-
let packageJson;
|
23
|
-
try {
|
24
|
-
packageJson = await readJson(path.join(packageDir, 'package.json'));
|
25
|
-
} catch (err) {
|
26
|
-
// ignore empty folders
|
27
|
-
continue;
|
28
|
-
}
|
21
|
+
for (let [workspace, packageJson] of Object.entries(workspacesPackageJsons)) {
|
29
22
|
let packageName = packageJson.name;
|
30
23
|
workspaceMeta.packages[packageName] = {
|
31
|
-
cwd:
|
24
|
+
cwd: path.join(workspaceMeta.cwd, workspace),
|
32
25
|
packageName,
|
33
26
|
version: packageJson.version,
|
34
27
|
isPrivate: packageJson.private,
|
@@ -65,7 +58,7 @@ function deleteOutOfRangePackages(_package, packages) {
|
|
65
58
|
function secondPass(workspaceMeta) {
|
66
59
|
let { packages } = workspaceMeta;
|
67
60
|
let packageNames = Object.keys(packages);
|
68
|
-
for (let _package of
|
61
|
+
for (let _package of collectPackages(workspaceMeta)) {
|
69
62
|
deleteUnrecognizedDeps(_package, packageNames);
|
70
63
|
deleteOutOfRangePackages(_package, packages);
|
71
64
|
}
|
@@ -73,19 +66,48 @@ function secondPass(workspaceMeta) {
|
|
73
66
|
|
74
67
|
async function buildDepGraph({
|
75
68
|
workspaceCwd,
|
76
|
-
|
69
|
+
...options
|
77
70
|
}) {
|
78
71
|
let workspacePackageJson = await readJson(path.join(workspaceCwd, 'package.json'));
|
79
72
|
|
80
73
|
let workspaces = await getWorkspacesPaths({ cwd: workspaceCwd });
|
81
74
|
|
82
|
-
let
|
75
|
+
let workspacesPackageJsons = {};
|
76
|
+
|
77
|
+
for (let workspace of workspaces) {
|
78
|
+
let packageJson;
|
79
|
+
|
80
|
+
try {
|
81
|
+
packageJson = await readJson(path.join(workspaceCwd, workspace, 'package.json'));
|
82
|
+
} catch (err) {
|
83
|
+
// ignore empty folders
|
84
|
+
continue;
|
85
|
+
}
|
86
|
+
|
87
|
+
workspacesPackageJsons[workspace] = packageJson;
|
88
|
+
}
|
89
|
+
|
90
|
+
let workspaceMeta = buildDepGraphFromObject({
|
91
|
+
workspaceCwd,
|
92
|
+
workspacePackageJson,
|
93
|
+
workspacesPackageJsons,
|
94
|
+
...options,
|
95
|
+
});
|
83
96
|
|
97
|
+
return workspaceMeta;
|
98
|
+
}
|
99
|
+
|
100
|
+
function buildDepGraphFromObject({
|
101
|
+
workspaceCwd,
|
102
|
+
workspacePackageJson,
|
103
|
+
workspacesPackageJsons,
|
104
|
+
shouldPruneDeps = true,
|
105
|
+
}) {
|
84
106
|
let workspaceMeta = {
|
85
107
|
cwd: workspaceCwd,
|
86
108
|
};
|
87
109
|
|
88
|
-
|
110
|
+
firstPass(workspaceMeta, workspacePackageJson, workspacesPackageJsons);
|
89
111
|
if (shouldPruneDeps) {
|
90
112
|
secondPass(workspaceMeta);
|
91
113
|
}
|
@@ -99,5 +121,6 @@ function collectPackages(workspaceMeta) {
|
|
99
121
|
|
100
122
|
module.exports = buildDepGraph;
|
101
123
|
Object.assign(module.exports, {
|
124
|
+
buildDepGraphFromObject,
|
102
125
|
collectPackages,
|
103
126
|
});
|
@@ -9,7 +9,6 @@ const {
|
|
9
9
|
const { trackNewVersion } = require('./version');
|
10
10
|
const semver = require('semver');
|
11
11
|
const dependencyTypes = require('./dependency-types');
|
12
|
-
const { isCycle } = require('./build-dag');
|
13
12
|
const { loadPackageConfig } = require('./config');
|
14
13
|
|
15
14
|
const defaultReleaseType = 'patch';
|
@@ -168,7 +167,7 @@ async function secondPass({
|
|
168
167
|
}
|
169
168
|
|
170
169
|
for (let group of dag.node.dependents) {
|
171
|
-
if (isCycle
|
170
|
+
if (group.isCycle) {
|
172
171
|
continue;
|
173
172
|
}
|
174
173
|
|
@@ -221,7 +220,7 @@ function thirdPass({
|
|
221
220
|
}
|
222
221
|
|
223
222
|
for (let group of dag.node.dependents) {
|
224
|
-
if (isCycle
|
223
|
+
if (group.isCycle) {
|
225
224
|
continue;
|
226
225
|
}
|
227
226
|
|
@@ -283,7 +282,7 @@ function fourthPass({
|
|
283
282
|
}
|
284
283
|
|
285
284
|
for (let group of dag.node.dependents) {
|
286
|
-
if (isCycle
|
285
|
+
if (group.isCycle) {
|
287
286
|
continue;
|
288
287
|
}
|
289
288
|
|
package/src/changed-files.js
CHANGED
@@ -67,7 +67,7 @@ async function changedFiles({
|
|
67
67
|
isMatch = true;
|
68
68
|
} else if (exts.some(ext => file.endsWith(`.${ext}`))) {
|
69
69
|
isMatch = true;
|
70
|
-
} else if (globs.some(glob => minimatch(file, glob))) {
|
70
|
+
} else if (globs.some(glob => minimatch(file, glob, { dot: true }))) {
|
71
71
|
isMatch = true;
|
72
72
|
}
|
73
73
|
|