git-daemon 0.1.10 → 0.1.11

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/README.md CHANGED
@@ -19,7 +19,9 @@ Git Daemon is a local Node.js service that exposes a small, authenticated HTTP A
19
19
  Healthchecks are user-supplied executables/scripts stored in local suites (which can be
20
20
  private repos). The daemon runs them as jobs, streams logs over SSE, and returns a
21
21
  normalized status (`na`, `failed`, `pass-partial`, `pass-full`) plus details. Suites are
22
- configured via local paths, and each check has a `healthcheck.json` manifest.
22
+ configured via local paths, and each check has a `healthcheck.json` manifest. For a
23
+ quick demo, set `healthchecks.demo: true` in config to auto-enable the bundled example
24
+ suite (when present).
23
25
 
24
26
  ## Security model (high level)
25
27
 
@@ -218,6 +220,7 @@ Key settings live in `config.json`:
218
220
  - `deps.defaultSafer`: defaults to `true` for `--ignore-scripts`
219
221
  - `jobs.maxConcurrent` and `jobs.timeoutSeconds`
220
222
  - `healthchecks.suites`: array of absolute or config-relative suite paths
223
+ - `healthchecks.demo`: enable bundled example healthchecks if present
221
224
 
222
225
  Tokens are stored (hashed) in `tokens.json`. Logs are written under the configured `logging.directory` with rotation.
223
226
 
@@ -140,6 +140,11 @@
140
140
  },
141
141
  "defaultSuiteId": {
142
142
  "type": "string"
143
+ },
144
+ "demo": {
145
+ "type": "boolean",
146
+ "default": false,
147
+ "description": "When true, auto-enables the bundled example healthchecks if present."
143
148
  }
144
149
  }
145
150
  },
package/dist/config.js CHANGED
@@ -47,6 +47,7 @@ const defaultConfig = () => ({
47
47
  },
48
48
  healthchecks: {
49
49
  suites: [],
50
+ demo: false,
50
51
  },
51
52
  logging: {
52
53
  directory: "logs",
@@ -68,7 +69,7 @@ const loadConfig = async (configDir) => {
68
69
  try {
69
70
  const raw = await fs_1.promises.readFile(configPath, "utf8");
70
71
  const data = JSON.parse(raw);
71
- return {
72
+ const merged = {
72
73
  ...(0, exports.defaultConfig)(),
73
74
  ...data,
74
75
  server: {
@@ -107,6 +108,22 @@ const loadConfig = async (configDir) => {
107
108
  entries: data.approvals?.entries ?? [],
108
109
  },
109
110
  };
111
+ if (merged.healthchecks?.demo) {
112
+ const demoSuitePath = path_1.default.resolve(__dirname, "..", "healthchecks", "example-suite");
113
+ try {
114
+ await fs_1.promises.access(demoSuitePath);
115
+ if (!merged.healthchecks.suites.includes(demoSuitePath)) {
116
+ merged.healthchecks.suites = [
117
+ ...merged.healthchecks.suites,
118
+ demoSuitePath,
119
+ ];
120
+ }
121
+ }
122
+ catch {
123
+ // Ignore missing demo suite; config can still load.
124
+ }
125
+ }
126
+ return merged;
110
127
  }
111
128
  catch (err) {
112
129
  if (err.code !== "ENOENT") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-daemon",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "main": "dist/daemon.js",
@@ -8,6 +8,8 @@
8
8
  "build": "tsc",
9
9
  "daemon": "tsx src/daemon.ts",
10
10
  "daemon:setup": "tsx src/setup.ts",
11
+ "typecheck": "tsc --noEmit",
12
+ "verify": "npm run lint && npm run typecheck && npm test",
11
13
  "test": "vitest run",
12
14
  "test:watch": "vitest",
13
15
  "test:clone": "bash scripts/test-clone.sh",
package/src/config.ts CHANGED
@@ -46,6 +46,7 @@ export const defaultConfig = (): AppConfig => ({
46
46
  },
47
47
  healthchecks: {
48
48
  suites: [],
49
+ demo: false,
49
50
  },
50
51
  logging: {
51
52
  directory: "logs",
@@ -67,7 +68,7 @@ export const loadConfig = async (configDir: string): Promise<AppConfig> => {
67
68
  try {
68
69
  const raw = await fs.readFile(configPath, "utf8");
69
70
  const data = JSON.parse(raw) as AppConfig;
70
- return {
71
+ const merged: AppConfig = {
71
72
  ...defaultConfig(),
72
73
  ...data,
73
74
  server: {
@@ -106,6 +107,28 @@ export const loadConfig = async (configDir: string): Promise<AppConfig> => {
106
107
  entries: data.approvals?.entries ?? [],
107
108
  },
108
109
  };
110
+
111
+ if (merged.healthchecks?.demo) {
112
+ const demoSuitePath = path.resolve(
113
+ __dirname,
114
+ "..",
115
+ "healthchecks",
116
+ "example-suite",
117
+ );
118
+ try {
119
+ await fs.access(demoSuitePath);
120
+ if (!merged.healthchecks.suites.includes(demoSuitePath)) {
121
+ merged.healthchecks.suites = [
122
+ ...merged.healthchecks.suites,
123
+ demoSuitePath,
124
+ ];
125
+ }
126
+ } catch {
127
+ // Ignore missing demo suite; config can still load.
128
+ }
129
+ }
130
+
131
+ return merged;
109
132
  } catch (err) {
110
133
  if ((err as NodeJS.ErrnoException).code !== "ENOENT") {
111
134
  throw err;
package/src/daemon.ts CHANGED
@@ -15,6 +15,7 @@ const start = async () => {
15
15
  port: ctx.config.server.port,
16
16
  workspaceRoot: ctx.config.workspaceRoot ?? "not configured",
17
17
  originAllowlist: ctx.config.originAllowlist,
18
+ healthchecksDemo: ctx.config.healthchecks?.demo ?? false,
18
19
  };
19
20
  ctx.logger.info(startupSummary, "Git Daemon starting");
20
21
  if (process.env.GIT_DAEMON_LOG_STDOUT !== "1") {
@@ -26,6 +27,9 @@ const start = async () => {
26
27
  console.log(
27
28
  ` allowlist: ${startupSummary.originAllowlist.join(", ") || "none"}`,
28
29
  );
30
+ if (startupSummary.healthchecksDemo) {
31
+ console.log(" healthchecks: demo mode enabled");
32
+ }
29
33
  const httpsConfig = ctx.config.server.https;
30
34
  if (httpsConfig?.enabled) {
31
35
  console.log(
package/src/types.ts CHANGED
@@ -34,6 +34,7 @@ export type AppConfig = {
34
34
  healthchecks?: {
35
35
  suites: string[];
36
36
  defaultSuiteId?: string;
37
+ demo?: boolean;
37
38
  };
38
39
  logging: {
39
40
  directory: string;