Skip to content

Commit

Permalink
Initial codebase (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jussi Vatjus-Anttila authored Mar 5, 2019
1 parent a84dc34 commit be9bce9
Show file tree
Hide file tree
Showing 17 changed files with 2,608 additions and 4 deletions.
93 changes: 93 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
version: 2

workflows:
version: 2
test-publish:
jobs:
- test-node8:
filters: # required since `deploy` has tag filters AND requires `build`
tags:
only: /.*/
- test-node10:
filters: # required since `deploy` has tag filters AND requires `build`
tags:
only: /.*/
- test-node-latest:
filters: # required since `deploy` has tag filters AND requires `build`
tags:
only: /.*/
- publish:
requires:
- test-node8
- test-node10
- test-node-latest
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/


defaults: &defaults
working_directory: ~/repo
docker:
- image: circleci/node:8.12.0
steps:
- checkout
- run: node --version > _tmp_file
- restore_cache:
key: dependency-cache-{{ checksum "_tmp_file" }}-{{ checksum "package.json" }}
- run:
name: npm-install
command: npm install

- save_cache:
key: dependency-cache-{{ checksum "_tmp_file" }}-{{ checksum "package.json" }}
paths:
- ./node_modules
- run:
name: test
command: npm test
environment:
REPORTER: mocha-circleci-reporter
MOCHA_FILE: junit/test-results.xml
#- run:
# name: coveralls
# command: cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
- run:
name: lint
command: npm run lint
when: always
- store_test_results:
path: junit
- store_artifacts:
path: junit
- store_artifacts:
path: coverage
prefix: coverage
jobs:
test-node8:
<<: *defaults
docker:
- image: circleci/node:8.12.0
test-node10:
<<: *defaults
docker:
- image: circleci/node:10.14.1
test-node-latest:
<<: *defaults
docker:
- image: circleci/node:latest
publish:
<<: *defaults
steps:
- checkout
- run: node --version > _tmp_file
- restore_cache:
key: dependency-cache-{{ checksum "_tmp_file" }}-{{ checksum "package.json" }}
- run:
name: Authenticate with registry
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
- run:
name: Publish package
command: npm publish
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**/node_modules
doc/
coverage/
19 changes: 19 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
env: {
es6: true,
node: true,
},
extends: 'airbnb-base',
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
rules: {
"max-len": ["error", {"code": 120, "tabWidth": 4, "ignoreUrls": true}],
"no-underscore-dangle": ["off"]
},
};
62 changes: 62 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

browser-test.js
.idea
junit
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Jussi Vatjus-Anttila

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
65 changes: 61 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,80 @@
## PlantUML code generator (pumlgen)
## PlantUML code generator (puml2code)

Tool that convert Plantuml -text file that represent UML diagram to code.

### Project status
**IN PROGRESS**
**POC/IN PROGRESS**

- [ ] core implementation
- [ ] CLI interface
- [x] CLI interface
- [x] JS interface
- [ ] unit tests
- [ ] e2e tests
- [ ] documentation

### Supported features
* output: javascript (es6)
* output: file/console per class
* ES6 class
* imports based on parameter
* camelCase conversion
* private variables (with underscore prefix)
* methods with parameters
* code documentation

### Usage

```
$ Usage: cli [options]
Options:
-V, --version output the version number
-i, --input [file] input .puml file
-l, --lang [lang] select output code language (default: "es6")
-o, --out [path] Output path (default: "console")
-h, --help output usage information
```

e.g.
```
$ puml2code -i myfile.puml
Scheduler.js:
// native modules
// 3rd party modules
// application modules
const Queue = require('./Queue');
const Resources = require('./Resources');
/**
* Class Scheduler
*/
class Scheduler {
/**
* TBD
*/
constructor(queue, resources) {
this._queue = query;
this._resoures = resources;
}
/**
* @param {Queue} queue TBD
*/
_test(queue) {
// TBD
}
/**
* @param {Queue} queue TBD
*/
__protected(queue) {
// TBD
}
}
```
[examples](examples/sample.js)

### LICENSE:
[MIT](LICENSE)
6 changes: 6 additions & 0 deletions examples/sample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const PlantUmlToCode = require('../src');


const platnuml = PlantUmlToCode.fromFile('./examples/sample.puml');
platnuml.generate()
.then(out => out.print());
11 changes: 11 additions & 0 deletions examples/sample.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@startuml
title Allocation queue - Class Diagram

class Scheduler {
+constructor(Queue, Resources)
-test(Queue)
#async protected(Queue)
-Queue _queue
-Resources _resoures: list of resources
}
@enduml
Loading

0 comments on commit be9bce9

Please sign in to comment.