Skip to content

Commit

Permalink
Add strictSsl publishing option
Browse files Browse the repository at this point in the history
Closes #128
  • Loading branch information
mpetuska committed Jul 14, 2023
1 parent c450ab1 commit ca40408
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ This is a maintenance release with a few minor bugfixes.
### Added

- New [Local TS consumer setup](./samples/local-ts-consumer/README.md) sample
- New `strictSsl` option for `NpmPublishTask`

### Changed

Expand Down
25 changes: 16 additions & 9 deletions npm-publish-docs/src/pages/user-guide/tasks/NpmPublishTask.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ The task can be created and configured in a `build.gradle.kts` file by registeri

```kotlin title="build.gradle.kts"
tasks {
register("name", dev.petuska.npm.publish.task.NpmPublishTask::class) {
...
}
register("name", dev.petuska.npm.publish.task.NpmPublishTask::class) {
...
}
}
```

Expand All @@ -22,15 +22,17 @@ tasks {
| [`packageDir`](#packagedir) | Directory | | |
| [`dry`](#dry) | Boolean | false | |
| [`tag`](#tag) | String | | |
| [`strictSsl`](#strictSsl) | Boolean | | |

=== "Keys"

| Property | CLI | System/Gradle | Environment |
|:--------------------------------|---------|:--------------|-------------|
| [`registry`](#registry) | | | |
| [`packageDir`](#destinationdir) | | | |
| [`dry`](#dry) | `--dry` | | |
| [`tag`](#tag) | `--tag` | | |
| Property | CLI | System/Gradle | Environment |
|:--------------------------------|----------------|:--------------|-------------|
| [`registry`](#registry) | | | |
| [`packageDir`](#destinationdir) | | | |
| [`dry`](#dry) | `--dry` | | |
| [`tag`](#tag) | `--tag` | | |
| [`strictSsl`](#strictSsl) | `--strict-ssl` | | |

=== "Usage"

Expand All @@ -43,6 +45,7 @@ tasks {
packageDir.set(layout.projectDirectory.dir("src/main/js"))
dry.set(true)
tag.set("latest")
strictSsl.set(false)
}
}
```
Expand All @@ -63,3 +66,7 @@ Controls dry-tun mode for the execution.

Sets a tag to label published package version
[More info](https://docs.npmjs.com/adding-dist-tags-to-packages)

### `strictSsl`

Controls strict SSL validation for network requests
13 changes: 11 additions & 2 deletions npm-publish-gradle-plugin/src/main/kotlin/task/NpmPublishTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,22 @@ public abstract class NpmPublishTask : NpmExecTask() {

/**
* Optional tag to label the published package version
* @see [NpmPublishExtension.dry]
* [npm](https://docs.npmjs.com/adding-dist-tags-to-packages)
*/
@get:Input
@get:Optional
@get:Option(option = "tag", description = "Optional tag to label the published package version")
public abstract val tag: Property<String>

/**
* Optional tag to label the published package version
* [npm](https://docs.npmjs.com/adding-dist-tags-to-packages)
*/
@get:Input
@get:Optional
@get:Option(option = "strict-ssl", description = "Optional flag to enable or disable strict SSL")
public abstract val strictSsl: Property<Boolean>

/**
* Configuration DSL allowing to modify a registry config
* @param action to apply
Expand Down Expand Up @@ -87,7 +96,7 @@ public abstract class NpmPublishTask : NpmExecTask() {
if (reg.authToken.isPresent) add("--//$repo:_authToken=${reg.authToken.get()}")
if (d) add("--dry-run")
if (tag.isPresent) add("--tag=${tag.get()}")
// add("${uri.scheme.trim()}://$repo")
if (strictSsl.isPresent) add("--strict-ssl=${strictSsl.get()}")
}
npmExec(args) { it.workingDir(packageDir.get()) }.rethrowFailure()
if (!d) info { "Published package at $pDir to ${reg.name} registry" }
Expand Down

0 comments on commit ca40408

Please sign in to comment.