Skip to content

Commit

Permalink
Merge pull request #23 from MonsieurBon/SDCISA-12917-improve-npm-publ…
Browse files Browse the repository at this point in the history
…ish-of-apis

Sdcisa 12917 improve npm publish of apis
  • Loading branch information
MonsieurBon authored Aug 23, 2023
2 parents dabdd27 + d314be7 commit 291e7e7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
- master

env:
RELEASE_VERSION: "0.4.22"
DEVELOP_VERSION: "0.4.23-SNAPSHOT"
RELEASE_VERSION: "0.4.23"
DEVELOP_VERSION: "0.4.24-SNAPSHOT"
GIT_AUTHOR_NAME: "@swisspost-devs"
GIT_AUTHOR_EMAIL: "oss@post.ch"
GIT_COMMITTER_NAME: "swisspost-devs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ protected void generatePackageJson(String version) throws IOException {
if (shortname != null && shortname.length() > 0) {
customConfig.put("shortname", shortname);
}
customConfig.put("projectName", mavenProject.getArtifactId());
customConfig.put("projectName", getProjectName());
customConfig.put("title", getTitle(apiSpec));

final List<String> plugins = new ArrayList<>();
Expand Down Expand Up @@ -351,14 +351,36 @@ private String getDescription(Map<String, Object> apiSpec) {
return (String) info.get("description");
}

private String getProjectName() {
return String.join("-", this.shortname, this.type);
}

private String getName() {
String artifactId = mavenProject.getArtifactId();
StringBuilder nameBuilder = new StringBuilder();

if (this.domain != null && this.domain.length() > 0) {
List<String> domainParts = new ArrayList<>(Arrays.asList(this.domain.split("\\.")));
Collections.reverse(domainParts);
String nodeDomain = String.join("-", domainParts);
nameBuilder.append("@").append(nodeDomain);
}

if(scope.length() == 0) {
return artifactId;
if (this.namespace != null && this.namespace.length() > 0) {
String nodeNamespace = this.namespace
.replace(".", "-")
.replace("-" + this.shortname, "");

if (nameBuilder.length() == 0) {
nameBuilder.append("@");
} else {
nameBuilder.append("-");
}
nameBuilder.append(nodeNamespace).append("/");
}

return String.format("%s/%s", this.scope.startsWith("@") ? this.scope : "@" + this.scope, artifactId);
nameBuilder.append(getProjectName());

return nameBuilder.toString();
}

protected void checkNodeInstalled() throws MojoExecutionException {
Expand Down

0 comments on commit 291e7e7

Please sign in to comment.