@mnci/cli 4.0.6 → 4.0.7

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 CHANGED
@@ -1136,9 +1136,39 @@ ${githubReleases ? "" : `
1136
1136
  if: \${{ ${onMain} }}
1137
1137
  `}`;
1138
1138
  }
1139
- var DEPENDABOT_CONFIG = `# Generated by MoNecromanCI. Weekly dependency-update PRs so vulnerable or
1139
+ var PIP_PROJECT_GLOBS = ["apps", "python-packages", "libs"];
1140
+ var PUB_PROJECT_GLOBS = ["apps", "packages", "libs"];
1141
+ var ECOSYSTEM_MANIFESTS = {
1142
+ pip: ["pyproject.toml", "requirements.txt"],
1143
+ pub: ["pubspec.yaml"]
1144
+ };
1145
+ function hasEcosystemProject(workspaceRoot, roots, manifests) {
1146
+ return roots.some((root) => {
1147
+ const base = (0, import_node_path2.join)(workspaceRoot, root);
1148
+ if (!(0, import_node_fs2.existsSync)(base)) {
1149
+ return false;
1150
+ }
1151
+ return (0, import_node_fs2.readdirSync)(base, { withFileTypes: true }).some(
1152
+ (entry) => entry.isDirectory() && manifests.some((manifest) => (0, import_node_fs2.existsSync)((0, import_node_path2.join)(base, entry.name, manifest)))
1153
+ );
1154
+ });
1155
+ }
1156
+ function dependabotBlock(ecosystem, roots) {
1157
+ return `
1158
+ - package-ecosystem: ${ecosystem}
1159
+ directories:
1160
+ ` + roots.map((root) => ` - "/${root}/*"
1161
+ `).join("") + " schedule:\n interval: weekly\n";
1162
+ }
1163
+ function dependabotConfig(workspaceRoot) {
1164
+ let config = `# Generated by MoNecromanCI. Weekly dependency-update PRs so vulnerable or
1140
1165
  # stale dependencies surface as a reviewable PR instead of only a push-time
1141
1166
  # warning.
1167
+ #
1168
+ # pip and pub appear here only once the workspace HAS a Python or Dart project.
1169
+ # An ecosystem entry whose directories match no manifest is a hard Dependabot
1170
+ # failure, not a no-op, so emitting them unconditionally cost every workspace
1171
+ # two red runs a week over projects it does not have.
1142
1172
  version: 2
1143
1173
  updates:
1144
1174
  - package-ecosystem: npm
@@ -1150,30 +1180,15 @@ updates:
1150
1180
  directory: "/"
1151
1181
  schedule:
1152
1182
  interval: weekly
1153
-
1154
- # Globs, not one entry per project: Python projects are added later via
1155
- # 'mnci add python-*', so this starts covering them automatically the
1156
- # moment the first one exists \u2014 a glob matching nothing yet is not an error.
1157
- - package-ecosystem: pip
1158
- directories:
1159
- - "/apps/*"
1160
- - "/python-packages/*"
1161
- - "/libs/*"
1162
- schedule:
1163
- interval: weekly
1164
-
1165
- # Same glob reasoning as pip above. Dart projects are pub workspace members,
1166
- # so each one declares its own dependencies even though they all resolve
1167
- # through the single root pubspec.lock \u2014 hence the per-project directories
1168
- # rather than just "/".
1169
- - package-ecosystem: pub
1170
- directories:
1171
- - "/apps/*"
1172
- - "/packages/*"
1173
- - "/libs/*"
1174
- schedule:
1175
- interval: weekly
1176
1183
  `;
1184
+ if (hasEcosystemProject(workspaceRoot, PIP_PROJECT_GLOBS, ECOSYSTEM_MANIFESTS.pip)) {
1185
+ config += dependabotBlock("pip", PIP_PROJECT_GLOBS);
1186
+ }
1187
+ if (hasEcosystemProject(workspaceRoot, PUB_PROJECT_GLOBS, ECOSYSTEM_MANIFESTS.pub)) {
1188
+ config += dependabotBlock("pub", PUB_PROJECT_GLOBS);
1189
+ }
1190
+ return config;
1191
+ }
1177
1192
  var NX_SCAFFOLDING_TO_REMOVE = [".prettierrc", ".prettierrc.json", ".vscode"];
1178
1193
  function removeNxScaffolding(workspaceRoot) {
1179
1194
  for (const entry of NX_SCAFFOLDING_TO_REMOVE) {
@@ -1300,7 +1315,7 @@ function applyOverlay(workspaceRoot, options, onProgress = () => {
1300
1315
  (0, import_node_path2.join)(workspaceRoot, ".github/workflows/ci.yml"),
1301
1316
  githubActionsYaml(options.agent, publishUrl, options.registry.kind, options.ci)
1302
1317
  );
1303
- writeFileEnsured((0, import_node_path2.join)(workspaceRoot, ".github/dependabot.yml"), DEPENDABOT_CONFIG);
1318
+ writeFileEnsured((0, import_node_path2.join)(workspaceRoot, ".github/dependabot.yml"), dependabotConfig(workspaceRoot));
1304
1319
  }
1305
1320
  }
1306
1321
 
@@ -1406,6 +1421,10 @@ function registerProjectCommands(workspaceRoot, name, commands) {
1406
1421
  if (commands.start) {
1407
1422
  scripts[`${name}:start`] = commands.start;
1408
1423
  }
1424
+ const dependabotPath = (0, import_node_path3.join)(workspaceRoot, ".github/dependabot.yml");
1425
+ if ((0, import_node_fs3.existsSync)(dependabotPath)) {
1426
+ writeFileEnsured(dependabotPath, dependabotConfig(workspaceRoot));
1427
+ }
1409
1428
  const manifestPath = (0, import_node_path3.join)(workspaceRoot, "package.json");
1410
1429
  const manifest = readJson(manifestPath);
1411
1430
  const existingScripts = manifest.scripts ?? {};