Update scripts

This commit is contained in:
freearhey 2025-02-27 20:55:39 +03:00
parent 5d52197f9c
commit 3fd1a03eea
5 changed files with 109 additions and 69 deletions

View file

@ -27,6 +27,6 @@ export class IssueData {
getArray(key: string): string[] {
const deleteSymbol = '~'
return this._data.get(key) === deleteSymbol ? [] : this._data.get(key).split(';')
return this._data.get(key) === deleteSymbol ? [] : this._data.get(key).split('\r\n')
}
}

View file

@ -9,33 +9,14 @@ const CustomOctokit = Octokit.plugin(paginateRest, restEndpointMethods)
const octokit = new CustomOctokit()
export class IssueLoader {
async load({ labels }: { labels: string[] | string }) {
labels = Array.isArray(labels) ? labels.join(',') : labels
async load(props?: { labels: string | string[] }) {
let labels = ''
if (props && props.labels) {
labels = Array.isArray(props.labels) ? props.labels.join(',') : props.labels
}
let issues: object[] = []
if (TESTING) {
switch (labels) {
case 'streams:add':
issues = (await import('../../tests/__data__/input/issues/streams_add.js')).default
break
case 'streams:edit':
issues = (await import('../../tests/__data__/input/issues/streams_edit.js')).default
break
case 'broken stream':
issues = (await import('../../tests/__data__/input/issues/broken_stream.js')).default
break
case 'streams:add,approved':
issues = (await import('../../tests/__data__/input/issues/streams_add_approved.js'))
.default
break
case 'streams:edit,approved':
issues = (await import('../../tests/__data__/input/issues/streams_edit_approved.js'))
.default
break
case 'streams:remove,approved':
issues = (await import('../../tests/__data__/input/issues/streams_remove_approved.js'))
.default
break
}
issues = (await import('../../tests/__data__/input/issues/all.js')).default
} else {
issues = await octokit.paginate(octokit.rest.issues.listForRepo, {
owner: OWNER,

View file

@ -25,11 +25,11 @@ const FIELDS = new Dictionary({
export class IssueParser {
parse(issue: { number: number; body: string; labels: { name: string }[] }): Issue {
const fields = issue.body.split('###')
const fields = typeof issue.body === 'string' ? issue.body.split('###') : []
const data = new Dictionary()
fields.forEach((field: string) => {
const parsed = field.split(/\r?\n/).filter(Boolean)
const parsed = typeof field === 'string' ? field.split(/\r?\n/).filter(Boolean) : []
let _label = parsed.shift()
_label = _label ? _label.trim() : ''
let _value = parsed.join('\r\n')