Skip to main content
4 of 6
switched to auto-generated usage info
0Valt
  • 1.4k
  • 4
  • 16

Generate StackApps - post generator for userscripts

About

Generate StackApps is a post Markdown generator for userscript projects reducing the amount of busywork required to publish userscripts for the benefit of the Stack Exchange network users. The package is highly customizable and takes a lot of the information from the project's package.json file (on an off-chance you are unfamiliar, here are the NPM docs).

Usage example

CLI usage:

generate-stackapps \
    --install "https://www.npmjs.com/package/@userscripters/generate-stackapps" \
    --language "TypeScript" \
    --org-name "UserScripters" \
    --org-url "https://github.com/userscripters" \
    --room "https://chat.stackoverflow.com/rooms/214345" \
    --tag "library" \
    --tag "typescript" \
    --thumbnail "https://i.sstatic.net/Cbt4Z.png"

Programmatic usage as a module:

import { generate } from "@userscripters/generate-stackapps";

const { body, tags, title } = await generate({
    installURL: "https://www.npmjs.com/package/@userscripters/generate-stackapps",
    languages: ["TypeScript"],
    orgName: "UserScripters",
    orgURL: "https://github.com/userscripters",
    roomURL: "https://chat.stackoverflow.com/rooms/214345",
    tags: ["library", "typescript"],
    testedIn: {
        chrome: "100.0.0"
    },
    thumbnailURL: "https://i.sstatic.net/Cbt4Z.png"
});

License

The script is licensed under the GPL-3.0-or-later license.

Download

Latest version: 1.0.3

The package is published as both an NPM package and a GitHub package. Can be installed via a package manager like NPM as usual:

npm install --save-dev @userscripters/generate-stackapps

If you opt to install it from the GitHub registry, please note that it only supports scoped packages, you will need a simple .npmrc file at your project root:

@userscripters:registry=https://npm.pkg.github.com

You will also need to be logged in to GitHub. An easy way to do so is to have a global .npmrc with your PAT (personal access token) set as an access token:

//npm.pkg.github.com/:_authToken=<your token here>

CLI Usage

The package exposes a CLI interface with the following syntax:

generate-stackapps [options]

There are various options one can provide to customize the output:

Options:
      --version               Show version number                      [boolean]
      --help                  Show help                                [boolean]
  -a, --about                 Long project description                  [string]
      --cr, --chrome          Last tested Chrome version                [string]
  -d, --direct                Send output to process.stdout (CLI-only)
                                                      [boolean] [default: false]
  -e, --excerpt               Short project description                 [string]
      --ed, --edge            Last tested Edge version                  [string]
      --ie, --explorer        Last tested Internet Explorer version     [string]
      --ff, --firefox         Last tested Firefox version               [string]
      --iu, --install         Project installation URL       [string] [required]
  -l, --language              Programming languages used (repeatable)    [array]
      --mu, --minified        Minified version installation URL         [string]
  -o, --output                Output file path (CLI-only)
                                            [string] [default: "./STACKAPPS.md"]
      --on, --org-name        GitHub organization name                  [string]
      --op, --opera           Last tested Opera version                 [string]
      --ou, --org-url         GitHub organization URL                   [string]
  -p, --package               Path to project's package.json
                                            [string] [default: "./package.json"]
  -r, --room                  Chat room URL                             [string]
      --sa, --screenshot-alt  Project screenshot alt text               [string]
      --su, --screenshot-url  Project screenshot URL                    [string]
      --tg, --tag             StackApps post tag (repeatable)
                                                   [array] [default: ["script"]]
      --tl, --title           StackApps post title                      [string]
      --th, --thumbnail       StackApps post thumbnail                  [string]

Platform

This is a Node.js package (tested on LTS 16.13.2), so it requires Node to be installed. Best used with TypeScript, but contains type declaration files for autocompletion as well.

Contact

Author: Oleg Valter
Organization: UserScripters

Please, submit bug reports on the source repository.
Before adding a new one, please check if it hasn't been raised before.

You can also drop by to chat, we are a friendly bunch.

Code

Source code is written in TypeScript.

Contributions are welcome, you can always submit a PR here.

0Valt
  • 1.4k
  • 4
  • 16