@andrian.yablonskyy/thub-agent 1.0.3 → 1.0.4

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
@@ -16,6 +16,8 @@ npx -y @andrian.yablonskyy/thub-agent run --type sw --image "$IMAGE_URL" --tests
16
16
 
17
17
  Read from flags, then environment (`THUB_URL`, `THUB_TOKEN`, `THUB_GROUP`, `THUB_USER`), then `~/.config/thub/agent.json`, then a bundled default. `url`/`token` are required by the time a command actually talks to the Coordinator; `group`/`user` are optional everywhere.
18
18
 
19
+ `npm install -g` creates `~/.config/thub/agent.json` for you (blank `url`/`token`, so nothing works until you set them) if it doesn't already exist — a re-install never overwrites it. Fill it in with `thub config set`:
20
+
19
21
  ```bash
20
22
  thub config set url https://thub.example.com
21
23
  thub config set token agt_...
package/config.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "url": "http://localhost:8000",
3
- "token": "agt_0CckgVh8wCMJpNkNpS7EBBeYJ8RCQ9LFIKUCYmZJ8oY",
3
+ "token": "",
4
4
  "group": "",
5
5
  "user": ""
6
6
  }
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@andrian.yablonskyy/thub-agent",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "TestHub Agent CLI — the single entry point CI/CD and developers use to submit and follow test jobs",
5
5
  "bin": {
6
6
  "thub": "./src/cli.js"
7
7
  },
8
8
  "main": "src/cli.js",
9
9
  "scripts": {
10
+ "postinstall": "node scripts/install-default-config.js",
10
11
  "lint": "eslint .",
11
12
  "lint:fix": "eslint . --fix"
12
13
  },
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @file scripts/install-default-config.js
3
+ * @description npm postinstall: creates ~/.config/thub/agent.json on a real global install, if it
4
+ * doesn't already exist, so `npm install -g` leaves a real, editable config file at
5
+ * the path this package actually reads from — not just an in-package fallback (README §7)
6
+ *
7
+ * @author Andrian Yablonskyy
8
+ * @copyright Copyright (c) 2026 Andrian Yablonskyy. All rights reserved.
9
+ *
10
+ * This file is part of TestHub and is proprietary and confidential.
11
+ * Unauthorized copying, modification, distribution, or use of this file,
12
+ * via any medium, is strictly prohibited without prior written permission
13
+ * from AdSystem.PRO.
14
+ */
15
+
16
+ 'use strict';
17
+
18
+ const fs = require('node:fs'),
19
+ os = require('node:os'),
20
+ path = require('node:path'),
21
+
22
+ CONFIG_PATH = path.join(os.homedir(), '.config', 'thub', 'agent.json'),
23
+
24
+ // Deliberately not a copy of the bundled config.json (which points at
25
+ // http://localhost:8000 for zero-setup `npm run agent` in the monorepo)
26
+ // — url/token are blank so a real install fails loudly with the usual
27
+ // "Missing coordinator URL or token" error until you actually set them,
28
+ // rather than silently looking configured.
29
+ DEFAULT_CONTENT = {
30
+ url: '',
31
+ token: '',
32
+ group: '',
33
+ user: ''
34
+ };
35
+
36
+ // npm only sets this for an actual `npm install -g` — absent for a plain
37
+ // local/workspace install (e.g. this monorepo's own `npm install`).
38
+ function isGlobalInstall(){
39
+ return process.env.npm_config_global === 'true';
40
+ }
41
+
42
+ // Best-effort and never fails the `npm install` itself. Never overwrites
43
+ // an existing file — a re-install/upgrade must not clobber whatever the
44
+ // user already configured.
45
+ function main(){
46
+ if (!isGlobalInstall() || fs.existsSync(CONFIG_PATH)){
47
+ return;
48
+ }
49
+ try {
50
+ fs.mkdirSync(path.dirname(CONFIG_PATH), { recursive: true });
51
+ fs.writeFileSync(CONFIG_PATH, JSON.stringify(DEFAULT_CONTENT, null, 2) + '\n', { mode: 0o600 });
52
+ console.log(`thub: created ${CONFIG_PATH} — set it with 'thub config set url <url>' / 'thub config set token <token>'`);
53
+ }
54
+ catch (err){
55
+ console.warn(`thub: could not create ${CONFIG_PATH} automatically (${err.message}).`);
56
+ }
57
+ }
58
+
59
+ main();