fastlane-plugin-changelog 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57b4471d6ae10ef7b6da62051f240fb79d9e427f
4
- data.tar.gz: 2b694ab107d07ad643185320131bf20590b04707
3
+ metadata.gz: 217045bc188429e310a1e0a6c5733c0ff8dcab0a
4
+ data.tar.gz: b861687d566ac30feac7866f2b1273d09e6c891b
5
5
  SHA512:
6
- metadata.gz: f00afaa4410d6b32a8ba12974983f7f5e3c7a53486d58f07a7f5a4bec44dbcddf9b6e055e96c8d2e5afd298d0f5624de02e156a07fa1da6b8bdfb74991d410d8
7
- data.tar.gz: 01ef33dd468b606a62c224381fb68745fbea6743729fdb129fcc7eb9aaa4bb5e07696ce94684d75e721c81b97ea17065e104812ba47f79627792505af1bfdaf4
6
+ metadata.gz: 704b66ac13237ca0772114f88053978886e8e4960620bbf6b8e408efee3da2c58d836c63c01ba113d3403786f2420ba858b71f728b1024fbf6523e59d1d1fec6
7
+ data.tar.gz: 8da58cd64910ec0d72bfdc15382469228088069c3cdc594290cc2253da89672e281581e281aa0d6a28062fceabd1b7a09e2321ab6545d9f879d104f9543f5a39
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 Pavel Procházka <pprochazka72@gmail.com>
3
+ Copyright (c) 2018 Pavel Procházka <pprochazka72@gmail.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -2,69 +2,11 @@ require 'fastlane/plugin/changelog/version'
2
2
 
3
3
  module Fastlane
4
4
  module Changelog
5
- CHANGELOG_PATH = './CHANGELOG.md'
6
- DEFAULT_CHANGELOG = '# Change Log
7
- All notable changes to this project will be documented in this file.
8
-
9
- The format is based on [Keep a Changelog](http://keepachangelog.com/)
10
- and this project adheres to [Semantic Versioning](http://semver.org/).
11
-
12
- ## [Unreleased]
13
- ### Added
14
- - Your awesome new feature'
15
-
16
5
  # Return all .rb files inside the "actions" and "helper" directory
17
6
  def self.all_classes
18
7
  Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
19
8
  end
20
9
 
21
- # Offer user to setup CHANGELOG.md file in project folder (unless it already exists)
22
- def self.setup_changelog
23
- unless has_changelog?
24
- if FastlaneCore::UI.confirm('Your project folder does not have CHANGELOG.md - do you want to create one now?')
25
- create_changelog
26
-
27
- FastlaneCore::UI.message('Changelog plugin can automaticaly create a link for comparison between two tags (see https://github.com/pajapro/fastlane-plugin-changelog#--stamp_changelog)')
28
- if FastlaneCore::UI.confirm('Do you want to create links for comparing tags?')
29
- repo_url = FastlaneCore::UI.input('Enter your GitHub or Bitbucket repository URL (e.g.: https://github.com/owner/project or https://bitbucket.org/owner/project):')
30
- create_comparison_link(repo_url)
31
- else
32
- write_to_changelog(DEFAULT_CHANGELOG)
33
- end
34
- end
35
- end
36
- end
37
-
38
- # Does CHANGELOG.md exists in project folder?
39
- def self.has_changelog?
40
- File.exist?(CHANGELOG_PATH)
41
- end
42
-
43
- # Create CHANGELOG.md file
44
- def self.create_changelog
45
- FileUtils.touch 'CHANGELOG.md'
46
- end
47
-
48
- # Create a link for tag comparison
49
- def self.create_comparison_link(repo_url)
50
- if repo_url.start_with?('https://github.com')
51
- output = DEFAULT_CHANGELOG + "\n\n[Unreleased]: #{repo_url}/compare/master...HEAD"
52
- write_to_changelog(output)
53
- elsif repo_url.start_with?('https://bitbucket.org')
54
- output = DEFAULT_CHANGELOG + "\n\n[Unreleased]: #{repo_url}/compare/master..HEAD"
55
- write_to_changelog(output)
56
- else
57
- FastlaneCore::UI.error('Unknown repository host')
58
- FastlaneCore::UI.message('Creating CHANGELOG.md without links for comparing tags')
59
- write_to_changelog(DEFAULT_CHANGELOG)
60
- end
61
- end
62
-
63
- # Write given content to CHANGELOG.md
64
- def self.write_to_changelog(changelog)
65
- File.open(CHANGELOG_PATH, 'w') { |f| f.write(changelog) }
66
- FastlaneCore::UI.success('Successfuly created CHANGELOG.md')
67
- end
68
10
  end
69
11
  end
70
12
 
@@ -73,6 +15,3 @@ end
73
15
  Fastlane::Changelog.all_classes.each do |current|
74
16
  require current
75
17
  end
76
-
77
- # By default we want to ensure CHANGELOG.md is present
78
- Fastlane::Changelog.setup_changelog
@@ -8,7 +8,7 @@ module Fastlane
8
8
  class ReadChangelogAction < Action
9
9
  def self.run(params)
10
10
  changelog_path = params[:changelog_path] unless params[:changelog_path].to_s.empty?
11
- UI.error("CHANGELOG.md at path '#{changelog_path}' does not exist") unless File.exist?(changelog_path)
11
+ changelog_path = Helper::ChangelogHelper.ensure_changelog_exists(changelog_path)
12
12
 
13
13
  section_identifier = params[:section_identifier] unless params[:section_identifier].to_s.empty?
14
14
  escaped_section_identifier = Regexp.escape(section_identifier[/\[(.*?)\]/, 1])
@@ -77,7 +77,7 @@ module Fastlane
77
77
  def self.available_options
78
78
  [
79
79
  FastlaneCore::ConfigItem.new(key: :changelog_path,
80
- env_name: "FL_READ_CHANGELOG_PATH_TO_CHANGELOG",
80
+ env_name: "FL_CHANGELOG_PATH",
81
81
  description: "The path to your project CHANGELOG.md",
82
82
  is_string: true,
83
83
  default_value: "./CHANGELOG.md",
@@ -6,7 +6,7 @@ module Fastlane
6
6
  def self.run(params)
7
7
  # 1. Ensure CHANGELOG.md exists
8
8
  changelog_path = params[:changelog_path] unless params[:changelog_path].to_s.empty?
9
- UI.error("CHANGELOG.md at path '#{changelog_path}' does not exist") unless File.exist?(changelog_path)
9
+ changelog_path = Helper::ChangelogHelper.ensure_changelog_exists(changelog_path)
10
10
 
11
11
  # 2. Ensure there are changes in [Unreleased] section
12
12
  unreleased_section_content = Actions::ReadChangelogAction.run(changelog_path: changelog_path, section_identifier: UNRELEASED_IDENTIFIER, excluded_markdown_elements: ["###"])
@@ -108,7 +108,7 @@ module Fastlane
108
108
  def self.available_options
109
109
  [
110
110
  FastlaneCore::ConfigItem.new(key: :changelog_path,
111
- env_name: "FL_STAMP_CHANGELOG_PATH_TO_CHANGELOG",
111
+ env_name: "FL_CHANGELOG_PATH",
112
112
  description: "The path to your project CHANGELOG.md",
113
113
  is_string: true,
114
114
  default_value: "./CHANGELOG.md",
@@ -3,7 +3,7 @@ module Fastlane
3
3
  class UpdateChangelogAction < Action
4
4
  def self.run(params)
5
5
  changelog_path = params[:changelog_path] unless params[:changelog_path].to_s.empty?
6
- UI.error("CHANGELOG.md at path '#{changelog_path}' does not exist") unless File.exist?(changelog_path)
6
+ changelog_path = Helper::ChangelogHelper.ensure_changelog_exists(changelog_path)
7
7
 
8
8
  section_identifier = params[:section_identifier] unless params[:section_identifier].to_s.empty?
9
9
  escaped_section_identifier = section_identifier[/\[(.*?)\]/, 1]
@@ -95,7 +95,7 @@ module Fastlane
95
95
  def self.available_options
96
96
  [
97
97
  FastlaneCore::ConfigItem.new(key: :changelog_path,
98
- env_name: "FL_UPDATE_CHANGELOG_PATH_TO_CHANGELOG",
98
+ env_name: "FL_CHANGELOG_PATH",
99
99
  description: "The path to your project CHANGELOG.md",
100
100
  is_string: true,
101
101
  default_value: "./CHANGELOG.md",
@@ -1,13 +1,74 @@
1
1
  module Fastlane
2
2
  module Helper
3
+ CHANGELOG_PATH = './CHANGELOG.md'
4
+ DEFAULT_CHANGELOG = '# Change Log
5
+ All notable changes to this project will be documented in this file.
6
+
7
+ The format is based on [Keep a Changelog](http://keepachangelog.com/)
8
+ and this project adheres to [Semantic Versioning](http://semver.org/).
9
+
10
+ ## [Unreleased]
11
+ ### Added
12
+ - Your awesome new feature'
13
+
14
+ # TODO: ❗️ Add unit tests for methods in this class
3
15
  class ChangelogHelper
4
- # class methods that you define here become available in your action
5
- # as `Helper::ChangelogHelper.your_method`
6
- #
7
- def self.show_message
8
- UI.message("Hello from the changelog plugin helper!")
16
+
17
+ # Ensures CHANGELOG.md exists at given path. If not, offers to create a default one.
18
+ # Returns path to CHANGELOG.md to be used
19
+ def self.ensure_changelog_exists(path)
20
+ if File.exist?(path)
21
+ FastlaneCore::UI.success "Found CHANGELOG.md at #{path}"
22
+ path
23
+ else
24
+ FastlaneCore::UI.message("Cannot find CHANGELOG.md at #{path}")
25
+ generate_changelog
26
+ CHANGELOG_PATH
27
+ end
28
+ end
29
+
30
+ # Generates CHANGELOG.md in project root
31
+ def self.generate_changelog
32
+ if FastlaneCore::UI.confirm('Do you want to generate default CHANGELOG.md in the project root?')
33
+ FileUtils.touch 'CHANGELOG.md'
34
+ generate_comparison_link
35
+ else
36
+ FastlaneCore::UI.error("Cannot continue without CHANGELOG.md file")
37
+ end
9
38
  end
10
39
 
40
+ # Generates link for tag comparison
41
+ def self.generate_comparison_link
42
+ FastlaneCore::UI.message('Changelog plugin can automaticaly create a link for comparison between two tags (see https://github.com/pajapro/fastlane-plugin-changelog#--stamp_changelog)')
43
+ if FastlaneCore::UI.confirm('Do you want to create links for comparing tags?')
44
+ repo_url = FastlaneCore::UI.input('Enter your GitHub or Bitbucket repository URL (e.g.: https://github.com/owner/project or https://bitbucket.org/owner/project):')
45
+ compose_comparison_link(repo_url)
46
+ else
47
+ write_to_changelog(DEFAULT_CHANGELOG)
48
+ end
49
+ end
50
+
51
+ # Composes link for tag comparison for GitHub or Bitbucket
52
+ def self.compose_comparison_link(repo_url)
53
+ if repo_url.start_with?('https://github.com')
54
+ output = DEFAULT_CHANGELOG + "\n\n[Unreleased]: #{repo_url}/compare/master...HEAD"
55
+ write_to_changelog(output)
56
+ elsif repo_url.start_with?('https://bitbucket.org')
57
+ output = DEFAULT_CHANGELOG + "\n\n[Unreleased]: #{repo_url}/compare/master..HEAD"
58
+ write_to_changelog(output)
59
+ else
60
+ FastlaneCore::UI.error('Unknown repository host')
61
+ FastlaneCore::UI.message('Creating CHANGELOG.md without links for comparing tags')
62
+ write_to_changelog(DEFAULT_CHANGELOG)
63
+ end
64
+ end
65
+
66
+ # Writes given content to CHANGELOG.md in project root
67
+ def self.write_to_changelog(changelog)
68
+ File.open(CHANGELOG_PATH, 'w') { |f| f.write(changelog) }
69
+ FastlaneCore::UI.success('Successfuly created CHANGELOG.md')
70
+ end
71
+
11
72
  def self.get_line_separator(file_path)
12
73
  f = File.open(file_path)
13
74
  enum = f.each_char
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Changelog
3
- VERSION = "0.9.0"
3
+ VERSION = "0.10.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-changelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Prochazka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-25 00:00:00.000000000 Z
11
+ date: 2018-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.96.0
33
+ version: 2.0.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 1.96.0
40
+ version: 2.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement