Skip to content

Commit

Permalink
Command-line options and Markdown output
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRandomLabs committed Feb 5, 2021
1 parent c10a0a0 commit e4b7d16
Show file tree
Hide file tree
Showing 13 changed files with 355 additions and 104 deletions.
29 changes: 0 additions & 29 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ ij_visual_guides = 100
ij_wrap_on_typing = false

[*.css]
ij_visual_guides = none
ij_css_align_closing_brace_with_properties = false
ij_css_blank_lines_around_nested_selector = 1
ij_css_blank_lines_between_blocks = 1
Expand All @@ -35,19 +34,15 @@ ij_css_use_double_quotes = true
ij_css_value_alignment = do_not_align

[*.feature]
ij_visual_guides = none
ij_gherkin_keep_indents_on_empty_lines = false

[*.gsp]
ij_visual_guides = none
ij_gsp_keep_indents_on_empty_lines = false

[*.haml]
ij_visual_guides = none
ij_haml_keep_indents_on_empty_lines = false

[*.java]
ij_visual_guides = none
ij_java_align_consecutive_assignments = false
ij_java_align_consecutive_variable_declarations = false
ij_java_align_group_field_declarations = false
Expand Down Expand Up @@ -296,7 +291,6 @@ ij_java_wrap_first_method_in_call_chain = false
ij_java_wrap_long_lines = false

[*.less]
ij_visual_guides = none
ij_less_align_closing_brace_with_properties = false
ij_less_blank_lines_around_nested_selector = 1
ij_less_blank_lines_between_blocks = 1
Expand All @@ -316,10 +310,7 @@ ij_less_use_double_quotes = true
ij_less_value_alignment = 0

[*.nbtt]
indent_style = space
max_line_length = 150
ij_continuation_indent_size = 4
ij_visual_guides = none
ij_nbtt_keep_indents_on_empty_lines = false
ij_nbtt_space_after_colon = true
ij_nbtt_space_after_comma = true
Expand All @@ -329,7 +320,6 @@ ij_nbtt_spaces_within_brackets = false
ij_nbtt_spaces_within_parentheses = false

[*.sass]
ij_visual_guides = none
ij_sass_align_closing_brace_with_properties = false
ij_sass_blank_lines_around_nested_selector = 1
ij_sass_blank_lines_between_blocks = 1
Expand All @@ -349,7 +339,6 @@ ij_sass_use_double_quotes = true
ij_sass_value_alignment = 0

[*.scss]
ij_visual_guides = none
ij_scss_align_closing_brace_with_properties = false
ij_scss_blank_lines_around_nested_selector = 1
ij_scss_blank_lines_between_blocks = 1
Expand All @@ -369,7 +358,6 @@ ij_scss_use_double_quotes = true
ij_scss_value_alignment = 0

[*.styl]
ij_visual_guides = none
ij_stylus_align_closing_brace_with_properties = false
ij_stylus_blank_lines_around_nested_selector = 1
ij_stylus_blank_lines_between_blocks = 1
Expand All @@ -389,7 +377,6 @@ ij_stylus_use_double_quotes = true
ij_stylus_value_alignment = 0

[.editorconfig]
ij_visual_guides = none
ij_editorconfig_align_group_field_declarations = false
ij_editorconfig_space_after_colon = false
ij_editorconfig_space_after_comma = true
Expand All @@ -398,7 +385,6 @@ ij_editorconfig_space_before_comma = false
ij_editorconfig_spaces_around_assignment_operators = true

[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.pom,*.rng,*.tld,*.wadl,*.wsdd,*.wsdl,*.xjb,*.xml,*.xsd,*.xsl,*.xslt,*.xul}]
ij_visual_guides = none
ij_xml_align_attributes = true
ij_xml_align_text = false
ij_xml_attribute_wrap = normal
Expand All @@ -418,7 +404,6 @@ ij_xml_text_wrap = normal
ij_xml_use_custom_settings = false

[{*.ats,*.ts}]
ij_visual_guides = none
ij_typescript_align_imports = false
ij_typescript_align_multiline_array_initializer_expression = false
ij_typescript_align_multiline_binary_operation = false
Expand Down Expand Up @@ -586,7 +571,6 @@ ij_typescript_while_on_new_line = false
ij_typescript_wrap_comments = false

[{*.bash,*.sh,*.zsh}]
ij_visual_guides = none
ij_shell_binary_ops_start_line = false
ij_shell_keep_column_alignment_padding = false
ij_shell_minify_program = false
Expand All @@ -595,7 +579,6 @@ ij_shell_switch_cases_indented = false

[{*.cjs,*.js}]
ij_continuation_indent_size = 4
ij_visual_guides = none
ij_javascript_align_imports = false
ij_javascript_align_multiline_array_initializer_expression = false
ij_javascript_align_multiline_binary_operation = false
Expand Down Expand Up @@ -761,7 +744,6 @@ ij_javascript_wrap_comments = false

