Library that contains all models for modeling tools in Leto's projects.
This library is used to create your own plugin for the Leto Modelizer tool.
npm install --save "git://github.com/ditrit/leto-modelizer-plugin-core.git"
Here are all imports you can use in your plugin:
import {
Component,
ComponentDefinition,
ComponentAttributeDefinition,
ComponentDrawOption,
ComponentAttribute,
ComponentLink,
ComponentLinkDefinition,
DefaultDrawer,
DefaultMetadata,
DefaultParser,
DefaultRender,
ParseError,
FileInformation,
FileInput,
DefaultData,
DefaultPlugin,
DefaultConfiguration,
Tag,
Variable,
} from "leto-modelizer-plugin-core";
For more information about all imports please refer to technical documentation and project template.
You can use it in that way:
import { DefaultParser } from 'leto-modelizer-plugin-core';
class FruitParser extends DefaultParser {
parse(inputs) {
// Write your own parser here
return {
components: [/* ... */], // Generated components from parser
links: [/* ... */] // Generated component links from parser
}
}
}
export default FruitParser;
To see a complete example, please refer to iactor.
You can use this template repository to create your own plugin.
The project template leto-modelizer-plugin-template provides you the default structure of a plugin and all useful scripts to generate resources and other.
It is strongly recommended to use it and the following documentation will make references to it.
Furthermore, in this template there are code comments to explain how to override methods/classes and usages.
You can read the template documentation to see how to create your own models.
For your plugin to be used by Leto Modelizer
, it needs to have this structure:
// src/index.js
export default new DefaultPlugin({
pluginData: MyPluginData, // MyPluginData has to extend DefaultData
pluginDrawer: MyPluginDrawer, // MyPluginDrawer has to extend DefaultDrawer
pluginMetadata: MyPluginMetadata, // MyPluginMetadata has to extend DefaultMetadata
pluginParser: MyPluginParser, // MyPluginParser has to extend DefaultParser
pluginRenderer: MyPluginRenderer, // MyPluginRenderer has to extend DefaultRender
});
Plugin lifecycle |
---|
This is the default lifecycle of plugin usage in Leto Modelizer.
Create you plugin project from leto-modelizer-plugin-template and follow the readme section of the template project.
The configuration.md explains how you can configure your plugin.
By default, plugin sends event if you provide a next()
function in DefaultData, like:
new DefaultPlugin({
event: {
next: () => {},
}
})
If you do not, events are still stored in the DefaultData.eventLogs
.
When you create your plugin, you can send event to Leto-modelizer to see the progression of your parsing or rendering action.
See EventLog
in technical documentation for more information.
Technical documentation can be found here.
Explanation of usage of scripts in package.json
.
Build this project in dist
folder.
Fix betterdocs template for jsdoc and make it work.
Generate documentation with jsdoc.
Start a sample integration vue dev server.
Run eslint check on the project.
Apply default fix for eslint in project.
Generate report of lint issues for sonar.
To use in development, to see current lint errors with auto-refresh.
Run all the unit tests.
Generate coverage report of the unit tests.
This is the default directory structure we use for this project:
leto-modelizer-plugin-core
├ cypress ⇨ Contains all the cypress related files
│ ├ e2e ⇨ Contains all the e2e tests
│ └ support ⇨ Contains all support files for e2e tests
│ └ step_definitions ⇨ Contains all step definitions for e2e tests
├ demo ⇨ Contains a vue demo application
├ dist ⇨ Contains the built application
├ docs ⇨ Contains all files generated by esdoc
├ public ⇨ Contains all public files, like favicon
├ reports ⇨ Contains all the report files for sonar
├ guides ⇨ Contains all the guides
├ └ docs ⇨ Contains all plugin-core documentation
│ └ migrations ⇨ Contains all migration guides
│ └ svg ⇨ Contains the guide to build a component svg
├ src ⇨ Contains all files for modeling tools
│ ├ assets ⇨ Contains all the assets
│ ├ draw ⇨ Contains all files related to the Class that draws components in a graphical representation
│ ├ error ⇨ Contains all files related to the Class that represents a parsing error
│ ├ metadata ⇨ Contains all files related to the Class that represents the metadata of a specific implementation
│ ├ models ⇨ Contains all files related to the Class that represents default plugin structure
│ ├ parser ⇨ Contains the Class used for parsing
│ └ render ⇨ Contains the Class that compile components to data
└ tests ⇨ Contains all files related to the tests
We use Semantic Versioning as guideline for the version management.
Steps to release:
- Checkout a branch
release/vX.Y.Z
from the latestdev
. - Improve your version number in
package.json
,package-lock.json
andchangelog.md
. - Verify the content of the
changelog.md
. - Build the project
- Commit your modification (with the
dist
content) with this commit's nameRelease version X.Y.Z
. - Create a pull request on github to this branch in
dev
. - After the previous PR is merged, create a pull request on github to
dev
inmain
. - After the previous PR is merged, tag the
main
branch withvX.Y.Z
- After the tag is push, make the release on the tag in GitHub
The default branch is main
, we can't commit on it and we can only make a pull request to add some code.
Release tags are only on the main
branch.
There is the branch naming policy: [BRANCH_TYPE]/[BRANCH_NAME]
BRANCH_TYPE
is a prefix to describe the purpose of the branch, accepted prefix are:feature
, used for feature developmentbugfix
, used for bug fiximprovement
, used for refactolibrary
, used for updating libraryprerelease
, used for preparing the branch for the releaserelease
, used for releasing projecthotfix
, used for applying a hotfix on main
BRANCH_NAME
is managed by this regex:[a-z0-9_-]
(_
is used as space character).
Examples:
# BAD
add_some_test
# GOOD
improvement/unit_test
# BAD
feature/adding-some-feature
# GOOD
feature/adding_some_feature