@graphcommerce/next-config 6.2.0-canary.55 → 6.2.0-canary.57
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/CHANGELOG.md +8 -0
- package/__tests__/utils/packageRoots.ts +35 -0
- package/dist/index.js +1 -0
- package/dist/utils/packageRoots.js +31 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/utils/packageRoots.ts +35 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 6.2.0-canary.57
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1982](https://github.com/graphcommerce-org/graphcommerce/pull/1982) [`e1fab2f6d`](https://github.com/graphcommerce-org/graphcommerce/commit/e1fab2f6d8f57d0488d8a915596d5c19cb7718e6) - Better detection what the package roots are when a custom node_modules directory is used ([@paales](https://github.com/paales))
|
|
8
|
+
|
|
9
|
+
## 6.2.0-canary.56
|
|
10
|
+
|
|
3
11
|
## 6.2.0-canary.55
|
|
4
12
|
|
|
5
13
|
## 6.2.0-canary.54
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { packageRoots } from '../../src/utils/packageRoots'
|
|
2
|
+
|
|
3
|
+
describe('packageRoots', () => {
|
|
4
|
+
it('should simplify all common paths', () => {
|
|
5
|
+
const paths = [
|
|
6
|
+
'../../packages/cli',
|
|
7
|
+
'../../packages/hygraph-cli',
|
|
8
|
+
'../../packagesDev/next-config',
|
|
9
|
+
'../../packagesDev/next-la',
|
|
10
|
+
'../../../layers/paketo-buildpacks_yarn-install/build-modules/node_modules/@graphcommerce/magento-cart-items',
|
|
11
|
+
'../../../layers/paketo-buildpacks_yarn-install/build-modules/node_modules/@graphcommerce/magento-product',
|
|
12
|
+
// ... (rest of your paths)
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
const expectedRoots = [
|
|
16
|
+
'../../packages',
|
|
17
|
+
'../../packagesDev',
|
|
18
|
+
'../../../layers/paketo-buildpacks_yarn-install/build-modules/node_modules/@graphcommerce',
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
const roots = packageRoots(paths)
|
|
22
|
+
|
|
23
|
+
// Expect roots to be an array
|
|
24
|
+
expect(Array.isArray(roots)).toBe(true)
|
|
25
|
+
|
|
26
|
+
// Expect the roots array to be equal to expectedRoots
|
|
27
|
+
expect(expectedRoots).toEqual(roots)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('should return an empty array for no common roots', () => {
|
|
31
|
+
const paths = ['../a/b', '../c/d']
|
|
32
|
+
const roots = packageRoots(paths)
|
|
33
|
+
expect(roots).toEqual([])
|
|
34
|
+
})
|
|
35
|
+
})
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./utils/isMonorepo"), exports);
|
|
18
18
|
__exportStar(require("./utils/resolveDependenciesSync"), exports);
|
|
19
|
+
__exportStar(require("./utils/packageRoots"), exports);
|
|
19
20
|
__exportStar(require("./withGraphCommerce"), exports);
|
|
20
21
|
__exportStar(require("./generated/config"), exports);
|
|
21
22
|
__exportStar(require("./config"), exports);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.packageRoots = void 0;
|
|
4
|
+
const packageRoots = (packagePaths) => {
|
|
5
|
+
const pathMap = {};
|
|
6
|
+
// Iterate over each path in the array
|
|
7
|
+
packagePaths.forEach((singlePath) => {
|
|
8
|
+
const parts = singlePath.split('/');
|
|
9
|
+
// Iterate through each part of the path
|
|
10
|
+
for (let i = 1; i < parts.length; i++) {
|
|
11
|
+
const subPath = parts.slice(0, i + 1).join('/');
|
|
12
|
+
// Increment the count of this subPath
|
|
13
|
+
if (pathMap[subPath]) {
|
|
14
|
+
pathMap[subPath].count += 1;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
pathMap[subPath] = { path: subPath, count: 1 };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
// Filter the paths that appear more than once
|
|
22
|
+
const roots = [];
|
|
23
|
+
Object.values(pathMap).forEach(({ path, count }) => {
|
|
24
|
+
if (count > 1) {
|
|
25
|
+
roots.push(path);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
// Filter out the sub-paths which are part of another longer sub-path
|
|
29
|
+
return roots.filter((root, index, self) => self.findIndex((r) => r !== root && r.startsWith(root + '/')) === -1);
|
|
30
|
+
};
|
|
31
|
+
exports.packageRoots = packageRoots;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/next-config",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "6.2.0-canary.
|
|
5
|
+
"version": "6.2.0-canary.57",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"types": "src/index.ts",
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
type PathCount = { path: string; count: number }
|
|
2
|
+
|
|
3
|
+
export const packageRoots = (packagePaths: string[]): string[] => {
|
|
4
|
+
const pathMap: { [key: string]: PathCount } = {}
|
|
5
|
+
|
|
6
|
+
// Iterate over each path in the array
|
|
7
|
+
packagePaths.forEach((singlePath) => {
|
|
8
|
+
const parts = singlePath.split('/')
|
|
9
|
+
|
|
10
|
+
// Iterate through each part of the path
|
|
11
|
+
for (let i = 1; i < parts.length; i++) {
|
|
12
|
+
const subPath = parts.slice(0, i + 1).join('/')
|
|
13
|
+
|
|
14
|
+
// Increment the count of this subPath
|
|
15
|
+
if (pathMap[subPath]) {
|
|
16
|
+
pathMap[subPath].count += 1
|
|
17
|
+
} else {
|
|
18
|
+
pathMap[subPath] = { path: subPath, count: 1 }
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
// Filter the paths that appear more than once
|
|
24
|
+
const roots: string[] = []
|
|
25
|
+
Object.values(pathMap).forEach(({ path, count }) => {
|
|
26
|
+
if (count > 1) {
|
|
27
|
+
roots.push(path)
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
// Filter out the sub-paths which are part of another longer sub-path
|
|
32
|
+
return roots.filter(
|
|
33
|
+
(root, index, self) => self.findIndex((r) => r !== root && r.startsWith(root + '/')) === -1,
|
|
34
|
+
)
|
|
35
|
+
}
|