[{*.cjsx,*.coffee}]
ij_continuation_indent_size = 4
ij_visual_guides = none
ij_coffeescript_align_function_body = false
ij_coffeescript_align_imports = false
ij_coffeescript_align_multiline_array_initializer_expression = true
Expand Down Expand Up @@ -856,11 +838,9 @@ ij_coffeescript_use_semicolon_after_statement = false
ij_coffeescript_var_declaration_wrap = normal

[{*.ft,*.vm,*.vsl}]
ij_visual_guides = none
ij_vtl_keep_indents_on_empty_lines = false

[{*.gant,*.gradle,*.groovy,*.gson,*.gy}]
ij_visual_guides = none
ij_groovy_align_group_field_declarations = false
ij_groovy_align_multiline_array_initializer_expression = false
ij_groovy_align_multiline_assignment = false
Expand Down Expand Up @@ -1040,7 +1020,6 @@ ij_groovy_while_on_new_line = false
ij_groovy_wrap_long_lines = false

[{*.gradle.kts,*.kt,*.kts,*.main.kts}]
ij_visual_guides = none
ij_kotlin_align_in_columns_case_branch = false
ij_kotlin_align_multiline_binary_operation = false
ij_kotlin_align_multiline_extends_list = false
Expand Down Expand Up @@ -1122,7 +1101,6 @@ ij_kotlin_wrap_expression_body_functions = 1
ij_kotlin_wrap_first_method_in_call_chain = false

[{*.har,*.jsb2,*.jsb3,*.json,*.mcmeta,.babelrc,.eslintrc,.stylelintrc,bowerrc,jest.config,mcmod.info}]
ij_visual_guides = none
ij_json_keep_blank_lines_in_code = 0
ij_json_keep_indents_on_empty_lines = false
ij_json_keep_line_breaks = true
Expand All @@ -1135,7 +1113,6 @@ ij_json_spaces_within_brackets = false
ij_json_wrap_long_lines = false

[{*.htm,*.html,*.ng,*.sht,*.shtm,*.shtml}]
ij_visual_guides = none
ij_html_add_new_line_before_tags = body,div,p,form,h1,h2,h3
ij_html_align_attributes = true
ij_html_align_text = false
Expand Down Expand Up @@ -1164,29 +1141,23 @@ ij_html_text_wrap = normal
ij_html_uniform_ident = false

[{*.jsf,*.jsp,*.jspf,*.tag,*.tagf,*.xjsp}]
ij_visual_guides = none
ij_jsp_jsp_prefer_comma_separated_import_list = false
ij_jsp_keep_indents_on_empty_lines = false

[{*.jspx,*.tagx}]
ij_visual_guides = none
ij_jspx_keep_indents_on_empty_lines = false

[{*.properties,spring.handlers,spring.schemas}]
ij_visual_guides = none
ij_properties_align_group_field_declarations = false
ij_properties_keep_blank_lines = false
ij_properties_key_value_delimiter = equals
ij_properties_spaces_around_key_value_delimiter = false

[{*.toml,Cargo.lock,Gopkg.lock,Pipfile}]
indent_style = space
ij_visual_guides = none
ij_toml_keep_indents_on_empty_lines = false

[{*.yaml,*.yml}]
indent_size = 2
ij_visual_guides = none
ij_yaml_keep_indents_on_empty_lines = false
ij_yaml_keep_line_breaks = true
ij_yaml_space_before_colon = true
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ Generates changelogs for CurseForge modpacks.

All public-facing code is documented with Javadoc and (mostly) tested with JUnit.

## How to use?
1. Put the `manifest.json` from your old version in a folder and rename it to `old.json`.
2. Put the `manifest.json` from your new version in the same folder and rename it to `new.json`.
3. Execute the `ChangelogGenerator.jar` by double-clicking it in the same folder.
4. Wait for the `changelog.txt`.
## Usage

Run `java -jar ChangelogGenerator-[version].jar --help` for command-line usage instructions.
13 changes: 10 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
group = "com.therandomlabs.changeloggenerator"
version = "2.0.0-pre5"
version = "2.0.0-pre6"

ext {
commonGradleBranch = "master"
mainClass = "${group}.Main"
mainClass = "${group}.ChangelogGeneratorOptions"
jacocoExcludes = [
"com.therandomlabs.changeloggenerator.ChangelogEntry",
"com.therandomlabs.changeloggenerator.Main"
"com.therandomlabs.changeloggenerator.ChangelogGeneratorOptions"
]
}

