1+ import path from "path" ;
12import { Command } from "interactive-commander" ;
23import createOra from "ora" ;
34import { getSettings } from "../../utils/settings" ;
@@ -6,6 +7,7 @@ import { IIntegrationFlow } from "./flows/_base";
67import { PullRequestFlow } from "./flows/pull-request" ;
78import { InBranchFlow } from "./flows/in-branch" ;
89import { getPlatformKit } from "./platforms" ;
10+ import { getConfig } from "../../utils/config" ;
911
1012interface CIOptions {
1113 parallel ?: boolean ;
@@ -70,26 +72,54 @@ export default new Command()
7072 parseBooleanArg ,
7173 )
7274 . action ( async ( options : CIOptions ) => {
75+ const configDir = options . workingDirectory
76+ ? path . resolve ( process . cwd ( ) , options . workingDirectory )
77+ : process . cwd ( ) ;
78+ const originalCwd = process . cwd ( ) ;
79+ let config ;
80+ try {
81+ process . chdir ( configDir ) ;
82+ config = getConfig ( false ) ;
83+ } finally {
84+ process . chdir ( originalCwd ) ;
85+ }
86+
87+ const isVNext = ! ! config ?. vNext ;
88+
7389 const settings = getSettings ( options . apiKey ) ;
7490
75- if ( ! settings . auth . apiKey ) {
76- console . error ( "No API key provided" ) ;
77- return ;
78- }
91+ if ( isVNext ) {
92+ if ( ! settings . auth . vnext ?. apiKey ) {
93+ console . error (
94+ "No LINGO_API_KEY provided. vNext requires LINGO_API_KEY environment variable." ,
95+ ) ;
96+ return ;
97+ }
98+ } else {
99+ if ( ! settings . auth . apiKey ) {
100+ console . error ( "No API key provided" ) ;
101+ return ;
102+ }
79103
80- const authenticator = createAuthenticator ( {
81- apiUrl : settings . auth . apiUrl ,
82- apiKey : settings . auth . apiKey ,
83- } ) ;
84- const auth = await authenticator . whoami ( ) ;
104+ const authenticator = createAuthenticator ( {
105+ apiUrl : settings . auth . apiUrl ,
106+ apiKey : settings . auth . apiKey ,
107+ } ) ;
85108
86- if ( ! auth ) {
87- console . error ( "Not authenticated" ) ;
88- return ;
109+ const auth = await authenticator . whoami ( ) ;
110+ if ( ! auth ) {
111+ console . error ( "Not authenticated" ) ;
112+ return ;
113+ }
89114 }
90115
91116 const env = {
92- LINGODOTDEV_API_KEY : settings . auth . apiKey ,
117+ ...( settings . auth . apiKey && {
118+ LINGODOTDEV_API_KEY : settings . auth . apiKey ,
119+ } ) ,
120+ ...( settings . auth . vnext ?. apiKey && {
121+ LINGO_API_KEY : settings . auth . vnext . apiKey ,
122+ } ) ,
93123 LINGODOTDEV_PULL_REQUEST : options . pullRequest ?. toString ( ) || "false" ,
94124 ...( options . commitMessage && {
95125 LINGODOTDEV_COMMIT_MESSAGE : options . commitMessage ,
@@ -132,7 +162,7 @@ export default new Command()
132162 }
133163
134164 const hasChanges = await flow . run ( {
135- parallel : options . parallel ,
165+ parallel : isVNext || options . parallel ,
136166 } ) ;
137167 if ( ! hasChanges ) {
138168 return ;
0 commit comments