@@ -4,34 +4,28 @@ import Project from '@openfn/project';
44import { DeployConfig , deployProject } from '@openfn/deploy' ;
55import type { Logger } from '../util/logger' ;
66import { Opts } from '../options' ;
7+ import { loadAppAuthConfig } from '../projects/util' ;
78
89export type DeployOptionsBeta = Required <
910 Pick <
1011 Opts ,
11- 'beta' | 'command' | 'log' | 'logJson' | 'apiKey' | 'endpoint' | 'path'
12+ | 'beta'
13+ | 'command'
14+ | 'log'
15+ | 'logJson'
16+ | 'apiKey'
17+ | 'endpoint'
18+ | 'path'
19+ | 'workspace'
1220 >
1321> ;
1422
1523export async function handler ( options : DeployOptionsBeta , logger : Logger ) {
16- const { OPENFN_API_KEY } = process . env ;
17-
18- const { endpoint } = options ;
19-
20- const config : Partial < DeployConfig > = {
21- apiKey : options . apiKey ,
22- } ;
23-
24- if ( ! options . apiKey && OPENFN_API_KEY ) {
25- logger . info ( 'Using OPENFN_API_KEY environment variable' ) ;
26- config . apiKey = OPENFN_API_KEY ;
27- }
24+ const config = loadAppAuthConfig ( options , logger ) ;
2825
2926 // TMP use options.path to set the directory for now
3027 // We'll need to manage this a bit better
31- const project = await Project . from ( 'fs' , { root : options . path || '.' } ) ;
32- // Why is there an id on openfn here?
33- console . log ( { openfn : project . openfn } ) ;
34-
28+ const project = await Project . from ( 'fs' , { root : options . workspace || '.' } ) ;
3529 // TODO: work out if there's any diff
3630
3731 // generate state for the provisioner
@@ -41,7 +35,7 @@ export async function handler(options: DeployOptionsBeta, logger: Logger) {
4135 logger . debug ( JSON . stringify ( state , null , 2 ) ) ;
4236
4337 // TODO not totally sold on endpoint handling right now
44- config . endpoint = endpoint || project . openfn ?. endpoint ;
38+ config . endpoint ??= project . openfn ?. endpoint ! ;
4539
4640 logger . info ( 'Sending project to app...' ) ;
4741
0 commit comments