Skip to content

Commit

Permalink
Merge pull request #223 from marhali/223-combat
Browse files Browse the repository at this point in the history
223 combat
  • Loading branch information
marhali authored Feb 19, 2023
2 parents f154c2d + d7d2880 commit ce0b3d3
Show file tree
Hide file tree
Showing 16 changed files with 159 additions and 648 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:

# Validate wrapper
- name: Gradle Wrapper Validation
uses: gradle/[email protected].4
uses: gradle/[email protected].5

# Setup Java 11 environment for the next steps
- name: Setup Java
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
# Run tests
- name: Run Tests
run: ./gradlew test
run: ./gradlew check

# Collect Tests Result of failed tests
- name: Collect Tests Result
Expand All @@ -87,6 +87,12 @@ jobs:
name: tests-result
path: ${{ github.workspace }}/build/reports/tests

# Upload Kover report to CodeCov
- name: Upload Code Coverage Report
uses: codecov/codecov-action@v3
with:
files: ${{ github.workspace }}/build/reports/kover/xml/report.xml

# Cache Plugin Verifier IDEs
- name: Setup Plugin Verifier IDEs Cache
uses: actions/cache@v3
Expand All @@ -108,7 +114,7 @@ jobs:

# Run Qodana inspections
- name: Qodana - Code Inspection
uses: JetBrains/[email protected].1
uses: JetBrains/[email protected].3

# Prepare plugin archive content for creating artifact
- name: Prepare Plugin Artifact
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,21 @@ jobs:
run: |
VERSION="${{ github.event.release.tag_name }}"
BRANCH="changelog-update-$VERSION"
LABEL="release changelog"
git config user.email "[email protected]"
git config user.name "GitHub Action"
git checkout -b $BRANCH
git commit -am "Changelog update - $VERSION"
git push --set-upstream origin $BRANCH
gh label create "$LABEL" \
--description "Pull requests with release changelog update" \
|| true
gh pr create \
--title "Changelog update - \`$VERSION\`" \
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
--base main \
--label "$LABEL" \
--head $BRANCH
2 changes: 1 addition & 1 deletion .github/workflows/run-ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:

# Wait for IDEA to be started
- name: Health Check
uses: jtalk/url-health-check-action@v2
uses: jtalk/url-health-check-action@v3
with:
url: http://127.0.0.1:8082
max-attempts: 15
Expand Down
16 changes: 13 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@
# easy-i18n Changelog

## [Unreleased]
### Changed
- Dropped support for IDE versions older than 2022.2
- Updated dependencies
- Removed deprecated API access (TranslatorToolWindowFactory)
- Replaced YAML mapping with own implementation

### Fixed
- Support for all 2023.1 builds (231.*)
- Exception on file change listener
- Broken badge link in README

## [4.4.0]
### Added
- Support of path variables for the locales directory configuration @SIMULATAN
### Added
- Support of path variables for the locales directory configuration @SIMULATAN

### Changed
### Changed
- Restructure form actions to improve user experience

## [4.3.1]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div id="top"></div>

