Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: 22
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6
with:
bun-version: 1.3.13
- run: bun install --frozen-lockfile
- run: bun run typecheck
- run: bun run lint
- run: bun run test
env:
GITDOG_TEST_DIR: ${{ runner.temp }}/gitdog-tests
- run: npm pack --dry-run
- run: bun audit --production
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
bun.lock
359 changes: 359 additions & 0 deletions README.md

Large diffs are not rendered by default.

87 changes: 87 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "gitdog",
"version": "0.1.0",
"description": "The official Gitdog CLI: manage projects, automation, tickets and teams from your terminal",
"type": "module",
"bin": {
"gitdog": "dist/cli.js"
},
"files": [
"dist",
"README.md"
],
"engines": {
"node": ">=22.14.0"
},
"packageManager": "bun@1.3.13",
"repository": {
"type": "git",
"url": "git+https://github.com/hyodotdev/gitdog-cli.git"
},
"homepage": "https://gitdog.dev",
"bugs": {
"url": "https://github.com/hyodotdev/gitdog-cli/issues"
},
"license": "UNLICENSED",
"scripts": {
"build": "tsc -p tsconfig.json",
"typecheck": "tsc --noEmit",
"lint": "prettier --check .",
"format": "prettier --write .",
"test": "bun run build && node --test test/*.test.mjs",
"test:dev": "bun run build && node scripts/test-dev.mjs",
"dev": "bun src/cli.ts",
"prepack": "bun run build"
},
"dependencies": {
"commander": "^15.0.0",
"convex": "^1.43.0"
},
"devDependencies": {
"@types/node": "^22.14.0",
"prettier": "^3.9.0",
"typescript": "~6.0.3"
}
}
104 changes: 104 additions & 0 deletions scripts/sync-api.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import ts from "typescript";
import { readFile, readdir, writeFile } from "node:fs/promises";
import { resolve, relative } from "node:path";

const backend = resolve(
process.argv.find((arg) => arg.startsWith("--backend="))?.slice(10) ??
"../gitdog.dev/convex",
);
const entries = [];
async function visit(directory) {
for (const item of await readdir(directory, { withFileTypes: true })) {
const path = resolve(directory, item.name);
if (item.name.startsWith("_") || item.name === "node_modules") continue;
if (item.isDirectory()) {
await visit(path);
continue;
}
if (!item.name.endsWith(".ts") || item.name.endsWith(".d.ts")) continue;
const source = ts.createSourceFile(
path,
await readFile(path, "utf8"),
ts.ScriptTarget.Latest,
true,
);
for (const node of source.statements) {
if (
!ts.isVariableStatement(node) ||
!node.modifiers?.some(
(modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword,
)
)
continue;
for (const declaration of node.declarationList.declarations) {
const call = declaration.initializer;
if (
!ts.isIdentifier(declaration.name) ||
!call ||
!ts.isCallExpression(call) ||
!ts.isIdentifier(call.expression)
)
continue;
const kind = call.expression.text;
if (!["query", "mutation", "action"].includes(kind)) continue;
const object = call.arguments[0];
if (!object || !ts.isObjectLiteralExpression(object))
throw new Error(`Unsupported public definition in ${path}`);
const args = object.properties.find(
(property) => property.name?.getText(source) === "args",
);
const definitions = Object.fromEntries(
source.statements
.filter(ts.isVariableStatement)
.flatMap((item) =>
item.declarationList.declarations
.filter(
(entry) => ts.isIdentifier(entry.name) && entry.initializer,
)
.map((entry) => [
entry.name.text,
entry.initializer.getText(source),
]),
),
);
let validator =
args && ts.isPropertyAssignment(args)
? args.initializer.getText(source)
: "{}";
for (const [name, value] of Object.entries(definitions)) {
if (name.endsWith("Validator"))
validator = validator.replaceAll(
new RegExp(`\\b${name}\\b`, "g"),
value,
);
}
entries.push({
path: `${relative(backend, path).replaceAll("\\", "/").slice(0, -3)}:${declaration.name.text}`,
kind,
args: validator,
});
}
}
}
}
await visit(backend);
entries.sort((left, right) => left.path.localeCompare(right.path));
const content = JSON.stringify(entries, null, 2) + "\n";
const target = new URL("../src/api-catalog.json", import.meta.url);
if (process.argv.includes("--check")) {
if (
JSON.stringify(JSON.parse(await readFile(target, "utf8"))) !==
JSON.stringify(entries)
)
throw new Error(
"Public API catalog is stale. Run bun scripts/sync-api.mjs.",
);
console.log(
`Public API catalog matches all ${entries.length} exported functions.`,
);
} else {
await writeFile(target, content);
console.log(
`Recorded ${entries.length} public functions. Internal functions are excluded.`,
);
}
Loading
Loading