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

bsc-plugin-update-main-args

v0.2.0

Published

A BrighterScript plugin that injects properties into the argument of the main function - useful for adding deeplinks for debugging

Downloads

309

Readme

Update Main Args (Brighterscript Plugin)

build status

A Brighterscript plugin that injects properties into the argument of the main function - useful for adding deep links for debugging, for example.

NOTE: Only Supports Brighterscript Version 1

It works by injecting a single line of code as the first line the main() (or runUserInterface()) function , like this:

sub main(args)
    args.append(parseJson("{""extra"":""args here""}"))
    ...
end sub

Usage

In a Brighterscript project, install the plugin:

npm install -D bsc-plugin-update-main-args

Add it to the plugins list in bsconfig.json, and set up the arguments to load:

{
    "plugins": ["bsc-plugin-update-main-args"],
    "updateMainArgs": {
        "args": {
            "mediaType": "movie",
            "contentId": "test-1234"
        }
    }
}

Read Args from .env

This plugin can also read arguments from an .env file (or from your system's environment variables).

Create a .env file with the variable MAIN_ARGS. It should be in JSON format:

MAIN_ARGS={"mediaType":"movie","contentId":"test-1234"}

Change the bsconfig options to load the environment variable:

{
    "plugins": ["bsc-plugin-update-main-args"],
    "updateMainArgs": {
        "useEnv": true,
        "envFilePath": ".env"
    }
}

Full Configuration Options

{
    "updateMainArgs": {
        "useEnv": true, // read environment variable
        "envFilePath": ".env", // path to specific .env file to read
        "envVar": "MAIN_ARGS", // The environment variable to read
        "args": {} // Just add args directly
    }
}

Example App

There is an test app showing how the plugin works in ./testapp (with the caveat that it is loading the plugin directly from source instead of through npm).

You can run the test app through VSCode:

  1. npm install to install all dependencies
  2. Open VSCode, run debug configuration Debug Test App

It will display all the arguments that werethe following screen:

Test App Screenshot

Test App configuration (./testapp/bsconfig.json):

{
    "updateMainArgs": {
        "useEnv": true,
        "envFilePath": "./testenv",
        "args": {
            "extra": "args here",
            "extra_params": {
                "can": "include",
                "objects": "too"
            }
        }
    }
}

Environment variables file (./testapp/testenv):

MAIN_ARGS={"mediaType":"movie","contentId":"abc1234"}