aicp-tracker 1.1.6 → 1.1.7
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/bin/setup.js +8 -0
- package/package.json +1 -1
- package/src/daemon.js +4 -8
package/bin/setup.js
CHANGED
|
@@ -9,6 +9,14 @@ const path = require('path');
|
|
|
9
9
|
// Skip if already fully configured (upgrade path — no prompts needed)
|
|
10
10
|
const isPostinstall = process.env.npm_lifecycle_event === 'postinstall';
|
|
11
11
|
if (isPostinstall) {
|
|
12
|
+
// Always record which project this package was installed into.
|
|
13
|
+
// process.cwd() during postinstall is the project root — the only reliable moment we know it.
|
|
14
|
+
try {
|
|
15
|
+
const config = require('../src/config');
|
|
16
|
+
const existing = config.load() || {};
|
|
17
|
+
config.save({ ...existing, projectPath: process.cwd() });
|
|
18
|
+
} catch {}
|
|
19
|
+
|
|
12
20
|
let existing = null;
|
|
13
21
|
try { existing = require('../src/config').load(); } catch {}
|
|
14
22
|
if (existing?.apiKey && existing?.vcsUrl) process.exit(0);
|
package/package.json
CHANGED
package/src/daemon.js
CHANGED
|
@@ -11,17 +11,13 @@ const { CONFIG_DIR } = require('./config');
|
|
|
11
11
|
|
|
12
12
|
const PID_FILE = path.join(CONFIG_DIR, 'daemon.pid');
|
|
13
13
|
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
// package.json that isn't ours (guards against global/npx installs).
|
|
14
|
+
// projectPath is saved during `npm install` (postinstall) when process.cwd()
|
|
15
|
+
// is reliably the host project root. Falls back to cwd if config is missing.
|
|
17
16
|
function detectProjectPath() {
|
|
18
|
-
const candidate = path.resolve(__dirname, '..', '..', '..');
|
|
19
|
-
const hostPkg = path.join(candidate, 'package.json');
|
|
20
17
|
try {
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
18
|
+
const cfg = require('./config').load();
|
|
19
|
+
if (cfg?.projectPath) return cfg.projectPath;
|
|
23
20
|
} catch {}
|
|
24
|
-
// Global install or npx — fall back to cwd at start time
|
|
25
21
|
return process.cwd();
|
|
26
22
|
}
|
|
27
23
|
|