neoan3 cli tool

Automation

neoan3 recently has officially switched over to a PHP-based cli helper. Migrating from the node cli tool requires deletion of the global npm package!

The cli tool helps you greatly with development of neoan3 components & frames. The full and current documentation can be found at https://github.com/neoan3/cli. Here we only want to go into a few important functions:

CLI-Templating

Since neoan3 is highly customizable, creation of components can be influenced by templates. Neoan3 does not require the use of the cli-tool, nor does the cli-tool require templates.
This is why neoan3 currently does not ship with a folder _template by default.
To use templating of neoan3-cli, create the folder _template.
In order to overwrite the way components are generated, we can now place template-files in this template folder.

Example: Custom element as React component

1. create _template/ce.js


        class {{name}} extends React.Component {
            render() {
                return <h1>Hello, {this.props.name}</h1>;
            }
        }
    

2. Run neoan3-cli:

neoan3 new component test

Select "Custom Element" when prompted

File component/test/test.ce.js:


        class Test extends React.Component {
            render() {
                return <h1>Hello, {this.props.name}</h1>;
            }
        }
    

Migration

The cli-tool creates, updates and executes neoan3 migration.json automatically. Neoan3 assumes you are working with VCS and therefore expects a simple structure of your tables to be sufficient. The cli-tool makes assumptions based on the model-names. The existence of a "TestModel", for instance, would connect the model to tables "test" as well as "test_entry", should they exist.
Assuming

Example: write TestModel migrate.json

1. Create model (if not already existing)

neoan3 new model test

2. Create tables (if not already existing)


        CREATE TABLE `test` (
          `id` binary(16) NOT NULL PRIMARY KEY,
          `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
          `insert_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
          `delete_date` datetime DEFAULT NULL
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
        CREATE TABLE `test_entry` (
          `id` binary(16) NOT NULL PRIMARY KEY,
          `test_id` binary(16) DEFAULT NULL,
          `entry` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
          `insert_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
          `delete_date` datetime DEFAULT NULL
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
    

3. Write migration

neoan3 migrate models down

Example: update database according to migrate.json changes

When collaborating, using multiple databases, and/or using various branches, you can update your database in one simple step:

neoan3 migrate models up

Adding components/frames/models

Collaboration is a huge topic in today's world. Beginners might initially not see it, but between agile development, containerized solutions and GIT-branching strategies is a world full of unsolved pain points.
The recommended approach of neoan3 collaboration can be described as "Everything but the core is a plugin". This means that all components/frames & models can be published (respecting their requirements & dependencies) as installable solutions either within a particular project or in other neoan3 projects.
What that means in particular can be explored in Working with teams. For simplicity, here we simply assume that you want to include an existing component, frame, or model.

Example: include a model available as composer-package

1. Include blua.blue's image model

neoan3 add model blua-blue/image-model

2. Install/update MySQL tables

neoan3 migrate models up
Unknown method: uni