almost-git

1.0.0-alpha.13 • Public • Published

almostjs-git

ALMOsT is an AgiLe MOdel Transformation framework for JavaScript

NPM Version Build Status Build status Coverage Status License: MIT

This repository contains a model and text co-evolution tool.

We take as a reference scenario a development team that uses Model Driven Development and in particular Model to Text transofrmation to speed up app development. The tool allow the developer to preserve the parts of the code that are defined outside the model-and-generate cycle, such as the code defining the look and feel of the graphical user interface and the connection between the client side and the back-end service endpoints.

Installation

$ npm install -g almost-git

Usage

Initialize the repository. This step is very important, you will not be able to use the evolve feature without this step.

$ almost-git init

Start the evolution process passing as parameter the folder containing the new generated code.

$ almost-git evolve ~/new-generated-code

During evolution process conflicts may arise. The tool try to solve them automatically using git, leaving manual intervention as fallback. Finalize the evolution after manual conflict resolution.

$ almost-git evolve --continue

If you change your mind and you do not want to solve conflict you can abort the evolution process.

$ almost-git evolve --abort

Example

Let's imagine Topolino is a software developer that use a Model Driven Development tool that generates code starting from a UML model. Topolino builds the first version of the model and run the code generator. The generated code is stored into model-0-generated-code folder. Topolino also creates an empty folder called repository.

$ ls ~
repository      model-0-generated-code
model-0-generated-code
│   one.js
│   two.js

Topolino copies the generated code into the empty folder that will be out git repository.

$ cp -R ~/model-0-generated-code/. ~/repository/

The generated code is composed of two files.

repository
│   one.js
│   two.js

The content of each file is shown below.

$ cat ~/repo/one.js
====
value: 1
====
$ cat ~/repo/two.js
====
value: 2
====

Topolino is now ready to initialize the git repository and to commit the first version of his awesome application.

cd ~/repository
$ almost-git init
Repository correclty initialized!

Now you can use almost-git to evolve your code. As we can see from the log the tool has commited the first generated code.

$ git log
1234567 first version of the generated code

Topolino now needs to change the content of the file one.js in order to improve his application.

$ nano ~/repo/one.js
$ cat ~/repo/one.js
====
value: one
====

After such effort Topolino commits the changes.

$ git commit -a -m "Change value in one.js"
$ git log
1234567 first version of the generated code
2345778 Change value in one.js

Then Topolino realized that a change in the model is required. He modify the model and run the code generator, saving the new generated code into model-1-generated-code folder.

$ ls ~
repository      model-0-generated-code      model-1-generated-code

The new generated code is composed of two files. The file one.js is still there and its content is not changed from the previoulsy generated code. The file two.js disappeared. A new file three.js is generated.

model-1-generated-code
│   one.js
│   three.js

The content of each file is shown below

$ cat ~/model-1-generated-code/one.js
====
value: 1
====
$ cat ~/model-1-generated-code/three.js
====
value: 3
====

Topolino needs to use the new generated code while preserving the changes he made on the previous version of the generated code. But Topolino is happy, because he is using almost-git. Topolino starts the code evolution using the tool. The folder storing the new generated code has to be passed as parameter.

$ cd ~/repository
$ almost-git evolve ~/model-1-generated-code

The tool build new version of the code based on the model-1-generated-code while preserving the changes the developer made to one.js

repository
│   one.js
│   three.js

The content of the files of the final version is shown below.

$ cat ~/repo/one.js
====
value: one
====
$ cat ~/repo/three.js
====
value: 3
====

The tool add two commits:

  • a snapshot of the new generated code
  • the new version of the code obtained reappling the manual changes to the new generated code
$ git log
1234567 first version of the generated code
2345778 Change value in one.js
3456789 second version of the generated code
4567890 merged model

Package Sidebar

Install

npm i almost-git

Weekly Downloads

2

Version

1.0.0-alpha.13

License

MIT

Unpacked Size

125 kB

Total Files

170

Last publish

Collaborators

  • emanuelefalzone