|
1 |
| -import com.github.gradle.node.npm.task.NpmTask |
2 |
| - |
3 | 1 | plugins {
|
4 | 2 | base
|
5 | 3 | alias(libs.plugins.node)
|
6 | 4 | id("org.jlleitschuh.gradle.ktlint") apply false
|
| 5 | + alias(libs.plugins.npm.publish) |
7 | 6 | }
|
8 | 7 |
|
9 |
| -tasks.named("npm_run_build") { |
| 8 | +val npmRunBuild = tasks.named("npm_run_build") { |
10 | 9 | inputs.dir("src")
|
11 | 10 | inputs.file("package.json")
|
12 | 11 | inputs.file("package-lock.json")
|
@@ -38,24 +37,49 @@ val patchKotlinExternals = tasks.create("patchKotlinExternals") {
|
38 | 37 | }
|
39 | 38 | }
|
40 | 39 |
|
41 |
| -tasks.named("assemble") { |
| 40 | +tasks.assemble { |
42 | 41 | dependsOn("npm_run_build")
|
43 | 42 | dependsOn("npm_run_generateKotlin")
|
44 | 43 | dependsOn(patchKotlinExternals)
|
45 | 44 | }
|
46 | 45 |
|
47 |
| -tasks.named("npm_run_generateKotlin") { |
48 |
| - finalizedBy(patchKotlinExternals) |
| 46 | +tasks.check { |
| 47 | + dependsOn("npm_run_lint") |
49 | 48 | }
|
50 | 49 |
|
51 |
| -val updateVersion = tasks.register<NpmTask>("updateVersion") { |
52 |
| - args.set(listOf("version", "$version")) |
| 50 | +tasks.named("npm_run_generateKotlin") { |
| 51 | + finalizedBy(patchKotlinExternals) |
53 | 52 | }
|
54 | 53 |
|
55 |
| -tasks.named("npm_publish") { |
56 |
| - dependsOn(updateVersion) |
| 54 | +// To copy the files is a workaround for https://github.com/mpetuska/npm-publish/issues/87 |
| 55 | +// With `NpmPackage.files` we cannot copy the "dist" directory into `destinationDir`. |
| 56 | +// We can only either copy the files from "dist" directly into `destinationDir` |
| 57 | +// or copy all files from `projectDir` into `destinationDir`. |
| 58 | +val copyBuildTypeScriptForPackaging = tasks.create<Copy>("copyBuildTypeScriptForPackaging") { |
| 59 | + dependsOn(npmRunBuild) |
| 60 | + from(projectDir) |
| 61 | + include("dist") |
| 62 | + into(layout.buildDirectory.dir("typeScriptForPackaging")) |
57 | 63 | }
|
58 | 64 |
|
59 |
| -tasks.named("publish") { |
60 |
| - dependsOn("npm_publish") |
| 65 | +npmPublish { |
| 66 | + registries { |
| 67 | + register("itemis-npm-open") { |
| 68 | + uri.set("https://artifacts.itemis.cloud/repository/npm-open") |
| 69 | + System.getenv("NODE_AUTH_TOKEN").takeIf { !it.isNullOrBlank() }?.let { |
| 70 | + authToken.set(it) |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | + packages { |
| 75 | + create("js") { |
| 76 | + packageJsonTemplateFile.set(projectDir.resolve("package.json")) |
| 77 | + packageJson { |
| 78 | + version.set("${project.version}") |
| 79 | + } |
| 80 | + files { |
| 81 | + setFrom(copyBuildTypeScriptForPackaging.outputs) |
| 82 | + } |
| 83 | + } |
| 84 | + } |
61 | 85 | }
|
0 commit comments