npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

appium-support

v2.55.0

Published

Support libs used across appium packages

Downloads

240,378

Readme

appium-support

Utility functions used to support libs used across appium packages.

npm install appium-support

Appium, as of version 1.5 is all based on promises, so this module provides promise wrappers for some common operations.

Most notably, we wrap fs for file system commands. Note the addition of hasAccess. Also note that fs.mkdir doesn't throw an error if the directory already exists, it will just resolve.

Methods

  • system.isWindows

  • system.isMac

  • system.isLinux

  • system.isOSWin64

  • system.arch

  • system.macOsxVersion

  • util.hasContent - returns true if input string has content

  • util.hasValue - returns true if input value is not undefined and no null

  • util.escapeSpace

  • util.escapeSpecialChars

  • util.localIp

  • util.cancellableDelay

  • util.multiResolve - multiple path.resolve

  • util.unwrapElement - parse an element ID from an element object: e.g.: {ELEMENT: 123, "element-6066-11e4-a52e-4f735466cecf": 123} returns 123

  • util.wrapElement - convert an element ID to an element object of the form: e.g.: 123 returns {ELEMENT: 123, "element-6066-11e4-a52e-4f735466cecf": 123}

  • fs.hasAccess - use this over fs.access

  • fs.exists - calls fs.hasAccess

  • fs.rimraf

  • fs.mkdir - doesn't throw an error if directory already exists

  • fs.copyFile

  • fs.open

  • fs.close

  • fs.access

  • fs.readFile

  • fs.writeFile

  • fs.write

  • fs.readlink

  • fs.chmod

  • fs.unlink

  • fs.readdir

  • fs.stat

  • fs.rename

  • fs.md5

  • plist.parsePlistFile

  • plist.updatePlistFile

  • mkdirp

  • logger

  • zip.extractAllTo - Extracts contents of a zipfile to a directory

  • zip.readEntries - Reads entries (files and directories) of a zipfile

  • zip.toInMemoryZip - Converts a directory into a base64 zipfile

logger

Basic logger defaulting to npmlog with special consideration for running tests (doesn't output logs when run with _TESTING=1 in the env).

Logging levels

There are a number of levels, exposed as methods on the log object, at which logging can be made. The built-in ones correspond to those of npmlog, and are: silly, verbose, info, http, warn, and error. In addition there is a debug level.

The default threshold level is verbose.

The logged output, by default, will be level prefix message. So

import { logger } from 'appium-support';
let log = logger.getLogger('mymodule');
log.warn('a warning');`

Will produce

warn mymodule a warning

Environment variables

There are two environment variable flags that affect the way appium-base-driver logger works.

_TESTING

  • _TESTING=1 stops output of logs when set to 1.

_FORCE_LOGS

  • This flag, when set to 1, reverses the _TESTING

Usage

log.level

  • get and set the threshold level at which to display the logs. Any logs at or above this level will be displayed. The special level silent will prevent anything from being displayed ever. See npmlog#level.

log[level](message)

  • logs to level
    import { logger } from 'appium-support';
    let log = logger.getLogger('mymodule');
    
    log.info('hi!');
    // => info mymodule hi!

log.unwrap()

  • retrieves the underlying npmlog object, in order to manage how logging is done at a low level (e.g., changing output streams, retrieving an array of messages, adding log levels, etc.).

    import { getLogger } from 'appium-base-driver';
    let log = getLogger('mymodule');
    
    log.info('hi!');
    
    let npmlogger = log.unwrap();
    
    // any `npmlog` methods
    let logs = npmlogger.record;
    // logs === [ { id: 0, level: 'info', prefix: 'mymodule', message: 'hi!', messageRaw: [ 'hi!' ] }]

log.errorAndThrow(error)

  • logs the error passed in, at error level, and then throws the error. If the error passed in is not an instance of Error (either directly, or a subclass of Error) it will be wrapped in a generic Error object.

    import { getLogger } from 'appium-base-driver';
    let log = getLogger('mymodule');
    
    // previously there would be two lines
    log.error('This is an error');
    throw new Error('This is an error');
    
    // now is compacted
    log.errorAndThrow('This is an error');