All Projects → barinbritva → init-typescript-app

barinbritva / init-typescript-app

Licence: MIT license
Initialize clean TypeScript setup by running single command. Optional package publication to npm.

Programming Languages

typescript
32286 projects
EJS
674 projects

Projects that are alternatives of or similar to init-typescript-app

Project Webcube
Continuously updated JS infrastructure for modern web dev
Stars: ✭ 141 (+605%)
Mutual labels:  starter-kit, zero-configuration
Create Elm App
🍃 Create Elm apps with zero configuration
Stars: ✭ 1,650 (+8150%)
Mutual labels:  build-tool, zero-configuration
Neutrino
Create and build modern JavaScript projects with zero initial configuration.
Stars: ✭ 3,844 (+19120%)
Mutual labels:  build-tool, zero-configuration
Instapack
All-in-one TypeScript and Sass compiler for web applications! 📦 🚀
Stars: ✭ 131 (+555%)
Mutual labels:  build-tool, zero-configuration
Elm Kitchen
Easily bootstrap a new Elm SPA
Stars: ✭ 21 (+5%)
Mutual labels:  build-tool, zero-configuration
next-boilerplate
☶ The easiest way to create a Next app by running one command.
Stars: ✭ 65 (+225%)
Mutual labels:  build-tool, zero-configuration
Asteroids
Yep, a gulp-ready-nunjucks-lover-sass-powered-and-humanstxt-included html starter kit!
Stars: ✭ 15 (-25%)
Mutual labels:  starter-kit
assemble-core
The core assemble application with no presets or defaults. All configuration is left to the implementor.
Stars: ✭ 17 (-15%)
Mutual labels:  build-tool
Textrude
Code generation from YAML/JSON/CSV models via SCRIBAN templates
Stars: ✭ 79 (+295%)
Mutual labels:  build-tool
make
The Ultimate Makefile to compile all your C, C++, Assembly and Fortran projects
Stars: ✭ 41 (+105%)
Mutual labels:  build-tool
tdesign-vue-starter
A starter-kit for TDesign Vue UI components.
Stars: ✭ 199 (+895%)
Mutual labels:  starter-kit
symfony-lts-docker-starter
🐳 Dockerized your Symfony project using a complete stack (Makefile, Docker-Compose, CI, bunch of quality insurance tools, tests ...) with a base according to up-to-date components and best practices.
Stars: ✭ 39 (+95%)
Mutual labels:  starter-kit
cdkdx
Zero-config CLI for aws cdk development
Stars: ✭ 31 (+55%)
Mutual labels:  build-tool
android-github-repo-template
A template for creating new repositories for the new Android Project.
Stars: ✭ 18 (-10%)
Mutual labels:  starter-kit
php-base-project
A Composer ready package to start a new PHP 7 project
Stars: ✭ 17 (-15%)
Mutual labels:  starter-kit
autovpn2
OpenVPN VPN Gate Client for Linux, connects you to a random Free VPN in a country of your choice by country code.
Stars: ✭ 30 (+50%)
Mutual labels:  zero-configuration
electron-vue-typescript-starter
Starter project for an Electron app with Vue in TypeScript.
Stars: ✭ 36 (+80%)
Mutual labels:  starter-kit
react-starter
Starter kit for React.
Stars: ✭ 16 (-20%)
Mutual labels:  starter-kit
python-flask-app
Start building your next Python Flask app on IBM Cloud.
Stars: ✭ 48 (+140%)
Mutual labels:  starter-kit
generator-bunny
🐰 Jumpstart node module, like a bunny!
Stars: ✭ 13 (-35%)
Mutual labels:  starter-kit

Init TypeScript App

GitHub Workflow Status License

🌟 Motivation

You are in the right repo if you want to:

  • quickly get pure, technology agnostic TypeScript setup for further customization;
  • easily create your own npm package.

📦 Features

  • Clean setup. No dependencies. Only configured TypeScript with production and development build modes;
  • Tune compiler strictness. Choose base mode to get TypeScript basic functionality or advanced mode to enable all kinds of checks;
  • Easy publication (optional). No more fuss with package publication to npm;
  • More features soon. Please, read about upcoming features in roadmap section.

🚀 Launch your project

Quick overview

npx init-typescript-app
# then answer for a few questions in cli
cd project-name
npm install
npm run build
npm start

You are all set up!

You are also able to install init-typescript-app globally if you are using npm of version lower than 5.2.0.

In the documentation we always use npm in all examples to be short. Of course, you can use any of package managers npm or yarn.

Starting in development mode

For development purposes it's reasonable to use npm run build:dev command. It does the following:

  • Runs build process in watch mode and generates source maps files
  • Disables a few compiler options for more comfortable developing process. See the details below.

Production settings include "noUnusedLocals": true and "allowUnreachableCode": false flags. That may be not really convenient. Consider next piece of pseudo code which is totally OK in terms of compiler:

function doMyStuff (): number {
  const numberOne: number = Math.random()
  const numberTwo: number = Math.random()
  const difference: number = numberOne - numberTwo
  const anotherVariable: number = Math.random()

  if (difference > 0) {
    console.log(anotherVariable)
    return numberOne
  } else {
    return numberTwo
  }
}

It's common practice to comment and add some lines of code during development process. Let's change the code like this:

