monorepo-next 8.4.1 → 8.5.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.4.1",
3
+ "version": "8.5.0",
4
4
  "description": "Detach monorepo packages from normal linking",
5
5
  "bin": {
6
6
  "next": "bin/next.js"
@@ -4,7 +4,7 @@ const path = require('path');
4
4
  const semver = require('semver');
5
5
  const dependencyTypes = require('./dependency-types');
6
6
  const readJson = require('./json').read;
7
- const getWorkspacesPaths = require('./get-workspaces-paths');
7
+ const { getWorkspacesPaths } = require('./get-workspaces-paths');
8
8
 
9
9
  function copyDeps(left, right) {
10
10
  for (let dependencyType of dependencyTypes) {
@@ -3,6 +3,7 @@
3
3
  const execa = require('execa');
4
4
  const path = require('path');
5
5
  const readJson = require('./json').read;
6
+ const readJsonSync = require('./json').readSync;
6
7
 
7
8
  async function getWorkspacesPaths({
8
9
  workspaceCwd,
@@ -30,4 +31,32 @@ async function getWorkspacesPaths({
30
31
  return workspaces;
31
32
  }
32
33
 
33
- module.exports = getWorkspacesPaths;
34
+ function getWorkspacesPathsSync({
35
+ workspaceCwd,
36
+ }) {
37
+ let workspacePackageJson = readJsonSync(path.join(workspaceCwd, 'package.json'));
38
+
39
+ let { workspaces } = workspacePackageJson;
40
+
41
+ if (!workspaces) {
42
+ workspaces = (execa.sync('pnpm', ['recursive', 'exec', '--', 'node', '-e', 'console.log(process.cwd())'], { cwd: workspaceCwd })).stdout
43
+ .split(/\r?\n/)
44
+ .map(workspace => path.relative(workspaceCwd, workspace));
45
+ } else {
46
+ let jsonString = (
47
+ execa.sync('yarn', ['--silent', 'workspaces', 'info'], {
48
+ cwd: workspaceCwd,
49
+ })
50
+ ).stdout;
51
+
52
+ let workspacesJson = JSON.parse(jsonString);
53
+
54
+ workspaces = Object.values(workspacesJson).map(({ location }) => location);
55
+ }
56
+ return workspaces;
57
+ }
58
+
59
+ module.exports = {
60
+ getWorkspacesPaths,
61
+ getWorkspacesPathsSync,
62
+ };
package/src/json.js CHANGED
@@ -11,6 +11,10 @@ async function read(path) {
11
11
  return JSON.parse(await fs.readFile(path, 'utf8'));
12
12
  }
13
13
 
14
+ function readSync(path) {
15
+ return JSON.parse(fs.readFileSync(path, 'utf8'));
16
+ }
17
+
14
18
  async function write(path, json) {
15
19
  await fs.writeFile(path, stringify(json));
16
20
  }
@@ -18,5 +22,6 @@ async function write(path, json) {
18
22
  module.exports = {
19
23
  stringify,
20
24
  read,
25
+ readSync,
21
26
  write,
22
27
  };