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