enablement-build-monorepo-version 8.3.6 → 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 +3 -2
- package/src/index.mjs +32 -1
- package/tests/lib.test.mjs +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "enablement-build-monorepo-version",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.0",
|
|
4
4
|
"description": "This detects changes in the children packages of a monorepo.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./src/index.mjs",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
]
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"
|
|
17
|
+
"minimatch": "~10.1.1",
|
|
18
|
+
"enablement-build-manifest": "1.8.2"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
21
|
"jest": "^30.4.2"
|
package/src/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { readFileSync, writeFileSync, existsSync, lstatSync } from "fs";
|
|
4
4
|
import { exec } from "child_process";
|
|
5
|
+
import { minimatch } from "minimatch";
|
|
5
6
|
|
|
6
7
|
const packageMetadata = JSON.parse(
|
|
7
8
|
readFileSync(new URL("../package.json", import.meta.url), "utf8"),
|
|
@@ -82,9 +83,39 @@ async function collectPackageEntries(prefixPath, scanFolder, packageFolder, hash
|
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
|
|
86
|
+
function createGitignoreMatcher(prefixPath, explicitPatterns) {
|
|
87
|
+
const gitignorePath = path.join(prefixPath, '.gitignore');
|
|
88
|
+
const rules = existsSync(gitignorePath)
|
|
89
|
+
? readFileSync(gitignorePath, 'utf8')
|
|
90
|
+
.split(/\r?\n/)
|
|
91
|
+
.map(line => line.trim())
|
|
92
|
+
.filter(line => line && !line.startsWith('#') && !line.startsWith('!'))
|
|
93
|
+
: [];
|
|
94
|
+
const patterns = [...rules, ...explicitPatterns];
|
|
95
|
+
|
|
96
|
+
return targetPath => {
|
|
97
|
+
const relativePath = path.relative(prefixPath, targetPath).replace(/\\/g, '/');
|
|
98
|
+
if (!relativePath || relativePath.startsWith('../')) return false;
|
|
99
|
+
const basename = path.basename(relativePath);
|
|
100
|
+
if (basename === 'node_modules') return true;
|
|
101
|
+
|
|
102
|
+
return patterns.some(pattern => {
|
|
103
|
+
const normalized = pattern.replace(/^\/+/, '').replace(/\/+$/, '');
|
|
104
|
+
if (!normalized) return false;
|
|
105
|
+
if (!normalized.includes('/')) {
|
|
106
|
+
return minimatch(basename, normalized, { dot: true }) ||
|
|
107
|
+
minimatch(relativePath, `**/${normalized}`, { dot: true });
|
|
108
|
+
}
|
|
109
|
+
return minimatch(relativePath, normalized, { dot: true }) ||
|
|
110
|
+
minimatch(relativePath, `${normalized}/**`, { dot: true });
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
85
115
|
async function main(options) {
|
|
86
116
|
return new Promise((mainResolve, mainreject) => {
|
|
87
|
-
const
|
|
117
|
+
const ignoredPath = createGitignoreMatcher(options.prefixPath, [...options.hashExcludeFolders, ...options.hashExcludeFiles]);
|
|
118
|
+
const hashOptions = { encoding: 'hex', folders: { exclude: ignoredPath, matchBasename: false, matchPath: true }, files: { exclude: ignoredPath, matchBasename: false, matchPath: true }, symbolicLinks: { ignoreTargetPath: true, ignoreTargetContent: true } };
|
|
88
119
|
const current = {};
|
|
89
120
|
const changeList = [];
|
|
90
121
|
const scanlist = [];
|
package/tests/lib.test.mjs
CHANGED
|
@@ -578,9 +578,9 @@ describe("extractDirsFromPatterns", () => {
|
|
|
578
578
|
expect(extractDirsFromPatterns(["*"])).toEqual([]);
|
|
579
579
|
});
|
|
580
580
|
|
|
581
|
-
it("
|
|
581
|
+
it("preserves the full literal prefix for a deep glob", () => {
|
|
582
582
|
expect(extractDirsFromPatterns(["components/ui/**"])).toEqual([
|
|
583
|
-
"components",
|
|
583
|
+
"components/ui",
|
|
584
584
|
]);
|
|
585
585
|
});
|
|
586
586
|
});
|