function doMyStuff (): number {
  const numberOne: number = Math.random()
  const numberTwo: number = Math.random()
  const difference: number = numberOne - numberTwo
  // this line emits error by noUnusedLocals rule
  const anotherVariable: number = Math.random()

  console.log(numberOne, numberTwo)
  return 1
  
  // this block emits by allowUnreachableCode rule
  if (difference > 0) {
    // console.log(anotherVariable)
    return numberOne
  } else {
    return numberTwo
  }
}

That's why these checks are switched off for development. You won't get these errors in your build, but an IDE will still show you errors so that you don't forget to fix them. This is a really convenient approach.

📮 Publish your package

If you chose npm package as your project type, you can make your package publication happen by running one command.

Just run npm run release from the root directory of your project. That's it!

Before you start, please, check out next information in this section.

Check your git setup

To use publication features it's necessary for your project to be a git repository.

# create empty repository at GitHub
# run from your project root directory:
git init
git remote add origin [email protected]:user-name/project-name.git
git push -u origin master

This example uses ssh connection to communicate with a repository. If you haven't ssh setup yet you can follow the instructions to deal with it. You still can use https connection instead:

git remote add origin https://github.com/user-name/project-name.git

Check your npm setup

To publish your package it's necessary to be signed in via your npm account in your console. Create an account if you don't have it. Then auth from your console by npm login command.

Of course, you can use any package registry you want, e.g. npm.pkg.github.com.

Check your files

It's necessary to be sure you publish what you exactly mean to publish. Using .npmignore is antipattern (you can read more information about it here and here). By default, only next files will be included into your package:

# your built files, included via package.json
dist
# next files are included by npm by default:
package.json
README.md (and its variants)
CHANGELOG.md (and its variants)
LICENSE

If you add new files or directories, it's necessary to include them to files section of your package.json. Run npm pack and check out output tarball before release. More information about it and other helpful development techniques you can read in npm developer guide.

How publication works under the hood

The release script does next:

  • Checks your working directory is clean in terms of Git. Commit or stash your changes before release.
  • Builds your package
  • Creates git tag with current version
  • Publish the package to npm registry
  • Increase version in package.json(and package-lock.json too) to next patch version
  • Commit changes of package*.json files
  • Push the new commit and tag to your repository

Ok! You are ready to work on the next version!

💡 Tips and tricks

Customization

Have no concerns to change everything you need for your project. After once you run init-typescript-app you fully control your project. It's ok to edit tsconfig.json options or even change build or release scripts. Just a few examples what you may want to change:

  • Pass change some params to build process or add extra steps to it
  • Change your publication process to push the package for private access instead of public. To do that remove --access public from publish command in release.sh
  • Change bumping commit text

In other words, follow your goals!

Troubleshooting

  • In rare cases it's possible to get errors from somewhere of node_modules/**/*d.ts. It means some third-party library typings are broken. If you run into this problem you can solve it by adding "skipDefaultLibCheck": true to compilerOptions of tsconfig.json. More information about tsconfig will be available soon.
  • If you chose advanced type checking, but run into the wall with it, you can rollback to base mode in two ways. The first way is to open tsconfig.json and invert a value of numerous options listed under // Checks comment. You can use hints from an IDE to detect exactly which options give you troubles. You are also able to toggle values one by one to find issuer. You can return toggled values when you will become more experienced. The second way is to permanently remove all the flags under // Checks comment.
  • It's possible to face a situation when you will get an error when trying to use some default object like window, document, Promise or some operators. It means you have to include library's build-in typings to your tsconfig. List of allowed libraries you can find here. Current example looks like that:
{
  "compilerOptions": {
    "lib": [
      "DOM",
      "ES2015"
    ]
  }
}
  • Sometimes it's necessary to extend definitions of standard objects. For instance, you use some library which adds custom property to window object - window.customProperty. Global window object always refers to build-in interface Window placed in lib.dom.d.ts. So you can't redeclare or edit it somehow. There are a lot of similar situations. Declaration merging comes to the rescue. The approach allows you to extend standard definitions implicitly. You can read more about declaration merging in the official documentation. Just one example to be clear:
// go to your project root dir
// create directory for types, for example `definitions`
// inside of `definitions` folder create file `dom.d.ts`
// add path `./definitions/dom.d.ts` to `include` section of your `tsconfg.json`
{
  "include": [
    "./src",
    "./definitions/dom.d.ts"
  ]
}
// for situation above add next code:
interface Window {
  // describe what you need
  customProperty: Object;
}

🗺 Roadmap

In version 1.x

  • Tests. Test frameworks, code coverage.
  • Code standards. Setting up eslint, auto code formatting.
  • Pull-request bots. Checking code coverage, dependencies vulnerabilities, etc
  • Changelog. Documenting changes, integration with release process.
  • Webpack option. Ability to make builds with Webpack.
  • Gulp option. Running additional tasks.

In version 2.x

  • Applications templates. Create not only libraries, but frontend and backend applications too.

🔙 Feedback

Your feedback is really important for the project. Please, use contacts from my profile to send your questions, suggestions, help requests and others. Also, feel free to use issues section to report bugs and problems.

👛 Contributing

See CONTRIBUTING

📄 License

MIT, see LICENSE for the details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].