File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,6 +62,15 @@ async function deployHandler(
6262 config . endpoint = process . env [ 'OPENFN_ENDPOINT' ] ;
6363 }
6464
65+ const rawSpec = await fs . readFile ( config . specPath , 'utf-8' ) ;
66+ const convertedSpec = await maybeConvertV2spec ( rawSpec ) ;
67+ if ( convertedSpec !== rawSpec ) {
68+ logger . debug (
69+ 'Detected v2 spec file! This will be converted into the legacy format and validation will be skipped.'
70+ ) ;
71+ config . spec = convertedSpec ;
72+ }
73+
6574 logger . debug ( 'Deploying with config' , config ) ;
6675 logger . info ( `Deploying` ) ;
6776
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { confirm } from '@inquirer/prompts';
22import { inspect } from 'node:util' ;
33import { DeployConfig , ProjectState } from './types' ;
44import { readFile , writeFile } from 'fs/promises' ;
5- import { parseAndValidate } from './validator' ;
5+ import { parseAndValidate , parseSpec } from './validator' ;
66import jsondiff from 'json-diff' ;
77import {
88 mergeProjectPayloadIntoState ,
@@ -108,8 +108,8 @@ export async function getSpec(path: string) {
108108
109109export async function deploy ( config : DeployConfig , logger : Logger ) {
110110 const [ state , spec ] = await Promise . all ( [
111- getState ( config . statePath ) ,
112- getSpec ( config . specPath ) ,
111+ config . state ?? getState ( config . statePath ) ,
112+ config . spec ? parseSpec ( config . spec ) : getSpec ( config . specPath ) ,
113113 ] ) ;
114114
115115 logger . debug ( 'spec' , spec ) ;
Original file line number Diff line number Diff line change @@ -193,4 +193,6 @@ export interface DeployConfig {
193193 requireConfirmation : boolean ;
194194 dryRun : boolean ;
195195 apiKey : string | null ;
196+ spec ?: string ;
197+ state ?: ProjectState ;
196198}
Original file line number Diff line number Diff line change @@ -3,6 +3,10 @@ import { ProjectSpec } from './types';
33import { readFile } from 'fs/promises' ;
44import path from 'path' ;
55
6+ export function parseSpec ( input : string ) {
7+ return { errors : [ ] as Error [ ] , doc : YAML . parse ( input ) as ProjectSpec } ;
8+ }
9+
610export interface Error {
711 context : any ;
812 message : string ;
You can’t perform that action at this time.
0 commit comments