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

@exercism/typescript-representer

v1.0.0

Published

Exercism AST representer for TypeScript

Downloads

3

Readme

@exercism/typescript-representer

typescript-representer / deploy typescript-representer / main

Installation

Clone this repository and then run:

yarn install

You'll need at least Node LTS for this to work.

yarn build

Global installation

If you want to use this package as a local tool, you can install it globally, in order to make the "binaries" available:

yarn global add @exercism/typescript-representer

On *nix systems or enabled shells (wsl, bash, git bash, etc.) you can now use typescript-representer <slug> <input> [<output>] [-flag] [--flags] to represent a local file (at input), or typescript-representer-remote https://exercism.io/... [<output>] [-flag] [--flags] to work on a remote solution.

Usage

If you're developing this, you can run this via yarn or the provided shell script.

  • .sh enabled systems (UNIX, WSL): yarn represent:dev
  • .bat fallback (cmd.exe, Git Bash for Windows): yarn represent:dev:bat

You'll want these :dev variants because it will build the required code (it will transpile from TypeScript to JavaScript, which is necessary to run this in Node environments, unlike Deno environments). When on Windows, if you're using Git Bash for Windows or a similar terminal, the .sh files will work, but will open a new window (which closes after execution). The .bat scripts will work in the same terminal.

You can also manually build using yarn or yarn build, and then run the script directly: ./bin/represent.sh arg1 -o2 --option3.

Run this with the argument help to see how to use this:

yarn represent:dev:bat help

Usage | represent.js <exercise> <input-directory> [<output-directory>] [options]

Options:
 ... see below

Examples:
  represent.js two-fer ~/typescript/two-fer/128/

  Represent the two-fer solution from the input directory "~/typescript/two-fer/128"

Options

| short | long | description | | | ------ | ------------------------- | ------------------------------------------------------------------- | -------------------------------------------- | | | --version | Show version number | boolean | | -d | --debug | Unless given, only outputs warnings and errors | boolean (default: false) | | -c | --console | If given, outputs to the console | boolean (default: false) | | --or | --output_representation | Path relative to the output dir where the representation is stored | string (default: "./representation.txt") | | --om | --output_mapping | Path relative to the output dir where the mapping is stored | string (default: "./mapping.json") | | -u | --ugly | If given, does not format the JSON output using 2 space indentation | boolean (default: false) | | | --dry | If given, does not output anything to disk | boolean (default: false) | | -h | --help | Show help | boolean |

When using development, likely you'll want -dc to also print the output and debug message to the console. You can use --dry to prevent the script from writing to disk. When the <output-directory> is not given, it default to the given <input-directory>

Remote solutions

There are tools provided to run the representer on remote solutions.

  • .sh enabled systems (UNIX, WSL): bin/scripts/remote.sh url
  • .bat fallback (cmd.exe, Git Bash for Windows): bin\scripts\remote.bat url

You can pass the following type of URLs:

  • Published solutions: /tracks/typescript/exercises/<slug>/<id>
  • Mentor solutions: /mentor/solutions/<id>
  • Your solutions: /my/solutions/<id>
  • Private solutions: /solutions/<id>

Using docker

To create the image, execute the following command from the repository root:

docker build -t exercism/typescript-representer .

To run from docker pass in the solutions path as a volume and execute with the necessary parameters:

docker run -v $(PATH_TO_SOLUTION):/solution exercism/typescript-representer ${SLUG} /solution

Example:

docker run -v ~/solution-238382y7sds7fsadfasj23j:/solution exercism/typescript-representer two-fer /solution

Formatting code

The easiest way to satisfy the code-format linter is to add a comment to your PR:

/format

Alternatively, run the following command:

# Ensure that the version matches the version inside .github/format-code.yml
EXERCISM_PRETTIER_VERSION=2.2.1 bin/format.sh