Skip to content

Keep Code-node JavaScript only in src/*.js, filled in at publish - #6

Merged
rrrutledge merged 3 commits into
mainfrom
build/js-source-files
Oct 30, 2026
Merged

rrrutledge merged 3 commits into
mainfrom
build/js-source-files

Conversation

@rrrutledge

@rrrutledge rrrutledge commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What changes

Before, each Code node's JavaScript sat inside the workflow JSON as one long escaped string, so a pull request showed a logic change as a single unreadable JSON line.
Now each Code node's JavaScript lives only in its own file under src/, one folder per workflow and one file per node, and a pull request shows a code change as ordinary lines of JavaScript.

In the committed workflow JSON, each Code node's code is a one-line comment naming its file under src/.
Publishing fills the real code in from that file before uploading, both for the automatic publish on merge and for a manual publish.
A merge that changes only a .js file publishes the workflow that uses it.
A new GitHub Action, the source-file check, fails a pull request when a Code node holds real code instead of naming a file, when a Code node names a file that doesn't exist, or when a file under src/ belongs to no Code node.
make build writes every workflow with its code filled in to dist/, for importing into n8n by hand, and make extract turns a workflow exported from the n8n editor back into a one-line comment per node plus its src/ files.
USAGE.md gains a section on changing a Code node: edit its file under src/, and run make extract after bringing in a workflow exported from the n8n editor.

Publishing sends n8n exactly what it runs today.

How it was verified

Each check below ran against this branch.

  • The preview job confirms it in CI. On every pull request, the new preview job builds the workflows from both the pull request and main and lists each as identical or names what changed; on this pull request, its run summary lists all 7 as identical.
  • Filled-in workflows match main. The built workflows in dist/ are byte-for-byte identical to every workflow JSON file on main.
  • Publishing finds the right workflows. Given a changed .js file, the publish step picks the workflow that uses it, alongside any changed workflow JSON.
  • The source-file check catches each mismatch. It failed for a missing source file, for a source file no node uses, and for a workflow pasted in from an export with its code inline.
  • An export round-trips cleanly. Running make extract on that pasted export restored the same one-line comments and left src/ unchanged.
  • All 7 workflows still import. Each filled-in workflow was created as an inactive copy through the n8n API, its Code nodes compared against the matching src/ files, and the copy deleted.
    Two of them carry credentials the API key has no access to, so their copies were created with credential references removed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AEavKGR3wFFUQXR9W16mSQ

…JSON

Each Code node's JavaScript now lives in its own file under src/, so a pull request shows a code change as ordinary lines of JavaScript. make build writes the code back into the workflow JSON, make extract seeds src/ from the JSON, and a CI check fails a pull request whose JSON and src/ disagree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01AEavKGR3wFFUQXR9W16mSQ
Each Code node's jsCode in the committed workflow JSON is now a one-line comment naming its src/ file, so a code change touches only the .js file. update-workflow.sh fills the code in before uploading, a merge that changes only src/ publishes the workflows it touches, make build writes filled-in workflows to dist/, and the CI check fails when a Code node holds code or names a missing file, or a src/ file is unused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01AEavKGR3wFFUQXR9W16mSQ
@rrrutledge rrrutledge changed the title Keep Code-node JavaScript in src/*.js and build it into the workflow JSON Keep Code-node JavaScript only in src/*.js, filled in at publish Oct 27, 2026
…base branch

A new preview job builds the workflows publishing would send from the pull request and from its base branch, and lists each one as identical or names what changed, on the run's summary page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01AEavKGR3wFFUQXR9W16mSQ
@rrrutledge
rrrutledge marked this pull request as ready for review October 30, 2026 00:44
@rrrutledge
rrrutledge merged commit 4b5046a into main Oct 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants