pantograph 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +1 -0
- data/LICENSE +21 -0
- data/README.md +197 -0
- data/bin/bin-proxy +19 -0
- data/bin/pantograph +23 -0
- data/pantograph/README.md +11 -0
- data/pantograph/lib/assets/ActionDetails.md.erb +106 -0
- data/pantograph/lib/assets/Actions.md.erb +43 -0
- data/pantograph/lib/assets/DefaultPantfileTemplate +20 -0
- data/pantograph/lib/assets/completions/completion.bash +23 -0
- data/pantograph/lib/assets/completions/completion.fish +39 -0
- data/pantograph/lib/assets/completions/completion.sh +12 -0
- data/pantograph/lib/assets/completions/completion.zsh +23 -0
- data/pantograph/lib/assets/custom_action_template.rb +80 -0
- data/pantograph/lib/assets/report_template.xml.erb +15 -0
- data/pantograph/lib/pantograph/action.rb +194 -0
- data/pantograph/lib/pantograph/action_collector.rb +35 -0
- data/pantograph/lib/pantograph/actions/README.md +3 -0
- data/pantograph/lib/pantograph/actions/actions_helper.rb +166 -0
- data/pantograph/lib/pantograph/actions/add_extra_platforms.rb +45 -0
- data/pantograph/lib/pantograph/actions/artifactory.rb +157 -0
- data/pantograph/lib/pantograph/actions/bundle_install.rb +156 -0
- data/pantograph/lib/pantograph/actions/changelog_from_git_commits.rb +197 -0
- data/pantograph/lib/pantograph/actions/clipboard.rb +52 -0
- data/pantograph/lib/pantograph/actions/cloc.rb +89 -0
- data/pantograph/lib/pantograph/actions/create_pull_request.rb +190 -0
- data/pantograph/lib/pantograph/actions/danger.rb +131 -0
- data/pantograph/lib/pantograph/actions/debug.rb +32 -0
- data/pantograph/lib/pantograph/actions/default_platform.rb +47 -0
- data/pantograph/lib/pantograph/actions/download.rb +76 -0
- data/pantograph/lib/pantograph/actions/echo.rb +14 -0
- data/pantograph/lib/pantograph/actions/ensure_bundle_exec.rb +59 -0
- data/pantograph/lib/pantograph/actions/ensure_env_vars.rb +58 -0
- data/pantograph/lib/pantograph/actions/ensure_git_branch.rb +69 -0
- data/pantograph/lib/pantograph/actions/ensure_git_status_clean.rb +81 -0
- data/pantograph/lib/pantograph/actions/erb.rb +88 -0
- data/pantograph/lib/pantograph/actions/get_build_number_repository.rb +120 -0
- data/pantograph/lib/pantograph/actions/get_github_release.rb +163 -0
- data/pantograph/lib/pantograph/actions/git_add.rb +93 -0
- data/pantograph/lib/pantograph/actions/git_branch.rb +58 -0
- data/pantograph/lib/pantograph/actions/git_commit.rb +80 -0
- data/pantograph/lib/pantograph/actions/git_pull.rb +53 -0
- data/pantograph/lib/pantograph/actions/git_submodule_update.rb +52 -0
- data/pantograph/lib/pantograph/actions/git_tag_exists.rb +74 -0
- data/pantograph/lib/pantograph/actions/github_api.rb +262 -0
- data/pantograph/lib/pantograph/actions/gradle.rb +278 -0
- data/pantograph/lib/pantograph/actions/import.rb +49 -0
- data/pantograph/lib/pantograph/actions/import_from_git.rb +71 -0
- data/pantograph/lib/pantograph/actions/is_ci.rb +51 -0
- data/pantograph/lib/pantograph/actions/jira.rb +115 -0
- data/pantograph/lib/pantograph/actions/lane_context.rb +60 -0
- data/pantograph/lib/pantograph/actions/last_git_commit.rb +58 -0
- data/pantograph/lib/pantograph/actions/last_git_tag.rb +51 -0
- data/pantograph/lib/pantograph/actions/make_changelog_from_jenkins.rb +81 -0
- data/pantograph/lib/pantograph/actions/min_pantograph_version.rb +57 -0
- data/pantograph/lib/pantograph/actions/nexus_upload.rb +230 -0
- data/pantograph/lib/pantograph/actions/notification.rb +75 -0
- data/pantograph/lib/pantograph/actions/number_of_commits.rb +75 -0
- data/pantograph/lib/pantograph/actions/opt_out_usage.rb +40 -0
- data/pantograph/lib/pantograph/actions/pantograph_version.rb +15 -0
- data/pantograph/lib/pantograph/actions/println.rb +14 -0
- data/pantograph/lib/pantograph/actions/prompt.rb +119 -0
- data/pantograph/lib/pantograph/actions/push_git_tags.rb +76 -0
- data/pantograph/lib/pantograph/actions/push_to_git_remote.rb +127 -0
- data/pantograph/lib/pantograph/actions/puts.rb +68 -0
- data/pantograph/lib/pantograph/actions/reset_git_repo.rb +121 -0
- data/pantograph/lib/pantograph/actions/rocket.rb +83 -0
- data/pantograph/lib/pantograph/actions/rsync.rb +74 -0
- data/pantograph/lib/pantograph/actions/ruby_version.rb +56 -0
- data/pantograph/lib/pantograph/actions/say.rb +56 -0
- data/pantograph/lib/pantograph/actions/scp.rb +114 -0
- data/pantograph/lib/pantograph/actions/set_github_release.rb +274 -0
- data/pantograph/lib/pantograph/actions/sh.rb +71 -0
- data/pantograph/lib/pantograph/actions/skip_docs.rb +52 -0
- data/pantograph/lib/pantograph/actions/slack.rb +288 -0
- data/pantograph/lib/pantograph/actions/sonar.rb +156 -0
- data/pantograph/lib/pantograph/actions/ssh.rb +162 -0
- data/pantograph/lib/pantograph/actions/twitter.rb +89 -0
- data/pantograph/lib/pantograph/actions/update_pantograph.rb +177 -0
- data/pantograph/lib/pantograph/actions/zip.rb +120 -0
- data/pantograph/lib/pantograph/auto_complete.rb +82 -0
- data/pantograph/lib/pantograph/boolean.rb +5 -0
- data/pantograph/lib/pantograph/cli_tools_distributor.rb +183 -0
- data/pantograph/lib/pantograph/command_line_handler.rb +43 -0
- data/pantograph/lib/pantograph/commands_generator.rb +344 -0
- data/pantograph/lib/pantograph/configuration_helper.rb +26 -0
- data/pantograph/lib/pantograph/core_ext/bundler_monkey_patch.rb +14 -0
- data/pantograph/lib/pantograph/documentation/actions_list.rb +214 -0
- data/pantograph/lib/pantograph/documentation/docs_generator.rb +95 -0
- data/pantograph/lib/pantograph/documentation/markdown_docs_generator.rb +221 -0
- data/pantograph/lib/pantograph/environment_printer.rb +282 -0
- data/pantograph/lib/pantograph/erb_template_helper.rb +30 -0
- data/pantograph/lib/pantograph/features.rb +4 -0
- data/pantograph/lib/pantograph/helper/README.md +29 -0
- data/pantograph/lib/pantograph/helper/dotenv_helper.rb +50 -0
- data/pantograph/lib/pantograph/helper/gem_helper.rb +26 -0
- data/pantograph/lib/pantograph/helper/git_helper.rb +135 -0
- data/pantograph/lib/pantograph/helper/gradle_helper.rb +62 -0
- data/pantograph/lib/pantograph/helper/sh_helper.rb +134 -0
- data/pantograph/lib/pantograph/junit_generator.rb +27 -0
- data/pantograph/lib/pantograph/lane.rb +97 -0
- data/pantograph/lib/pantograph/lane_list.rb +77 -0
- data/pantograph/lib/pantograph/lane_manager.rb +140 -0
- data/pantograph/lib/pantograph/lane_manager_base.rb +92 -0
- data/pantograph/lib/pantograph/markdown_table_formatter.rb +62 -0
- data/pantograph/lib/pantograph/new_action.rb +47 -0
- data/pantograph/lib/pantograph/one_off.rb +45 -0
- data/pantograph/lib/pantograph/other_action.rb +29 -0
- data/pantograph/lib/pantograph/pant_file.rb +377 -0
- data/pantograph/lib/pantograph/pantograph_require.rb +75 -0
- data/pantograph/lib/pantograph/plugins/plugin_fetcher.rb +55 -0
- data/pantograph/lib/pantograph/plugins/plugin_generator.rb +86 -0
- data/pantograph/lib/pantograph/plugins/plugin_generator_ui.rb +19 -0
- data/pantograph/lib/pantograph/plugins/plugin_info.rb +49 -0
- data/pantograph/lib/pantograph/plugins/plugin_info_collector.rb +159 -0
- data/pantograph/lib/pantograph/plugins/plugin_manager.rb +387 -0
- data/pantograph/lib/pantograph/plugins/plugin_search.rb +46 -0
- data/pantograph/lib/pantograph/plugins/plugin_update_manager.rb +70 -0
- data/pantograph/lib/pantograph/plugins/plugins.rb +12 -0
- data/pantograph/lib/pantograph/plugins/template/%gem_name%.gemspec.erb +35 -0
- data/pantograph/lib/pantograph/plugins/template/.circleci/config.yml +43 -0
- data/pantograph/lib/pantograph/plugins/template/.gitignore +12 -0
- data/pantograph/lib/pantograph/plugins/template/.rspec +5 -0
- data/pantograph/lib/pantograph/plugins/template/.rubocop.yml +179 -0
- data/pantograph/lib/pantograph/plugins/template/.travis.yml +4 -0
- data/pantograph/lib/pantograph/plugins/template/Gemfile +6 -0
- data/pantograph/lib/pantograph/plugins/template/LICENSE.erb +21 -0
- data/pantograph/lib/pantograph/plugins/template/README.md.erb +52 -0
- data/pantograph/lib/pantograph/plugins/template/Rakefile +9 -0
- data/pantograph/lib/pantograph/plugins/template/lib/pantograph/plugin/%plugin_name%/actions/%plugin_name%_action.rb.erb +47 -0
- data/pantograph/lib/pantograph/plugins/template/lib/pantograph/plugin/%plugin_name%/helper/%plugin_name%_helper.rb.erb +16 -0
- data/pantograph/lib/pantograph/plugins/template/lib/pantograph/plugin/%plugin_name%/version.rb.erb +5 -0
- data/pantograph/lib/pantograph/plugins/template/lib/pantograph/plugin/%plugin_name%.rb.erb +16 -0
- data/pantograph/lib/pantograph/plugins/template/pantograph/Pantfile.erb +3 -0
- data/pantograph/lib/pantograph/plugins/template/pantograph/Pluginfile.erb +1 -0
- data/pantograph/lib/pantograph/plugins/template/spec/%plugin_name%_action_spec.rb.erb +9 -0
- data/pantograph/lib/pantograph/plugins/template/spec/spec_helper.rb.erb +15 -0
- data/pantograph/lib/pantograph/runner.rb +371 -0
- data/pantograph/lib/pantograph/server/action_command.rb +61 -0
- data/pantograph/lib/pantograph/server/action_command_return.rb +14 -0
- data/pantograph/lib/pantograph/server/command_executor.rb +7 -0
- data/pantograph/lib/pantograph/server/command_parser.rb +36 -0
- data/pantograph/lib/pantograph/server/control_command.rb +23 -0
- data/pantograph/lib/pantograph/server/json_return_value_processor.rb +72 -0
- data/pantograph/lib/pantograph/server/socket_server.rb +232 -0
- data/pantograph/lib/pantograph/server/socket_server_action_command_executor.rb +101 -0
- data/pantograph/lib/pantograph/setup/setup.rb +290 -0
- data/pantograph/lib/pantograph/setup/setup_android.rb +64 -0
- data/pantograph/lib/pantograph/setup/setup_ios.rb +412 -0
- data/pantograph/lib/pantograph/shells.rb +6 -0
- data/pantograph/lib/pantograph/supported_platforms.rb +28 -0
- data/pantograph/lib/pantograph/tools.rb +10 -0
- data/pantograph/lib/pantograph/version.rb +5 -0
- data/pantograph/lib/pantograph.rb +51 -0
- data/pantograph_core/README.md +79 -0
- data/pantograph_core/lib/assets/XMLTemplate.xml.erb +12 -0
- data/pantograph_core/lib/pantograph_core/analytics/action_completion_context.rb +34 -0
- data/pantograph_core/lib/pantograph_core/analytics/action_launch_context.rb +38 -0
- data/pantograph_core/lib/pantograph_core/analytics/analytics_event_builder.rb +23 -0
- data/pantograph_core/lib/pantograph_core/analytics/analytics_ingester_client.rb +54 -0
- data/pantograph_core/lib/pantograph_core/analytics/analytics_session.rb +71 -0
- data/pantograph_core/lib/pantograph_core/cert_checker.rb +116 -0
- data/pantograph_core/lib/pantograph_core/command_executor.rb +99 -0
- data/pantograph_core/lib/pantograph_core/configuration/commander_generator.rb +103 -0
- data/pantograph_core/lib/pantograph_core/configuration/config_item.rb +314 -0
- data/pantograph_core/lib/pantograph_core/configuration/configuration.rb +332 -0
- data/pantograph_core/lib/pantograph_core/configuration/configuration_file.rb +182 -0
- data/pantograph_core/lib/pantograph_core/core_ext/shellwords.rb +63 -0
- data/pantograph_core/lib/pantograph_core/core_ext/string.rb +17 -0
- data/pantograph_core/lib/pantograph_core/env.rb +9 -0
- data/pantograph_core/lib/pantograph_core/feature/feature.rb +51 -0
- data/pantograph_core/lib/pantograph_core/features.rb +4 -0
- data/pantograph_core/lib/pantograph_core/globals.rb +27 -0
- data/pantograph_core/lib/pantograph_core/helper.rb +409 -0
- data/pantograph_core/lib/pantograph_core/keychain_importer.rb +74 -0
- data/pantograph_core/lib/pantograph_core/languages.rb +14 -0
- data/pantograph_core/lib/pantograph_core/module.rb +29 -0
- data/pantograph_core/lib/pantograph_core/pantograph_folder.rb +39 -0
- data/pantograph_core/lib/pantograph_core/pantograph_pty.rb +57 -0
- data/pantograph_core/lib/pantograph_core/pkg_file_analyser.rb +44 -0
- data/pantograph_core/lib/pantograph_core/print_table.rb +131 -0
- data/pantograph_core/lib/pantograph_core/string_filters.rb +51 -0
- data/pantograph_core/lib/pantograph_core/swag.rb +85 -0
- data/pantograph_core/lib/pantograph_core/tag_version.rb +31 -0
- data/pantograph_core/lib/pantograph_core/test_parser.rb +107 -0
- data/pantograph_core/lib/pantograph_core/ui/disable_colors.rb +17 -0
- data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_common_error.rb +19 -0
- data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_crash.rb +11 -0
- data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_error.rb +25 -0
- data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_exception.rb +19 -0
- data/pantograph_core/lib/pantograph_core/ui/errors/pantograph_shell_error.rb +11 -0
- data/pantograph_core/lib/pantograph_core/ui/errors.rb +1 -0
- data/pantograph_core/lib/pantograph_core/ui/github_issue_inspector_reporter.rb +62 -0
- data/pantograph_core/lib/pantograph_core/ui/implementations/shell.rb +159 -0
- data/pantograph_core/lib/pantograph_core/ui/interface.rb +205 -0
- data/pantograph_core/lib/pantograph_core/ui/pantograph_runner.rb +276 -0
- data/pantograph_core/lib/pantograph_core/ui/ui.rb +26 -0
- data/pantograph_core/lib/pantograph_core/update_checker/changelog.rb +37 -0
- data/pantograph_core/lib/pantograph_core/update_checker/update_checker.rb +107 -0
- data/pantograph_core/lib/pantograph_core.rb +45 -0
- metadata +987 -0
@@ -0,0 +1,95 @@
|
|
1
|
+
module Pantograph
|
2
|
+
class DocsGenerator
|
3
|
+
def self.run(ff, output_path = nil)
|
4
|
+
output_path ||= File.join(PantographCore::PantographFolder.path || '.', 'README.md')
|
5
|
+
|
6
|
+
output = ["pantograph documentation"]
|
7
|
+
output << "================"
|
8
|
+
|
9
|
+
output << "# Installation"
|
10
|
+
output << ""
|
11
|
+
output << "Make sure you have the latest version of the Xcode command line tools installed:"
|
12
|
+
output << ""
|
13
|
+
output << "```"
|
14
|
+
output << "xcode-select --install"
|
15
|
+
output << "```"
|
16
|
+
output << ""
|
17
|
+
output << "Install _pantograph_ using"
|
18
|
+
output << "```"
|
19
|
+
output << "gem install pantograph"
|
20
|
+
output << "```"
|
21
|
+
output << "or alternatively using `brew cask install pantograph`"
|
22
|
+
output << ""
|
23
|
+
output << "# Available Actions"
|
24
|
+
|
25
|
+
all_keys = ff.runner.lanes.keys.reject(&:nil?)
|
26
|
+
all_keys.unshift(nil) # because we want root elements on top. always! They have key nil
|
27
|
+
|
28
|
+
all_keys.each do |platform|
|
29
|
+
lanes = ff.runner.lanes[platform]
|
30
|
+
|
31
|
+
if lanes.nil? || lanes.empty? || lanes.all? { |_, lane| lane.is_private }
|
32
|
+
next
|
33
|
+
end
|
34
|
+
|
35
|
+
output << "## #{formatted_platform(platform)}" if platform
|
36
|
+
|
37
|
+
lanes.each do |lane_name, lane|
|
38
|
+
next if lane.is_private
|
39
|
+
output << render(platform, lane_name, lane.description.join("\n\n"))
|
40
|
+
end
|
41
|
+
|
42
|
+
output << ""
|
43
|
+
output << "----"
|
44
|
+
output << ""
|
45
|
+
end
|
46
|
+
|
47
|
+
output << "This README.md is auto-generated and will be re-generated every time [pantograph](https://pantograph.tools) is run."
|
48
|
+
output << "More information about pantograph can be found on [pantograph.tools](https://pantograph.tools)."
|
49
|
+
output << "The documentation of pantograph can be found on [docs.pantograph.tools](https://docs.pantograph.tools)."
|
50
|
+
output << ""
|
51
|
+
|
52
|
+
begin
|
53
|
+
File.write(output_path, output.join("\n"))
|
54
|
+
UI.success("Successfully generated documentation at path '#{File.expand_path(output_path)}'") if PantographCore::Globals.verbose?
|
55
|
+
rescue => ex
|
56
|
+
UI.error(ex)
|
57
|
+
UI.error("Couldn't save pantograph documentation at path '#{File.expand_path(output_path)}', make sure you have write access to the containing directory.")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
#####################################################
|
62
|
+
# @!group Helper
|
63
|
+
#####################################################
|
64
|
+
|
65
|
+
def self.formatted_platform(pl)
|
66
|
+
pl = pl.to_s
|
67
|
+
case pl
|
68
|
+
when 'ios'
|
69
|
+
'iOS'
|
70
|
+
when 'android'
|
71
|
+
'Android'
|
72
|
+
when 'mac'
|
73
|
+
'MacOS'
|
74
|
+
else
|
75
|
+
pl
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
# @param platform [String]
|
81
|
+
# @param lane [Pantograph::Lane]
|
82
|
+
# @param description [String]
|
83
|
+
def self.render(platform, lane, description)
|
84
|
+
full_name = [platform, lane].reject(&:nil?).join(' ')
|
85
|
+
|
86
|
+
output = []
|
87
|
+
output << "### #{full_name}"
|
88
|
+
output << "```"
|
89
|
+
output << "pantograph #{full_name}"
|
90
|
+
output << "```"
|
91
|
+
output << description
|
92
|
+
output
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,221 @@
|
|
1
|
+
module Pantograph
|
2
|
+
class MarkdownDocsGenerator
|
3
|
+
attr_accessor :categories
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
require 'pantograph'
|
7
|
+
require 'pantograph/documentation/actions_list'
|
8
|
+
Pantograph.load_actions
|
9
|
+
|
10
|
+
self.work
|
11
|
+
end
|
12
|
+
|
13
|
+
def work
|
14
|
+
fill_built_in_actions
|
15
|
+
end
|
16
|
+
|
17
|
+
def fill_built_in_actions
|
18
|
+
self.categories = {}
|
19
|
+
|
20
|
+
Pantograph::Action::AVAILABLE_CATEGORIES.each { |a| self.categories[readable_category_name(a)] = {} }
|
21
|
+
|
22
|
+
# Fill categories with all built-in actions
|
23
|
+
ActionsList.all_actions do |action|
|
24
|
+
readable = readable_category_name(action.category)
|
25
|
+
|
26
|
+
if self.categories[readable].kind_of?(Hash)
|
27
|
+
self.categories[readable][number_of_launches_for_action(action.action_name)] = action
|
28
|
+
else
|
29
|
+
UI.error("Action '#{action.name}' doesn't contain category information... skipping")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def number_of_launches_for_action(action_name)
|
35
|
+
found = all_actions_from_enhancer.find { |c| c['action'] == action_name.to_s }
|
36
|
+
|
37
|
+
return found["index"] if found
|
38
|
+
return 10_000 + rand # new actions that we've never tracked before will be shown at the bottom of the page, need `rand` to not overwrite them
|
39
|
+
end
|
40
|
+
|
41
|
+
def all_actions_from_enhancer
|
42
|
+
require 'json'
|
43
|
+
@_launches ||= JSON.parse(File.read(File.join(Pantograph::ROOT, "assets/action_ranking.json"))) # root because we're in a temporary directory here
|
44
|
+
end
|
45
|
+
|
46
|
+
def actions_path
|
47
|
+
"lib/pantograph/actions/"
|
48
|
+
end
|
49
|
+
|
50
|
+
def where_is(klass)
|
51
|
+
# Gets all source files for action
|
52
|
+
methods = klass.methods(false).map { |m| klass.method(m) }
|
53
|
+
source_files = methods
|
54
|
+
.map(&:source_location)
|
55
|
+
.compact
|
56
|
+
.map { |(file, line)| file }
|
57
|
+
.uniq
|
58
|
+
|
59
|
+
# Return file or error if multiples
|
60
|
+
if source_files.size == 1
|
61
|
+
return source_files.first
|
62
|
+
else
|
63
|
+
UI.crash!("Multiple source files were found for action `#{klass}`")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def filename_for_action(action)
|
68
|
+
absolute_path = where_is(action)
|
69
|
+
filename = File.basename(absolute_path)
|
70
|
+
|
71
|
+
path = File.join(Pantograph::ROOT, actions_path, filename)
|
72
|
+
unless File.exist?(path)
|
73
|
+
UI.error("Action '#{action.name}' not found in root pantograph project... skipping")
|
74
|
+
UI.verbose("Action '#{action.name}' found at #{path}")
|
75
|
+
return nil
|
76
|
+
end
|
77
|
+
filename
|
78
|
+
end
|
79
|
+
|
80
|
+
def custom_action_docs_path
|
81
|
+
"lib/pantograph/actions/docs/"
|
82
|
+
end
|
83
|
+
|
84
|
+
def load_custom_action_md(action)
|
85
|
+
# check if there is a custom detail view in markdown available in the pantograph code base
|
86
|
+
custom_file_location = File.join(Pantograph::ROOT, custom_action_docs_path, "#{action.action_name}.md")
|
87
|
+
if File.exist?(custom_file_location)
|
88
|
+
UI.verbose("Using custom md file for action #{action.action_name}")
|
89
|
+
return File.read(custom_file_location)
|
90
|
+
end
|
91
|
+
return load_custom_action_md_erb(action)
|
92
|
+
end
|
93
|
+
|
94
|
+
def load_custom_action_md_erb(action)
|
95
|
+
# check if there is a custom detail view as markdown ERB available in the pantograph code base
|
96
|
+
custom_file_location = File.join(Pantograph::ROOT, custom_action_docs_path, "#{action.action_name}.md.erb")
|
97
|
+
if File.exist?(custom_file_location)
|
98
|
+
UI.verbose("Using custom md.erb file for action #{action.action_name}")
|
99
|
+
|
100
|
+
result = ERB.new(File.read(custom_file_location), 0, '-').result(binding) # https://web.archive.org/web/20160430190141/www.rrn.dk/rubys-erb-templating-system
|
101
|
+
|
102
|
+
return result
|
103
|
+
end
|
104
|
+
return nil
|
105
|
+
end
|
106
|
+
|
107
|
+
def actions_md_contents
|
108
|
+
action_mds = {}
|
109
|
+
|
110
|
+
ActionsList.all_actions do |action|
|
111
|
+
@action = action
|
112
|
+
@action_filename = filename_for_action(action)
|
113
|
+
|
114
|
+
unless @action_filename
|
115
|
+
next
|
116
|
+
end
|
117
|
+
|
118
|
+
@custom_content = load_custom_action_md(action)
|
119
|
+
|
120
|
+
if action.superclass != Pantograph::Action
|
121
|
+
@custom_content ||= load_custom_action_md(action.superclass)
|
122
|
+
end
|
123
|
+
|
124
|
+
template = File.join(Pantograph::ROOT, "lib/assets/ActionDetails.md.erb")
|
125
|
+
result = ERB.new(File.read(template), 0, '-').result(binding)
|
126
|
+
|
127
|
+
action_mds[action.action_name] = result
|
128
|
+
end
|
129
|
+
|
130
|
+
return action_mds
|
131
|
+
end
|
132
|
+
|
133
|
+
def generate!(target_path: nil)
|
134
|
+
require 'yaml'
|
135
|
+
FileUtils.mkdir_p(target_path)
|
136
|
+
docs_dir = File.join(target_path, "docs")
|
137
|
+
|
138
|
+
# Generate actions.md
|
139
|
+
template = File.join(Pantograph::ROOT, "lib/assets/Actions.md.erb")
|
140
|
+
result = ERB.new(File.read(template), 0, '-').result(binding) # https://web.archive.org/web/20160430190141/www.rrn.dk/rubys-erb-templating-system
|
141
|
+
File.write(File.join(docs_dir, "actions.md"), result)
|
142
|
+
|
143
|
+
# Generate actions sub pages (e.g. actions/slather.md, actions/scan.md)
|
144
|
+
all_actions_ref_yml = []
|
145
|
+
FileUtils.mkdir_p(File.join(docs_dir, "actions"))
|
146
|
+
ActionsList.all_actions do |action|
|
147
|
+
@action = action # to provide a reference in the .html.erb template
|
148
|
+
@action_filename = filename_for_action(action)
|
149
|
+
|
150
|
+
unless @action_filename
|
151
|
+
next
|
152
|
+
end
|
153
|
+
|
154
|
+
# Make sure to always assign `@custom_content`, as we're in a loop and `@` is needed for the `erb`
|
155
|
+
@custom_content = load_custom_action_md(action)
|
156
|
+
|
157
|
+
if action.superclass != Pantograph::Action
|
158
|
+
# This means, the current method is an alias
|
159
|
+
# meaning we're gonna look if the parent class
|
160
|
+
# has a custom md file.
|
161
|
+
@custom_content ||= load_custom_action_md(action.superclass)
|
162
|
+
end
|
163
|
+
|
164
|
+
template = File.join(Pantograph::ROOT, "lib/assets/ActionDetails.md.erb")
|
165
|
+
result = ERB.new(File.read(template), 0, '-').result(binding) # https://web.archive.org/web/20160430190141/www.rrn.dk/rubys-erb-templating-system
|
166
|
+
|
167
|
+
file_name = File.join("actions", "#{action.action_name}.md")
|
168
|
+
File.write(File.join(docs_dir, file_name), result)
|
169
|
+
|
170
|
+
all_actions_ref_yml << { action.action_name => file_name }
|
171
|
+
end
|
172
|
+
|
173
|
+
# Modify the mkdocs.yml to list all the actions
|
174
|
+
mkdocs_yml_path = File.join(target_path, 'mkdocs.yml')
|
175
|
+
raise "Could not find mkdocs.yml in #{target_path}, make sure to point to the pantograph/docs repo" unless File.exist?(mkdocs_yml_path)
|
176
|
+
mkdocs_yml = YAML.load_file(mkdocs_yml_path)
|
177
|
+
hidden_actions_array = mkdocs_yml['nav'].find { |p| !p['Available Actions'].nil? }
|
178
|
+
hidden_actions_array['Available Actions'] = all_actions_ref_yml
|
179
|
+
File.write(mkdocs_yml_path, mkdocs_yml.to_yaml)
|
180
|
+
|
181
|
+
# Copy over the assets from the `actions/docs/assets` directory
|
182
|
+
Dir[File.join(custom_action_docs_path, "assets", "*")].each do |current_asset_path|
|
183
|
+
UI.message("Copying asset #{current_asset_path}")
|
184
|
+
FileUtils.cp(current_asset_path, File.join(docs_dir, "img", "actions", File.basename(current_asset_path)))
|
185
|
+
end
|
186
|
+
|
187
|
+
UI.success("Generated new docs on path #{target_path}")
|
188
|
+
end
|
189
|
+
|
190
|
+
private
|
191
|
+
|
192
|
+
def readable_category_name(category_symbol)
|
193
|
+
case category_symbol
|
194
|
+
when :misc
|
195
|
+
"Misc"
|
196
|
+
when :source_control
|
197
|
+
"Source Control"
|
198
|
+
when :notifications
|
199
|
+
"Notifications"
|
200
|
+
when :documentation
|
201
|
+
"Documentation"
|
202
|
+
when :testing
|
203
|
+
"Testing"
|
204
|
+
when :building
|
205
|
+
"Building"
|
206
|
+
when :push
|
207
|
+
"Push"
|
208
|
+
when :project
|
209
|
+
"Project"
|
210
|
+
when :beta
|
211
|
+
"Beta"
|
212
|
+
when :production
|
213
|
+
"Releasing your app"
|
214
|
+
when :deprecated
|
215
|
+
"Deprecated"
|
216
|
+
else
|
217
|
+
category_symbol.to_s.capitalize
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
@@ -0,0 +1,282 @@
|
|
1
|
+
module Pantograph
|
2
|
+
class EnvironmentPrinter
|
3
|
+
def self.output
|
4
|
+
env_info = get
|
5
|
+
|
6
|
+
# Remove sensitive option values
|
7
|
+
PantographCore::Configuration.sensitive_strings.compact.each do |sensitive_element|
|
8
|
+
env_info.gsub!(sensitive_element, "#########")
|
9
|
+
end
|
10
|
+
|
11
|
+
puts(env_info)
|
12
|
+
UI.important("Take notice that this output may contain sensitive information, or simply information that you don't want to make public.")
|
13
|
+
if PantographCore::Helper.mac? && UI.interactive? && UI.confirm("🙄 Wow, that's a lot of markdown text... should pantograph put it into your clipboard, so you can easily paste it on GitHub?")
|
14
|
+
copy_to_clipboard(env_info)
|
15
|
+
UI.success("Successfully copied markdown into your clipboard 🎨")
|
16
|
+
end
|
17
|
+
UI.success("Open https://github.com/pantograph/pantograph/issues/new to submit a new issue ✅")
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.get
|
21
|
+
UI.important("Generating pantograph environment output, this might take a few seconds...")
|
22
|
+
require "pantograph/markdown_table_formatter"
|
23
|
+
env_output = ""
|
24
|
+
env_output << print_system_environment
|
25
|
+
env_output << print_system_locale
|
26
|
+
env_output << print_pantograph_files
|
27
|
+
env_output << print_loaded_pantograph_gems
|
28
|
+
env_output << print_loaded_plugins
|
29
|
+
env_output << print_loaded_gems
|
30
|
+
env_output << print_date
|
31
|
+
|
32
|
+
# Adding title
|
33
|
+
status = (env_output.include?("🚫") ? "🚫" : "✅")
|
34
|
+
env_header = "<details><summary>#{status} pantograph environment #{status}</summary>\n\n"
|
35
|
+
env_tail = "</details>"
|
36
|
+
final_output = ""
|
37
|
+
|
38
|
+
if PantographCore::Globals.captured_output?
|
39
|
+
final_output << "### Captured Output\n\n"
|
40
|
+
final_output << "Command Used: `#{ARGV.join(' ')}`\n"
|
41
|
+
final_output << "<details><summary>Output/Log</summary>\n\n```\n\n#{PantographCore::Globals.captured_output}\n\n```\n\n</details>\n\n"
|
42
|
+
end
|
43
|
+
|
44
|
+
final_output << env_header + env_output + env_tail
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.print_date
|
48
|
+
date = Time.now.strftime("%Y-%m-%d")
|
49
|
+
"\n*generated on:* **#{date}**\n"
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.print_loaded_plugins
|
53
|
+
ENV["PANTOGRAPH_ENV_PRINTER"] = "enabled"
|
54
|
+
env_output = "### Loaded pantograph plugins:\n"
|
55
|
+
env_output << "\n"
|
56
|
+
plugin_manager = Pantograph::PluginManager.new
|
57
|
+
plugin_manager.load_plugins
|
58
|
+
if plugin_manager.available_plugins.length <= 0
|
59
|
+
env_output << "**No plugins Loaded**\n"
|
60
|
+
else
|
61
|
+
table = ""
|
62
|
+
table << "| Plugin | Version | Update-Status |\n"
|
63
|
+
table << "|--------|---------|\n"
|
64
|
+
plugin_manager.available_plugins.each do |plugin|
|
65
|
+
begin
|
66
|
+
installed_version = Pantograph::ActionCollector.determine_version(plugin)
|
67
|
+
latest_version = PantographCore::UpdateChecker.fetch_latest(plugin)
|
68
|
+
if Gem::Version.new(installed_version) == Gem::Version.new(latest_version)
|
69
|
+
update_status = "✅ Up-To-Date"
|
70
|
+
else
|
71
|
+
update_status = "🚫 Update available"
|
72
|
+
end
|
73
|
+
rescue
|
74
|
+
update_status = "💥 Check failed"
|
75
|
+
end
|
76
|
+
table << "| #{plugin} | #{installed_version} | #{update_status} |\n"
|
77
|
+
end
|
78
|
+
|
79
|
+
rendered_table = MarkdownTableFormatter.new(table)
|
80
|
+
env_output << rendered_table.to_md
|
81
|
+
end
|
82
|
+
|
83
|
+
env_output << "\n\n"
|
84
|
+
env_output
|
85
|
+
end
|
86
|
+
|
87
|
+
# We have this as a separate method, as this has to be handled
|
88
|
+
# slightly differently, depending on how pantograph is being called
|
89
|
+
def self.gems_to_check
|
90
|
+
if Helper.contained_pantograph?
|
91
|
+
Gem::Specification
|
92
|
+
else
|
93
|
+
Gem.loaded_specs.values
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.print_loaded_pantograph_gems
|
98
|
+
# pantographs internal gems
|
99
|
+
env_output = "### pantograph gems\n\n"
|
100
|
+
table = ""
|
101
|
+
table << "| Gem | Version | Update-Status |\n"
|
102
|
+
table << "|-----|---------|------------|\n"
|
103
|
+
pantograph_tools = Pantograph::TOOLS + [:pantograph_core]
|
104
|
+
|
105
|
+
gems_to_check.each do |current_gem|
|
106
|
+
update_status = "N/A"
|
107
|
+
|
108
|
+
next unless pantograph_tools.include?(current_gem.name.to_sym)
|
109
|
+
begin
|
110
|
+
latest_version = PantographCore::UpdateChecker.fetch_latest(current_gem.name)
|
111
|
+
if Gem::Version.new(current_gem.version) >= Gem::Version.new(latest_version)
|
112
|
+
update_status = "✅ Up-To-Date"
|
113
|
+
else
|
114
|
+
update_status = "🚫 Update available"
|
115
|
+
end
|
116
|
+
rescue
|
117
|
+
update_status = "💥 Check failed"
|
118
|
+
end
|
119
|
+
table << "| #{current_gem.name} | #{current_gem.version} | #{update_status} |\n"
|
120
|
+
end
|
121
|
+
|
122
|
+
rendered_table = MarkdownTableFormatter.new(table)
|
123
|
+
env_output << rendered_table.to_md
|
124
|
+
|
125
|
+
env_output << "\n\n"
|
126
|
+
|
127
|
+
return env_output
|
128
|
+
end
|
129
|
+
|
130
|
+
def self.print_loaded_gems
|
131
|
+
env_output = "<details>"
|
132
|
+
env_output << "<summary><b>Loaded gems</b></summary>\n\n"
|
133
|
+
|
134
|
+
table = "| Gem | Version |\n"
|
135
|
+
table << "|-----|---------|\n"
|
136
|
+
gems_to_check.each do |current_gem|
|
137
|
+
unless Pantograph::TOOLS.include?(current_gem.name.to_sym)
|
138
|
+
table << "| #{current_gem.name} | #{current_gem.version} |\n"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
rendered_table = MarkdownTableFormatter.new(table)
|
142
|
+
|
143
|
+
env_output << rendered_table.to_md
|
144
|
+
env_output << "</details>\n\n"
|
145
|
+
return env_output
|
146
|
+
end
|
147
|
+
|
148
|
+
def self.print_system_locale
|
149
|
+
env_output = "### System Locale\n\n"
|
150
|
+
found_one = false
|
151
|
+
env_table = ""
|
152
|
+
["LANG", "LC_ALL", "LANGUAGE"].each do |e|
|
153
|
+
env_icon = "🚫"
|
154
|
+
if ENV[e] && ENV[e].end_with?("UTF-8")
|
155
|
+
env_icon = "✅"
|
156
|
+
found_one = true
|
157
|
+
end
|
158
|
+
if ENV[e].nil?
|
159
|
+
env_icon = ""
|
160
|
+
end
|
161
|
+
env_table << "| #{e} | #{ENV[e]} | #{env_icon} |\n"
|
162
|
+
end
|
163
|
+
if !found_one
|
164
|
+
table = "| Error |\n"
|
165
|
+
table << "|-----|\n"
|
166
|
+
table << "| No Locale with UTF8 found 🚫|\n"
|
167
|
+
else
|
168
|
+
table = "| Variable | Value | |\n"
|
169
|
+
table << "|-----|---------|----|\n"
|
170
|
+
table << env_table
|
171
|
+
end
|
172
|
+
rendered_table = MarkdownTableFormatter.new(table)
|
173
|
+
env_output << rendered_table.to_md
|
174
|
+
env_output << "\n\n"
|
175
|
+
end
|
176
|
+
|
177
|
+
def self.print_system_environment
|
178
|
+
require "openssl"
|
179
|
+
|
180
|
+
env_output = "### Stack\n\n"
|
181
|
+
product, version, build = "Unknown"
|
182
|
+
os_version = "UNKNOWN"
|
183
|
+
|
184
|
+
if Helper.mac?
|
185
|
+
product, version, build = `sw_vers`.strip.split("\n").map { |line| line.split(':').last.strip }
|
186
|
+
os_version = version
|
187
|
+
end
|
188
|
+
|
189
|
+
if Helper.linux?
|
190
|
+
# this should work on pretty much all linux distros
|
191
|
+
os_version = `uname -a`.strip
|
192
|
+
version = ""
|
193
|
+
build = `uname -r`.strip
|
194
|
+
product = `cat /etc/issue.net`.strip
|
195
|
+
|
196
|
+
distro_guesser = {
|
197
|
+
fedora: "/etc/fedora-release",
|
198
|
+
debian_based: "/etc/debian_version",
|
199
|
+
suse: "/etc/SUSE-release",
|
200
|
+
mandrake: "/etc/mandrake-release"
|
201
|
+
}
|
202
|
+
|
203
|
+
distro_guesser.each do |dist, vers|
|
204
|
+
os_version = "#{dist} " + File.read(vers).strip if File.exist?(vers)
|
205
|
+
version = os_version
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
table_content = {
|
210
|
+
"pantograph" => Pantograph::VERSION,
|
211
|
+
"OS" => os_version,
|
212
|
+
"Ruby" => RUBY_VERSION,
|
213
|
+
"Bundler?" => Helper.bundler?,
|
214
|
+
"Git" => `git --version`.strip.split("\n").first,
|
215
|
+
"Installation Source" => anonymized_path($PROGRAM_NAME),
|
216
|
+
"Host" => "#{product} #{version} (#{build})",
|
217
|
+
"Ruby Lib Dir" => anonymized_path(RbConfig::CONFIG['libdir']),
|
218
|
+
"OpenSSL Version" => OpenSSL::OPENSSL_VERSION,
|
219
|
+
"Is contained" => Helper.contained_pantograph?.to_s,
|
220
|
+
"Is homebrew" => Helper.homebrew?.to_s
|
221
|
+
}
|
222
|
+
|
223
|
+
if Helper.mac?
|
224
|
+
table_content["Xcode Path"] = anonymized_path(Helper.xcode_path)
|
225
|
+
begin
|
226
|
+
table_content["Xcode Version"] = Helper.xcode_version
|
227
|
+
rescue => ex
|
228
|
+
UI.error(ex)
|
229
|
+
UI.error("Could not get Xcode Version")
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
table = ["| Key | Value |"]
|
234
|
+
table += table_content.collect { |k, v| "| #{k} | #{v} |" }
|
235
|
+
|
236
|
+
begin
|
237
|
+
rendered_table = MarkdownTableFormatter.new(table.join("\n"))
|
238
|
+
env_output << rendered_table.to_md
|
239
|
+
rescue => ex
|
240
|
+
UI.error(ex)
|
241
|
+
UI.error("Error rendering markdown table using the following text:")
|
242
|
+
UI.message(table.join("\n"))
|
243
|
+
env_output << table.join("\n")
|
244
|
+
end
|
245
|
+
|
246
|
+
env_output << "\n\n"
|
247
|
+
env_output
|
248
|
+
end
|
249
|
+
|
250
|
+
def self.print_pantograph_files
|
251
|
+
env_output = "### pantograph files:\n\n"
|
252
|
+
|
253
|
+
pantograph_path = PantographCore::PantographFolder.pantfile_path
|
254
|
+
|
255
|
+
if pantograph_path && File.exist?(pantograph_path)
|
256
|
+
env_output << "<details>"
|
257
|
+
env_output << "<summary>`#{pantograph_path}`</summary>\n"
|
258
|
+
env_output << "\n"
|
259
|
+
env_output << "```ruby\n"
|
260
|
+
env_output << File.read(pantograph_path, encoding: "utf-8")
|
261
|
+
env_output << "\n```\n"
|
262
|
+
env_output << "</details>"
|
263
|
+
else
|
264
|
+
env_output << "**No Pantfile found**\n"
|
265
|
+
end
|
266
|
+
env_output << "\n\n"
|
267
|
+
env_output
|
268
|
+
end
|
269
|
+
|
270
|
+
def self.anonymized_path(path, home = ENV['HOME'])
|
271
|
+
return home ? path.gsub(%r{^#{home}(?=/(.*)|$)}, '~\2') : path
|
272
|
+
end
|
273
|
+
|
274
|
+
# Copy a given string into the clipboard
|
275
|
+
# Make sure to ask the user first, as some people don't
|
276
|
+
# use a clipboard manager, so they might lose something important
|
277
|
+
def self.copy_to_clipboard(string)
|
278
|
+
require 'open3'
|
279
|
+
Open3.popen3('pbcopy') { |input, _, _| input << string }
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Pantograph
|
2
|
+
class ErbTemplateHelper
|
3
|
+
require "erb"
|
4
|
+
def self.load(template_name)
|
5
|
+
path = "#{Pantograph::ROOT}/lib/assets/#{template_name}.erb"
|
6
|
+
load_from_path(path)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.load_from_path(template_filepath)
|
10
|
+
unless File.exist?(template_filepath)
|
11
|
+
UI.user_error!("Could not find template at path '#{template_filepath}'")
|
12
|
+
end
|
13
|
+
File.read(template_filepath)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.render(template, template_vars_hash, trim_mode = nil)
|
17
|
+
Pantograph::ErbalT.new(template_vars_hash, trim_mode).render(template)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
class ErbalT < OpenStruct
|
21
|
+
def initialize(hash, trim_mode = nil)
|
22
|
+
super(hash)
|
23
|
+
@trim_mode = trim_mode
|
24
|
+
end
|
25
|
+
|
26
|
+
def render(template)
|
27
|
+
ERB.new(template, nil, @trim_mode).result(binding)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
### pantograph Helper
|
2
|
+
|
3
|
+
You can put shared code into this folder. Use this if you need to access the same code from multiple actions or to just clean up the actual action.
|
4
|
+
|
5
|
+
To create a new helper, duplicate the `podspec_helper.rb`, rename the class and put your code inside the class.
|
6
|
+
|
7
|
+
Make sure it's structured like this:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
module Pantograph
|
11
|
+
module Helper
|
12
|
+
class PodspecHelper
|
13
|
+
...
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
```
|
18
|
+
|
19
|
+
The `git_helper` and `sh_helper` are different, please make sure to build something like `podspec_helper`.
|
20
|
+
|
21
|
+
### Use of the helper class
|
22
|
+
|
23
|
+
To access the helper class use
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
Helper::PodspecHelper....
|
27
|
+
```
|
28
|
+
|
29
|
+
Make sure to prefix your helper with the `Helper::` module.
|