You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@oaklean/cli

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oaklean/cli

A command-line interface that provides utilities for parsing, inspecting, and converting the .oak file format, as well as interfaces used in the @oaklean suite.

0.1.4
latest
Source
npmnpm
Version published
Weekly downloads
320
-30.13%
Maintainers
0
Weekly downloads
 
Created
Source

@oaklean/cli

A command-line interface that provides utilities for parsing, inspecting, and converting the .oak file format, as well as interfaces used in the @oaklean suite.

Usage

$ npx oak -h

Usage: oak [options] [command]

An CLI to interact with the @oaklean suite

Options:
  -V, --version   output the version number
  -h, --help      display help for command

Commands:
  init            Create a .oaklean config file
  format          commands to convert or inspect the profiler's format
     - toHash Calculates the hash of given a profiler format
     - toJSON Converts a profiler format that is given in binary format to a json version
     - toSourceFileTree Converts a profiler format that is given in binary format to a SourceFileMetaDataTree
     - check Checks wether all files in the profiler format are present
  
  profile         commands to convert or inspect the cpu profile's format
     - toCPUModel Converts a cpu profile format that is given to a cpu model format
  
  parse           commands to parse javascript or typescript files
     - toPST Converts a given javascript/typescript file and extracts the ProgramStructureTree from it and stores it into a file
  
  transpile       commands to parse javascript or typescript files
     - withJest Transpiles a given javascript/typescript file with jest and stores the transpiled code into a file
     - withTS Transpiles a given javascript/typescript file with typescript and stores the transpiled code into a file
  
  backend         commands to interact with the backend
     - send Sends a given .oak report to a backend specified in the .oaklean config
  
  help [command]  display help for command

Fast Config Setup

The @oaklean/cli can be used to easily setup a .oaklean config file.

  • Install the cli: npm add --save-dev @oaklean/cli
  • Run the init script: npx oak init
  • It will ask you which sensor interface should be used for energy measurements:
Select a sensor interface (recommended for your platform: perf)
  None (pure cpu time measurements)
  powermetrics (macOS only)
❯ perf (Linux only)
  windows (Windows only)
energy measurements on Linux (Intel & AMD CPUs only)
  • The cli asks you to confirm your choice and generates a valid .oaklean config file for you:
? Select a sensor interface (recommended for your platform: perf) perf (Linux only)
{
  "exportOptions": {
    "outDir": "profiles/",
    "outHistoryDir": "profiles_history/",
    "rootDir": "./",
    "exportV8Profile": false,
    "exportReport": true,
    "exportSensorInterfaceData": false
  },
  "projectOptions": {
    "identifier": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
  },
  "runtimeOptions": {
    "seeds": {},
    "v8": {
      "cpu": {
        "sampleInterval": 1
      }
    },
    "sensorInterface": {
      "type": "perf",
      "options": {
        "outputFilePath": "energy-measurements.txt",
        "sampleInterval": 100
      }
    }
  }
}
? Is this OK? (yes) (Y/n)
Available Sensor Interfaces
SensorInterfaceOperating System
powermetricsmacOS
perflinux
windowswindows

If you want to how to setup the Sensor Interfaces and how to make them work with Docker you can read more about it here

:warning: Most Sensor Interfaces need root privileges
Look into the Sensor Interface Docs to see how you can run them without root privileges

:mag: How measurements work
During the test execution measurements are collected with a sample based approach. So for every n - microseconds it collects a v8 cpu profile and energy measurements of the sensor interface. You can adjust the sampling rate with the sampleInterval options in the .oaklean config file above.

Development

To build the tool, execute npm run build.

To make the tool available on your system and enable the oak command, simply run npm run setup. This command not only builds the tool but also updates your system's version of @oaklean/cli to the newly built one.

Keywords

oaklean

FAQs

Package last updated on 22 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts