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

alinex-scripter

v1.2.0

Published

Scripting made easy in the alinex environment.

Downloads

4

Readme

Package: alinex-scripter

Build Status Coverage Status Dependency Status

The scripter makes the best nodejs easy usable from scripts with the full configuration support but without the nasty initialization.

So you mainly concentrate on your functional work and get

  • remote execution support
  • easy database access
  • easy web service requests
  • reporting
  • mail response

It can be started from command line or triggered using cron.

It is one of the modules of the Alinex Universe following the code standards defined in the General Docs.

Install

NPM Downloads

Install the package globally using npm on a central server.

sudo npm install -g alinex-scripter --production

After global installation you may directly call scripter from anywhere.

scripter --help

Always have a look at the latest changes.

Bash Code completion

If you like, you can add code completion for bash by copying the output of:

> scripter bashrc-script

###-begin-cli.coffee-completions-###
#
# yargs command completion script
#
# Installation: scripter completion >> ~/.bashrc
#    or scripter completion >> ~/.bash_profile on OSX.
#
_yargs_completions()
{
    local cur_word args type_list

    cur_word="${COMP_WORDS[COMP_CWORD]}"
    args=$(printf "%s " "${COMP_WORDS[@]}")

    # ask yargs to generate completions.
    type_list=`scripter --get-yargs-completions $args`

    COMPREPLY=( $(compgen -W "${type_list}" -- ${cur_word}) )

    # if no match was found, fall back to filename completion
    if [ ${#COMPREPLY[@]} -eq 0 ]; then
      COMPREPLY=( $(compgen -f -- "${cur_word}" ) )
    fi

    return 0
}
complete -F _yargs_completions scripter
###-end-cli.coffee-completions-###

Put these lines into your ~/.bashrc file.

Usage

You can simple call the scripter command with one of the configured jobs:

> scripter <job> [<options>]...

Initializing...
Run the job...
...
Goodbye

To list all the possible jobs:

> scripter --help

This will show the possible jobs which are defined as scripts.

Email

By default the report from the script will only be displayed on screen. But you may also send it as an email. To do so use the --mail switch:

  • --mail - will send it like defined in the script
  • --mail default - will send it using the default email template
  • --mail alexander.schillingæmycompany.de - will send it only to this address

Scripts

To add functionality you have to write your own scripts like:

# Test Script
# ========================================================================

exports.title = 'only for testing'
exports.description = 'what exactly will be done...'

exports.options =
  xtest:
    alias: 'x'
    type: 'string'

exports.handler = (args, cb) ->
  # shortcuts to predefined objects
  debug = exports.debug
  # do the job
  debug "running now..."
  console.log args
  # done ending function
  cb()

exports.mail =
  base: default

The script needs at least a title text and a handler function which will be called with the arguments and a callback. Optionally you may define some CLI options specific to these job.

This script has to be stored in

  • subfolder var/script
  • /etc/scripter/script
  • ~/.scripter/script

as JavaScript or CoffeeScript.

To include them you have to call the scripter once with it's --update option:

> scripter --update

Preset instances

The following objects will be preset in the exports object for you to use:

  • debug - instance to output debugging messages
  • report - specific report object to add to
  • sendmail(job, args, cb) - send an email without ending the script (another one will be send if the script finishes, prevent last mail with process.exit)

You may use them like:

exports.handler = (args, cb) ->
  # shortcuts to predefined objects
  debug = exports.debug
  report = exports.report
  # code of the handler using them...

Available packages

Additionally you may use any module which the scripter already installed by only requiring it like:

  • alinex-async - async helper
  • alinex-config - configuration settings
  • alinex-validator - validation of entries
  • alinex-fs - local filesystem manipulation
  • alinex-database - database access
  • alinex-exec - execution of command line tools, also remote
  • alinex-mail - mail sending
  • alinex-report - report generation (used to fill the report instance)
  • alinex-util - different type utilities
  • chalk - color code
  • math - Math.js calculations

More may be added later.

Configuration

Exec

You may need the setup under /exec like described in Exec. This is used to setup execution with load handling and maybe remote connections.

Database

Also you need the setup under /database like described in Database. This is used to make the specific database connections.

Email

You may need the setup under /email like described in Mail. This is used to send emails without detailed call in the script.

License

Copyright 2016 Alexander Schilling

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.