From fc4d5bf2c40dde5ca083762f302744b3b4788c2e Mon Sep 17 00:00:00 2001 From: josephjclark Date: Tue, 19 Mar 2024 13:23:49 +0300 Subject: [PATCH] Fix pull without workflows (#631) deploy: allow pull for projects with no workflows --- packages/cli/CHANGELOG.md | 8 ++++++++ packages/cli/package.json | 2 +- packages/deploy/CHANGELOG.md | 6 ++++++ packages/deploy/package.json | 2 +- packages/deploy/src/validator.ts | 7 ++++++- packages/deploy/test/validator.test.ts | 16 ++++++++++++++++ 6 files changed, 38 insertions(+), 3 deletions(-) diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 92603c99c..46bafd4f2 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,12 @@ # @openfn/cli +## 1.1.2 + +### Patch Changes + +- Updated dependencies [6d52ddf] + - @openfn/deploy@0.4.4 + ## 1.1.1 ### Patch Changes @@ -9,6 +16,7 @@ - @openfn/compiler@0.0.41 - @openfn/deploy@0.4.3 - @openfn/runtime@1.0.1 + ## 1.1.0 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index 17ad7ae8d..9a7830871 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@openfn/cli", - "version": "1.1.1", + "version": "1.1.2", "description": "CLI devtools for the openfn toolchain.", "engines": { "node": ">=18", diff --git a/packages/deploy/CHANGELOG.md b/packages/deploy/CHANGELOG.md index e7e627e2a..97bb19677 100644 --- a/packages/deploy/CHANGELOG.md +++ b/packages/deploy/CHANGELOG.md @@ -1,5 +1,11 @@ # @openfn/deploy +## 0.4.4 + +### Patch Changes + +- 6d52ddf: Fix an issue pulling a project with no workflows + ## 0.4.3 ### Patch Changes diff --git a/packages/deploy/package.json b/packages/deploy/package.json index fcf37d1fe..37c6eada7 100644 --- a/packages/deploy/package.json +++ b/packages/deploy/package.json @@ -1,6 +1,6 @@ { "name": "@openfn/deploy", - "version": "0.4.3", + "version": "0.4.4", "description": "Deploy projects to Lightning instances", "type": "module", "exports": { diff --git a/packages/deploy/src/validator.ts b/packages/deploy/src/validator.ts index 30b066450..8f8d78158 100644 --- a/packages/deploy/src/validator.ts +++ b/packages/deploy/src/validator.ts @@ -47,7 +47,12 @@ export function parseAndValidate(input: string): { } function validateWorkflows(workflows: any) { - if (isMap(workflows)) { + if (typeof workflows === 'undefined') { + // allow workflows to be unspecified, but ensure there is an empty + // map to avoid errors downstream + doc.setIn(['workflows'], {}) + } + else if (isMap(workflows)) { for (const workflow of workflows.items) { if (isPair(workflow)) { pushUniqueKey(workflow, (workflow as any).key.value); diff --git a/packages/deploy/test/validator.test.ts b/packages/deploy/test/validator.test.ts index 0a70b006d..67559c99b 100644 --- a/packages/deploy/test/validator.test.ts +++ b/packages/deploy/test/validator.test.ts @@ -76,3 +76,19 @@ workflows: ].condition_expression === 'true' ); }); + + +test('allow empty workflows', (t) => { + let doc = ` +name: project-name + `; + + let result = parseAndValidate(doc); + + t.is(result.errors.length, 0) + + t.deepEqual(result.doc, { + name: 'project-name', + workflows: {} + }) +}); \ No newline at end of file