# @atomicg/atomicg

> CLI source code and text file generation tool.

Latest version **1.0.8** (published 2020-01-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install @atomicg/atomicg
pnpm add @atomicg/atomicg
yarn add @atomicg/atomicg
bun add @atomicg/atomicg
```

Provides the command `atomicg`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2020-01-16 |
| First published | 2020-01-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 17.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | atomicg |
| Maintainers | gilbertovento, gorums |
| Keywords | generation, cli, utility, source code, mysql, expressjs, sequelize |

## Links

- npm: https://www.npmjs.com/package/@atomicg/atomicg
- npm.io page: https://npm.io/package/@atomicg/atomicg

## Dependencies (6)

- [boxen](https://npm.io/package/boxen.md) ^4.1.0
- [chalk](https://npm.io/package/chalk.md) ^3.0.0
- [yargs](https://npm.io/package/yargs.md) ^15.0.2
- [fs-extra](https://npm.io/package/fs-extra.md) ^8.1.0
- [websocket](https://npm.io/package/websocket.md) ^1.0.30
- [require-text](https://npm.io/package/require-text.md) 0.0.1

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.0.8 (latest) — 2020-01-16
- 1.0.7 — 2020-01-16
- 1.0.6 — 2020-01-16
- 1.0.5 — 2020-01-15
- 1.0.4 — 2020-01-15
- 1.0.3 — 2020-01-15
- 1.0.2 — 2020-01-13
- 1.0.1 — 2020-01-13
- 1.0.0 — 2020-01-13

## README

# AtomicG

AtomicG is a CLI model-first source code generation tool, that can be used to automate the generation of regular and 
boilerplate source code files for your project, like Rest API CRUDs handlers, SQL scripts, entity classes for ORMs, etc...
You can read more about this tool in the official web site https://www.atomicg.dev/, also join the discussion in our 
discord server https://discord.gg/n65mRJZ or send us an email with any concern you have to info@atomicg.dev

# Instalation

AtomicG cli client can be installed using npm, it's recommended to install it globally, so it can be use in any project of 
any supported platform.

    npm i @atomicg/atomicg -g

# Usage

The first thing to do is to create a model to work with. An initial AtomicG model can be generated with the init command.

    atomicg init

This will create the *atomicg.yml* file in the current folder, the created model it's simply a starting point, entities 
and generators must be added to the model to create useful code for the project. The next section describes in detail
how to write a model. To generate the source code for the current model just run the tool with no options.

    atomicg    

# Model Reference

This section describes the information that can be added to the model and the source code each one produce. The following
is an example of an atomicg model.

    model:
      name: MyModel
      description: My Model
    
      basepath:
    
      uses:
        - gen: mysql
        - gen: sequelize
        - gen: express
    
      # Entities to be generated for this model.
      entities:
        - name: User
          fields:
            - name: email
              type: string
            - name: password
              type: string
            - name: name
              type: string
        - name: Group
          fields:
            - name: name
              type: string

All model must have the root element *model* beneath it the following options are available.

| option      | description                          | required |
|-------------|--------------------------------------|----------|
| name        | The name of the model.               | yes      |
| description | A short description to this model.   | no       |
| uses        | The list of generators to use.       | yes      |
| entities    | The list of entities to be generated | yes      |

The *uses* option allows to add a list with all the generators that will be generating code for this model. At this moment 
only 3 are supported, they are de following.

| generator | description                                                                                          |
|-----------|------------------------------------------------------------------------------------------------------|
| mysql     | generates the DDL script for MySQL database.                                                         |
| sequelize | generates a Sequelize model for each entity in the model.                                            |
| express   | generates an ExpressJS CRUD router for each entity in the model, that can be used as part of an API. |

The *entities* tag is used to specify the entities of the model and each entity has the following options.

| option | description                                                                           | required |
|--------|---------------------------------------------------------------------------------------|----------|
| name   | the name of the entity, that will be used for classes and file names for this entity. | yes      |
| fields | the list of fields for this entity.                                                   | yes      |
 
The tags for each field are the following.

| option    | description                                                                                                                       | required |
|-----------|-----------------------------------------------------------------------------------------------------------------------------------|----------|
| name      | the name of the field, this info will be used to generate properties and columns for the field.                                   | yes      |
| type      | the data type of the field, see the table of the available types for more information.                                            | yes      |
| required  | if the field is required or not, this determines if the column in the database allows null or not.                                | no       |
| length    | the length of the field for string and numeric types. for the text data type this field most be either null, tiny, medium or long | no       |
| decimals  | the number of decimals for floating-point data types                                                                              | no       |
| precision | the precision of the field for decimals types.                                                                                    | no       |
| scale     | the scale of the field for decimals types.                                                                                        | no       |
| index     | if the field must be indexed, see the index type table for more info.                                                             | no       |
| transform | the transformation that are needed by default on the data of the field. see the transformations table for more info.              | no       |
| values    | used with the enum datatype to specify the set of values that the enum accepts.                                                   | no       |

The following table shows the available datatypes.

| datatype | description                                           | SQL type                             | Sequelize type                       |
|----------|-------------------------------------------------------|--------------------------------------|--------------------------------------|
| boolean  | a boolean (true or false, usually 1 byte              | BOOLEAN                              | BOOLEAN                              |
| byte     | a 1 byte (8 bits) integer                             | TINYINT(length)                      | TINYINT(length)                      |
| short    | a 2 bytes (16 bits) integer                           | INTEGER(length)                      | INTEGER(length)                      |
| medium   | a 3 bytes (24 bits) integer                           | INTEGER(length)                      | INTEGER(length)                      |
| integer  | a 4 bytes (32 bits) integer                           | INTEGER(length)                      | INTEGER(length)                      |
| long     | a 8 bytes (64 bits) integer                           | BIGINT(length)                       | BIGINT(length)                       |
| char     | a fixed length string of characters                   | CHAR(length)                         | CHAR(length)                         |
| string   | a variable length string of characters                | VARCHAR(length)                      | STRING(length)                       |
| text     | a customizable (tiny, medium, long) text field        | TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT | TEXT, TEXT('tiny', 'medium', 'long') |
| float    | a single-precision floating-point number              | FLOAT(length, decimals)              | FLOAT(length, precision)             |
| double   | a double-precision floating-point number              | DOUBLE(length, decimals)             | DOUBLE(length, precision)            |
| decimal  | a decimal number that can store exact numbers.        | DECIMAL(precision, scale)            | DECIMAL(precision, scale)            |
| enum     | an enumeration field that only allows a set of values | ENUM(values)                         | ENUM                                 |

The following table shows the available options for the index tag.

| option  | description                                                                                                                                         |
|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------|
| none    | this is the default option, it means that this field will not be indexed.                                                                           |
| indexed | this options means that the database generator and the orm generator will create and index on this field.                                           |
| unique  | this options is the same as indexed but the created index will be a unique index,  meaning that this field will have unique values in the database. |

The following table shows the available options for the transform tag.

| transform   | description                                                                             |
|-------------|-----------------------------------------------------------------------------------------|
| trim        | it will trim the white spaces characters from both size to any value pass to the field. |
| upper       | it will convert to upper case any value that is pass to the field.                      |
| lower       | it will convert to lower case any value that is pass to the field.                      |
| emptyToNull | it will convert to null any empty string that is pass to the field.                     |

NOTE: This transformations are applicable to string fields only.

---
_Source: https://npm.io/package/@atomicg/atomicg · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
