@vibescore/tracker 0.0.5 → 0.0.6
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/package.json +1 -1
- package/src/commands/init.js +22 -1
package/package.json
CHANGED
package/src/commands/init.js
CHANGED
|
@@ -165,6 +165,7 @@ const trackerDir = ${JSON.stringify(trackerDir)};
|
|
|
165
165
|
const signalPath = ${JSON.stringify(queueSignalPath)};
|
|
166
166
|
const originalPath = ${JSON.stringify(originalPath)};
|
|
167
167
|
const trackerBinPath = ${JSON.stringify(trackerBinPath)};
|
|
168
|
+
const depsMarkerPath = path.join(trackerDir, 'app', 'node_modules', '@insforge', 'sdk', 'package.json');
|
|
168
169
|
const fallbackPkg = ${JSON.stringify(fallbackPkg)};
|
|
169
170
|
|
|
170
171
|
try {
|
|
@@ -180,7 +181,9 @@ try {
|
|
|
180
181
|
try { last = Number(fs.readFileSync(throttlePath, 'utf8')) || 0; } catch (_) {}
|
|
181
182
|
if (now - last > 20_000) {
|
|
182
183
|
try { fs.writeFileSync(throttlePath, String(now), 'utf8'); } catch (_) {}
|
|
183
|
-
|
|
184
|
+
const hasLocalRuntime = fs.existsSync(trackerBinPath);
|
|
185
|
+
const hasLocalDeps = fs.existsSync(depsMarkerPath);
|
|
186
|
+
if (hasLocalRuntime && hasLocalDeps) {
|
|
184
187
|
spawnDetached([process.execPath, trackerBinPath, 'sync', '--auto', '--from-notify']);
|
|
185
188
|
} else {
|
|
186
189
|
spawnDetached(['npx', '--yes', fallbackPkg, 'sync', '--auto', '--from-notify']);
|
|
@@ -250,10 +253,12 @@ async function installLocalTrackerApp({ appDir }) {
|
|
|
250
253
|
const packageRoot = path.resolve(__dirname, '../..');
|
|
251
254
|
const srcFrom = path.join(packageRoot, 'src');
|
|
252
255
|
const binFrom = path.join(packageRoot, 'bin', 'tracker.js');
|
|
256
|
+
const nodeModulesFrom = path.join(packageRoot, 'node_modules');
|
|
253
257
|
|
|
254
258
|
const srcTo = path.join(appDir, 'src');
|
|
255
259
|
const binToDir = path.join(appDir, 'bin');
|
|
256
260
|
const binTo = path.join(binToDir, 'tracker.js');
|
|
261
|
+
const nodeModulesTo = path.join(appDir, 'node_modules');
|
|
257
262
|
|
|
258
263
|
await fs.rm(appDir, { recursive: true, force: true }).catch(() => {});
|
|
259
264
|
await ensureDir(appDir);
|
|
@@ -261,4 +266,20 @@ async function installLocalTrackerApp({ appDir }) {
|
|
|
261
266
|
await ensureDir(binToDir);
|
|
262
267
|
await fs.copyFile(binFrom, binTo);
|
|
263
268
|
await fs.chmod(binTo, 0o755).catch(() => {});
|
|
269
|
+
await copyRuntimeDependencies({ from: nodeModulesFrom, to: nodeModulesTo });
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
async function copyRuntimeDependencies({ from, to }) {
|
|
273
|
+
try {
|
|
274
|
+
const st = await fs.stat(from);
|
|
275
|
+
if (!st.isDirectory()) return;
|
|
276
|
+
} catch (_e) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
try {
|
|
281
|
+
await fs.cp(from, to, { recursive: true });
|
|
282
|
+
} catch (_e) {
|
|
283
|
+
// Best-effort: missing dependencies will fall back to npx at notify time.
|
|
284
|
+
}
|
|
264
285
|
}
|