Expand All @@ -22,7 +22,14 @@ dependencies {
api "com.github.TheRandomLabs:CurseAPI:master-SNAPSHOT"
api "com.github.TheRandomLabs:CurseAPI-Minecraft:master-SNAPSHOT"

implementation "info.picocli:picocli:4.6.1"
annotationProcessor "info.picocli:picocli-codegen:4.6.1"

implementation "com.atlassian.commonmark:commonmark:0.13.1"

testImplementation "com.github.TheRandomLabs:TRLUtils-IO:master-SNAPSHOT"
}

compileJava {
options.compilerArgs += "-Aproject=${project.group}/${project.name}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ public class BasicChangelogGenerator extends ChangelogGenerator {
*/
public static final BasicChangelogGenerator instance = new BasicChangelogGenerator();

private static final Splitter LINE_SEPARATOR_SPLITTER = Splitter.on(System.lineSeparator()).
/**
* A {@link Splitter} that works on line separators.
* Empty strings are omitted, and results are trimmed.
*/
protected static final Splitter LINE_SEPARATOR_SPLITTER = Splitter.on(System.lineSeparator()).
omitEmptyStrings().
trimResults();

Expand All @@ -67,7 +71,9 @@ protected BasicChangelogGenerator() {
* {@inheritDoc}
*/
@Override
public String generate(CurseModpack oldModpack, CurseModpack newModpack) throws CurseException {
public String generate(
CurseModpack oldModpack, CurseModpack newModpack, ChangelogGeneratorOptions options
) throws CurseException {
final CurseFilesComparison<BasicCurseFile> comparison =
CurseFilesComparison.of(oldModpack.files(), newModpack.files());
final StringBuilder builder = new StringBuilder();
Expand Down Expand Up @@ -167,7 +173,7 @@ protected void appendFiles(
);

for (String projectName : projectNames) {
builder.append(System.lineSeparator()).append("- ").append(projectName);
builder.append(System.lineSeparator()).append("* ").append(projectName);
}
}

Expand All @@ -183,7 +189,7 @@ protected void appendFiles(
protected void appendChangelogEntries(
StringBuilder builder, String title, Set<CurseFileChange<BasicCurseFile>> fileChanges
) throws CurseException {
builder.append(title).append(':');
appendTitle(builder, title);

final Map<String, ChangelogEntries> allEntries = new TreeMap<>(CurseAPI.parallelMap(
fileChanges,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package com.therandomlabs.changeloggenerator;

import com.google.common.base.MoreObjects;
import okhttp3.HttpUrl;
import org.jsoup.nodes.Element;

/**
Expand All @@ -32,19 +33,22 @@
public final class ChangelogEntry implements Comparable<ChangelogEntry> {
private final Comparable<?> comparable;
private final String title;
private final HttpUrl url;
private Element entry;

/**
* Constructs a {@link ChangelogEntry} instance with the specified title and entry.
* Constructs a {@link ChangelogEntry} instance with the specified title, entry and URL.
*
* @param comparable a {@link Comparable} for use in sorting. Changelog entries for newer
* files should be sorted first.
* @param title a title.
* @param url a URL.
* @param entry a changelog entry.
*/
public ChangelogEntry(Comparable<?> comparable, String title, Element entry) {
public ChangelogEntry(Comparable<?> comparable, String title, HttpUrl url, Element entry) {
this.comparable = comparable;
this.title = title;
this.url = url;
this.entry = entry;
}

Expand Down Expand Up @@ -94,6 +98,14 @@ public String title() {
return title;
}

/**
* Returns this {@link ChangelogEntry}'s URL.
* @return this {@link ChangelogEntry}'s URL.
*/
public HttpUrl url() {
return url;
}

/**
* Returns this {@link ChangelogEntry}'s changelog entry.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,25 @@ public ChangelogEntries getChangelogEntries(
* @return the generated changelog.
* @throws CurseException if an error occurs.
*/
public abstract String generate(CurseModpack oldModpack, CurseModpack newModpack)
throws CurseException;
public String generate(CurseModpack oldModpack, CurseModpack newModpack) throws CurseException {
return generate(oldModpack, newModpack, new ChangelogGeneratorOptions());
}

/**
* Generates a changelog that details changes between an older and newer version of a
* CurseForge modpack.
*
* @param oldModpack a {@link CurseModpack} instance that represents an older version of a
* CurseForge modpack.
* @param newModpack a {@link CurseModpack} instance that represents a newer version of a
* CurseForge modpack.
* @param options ChangelogGenerator options.
* @return the generated changelog.
* @throws CurseException if an error occurs.
*/
public abstract String generate(
CurseModpack oldModpack, CurseModpack newModpack, ChangelogGeneratorOptions options
) throws CurseException;

/**
* Registers the specified {@link ChangelogProvider} to this {@link ChangelogGenerator}
Expand Down
Loading

0 comments on commit e4b7d16

Please sign in to comment.