drawio_dsl 0.8.6 → 0.8.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.vscode/settings.json +2 -1
  3. data/CHANGELOG.md +22 -0
  4. data/README.md +0 -7
  5. data/{.builders/.data/shapes.json → config/configuration.json} +49 -49
  6. data/docs/domain-modal/domain_model_custom.drawio +134 -134
  7. data/docs/domain-modal/domain_model_custom.svg +1 -1
  8. data/docs/domain_model.drawio +265 -0
  9. data/docs/domain_model.json +1038 -0
  10. data/docs/domain_model.svg +3 -0
  11. data/docs/parking_app.drawio +24 -24
  12. data/docs/parking_app.svg +1 -1
  13. data/docs/printspeak-architecture-generator.drawio +42 -30
  14. data/docs/printspeak-architecture-generator.svg +1 -1
  15. data/docs/project-plan/project.drawio +78 -54
  16. data/docs/project-plan/project_done.svg +1 -1
  17. data/docs/project-plan/project_in_progress.svg +1 -1
  18. data/docs/project-plan/project_todo.svg +1 -1
  19. data/lib/drawio_dsl/configuration.rb +99 -0
  20. data/lib/drawio_dsl/drawio.rb +16 -0
  21. data/lib/drawio_dsl/formatters/base_formatter.rb +120 -0
  22. data/lib/drawio_dsl/formatters/html_builder.rb +39 -0
  23. data/lib/drawio_dsl/formatters/interface_formatter.rb +13 -1
  24. data/lib/drawio_dsl/formatters/klass_formatter.rb +13 -1
  25. data/lib/drawio_dsl/version.rb +1 -1
  26. data/lib/drawio_dsl.rb +2 -0
  27. data/package-lock.json +2 -2
  28. data/package.json +1 -1
  29. metadata +6 -31
  30. data/.builders/.templates/basic/configuration_shapes.rb +0 -27
  31. data/.builders/.templates/basic/dom_builder_shapes.rb +0 -17
  32. data/.builders/.templates/basic/drawio_extensions.rb +0 -58
  33. data/.builders/.templates/basic/drawio_shapes.rb +0 -23
  34. data/.builders/.templates/basic/schema_require.rb +0 -19
  35. data/.builders/.templates/basic/schema_shape.rb +0 -9
  36. data/.builders/.templates/basic/schema_shape_spec.rb +0 -13
  37. data/.builders/_.rb +0 -1
  38. data/.builders/blueprint/shapes.rb +0 -173
  39. data/.builders/boot.rb +0 -72
  40. data/.builders/generators/01-bootstrap.rb +0 -130
  41. data/.builders/generators/02-generate-app.rb +0 -47
  42. data/.builders/generators/10-transform-drawio-js.rb +0 -195
  43. data/.builders/generators/20-drawio-extensions.rb +0 -41
  44. data/.builders/generators/domain_diagram.rb +0 -473
  45. data/.builders/generators/parking-map.png +0 -0
  46. data/.builders/generators/parking_app.rb +0 -110
  47. data/.builders/generators/printspeak-architecture-generator.rb +0 -45
  48. data/.builders/generators/project-plan.rb +0 -81
  49. data/.builders/generators/sample_diagrams/05-samples.rb +0 -36
  50. data/.builders/generators/sample_diagrams/10-page-margin.rb +0 -42
  51. data/.builders/generators/sample_diagrams/15-grid-direction.rb +0 -34
  52. data/.builders/generators/sample_diagrams/16-grid-alignment.rb +0 -70
  53. data/.builders/generators/sample_diagrams/20-styles.rb +0 -61
  54. data/.builders/generators/sample_diagrams/25-themes.rb +0 -37
  55. data/.builders/generators/sample_diagrams/30-html-shapes.rb +0 -48
  56. data/.builders/generators/sample_diagrams/35-ids-and-arrows.rb +0 -28
  57. data/.builders/generators/sample_diagrams/50-willoughby-council.rb +0 -51
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Attach configuration to the DrawIO DSL module
4
- # :nocov:
5
- module DrawioDsl
6
- # Used to attach configuration to KConfig module
7
- module ConfigurationShapes
8
- ShapeDefaults = Struct.new(:type, :category, :x, :y, :w, :h, :style_modifiers, keyword_init: true)
9
- Shapes = Struct.new(
10
- :shape,
11
- {{#each shapes}}
12
- :{{snake ./type}},
13
- {{/each}}
14
- keyword_init: true
15
- )
16
-
17
- def add_shapes
18
- @shapes = Shapes.new(
19
- shape: ShapeDefaults.new(type: :shape, category: :element, x: 0, y: 0, w: 20, h: 20, style_modifiers: ''),
20
- {{#each shapes}}
21
- {{snake ./type}}: ShapeDefaults.new(type: :{{snake ./type}}, x: {{./x}}, category: :{{./category}}, y: {{./y}}, w: {{./w}}, h: {{./h}}, style_modifiers: '{{{./style_modifiers}}}'){{#if @last}}{{^}},{{/if}}
22
- {{/each}}
23
- )
24
- end
25
- end
26
- end
27
- # :nocov:
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
- module DrawioDsl
5
- # DrawioDsl is a DSL for draw-io diagrams.
6
- module DomBuilderShapes
7
- {{#each shapes}}
8
-
9
- def add_{{snake ./type}}(id = nil, **opts, &block)
10
- opts = { id: id }.merge(opts) if id
11
- {{snake ./type}} = DrawioDsl::Schema::{{camel ./type}}.new(current_page, **opts, &block)
12
- add_shape({{snake ./type}})
13
- end
14
- {{/each}}
15
- end
16
- end
17
- # :nocov:
@@ -1,58 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DrawioDsl
4
- # :nocov:
5
- # 1000's of extension shapes derived from Extensions.js that can be used via the add_shape method
6
- class DrawioExtensions
7
-
8
- attr_reader :sections
9
- attr_reader :current_section
10
-
11
- def initialize
12
- @sections = []
13
- end
14
-
15
- def section(name)
16
- @current_section = {
17
- name: name,
18
- shapes: []
19
- }
20
- @sections << current_section
21
-
22
- yield if block_given?
23
- end
24
-
25
- def shape(name, style, original_name)
26
- shape = {
27
- name: name,
28
- style: style,
29
- original_name: original_name
30
- }
31
- current_section[:shapes] << shape
32
- shape
33
- end
34
-
35
- def to_h
36
- {
37
- sections: @sections.map(&:to_h)
38
- }
39
- end
40
-
41
- # This methods was generated using Extensions.js
42
- # This generation can be improved over time and the code to do the generation
43
- # can be found in the .builders/generators/10-transform-drawio-js.rb.
44
- # original source: ~/dev/tools/drawio-desktop/drawio/src/main/webapp/js/diagramly/Extensions.js
45
- def build_extensions
46
- # Constants
47
- {{{constants}}}
48
- {{#each sections}}
49
- section :{{snake ./name}} do
50
- {{#each ./shapes}}
51
- shape :{{padr (snake ./name) 60}}, "{{{./style}}}", "{{./name}}"
52
- {{/each}}
53
- end
54
- {{/each}}
55
- end
56
- end
57
- # :nocov:
58
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DrawioDsl
4
- # List of DSL methods for each common shape
5
- # :nocov:
6
- module DrawioShapes
7
- def random(**opts)
8
- case rand({{shape_length}})
9
- {{#each shapes}}
10
- when {{@index}}
11
- {{snake ./type}}(**opts)
12
- {{/each}}
13
- end
14
- end
15
- {{#each shapes}}
16
-
17
- def {{snake ./type}}(id = nil, **opts, &block)
18
- builder.add_{{snake ./type}}(id, **opts, &block)
19
- end
20
- {{/each}}
21
- end
22
- # :nocov:
23
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'common_style'
4
- require_relative 'default_palette'
5
- require_relative 'diagram'
6
- require_relative 'node'
7
- require_relative 'node_list'
8
- require_relative 'page'
9
-
10
- require_relative 'layouts/layout'
11
- require_relative 'layouts/flex_layout'
12
- require_relative 'layouts/grid_layout'
13
-
14
- require_relative 'shapes/shape'
15
- {{#each shapes}}
16
- require_relative 'shapes/{{snake ./type}}'
17
- {{/each}}
18
-
19
- require_relative 'virtual/anchor'
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DrawioDsl
4
- module Schema
5
- class {{camel shape.type}} < Shape
6
- configure_shape(:{{snake shape.type}})
7
- end
8
- end
9
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe DrawioDsl::Schema::{{camel shape.type}} do
4
- include_context :node_dependencies
5
-
6
- subject { instance }
7
-
8
- let(:instance) { described_class.new(diagram, **args) }
9
- let(:args) { { id: 1 } }
10
- let(:default) { KConfig.configuration.drawio.shapes.{{snake shape.type}} }
11
-
12
- it_behaves_like :basic_shape_attributes
13
- end
data/.builders/_.rb DELETED
@@ -1 +0,0 @@
1
- # require_relative './path/here'
@@ -1,173 +0,0 @@
1
- m = KManager.model :shapes, namespace: %i[domain] do
2
- # microapp = import(:handlebars_helpers, :microapp)
3
-
4
- # other settings
5
- # strokeWidth: 1-n
6
- # when there is an arrow at beginning
7
- # startFill=1,0
8
- # when there is an arrow at end
9
- # endFill=1,0
10
-
11
-
12
- table :strokes do
13
- fields [:name, :style]
14
-
15
- row :dashed , 'dashed=1;fixDash=1'
16
- row :dotted , 'dashed=1;fixDash=1;dashPattern=1 4'
17
- row :dashdot , 'dashed=1;fixDash=1;dashPattern=10 5 1 5'
18
- row :dashdotdot , 'dashed=1;fixDash=1;dashPattern=10 5 1 5 1 5'
19
- row :dotdotdot , 'dashed=1;fixDash=1;dashPattern=1 2'
20
- row :longdash , 'dashed=1;fixDash=1;dashPattern=16 6'
21
- row :dashlongdash , 'dashed=1;fixDash=1;dashPattern=10 6 16 6'
22
- row :dashed24 , 'dashed=1;fixDash=1;dashPattern=3 8'
23
- row :dashed32 , 'dashed=1;fixDash=1;dashPattern=6 5'
24
- row :dashed44 , 'dashed=1;fixDash=1;dashPattern=8 8'
25
- end
26
-
27
- table :connector_compass do
28
- fields %i[name x y]
29
-
30
- row :n , x: 0.5 , y: 0 # 'exitX=0.5;exitY=0;exitDx=0;exitDy=0' 'entryX=0.5;entryY=0;entryDx=0;entryDy=0'
31
- row :ne , x: 1 , y: 0 # 'exitX=1;exitY=0;exitDx=0;exitDy=0' 'entryX=1;entryY=0;entryDx=0;entryDy=0'
32
- row :e , x: 1 , y: 0.5 # 'exitX=1;exitY=0.5;exitDx=0;exitDy=0' 'entryX=1;entryY=0.5;entryDx=0;entryDy=0'
33
- row :se , x: 1 , y: 1 # 'exitX=1;exitY=1;exitDx=0;exitDy=0' 'entryX=1;entryY=1;entryDx=0;entryDy=0'
34
- row :s , x: 0.5 , y: 1 # 'exitX=0.5;exitY=1;exitDx=0;exitDy=0' 'entryX=0.5;entryY=1;entryDx=0;entryDy=0'
35
- row :sw , x: 0 , y: 1 # 'exitX=0;exitY=1;exitDx=0;exitDy=0' 'entryX=0;entryY=1;entryDx=0;entryDy=0'
36
- row :w , x: 0 , y: 0.5 # 'exitX=0;exitY=0.5;exitDx=0;exitDy=0' 'entryX=0;entryY=0.5;entryDx=0;entryDy=0'
37
- row :nw , x: 0 , y: 0 # 'exitX=0;exitY=0;exitDx=0;exitDy=0' 'entryX=0;entryY=0;entryDx=0;entryDy=0'
38
- end
39
-
40
- table :connector_design do
41
- fields [:name, :style]
42
-
43
- row :style1, ''
44
- row :style2, 'shape=link'
45
- row :style3, 'shape=flexArrow'
46
- row :style4, 'shape=arrow'
47
- end
48
-
49
- table :connector_arrows do
50
- fields [:name, :style]
51
-
52
- row :simple , 'open'
53
- row :triangle , 'block'
54
- row :diamond , 'diamond'
55
- row :circle , 'oval'
56
- row :cross , 'cross'
57
- row :short , 'classicThin'
58
- row :default , 'classic'
59
- row :none , 'none'
60
- row :plain , 'open'
61
- row :skewed_dash , 'dash'
62
- row :concave , 'openThin'
63
- row :er_many , 'ERmany'
64
- row :er_one , 'ERone'
65
- row :er_one_optional , 'ERzeroToOne'
66
- row :er_one_mandatory , 'ERmandOne'
67
- row :er_many_optional , 'ERzeroToMany'
68
- row :er_many_mandatory , 'ERoneToMany'
69
- end
70
-
71
- table :connector_waypoints do # aka edgeStyle
72
- fields [:name, :style]
73
-
74
- row :straight , 'edgeStyle=none'
75
- row :orthogonal , 'edgeStyle=orthogonalEdgeStyle'
76
- row :elbow , 'edgeStyle=elbowEdgeStyle'
77
- row :elbow_vertical , 'edgeStyle=elbowEdgeStyle;elbow=vertical'
78
- row :isometric , 'edgeStyle=isometricEdgeStyle'
79
- row :isometric_vertical , 'edgeStyle=isometricEdgeStyle;elbow=vertical'
80
- row :orthogonal_curved , 'edgeStyle=orthogonalEdgeStyle;curved=1'
81
- row :entity_relation , 'edgeStyle=entityRelationEdgeStyle'
82
- end
83
-
84
- table :shapes do
85
- fields [:type, :category, :x, :y, :w, :h, :style_modifiers]
86
-
87
- # shape is a custom object
88
- # row :shape , 0, 0, 20, 20, ''
89
-
90
- row :line , :line , 0, 0, 50, 50, 'edgeStyle=none;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0'
91
- # row :line , :line , 0, 0, 50, 50, 'edgeStyle=entityRelationEdgeStyle;strokeWidth=1;elbow=vertical;startArrow=none;startFill=0;endArrow=block;endFill=0;targetPerimeterSpacing=0;shape=flexArrow;endSize=6;fillStyle=zigzag;'
92
- # row :dashed , 'dashed=1;fixDash=1'
93
- # row :dotted , 'dashed=1;fixDash=1;dashPattern=1 4'
94
- # row :dashdot , 'dashed=1;fixDash=1;dashPattern=10 5 1 5'
95
- # row :dashdotdot , 'dashed=1;fixDash=1;dashPattern=10 5 1 5 1 5'
96
- # row :dotdotdot , 'dashed=1;fixDash=1;dashPattern=1 2'
97
- # row :longdash , 'dashed=1;fixDash=1;dashPattern=16 6'
98
- # row :dashlongdash , 'dashed=1;fixDash=1;dashPattern=10 6 16 6'
99
- # row :dashed24 , 'dashed=1;fixDash=1;dashPattern=3 8'
100
- # row :dashed32 , 'dashed=1;fixDash=1;dashPattern=6 5'
101
- # row :dashed44 , 'dashed=1;fixDash=1;dashPattern=8 8'
102
- # edge="1" parent="node_root_2T8" source="b" target="c"
103
-
104
- # configuration for general purpose shapes
105
- row :h1 , :text , 0, 0, 100, 50, 'text;fontSize=89;fontColor=#ffffff;fontStyle=1;fillColor=none'
106
- row :h2 , :text , 0, 0, 100, 50, 'text;fontSize=67;fontColor=#ffffff;fontStyle=1;fillColor=none'
107
- row :h3 , :text , 0, 0, 100, 50, 'text;fontSize=50;fontColor=#ffffff;fontStyle=1;fillColor=none'
108
- row :h4 , :text , 0, 0, 100, 50, 'text;fontSize=37;fontColor=#ffffff;fontStyle=1;fillColor=none'
109
- row :h5 , :text , 0, 0, 100, 50, 'text;fontSize=28;fontColor=#ffffff;fontStyle=1;fillColor=none'
110
- row :h6 , :text , 0, 0, 100, 50, 'text;fontSize=21;fontColor=#ffffff;fontStyle=1;fillColor=none'
111
- row :p , :text , 0, 0, 100, 50, 'text;fontSize=16;fontColor=#ffffff;fontStyle=1;fillColor=none'
112
-
113
- row :actor , :element, 0, 0, 40, 50, 'shape=actor'
114
- row :actor2 , :element, 0, 0, 30, 50, 'shape=umlActor;verticalLabelPosition=bottom;outlineConnect=1'
115
- row :callout , :element, 0, 0, 160, 120, 'shape=callout'
116
- row :callout2 , :element, 0, 0, 160, 160, 'shape=mxgraph.basic.oval_callout'
117
- row :callout3 , :element, 0, 0, 160, 160, 'shape=mxgraph.basic.cloud_callout'
118
- row :callout4 , :element, 0, 0, 160, 120, 'shape=mxgraph.basic.roundRectCallout;dx=30;dy=15;size=5;boundedLbl=1;'
119
- row :circle , :element, 0, 0, 160, 160, 'ellipse'
120
- row :cloud , :element, 0, 0, 160, 160, 'shape=cloud'
121
- row :container , :element, 0, 0, 160, 160, 'swimlane'
122
- row :container2 , :element, 0, 0, 160, 160, 'swimlane;horizontal=0'
123
- row :container3 , :element, 0, 0, 160, 160, 'swimlane;startSize=50'
124
- row :container4 , :element, 0, 0, 160, 160, 'swimlane;resizable=0'
125
- row :cross , :element, 0, 0, 50, 50, 'verticalLabelPosition=bottom;verticalAlign=top;html=1;shape=mxgraph.basic.x'
126
- row :envelop , :element, 0, 0, 160, 100, 'shape=message'
127
- row :database , :element, 0, 0, 160, 80, 'shape=mxgraph.flowchart.database;strokeWidth=1'
128
- row :db_json , :element, 0, 0, 160, 40, 'shape=mxgraph.flowchart.database;strokeWidth=1'
129
- row :diamond , :element, 0, 0, 100, 100, 'rhombus'
130
- row :document , :element, 0, 0, 160, 160, 'shape=mxgraph.basic.document'
131
- row :ellipse , :element, 0, 0, 200, 120, 'ellipse'
132
- row :group , :element, 0, 0, 210, 210, 'fontSize=20;verticalAlign=top'
133
- row :hexagon , :element, 0, 0, 200, 120, 'shape=hexagon'
134
- row :interface , :element, 0, 0, 160, 160, 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'
135
- row :klass , :element, 0, 0, 160, 160, 'align=left;overflow=fill;fontSize=12;fontFamily=Helvetica'
136
- row :note , :element, 0, 0, 160, 160, 'shape=note'
137
- row :process , :element, 0, 0, 200, 120, 'shape=process'
138
- row :rectangle , :element, 0, 0, 200, 120, ''
139
- row :rectangle2 , :element, 0, 0, 200, 120, 'shape=mxgraph.basic.cloud_rect'
140
- row :square , :element, 0, 0, 160, 160, ''
141
- row :step , :element, 0, 0, 120, 80, 'shape=step;perimeter=stepPerimeter;fixedSize=1'
142
- row :tick , :element, 0, 0, 50, 50, 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.tick'
143
- row :todo , :element, 0, 0, 300, 60, ''
144
- row :face , :element, 0, 0, 100, 100, 'verticalLabelPosition=bottom;verticalAlign=top;shape=mxgraph.basic.smiley'
145
- row :triangle , :element, 0, 0, 100, 100, 'triangle'
146
-
147
- # configuration for embedded element shape
148
- # note that the width / height probably should be driven of parent shape
149
- row :embed_row , :element, 0, 0, 200, 40, 'shape=partialRectangle;collapsible=0;dropTarget=0;pointerEvents=0;top=0;left=0;bottom=1;right=0;points=[[0,0.5],[1,0.5]];portConstraint=eastwest'
150
- row :embed_col50 , :element, 0, 0, 50, 40, 'shape=partialRectangle;connectable=0;top=0;left=0;bottom=0;right=0;fontStyle=1;overflow=hidden'
151
- row :embed_col200 , :element, 0, 0, 150, 40, 'shape=partialRectangle;connectable=0;top=0;left=0;bottom=0;right=0;align=left;spacingLeft=6;overflow=hidden'
152
- end
153
-
154
- action do
155
- data = self.raw_data
156
- content = {
157
- strokes: data['strokes'],
158
- connector: {
159
- compass: data['connector_compass'],
160
- waypoints: data['connector_waypoints'],
161
- arrows: data['connector_arrows'],
162
- design: data['connector_design']
163
- },
164
- shapes: data['shapes'],
165
- }
166
-
167
- k_builder
168
- .cd(:data)
169
- .add_file('shapes.json', content: JSON.pretty_generate(content), on_exist: :write)
170
- end
171
- end
172
-
173
-
data/.builders/boot.rb DELETED
@@ -1,72 +0,0 @@
1
- # Boot Sequence
2
-
3
- include KLog::Logging
4
-
5
- CONFIG_KEY = :drawio_dsl
6
-
7
- log.kv 'working folder', Dir.pwd
8
-
9
- Handlebars::Helpers.configure do |config|
10
- config.helper_config_file = File.join(Gem.loaded_specs['handlebars-helpers'].full_gem_path, '.handlebars_helpers.json')
11
- config.string_formatter_config_file = File.join(Gem.loaded_specs['handlebars-helpers'].full_gem_path, '.handlebars_string_formatters.json')
12
- end
13
-
14
- def camel
15
- require 'handlebars/helpers/string_formatting/camel'
16
- Handlebars::Helpers::StringFormatting::Camel.new
17
- end
18
-
19
- def titleize
20
- require 'handlebars/helpers/string_formatting/titleize'
21
- Handlebars::Helpers::StringFormatting::Titleize.new
22
- end
23
-
24
- def pluralize
25
- require 'handlebars/helpers/inflection/pluralize'
26
- Handlebars::Helpers::Inflection::Pluralize.new
27
- end
28
-
29
- def singularize
30
- require 'handlebars/helpers/inflection/singularize'
31
- Handlebars::Helpers::Inflection::Singularize.new
32
- end
33
-
34
- def dasherize
35
- require 'handlebars/helpers/string_formatting/dasherize'
36
- Handlebars::Helpers::StringFormatting::Dasherize.new
37
- end
38
-
39
- def k_builder
40
- @k_builder ||= KBuilder::BaseBuilder.init(KConfig.configuration(CONFIG_KEY))
41
- end
42
-
43
- KConfig.configure(CONFIG_KEY) do |config|
44
- builder_folder = Dir.pwd
45
- base_folder = File.expand_path('../', builder_folder)
46
- global_template = File.expand_path('~/dev/kgems/k_templates/templates')
47
-
48
- # Templates
49
- config.template_folders.add(:global_template , global_template)
50
- config.template_folders.add(:template , File.expand_path('.templates', Dir.pwd))
51
-
52
- # Target Folders
53
- config.target_folders.add(:app , base_folder)
54
- config.target_folders.add(:lib , :app, 'lib', 'drawio_dsl')
55
- config.target_folders.add(:spec , :app, 'spec', 'drawio_dsl')
56
- config.target_folders.add(:docs , :app, 'docs')
57
- config.target_folders.add(:builder , builder_folder)
58
- config.target_folders.add(:data , :builder, '.data')
59
- end
60
-
61
- KConfig.configuration(CONFIG_KEY).debug
62
-
63
- area = KManager.add_area(CONFIG_KEY)
64
- resource_manager = area.resource_manager
65
- resource_manager
66
- .fileset
67
- .glob('*.rb', exclude: ['boot.rb'])
68
- .glob('generators/**/*.rb')
69
- .glob('blueprint/**/*.rb')
70
- resource_manager.add_resources
71
-
72
- KManager.boot
@@ -1,130 +0,0 @@
1
- KManager.action :bootstrap do
2
- action do
3
- application_name = :drawio_dsl
4
- director = KDirector::Dsls::RubyGemDsl
5
- .init(k_builder,
6
- on_exist: :skip, # %i[skip write compare]
7
- on_action: :queue # %i[queue execute]
8
- )
9
- .data(
10
- ruby_version: '2.7',
11
- application: application_name,
12
- application_description: 'DrawIO DSL can build DrawIO diagrams using a Domain Specific Language',
13
- application_lib_path: application_name.to_s,
14
- application_lib_namespace: 'DrawioDsl',
15
- namespaces: ['DrawioDsl'],
16
- author: 'David Cruwys',
17
- author_email: 'david@ideasmen.com.au',
18
- initial_semver: '0.0.1',
19
- main_story: 'As a Developer, I to use natural language to build diagrams quickly, so that I can create visual documentation',
20
- copyright_date: '2022',
21
- website: 'http://appydave.com/gems/drawio_dsl'
22
- )
23
- .github(
24
- active: false,
25
- repo_name: application_name
26
- ) do
27
- create_repository
28
- # delete_repository
29
- # list_repositories
30
- open_repository
31
- # run_command('git init')
32
- end
33
- .blueprint(
34
- active: false,
35
- name: :bin_hook,
36
- description: 'initialize repository',
37
- on_exist: :write) do
38
-
39
- cd(:app)
40
-
41
- run_template_script('bin/runonce/git-setup.sh', dom: dom)
42
-
43
- add('.githooks/commit-msg').run_command('chmod +x .githooks/commit-msg')
44
- add('.githooks/pre-commit').run_command('chmod +x .githooks/pre-commit')
45
-
46
- add('.gitignore')
47
-
48
- run_command('git config core.hooksPath .githooks') # enable sharable githooks (developer needs to turn this on before editing rep)
49
-
50
- run_command("git add .; git commit -m 'chore: #{self.options.description.downcase}'; git push")
51
- run_command("gh repo edit -d \"#{dom[:application_description]}\"")
52
- end
53
- .package_json(
54
- active: false,
55
- name: :package_json,
56
- description: 'Set up the package.json file for semantic versioning'
57
- ) do
58
- self
59
- .add('package.json', dom: dom)
60
- .play_actions
61
-
62
- self
63
- .add_script('release', 'semantic-release')
64
- .sort
65
- .development
66
- .npm_add_group('semver-ruby')
67
-
68
- run_command("git add .; git commit -m 'chore: #{self.options.description.downcase}'; git push")
69
- end
70
- .blueprint(
71
- active: false,
72
- name: :opinionated,
73
- description: 'opinionated GEM files',
74
- on_exist: :write) do
75
-
76
- cd(:app)
77
-
78
- add('bin/setup')
79
- add('bin/console')
80
-
81
- add("lib/#{typed_dom.application}.rb" , template_file: 'lib/applet_name.rb' , dom: dom)
82
- add("lib/#{typed_dom.application}/version.rb" , template_file: 'lib/applet_name/version.rb' , dom: dom)
83
-
84
- add('spec/spec_helper.rb')
85
- add("spec/#{typed_dom.application}_spec.rb" , template_file: 'spec/applet_name_spec.rb', dom: dom)
86
-
87
- add("#{typed_dom.application}.gemspec" , template_file: 'applet_name.gemspec', dom: dom)
88
- add('Gemfile', dom: dom)
89
- add('Guardfile', dom: dom)
90
- add('Rakefile', dom: dom)
91
- add('.rspec', dom: dom)
92
- add('.rubocop.yml', dom: dom)
93
- add('README.md', dom: dom)
94
- add('CODE_OF_CONDUCT.md', dom: dom)
95
- add('LICENSE.txt', dom: dom)
96
-
97
- run_command("rubocop -a")
98
-
99
- run_command("git add .; git commit -m 'chore: #{self.options.description.downcase}'; git push")
100
- end
101
- .blueprint(
102
- active: false,
103
- name: :ci_cd,
104
- description: 'github actions (CI/CD)',
105
- on_exist: :write) do
106
-
107
- cd(:app)
108
-
109
- run_command("gh secret set SLACK_WEBHOOK --body \"$SLACK_REPO_WEBHOOK\"")
110
- run_command("gh secret set GEM_HOST_API_KEY --body \"$GEM_HOST_API_KEY\"")
111
-
112
- add('.github/workflows/main.yml')
113
- add('.releaserc.json')
114
-
115
- run_command("git add .; git commit -m 'chore: #{self.options.description.downcase}'; git push")
116
- end
117
-
118
- director.play_actions
119
- # director.builder.logit
120
- end
121
- end
122
-
123
- KManager.opts.app_name = 'drawio_dsl'
124
- KManager.opts.sleep = 2
125
- KManager.opts.reboot_on_kill = 0
126
- KManager.opts.reboot_sleep = 4
127
- KManager.opts.exception_style = :short
128
- KManager.opts.show.time_taken = true
129
- KManager.opts.show.finished = true
130
- KManager.opts.show.finished_message = 'FINISHED :)'
@@ -1,47 +0,0 @@
1
- KManager.action :requires do
2
-
3
- action do
4
- shapes_file = k_builder.target_folders.get_filename(:data, 'shapes.json')
5
- shapes_configuration = JSON.parse(File.read(shapes_file))
6
- shapes = shapes_configuration['shapes']
7
- # strokes = shapes_configuration['strokes']
8
-
9
- KDirector::Dsls::BasicDsl
10
- .init(k_builder,
11
- on_exist: :write, # %i[skip write compare]
12
- on_action: :execute # %i[queue execute]
13
- )
14
- .blueprint(
15
- active: true,
16
- on_exist: :write) do
17
-
18
- cd(:lib)
19
-
20
- add('schema/_.rb', template_file: 'schema_require.rb', shapes: shapes)
21
-
22
- # build source code for each shape
23
- shapes.each do |shape|
24
- add("schema/shapes/#{shape['type']}.rb",
25
- template_file: 'schema_shape.rb',
26
- shape: shape)
27
- end
28
-
29
- add("drawio_shapes.rb" , template_file: 'drawio_shapes.rb' , shapes: shapes, shape_length: shapes.length)
30
- add("dom_builder_shapes.rb" , template_file: 'dom_builder_shapes.rb' , shapes: shapes)
31
- add("configuration_shapes.rb" , template_file: 'configuration_shapes.rb', shapes: shapes)
32
-
33
- cd(:spec)
34
-
35
- # build spec for each shape
36
- shapes.each do |shape|
37
- add("schema/shapes/#{shape['type']}_spec.rb",
38
- template_file: 'schema_shape_spec.rb',
39
- shape: shape)
40
- end
41
-
42
- cd(:app)
43
- run_command('rubocop -a')
44
-
45
- end
46
- end
47
- end