orquesta-cli 0.2.25 → 0.2.26
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/dist/cli.js
CHANGED
|
@@ -63,12 +63,17 @@ program
|
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
if (options.init) {
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
await configManager.initialize();
|
|
67
|
+
const saved = configManager.getOrquestaConfig();
|
|
68
|
+
const token = options.token || saved?.token;
|
|
69
|
+
if (!token) {
|
|
70
|
+
console.error(chalk.red('Error: not connected to Orquesta.'));
|
|
71
|
+
console.error('Run ' + chalk.cyan('orquesta --login') + ' first, or pass ' + chalk.cyan('orquesta --init --token oat_…') + '.');
|
|
68
72
|
process.exit(1);
|
|
69
73
|
}
|
|
70
74
|
const { initHooks } = await import('./orquesta/hook-init.js');
|
|
71
|
-
|
|
75
|
+
const preferredProjectId = options.token ? undefined : saved?.projectId;
|
|
76
|
+
await initHooks(token, undefined, preferredProjectId);
|
|
72
77
|
return;
|
|
73
78
|
}
|
|
74
79
|
await configManager.initialize();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function initHooks(token: string, apiUrl?: string): Promise<void>;
|
|
1
|
+
export declare function initHooks(token: string, apiUrl?: string, preferredProjectId?: string): Promise<void>;
|
|
2
2
|
export declare function writeHookFiles(opts: {
|
|
3
3
|
projectId: string;
|
|
4
4
|
token: string;
|
|
@@ -31,7 +31,7 @@ function resolveAgentBin() {
|
|
|
31
31
|
console.warn(' \x1b[33m npm install -g orquesta-agent\x1b[0m\n');
|
|
32
32
|
return 'orquesta-agent';
|
|
33
33
|
}
|
|
34
|
-
export async function initHooks(token, apiUrl = 'https://getorquesta.com') {
|
|
34
|
+
export async function initHooks(token, apiUrl = 'https://getorquesta.com', preferredProjectId) {
|
|
35
35
|
console.log('\n Initializing Orquesta hook integration...\n');
|
|
36
36
|
const agentBin = resolveAgentBin();
|
|
37
37
|
console.log(' Validating token...');
|
|
@@ -46,14 +46,15 @@ export async function initHooks(token, apiUrl = 'https://getorquesta.com') {
|
|
|
46
46
|
console.error(` Error: Invalid token`);
|
|
47
47
|
process.exit(1);
|
|
48
48
|
}
|
|
49
|
-
const
|
|
50
|
-
|
|
49
|
+
const chosen = (preferredProjectId && data.projects?.find((p) => p.id === preferredProjectId)) ||
|
|
50
|
+
data.projects?.[0];
|
|
51
|
+
if (!chosen) {
|
|
51
52
|
console.error(' Error: No projects found for this token');
|
|
52
53
|
process.exit(1);
|
|
53
54
|
throw new Error();
|
|
54
55
|
}
|
|
55
|
-
projectId =
|
|
56
|
-
projectName =
|
|
56
|
+
projectId = chosen.id;
|
|
57
|
+
projectName = chosen.name;
|
|
57
58
|
console.log(` Connected to: ${projectName}\n`);
|
|
58
59
|
}
|
|
59
60
|
catch (err) {
|