Skip to content

Commit 954d398

Browse files
authored
Merge pull request #1385 from OpenFn/sync-v2-endpoint
feat: override endpoint with one from openfn.yaml
2 parents 1e8fa8e + 9ecc3ba commit 954d398

4 files changed

Lines changed: 22 additions & 1 deletion

File tree

packages/cli/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @openfn/cli
22

3+
## 1.34.2
4+
5+
### Patch Changes
6+
7+
- 3918358: Override config.endpoint with one from openfn.yaml
8+
39
## 1.34.1
410

511
### Patch Changes

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openfn/cli",
3-
"version": "1.34.1",
3+
"version": "1.34.2",
44
"description": "CLI devtools for the OpenFn toolchain",
55
"engines": {
66
"node": ">=18",

packages/cli/src/deploy/handler.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { DeployOptions } from './command';
1010
import * as beta from '../projects/deploy';
1111
import path from 'node:path';
1212
import { fileExists } from '../util/file-exists';
13+
import { yamlToJson } from '@openfn/project';
14+
import fs from 'node:fs/promises';
1315

1416
export type DeployFn = typeof deploy;
1517

@@ -39,6 +41,12 @@ async function deployHandler(
3941
'openfn.yaml'
4042
);
4143
if (await fileExists(v2ConfigPath)) {
44+
// override endpoint with one from openfn.yaml
45+
const config = yamlToJson(await fs.readFile(v2ConfigPath, 'utf-8'));
46+
if (config?.project?.endpoint) {
47+
config.endpoint = config.project.endpoint;
48+
}
49+
4250
logger.always(
4351
'Detected openfn.yaml file - switching to v2 deploy (openfn project deploy)'
4452
);

packages/cli/src/pull/handler.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type { Logger } from '../util/logger';
1212
import { PullOptions } from '../pull/command';
1313
import beta from '../projects/pull';
1414
import { fileExists } from '../util/file-exists';
15+
import { yamlToJson } from '@openfn/project';
1516

1617
async function pullHandler(options: PullOptions, logger: Logger) {
1718
if (options.beta) {
@@ -26,6 +27,12 @@ async function pullHandler(options: PullOptions, logger: Logger) {
2627
'openfn.yaml'
2728
);
2829
if (await fileExists(v2ConfigPath)) {
30+
// override endpoint with one from openfn.yaml
31+
const config = yamlToJson(await fs.readFile(v2ConfigPath, 'utf-8'));
32+
if (config?.project?.endpoint) {
33+
config.endpoint = config.project.endpoint;
34+
}
35+
2936
logger.always(
3037
'Detected openfn.yaml file - switching to v2 pull (openfn project pull)'
3138
);

0 commit comments

Comments
 (0)