@mnci/cli 4.7.0 → 4.7.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/dist/cli.js +33 -0
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1637,6 +1637,38 @@ function ensureEslintCacheIgnored(workspaceRoot) {
|
|
|
1637
1637
|
`
|
|
1638
1638
|
);
|
|
1639
1639
|
}
|
|
1640
|
+
var PYTHON_ARTEFACT_IGNORES = ["__pycache__/", "*.py[cod]"];
|
|
1641
|
+
function ensurePythonArtefactsIgnored(workspaceRoot) {
|
|
1642
|
+
const gitignorePath = (0, import_node_path2.join)(workspaceRoot, ".gitignore");
|
|
1643
|
+
if (!fileExists(gitignorePath)) {
|
|
1644
|
+
return;
|
|
1645
|
+
}
|
|
1646
|
+
const hasPython = (0, import_node_fs2.globSync)(
|
|
1647
|
+
["python-packages/*/pyproject.toml", "apps/*/pyproject.toml", "libs/*/pyproject.toml"],
|
|
1648
|
+
{ cwd: workspaceRoot }
|
|
1649
|
+
).length > 0;
|
|
1650
|
+
if (!hasPython) {
|
|
1651
|
+
return;
|
|
1652
|
+
}
|
|
1653
|
+
const current = (0, import_node_fs2.readFileSync)(gitignorePath, "utf8");
|
|
1654
|
+
const present = new Set(current.split("\n").map((line) => line.trim()));
|
|
1655
|
+
const missing = PYTHON_ARTEFACT_IGNORES.filter((line) => !present.has(line));
|
|
1656
|
+
if (missing.length === 0) {
|
|
1657
|
+
return;
|
|
1658
|
+
}
|
|
1659
|
+
const withoutTrailingBlankLines = current.replace(/\n+$/u, "");
|
|
1660
|
+
const separator = withoutTrailingBlankLines.length > 0 ? "\n\n" : "";
|
|
1661
|
+
const heading = [
|
|
1662
|
+
"# Added by MoNecromanCI: Python bytecode. The tool caches (.mypy_cache,",
|
|
1663
|
+
"# .pytest_cache, .ruff_cache) write their own .gitignore; CPython does not."
|
|
1664
|
+
].join("\n");
|
|
1665
|
+
writeFileEnsured(
|
|
1666
|
+
gitignorePath,
|
|
1667
|
+
`${withoutTrailingBlankLines}${separator}${heading}
|
|
1668
|
+
${missing.join("\n")}
|
|
1669
|
+
`
|
|
1670
|
+
);
|
|
1671
|
+
}
|
|
1640
1672
|
function removeProjectEslintConfigs(workspaceRoot) {
|
|
1641
1673
|
const matches = (0, import_node_fs2.globSync)("{apps,libs,packages}/*/eslint.config.{js,mjs,cjs,ts,mts,cts}", {
|
|
1642
1674
|
cwd: workspaceRoot
|
|
@@ -1728,6 +1760,7 @@ function applyOverlay(workspaceRoot, options, onProgress = () => {
|
|
|
1728
1760
|
writeFileEnsured((0, import_node_path2.join)(workspaceRoot, ESLINT_MNCI_FILENAME), ESLINT_MNCI_CONFIG);
|
|
1729
1761
|
writeEslintEntryPoint(workspaceRoot, onProgress);
|
|
1730
1762
|
ensureEslintCacheIgnored(workspaceRoot);
|
|
1763
|
+
ensurePythonArtefactsIgnored(workspaceRoot);
|
|
1731
1764
|
for (const retired of RETIRED_FORMATTER_FILES) {
|
|
1732
1765
|
removeIfPresent((0, import_node_path2.join)(workspaceRoot, retired));
|
|
1733
1766
|
}
|