@robot-resources/cli-core 0.1.1 → 0.1.3
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/auth.mjs +9 -8
- package/package.json +12 -1
- package/python-bridge.mjs +41 -4
package/auth.mjs
CHANGED
|
@@ -219,14 +219,15 @@ export async function authenticate() {
|
|
|
219
219
|
|
|
220
220
|
console.log(`\n Auth URL: ${authUrl}\n`);
|
|
221
221
|
|
|
222
|
-
// Open browser
|
|
223
|
-
const {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
222
|
+
// Open browser (use execFile to avoid shell injection)
|
|
223
|
+
const { execFile } = await import('node:child_process');
|
|
224
|
+
if (process.platform === 'win32') {
|
|
225
|
+
// 'start' is a cmd.exe builtin, not an executable — must invoke via cmd.exe
|
|
226
|
+
execFile('cmd.exe', ['/c', 'start', '""', authUrl]);
|
|
227
|
+
} else {
|
|
228
|
+
const openCmd = process.platform === 'darwin' ? 'open' : 'xdg-open';
|
|
229
|
+
execFile(openCmd, [authUrl]);
|
|
230
|
+
}
|
|
230
231
|
|
|
231
232
|
console.log(' Waiting for GitHub authorization...\n');
|
|
232
233
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robot-resources/cli-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Shared CLI utilities — auth, config, login (internal)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|
|
@@ -21,6 +21,17 @@
|
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"vitest": "^1.2.0"
|
|
23
23
|
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/robot-resources/robot-resources.git",
|
|
27
|
+
"directory": "packages/cli-core"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://robotresources.ai",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/robot-resources/robot-resources/issues"
|
|
32
|
+
},
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"author": "Robot Resources Team",
|
|
24
35
|
"publishConfig": {
|
|
25
36
|
"access": "public"
|
|
26
37
|
},
|
package/python-bridge.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { execSync } from 'node:child_process';
|
|
1
|
+
import { execSync, spawn } from 'node:child_process';
|
|
2
2
|
import { existsSync, mkdirSync } from 'node:fs';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { join } from 'node:path';
|
|
@@ -69,6 +69,18 @@ export function ensureVenv(pythonBin) {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
// Pre-check: verify the venv module is available (missing on some Debian/Ubuntu systems)
|
|
73
|
+
try {
|
|
74
|
+
execSync(`"${pythonBin}" -c "import ensurepip; import venv"`, { stdio: 'pipe' });
|
|
75
|
+
} catch {
|
|
76
|
+
const version = execSync(`"${pythonBin}" --version`, { encoding: 'utf-8' }).trim().match(/\d+\.\d+/)?.[0] || '3.x';
|
|
77
|
+
throw new Error(
|
|
78
|
+
`Python venv module is not installed.\n` +
|
|
79
|
+
` Fix: sudo apt install python${version}-venv (Debian/Ubuntu)\n` +
|
|
80
|
+
` Then re-run: npx robot-resources`
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
72
84
|
mkdirSync(join(homedir(), '.robot-resources'), { recursive: true });
|
|
73
85
|
execSync(`"${pythonBin}" -m venv "${VENV_DIR}"`, { stdio: 'pipe' });
|
|
74
86
|
return venvPython;
|
|
@@ -76,14 +88,39 @@ export function ensureVenv(pythonBin) {
|
|
|
76
88
|
|
|
77
89
|
/**
|
|
78
90
|
* Install (or upgrade) the router Python package into the managed venv.
|
|
91
|
+
* Prints progress every 5 seconds to keep terminal sessions alive
|
|
92
|
+
* (OC session handlers reap silent processes).
|
|
79
93
|
*
|
|
80
94
|
* @param {object} [options]
|
|
81
|
-
* @param {'pipe'|'inherit'} [options.stdio='pipe'] — controls install output visibility
|
|
82
95
|
* @param {number} [options.timeout=120000] — pip install timeout in ms
|
|
83
96
|
*/
|
|
84
|
-
export function installRouter({
|
|
97
|
+
export function installRouter({ timeout = 120_000 } = {}) {
|
|
85
98
|
const pip = getVenvPip();
|
|
86
|
-
|
|
99
|
+
|
|
100
|
+
return new Promise((resolve, reject) => {
|
|
101
|
+
const proc = spawn(pip, ['install', '--upgrade', ROUTER_PACKAGE], {
|
|
102
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
103
|
+
timeout,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
process.stdout.write(' Installing dependencies...\n');
|
|
107
|
+
let seconds = 0;
|
|
108
|
+
const progress = setInterval(() => {
|
|
109
|
+
seconds += 4;
|
|
110
|
+
process.stdout.write(` Installing dependencies... ${seconds}s\n`);
|
|
111
|
+
}, 4000);
|
|
112
|
+
|
|
113
|
+
proc.on('close', (code) => {
|
|
114
|
+
clearInterval(progress);
|
|
115
|
+
if (code === 0) resolve();
|
|
116
|
+
else reject(new Error(`pip install exited with code ${code}`));
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
proc.on('error', (err) => {
|
|
120
|
+
clearInterval(progress);
|
|
121
|
+
reject(err);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
87
124
|
}
|
|
88
125
|
|
|
89
126
|
/**
|