Skip to content

divide 0.7.0

Choose a tag to compare

@github-actions github-actions released this 22 Nov 17:40

divide 0.7.0 makes Runner's Modules and Functions part of the Flow Designer. You can see which Steps use each Function, make a Module or a Function from a template, attach it to a Step and open it in the PHP editor, without writing folders or return function (...) by hand.

The workflow: a Module and a Function made from the Flow Designer, its PHP written, a Step that uses it, the Flow run

The Functions window

F on the Flow Designer's board, or Run > Flow functions, opens the window.

  • The function root, and where it comes from: the Run Flow dialog's --root, the context's _root_folder, the project's .div/runner.json, or the project.
  • The Modules and the Functions in each. A Module mapped elsewhere shows its folder. A Module outside the project is shown read-only.
  • The Steps that use each Function, in every Flow of the project. Open Flows count as they are in the editor, unsaved changes included.
  • Imports: the Functions each one imports with $context['_importer']('name', 'module'), when the name is written literally. A computed name shows as unknown, never as a problem.
  • References that resolve to nothing. Enter on one makes it.
Key What it does
Enter open a Function in the PHP editor, at its return; go to a Step; make a missing Function
Ins a new Function, in the Module under the cursor
Shift+Ins a new Module
Alt+F10 the window's menu, which also makes .div/runner.json
Ctrl+R read the disk again

Making Functions

  • New Function asks for the Module (or the root), the name and the use, activity or condition. It says where the file goes and what a Step will say to use it.
  • The file is a minimal, valid PHP 8.1 callable of the shared context. A condition returns bool; an activity returns mixed, which Runner keeps under the Step's id. It is a starting point: write any PHP there.
  • From a Step: in the Step dialog, Down offers the Modules and their Functions. Function... opens the Step's Function, or New... fills in module and activity (or condition).
    • The Step dialog's OK writes the Step as one YAML edit (one Ctrl+Z) and makes the file.
    • Cancel writes and makes nothing.
  • What is never done:
    • writing over a file that is already there;
    • writing outside the project, in Composer's vendor folder or in a hidden folder;
    • running a Function's PHP to list or read it.

Checks on a Function

A Function's file is read with tree-sitter, never run. It is flagged at the Step that names it, on the board, in the code and in Messages, when it:

  • returns nothing;
  • returns a closure that needs more than one argument;
  • returns a closure whose context is typed as something other than an array.

Any other callable is left alone, and existing Functions are never rewritten.

.div/runner.json

An optional project file, {"root": "functions", "modules": {...}}, gives the function root and the Module folders once, for everyone who clones the project.

  • Precedence: the Flow's --root comes first, then the context's _root_folder and _modules, then the file, then Runner's defaults.
  • A run passes what the file adds to Runner. Runner itself does not read the file.
  • examples/generator has one.

Also

  • The help has a new page, Flow Functions, in English and Spanish, with the workflow as a GIF.
  • The Spanish interface covers all of the above.

Known limits

  • The window makes Modules and Functions; renaming, moving and deleting them is the Project window's.
  • Running or debugging a single Function, and simulating Functions or Flows, are separate work.

Install

Ready to run, with nothing else to install:

  • macOS and Linux: brew install divengine/tap/divide
  • Windows: scoop install https://github.com/divengine/divide/releases/latest/download/divide.json, or the .msi below
  • Linux: the .deb, .rpm, .apk and Arch packages, the AppImage or the binary alone, below
  • macOS: the archive for Apple silicon or Intel, below

Rendering and checking includes need PHP 8 and Div (composer require divengine/div); Runner Flows need Runner (composer require divengine/runner); the Git menu needs git. divide is free software under the GPL, version 3 or later. The binaries are not signed yet: see Installation.