@alleyinteractive/changelog-extractor 0.1.0 → 0.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/README.md CHANGED
@@ -21,8 +21,6 @@ as both a **GitHub Action** and a **CLI tool**.
21
21
 
22
22
  #### Extract All Versions
23
23
 
24
- ### Extract All Versions
25
-
26
24
  By default, the action returns all versions in the changelog:
27
25
 
28
26
  ```yaml
@@ -36,7 +34,7 @@ By default, the action returns all versions in the changelog:
36
34
  echo '${{ fromJson(steps.changelog.outputs.result)[0].contents }}'
37
35
  ```
38
36
 
39
- ### Extract Specific Version
37
+ #### Extract Specific Version
40
38
 
41
39
  ```yaml
42
40
  - name: Extract v1.14.0 Changelog
@@ -47,7 +45,7 @@ By default, the action returns all versions in the changelog:
47
45
  version: '1.14.0' # or 'v1.14.0'
48
46
  ```
49
47
 
50
- ### Create Release from Latest Version
48
+ #### Create Release from Latest Version
51
49
 
52
50
  ```yaml
53
51
  name: Release
@@ -141,6 +139,20 @@ npm install -g @alleyinteractive/changelog-extractor
141
139
  changelog-extractor
142
140
  ```
143
141
 
142
+ By default, the CLI outputs JSON to stdout. You can also specify other output
143
+ formats using the `--format` option:
144
+
145
+ ```bash
146
+ # JSON output (default)
147
+ npx @alleyinteractive/changelog-extractor --format json
148
+
149
+ # Pretty-printed dump
150
+ npx @alleyinteractive/changelog-extractor --format dump
151
+
152
+ # Plain text output
153
+ npx @alleyinteractive/changelog-extractor --format text
154
+ ```
155
+
144
156
  ## Supported Changelog Format
145
157
 
146
158
  This action parses changelogs following the
package/dist/index.js CHANGED
@@ -27246,6 +27246,86 @@ function requireCore () {
27246
27246
 
27247
27247
  var coreExports = requireCore();
27248
27248
 
27249
+ /**
27250
+ * Unwrap text that has been wrapped across multiple lines.
27251
+ * This fixes changelog text that has been hard-wrapped for readability
27252
+ * but should flow as continuous text.
27253
+ *
27254
+ * @param {string} text - The text content to unwrap
27255
+ * @returns {string} The unwrapped text
27256
+ */
27257
+ function unwrapText(text) {
27258
+ const lines = text.split('\n');
27259
+ const unwrappedLines = [];
27260
+
27261
+ for (let i = 0; i < lines.length; i++) {
27262
+ let currentLine = lines[i];
27263
+
27264
+ // Skip empty lines - preserve them as-is
27265
+ if (currentLine.trim() === '') {
27266
+ unwrappedLines.push(currentLine);
27267
+ continue
27268
+ }
27269
+
27270
+ // Collect continuation lines
27271
+ let j = i + 1;
27272
+ while (j < lines.length) {
27273
+ const nextLine = lines[j];
27274
+
27275
+ // Stop if next line is empty
27276
+ if (nextLine.trim() === '') {
27277
+ break
27278
+ }
27279
+
27280
+ const trimmedCurrent = currentLine.trim();
27281
+ const trimmedNext = nextLine.trim();
27282
+
27283
+ // Don't unwrap if current line looks like it ends a sentence/item
27284
+ const endsWithPunctuation = /[.!?:;]$/.test(trimmedCurrent);
27285
+ const endsWithCode = /`$/.test(trimmedCurrent);
27286
+ const endsWithBullet = /[-*+]\s*$/.test(trimmedCurrent);
27287
+
27288
+ // Don't unwrap if next line starts a new bullet point, section, or sentence
27289
+ const startsWithBullet = /^[-*+]\s/.test(trimmedNext);
27290
+ const startsWithNumber = /^\d+\.\s/.test(trimmedNext);
27291
+ const startsWithMarkdown = /^[#>]/.test(trimmedNext);
27292
+
27293
+ // More nuanced check for new sentences
27294
+ const prevEndsWithContinuation =
27295
+ /[,&]$/.test(trimmedCurrent) ||
27296
+ /\b(and|or|but|with|for|to|from|in|on|at|by)$/.test(trimmedCurrent);
27297
+ const startsWithCapitalNewSentence =
27298
+ /^[A-Z]/.test(trimmedNext) &&
27299
+ !prevEndsWithContinuation &&
27300
+ endsWithPunctuation;
27301
+
27302
+ // Determine if we should unwrap this line with the next
27303
+ const shouldUnwrap =
27304
+ !endsWithPunctuation &&
27305
+ !endsWithCode &&
27306
+ !endsWithBullet &&
27307
+ !startsWithBullet &&
27308
+ !startsWithNumber &&
27309
+ !startsWithCapitalNewSentence &&
27310
+ !startsWithMarkdown;
27311
+
27312
+ if (shouldUnwrap) {
27313
+ // Join the lines, preserving the original indentation of the first line
27314
+ // but removing indentation from continuation lines
27315
+ currentLine = currentLine + ' ' + trimmedNext;
27316
+ j++; // Move to next line
27317
+ } else {
27318
+ break // Stop unwrapping
27319
+ }
27320
+ }
27321
+
27322
+ unwrappedLines.push(currentLine);
27323
+ i = j - 1; // Skip the lines we've consumed (j-1 because for loop will increment)
27324
+ }
27325
+
27326
+ return unwrappedLines.join('\n')
27327
+ }
27328
+
27249
27329
  /**
27250
27330
  * Parse a Keep a Changelog formatted changelog file.
27251
27331
  *
@@ -27346,7 +27426,9 @@ function parseChangelog(changelogContent, version = null) {
27346
27426
 
27347
27427
  const content = currentSectionContent.join('\n');
27348
27428
  if (content.trim()) {
27349
- currentVersion.sections[currentSection] = content;
27429
+ // Unwrap any text that has been hard-wrapped across lines
27430
+ const unwrappedContent = unwrapText(content);
27431
+ currentVersion.sections[currentSection] = unwrappedContent;
27350
27432
  }
27351
27433
  }
27352
27434
  }
@@ -27368,7 +27450,9 @@ function parseChangelog(changelogContent, version = null) {
27368
27450
 
27369
27451
  const content = trimmedContent.join('\n');
27370
27452
  if (content.trim()) {
27371
- currentVersion.sections['general'] = content;
27453
+ // Unwrap any text that has been hard-wrapped across lines
27454
+ const unwrappedContent = unwrapText(content);
27455
+ currentVersion.sections['general'] = unwrappedContent;
27372
27456
  }
27373
27457
  generalContent = [];
27374
27458
  }