Class: AlFolioUpgrade::CLI
- Inherits:
-
Object
- Object
- AlFolioUpgrade::CLI
- Defined in:
- lib/al_folio_upgrade/cli.rb
Defined Under Namespace
Classes: Finding
Constant Summary collapse
- REPORT_PATH =
"al-folio-upgrade-report.md"- FILE_GLOBS =
[ "_config.yml", "_includes/**/*.{liquid,html}", "_layouts/**/*.{liquid,html}", "_pages/**/*.{md,markdown,liquid,html}", "_posts/**/*.{md,markdown,liquid,html}", "assets/js/**/*.js", "assets/css/**/*.css", "assets/tailwind/**/*.css", ].freeze
- IGNORE_PATH_PATTERNS =
[ /\/distillpub\//, /\/search\/ninja-footer\.min\.js$/, /\/bootstrap\.bundle\.min\.js$/, /\/bootstrap-toc\.min\.js$/, /\.min\.js$/, /\.map$/, ].freeze
- SAFE_REPLACEMENTS =
[ { from: /\bfont-weight-bold\b/, to: "font-bold" }, { from: /\bfont-weight-medium\b/, to: "font-medium" }, { from: /\bfont-weight-lighter\b/, to: "font-light" }, { from: %r{https://distill\.pub/template\.v2\.js}, to: "/assets/js/distillpub/template.v2.js" }, { from: %r{assets/tailwind/input\.css}, to: "assets/tailwind/app.css" }, ].freeze
- CORE_OVERRIDE_FILES =
%w[ _includes/head.liquid _includes/scripts.liquid _layouts/default.liquid _layouts/post.liquid _layouts/page.liquid _layouts/distill.liquid assets/js/common.js assets/js/theme.js assets/js/tooltips-setup.js assets/tailwind/app.css tailwind.config.js ].freeze
- PLUGIN_OWNED_LOCAL_PATHS =
{ "_plugins/external-posts.rb" => "al_ext_posts", "_plugins/google-scholar-citations.rb" => "al_citations", "_plugins/inspirehep-citations.rb" => "al_citations", "_plugins/hide-custom-bibtex.rb" => "al_folio_core", "_plugins/details.rb" => "al_folio_core", "_plugins/file-exists.rb" => "al_folio_core", "_plugins/remove-accents.rb" => "al_folio_core", "assets/js/distillpub/**/*" => "al_folio_distill", "assets/js/search/**/*" => "al_search", "assets/webfonts/**/*" => "al_icons", "assets/fonts/academicons.*" => "al_icons", "assets/fonts/scholar-icons.*" => "al_icons" }.freeze
Instance Method Summary collapse
-
#initialize(root: Dir.pwd, stdout: $stdout, stderr: $stderr) ⇒ CLI
constructor
A new instance of CLI.
- #run(argv) ⇒ Object
Constructor Details
Instance Method Details
#run(argv) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/al_folio_upgrade/cli.rb', line 83 def run(argv) return usage(1) if argv.empty? command = argv.shift unless command == "upgrade" @stderr.puts("Unsupported command: #{command}") return usage(1) end subcommand = argv.shift case subcommand when "audit" = { fail_on_blocking: true } OptionParser.new do |opts| opts.on("--no-fail", "Do not fail even when blocking findings exist") do [:fail_on_blocking] = false end end.parse!(argv) findings = audit write_report(findings) print_summary(findings) return 1 if [:fail_on_blocking] && blocking?(findings) 0 when "apply" = { safe: false } OptionParser.new do |opts| opts.on("--safe", "Apply only deterministic safe codemods") do [:safe] = true end end.parse!(argv) unless [:safe] @stderr.puts("Only --safe mode is supported in v1.x.") return 1 end changed_files = apply_safe_codemods findings = audit write_report(findings) @stdout.puts("Applied safe codemods to #{changed_files} file(s).") print_summary(findings) 0 when "report" findings = audit write_report(findings) print_summary(findings) 0 else @stderr.puts("Unsupported subcommand: #{subcommand.inspect}") usage(1) end end |