Coder Social home page Coder Social logo

wiremock-standalone's Introduction

WireMock Standalone for NPM

Wiremock Standalone Wiremock Standalone npm

This package downloads WireMock standalone from Maven Central and provides simple CLI wrapper for NPM.

How to use

npm i -D wiremock-standalone
# OR
pnpm add -D wiremock-standalone
# OR
yarn add -D wiremock-standalone

Usage (as script in package.json):

{
  "scripts": {
    "start:mock": "wiremock --root-dir ./mock"
  }
}

Downloader configuration

By default, the latest stable jre8 version of WireMock JAR is downloaded from public Maven repository. You can override this behavior by:

  1. setting environment variables
  2. creating .wiremock configuration file in your project (JSON format)
  3. adding wiremock property in your package.json
ENV JSON Default
MAVEN_REPO_URL mavenRepoURL https://repo1.maven.org/maven2
WIREMOCK_VERSION version resolved to the latest
JRE_VERSION jreVersion jre8

Runtime options

Java arguments

You can pass options to Java runtime with --java-arg CLI argument. All system properties are collected and appended to wiremock's --permitted-system-keys option.

wiremock --java-arg -Dmy.custom.var=some-value --root-dir ./mock

HOWTOs

Passing ENV variables with env-cmd

yarn env-cmd -f [path/to/.env] yarn wiremock --global-response-templating --verbose --root-dir ./mocks --permitted-system-keys=WIREMOCK_.*

Donation

If this project help you reduce time to develop, you can give me a cup of coffee :)

Donate

wiremock-standalone's People

Contributors

buffalo704 avatar chetanddesai avatar duslerke avatar frederic-kneier avatar hagith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

wiremock-standalone's Issues

Proxy Config not working

Proxy Config not working

Hi @Hagith,

thank you for the updated version of the standalone.
I tried downloading the wiremock via an alternative repo and failed.

It seems that the basepath was changed from const mavenPath = 'com/github/tomakehurst/wiremock-standalone'; to const mavenPath = 'maven2/com/github/tomakehurst/wiremock-standalone'; in one of your latest commits.

So the installer tries to download from <MAVEN_REPO_URL>/maven2/com/github/tomakehurst/wiremock-standalone.
My proxy sadly provides the artifact under the following url: <MAVEN_REPO_URL>/maven-central/com/github/tomakehurst/wiremock-standalone and i have no way to change this.

Is it possible to move the /maven2-prefix from the "mavenPath" to the "mavenRepoUrl"?

Thank you and Best Regards
Stephan

Wiremock 3.0.0 404 error

On version 3.1.2

when running install.js, I receieve the error

Downloading WireMock standalone from Maven Central...
 https://repo1.maven.org/maven2/com/github/tomakehurst/wiremock-jre8-standalone/3.0.1/wiremock-jre8-standalone-3.0.1.jar
 Error: Request failed with status code 404

Wiremock 3.0.0 came out yesterday, and it appears that wiremock 3 doesn't have a jar file.
https://repo1.maven.org/maven2/com/github/tomakehurst/wiremock-jre8-standalone/3.0.1/

perhaps you can use the latest version of wiremock 2

Can't pass -D options to the java command line

Hi folks,

I can't seem to pass -D options to the underlying java process that runs the jar from your commandline? I need to pass a custom system variable, say -Dmy.custom.var=localhost:9090? Is this possibly with your module?

Thanks,
Mark.

Wiremock-standalone install fails upon yarn install when attempting to retrieve the latest wiremock version.

Problem:

Upon there being no MAVEN_... or WIREMOCK_VERSION environment variables specified, the install.js script fails with the:
Error: Cannot read property '1' of null.

Cause:

This is because the script attempts to determine the wiremock version from the maven-metadata.xml file by the following regex pattern that expects the version between the release tags to be 3 dot-separated numbers:

return meta.match(/<release>([.\d]+)<\/release>/m)[1];

Presently, the maven-metadata.xml file returned has the release version specified like so:

<release>3.0.0-beta-2</release>

This fails the match on the install.js Line 28 pattern, making the .match(...) return null, finally, causing the error message mentioned above.

Notes:

Current maven-metadata.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<metadata>
	<groupId>com.github.tomakehurst</groupId>
	<artifactId>wiremock-standalone</artifactId>
	<versioning>
		<latest>3.0.0-beta-2</latest>
		<release>3.0.0-beta-2</release>
		<versions>
			<version>2.0.1-beta</version>
			... etc (removing all in between to make this shorter)
			<version>2.27.1</version>
			<version>2.27.2</version>
			<version>3.0.0-beta-1</version>
			<version>3.0.0-beta-2</version>
		</versions>
		<lastUpdated>20221230190922</lastUpdated>
	</versioning>
</metadata>

Created this Issue ticket, in case a different solution to that of PR #20 is wanted.

Downloading WireMock jar from Maven Central failed

When using this library in a Windows environment and a terminal without curl support, the wiremock-standalone jar fails to download on npm install.

Workaround is to use some curl-enabled terminal on windows (like git bash), but it would be interesting to have it working on any chosen terminal.

error An unexpected error occurred: "C:\myrepo\node_modules\wiremock-standalone: Command failed.
Exit code: 1
Command: C:\Windows\system32\cmd.exe
Arguments: /d /s /c node install.js
Directory: C:\myrepo\node_modules\wiremock-standalone
Output:
Downloading WireMock standalone from Maven Central...
http://repo1.maven.org/maven2/com/github/tomakehurst/wiremock-standalone/2.15.0/wiremock-standalone-2.15.0.jar
C:\myrepo\node_modules\wiremock-standalone\install.js:15
throw new Error('Downloading WireMock jar from Maven Central failed');
^

Error: Downloading WireMock jar from Maven Central failed
at Object. (C:\myrepo\node_modules\wiremock-standalone\install.js:15:9)
at Module._compile (module.js:662:30)
at Object.Module._extensions..js (module.js:673:10)
at Module.load (module.js:575:32)
at tryModuleLoad (module.js:515:12)
at Function.Module._load (module.js:507:3)
at Function.Module.runMain (module.js:703:10)

Unable to install wiremock-jre8-standalone-2.29.1.jar

The install.js file is set in a deprecated "java 7" way.

const url = ${options.mavenRepoURL}/${mavenPath}/${version}/wiremock-standalone-${version}.jar;
This limits the last version to be 2.27.2.

Is it possible to be flexible enough to allow for the java 8 standalone pattern to be used as well.
https://repo1.maven.org/maven2/com/github/tomakehurst/wiremock-jre8-standalone/2.29.1/wiremock-jre8-standalone-2.29.1.jar

I am in need of the handlebar helpers that are found in the latter version.

Set proxy config

I can't install wiremock due proxy config. I need set a proxy config to download https://repo1.maven.org/maven2/com/github/tomakehurst/wiremock-standalone/xxx/wiremock-standalone-xxx.jar

/node_modules/wiremock-standalone/install.js:37 throw new Error('Downloading WireMock jar from Maven Central failed: ${error}'); ^ Error: Downloading WireMock jar from Maven Central failed: connect ETIMEDOUT 151.101.132.209:443

I tried setting .nmv/jvm.config
I tried setting HOME/.m2/settings.xml
I tried exporting:
export http_proxy=http://x export https_proxy=http://x

But nothing... I can download from navigator the .jar , even do a curl...

Reading install.js I think it's necessary an option to set proxy setting, because http.get ignore all this options and environment vars...

Terminal: zsh
System: macOS Catalina (10.15.6)
node.js: 12.16.3
npm -v: 6.14.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.