Skip to content

Commit 737c092

Browse files
committed
feat: npm publication with only the specification
So that consumers can run their own generator.
1 parent a246d0e commit 737c092

File tree

5 files changed

+85
-7
lines changed

5 files changed

+85
-7
lines changed

redocly/build.gradle.kts

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,61 @@
1+
import com.github.gradle.node.npm.task.NpmTask
2+
import org.gradle.kotlin.dsl.register
3+
14
plugins {
25
base
36
alias(libs.plugins.node)
47
}
58

6-
tasks.named("npm_run_join") {
9+
tasks.assemble {
710
dependsOn("npm_run_bundle")
811
}
12+
13+
val bundledDir = layout.projectDirectory.dir("bundled")
14+
val publicationFile = bundledDir.file("modelix-openapi-specifications-${project.version}.tgz")
15+
16+
val updateVersionTask = tasks.register<NpmTask>("updatePackageVersion") {
17+
workingDir.set(bundledDir.asFile)
18+
npmCommand = listOf("version")
19+
args.set(listOf(
20+
project.version.toString(),
21+
"--allow-same-version"
22+
))
23+
}
24+
25+
val npmPackTask =
26+
tasks.register<NpmTask>("npmPack") {
27+
group = "build"
28+
dependsOn("npm_run_bundle")
29+
dependsOn(updateVersionTask)
30+
31+
workingDir.set(bundledDir.asFile)
32+
npmCommand = listOf("pack")
33+
}
34+
35+
val npmPublishTask =
36+
tasks.register<NpmTask>("npmPublish") {
37+
group = "publishing"
38+
dependsOn(npmPackTask)
39+
40+
inputs.file(publicationFile)
41+
42+
workingDir.set(bundledDir.asFile)
43+
npmCommand.set(listOf("publish"))
44+
args.set(
45+
listOf(
46+
publicationFile.asFile.absolutePath,
47+
"--registry=https://artifacts.itemis.cloud/repository/npm-open/",
48+
"--//artifacts.itemis.cloud/repository/npm-open/:_authToken=${project.findProperty(
49+
"artifacts.itemis.cloud.npm.token",
50+
)}",
51+
),
52+
)
53+
}
54+
55+
tasks.assemble {
56+
dependsOn(npmPackTask)
57+
}
58+
59+
tasks.publish {
60+
dependsOn(npmPublishTask)
61+
}

redocly/bundled/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.tgz
2+
*.yaml

redocly/bundled/package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "@modelix/openapi-specifications",
3+
"version": "0.0.1-SNAPSHOT.4",
4+
"description": "OpenApi yaml files of the Modelix services",
5+
"homepage": "https://modelix.org/",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/modelix/modelix.openapi.git"
9+
},
10+
"license": "Apache 2.0",
11+
"files": [
12+
"./*.yaml"
13+
],
14+
"scripts": {
15+
"bundle": "redocly bundle",
16+
"package": "npm pack",
17+
"update-version": "npm version 0.0.1-SNAPSHOT.4"
18+
},
19+
"publishConfig": {
20+
"registry": "https://artifacts.itemis.cloud/repository/npm-open/"
21+
},
22+
"devDependencies": {
23+
"@redocly/cli": "^1.34.2"
24+
}
25+
}

redocly/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
"@redocly/cli": "^1.34.2"
88
},
99
"scripts": {
10-
"bundle": "redocly bundle",
11-
"join": "redocly join build/bundled/**/*.yaml --output=build/joined.yaml",
12-
"bundle-and-join": "$npm_execpath run bundle && $npm_execpath run join"
10+
"bundle": "redocly bundle"
1311
}
1412
}

redocly/redocly.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ plugins:
44
apis:
55
repository@v3:
66
root: ../specifications/repository/v3/repository.yaml
7-
output: ./build/bundled/repository-v3.yaml
7+
output: ./bundled/repository-v3.yaml
88
decorators:
99
plugin/use-server-path: {}
1010
maven-connector@v1:
1111
root: ../specifications/maven-connector/v1/maven.yaml
12-
output: ./build/bundled/maven-connector-v1.yaml
12+
output: ./bundled/maven-connector-v1.yaml
1313
decorators:
1414
plugin/use-server-path: {}
1515
workspaces@v1:
1616
root: ../specifications/workspaces/v1/workspaces.yaml
17-
output: ./build/bundled/workspaces-v1.yaml
17+
output: ./bundled/workspaces-v1.yaml
1818
decorators:
1919
plugin/use-server-path: {}

0 commit comments

Comments
 (0)