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

tsg-js

v1.0.0

Published

TypeScript code generator

Downloads

18

Readme

tsg-js

TypeScript code generator.

tsg-js is inspired by similar functionality in the Ruby-on-Rails (RoR) framework.

Installation

Unstall tsg-js either globally, or local to your project.

> npm install tsg-js -g
... or ...
> npm install tsg-js

Use

Generate a TypeScript class in your source directory, per tsconfig.js location.

> npx tsg genclass SomeClass

file written: src/SomeClass.ts

Generate a TypeScript class and corresponding unit test. Assumes the use of Jest.

> npx tsg genclass SomeClass -t

file written: src/SomeClass.ts
file written: src/SomeClass.test.ts

Generate a TypeScript unit test. Assumes the use of Jest.

> npx tsg gentest SomeClass

file written: src/SomeClass.test.ts

Generate a Jest Config File.

> npx tsg genjest

file written: .../jest.config.js

List the contents of your source directory, per tsconfig.js location.

> npx tsg lsrc

command: ls -al src
total 56
drwxr-xr-x@  9 cjoakim  staff  288 Dec  4 11:41 .
drwxr-xr-x@ 15 cjoakim  staff  480 Dec  4 11:40 ..
-rw-r--r--@  1 cjoakim  staff  283 Dec  4 11:36 Class1.ts
-rw-r--r--@  1 cjoakim  staff  280 Dec  4 11:36 Class2.test.ts
-rw-r--r--@  1 cjoakim  staff  283 Dec  4 11:36 Class2.ts
-rw-r--r--@  1 cjoakim  staff  280 Dec  4 11:36 Class3.test.ts
-rw-r--r--@  1 cjoakim  staff  283 Dec  4 11:36 Class3.ts
-rw-r--r--@  1 cjoakim  staff  298 Dec  4 11:42 SomeClass.test.ts
-rw-r--r--@  1 cjoakim  staff  286 Dec  4 11:41 SomeClass.ts

List the contents of your transpiled outputed directory, per tsconfig.js location.

> npx tsg ldist

command: ls -al dist
total 80
drwxr-xr-x@ 12 cjoakim  staff  384 Dec  4 11:36 .
drwxr-xr-x@ 15 cjoakim  staff  480 Dec  4 11:40 ..
-rw-r--r--@  1 cjoakim  staff  104 Dec  4 11:36 Class1.d.ts
-rw-r--r--@  1 cjoakim  staff  295 Dec  4 11:36 Class1.js
-rw-r--r--@  1 cjoakim  staff  104 Dec  4 11:36 Class2.d.ts
-rw-r--r--@  1 cjoakim  staff  295 Dec  4 11:36 Class2.js
-rw-r--r--@  1 cjoakim  staff   66 Dec  4 11:36 Class2.test.d.ts
-rw-r--r--@  1 cjoakim  staff  299 Dec  4 11:36 Class2.test.js
-rw-r--r--@  1 cjoakim  staff  104 Dec  4 11:36 Class3.d.ts
-rw-r--r--@  1 cjoakim  staff  295 Dec  4 11:36 Class3.js
-rw-r--r--@  1 cjoakim  staff   66 Dec  4 11:36 Class3.test.d.ts
-rw-r--r--@  1 cjoakim  staff  299 Dec  4 11:36 Class3.test.js

Complete example of output

$ npx tsg
  _____ ____   ____       _
 |_   _/ ___| / ___|     (_)___
   | | \___ \| |  _ _____| / __|
   | |  ___) | |_| |_____| \__ \
   |_| |____/ \____|    _/ |___/
                       |__/
  version: 0.1.1
--------------------------------------------------------------------
npx tsg genclass SomeClass      # generate a class file
npx tsg genclass SomeClass -t   # generate class and test files
npx tsg gentest SomeClass       # generate a test file
npx tsg genjest                 # generate a Jest config file
npx tsg lsrc                    # list the TS source directory
npx tsg ldist                   # list the TS transpiled directory

Version History

| Version | Date | Changes | | ------- | ---------- | --------------------------------------------------------------- | | 1.0.0 | 2023/12/08 | First GA release; tested on macOS 14/Sonoma and Windows 11 | | 0.1.1 | 2023/12/04 | Beta 2 | | 0.1.0 | 2023/12/04 | Beta 1 | | 0.0.2 | 2023/12/01 | Pre-Alpha | | 0.0.1 | 2023/12/01 | Pre-Alpha, create library on npmjs.org |