The repository was a bare Nova scaffold. This builds it out to match the
capabilities of the official Gitea VS Code extension.
Sidebar sections:
- Current Branch: pull requests and workflow runs for the checked-out
branch, with a current/all/pinned branch filter
- Workflows: runs grouped by workflow file, expanding into jobs, steps,
and artifacts
- Pull Requests: open pull requests across repositories, expanding into
reviews, review comments, and changed files
- Settings: per-instance connection state, plus repository Actions
secrets and variables
Commands cover run control (re-run, re-run failed jobs, re-run a job,
cancel), job logs, artifact download/reveal/open, pull request overview,
diff, checkout, creation, merge and close, the full review cycle, and
secret and variable management. Multiple instances are supported, routed
by git remote host, with tokens held per instance in the Keychain.
Nova exposes no webview, diff editor, editor decorations, or extension
status bar, so four features are shaped differently from the VS Code
original: the pull request timeline renders as Markdown, diffs open as
unified .diff documents, review comments are published through an
IssueCollection so they appear in the gutter and the Issues sidebar, and
a failed run posts a notification. OAuth and insecureSkipVerify have no
Nova equivalent and are omitted. README.md records all of this.
Endpoints were taken from Gitea's published swagger.v1.json. Servers
predating the workflow runs API fall back to /actions/tasks.
Tests/ runs the extension's real code under Node against a stubbed Nova
runtime and a canned Gitea instance: 88 checks, no install step and no
network. Images are generated by Tools/make-icons.py.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MQuusXgZC2dzwpJJ1qhtti
159 lines
6.1 KiB
JavaScript
159 lines
6.1 KiB
JavaScript
// Minimal stand-in for Nova's extension runtime, enough to exercise the
|
|
// extension's logic under plain Node.
|
|
const path = require("node:path");
|
|
const fs = require("node:fs");
|
|
const os = require("node:os");
|
|
|
|
const EXTENSION_ROOT = path.resolve(__dirname, "..");
|
|
|
|
const configStore = new Map();
|
|
const workspaceStore = new Map();
|
|
|
|
function makeConfig(store) {
|
|
return {
|
|
get(key) { return store.has(key) ? store.get(key) : null; },
|
|
set(key, value) { store.set(key, value); },
|
|
remove(key) { store.delete(key); },
|
|
onDidChange() { return { dispose() {} }; },
|
|
observe() { return { dispose() {} }; },
|
|
};
|
|
}
|
|
|
|
global.TreeItemCollapsibleState = { None: 0, Collapsed: 1, Expanded: 2 };
|
|
global.TreeItem = class TreeItem {
|
|
constructor(name, state) { this.name = name; this.collapsibleState = state; }
|
|
};
|
|
global.IssueSeverity = { Error: 0, Warning: 1, Hint: 2, Info: 3 };
|
|
global.Issue = class Issue {};
|
|
global.IssueCollection = class IssueCollection {
|
|
constructor(name) { this.name = name; this.map = new Map(); }
|
|
set(uri, issues) { this.map.set(uri, issues); }
|
|
get(uri) { return this.map.get(uri); }
|
|
has(uri) { return this.map.has(uri); }
|
|
remove(uri) { this.map.delete(uri); }
|
|
clear() { this.map.clear(); }
|
|
dispose() { this.map.clear(); }
|
|
};
|
|
global.Range = class Range {
|
|
constructor(start, end) { this.start = start; this.end = end; }
|
|
};
|
|
global.NotificationRequest = class NotificationRequest {
|
|
constructor(id) { this.identifier = id; }
|
|
};
|
|
global.Process = class Process {
|
|
constructor(command, options) { this.command = command; this.options = options; }
|
|
onStdout(cb) { this._out = cb; }
|
|
onStderr(cb) { this._err = cb; }
|
|
onDidExit(cb) { this._exit = cb; }
|
|
start() {
|
|
const { spawnSync } = require("node:child_process");
|
|
const args = this.options.args || [];
|
|
const result = spawnSync(this.command, args, { cwd: this.options.cwd, encoding: "utf-8" });
|
|
if (result.stdout && this._out) this._out(result.stdout);
|
|
if (result.stderr && this._err) this._err(result.stderr);
|
|
setImmediate(() => this._exit(result.status === null ? -1 : result.status));
|
|
}
|
|
};
|
|
|
|
const commands = new Map();
|
|
const treeViews = [];
|
|
|
|
global.TreeView = class TreeView {
|
|
constructor(id, options) {
|
|
this.id = id;
|
|
this.dataProvider = options.dataProvider;
|
|
this.visible = true;
|
|
this.selection = [];
|
|
treeViews.push(this);
|
|
}
|
|
reload() { return Promise.resolve(); }
|
|
dispose() {}
|
|
};
|
|
|
|
const keychain = new Map();
|
|
|
|
global.nova = {
|
|
version: [11, 0, 0],
|
|
versionString: "11.0",
|
|
inDevMode: () => true,
|
|
extension: { path: EXTENSION_ROOT },
|
|
config: makeConfig(configStore),
|
|
clipboard: { writeText(text) { global.__clipboard = text; } },
|
|
credentials: {
|
|
getPassword(service, user) { return keychain.get(`${service}:${user}`) ?? null; },
|
|
setPassword(service, user, password) { keychain.set(`${service}:${user}`, password); },
|
|
removePassword(service, user) { keychain.delete(`${service}:${user}`); },
|
|
},
|
|
commands: {
|
|
register(name, handler) {
|
|
if (commands.has(name)) throw new Error(`duplicate command: ${name}`);
|
|
commands.set(name, handler);
|
|
return { dispose() {} };
|
|
},
|
|
invoke(name, ...args) {
|
|
const handler = commands.get(name);
|
|
if (!handler) return Promise.reject(new Error(`no such command: ${name}`));
|
|
return Promise.resolve(handler(...args));
|
|
},
|
|
},
|
|
subscriptions: { add() {}, remove() {} },
|
|
openConfig() {}, openURL(url) { global.__openedUrl = url; }, beep() {},
|
|
path: {
|
|
join: (...parts) => path.join(...parts),
|
|
dirname: (p) => path.dirname(p),
|
|
basename: (p) => path.basename(p),
|
|
normalize: (p) => path.normalize(p),
|
|
isAbsolute: (p) => path.isAbsolute(p),
|
|
expanduser: (p) => p.replace(/^~/, os.homedir()),
|
|
split: (p) => p.split("/").filter(Boolean),
|
|
splitext: (p) => [p.slice(0, p.lastIndexOf(".")), p.slice(p.lastIndexOf("."))],
|
|
},
|
|
fs: {
|
|
F_OK: 0, R_OK: 4, W_OK: 2, X_OK: 1,
|
|
access(p) { return fs.existsSync(p); },
|
|
stat(p) {
|
|
if (!fs.existsSync(p)) return null;
|
|
const s = fs.statSync(p);
|
|
return { size: s.size, isFile: () => s.isFile(), isDirectory: () => s.isDirectory() };
|
|
},
|
|
listdir(p) { return fs.readdirSync(p); },
|
|
mkdir(p) { fs.mkdirSync(p); },
|
|
remove(p) { fs.unlinkSync(p); },
|
|
reveal(p) { global.__revealed = p; },
|
|
open(p, mode) {
|
|
const binary = mode.includes("b");
|
|
const chunks = [];
|
|
return {
|
|
write(data) { chunks.push(binary ? Buffer.from(data) : Buffer.from(String(data), "utf-8")); },
|
|
close() { fs.writeFileSync(p, Buffer.concat(chunks)); },
|
|
};
|
|
},
|
|
},
|
|
workspace: {
|
|
path: null,
|
|
config: makeConfig(workspaceStore),
|
|
activeTextEditor: null,
|
|
textEditors: [],
|
|
openFile(p, options) { global.__opened = { path: p, options }; return Promise.resolve({}); },
|
|
openNewTextDocument(options) { global.__opened = { untitled: options }; return Promise.resolve({}); },
|
|
showInformativeMessage(m) { global.__messages.push(["info", m]); },
|
|
showWarningMessage(m) { global.__messages.push(["warn", m]); },
|
|
showErrorMessage(m) { global.__messages.push(["error", m]); },
|
|
showActionPanel(m, o, cb) { global.__messages.push(["action", m]); cb(global.__actionAnswer ?? null); },
|
|
showInputPanel(m, o, cb) { global.__messages.push(["input", m]); cb(global.__inputAnswer ?? null); },
|
|
showInputPalette(m, o, cb) { cb(global.__inputAnswer ?? null); },
|
|
showChoicePalette(items, o, cb) {
|
|
const i = global.__choiceIndex ?? 0;
|
|
cb(items[i] ?? null, items[i] === undefined ? null : i);
|
|
},
|
|
},
|
|
notifications: { add() { return Promise.resolve({ actionIdx: 2 }); } },
|
|
};
|
|
|
|
global.__messages = [];
|
|
global.__commands = commands;
|
|
global.__treeViews = treeViews;
|
|
global.__keychain = keychain;
|
|
|
|
module.exports = { EXTENSION_ROOT };
|