-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CircleCI config. Add project maven settings file. Add changelog. Update README.
- Loading branch information
1 parent
80d0bf0
commit 15f8c78
Showing
8 changed files
with
388 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
# directory where steps will run | ||
working_directory: ~/typescript-mapper | ||
docker: | ||
- image: daniloarcidiacono/ci-java-node:0.4.0 | ||
|
||
steps: | ||
# check out source code to working directory | ||
- checkout | ||
|
||
# restore the saved cache after the first run or if `pom.xml` has changed | ||
- restore_cache: | ||
key: typescript-mapper-{{ checksum "pom.xml" }} | ||
|
||
# gets the project dependencies | ||
- run: mvn dependency:go-offline | ||
|
||
# saves the project dependencies | ||
- save_cache: | ||
paths: | ||
- ~/.m2 | ||
key: typescript-mapper-{{ checksum "pom.xml" }} | ||
|
||
# Build | ||
- run: mvn clean package verify -Pdocs | ||
|
||
# Deploy | ||
- deploy: | ||
name: "Create GitHub release" | ||
command: | | ||
hub release create -a target/typescript-mapper-$CIRCLE_TAG-javadoc.jar -F CHANGELOG_LATEST.md $CIRCLE_TAG | ||
# Upload test coverage | ||
- run: bash <(curl -s https://codecov.io/bash) | ||
|
||
# uploads the test metadata from the `target/surefire-reports` directory so that it can show up in the CircleCI dashboard. | ||
- store_test_results: | ||
path: target/surefire-reports | ||
|
||
# store the jar as an artifact | ||
- store_artifacts: | ||
path: target/typescript-mapper-{{ .Environment.CIRCLE_TAG }}.jar | ||
|
||
workflows: | ||
version: 2 | ||
build_and_deploy: | ||
jobs: | ||
- build: | ||
filters: | ||
tags: | ||
only: /.*/ | ||
branches: | ||
ignore: /.*/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 | ||
https://maven.apache.org/xsd/settings-1.0.0.xsd"> | ||
<servers> | ||
<server> | ||
<id>ossrh</id> | ||
<username>${ossrh.username}</username> | ||
<password>${ossrh.password}</password> | ||
</server> | ||
</servers> | ||
</settings> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# typescript-mapper 0.1.0 (2019-01-13) | ||
|
||
### Features | ||
|
||
* Recursive mapping of classes and enumerations; | ||
* Support for Java generics, including wildcard types; | ||
* Support for standard collection types (sets, maps, ...); | ||
* Java annotations `@TypescriptDTO`, `@TypescriptComments` and `@TypescriptField` for specific customizations; | ||
* Multi-file output with fully customizable logic (default: one file per package); | ||
* Import generation; | ||
* Empty DTOs/sources elimination; | ||
* Support for Jackson annotations `@JsonTypeInfo` and `@JsonSubTypes`; | ||
* Fluent API for configuration; | ||
* Maven plugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
typescript-mapper 0.1.0 | ||
|
||
### Features | ||
|
||
* Recursive mapping of classes and enumerations; | ||
* Support for Java generics, including wildcard types; | ||
* Support for standard collection types (sets, maps, ...); | ||
* Java annotations `@TypescriptDTO`, `@TypescriptComments` and `@TypescriptField` for specific customizations; | ||
* Multi-file output with fully customizable logic (default: one file per package); | ||
* Import generation; | ||
* Empty DTOs/sources elimination; | ||
* Support for Jackson annotations `@JsonTypeInfo` and `@JsonSubTypes`; | ||
* Fluent API for configuration; | ||
* Maven plugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @daniloarcidiacono |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,172 @@ | ||
# Typescript Template | ||
[![Maven Central](https://img.shields.io/maven-central/v/io.github.daniloarcidiacono/typescript-mapper.svg?label=Maven%20Central)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22io.github.daniloarcidiacono%22%20a%3A%22typescript-mapper%22) | ||
[![codecov](https://codecov.io/gh/daniloarcidiacono/typescript-mapper/branch/master/graph/badge.svg)](https://codecov.io/gh/daniloarcidiacono/typescript-mapper) | ||
[![CircleCI](https://circleci.com/gh/daniloarcidiacono/typescript-mapper/tree/master.svg?style=svg)](https://circleci.com/gh/daniloarcidiacono/typescript-mapper/tree/master) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) | ||
|
||
# What? | ||
Typescript mapper is a tool for generating TypeScript .d.ts files from Java source code. | ||
|
||
See the CHANGELOG for a more complete list of available features. | ||
|
||
# How? | ||
Include the plugin in your Maven project: | ||
|
||
src/pom.xml | ||
```xml | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.example</groupId> | ||
<artifactId>myapp</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
|
||
<properties> | ||
<typescript-mapper.version>LATEST</typescript-mapper.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<!-- For annotations --> | ||
<dependency> | ||
<groupId>io.github.daniloarcidiacono.typescriptmapper</groupId> | ||
<artifactId>typescript-mapper-core</artifactId> | ||
<version>${typescript-mapper.version}</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.github.daniloarcidiacono.typescriptmapper</groupId> | ||
<artifactId>typescript-mapper-maven-plugin</artifactId> | ||
<version>${typescript-mapper.version}</version> | ||
<configuration> | ||
<basePackage>com.example.myapp</basePackage> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>map</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> | ||
``` | ||
|
||
Consider the following classes: | ||
|
||
src/main/java/com/example/myapp/domain/Person.java | ||
```java | ||
package com.example.myapp.domain; | ||
|
||
import com.example.myapp.info.Tag; | ||
import io.github.daniloarcidiacono.typescriptmapper.core.annotation.TypescriptComments; | ||
import io.github.daniloarcidiacono.typescriptmapper.core.annotation.TypescriptDTO; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@TypescriptDTO | ||
public class Person { | ||
@TypescriptComments("The name of the domain.") | ||
private String name; | ||
private int age; | ||
private boolean hasChildren; | ||
private List<Tag> tags; | ||
|
||
@TypescriptComments({ | ||
"The emails of the domain.", | ||
"Key is provider, value is email." | ||
}) | ||
private Map<String, String> emails; | ||
|
||
// ... rest of the code ... | ||
} | ||
``` | ||
|
||
src/main/java/com/example/myapp/info/Tag.java | ||
```java | ||
package com.example.myapp.info; | ||
|
||
import io.github.daniloarcidiacono.typescriptmapper.core.annotation.TypescriptComments; | ||
import io.github.daniloarcidiacono.typescriptmapper.core.annotation.TypescriptDTO; | ||
import io.github.daniloarcidiacono.typescriptmapper.core.annotation.TypescriptField; | ||
|
||
@TypescriptDTO | ||
@TypescriptComments("Colored tag.") | ||
public class Tag { | ||
private String name; | ||
|
||
@TypescriptComments("Optional tag color") | ||
@TypescriptField(required = false) | ||
private Color color; | ||
|
||
// ... rest of the code ... | ||
} | ||
|
||
@TypescriptDTO | ||
@TypescriptComments("Tag colors") | ||
enum Color { | ||
RED, | ||
GREEN | ||
} | ||
``` | ||
|
||
Running `mvn compile` produces the following output: | ||
|
||
|
||
target/mapped/com/example/myapp/domain.ts | ||
```typescript | ||
/** | ||
* This file is automatically generated by TypescriptMapper. | ||
* Do not modify this file -- YOUR CHANGES WILL BE ERASED! | ||
*/ | ||
import { Tag } from './info'; | ||
export interface Person { | ||
// The name of the domain. | ||
name: string; | ||
age: number; | ||
hasChildren: boolean; | ||
tags: Tag[]; | ||
|
||
/** | ||
* The emails of the domain. | ||
* Key is provider, value is email. | ||
*/ | ||
emails: { [ index: string ]: string }; | ||
} | ||
``` | ||
|
||
target/mapped/com/example/myapp/info.ts | ||
```typescript | ||
/** | ||
* This file is automatically generated by TypescriptMapper. | ||
* Do not modify this file -- YOUR CHANGES WILL BE ERASED! | ||
*/ | ||
// Colored tag. | ||
export interface Tag { | ||
name: string; | ||
|
||
// Optional tag color | ||
color?: Color; | ||
} | ||
|
||
// Tag colors | ||
export enum Color { | ||
RED = 'RED', | ||
GREEN = 'GREEN' | ||
} | ||
``` | ||
|
||
The folder structure can be customized with any logic (the imports will be adjusted accordingly). | ||
|
||
# Why? | ||
Type-safe DTOs exchanged by back-end and front-end components. | ||
|
||
# Where? | ||
The latest version is available on [Maven Central](https://search.maven.org/artifact/io.github.daniloarcidiacono/typescript-mapper). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Check that we are in the root folder | ||
if ! [[ -f "./scripts/prepare-release.sh" ]]; then | ||
(>&2 echo "Script must be run from the root folder, actual $(pwd)") | ||
exit 1 | ||
fi | ||
|
||
# Get the current branch | ||
branch_name=$(git symbolic-ref -q HEAD) | ||
branch_name=${branch_name##refs/heads/} | ||
branch_name=${branch_name:-HEAD} | ||
|
||
# Check that we are in master | ||
if [[ ${branch_name} != 'master' ]]; then | ||
(>&2 echo "Releases can be prepared only on master branch, current one is ${branch_name}!") | ||
exit 1 | ||
fi | ||
|
||
# Check the arguments | ||
if [[ "$#" -ne 1 ]]; then | ||
(>&2 echo "Invalid number of arguments, found $#, expected 1") | ||
echo "prepare-release <new-version>" | ||
exit 1 | ||
fi | ||
|
||
# Fetch (for picking tags) | ||
git fetch | ||
existing_tag=$(git tag --list | grep $1 | wc -l) | ||
if [[ ${existing_tag} -gt 0 ]]; then | ||
(>&2 echo "Tag $1 already exists, stop.") | ||
exit 1 | ||
fi | ||
|
||
# Merge | ||
echo "Merging from dev" | ||
git merge origin/dev --no-ff --no-commit | ||
|
||
# Check if there are any conflicts | ||
conflicts=$(git ls-files -u | wc -l) | ||
if [[ ${conflicts} -gt 0 ]]; then | ||
(>&2 echo "There are merge conflicts, stop (use git merge --abort to undo changes).") | ||
exit 1 | ||
fi | ||
|
||
# Update the version | ||
echo "Setting project version to $1" | ||
mvn versions:set -DgenerateBackupPoms=false -DnewVersion=$1 | ||
|
||
# Compile with tests | ||
mvn clean verify | ||
|
||
if [[ $? -ne 0 ]]; then | ||
(>&2 echo "Project build failed, stop (use git merge --abort to undo changes).") | ||
exit 1 | ||
fi | ||
|
||
# Success: commit and tag | ||
echo "Build success, creating tagged commit" | ||
git commit -am "chore: version $1" | ||
git tag -a $1 -m "$1" | ||
|
||
# Ready to push! | ||
# git push origin master --tags |
Oops, something went wrong.