fg-devkit 1.14.2 → 1.14.3
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/configs/cliff.toml
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[changelog]
|
|
6
6
|
body = """
|
|
7
7
|
{% if version %}\
|
|
8
|
-
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d
|
|
8
|
+
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
|
|
9
9
|
{% else %}\
|
|
10
10
|
## [unreleased]
|
|
11
11
|
{% endif %}\
|
package/configs/cliff.user.toml
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[changelog]
|
|
6
6
|
body = """
|
|
7
7
|
{% if version %}\
|
|
8
|
-
## Version {{ version | trim_start_matches(pat="v") }} - {{ timestamp | date(format="%Y-%m-%d
|
|
8
|
+
## Version {{ version | trim_start_matches(pat="v") }} - {{ timestamp | date(format="%Y-%m-%d") }}
|
|
9
9
|
{% else %}\
|
|
10
10
|
## [unreleased]
|
|
11
11
|
{% endif %}\
|
package/package.json
CHANGED
package/release-notes/format.ts
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import type { ChangelogRelease } from './types'
|
|
2
2
|
|
|
3
|
+
export const toChangelogDateOnly = (date: string): string => {
|
|
4
|
+
const dateMatch = date.match(/^(\d{4}-\d{2}-\d{2})(?: \d{2}:\d{2})?$/)
|
|
5
|
+
return dateMatch?.[1] ?? date
|
|
6
|
+
}
|
|
7
|
+
|
|
3
8
|
export const formatChangelogDate = (date: string): string => {
|
|
4
|
-
const
|
|
5
|
-
if (
|
|
9
|
+
const datePart = toChangelogDateOnly(date)
|
|
10
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(datePart)) {
|
|
6
11
|
return date
|
|
7
12
|
}
|
|
8
13
|
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const parsed = timePart ? new Date(`${datePart}T${timePart}:00`) : new Date(`${datePart}T12:00:00`)
|
|
12
|
-
const formattedDate = parsed.toLocaleDateString('sv-SE', { dateStyle: 'long' })
|
|
13
|
-
|
|
14
|
-
if (!timePart) {
|
|
15
|
-
return formattedDate
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const formattedTime = parsed.toLocaleTimeString('sv-SE', { hour: '2-digit', minute: '2-digit' })
|
|
19
|
-
return `${formattedDate} ${formattedTime}`
|
|
14
|
+
const parsed = new Date(`${datePart}T12:00:00`)
|
|
15
|
+
return parsed.toLocaleDateString('sv-SE', { dateStyle: 'long' })
|
|
20
16
|
}
|
|
21
17
|
|
|
22
18
|
const CONVENTIONAL_COMMIT_RE = /^(feat|fix|perf|refactor|chore|dep|vuln)(\([^)]+\))?:\s/
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { sortUserReleaseSections } from './format'
|
|
1
|
+
import { sortUserReleaseSections, toChangelogDateOnly } from './format'
|
|
2
2
|
import type { ChangelogRelease } from './types'
|
|
3
3
|
|
|
4
4
|
export const serializeUserChangelogRelease = (release: ChangelogRelease): string => {
|
|
5
|
-
const lines: string[] = [
|
|
5
|
+
const lines: string[] = [
|
|
6
|
+
`## Version ${release.version} - ${toChangelogDateOnly(release.date)}`,
|
|
7
|
+
'',
|
|
8
|
+
]
|
|
6
9
|
|
|
7
10
|
for (const section of sortUserReleaseSections(release.sections)) {
|
|
8
11
|
if (section.items.length === 0) {
|
|
@@ -3,7 +3,6 @@ import path from 'node:path'
|
|
|
3
3
|
import { fileURLToPath } from 'node:url'
|
|
4
4
|
import { parseUserChangelog } from './parseChangelog.ts'
|
|
5
5
|
import { serializeUserChangelogRelease } from './serializeUserChangelog.ts'
|
|
6
|
-
import type { ChangelogRelease } from './types.ts'
|
|
7
6
|
|
|
8
7
|
const rootDir = process.env.FG_DEVKIT_CWD
|
|
9
8
|
? path.resolve(process.env.FG_DEVKIT_CWD)
|
|
@@ -14,36 +13,6 @@ const contentPath = path.join(rootDir, 'CHANGELOG.user.md')
|
|
|
14
13
|
const readMarkdown = (filePath: string): string =>
|
|
15
14
|
existsSync(filePath) ? readFileSync(filePath, 'utf-8') : ''
|
|
16
15
|
|
|
17
|
-
const updateVersionTimestamps = (
|
|
18
|
-
content: string,
|
|
19
|
-
draftReleases: ChangelogRelease[],
|
|
20
|
-
): { content: string; versions: string[] } => {
|
|
21
|
-
const versions: string[] = []
|
|
22
|
-
let result = content
|
|
23
|
-
|
|
24
|
-
for (const release of draftReleases) {
|
|
25
|
-
const dateTimeMatch = release.date.match(/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2})$/)
|
|
26
|
-
if (!dateTimeMatch) {
|
|
27
|
-
continue
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const [, datePart, timePart] = dateTimeMatch
|
|
31
|
-
const headingWithoutTime = `## Version ${release.version} - ${datePart}`
|
|
32
|
-
const headingWithTime = `## Version ${release.version} - ${datePart} ${timePart}`
|
|
33
|
-
|
|
34
|
-
if (result.includes(headingWithTime)) {
|
|
35
|
-
continue
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (result.includes(headingWithoutTime)) {
|
|
39
|
-
result = result.replaceAll(headingWithoutTime, headingWithTime)
|
|
40
|
-
versions.push(release.version)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return { content: result, versions }
|
|
45
|
-
}
|
|
46
|
-
|
|
47
16
|
const draft = parseUserChangelog(readMarkdown(draftPath))
|
|
48
17
|
const existingContent = readMarkdown(contentPath).trimEnd()
|
|
49
18
|
const existing = existingContent.length > 0 ? parseUserChangelog(existingContent) : []
|
|
@@ -51,34 +20,17 @@ const existing = existingContent.length > 0 ? parseUserChangelog(existingContent
|
|
|
51
20
|
const existingVersions = new Set(existing.map((release) => release.version))
|
|
52
21
|
const newReleases = draft.filter((release) => !existingVersions.has(release.version))
|
|
53
22
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (newReleases.length > 0) {
|
|
57
|
-
const newBlocks = newReleases.map((release) => serializeUserChangelogRelease(release)).join('\n\n')
|
|
58
|
-
mergedContent =
|
|
59
|
-
existingContent.length > 0 ? `${newBlocks}\n\n${existingContent}` : newBlocks
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const { content: contentWithTimestamps, versions: updatedTimestamps } = updateVersionTimestamps(
|
|
63
|
-
mergedContent,
|
|
64
|
-
draft,
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
if (newReleases.length === 0 && updatedTimestamps.length === 0) {
|
|
23
|
+
if (newReleases.length === 0) {
|
|
68
24
|
process.stdout.write('No user changelog changes to sync.\n')
|
|
69
25
|
process.exit(0)
|
|
70
26
|
}
|
|
71
27
|
|
|
72
|
-
|
|
28
|
+
const newBlocks = newReleases.map((release) => serializeUserChangelogRelease(release)).join('\n\n')
|
|
29
|
+
const mergedContent =
|
|
30
|
+
existingContent.length > 0 ? `${newBlocks}\n\n${existingContent}` : newBlocks
|
|
73
31
|
|
|
74
|
-
|
|
75
|
-
process.stdout.write(
|
|
76
|
-
`Added user changelog version(s): ${newReleases.map((release) => release.version).join(', ')}\n`,
|
|
77
|
-
)
|
|
78
|
-
}
|
|
32
|
+
writeFileSync(contentPath, `${mergedContent.trimEnd()}\n`)
|
|
79
33
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
)
|
|
84
|
-
}
|
|
34
|
+
process.stdout.write(
|
|
35
|
+
`Added user changelog version(s): ${newReleases.map((release) => release.version).join(', ')}\n`,
|
|
36
|
+
)
|