tickets
All repositories: gitoria
3.0 KB
// tools/import.hl — import AntColony ticket files into the RUNNING app, over its JSON API.//// bin/hybriel tools/import.hl (default folder: import/tickets of the app — relative paths// resolve against THIS script's folder, hence '../import/tickets')// TICKETS_IMPORT_DIR=/some/dir TICKETS_URL=http://127.0.0.1:8350 bin/hybriel tools/import.hl//// WRITES NEED A TOKEN (ticket #7): TICKETS_TOKEN = an API token (log in with ident, /you →// "Create a token"); the imported tickets are opened by that token's user.//// A ticket file is `project:` and `subject:` header lines, a blank line, the summary// (hard-wrapped lines are joined into paragraphs, blank line = new paragraph —// lib/import.hl).// Each file is POSTed to /api/tickets with `source` = its file name; the app answers a// known source with the ticket it already has (200, existed) instead of a second one// (201), so running this twice imports nothing twice. Going through the API (not the// tables) means the running server stays the only writer and open browsers see the// imported tickets arrive live.import { listDir, readFile } from 'hl:fs'import { env } from 'hl:proc'import { fetch } from 'hl:fetch'import { parse } from '../lib/import.hl'static dir = env('TICKETS_IMPORT_DIR') != null ? env('TICKETS_IMPORT_DIR') : '../import/tickets'static base = env('TICKETS_URL') != null ? env('TICKETS_URL') : 'http://127.0.0.1:8350'static token = env('TICKETS_TOKEN') != null ? env('TICKETS_TOKEN') : ''if (token == '') { console.log('import: TICKETS_TOKEN is not set — API writes need a token (log in, /you → Create a token)') }// a > b for two strings (strings order by code point, hybriel#2; still no list sort())static after = (a, b) => { return a > b }// file names, sorted, so an empty store numbers each project's tickets in file ordernames = []for (n of listDir(dir)) {name = hlTypeName(n) == 'String' ? n : n.nameif (name.endsWith('.md')) { names.push(name) }}let i = 1while (i < names.length) {cur = names[i]let j = i - 1while (j >= 0 && after(names[j], cur)) {names[j + 1] = names[j]j = j - 1}names[j + 1] = curi = i + 1}created = 0existed = 0failed = 0for (name of names) {t = parse(readFile(dir + '/' + name))if (t.error != null) {console.log('SKIP ' + name + ': ' + t.error)failed = failed + 1} else {res = fetch(base + '/api/tickets', { method = 'POST' headers = { authorization = 'Bearer ' + token } json = { project = t.project subject = t.subject summary = t.summary source = name } })if (res.status == 201) {created = created + 1tk = res.json().ticketconsole.log('NEW ' + name + ' → ' + tk.project + ' ' + tk.ref)} else if (res.status == 200) {existed = existed + 1tk = res.json().ticketconsole.log('HAVE ' + name + ' = ' + tk.project + ' ' + tk.ref)} else {failed = failed + 1console.log('FAIL ' + name + ': ' + res.status + ' ' + res.text())}}}console.log('import: ' + created + ' new, ' + existed + ' already there, ' + failed + ' failed (' + dir + ' → ' + base + ')')
Branches
Latest commits
- b03f11b6Tickets conductor: CONDUCTOR.md (project part), short STATUS.md, old STATUS to archive/2026-10-31mre
- a4123831tickets#42: the /connect and /login/callback error pages are app pages: the function routes redirect to /connect/failed/<code> and /login/failed/<code> (components/problem.hl, sentences in lib/problems.hl), htmlPage and its hand-written stylesheet are gone; gate tests/error-pages.mjsmre
- cefc7b4atickets: a startup error prints its message before exit 1 (hybriel#247)mre
- 99bd6570tickets: lib/migrate.hl writes no table of another topic any more: projects.hl rewriteSlug / addProjectNamed / hasMembers, tickets.hl moveToProject / ticketRecords / ticketRecordsOf, events.hl renameStates / eventRecords / eventRecordsOf; the migration calls them (tickets#47)mre
- b57161e3tickets: the markup names its own rules (Style.pMessage, Style.olTickets, ...) instead of hand-written class strings that copy a stylesheet rule; the shared bodies sit in lib/looks.hl (tickets#38)mre
- f767b24dtickets: 111 needless let became plain declarations (3 in ticket.hl, ticket_list.hl, comments.hl and 108 never-reassigned, not captured loop-body ones); the 212 really reassigned lets stay (tickets#44)mre
- 16c0d3b5tickets: the modal window is phone first: the full-screen sheet is the base rule, the centred window sits in the min-width 60rem block (tickets#39)mre
- 090ee809tickets: every component's styles in its own nested Style {} block; styles.hl keeps only the theme inherit, the accent and the site-wide rules (tickets#36)mre
- d395763ftickets: ident-access gate ports 8769/8768 (8797 is taken on loreana)mre
- afb9a403tickets: an ident access key (Authorization: Bearer idt_…) works in the API (ident#27 app side): lib/ident-access.hl copied from components, read keys GET only, ident down 503; gate tests/ident-access-tickets.mjsmre
- 48c1ba79tickets: md-paste-files gate with the file manager casesmre
- f04afc43tickets: MdEditor from components 59704ce (a file manager copy still attaches, pipe rows, tickets#49)mre
- 06599fa0tickets: MdEditor from components b0f1ec2 (a clipboard with text always pastes the text, tickets#49); real Ctrl+V gatemre
- 2e1b116ftickets: re-vendor Hybriel master acaceaf3 (framework ec8d6c1d): plugins/web patch queue while a page is built, anonymous session cookies refresh; gate waits for the comment editors to draw (W174) and clicks the form editor when it stands still; security gate: main's code runs on its own binary, lazy-session cookie checksmre
- 361bc0fetickets: re-vendor Hybriel 7a684920 (WIP, not deployed); on Error exits 1 at startup; migrate passes its log by reference; gate checks follow lazy sessions and the 413 refusalmre
- 8a69999cident#28: /login/callback never signs out the session it finds; a valid code puts the user on the same sessionmre
- 337e9b21tickets#37: a comment's files are open to everyone who can read the commentmre
- 1800600ftickets: write the standby service out in full so the boot gate can read the main servicemre
- 8179d287tickets: standby service on its port plus 10 and a deploy that hands over through it without a gapmre
- 0398145ctickets: the table grid rule is marked functional for check-thememre