Skip to content

Commit ba66920

Browse files
committed
chore: wip
1 parent 55b7625 commit ba66920

File tree

7 files changed

+75
-132
lines changed

7 files changed

+75
-132
lines changed

packages/logsmith/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export async function loadLogsmithConfig(overrides: LogsmithOptions = {}): Promi
103103

104104
// Filter out undefined values from overrides to avoid overriding defaults
105105
const filteredOverrides = Object.fromEntries(
106-
Object.entries(overrides).filter(([, value]) => value !== undefined)
106+
Object.entries(overrides).filter(([, value]) => value !== undefined),
107107
) as LogsmithOptions
108108

109109
// Merge configurations with proper precedence: overrides > loaded > defaults

packages/logsmith/src/utils.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,8 @@ export async function lintMarkdown(content: string, config: LogsmithConfig): Pro
750750

751751
try {
752752
// Dynamically import markdownlint to avoid bundling issues
753-
const { default: markdownlint } = await import('markdownlint')
753+
const markdownlintModule = await import('markdownlint')
754+
const markdownlint = (markdownlintModule as any).default || markdownlintModule
754755

755756
// Prepare markdownlint options
756757
const options = {
@@ -771,7 +772,7 @@ export async function lintMarkdown(content: string, config: LogsmithConfig): Pro
771772
const externalConfig = JSON.parse(readFileSync(config.markdownLintConfig, 'utf8'))
772773
options.config = { ...options.config, ...externalConfig }
773774
}
774-
catch (error) {
775+
catch (error: any) {
775776
if (config.verbose) {
776777
logWarning(`Failed to load markdownlint config from ${config.markdownLintConfig}: ${error}`)
777778
}
@@ -785,7 +786,7 @@ export async function lintMarkdown(content: string, config: LogsmithConfig): Pro
785786
const errors = result.content || []
786787
if (errors.length > 0 && config.verbose) {
787788
logInfo('Markdownlint found issues that have been auto-fixed:')
788-
errors.forEach((error) => {
789+
errors.forEach((error: any) => {
789790
logInfo(` Line ${error.lineNumber}: ${error.ruleDescription}`)
790791
})
791792
}
@@ -806,7 +807,7 @@ export async function lintMarkdown(content: string, config: LogsmithConfig): Pro
806807

807808
return fixedContent
808809
}
809-
catch (error) {
810+
catch (error: any) {
810811
if (config.verbose) {
811812
logWarning(`Markdownlint failed: ${error}. Returning original content.`)
812813
}

packages/logsmith/test/changelog.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,12 @@ describe('changelog', () => {
247247

248248
try {
249249
const result = await generateChangelog(config)
250-
250+
251251
// Verify that the result is defined and content is a string
252252
expect(result).toBeDefined()
253253
expect(typeof result.content).toBe('string')
254254
expect(result.format).toBe('markdown')
255-
255+
256256
// The content should be processed (even if linting currently falls back to original)
257257
// This test verifies that the linting integration doesn't break the flow
258258
expect(result.content.length).toBeGreaterThanOrEqual(0)
@@ -275,10 +275,10 @@ describe('changelog', () => {
275275

276276
try {
277277
const result = await generateChangelog(config)
278-
278+
279279
expect(result).toBeDefined()
280280
expect(result.format).toBe('json')
281-
281+
282282
// For JSON format, content should be valid JSON
283283
if (result.content) {
284284
expect(() => JSON.parse(result.content)).not.toThrow()
@@ -302,10 +302,10 @@ describe('changelog', () => {
302302

303303
try {
304304
const result = await generateChangelog(config)
305-
305+
306306
expect(result).toBeDefined()
307307
expect(result.format).toBe('html')
308-
308+
309309
// For HTML format, content should contain HTML structure
310310
if (result.content) {
311311
expect(result.content).toContain('<!DOCTYPE html>')
@@ -341,7 +341,7 @@ describe('changelog', () => {
341341
try {
342342
const resultWithLinting = await generateChangelog(configWithLinting)
343343
const resultWithoutLinting = await generateChangelog(configWithoutLinting)
344-
344+
345345
// Both should work regardless of linting setting
346346
expect(resultWithLinting).toBeDefined()
347347
expect(resultWithoutLinting).toBeDefined()
@@ -366,7 +366,7 @@ describe('changelog', () => {
366366

367367
try {
368368
const result = await generateChangelog(config)
369-
369+
370370
// Verify that even console-only output gets linting applied
371371
expect(result).toBeDefined()
372372
expect(result.outputPath).toBeUndefined()

packages/logsmith/test/config.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ describe('config', () => {
3535
// Test that the default config has the correct bot exclusions
3636
expect(defaultConfig.excludeAuthors).toContain('dependabot[bot]')
3737
expect(defaultConfig.excludeAuthors).toContain('github-actions[bot]')
38-
38+
3939
// Test that the config can be overridden
4040
const customConfig: LogsmithConfig = {
4141
...defaultConfig,
4242
excludeAuthors: ['custom-bot', 'another-bot'],
4343
}
44-
44+
4545
expect(customConfig.excludeAuthors).toContain('custom-bot')
4646
expect(customConfig.excludeAuthors).toContain('another-bot')
4747
expect(customConfig.excludeAuthors).not.toContain('dependabot[bot]')
@@ -57,12 +57,12 @@ describe('config', () => {
5757
}
5858

5959
const config = await loadLogsmithConfig(overridesWithUndefined)
60-
60+
6161
// Should preserve default excludeAuthors
6262
expect(config.excludeAuthors).toContain('dependabot[bot]')
6363
expect(config.excludeAuthors).toContain('github-actions[bot]')
6464
expect(config.excludeAuthors).toHaveLength(2)
65-
65+
6666
// Other overrides should still work
6767
expect(config.verbose).toBe(true)
6868
expect(config.output).toBe('CUSTOM.md')
@@ -77,14 +77,14 @@ describe('config', () => {
7777
}
7878

7979
const config = await loadLogsmithConfig(overridesWithExplicitAuthors)
80-
80+
8181
// Should use the explicit excludeAuthors
8282
expect(config.excludeAuthors).toContain('explicit-bot')
8383
expect(config.excludeAuthors).toContain('another-explicit-bot')
8484
expect(config.excludeAuthors).toHaveLength(2)
8585
expect(config.excludeAuthors).not.toContain('dependabot[bot]')
8686
expect(config.excludeAuthors).not.toContain('github-actions[bot]')
87-
87+
8888
// Other overrides should still work
8989
expect(config.verbose).toBe(true)
9090
expect(config.output).toBe('CUSTOM.md')

packages/logsmith/test/markdown-integration.test.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe('markdown linting integration', () => {
99
describe('end-to-end markdown linting', () => {
1010
it('should apply linting when generating changelog to file', async () => {
1111
const testOutputPath = 'test/test-output-changelog.md'
12-
12+
1313
// Clean up any existing test file
1414
if (existsSync(testOutputPath)) {
1515
unlinkSync(testOutputPath)
@@ -26,12 +26,12 @@ describe('markdown linting integration', () => {
2626

2727
try {
2828
const result = await generateChangelog(config)
29-
29+
3030
// Verify the result structure
3131
expect(result).toBeDefined()
3232
expect(result.format).toBe('markdown')
3333
expect(result.outputPath).toContain(testOutputPath)
34-
34+
3535
// Verify the file was created and contains expected content
3636
if (existsSync(testOutputPath)) {
3737
const fileContent = readFileSync(testOutputPath, 'utf-8')
@@ -64,13 +64,13 @@ describe('markdown linting integration', () => {
6464

6565
try {
6666
const result = await generateChangelog(config)
67-
67+
6868
// Verify that console output gets linting applied
6969
expect(result).toBeDefined()
7070
expect(result.format).toBe('markdown')
7171
expect(result.outputPath).toBeUndefined()
7272
expect(typeof result.content).toBe('string')
73-
73+
7474
// Content should be processed (even if linting currently falls back)
7575
expect(result.content.length).toBeGreaterThanOrEqual(0)
7676
}
@@ -82,7 +82,7 @@ describe('markdown linting integration', () => {
8282

8383
it('should merge with existing changelog and apply linting', async () => {
8484
const testOutputPath = 'test/test-merge-changelog.md'
85-
85+
8686
// Create an existing changelog with formatting issues
8787
const existingContent = `# Changelog
8888
@@ -107,10 +107,10 @@ describe('markdown linting integration', () => {
107107

108108
try {
109109
const result = await generateChangelog(config)
110-
110+
111111
expect(result).toBeDefined()
112112
expect(result.format).toBe('markdown')
113-
113+
114114
// Verify the file was updated and should have linting applied
115115
if (existsSync(testOutputPath)) {
116116
const updatedContent = readFileSync(testOutputPath, 'utf-8')
@@ -150,7 +150,7 @@ This content should not be immediately after the heading
150150
`
151151

152152
const result = await lintMarkdown(problematicContent, config)
153-
153+
154154
// Should return the content (potentially fixed or unchanged if markdownlint fails)
155155
expect(typeof result).toBe('string')
156156
expect(result.length).toBeGreaterThan(0)
@@ -169,7 +169,7 @@ Content with formatting issues
169169
Multiple blank lines`
170170

171171
const result = await lintMarkdown(content, config)
172-
172+
173173
// Should return unchanged when linting is disabled
174174
expect(result).toBe(content)
175175
})
@@ -181,7 +181,7 @@ Multiple blank lines`
181181
}
182182

183183
const result = await lintMarkdown('', config)
184-
184+
185185
expect(typeof result).toBe('string')
186186
})
187187

@@ -200,7 +200,7 @@ Multiple blank lines`
200200
`
201201

202202
const result = await lintMarkdown(malformedContent, config)
203-
203+
204204
// Should not throw and return a string
205205
expect(typeof result).toBe('string')
206206
expect(result.length).toBeGreaterThan(0)
@@ -220,9 +220,9 @@ Multiple blank lines`
220220

221221
try {
222222
const result = await generateChangelog(config)
223-
223+
224224
expect(result.format).toBe('json')
225-
225+
226226
// JSON content should not be processed through markdown linting
227227
if (result.content) {
228228
expect(() => JSON.parse(result.content)).not.toThrow()
@@ -246,9 +246,9 @@ Multiple blank lines`
246246

247247
try {
248248
const result = await generateChangelog(config)
249-
249+
250250
expect(result.format).toBe('html')
251-
251+
252252
// HTML content should not be processed through markdown linting
253253
if (result.content) {
254254
expect(result.content).toContain('<!DOCTYPE html>')
@@ -264,9 +264,9 @@ Multiple blank lines`
264264
describe('test data validation', () => {
265265
it('should have test changelog data file in correct location', () => {
266266
const testChangelogPath = 'test/test-changelog.md'
267-
267+
268268
expect(existsSync(testChangelogPath)).toBe(true)
269-
269+
270270
const content = readFileSync(testChangelogPath, 'utf-8')
271271
expect(content).toContain('# Changelog')
272272
expect(content.length).toBeGreaterThan(0)
@@ -276,7 +276,7 @@ Multiple blank lines`
276276
describe('author exclusion integration', () => {
277277
it('should exclude bot authors from contributors section', async () => {
278278
const testOutputPath = 'test/test-authors-exclusion.md'
279-
279+
280280
// Clean up any existing test file
281281
if (existsSync(testOutputPath)) {
282282
unlinkSync(testOutputPath)
@@ -295,17 +295,17 @@ Multiple blank lines`
295295

296296
try {
297297
const result = await generateChangelog(config)
298-
298+
299299
expect(result).toBeDefined()
300300
expect(result.format).toBe('markdown')
301-
301+
302302
// Verify the file was created
303303
if (existsSync(testOutputPath)) {
304304
const fileContent = readFileSync(testOutputPath, 'utf-8')
305-
305+
306306
// Should contain changelog content
307307
expect(fileContent).toContain('# Changelog')
308-
308+
309309
// If there are contributors, they should NOT include bot authors
310310
if (fileContent.includes('### Contributors')) {
311311
expect(fileContent).not.toContain('dependabot[bot]')
@@ -327,7 +327,7 @@ Multiple blank lines`
327327

328328
it('should respect custom excludeAuthors configuration', async () => {
329329
const testOutputPath = 'test/test-custom-authors-exclusion.md'
330-
330+
331331
// Clean up any existing test file
332332
if (existsSync(testOutputPath)) {
333333
unlinkSync(testOutputPath)
@@ -346,17 +346,17 @@ Multiple blank lines`
346346

347347
try {
348348
const result = await generateChangelog(config)
349-
349+
350350
expect(result).toBeDefined()
351351
expect(result.format).toBe('markdown')
352-
352+
353353
// Verify the file was created
354354
if (existsSync(testOutputPath)) {
355355
const fileContent = readFileSync(testOutputPath, 'utf-8')
356-
356+
357357
// Should contain changelog content
358358
expect(fileContent).toContain('# Changelog')
359-
359+
360360
// If there are contributors, they should NOT include excluded authors
361361
if (fileContent.includes('### Contributors')) {
362362
expect(fileContent).not.toContain('John Doe')
@@ -381,7 +381,7 @@ Multiple blank lines`
381381
expect(defaultConfig.excludeAuthors).toContain('dependabot[bot]')
382382
expect(defaultConfig.excludeAuthors).toContain('github-actions[bot]')
383383
expect(defaultConfig.excludeAuthors).toHaveLength(2)
384-
384+
385385
// Verify the config structure
386386
expect(Array.isArray(defaultConfig.excludeAuthors)).toBe(true)
387387
expect(typeof defaultConfig.excludeAuthors[0]).toBe('string')

0 commit comments

Comments
 (0)