<!-- PROJECT SHIELDS -->
[![Build](https://img.shields.io/github/workflow/status/marhali/easy-i18n/Build?style=for-the-badge)](https://github.com/marhali/easy-i18n/actions)
[![Build](https://img.shields.io/github/actions/workflow/status/marhali/easy-i18n/build.yml?branch=main&style=for-the-badge)](https://github.com/marhali/easy-i18n/actions)
[![Version](https://img.shields.io/jetbrains/plugin/v/16316.svg?style=for-the-badge)](https://plugins.jetbrains.com/plugin/16316)
[![Downloads](https://img.shields.io/jetbrains/plugin/d/16316.svg?style=for-the-badge)](https://plugins.jetbrains.com/plugin/16316)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg?style=for-the-badge)](https://paypal.me/marhalide)
Expand Down
53 changes: 31 additions & 22 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML

fun properties(key: String) = project.findProperty(key).toString()
Expand All @@ -6,13 +7,15 @@ plugins {
// Java support
id("java")
// Kotlin support
id("org.jetbrains.kotlin.jvm") version "1.7.10"
id("org.jetbrains.kotlin.jvm") version "1.7.21"
// Gradle IntelliJ Plugin
id("org.jetbrains.intellij") version "1.8.0"
id("org.jetbrains.intellij") version "1.13.0"
// Gradle Changelog Plugin
id("org.jetbrains.changelog") version "1.3.1"
id("org.jetbrains.changelog") version "2.0.0"
// Gradle Qodana Plugin
id("org.jetbrains.qodana") version "0.1.13"
// Gradle Kover Plugin
id("org.jetbrains.kotlinx.kover") version "0.6.1"
}

group = properties("pluginGroup")
Expand All @@ -27,11 +30,9 @@ dependencies {
implementation("de.marhali:json5-java:2.0.0")
}

// Set the JVM language level used to compile sources and generate files - Java 11 is required since 2020.3
// Set the JVM language level used to build project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+.
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
jvmToolchain(17)
}

// Configure Gradle IntelliJ Plugin - read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
Expand All @@ -46,18 +47,23 @@ intellij {

// Configure Gradle Changelog Plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
changelog {
version.set(properties("pluginVersion"))
groups.set(emptyList())
repositoryUrl.set(properties("pluginRepositoryUrl"))
}

// Configure Gradle Qodana Plugin - read more: https://github.com/JetBrains/gradle-qodana-plugin
qodana {
cachePath.set(projectDir.resolve(".qodana").canonicalPath)
reportPath.set(projectDir.resolve("build/reports/inspections").canonicalPath)
cachePath.set(file(".qodana").canonicalPath)
reportPath.set(file("build/reports/inspections").canonicalPath)
saveReport.set(true)
showReport.set(System.getenv("QODANA_SHOW_REPORT")?.toBoolean() ?: false)
}

// Configure Gradle Kover Plugin - read more: https://github.com/Kotlin/kotlinx-kover#configuration
kover.xmlReport {
onCheck.set(true)
}

tasks {
wrapper {
gradleVersion = properties("gradleVersion")
Expand All @@ -70,22 +76,25 @@ tasks {

// Extract the <!-- Plugin description --> section from README.md and provide for the plugin's manifest
pluginDescription.set(
projectDir.resolve("README.md").readText().lines().run {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"

if (!containsAll(listOf(start, end))) {
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
}
subList(indexOf(start) + 1, indexOf(end))
}.joinToString("\n").run { markdownToHTML(this) }
file("README.md").readText().lines().run {
val start = "<!-- Plugin description -->"
val end = "<!-- Plugin description end -->"

if (!containsAll(listOf(start, end))) {
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
}
subList(indexOf(start) + 1, indexOf(end))
}.joinToString("\n").let { markdownToHTML(it) }
)

// Get the latest available change notes from the changelog file
changeNotes.set(provider {
changelog.run {
getOrNull(properties("pluginVersion")) ?: getLatest()
}.toHTML()
with(changelog) {
renderItem(
getOrNull(properties("pluginVersion")) ?: getLatest(),
Changelog.OutputType.HTML,
)
}
})
}

Expand Down
21 changes: 11 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
# IntelliJ Platform Artifacts Repositories
# -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html
# IntelliJ Platform Artifacts Repositories -> https://plugins.jetbrains.com/docs/intellij/intellij-artifacts.html

pluginGroup = de.marhali.easyi18n
pluginName = easy-i18n
# SemVer format -> https://semver.org
pluginVersion = 4.4.0
pluginVersion = 4.4.1

# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
pluginSinceBuild = 203
pluginUntilBuild = 223.*
pluginSinceBuild = 223
pluginUntilBuild = 231.*

# IntelliJ Platform Properties -> https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
platformType = IU
platformVersion = 2022.2
platformVersion = 2022.3

# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
platformPlugins = org.jetbrains.kotlin, JavaScriptLanguage, com.jetbrains.php:222.3345.118
platformPlugins = org.jetbrains.kotlin, JavaScript, com.jetbrains.php:223.7571.182

# Gradle Releases -> https://github.com/gradle/gradle/releases
gradleVersion = 7.5.1

# Opt-out flag for bundling Kotlin standard library.
# See https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library for details.
# Opt-out flag for bundling Kotlin standard library -> https://plugins.jetbrains.com/docs/intellij/kotlin.html#kotlin-standard-library
# suppress inspection "UnusedProperty"
kotlin.stdlib.default.dependency = false
kotlin.stdlib.default.dependency = false

# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html
org.gradle.unsafe.configuration-cache = true
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@

import de.marhali.easyi18n.io.parser.ArrayMapper;

import thito.nodeflow.config.ListSection;
import java.util.ArrayList;
import java.util.List;

/**
* Map for yaml array values.
* @author marhali
*/
public class YamlArrayMapper extends ArrayMapper {
public static String read(ListSection list) {
public static String read(List<Object> list) {
return read(list.iterator(), Object::toString);
}

public static ListSection write(String concat) {
ListSection list = new ListSection();
public static List<Object> write(String concat) {
List<Object> list = new ArrayList<>();
write(concat, list::add);
return list;
}
}
}
40 changes: 17 additions & 23 deletions src/main/java/de/marhali/easyi18n/io/parser/yaml/YamlMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,25 @@
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.math.NumberUtils;

import thito.nodeflow.config.ListSection;
import thito.nodeflow.config.MapSection;
import thito.nodeflow.config.Section;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Mapper for mapping yaml files into translation nodes and backwards.
* @author marhali
*/
public class YamlMapper {

public static void read(String locale, Section section, TranslationNode node) {
for(String key : section.getKeys()) {
Object value = section.getInScope(key).get();
@SuppressWarnings("unchecked")
public static void read(String locale, Map<String, Object> section, TranslationNode node) {
for(String key : section.keySet()) {
Object value = section.get(key);
TranslationNode childNode = node.getOrCreateChildren(key);

if(value instanceof MapSection) {
// Nested element - run recursively
read(locale, (MapSection) value, childNode);
if(value instanceof Map) {
// Nested element run recursively
read(locale, (Map<String, Object>) value, childNode);
} else {
TranslationValue translation = childNode.getValue();

String content = value instanceof ListSection
? YamlArrayMapper.read((ListSection) value)
String content = value instanceof List
? YamlArrayMapper.read((List<Object>) value)
: StringUtil.escapeControls(String.valueOf(value), true);

translation.put(locale, content);
Expand All @@ -40,29 +34,29 @@ public static void read(String locale, Section section, TranslationNode node) {
}
}

public static void write(String locale, Section section, TranslationNode node) {
public static void write(String locale, Map<String, Object> section, TranslationNode node) {
for(Map.Entry<String, TranslationNode> entry : node.getChildren().entrySet()) {
String key = entry.getKey();
TranslationNode childNode = entry.getValue();

if(!childNode.isLeaf()) {
// Nested node - run recursively
MapSection childSection = new MapSection();
Map<String, Object> childSection = new HashMap<>();
write(locale, childSection, childNode);
if(childSection.size() > 0) {
section.setInScope(key, childSection);
section.put(key, childSection);
}
} else {
TranslationValue translation = childNode.getValue();
String content = translation.get(locale);

if(content != null) {
if(YamlArrayMapper.isArray(content)) {
section.setInScope(key, YamlArrayMapper.write(content));
section.put(key, YamlArrayMapper.write(content));
} else if(NumberUtils.isNumber(content)) {
section.setInScope(key, NumberUtils.createNumber(content));
section.put(key, NumberUtils.createNumber(content));
} else {
section.setInScope(key, StringEscapeUtils.unescapeJava(content));
section.put(key, StringEscapeUtils.unescapeJava(content));
}
}
}
Expand Down
Loading

0 comments on commit ce0b3d3

Please sign in to comment.