pdk 1.13.0 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +25 -0
- data/README.md +41 -0
- data/lib/pdk.rb +0 -13
- data/lib/pdk/analytics.rb +18 -2
- data/lib/pdk/analytics/client/google_analytics.rb +3 -0
- data/lib/pdk/answer_file.rb +4 -1
- data/lib/pdk/cli.rb +7 -2
- data/lib/pdk/cli/build.rb +2 -2
- data/lib/pdk/cli/bundle.rb +7 -1
- data/lib/pdk/cli/console.rb +148 -0
- data/lib/pdk/cli/convert.rb +2 -2
- data/lib/pdk/cli/exec.rb +14 -14
- data/lib/pdk/cli/exec/command.rb +16 -11
- data/lib/pdk/cli/exec/interactive_command.rb +4 -0
- data/lib/pdk/cli/exec_group.rb +5 -5
- data/lib/pdk/cli/module/build.rb +0 -2
- data/lib/pdk/cli/module/generate.rb +1 -2
- data/lib/pdk/cli/new.rb +1 -1
- data/lib/pdk/cli/new/defined_type.rb +2 -0
- data/lib/pdk/cli/new/provider.rb +2 -0
- data/lib/pdk/cli/new/task.rb +2 -0
- data/lib/pdk/cli/new/{unit_test.rb → test.rb} +16 -12
- data/lib/pdk/cli/new/transport.rb +2 -0
- data/lib/pdk/cli/test/unit.rb +5 -3
- data/lib/pdk/cli/update.rb +2 -3
- data/lib/pdk/cli/util.rb +45 -14
- data/lib/pdk/cli/util/spinner.rb +2 -2
- data/lib/pdk/cli/validate.rb +6 -2
- data/lib/pdk/config.rb +20 -8
- data/lib/pdk/config/analytics_schema.json +26 -0
- data/lib/pdk/config/json.rb +14 -3
- data/lib/pdk/config/json_schema_namespace.rb +143 -0
- data/lib/pdk/config/json_schema_setting.rb +53 -0
- data/lib/pdk/config/json_with_schema.rb +50 -0
- data/lib/pdk/config/namespace.rb +84 -76
- data/lib/pdk/config/setting.rb +132 -0
- data/lib/pdk/config/yaml.rb +15 -3
- data/lib/pdk/config/yaml_with_schema.rb +59 -0
- data/lib/pdk/generate.rb +0 -2
- data/lib/pdk/generate/module.rb +29 -16
- data/lib/pdk/generate/puppet_object.rb +31 -28
- data/lib/pdk/module.rb +2 -2
- data/lib/pdk/module/build.rb +21 -8
- data/lib/pdk/module/convert.rb +64 -7
- data/lib/pdk/module/metadata.rb +5 -1
- data/lib/pdk/module/templatedir.rb +24 -7
- data/lib/pdk/module/update.rb +5 -1
- data/lib/pdk/module/update_manager.rb +21 -13
- data/lib/pdk/report.rb +4 -3
- data/lib/pdk/report/event.rb +5 -3
- data/lib/pdk/tests/unit.rb +36 -7
- data/lib/pdk/util.rb +20 -8
- data/lib/pdk/util/bundler.rb +14 -6
- data/lib/pdk/util/filesystem.rb +5 -0
- data/lib/pdk/util/git.rb +6 -0
- data/lib/pdk/util/puppet_strings.rb +24 -2
- data/lib/pdk/util/puppet_version.rb +25 -10
- data/lib/pdk/util/ruby_version.rb +13 -1
- data/lib/pdk/util/template_uri.rb +23 -2
- data/lib/pdk/util/vendored_file.rb +28 -24
- data/lib/pdk/util/version.rb +5 -5
- data/lib/pdk/validate/base_validator.rb +5 -4
- data/lib/pdk/validate/metadata/metadata_json_lint.rb +0 -4
- data/lib/pdk/validate/metadata/metadata_syntax.rb +5 -3
- data/lib/pdk/validate/metadata_validator.rb +0 -2
- data/lib/pdk/validate/puppet/puppet_epp.rb +4 -4
- data/lib/pdk/validate/puppet/puppet_lint.rb +0 -3
- data/lib/pdk/validate/puppet/puppet_syntax.rb +4 -4
- data/lib/pdk/validate/puppet_validator.rb +0 -2
- data/lib/pdk/validate/ruby/rubocop.rb +0 -5
- data/lib/pdk/validate/ruby_validator.rb +0 -2
- data/lib/pdk/validate/tasks/metadata_lint.rb +9 -5
- data/lib/pdk/validate/tasks/name.rb +4 -2
- data/lib/pdk/validate/tasks_validator.rb +0 -2
- data/lib/pdk/validate/yaml/syntax.rb +4 -4
- data/lib/pdk/validate/yaml_validator.rb +0 -2
- data/lib/pdk/version.rb +1 -1
- data/locales/pdk.pot +351 -311
- metadata +11 -7
- data/lib/pdk/config/validator.rb +0 -31
- data/lib/pdk/config/value.rb +0 -94
data/lib/pdk/cli/exec/command.rb
CHANGED
@@ -1,14 +1,3 @@
|
|
1
|
-
require 'bundler'
|
2
|
-
require 'childprocess'
|
3
|
-
require 'English'
|
4
|
-
require 'tempfile'
|
5
|
-
require 'tty-which'
|
6
|
-
|
7
|
-
require 'pdk/util'
|
8
|
-
require 'pdk/util/git'
|
9
|
-
require 'pdk/util/ruby_version'
|
10
|
-
require 'pdk/cli/util/spinner'
|
11
|
-
|
12
1
|
module PDK
|
13
2
|
module CLI
|
14
3
|
module Exec
|
@@ -20,6 +9,9 @@ module PDK
|
|
20
9
|
attr_writer :exec_group
|
21
10
|
|
22
11
|
def initialize(*argv)
|
12
|
+
require 'childprocess'
|
13
|
+
require 'tempfile'
|
14
|
+
|
23
15
|
@argv = argv
|
24
16
|
|
25
17
|
@process = ChildProcess.build(*@argv)
|
@@ -50,6 +42,8 @@ module PDK
|
|
50
42
|
end
|
51
43
|
|
52
44
|
def register_spinner(spinner, opts = {})
|
45
|
+
require 'pdk/cli/util'
|
46
|
+
|
53
47
|
return unless PDK::CLI::Util.interactive?
|
54
48
|
@success_message = opts.delete(:success)
|
55
49
|
@failure_message = opts.delete(:failure)
|
@@ -58,10 +52,14 @@ module PDK
|
|
58
52
|
end
|
59
53
|
|
60
54
|
def add_spinner(message, opts = {})
|
55
|
+
require 'pdk/cli/util'
|
56
|
+
|
61
57
|
return unless PDK::CLI::Util.interactive?
|
62
58
|
@success_message = opts.delete(:success)
|
63
59
|
@failure_message = opts.delete(:failure)
|
64
60
|
|
61
|
+
require 'pdk/cli/util/spinner'
|
62
|
+
|
65
63
|
@spinner = TTY::Spinner.new("[:spinner] #{message}", opts.merge(PDK::CLI::Util.spinner_opts_for_platform))
|
66
64
|
end
|
67
65
|
|
@@ -77,6 +75,7 @@ module PDK
|
|
77
75
|
resolved_env_for_command.each { |k, v| @process.environment[k] = v }
|
78
76
|
|
79
77
|
if [:module, :pwd].include?(context)
|
78
|
+
require 'pdk/util'
|
80
79
|
mod_root = PDK::Util.module_root
|
81
80
|
|
82
81
|
unless mod_root
|
@@ -155,6 +154,10 @@ module PDK
|
|
155
154
|
resolved_env['BUNDLE_IGNORE_CONFIG'] = '1'
|
156
155
|
|
157
156
|
if [:module, :pwd].include?(context)
|
157
|
+
require 'pdk/util'
|
158
|
+
require 'pdk/util/git'
|
159
|
+
require 'pdk/util/ruby_version'
|
160
|
+
|
158
161
|
resolved_env['GEM_HOME'] = PDK::Util::RubyVersion.gem_home
|
159
162
|
resolved_env['GEM_PATH'] = PDK::Util::RubyVersion.gem_path
|
160
163
|
|
@@ -186,6 +189,8 @@ module PDK
|
|
186
189
|
end
|
187
190
|
|
188
191
|
def run_process_in_clean_env!
|
192
|
+
require 'bundler'
|
193
|
+
|
189
194
|
::Bundler.with_clean_env do
|
190
195
|
run_process!
|
191
196
|
end
|
@@ -35,6 +35,8 @@ module PDK
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def execute!
|
38
|
+
require 'pdk/util'
|
39
|
+
|
38
40
|
@resolved_env = resolved_env_for_command
|
39
41
|
|
40
42
|
if [:module, :pwd].include?(context)
|
@@ -98,6 +100,8 @@ module PDK
|
|
98
100
|
end
|
99
101
|
|
100
102
|
def child_status
|
103
|
+
require 'English'
|
104
|
+
|
101
105
|
$CHILD_STATUS
|
102
106
|
end
|
103
107
|
|
data/lib/pdk/cli/exec_group.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
-
require 'tty-which'
|
2
|
-
|
3
|
-
require 'pdk/util'
|
4
|
-
require 'pdk/cli/util/spinner'
|
5
|
-
|
6
1
|
module PDK
|
7
2
|
module CLI
|
8
3
|
class ExecGroup
|
9
4
|
def initialize(message, opts = {})
|
5
|
+
require 'pdk/cli/util'
|
10
6
|
@options = opts.merge(PDK::CLI::Util.spinner_opts_for_platform)
|
11
7
|
|
12
8
|
if PDK::CLI::Util.interactive?
|
9
|
+
require 'pdk/cli/util/spinner'
|
10
|
+
|
13
11
|
@spinner = if parallel?
|
14
12
|
TTY::Spinner::Multi.new("[:spinner] #{message}", @options)
|
15
13
|
else
|
@@ -41,6 +39,8 @@ module PDK
|
|
41
39
|
end
|
42
40
|
|
43
41
|
def add_spinner(message, opts = {})
|
42
|
+
require 'pdk/cli/util'
|
43
|
+
|
44
44
|
return unless PDK::CLI::Util.interactive?
|
45
45
|
@spinner.register("[:spinner] #{message}", @options.merge(opts).merge(PDK::CLI::Util.spinner_opts_for_platform))
|
46
46
|
end
|
data/lib/pdk/cli/module/build.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'tty-prompt'
|
2
|
-
|
3
1
|
module PDK::CLI
|
4
2
|
@module_generate_cmd = @module_cmd.define_command do
|
5
3
|
name 'generate'
|
@@ -12,6 +10,7 @@ module PDK::CLI
|
|
12
10
|
|
13
11
|
run do |opts, args, _cmd|
|
14
12
|
require 'pdk/generate/module'
|
13
|
+
require 'tty-prompt'
|
15
14
|
|
16
15
|
module_name = args[0]
|
17
16
|
|
data/lib/pdk/cli/new.rb
CHANGED
data/lib/pdk/cli/new/provider.rb
CHANGED
data/lib/pdk/cli/new/task.rb
CHANGED
@@ -7,6 +7,8 @@ module PDK::CLI
|
|
7
7
|
option nil, :description, _('A short description of the purpose of the task'), argument: :required
|
8
8
|
|
9
9
|
run do |opts, args, _cmd|
|
10
|
+
require 'pdk/generate/task'
|
11
|
+
|
10
12
|
PDK::CLI::Util.ensure_in_module!(
|
11
13
|
message: _('Tasks can only be created from inside a valid module directory.'),
|
12
14
|
log_level: :info,
|
@@ -1,22 +1,19 @@
|
|
1
1
|
module PDK::CLI
|
2
2
|
@new_define_cmd = @new_cmd.define_command do
|
3
|
-
name '
|
4
|
-
usage _('
|
5
|
-
summary _('
|
6
|
-
|
7
|
-
Generate a new rspec-puppet unit test for an existing class or defined type.
|
8
|
-
|
9
|
-
Please note, this is an experimental feature; the functionality and UX is
|
10
|
-
subject to change in future releases.
|
11
|
-
EOF
|
12
|
-
)
|
3
|
+
name 'test'
|
4
|
+
usage _('test [options] <name>')
|
5
|
+
summary _('Create a new test for the object named <name>')
|
6
|
+
flag :u, :unit, _('Create a new unit test.')
|
13
7
|
PDK::CLI.puppet_version_options(self)
|
14
8
|
PDK::CLI.puppet_dev_option(self)
|
15
9
|
|
16
10
|
run do |opts, args, _cmd|
|
11
|
+
require 'pdk/util/puppet_strings'
|
12
|
+
require 'pdk/util/bundler'
|
13
|
+
|
17
14
|
PDK::CLI::Util.validate_puppet_version_opts(opts)
|
18
15
|
PDK::CLI::Util.ensure_in_module!(
|
19
|
-
message: _('
|
16
|
+
message: _('Tests can only be created from inside a valid module directory.'),
|
20
17
|
log_level: :info,
|
21
18
|
)
|
22
19
|
|
@@ -28,6 +25,13 @@ EOF
|
|
28
25
|
exit 1
|
29
26
|
end
|
30
27
|
|
28
|
+
unless opts[:unit]
|
29
|
+
# At a future time, we'll replace this conditional with an interactive
|
30
|
+
# question to choose the test type.
|
31
|
+
PDK.logger.info _('Test type not specified, assuming unit.')
|
32
|
+
opts[:unit] = true
|
33
|
+
end
|
34
|
+
|
31
35
|
puppet_env = PDK::CLI::Util.puppet_from_opts_or_env(opts)
|
32
36
|
PDK::Util::PuppetVersion.fetch_puppet_dev if opts[:'puppet-dev']
|
33
37
|
PDK::Util::RubyVersion.use(puppet_env[:ruby_version])
|
@@ -36,7 +40,7 @@ EOF
|
|
36
40
|
begin
|
37
41
|
generator, obj = PDK::Util::PuppetStrings.find_object(object_name)
|
38
42
|
|
39
|
-
PDK::CLI::Util.analytics_screen_view('
|
43
|
+
PDK::CLI::Util.analytics_screen_view('new_test', opts)
|
40
44
|
|
41
45
|
generator.new(module_dir, obj['name'], opts.merge(spec_only: true)).run
|
42
46
|
rescue PDK::Util::PuppetStrings::NoObjectError
|
data/lib/pdk/cli/test/unit.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'pdk/cli/util/option_validator'
|
2
|
-
require 'pdk/report'
|
3
|
-
|
4
1
|
module PDK::CLI
|
5
2
|
@test_unit_cmd = @test_cmd.define_command do
|
6
3
|
name 'unit'
|
@@ -15,6 +12,7 @@ module PDK::CLI
|
|
15
12
|
flag :c, 'clean-fixtures', _('Clean up downloaded fixtures after the test run.')
|
16
13
|
|
17
14
|
option nil, :tests, _('Specify a comma-separated list of unit test files to run.'), argument: :required, default: '' do |values|
|
15
|
+
require 'pdk/cli/util/option_validator'
|
18
16
|
PDK::CLI::Util::OptionValidator.comma_separated_list?(values)
|
19
17
|
end
|
20
18
|
|
@@ -23,6 +21,8 @@ module PDK::CLI
|
|
23
21
|
|
24
22
|
run do |opts, _args, _cmd|
|
25
23
|
require 'pdk/tests/unit'
|
24
|
+
require 'pdk/report'
|
25
|
+
require 'pdk/util/bundler'
|
26
26
|
|
27
27
|
PDK::CLI::Util.validate_puppet_version_opts(opts)
|
28
28
|
|
@@ -70,8 +70,10 @@ module PDK::CLI
|
|
70
70
|
|
71
71
|
report = PDK::Report.new
|
72
72
|
report_formats = if opts[:format]
|
73
|
+
opts[:interactive] = false
|
73
74
|
PDK::CLI::Util::OptionNormalizer.report_formats(opts[:format])
|
74
75
|
else
|
76
|
+
opts[:interactive] = true
|
75
77
|
[{
|
76
78
|
method: PDK::Report.default_format,
|
77
79
|
target: PDK::Report.default_target,
|
data/lib/pdk/cli/update.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'pdk/cli/util'
|
2
|
-
require 'pdk/util'
|
3
|
-
|
4
1
|
module PDK::CLI
|
5
2
|
@update_cmd = @base_cmd.define_command do
|
6
3
|
name 'update'
|
@@ -13,6 +10,8 @@ module PDK::CLI
|
|
13
10
|
PDK::CLI.template_ref_option(self)
|
14
11
|
|
15
12
|
run do |opts, _args, _cmd|
|
13
|
+
require 'pdk/cli/util'
|
14
|
+
require 'pdk/util'
|
16
15
|
require 'pdk/module/update'
|
17
16
|
|
18
17
|
PDK::CLI::Util.ensure_in_module!(
|
data/lib/pdk/cli/util.rb
CHANGED
@@ -69,6 +69,8 @@ module PDK
|
|
69
69
|
module_function :ci_environment?
|
70
70
|
|
71
71
|
def interactive?
|
72
|
+
require 'pdk/logger'
|
73
|
+
|
72
74
|
return false if PDK.logger.debug?
|
73
75
|
return !ENV['PDK_FRONTEND'].casecmp('noninteractive').zero? if ENV['PDK_FRONTEND']
|
74
76
|
return false if ci_environment?
|
@@ -103,10 +105,31 @@ module PDK
|
|
103
105
|
end
|
104
106
|
module_function :module_version_check
|
105
107
|
|
106
|
-
def
|
107
|
-
|
108
|
-
|
109
|
-
|
108
|
+
def check_for_deprecated_puppet(version)
|
109
|
+
return unless version.is_a?(Gem::Version)
|
110
|
+
|
111
|
+
deprecated_below = Gem::Version.new('5.0.0')
|
112
|
+
return unless version < deprecated_below
|
113
|
+
|
114
|
+
deprecated_msg = _(
|
115
|
+
'Support for Puppet versions older than %{version} is ' \
|
116
|
+
'deprecated and will be removed in a future version of PDK.',
|
117
|
+
) % { version: deprecated_below.to_s }
|
118
|
+
PDK.logger.warn(deprecated_msg)
|
119
|
+
end
|
120
|
+
module_function :check_for_deprecated_puppet
|
121
|
+
|
122
|
+
# @param opts [Hash] - the pdk options ot use, defaults to empty hash
|
123
|
+
# @option opts [String] :'puppet-dev' Use the puppet development version, default to PDK_PUPPET_DEV env
|
124
|
+
# @option opts [String] :'puppet-version' Puppet version to use, default to PDK_PUPPET_VERSION env
|
125
|
+
# @option opts [String] :'pe-version' PE Puppet version to use, default to PDK_PE_VERSION env
|
126
|
+
# @param logging_disabled [Boolean] - disable logging of PDK info
|
127
|
+
# @return [Hash] - return hash of { gemset: <>, ruby_version: 2.x.x }
|
128
|
+
def puppet_from_opts_or_env(opts, logging_disabled = false)
|
129
|
+
opts ||= {}
|
130
|
+
use_puppet_dev = opts.fetch(:'puppet-dev', ENV['PDK_PUPPET_DEV'])
|
131
|
+
desired_puppet_version = opts.fetch(:'puppet-version', ENV['PDK_PUPPET_VERSION'])
|
132
|
+
desired_pe_version = opts.fetch(:'pe-version', ENV['PDK_PE_VERSION'])
|
110
133
|
|
111
134
|
begin
|
112
135
|
puppet_env =
|
@@ -124,20 +147,26 @@ module PDK
|
|
124
147
|
end
|
125
148
|
|
126
149
|
# Notify user of what Ruby version will be used.
|
127
|
-
|
128
|
-
version
|
129
|
-
|
150
|
+
unless logging_disabled
|
151
|
+
PDK.logger.info(_('Using Ruby %{version}') % {
|
152
|
+
version: puppet_env[:ruby_version],
|
153
|
+
})
|
154
|
+
end
|
155
|
+
|
156
|
+
check_for_deprecated_puppet(puppet_env[:gem_version])
|
130
157
|
|
131
158
|
gemset = { puppet: puppet_env[:gem_version].to_s }
|
132
159
|
|
133
160
|
# Notify user of what gems are being activated.
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
gem
|
139
|
-
|
140
|
-
|
161
|
+
unless logging_disabled
|
162
|
+
gemset.each do |gem, version|
|
163
|
+
next if version.nil?
|
164
|
+
|
165
|
+
PDK.logger.info(_('Using %{gem} %{version}') % {
|
166
|
+
gem: gem.to_s.capitalize,
|
167
|
+
version: version,
|
168
|
+
})
|
169
|
+
end
|
141
170
|
end
|
142
171
|
|
143
172
|
{
|
@@ -221,6 +250,8 @@ module PDK
|
|
221
250
|
module_function :validate_template_opts
|
222
251
|
|
223
252
|
def analytics_screen_view(screen_name, opts = {})
|
253
|
+
require 'pdk/analytics'
|
254
|
+
|
224
255
|
dimensions = {
|
225
256
|
ruby_version: RUBY_VERSION,
|
226
257
|
}
|
data/lib/pdk/cli/util/spinner.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'tty-spinner'
|
2
2
|
|
3
|
-
require 'pdk/cli/util'
|
4
|
-
|
5
3
|
# Replace the built-in tty check in tty-spinner with our own implementation
|
6
4
|
# that allows us to mock the behaviour during acceptance tests.
|
7
5
|
module TTY
|
8
6
|
class Spinner
|
9
7
|
def tty?
|
8
|
+
require 'pdk/cli/util'
|
9
|
+
|
10
10
|
PDK::CLI::Util.interactive?
|
11
11
|
end
|
12
12
|
end
|
data/lib/pdk/cli/validate.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'pdk/util/bundler'
|
2
|
-
|
3
1
|
module PDK::CLI
|
4
2
|
@validate_cmd = @base_cmd.define_command do
|
5
3
|
name 'validate'
|
@@ -26,6 +24,8 @@ module PDK::CLI
|
|
26
24
|
exit 0
|
27
25
|
end
|
28
26
|
|
27
|
+
require 'pdk/validate'
|
28
|
+
|
29
29
|
validator_names = PDK::Validate.validators.map { |v| v.name }
|
30
30
|
validators = PDK::Validate.validators
|
31
31
|
targets = []
|
@@ -101,10 +101,14 @@ module PDK::CLI
|
|
101
101
|
|
102
102
|
options.merge!(puppet_env[:gemset])
|
103
103
|
|
104
|
+
require 'pdk/util/bundler'
|
105
|
+
|
104
106
|
PDK::Util::Bundler.ensure_bundle!(puppet_env[:gemset])
|
105
107
|
|
106
108
|
exit_code = 0
|
107
109
|
if opts[:parallel]
|
110
|
+
require 'pdk/cli/exec_group'
|
111
|
+
|
108
112
|
exec_group = PDK::CLI::ExecGroup.new(_('Validating module using %{num_of_threads} threads' % { num_of_threads: validators.count }), opts)
|
109
113
|
|
110
114
|
validators.each do |validator|
|
data/lib/pdk/config.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'pdk/config/errors'
|
2
|
-
require 'pdk/config/json'
|
3
2
|
require 'pdk/config/namespace'
|
4
|
-
require 'pdk/config/
|
5
|
-
require 'pdk/config/value'
|
3
|
+
require 'pdk/config/setting'
|
6
4
|
require 'pdk/config/yaml'
|
5
|
+
require 'pdk/config/yaml_with_schema'
|
6
|
+
require 'pdk/config/json'
|
7
7
|
|
8
8
|
module PDK
|
9
9
|
def self.config
|
@@ -12,17 +12,16 @@ module PDK
|
|
12
12
|
|
13
13
|
class Config
|
14
14
|
def user
|
15
|
+
require 'pdk/answer_file'
|
15
16
|
@user ||= PDK::Config::JSON.new('user', file: PDK::Config.user_config_path) do
|
16
17
|
mount :module_defaults, PDK::Config::JSON.new(file: PDK.answers.answer_file_path)
|
17
18
|
|
18
|
-
mount :analytics, PDK::Config::
|
19
|
-
|
20
|
-
validate PDK::Config::Validator.boolean
|
19
|
+
mount :analytics, PDK::Config::YAMLWithSchema.new(file: PDK::Config.analytics_config_path, persistent_defaults: true, schema_file: PDK::Config.json_schema('analytics')) do
|
20
|
+
setting :disabled do
|
21
21
|
default_to { PDK::Config.bolt_analytics_config.fetch('disabled', true) }
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
validate PDK::Config::Validator.uuid
|
24
|
+
setting 'user-id' do
|
26
25
|
default_to do
|
27
26
|
require 'securerandom'
|
28
27
|
|
@@ -60,11 +59,22 @@ module PDK
|
|
60
59
|
File.join(PDK::Util.configdir, 'user_config.json')
|
61
60
|
end
|
62
61
|
|
62
|
+
def self.json_schemas_path
|
63
|
+
File.join(__dir__, 'config')
|
64
|
+
end
|
65
|
+
|
66
|
+
# return nil if not exist
|
67
|
+
def self.json_schema(name)
|
68
|
+
File.join(json_schemas_path, name + '_schema.json')
|
69
|
+
end
|
70
|
+
|
63
71
|
def self.analytics_config_exist?
|
64
72
|
PDK::Util::Filesystem.file?(analytics_config_path)
|
65
73
|
end
|
66
74
|
|
67
75
|
def self.analytics_config_interview!
|
76
|
+
require 'pdk/cli/util'
|
77
|
+
|
68
78
|
return unless PDK::CLI::Util.interactive?
|
69
79
|
|
70
80
|
pre_message = _(
|
@@ -90,6 +100,8 @@ module PDK
|
|
90
100
|
},
|
91
101
|
]
|
92
102
|
|
103
|
+
require 'pdk/cli/util/interview'
|
104
|
+
|
93
105
|
PDK.logger.info(text: pre_message, wrap: true)
|
94
106
|
prompt = TTY::Prompt.new(help_color: :cyan)
|
95
107
|
interview = PDK::CLI::Util::Interview.new(prompt)
|