k_manager 0.0.28 → 0.0.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/k_manager +0 -1
- data/lib/k_manager/cli/new.rb +29 -10
- data/lib/k_manager/document_import/build_tag.rb +20 -0
- data/lib/k_manager/document_import/extension.rb +20 -0
- data/lib/k_manager/document_import/importer.rb +13 -0
- data/lib/k_manager/manager.rb +24 -13
- data/lib/k_manager/overview/models.rb +3 -1
- data/lib/k_manager/version.rb +1 -1
- data/lib/k_manager.rb +3 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e37f7eaec478502778d24559e32635bf448788a5f89598961b3b5dc1d2109168
|
4
|
+
data.tar.gz: f51fe8850fdab828076e197902b88037aa99527e8c9f5faab4ab11ff4eec7c33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64d7a94731b67333f2d271c6b0fe9b04841b3d0a4fdaa7fa014a04af5fd3bb38ff888ded7b96ea74bef3f8239f5759f4edc5ffa9c5e02ddfaca4dba197d88f63
|
7
|
+
data.tar.gz: a7ce44a02dde86c04c40481ac56dc73adf3340e538f183b51dbd61e02cb122674d3decd58451acffda39351ae9d3d657230a4489bf1fd6b67297ca6afb4a686b
|
data/exe/k_manager
CHANGED
data/lib/k_manager/cli/new.rb
CHANGED
@@ -28,6 +28,19 @@ module KManager
|
|
28
28
|
default: nil,
|
29
29
|
desc: 'Log level, use debug for more info'
|
30
30
|
|
31
|
+
option :description,
|
32
|
+
default: nil,
|
33
|
+
aliases: ['-d'],
|
34
|
+
desc: 'Application description'
|
35
|
+
|
36
|
+
option :user_story,
|
37
|
+
default: nil,
|
38
|
+
desc: 'Main user story'
|
39
|
+
|
40
|
+
option :repo_organization,
|
41
|
+
default: nil,
|
42
|
+
desc: 'Repository organization'
|
43
|
+
|
31
44
|
example [
|
32
45
|
' # Project in current directory - will create a .builders folder and boot file at ./builders/boot.rb',
|
33
46
|
'-b ../config/boot.rb # Project in current directory - will create a .builders folder and boot file at ./config/boot.rb',
|
@@ -36,32 +49,34 @@ module KManager
|
|
36
49
|
]
|
37
50
|
|
38
51
|
# rubocop:disable Metrics/ParameterLists
|
39
|
-
def call(project_folder:, builder_folder:, log_level:, force:, template:, **)
|
52
|
+
def call(project_folder:, builder_folder:, log_level:, force:, template:, **opts)
|
40
53
|
project_folder = absolute_path(project_folder, Dir.pwd)
|
41
54
|
name = File.basename(project_folder)
|
42
55
|
builder_folder = absolute_path(builder_folder, project_folder)
|
43
56
|
template_root_folder = File.expand_path('~/dev/kgems/k_templates/definitions/starter')
|
44
57
|
|
45
|
-
log_params(name, project_folder, builder_folder, force, log_level, template_root_folder, template) if log_level == 'debug'
|
58
|
+
log_params(name, project_folder, builder_folder, force, log_level, template_root_folder, template, **opts) if log_level == 'debug'
|
46
59
|
|
47
|
-
create_project(name, project_folder, builder_folder, template_root_folder, template) if can_create?(force, builder_folder)
|
60
|
+
create_project(name, project_folder, builder_folder, template_root_folder, template, **opts) if can_create?(force, builder_folder)
|
48
61
|
end
|
49
62
|
# rubocop:enable Metrics/ParameterLists
|
50
63
|
|
51
64
|
private
|
52
65
|
|
53
|
-
|
66
|
+
# rubocop:disable Metrics/ParameterLists
|
67
|
+
def create_project(name, project_folder, builder_folder, template_root_folder, template, **opts)
|
54
68
|
FileUtils.mkdir_p(project_folder)
|
55
69
|
FileUtils.mkdir_p(builder_folder)
|
56
70
|
|
57
71
|
# handle_main_start_command
|
58
72
|
|
59
|
-
setup_builder_from_template(name, builder_folder, template_root_folder, 'default') unless setup_builder_from_template(name, builder_folder, template_root_folder, template)
|
73
|
+
setup_builder_from_template(name, builder_folder, template_root_folder, 'default', **opts) unless setup_builder_from_template(name, builder_folder, template_root_folder, template, **opts)
|
60
74
|
|
61
75
|
log.info 'Project created'
|
62
76
|
end
|
77
|
+
# rubocop:enable Metrics/ParameterLists
|
63
78
|
|
64
|
-
def setup_builder_from_template(name, builder_folder, template_root_folder, template
|
79
|
+
def setup_builder_from_template(name, builder_folder, template_root_folder, template, **opts)
|
65
80
|
return false unless template
|
66
81
|
|
67
82
|
# /Users/davidcruwys/dev/kgems/k_templates/definitions/starter/ruby_gem/.starter.json
|
@@ -75,7 +90,7 @@ module KManager
|
|
75
90
|
return false if starter_config['files'].nil? || starter_config['files'].empty?
|
76
91
|
|
77
92
|
starter_config['files']&.each do |relative_file|
|
78
|
-
builder.add_file(relative_file, template_file: relative_file, name: name)
|
93
|
+
builder.add_file(relative_file, template_file: relative_file, **{ name: name }.merge(opts))
|
79
94
|
end
|
80
95
|
end
|
81
96
|
|
@@ -112,8 +127,8 @@ module KManager
|
|
112
127
|
false
|
113
128
|
end
|
114
129
|
|
115
|
-
# rubocop:disable Metrics/ParameterLists
|
116
|
-
def log_params(name, project_folder, builder_folder, force, log_level, template_root_folder, template)
|
130
|
+
# rubocop:disable Metrics/ParameterLists, Metrics/AbcSize
|
131
|
+
def log_params(name, project_folder, builder_folder, force, log_level, template_root_folder, template, **opts)
|
117
132
|
log.section_heading('Create new project')
|
118
133
|
log.kv 'name' , name
|
119
134
|
log.kv 'project_folder' , project_folder
|
@@ -122,8 +137,12 @@ module KManager
|
|
122
137
|
log.kv 'log_level' , log_level
|
123
138
|
log.kv 'template_root_folder' , template_root_folder
|
124
139
|
log.kv 'template' , template
|
140
|
+
|
141
|
+
opts.each do |key, value|
|
142
|
+
log.kv key, value
|
143
|
+
end
|
125
144
|
end
|
126
|
-
# rubocop:enable Metrics/ParameterLists
|
145
|
+
# rubocop:enable Metrics/ParameterLists, Metrics/AbcSize
|
127
146
|
end
|
128
147
|
end
|
129
148
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module KManager
|
4
|
+
# Allow existing documents from KDoc and other sources to be imported using the resource manager
|
5
|
+
module DocumentImport
|
6
|
+
class BuildTag
|
7
|
+
include KDoc::Taggable
|
8
|
+
|
9
|
+
def initialize(key:, type: :container, namespace: nil)
|
10
|
+
opts = {
|
11
|
+
key: key,
|
12
|
+
type: type,
|
13
|
+
namespace: namespace
|
14
|
+
}
|
15
|
+
|
16
|
+
initialize_tag(opts)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module KManager
|
4
|
+
# Alow existing documents from KDoc and other sources to be imported using the resource manager
|
5
|
+
module DocumentImport
|
6
|
+
module Extension
|
7
|
+
include KLog::Logging
|
8
|
+
|
9
|
+
def import(tag)
|
10
|
+
# KManager.find_document(tag)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
KDoc::Action.include(KManager::DocumentImport::Extension)
|
17
|
+
KDoc::Model.include(KManager::DocumentImport::Extension)
|
18
|
+
KDoc::CsvDoc.include(KManager::DocumentImport::Extension)
|
19
|
+
KDoc::JsonDoc.include(KManager::DocumentImport::Extension)
|
20
|
+
KDoc::YamlDoc.include(KManager::DocumentImport::Extension)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module KManager
|
4
|
+
# Allow existing documents from KDoc and other sources to be imported using the resource manager
|
5
|
+
module DocumentImport
|
6
|
+
# Find a document by tag for importing
|
7
|
+
class Importer
|
8
|
+
def import(tag, area: nil)
|
9
|
+
KManager.find_document(tag, area: area)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/k_manager/manager.rb
CHANGED
@@ -5,6 +5,8 @@ module KManager
|
|
5
5
|
#
|
6
6
|
# TODO: Write Tests
|
7
7
|
class Manager
|
8
|
+
include KLog::Logging
|
9
|
+
|
8
10
|
attr_accessor :active_uri
|
9
11
|
|
10
12
|
# NOTE: rename current_resource to active_resource, focused_resource?
|
@@ -65,6 +67,24 @@ module KManager
|
|
65
67
|
@areas ||= []
|
66
68
|
end
|
67
69
|
|
70
|
+
# List of resources for an area.
|
71
|
+
#
|
72
|
+
# if area is nil, then return resources for the area matching the current_resource
|
73
|
+
def area_resources(area: nil)
|
74
|
+
area = resolve_area(area)
|
75
|
+
|
76
|
+
log.error 'Could not resolve area' if area.nil?
|
77
|
+
|
78
|
+
area&.resources
|
79
|
+
end
|
80
|
+
|
81
|
+
# List of documents for an area.
|
82
|
+
#
|
83
|
+
# if area is nil, for the area matching the current_resource
|
84
|
+
def area_documents(area: nil)
|
85
|
+
area_resources(area: area)&.flat_map(&:documents)
|
86
|
+
end
|
87
|
+
|
68
88
|
def add_area(name, namespace: nil)
|
69
89
|
area = find_area(name)
|
70
90
|
|
@@ -76,16 +96,7 @@ module KManager
|
|
76
96
|
end
|
77
97
|
|
78
98
|
def find_document(tag, area: nil)
|
79
|
-
area
|
80
|
-
|
81
|
-
log.error 'Could not resolve area' if area.nil?
|
82
|
-
|
83
|
-
log.line
|
84
|
-
log.error(tag)
|
85
|
-
log.line
|
86
|
-
|
87
|
-
documents = area.resources.flat_map(&:documents)
|
88
|
-
documents.find { |d| d.tag == tag }
|
99
|
+
area_documents(area: area)&.find { |d| d.tag == tag }
|
89
100
|
end
|
90
101
|
|
91
102
|
def fire_actions(*actions)
|
@@ -101,14 +112,14 @@ module KManager
|
|
101
112
|
|
102
113
|
def resolve_area(area)
|
103
114
|
if area.nil?
|
104
|
-
return
|
115
|
+
return current_resource.area if current_resource
|
105
116
|
|
106
|
-
return
|
117
|
+
return areas.first
|
107
118
|
end
|
108
119
|
|
109
120
|
return area if area.is_a?(Area)
|
110
121
|
|
111
|
-
find_area(
|
122
|
+
find_area(area)
|
112
123
|
end
|
113
124
|
|
114
125
|
# Return a list of resources for a URI.
|
@@ -64,7 +64,9 @@ module KManager
|
|
64
64
|
attribute :document_id , Types::Strict::Integer
|
65
65
|
attribute :document_data , Types::Strict::Any.optional.default # Hash.optional.default(nil) | Types::Strict::Array.of(Types::Strict::Hash).optional.default(nil)
|
66
66
|
attribute :document_key , Types::Strict::String | Types::Strict::Symbol
|
67
|
-
attribute :document_namespace , Types::Strict::String | Types::Strict::
|
67
|
+
attribute :document_namespace , Types::Strict::String | Types::Strict::Symbol |
|
68
|
+
Types::Strict::Array.of(Types::Strict::String).optional.default(nil) |
|
69
|
+
Types::Strict::Array.of(Types::Strict::Symbol).optional.default(nil)
|
68
70
|
attribute :document_tag , Types::Strict::String | Types::Strict::Symbol
|
69
71
|
attribute :document_type , Types::Strict::String | Types::Strict::Symbol
|
70
72
|
# TODO: Write code to populate this with the resource line number
|
data/lib/k_manager/version.rb
CHANGED
data/lib/k_manager.rb
CHANGED
@@ -29,6 +29,9 @@ require 'k_manager/resources/mem_resource'
|
|
29
29
|
require 'k_manager/resources/resource_document_factory'
|
30
30
|
require 'k_manager/resources/resource_factory'
|
31
31
|
require 'k_manager/resources/resource_manager'
|
32
|
+
require 'k_manager/document_import/build_tag'
|
33
|
+
require 'k_manager/document_import/importer'
|
34
|
+
require 'k_manager/document_import/extension'
|
32
35
|
require 'k_manager/document_factory'
|
33
36
|
require 'k_manager/manager'
|
34
37
|
require 'k_manager/area'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: k_manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-struct
|
@@ -191,6 +191,9 @@ files:
|
|
191
191
|
- lib/k_manager/cli/version.rb
|
192
192
|
- lib/k_manager/cli/watch.rb
|
193
193
|
- lib/k_manager/document_factory.rb
|
194
|
+
- lib/k_manager/document_import/build_tag.rb
|
195
|
+
- lib/k_manager/document_import/extension.rb
|
196
|
+
- lib/k_manager/document_import/importer.rb
|
194
197
|
- lib/k_manager/manager.rb
|
195
198
|
- lib/k_manager/overview/dashboard.rb
|
196
199
|
- lib/k_manager/overview/dump_json.rb
|