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.

Your ultimate dev helper

Using the cli tool to the fullest greatly speeds up your development. Not only does it create frames, components and models, it also generates unit tests for you that are more than just a boiler plate. Continuous integration has never been so easy and efficient.

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.

Example: write TestModel migrate.json

1. Create model (if not already existing)

neoan3 new model test

2.1 If table(s) already exist (e.g structured like shown below)


        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;
    
Run neoan3 migrate models down

2.2 If model tables do not exist in your database

Run neoan3 develop (if not already running)

Visit http://localhost:8080/migrate

3 Design your table(s) and write your migration (write out).

Run neoan3 migrate models up
Unknown method: uni