GithubHelp home page GithubHelp logo

isabella232 / jslib.k6.io Goto Github PK

View Code? Open in Web Editor NEW

This project forked from grafana/jslib.k6.io

0.0 0.0 0.0 3.74 MB

Repository of useful utility libs for k6 scripts

License: GNU Affero General Public License v3.0

JavaScript 44.79% Shell 0.10% HTML 54.52% CSS 0.60%

jslib.k6.io's Introduction

jslib.k6.io

jslib.k6.io, hosted utility libs for k6 scripts.

To make life a little easier during development make sure that the following are installed:

  • node >= 11.2.0
  • yarn >= 1.13.0

How to add a new JS package

  1. Create a new branch from master.
  2. Create a new lib dir /lib/{lib_name}
  3. Create a new version dir /lib/{lib_name}/{desired_version}/
  4. Add an entry file /lib/{lib_name}/{desired_version}/index.js
  5. Add the lib to supported.json (see example below):
{
  "{lib_name}": ["{desired_version}"]
}

// Example result
{
  "awesome-lib": ["2.0.3"]
}
  1. Add test case in /tests/basic.js and /tests/testSuite.js to make sure that the added lib is importable and runnable by k6.
  2. Update the homepage by running yarn run generate-homepage.
  3. Verify that new homepage /lib/index.html is legit (Quickly done by running yarn run verify-homepage).
  4. Create a PR, get approved etc..
  5. Merge master. (This will push the updates to S3).
  6. Browse to https://jslib.k6.io/{lib_name}/{desired_version}/index.js

Add a JS package that requires bundling

Running yarn run bundle $pkgName@pkgVersion will try to run webpack bundling on the file located at /lib/$pkgName/$pkgBundle/index.src.js.
If all goes well you'll get a bundle file index.js alongside the "src file". If there is already a file named index.js at the given path, you will be asked to override or exit.

When running this command there will be an option to run babel transpile on the bundle as well.

# Example

yarn run bundle [email protected]

How to add a new version of a and existing package.

  1. Create a new branch from master.
  2. Create a new "version dir" in /lib/{lib_name}/{desired_version}/
  3. Add entry file for version /lib/{lib_name}/{desired_version}/index.js
  4. Add the version to supported.json like:
{
  "my-lib": [
    "1.0.2",
    // Use semantic versioning
    "{desired_version}"
  ]
}

// Example result
{
  "my-lib": [
    "1.0.2",
    "2.0.3"
  ]
}
  1. Add test case in /tests/basic.js to make sure that the ported lib is importable and runnable by k6.
  2. Update the homepage by running yarn run generate-homepage.
  3. Verify that new homepage /lib/index.html is legit (Quickly done by running yarn run verify-homepage).
  4. Create a PR, get approved etc..
  5. Merge master. (This will push the updates to S3).
  6. Browse to https://jslib.k6.io/{lib_name}/{desired_version}/index.js

Updating styling and layout of the "Homepage"

The homepage of https://jslib.k6.io live in the /static dir.
The final index.html page gets generated by running yarn run generate-homepage.

Useful dev commands:

# Listen to file changes, restart devserver and serve index.html
yarn run develop-homepage

# Quickly serve index.html
yarn run verify-homepage

# Generate index.html
yarn run generate-homepage

Installing new package via npm and automagically adding it to libs

The outcome of this might vary depeding on the quality of the desired node_module you want to add.

The following command will try to:

  1. Install the desired {package_name}
  2. Copy the module to /lib
  3. Update the homepage /lib/index.html
yarn run add-pkg {package_name}

Once run successfully, make sure that you do the following:

  • Add test case in /tests/basic.js to make sure that the ported lib is importable and runnable by k6.
  • Verify that new homepage /lib/index.html is legit.

Updating a version of a JS package listed in package.json dependencies

Some of the JS packages in /lib/ can be libraries that exist on NPM today. To add a specific or the latest version of a package that exists on npm the following steps will help you with that.

  1. yarn upgrade {my_package}@version (for specific version) yarn upgrade {my_package} --latest (for the latest).
  2. yarn run copy-libs

If all went well the following should have happened:

  • New version dir and entry file created /lib/{my_package}/{new_version}/index.js.
  • New version entry added to support.json (see example below)
{
  "my_package": [
    "1.0.2", // Previous version
    "2.0.0" // New version added by copy-libs command.
  ]
}

If not then you will have to manually create the new version like described here.

Once a new version dir has been created and added to supported.json it is time to:

  1. Add test case in /tests/basic.js to make sure that the added version is importable and runnable by k6.
  2. Update the homepage by running yarn run generate-homepage.
  3. Verify that new homepage /lib/index.html is legit (Quickly done by running yarn run verify-homepage).
  4. Create a PR, get approved etc..
  5. Merge master. (This will push the updates to S3).
  6. Browse to https://jslib.k6.io/{lib_name}/{desired_version}/index.js

jslib.k6.io's People

Contributors

dependabot[bot] avatar floord avatar javaducky avatar legander avatar na-- avatar oleiade avatar simskij avatar sniku avatar szkiba avatar w1kman avatar

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.