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

@neurospeech/jex

v1.0.104

Published

Easy shell scripting with JavaScript and E4X (Similar to JSX)

Downloads

15

Readme

@neurospeech/jex

Easy shell scripting with JavaScript and E4X (Similar to JSX)

Problem Definition

  1. Bash, Powershell all scripting languages are limited in terms of language features.
  2. Editor support is also limited.
  3. Debugging is difficult.
  4. We wanted to JavaScript as shell script, along with JSX to organize large set of commands.
  5. So we created modified version of JSX which execute script little differently.

Jex Script

Jex script is a simple JSX file, with slightly different execution sequence.

Typical JSX nodes are converted to an organized set of nodes, and each properties are set at time of creation. Jex processes JSX nodes little differently, each child node is created at time of execution, so values of previous node can be considered as an input to next node.

This allows us to put some JavaScript code between multiple commands. In the given example, you will see that first command receives version and it is stored, in next command we are printing same version.

Each command executes asynchronously and you can easily break or continue execution based on previous step's result without having to write async/await.

Getting Started

# This is to execute using jex
npm install -g @neurospeech/jsx
# This is for imports
npm install @neurospeech/jsx

Example

node-version.jsx

import { Batch, Run, invoke, Log } from "@neurospeech/jex/index.js";
let version = "";
await invoke(<Batch>
    <Run
        cmd="node"
        args={["--version"]}
        logData={false}
        then={(x) => version = x.text.trim() }
        />
    { /** Execute Code in the curly braces, it will not print on console */
        version = `Installed node version is ${version}` }

    { console.log(version) }

    <Run
        cmd="node"
        args="--version"
        />
</Batch>)

Please note, when the command is finished, version variable will be set from the process's output.

Next executable code will be executed after first command has finished asychronously. As opposed to creation of JSX document.

jex node-version.jsx

Not Impressed?

Lets see little complicated example. Following file is referring mac commands to install certificate and upload the app file to Apple Connect.

import { Security } from "@neurospeech/jex/dist/ci/mac/Security.js";
import { XCRun } from "@neurospeech/jex/dist/ci/mac/XCRun.js";
// install certificate

const certPath = "cert.p12";
const certPass = process.env.CERT_PASS;
const keychainPass = process.env.CERT_PASS;
const keychainPath = "CERT_KEY_CHAIN";
const appPath = process.env.IOS_APP;
const apiKeyId = process.env.IOS_API_KEY_ID;
const issuerId = process.env.IOS_ISSUER_ID;

let singingIdentity;

await invoke(<Batch>
    <Security.CreateKeyChain
        path={keychainPath}
        password={keychainPass}
        />
    <Security.SetKeychainSettings
        path={keychainPath}
        lut="21600"
        />
    <Security.UnlockKeychain
        path={keychainPath}
        password={keychainPass}
        />
    <Security.Import
        certPath={certPath}
        certPass={certPass}
        keychainPath={keychainPath}
        then={(x) => ( signingIdentity = x.signingIdentity )}
        />

    <XCRun.UploadApp
        appPath={appPath}
        apiKeyId={apiKeyId}
        issuerId={issuerId}
        />

    <Run
        cmd="something-secret"
        args={[
            "publish",
            /** this can mask secret as shown below */
            mask `-p:KeyStorePassword=${"secret"}`,
            /** this will also work */
            mask("password")
        ]}
        />
</Batch>);

Features

  1. When commands are organized in library, while editing, code editor will provide intellisense along with compile time error for missing arguments.
  2. Arguments can be well defined and encoded easily within the code.
  3. You can easily utilize node's API.
  4. This is a viable alternative of yml files. As every jex library can easily incorporate required arguments needed along with jsdoc help.
  5. This can be used in CI/CD, that can be truly platform independent, so same build script can be used in any DevOp environment wherever node is installed.

Library Authoring

To create reusable functions for jex, you should not transform JSX to JS, instead use jex parse folder to transform your JSX to JS.

Samples

For more samples, please look at samples folder in this repository.