@aspruyt/xfg 3.9.2 → 3.9.4

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.
@@ -192,7 +192,7 @@ async function processRulesets(repos, config, options, processor, repoProcessor,
192
192
  /**
193
193
  * Process repo settings for all configured repositories.
194
194
  */
195
- async function processRepoSettings(repos, config, options, processorFactory, results, collector, lifecycleSkipped) {
195
+ async function processRepoSettings(repos, config, options, processorFactory, results, collector, lifecycleSkipped, indexOffset) {
196
196
  if (repos.length === 0) {
197
197
  return;
198
198
  }
@@ -200,6 +200,7 @@ async function processRepoSettings(repos, config, options, processorFactory, res
200
200
  console.log(`\nProcessing repo settings for ${repos.length} repositories\n`);
201
201
  for (let i = 0; i < repos.length; i++) {
202
202
  const repoConfig = repos[i];
203
+ const current = indexOffset + i + 1;
203
204
  if (lifecycleSkipped.has(repoConfig.git)) {
204
205
  continue;
205
206
  }
@@ -210,7 +211,7 @@ async function processRepoSettings(repos, config, options, processorFactory, res
210
211
  });
211
212
  }
212
213
  catch (error) {
213
- logger.error(i + 1, repoConfig.git, String(error));
214
+ logger.error(current, repoConfig.git, String(error));
214
215
  collector.appendError(repoConfig.git, error);
215
216
  continue;
216
217
  }
@@ -220,14 +221,14 @@ async function processRepoSettings(repos, config, options, processorFactory, res
220
221
  dryRun: options.dryRun,
221
222
  });
222
223
  if (result.planOutput && result.planOutput.lines.length > 0) {
223
- console.log(`\n ${chalk.bold(repoName)}:`);
224
- console.log(" Repo Settings:");
224
+ logger.info("");
225
+ logger.info(chalk.bold(`${repoName} - Repo Settings:`));
225
226
  for (const line of result.planOutput.lines) {
226
- console.log(line);
227
+ logger.info(line);
227
228
  }
228
229
  if (result.warnings && result.warnings.length > 0) {
229
230
  for (const warning of result.warnings) {
230
- console.log(chalk.yellow(` ⚠️ Warning: ${warning}`));
231
+ logger.info(chalk.yellow(`Warning: ${warning}`));
231
232
  }
232
233
  }
233
234
  }
@@ -235,10 +236,10 @@ async function processRepoSettings(repos, config, options, processorFactory, res
235
236
  // Silent skip
236
237
  }
237
238
  else if (result.success) {
238
- console.log(chalk.green(` ✓ ${repoName}: ${result.message}`));
239
+ logger.success(current, repoName, result.message);
239
240
  }
240
241
  else {
241
- console.log(chalk.red(` ✗ ${repoName}: ${result.message}`));
242
+ logger.error(current, repoName, result.message);
242
243
  }
243
244
  if (!result.skipped) {
244
245
  const existing = results.find((r) => r.repoName === repoName);
@@ -259,7 +260,7 @@ async function processRepoSettings(repos, config, options, processorFactory, res
259
260
  }
260
261
  }
261
262
  catch (error) {
262
- logger.error(i + 1, repoName, String(error));
263
+ logger.error(current, repoName, String(error));
263
264
  collector.appendError(repoName, error);
264
265
  }
265
266
  }
@@ -312,7 +313,7 @@ export async function runSettings(options, processorFactory = defaultRulesetProc
312
313
  const allRepos = [...reposWithRulesets, ...reposWithRepoSettings];
313
314
  const lifecycleSkipped = await runLifecycleChecks(allRepos, config, options, lm, results, collector, tokenManager);
314
315
  await processRulesets(reposWithRulesets, config, options, processor, repoProcessor, results, collector, lifecycleSkipped);
315
- await processRepoSettings(reposWithRepoSettings, config, options, repoSettingsProcessorFactory, results, collector, lifecycleSkipped);
316
+ await processRepoSettings(reposWithRepoSettings, config, options, repoSettingsProcessorFactory, results, collector, lifecycleSkipped, reposWithRulesets.length);
316
317
  console.log("");
317
318
  const report = buildSettingsReport(collector.getAll());
318
319
  const lines = formatSettingsReportCLI(report);
@@ -7,6 +7,7 @@ import { formatValuePlain, formatRulesetConfigPlain, } from "./settings-report.j
7
7
  // =============================================================================
8
8
  function formatCombinedSummary(input) {
9
9
  const parts = [];
10
+ const dry = input.dryRun;
10
11
  // Lifecycle totals
11
12
  if (input.lifecycle) {
12
13
  const t = input.lifecycle.totals;
@@ -14,11 +15,11 @@ function formatCombinedSummary(input) {
14
15
  if (repoTotal > 0) {
15
16
  const repoParts = [];
16
17
  if (t.created > 0)
17
- repoParts.push(`${t.created} to create`);
18
+ repoParts.push(`${t.created} ${dry ? "to create" : "created"}`);
18
19
  if (t.forked > 0)
19
- repoParts.push(`${t.forked} to fork`);
20
+ repoParts.push(`${t.forked} ${dry ? "to fork" : "forked"}`);
20
21
  if (t.migrated > 0)
21
- repoParts.push(`${t.migrated} to migrate`);
22
+ repoParts.push(`${t.migrated} ${dry ? "to migrate" : "migrated"}`);
22
23
  const repoWord = repoTotal === 1 ? "repo" : "repos";
23
24
  parts.push(`${repoTotal} ${repoWord} (${repoParts.join(", ")})`);
24
25
  }
@@ -30,11 +31,11 @@ function formatCombinedSummary(input) {
30
31
  if (fileTotal > 0) {
31
32
  const fileParts = [];
32
33
  if (t.files.create > 0)
33
- fileParts.push(`${t.files.create} to create`);
34
+ fileParts.push(`${t.files.create} ${dry ? "to create" : "created"}`);
34
35
  if (t.files.update > 0)
35
- fileParts.push(`${t.files.update} to update`);
36
+ fileParts.push(`${t.files.update} ${dry ? "to update" : "updated"}`);
36
37
  if (t.files.delete > 0)
37
- fileParts.push(`${t.files.delete} to delete`);
38
+ fileParts.push(`${t.files.delete} ${dry ? "to delete" : "deleted"}`);
38
39
  const fileWord = fileTotal === 1 ? "file" : "files";
39
40
  parts.push(`${fileTotal} ${fileWord} (${fileParts.join(", ")})`);
40
41
  }
@@ -47,9 +48,9 @@ function formatCombinedSummary(input) {
47
48
  const settingWord = settingsTotal === 1 ? "setting" : "settings";
48
49
  const actions = [];
49
50
  if (t.settings.add > 0)
50
- actions.push(`${t.settings.add} to add`);
51
+ actions.push(`${t.settings.add} ${dry ? "to add" : "added"}`);
51
52
  if (t.settings.change > 0)
52
- actions.push(`${t.settings.change} to change`);
53
+ actions.push(`${t.settings.change} ${dry ? "to change" : "changed"}`);
53
54
  parts.push(`${settingsTotal} ${settingWord} (${actions.join(", ")})`);
54
55
  }
55
56
  const rulesetsTotal = t.rulesets.create + t.rulesets.update + t.rulesets.delete;
@@ -57,18 +58,19 @@ function formatCombinedSummary(input) {
57
58
  const rulesetWord = rulesetsTotal === 1 ? "ruleset" : "rulesets";
58
59
  const actions = [];
59
60
  if (t.rulesets.create > 0)
60
- actions.push(`${t.rulesets.create} to create`);
61
+ actions.push(`${t.rulesets.create} ${dry ? "to create" : "created"}`);
61
62
  if (t.rulesets.update > 0)
62
- actions.push(`${t.rulesets.update} to update`);
63
+ actions.push(`${t.rulesets.update} ${dry ? "to update" : "updated"}`);
63
64
  if (t.rulesets.delete > 0)
64
- actions.push(`${t.rulesets.delete} to delete`);
65
+ actions.push(`${t.rulesets.delete} ${dry ? "to delete" : "deleted"}`);
65
66
  parts.push(`${rulesetsTotal} ${rulesetWord} (${actions.join(", ")})`);
66
67
  }
67
68
  }
68
69
  if (parts.length === 0) {
69
70
  return "No changes";
70
71
  }
71
- return `Plan: ${parts.join(", ")}`;
72
+ const prefix = dry ? "Plan" : "Applied";
73
+ return `${prefix}: ${parts.join(", ")}`;
72
74
  }
73
75
  function hasAnyChanges(input) {
74
76
  if (input.lifecycle && hasLifecycleChanges(input.lifecycle))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aspruyt/xfg",
3
- "version": "3.9.2",
3
+ "version": "3.9.4",
4
4
  "description": "CLI tool for repository-as-code: sync files and manage settings across GitHub, Azure DevOps, and GitLab",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",