@miketromba/issy-core 0.7.3 → 0.8.1
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/package.json +1 -1
- package/src/lib/index.ts +2 -0
- package/src/lib/issues.ts +40 -8
package/package.json
CHANGED
package/src/lib/index.ts
CHANGED
package/src/lib/issues.ts
CHANGED
|
@@ -189,7 +189,8 @@ export function parseFrontmatter(content: string): {
|
|
|
189
189
|
const colonIdx = line.indexOf(':')
|
|
190
190
|
if (colonIdx > 0) {
|
|
191
191
|
const key = line.slice(0, colonIdx).trim()
|
|
192
|
-
const
|
|
192
|
+
const rawValue = line.slice(colonIdx + 1).trim()
|
|
193
|
+
const value = key === 'title' ? yamlUnquote(rawValue) : rawValue
|
|
193
194
|
;(frontmatter as Record<string, string>)[key] = value
|
|
194
195
|
}
|
|
195
196
|
}
|
|
@@ -197,9 +198,32 @@ export function parseFrontmatter(content: string): {
|
|
|
197
198
|
return { frontmatter, body }
|
|
198
199
|
}
|
|
199
200
|
|
|
201
|
+
function yamlQuote(value: string): string {
|
|
202
|
+
// biome-ignore lint/complexity/noUselessEscapeInRegex: \[ is needed inside the character class for correct matching
|
|
203
|
+
if (/[:#\[\]{}&*!|>'"%@`,\n]/.test(value) || value !== value.trim()) {
|
|
204
|
+
const escaped = value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')
|
|
205
|
+
return `"${escaped}"`
|
|
206
|
+
}
|
|
207
|
+
return value
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function yamlUnquote(value: string): string {
|
|
211
|
+
if (
|
|
212
|
+
(value.startsWith('"') && value.endsWith('"')) ||
|
|
213
|
+
(value.startsWith("'") && value.endsWith("'"))
|
|
214
|
+
) {
|
|
215
|
+
const inner = value.slice(1, -1)
|
|
216
|
+
if (value.startsWith('"')) {
|
|
217
|
+
return inner.replace(/\\"/g, '"').replace(/\\\\/g, '\\')
|
|
218
|
+
}
|
|
219
|
+
return inner
|
|
220
|
+
}
|
|
221
|
+
return value
|
|
222
|
+
}
|
|
223
|
+
|
|
200
224
|
export function generateFrontmatter(data: IssueFrontmatter): string {
|
|
201
225
|
const lines = ['---']
|
|
202
|
-
lines.push(`title: ${data.title}`)
|
|
226
|
+
lines.push(`title: ${yamlQuote(data.title)}`)
|
|
203
227
|
lines.push(`priority: ${data.priority}`)
|
|
204
228
|
if (data.scope) {
|
|
205
229
|
lines.push(`scope: ${data.scope}`)
|
|
@@ -510,18 +534,26 @@ export async function deleteIssue(id: string): Promise<void> {
|
|
|
510
534
|
|
|
511
535
|
// --- Hooks ---
|
|
512
536
|
|
|
513
|
-
|
|
514
|
-
* Read the on_close.md hook content if it exists.
|
|
515
|
-
*/
|
|
516
|
-
export async function getOnCloseContent(): Promise<string | null> {
|
|
537
|
+
async function readHookFile(filename: string): Promise<string | null> {
|
|
517
538
|
try {
|
|
518
|
-
|
|
519
|
-
return await readFile(onClosePath, 'utf-8')
|
|
539
|
+
return await readFile(join(getIssyDir(), filename), 'utf-8')
|
|
520
540
|
} catch {
|
|
521
541
|
return null
|
|
522
542
|
}
|
|
523
543
|
}
|
|
524
544
|
|
|
545
|
+
export async function getOnCloseContent(): Promise<string | null> {
|
|
546
|
+
return readHookFile('on_close.md')
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
export async function getOnCreateContent(): Promise<string | null> {
|
|
550
|
+
return readHookFile('on_create.md')
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
export async function getOnUpdateContent(): Promise<string | null> {
|
|
554
|
+
return readHookFile('on_update.md')
|
|
555
|
+
}
|
|
556
|
+
|
|
525
557
|
// --- Next issue ---
|
|
526
558
|
|
|
527
559
|
/**
|