Skip to content

Release: CLI@1.39.0 next worker@1.27.3#1490

Merged
josephjclark merged 3 commits into
mainfrom
release/next
Jul 24, 2026
Merged

Release: CLI@1.39.0 next worker@1.27.3#1490
josephjclark merged 3 commits into
mainfrom
release/next

Conversation

@josephjclark

@josephjclark josephjclark commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

CLI improvements for Plan International

  • compile to disk
  • enable writing to stdout

Includes a shallow worker version change (worker is totally unaffected but dependencies need updating)

* enable writing to stdout

* remove log file
@github-project-automation github-project-automation Bot moved this to New Issues in Core Jul 22, 2026
mtuchi and others added 2 commits July 22, 2026 18:42
* cli: add openfn compile --test for unit testing job code

- Add --test flag: compiles job expressions for unit testing, writing
  output to tests/ by default (reads dirs.tests from openfn.yaml)
- Add --strip (default on with --test): tree-shakes compiled output,
  keeping only export const/function declarations and their transitive
  dependencies; use --no-strip to keep all compiled code
- Add --watch flag: watches source files and recompiles on change
  (uses chokidar)
- Strip mode removes injected _defer import when operations are stripped
- Skip writing files with no exportable code after stripping; log when
  skipping
- Auto-clean stale step files in tests/ that were skipped in the current
  run without touching user-added files at other paths
- Fix --test --no-strip skipping pure-operation jobs (hasExportableCode
  guard now only applies when strip is active)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: update pnpm-lock.yaml

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* cli: refine compile --test behaviour

- remove export default [] from strip mode output (not needed for unit testing)
- add --no-strip flag to keep full compiled output including operations
- remove --strip standalone flag (stripping is always on with --test by default)
- auto-derive output path for single-file --test using tests/ dir
- skip writing files with no exportable code in strip mode
- auto-clean stale step files in tests/ after project-wide strip runs
- fix --test --no-strip skipping pure-operation jobs
- update help examples and option descriptions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: reference unit-testing-jobs.md in additional documentation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: add unit-testing-jobs.md guide for openfn compile --test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* compiler/cli: replace --test with --exports-only, add project-wide compile

- Drop --test and --strip/--no-strip flags from openfn compile
- Add --exports-only flag (opt-in) to strip operation calls, keeping only
  exported constants and functions for unit testing
- openfn compile (no args) now compiles the whole project to compiled/ by default
- openfn compile <workflow-name> looks up a workflow by name/id and compiles it
- Extract stripping logic into a new exports-only transformer (order: 0) that
  runs before all others; remove strip option from top-level-operations
- Update unit-testing-jobs.md to document the new workflow

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* prettier format

* chore: trim noisy comments from compile and transformer files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* pnpm test:format

* compiler/cli: simplify exports-only transformer, rewrite tests as source strings

- Strip exports-only transformer down to a simple filter (imports + named exports only) — removes collectRefs/buildDeclMap/collectDeps dep-tracking
- Rewrite exports-only tests using before/after source strings instead of AST builders
- Extract runCompile helper in handler.ts to remove duplicated watch/non-watch logic
- Clean up (step as any) casts in compile.ts now that step types are correct
- Update unit-testing-jobs.md to drop the non-exported dependency note

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* compiler/cli: move hasExportableCode to compiler, simplify compileProject loop

- hasExportableCode now lives in exports-only.ts and is exported from @openfn/compiler — the compiler decides what's exportable, not the CLI
- Simplified regex: only match explicit export declarations (non-exported helpers are stripped by exports-only, so they'll never appear in the output)
- Flatten nested workflow/step loops into a flat allSteps array in compileProject
- Downgrade skipped-step log from info to debug
- Remove hasExportableCode tests from CLI (now covered in compiler's exports-only test suite)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* remove all changes

* chore: restore top-level-operations test to match main

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* cli: remove stale file cleanup from compileProject

Just skip steps with no exportable code — don't track or delete old output files.
The compiled dir is a dist folder; cleanup can be a future --clean flag if needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* cli: add --clean and --workspace to compile, output .mjs to dist/

- Add --clean to remove the output folder before compiling (off by default)
- Add --workspace support, as in execute and project commands
- Default output dir is now dist/ (or dirs.compiled from openfn.yaml)
- Compiled files use the .mjs extension
- Simplify runCompile routing: file paths compile directly, anything else
  compiles the checked-out project
- Watch mode respects the configured workflows dir and workspace root,
  and ignores the resolved output dir

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* lexicon/project: add dirs.compiled to WorkspaceConfig

Type the compiled output dir key used by openfn compile. buildConfig
passes it through without a default so it is only serialized into
openfn.yaml when the user sets it; the CLI defaults it to dist/ at
point of use.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs: update unit-testing guide for dist/.mjs output; add changeset

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* compiler: keep export-list deps in exports-only, rewrite tests against transform

- hasExportableCode now matches any non-default export (export lists,
  export *, async functions) instead of enumerating declaration keywords
- exports-only keeps top-level declarations referenced by bare export
  lists (export { x }) so compiled output is importable, and preserves
  export * re-exports
- tests call transform() directly with parsed source instead of a local
  compile() wrapper, matching lazy-state.test.ts

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* cli: trim low-value comments in compile handler

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* compiler/cli: drop hasExportableCode, skip empty output with a trim check

The exports-only transform already strips everything non-exportable, so
"nothing to test" is just empty compiled output. Replace the exported
regex helper (and its 11 tests) with an inline !code.trim() check in
compileProject. Skip behavior is unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* cli/compiler: test cleanup from review feedback

- rename compileProject tests to "compile from project" and move them up
  as peers of the other compile-from-x tests
- use the shared mockFs helper instead of repeating the pnpm mock
  boilerplate in every project test
- import fs statically instead of dynamic await import
- add real compile handler tests (stdout, outputPath, workflow, project
  mode, missing file) replacing the placeholder
- exports-only: lead with basic strip behaviour, then no-op inverses
  over the same source

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* remove comments

* Change how ensureExports gets fed into the compiler (#1489)

* Change how ensureExports gets fed into the compiler

Let the CLI only the transforms rather than toggling off options

* update tests

* fix types

* remove test

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Joe Clark <joe@openfn.org>
@josephjclark josephjclark changed the title Release: CLI next Release: CLI@1.39.0 next worker@1.27.3 Jul 24, 2026
@josephjclark
josephjclark merged commit c546f75 into main Jul 24, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from New Issues to Done in Core Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants