Skip to content

Commit

Permalink
implement package
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Jan 7, 2023
1 parent 1d4ab69 commit 0ca1998
Show file tree
Hide file tree
Showing 15 changed files with 5,760 additions and 164 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]

indent_style = space
indent_size = 2

end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
75 changes: 75 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/** @type {import('eslint').Linter.Config} */
const config = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'unicorn', 'import'],
extends: ['eslint:recommended'],
env: {
node: true,
es6: true,
},
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
},
rules: {
quotes: ['error', 'single', { avoidEscape: true }],
camelcase: ['error', { properties: 'never' }],
semi: ['error', 'never'],
indent: [2, 4],
eqeqeq: ['error', 'always'],

'prefer-const': 'error',
'no-multiple-empty-lines': [2, { max: 1, maxEOF: 1 }],
'array-bracket-spacing': ['error', 'never'],
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
'comma-spacing': ['error', { before: false, after: true }],
'no-lonely-if': 'error',
'dot-notation': 'error',
'no-else-return': 'error',
'no-tabs': 'error',
'no-trailing-spaces': [
'error',
{
skipBlankLines: false,
ignoreComments: false,
},
],
'no-var': 'error',
'unicode-bom': ['error', 'never'],
curly: ['error', 'all'],
'object-curly-spacing': ['error', 'always'],
'keyword-spacing': ['error'],
'require-atomic-updates': 0,
'linebreak-style': ['error', 'unix'],
'unicorn/prefer-node-protocol': ['error'],
'import/extensions': ['error', 'ignorePackages'],
'no-restricted-syntax': [
'error',
'IfStatement > ExpressionStatement > AssignmentExpression',
],
'unicorn/prefer-ternary': 'error',
},
overrides: [
{
files: ['*.ts'],
rules: {
// see https://stackoverflow.com/questions/55280555/typescript-eslint-eslint-plugin-error-route-is-defined-but-never-used-no-un
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'no-undef': 'off',
// allow overloads
'no-redeclare': 'off',
},
},
{
files: ['*.test.ts'],
rules: {
'dot-notation': 'off',
},
},
],
}

module.exports = config
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run test:lint
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.10.0
59 changes: 57 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,60 @@
# Safaridriver for Node.js

An NPM wrapper for handling the Safaridriver binary.
> A Node.js untility to manage Safaridriver sessions.
__Note:__ 🚧 this package is currently in development, come back later!
The Safaridriver utility is used to launch an HTTP server that implements the [WebDriver](https://w3c.github.io/webdriver/) REST API. When launched, Safaridriver allows for automated testing of web content using the version of Safari that is installed with macOS.

## Install

To install the package, run:

```sh
npm install --save-dev safaridriver
```

## Usage

To start a Safaridriver server, import the package and run:

```js
import safaridriver from 'safaridriver'

safaridriver.start()

// run some automation...

// then kill instance via:
safaridriver.stop()
```

## Options

### `port`

Specifies the port on which the HTTP server should listen for incoming connections. If the port is already in use or otherwise unavailable, Safaridriver will exit immediately with a non-zero return code.

__Type:__ `number`<br />
__Default:__ `4444`

### `path`

Path to Safaridriver binary.

__Type:__ `string`<br />
__Default:__ `/usr/bin/safaridriver`

### `enable`

Applies configuration changes so that subsequent WebDriver sessions will run without further authentication. This includes checking "Enable Remote Automation" in Safari's `Develop` menu. The user must authenticate via password for the changes to be applied.

When this option is specified, safaridriver exits immediately without starting up the REST API service. If the changes were successful or already applied, safaridriver exits 0; otherwise, safaridriver exits >0 and prints an error message to stderr.

__Type:__ `boolean`<br />
__Default:__ `false`

### `diagnose`

Enables diagnostic logging for all sessions hosted by this safaridriver instance.

__Type:__ `boolean`<br />
__Default:__ `false`

0 comments on commit 0ca1998

Please sign in to comment.