GithubHelp home page GithubHelp logo

bitjson / typescript-starter Goto Github PK

View Code? Open in Web Editor NEW
3.5K 43.0 242.0 1.95 MB

Quickly create and configure a new library or Node.js project

Home Page: https://bitjson.github.io/typescript-starter/

License: MIT License

TypeScript 99.42% JavaScript 0.58%
typescript typedoc ava tslint prettier standard-version nodejs library starter template

typescript-starter's Introduction

typescript-starter dark logotypescript-starter logo

NPM version Codecov CircleCI Travis AppVeyor GitHub stars

demo of the typescript-starter command-line interface

Start Now

Run one simple command to install and use the interactive project generator. You'll need Node v10 or later.

npx typescript-starter

The interactive CLI will help you create and configure your project automatically.

Since this repo includes the CLI and it's tests, you'll only need to fork or clone this project if you want to contribute. If you find this project useful, please consider leaving a star so others can find it. Thanks!

Features

So we can have nice things:

  • Generate API documentation (HTML or JSON) without a mess of JSDoc tags to maintain
  • Collocated, atomic, concurrent unit tests with AVA
  • Source-mapped code coverage reports with nyc
  • Configurable code coverage testing (for continuous integration)
  • Automatic linting and formatting using typescript-eslint and Prettier

But first, a good editor

Before you start, consider using an editor with good typescript support.

VS Code (below) is a popular option. Editors with typescript support can provide helpful autocomplete, inline documentation, and code refactoring features.

Also consider installing editor extensions for ESLint and Prettier. These extensions automatically format your code each time you save, and may quickly become invaluable.

Typescript Editor Support – vscode

Developing with typescript-starter

Development zen

To start working, run the watch:build task using npm or yarn.

npm run watch:build

In another terminal tab/window, run the watch:test task:

npm run watch:test

These watch tasks make development much faster and more interactive. They're particularly helpful for TDD/BDD workflows.

These watch tasks will build and watch the entire project for changes (to both the library source files and test source files). As you develop, you can add tests for new functionality – which will initially fail – before developing the new functionality. Each time you save, any changes will be rebuilt and retested.

typescript-starter's watch task

Since only changed files are rebuilt and retested, this workflow remains fast even for large projects.

Enable stronger type checking (recommended)

To make getting started easier, the default tsconfig.json is using a very flexible configuration. This will allow you to get started without many warnings from Typescript.

To enable additional Typescript type checking features (a good idea for mission-critical or large projects), review the commented-out lines in your typescript compiler options.

Auto-fix and format project

To automatically fix eslint and prettier formatting issues, run:

npm run fix

View test coverage

To generate and view test coverage, run:

npm run cov

This will create an HTML report of test coverage – source-mapped back to Typescript – and open it in your default browser.

source-mapped typescript test coverage example

Generate your API docs

The src folder is analyzed and documentation is automatically generated using TypeDoc.

npm run doc

This command generates API documentation for your library in HTML format and opens it in a browser.

Since types are tracked by Typescript, there's no need to indicate types in JSDoc format. For more information, see the TypeDoc documentation.

To generate and publish your documentation to GitHub Pages use the following command:

npm run doc:publish

Once published, your documentation should be available at the proper GitHub Pages URL for your repo. See typescript-starter's GitHub Pages for an example.

TypeDoc documentation example

For more advanced documentation generation, you can provide your own TypeDoc theme, or build your own documentation using the JSON TypeDoc export:

npm run doc:json

Bump version, update changelog, commit, & tag release

It's recommended that you install commitizen to make commits to your project.

npm install -g commitizen

# commit your changes:
git cz

This project is tooled for conventional changelog to make managing releases easier. See the standard-version documentation for more information on the workflow, or CHANGELOG.md for an example.

# bump package.json version, update CHANGELOG.md, git tag the release
npm run version

You may find a tool like wip helpful for managing work in progress before you're ready to create a meaningful commit.

One-step publish preparation script

Bringing together many of the steps above, this repo includes a one-step release preparation command.

# Prepare a standard release:
npm run prepare-release

This command runs the following tasks:

  • hard-reset: cleans the repo by removing all untracked files and resetting --hard to the latest commit. (Note: this could be destructive.)
  • test: build and fully test the project
  • docs:html: generate the latest version of the documentation
  • docs:publish: publish the documentation to GitHub Pages
  • version: bump package.json version, update CHANGELOG.md, and git tag the release

When the script finishes, it will log the final command needed to push the release commit to the repo and publish the package on the npm registry:

git push --follow-tags origin master; npm publish

Look over the release if you'd like, then execute the command to publish everything.

You can also prepare a non-standard release:

# Or a non-standard release:

# Reset the repo to the latest commit and build everything
npm run hard-reset && npm run test && npm run cov:check && npm run doc:html

# Then version it with standard-version options. e.g.:
# don't bump package.json version
npm run version -- --first-release

# Other popular options include:

# PGP sign it:
# $ npm run version -- --sign

# alpha release:
# $ npm run version -- --prerelease alpha

# And don't forget to push the docs to GitHub pages:
npm run doc:publish

FAQs

Why are there two builds? (main and module)

The src of typescript-starter is compiled into two separate builds: main and module. The main build is configured to use the CommonJS module system. The module build uses the new es6 module system.

Because Node.js LTS releases do not yet support the es6 module system, some projects which depend on your project will follow the main field in package.json. Tools which support the new system (like Rollup, Webpack, or Parcel) will follow the module field, giving them the ability to statically analyze your project. These tools can tree-shake your module build to import only the code they need.

Why put tests next to the source code?

By convention, sample tests in this project are adjacent to the files they test.

  • Such tests are easy to find.
  • You see at a glance if a part of your project lacks tests.
  • Nearby tests can reveal how a part works in context.
  • When you move the source (inevitable), you remember to move the test.
  • When you rename the source file (inevitable), you remember to rename the test file.

(Bullet points taken from the Angular Testing Guide.)

Can I move the tests?

Yes. For some projects, separating tests from the code they test may be desirable. This project is already configured to test any *.spec.ts files located in the src directory, so reorganize your tests however you'd like. You can put them all in a single folder, add tests that test more than one file, or mix and match strategies (e.g. for other types of tests, like integration or e2e tests).

Can I use ts-node for all the things?

Tests are compiled and performed on the final builds in the standard Node.js runtime (rather than an alternative like ts-node) to ensure that they pass in that environment. If you are build a Node.js application, and you are using ts-node in production, you can modify this project to use ts-node rather than a build step.

However, if you're building any kind of library, you should always compile to javascript.

Library authors sometimes make the mistake of distributing their libraries in typescript. Intuitively, this seems like a reasonable course of action, especially if all of your intended consumers will be using typescript as well.

TypeScript has versions, and different versions of TypeScript may not be compatible. Upgrading to a new major version of TypeScript sometimes requires code changes, and must be done project-by-project. Additionally, if you're using the latest version of TypeScript to build your library, and one of your consumers is using an older version in their application, their compiler will be unable to compile your library.

How do I bundle my library for the browser?

The short answer is: don't pre-bundle your library.

Previous versions of typescript-starter included browser bundling using Rollup. This feature has since been removed, since very few libraries should ever be pre-bundled.

If the consumer of your library is using Node.js, bundling is especially unnecessary, since Node.js can reliably resolve dependencies, and bundling may even make debugging more difficult.

If the consumer of your library is a browser application, the application likely has its own build tooling. Very few serious applications are manually bundling their javascript, especially with easy to use, no configuration tools like Parcel available.

Your library is most useful to downstream consumers as a clean, modular codebase, properly exporting features using es6 exports. Consumers can import the exact es6 exports they need from your library, and tree-shake the rest.

How can my library provide different functionality between Node.js and the browser?

In the past, complex javascript libraries have used solutions like Browserify to bundle a version of their application for the browser. Most of these solutions work by allowing library developers to extensively configure and manually override various dependencies with respective browser versions.

For example, where a Node.js application might use Node.js' built-in crypto module, a browser version would need to fall back to a polyfill-like alternative dependency like crypto-browserify.

With es6, this customization and configuration is no longer necessary. Your library can now export different functionality for different consumers. While browser consumers may import a native JavaScript crypto implementation which your library exports, Node.js users can choose to import a different, faster implementation which your library exports.

See hash.ts for a complete example. Two different functions are exported, sha256, and sha256Native. Browser consumers will not be able to import sha256Native, since their bundler will be unable to resolve the built-in Node.js dependency (their bundler will throw an error). Node.js users, however, will be able to import it normally. Each consumer can import the exact functionality they need.

One perceived downside of this solution is that it complicates the library's API. Browser consumers will sometimes import one feature while Node.js users import another. While this argument has merit, we should weigh it against the benefits.

Providing a public API where consumer code is the same between browsers and Node.js is desirable, but it comes at the cost of significant configuration and complexity. In many cases, it requires that code be aware of its environment at runtime, requiring additional complexity and testing.

A better way to provide this developer experience is to provide similar APIs for each environment, and then encourage the use of es6 import aliasing to standardize between them.

For example, in the documentation for typescript-starter, we encourage Node.js users to import sha256Native as sha256. With this convention, we get a standard API without loaders or dependency substitution hacks.

// browser-application.js
import { sha256 } from 'typescript-starter';

// fully-portable code
console.log(sha256('test'));
// node-application.js
import { sha256Native as sha256 } from 'typescript-starter';

// fully-portable code
console.log(sha256('test'));

What about Git hooks to validate commit messages?

This project uses standard-version to automatically update the changelog based on commit messages since the last release. To do this, each relevant commit must be properly formatted.

To ensure all commits follow the proper conventions, you can use a package like commitlint with Husky. However, keep in mind that commit hooks can be confusing, especially for new contributors. They also interfere with some development tools and workflows.

If your project is private, or will primarily receive contributions from long-running contributors, this may be a good fit. Otherwise, this setup may raise the barrier to one-off contributions slightly.

Note, as a maintainer, if you manage your project on GitHub or a similar website, you can now use the Squash and Merge option to add a properly formatted, descriptive commit messages when merging each pull request. This is likely to be more valuable than trying to force one-time contributors to adhere to commit conventions, since you can also maintain a more consistent language style. Because this is the best choice for the vast majority of projects, typescript-starter does not bundle any commit message validation.


Contributing

Pull Requests welcome! To work on the CLI, clone and build the repo, then use npm link to install it globally.

git clone https://github.com/bitjson/typescript-starter.git
cd typescript-starter
npm install
npm test
npm link

Manual testing

To manually test the CLI, you can use the TYPESCRIPT_STARTER_REPO_URL environment variable to test a clone from your local repo. Run npm run build:main -- -w as you're developing, then in a different testing directory:

mkdir typescript-starter-testing
cd typescript-starter-testing
TYPESCRIPT_STARTER_REPO_URL='/local/path/to/typescript-starter' typescript-starter

You can also set TYPESCRIPT_STARTER_REPO_URL to any valid Git URL, such as your fork of this repo:

TYPESCRIPT_STARTER_REPO_URL='https://github.com/YOUR_USERNAME/typescript-starter.git' typescript-starter

If TYPESCRIPT_STARTER_REPO_BRANCH is not provided, it will default to master.

Debug in VS Code

If you're using VS Code, the Debug CLI launch configuration also allows you to immediately build and step through execution of the CLI.

Integration Test Result Diffs

You can compare the integration test results before and after a change by running check-cli before and after applying your changes:

npm run check-cli

Each time you run check-cli, the test results will be committed to the diff directory, allowing you to easily review the differences with git diff HEAD or an interactive Git client like GitHub for Desktop or SourceTree.

If you already have changes in the working directory, try:

git stash && npm run check-cli && git stash pop && npm run check-cli

typescript-starter's People

Contributors

asmagin avatar bitjson avatar cspotcode avatar didierdemoniere avatar duncanchen avatar emmanuelgautier avatar francescoborzi avatar greenkeeper[bot] avatar jmerle avatar johnslemmer avatar mhegazy avatar micahriggan avatar msalcala11 avatar pselden avatar ryanjohnston avatar timhwang21 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

typescript-starter's Issues

Missing changelog command

  • I'm submitting a ...
    [x] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

There is no changelog command as is shown in the npm run info script and on the README.

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

I simply generated the project as instructed, and there is no changelog command to generate the changelog.

env: node\r: No such file or directory

  • I'm submitting a ...
    [x] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

After generating a project, I ran npm run info and received the following:

> [email protected] info /Users/REDACTED
> npm-scripts-info

env: node\r: No such file or directory
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] info: `npm-scripts-info`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] info script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/REDACTED

The same error occurs when running ./node_modules/.bin/npm-scripts-info directly.

However, if you call it as node ./node_modules/.bin/npm-scripts-info, it works fine.

This is obviously the same error as here so there's clearly some DOS endings instead of unix endings but I'm not sure where.

build-tests.js

  • I'm submitting a ...
    [ ] bug report
    [ ] feature request
    [x] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

Thank you for sharing this! Do you mind explaining the rationale and need for build-tests.js

yarn watch not working on windows 10

  • I'm submitting a ...
    [x ] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary
    running yarn watch on windows 10 will produce this output

yarn watch v0.20.3
$ trash build && multiview [yarn watch:build] [yarn watch:unit]
module.js:472
    throw err;
    ^

Error: Cannot find module './build/Debug/buffertools.node'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (~~my repo~~\node_modules\buffertools\buffertools.js:26:20)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
error Command failed with exit code 1.

this is because multiview use buffertools which not support simple instalation on windows ( you need a C++ compiler & python 2.7 for that).

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

Coverage doesn't work with node <4.5

  • I'm submitting a ...
    [x ] bug report

The ava library being used is affected by the following bug which causes it to fail to run the coverage:
avajs/ava#1354
They're recommending that engines in package.json is changed to node>=4.5, would probably be a good idea to do the same here :)

Add a monorepo option?

Reddit said you wanted feedback, so here goes: A lot of this looks great, and I would probably use it, but I need multi-repo support (probably using lerna).

enhancements ideas?

@bitjson

I've started a few projects based on this structure -- but I've gone what I would call 'more full on' with the class structure, using express, etc. etc.

Would you be interested on collaborating on updating the template with latest typescript, tools, etc. and maybe another repo extended with express js?

Or would you prefer me to fork and go?

thanks for the great work - it was a tremendous help.

Chad

CLI setup failing on windows 10

  • I'm submitting a ...
    [ x ] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ x ] question about how to use this project

  • Summary

Either I'm setting this up wrong, or there's a bug with the setup. Running through the CLI constantly fails to properly install for me on windows 10. I have tried in command prompt, powershell, and Bash (WSL) and each time I get the same error. I have also tried using "Run as admin" and still fails.

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

Errors:

image

Main error is a renaming operation;

15921 silly saveTree | `-- [email protected]
15921 silly saveTree `-- [email protected]
15922 verbose stack Error: EPERM: operation not permitted, rename 'X:\dev\.misc\test-ts\node_modules\.staging\nyc-f51733ed\node_modules\snapdragon' -> 'X:\dev\.misc\test-ts\node_modules\.staging\snapdragon-5e10080e'
15923 verbose cwd X:\dev\.misc\test-ts
15924 verbose Windows_NT 10.0.17134
15925 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\xander\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install"
15926 verbose node v10.7.0
15927 verbose npm  v6.1.0
15928 error path X:\dev\.misc\test-ts\node_modules\.staging\nyc-f51733ed\node_modules\snapdragon
15929 error code EPERM
15930 error errno -4048
15931 error syscall rename
15932 error Error: EPERM: operation not permitted, rename 'X:\dev\.misc\test-ts\node_modules\.staging\nyc-f51733ed\node_modules\snapdragon' -> 'X:\dev\.misc\test-ts\node_modules\.staging\snapdragon-5e10080e'
15932 error  { [Error: EPERM: operation not permitted, rename 'X:\dev\.misc\test-ts\node_modules\.staging\nyc-f51733ed\node_modules\snapdragon' -> 'X:\dev\.misc\test-ts\node_modules\.staging\snapdragon-5e10080e']
15932 error   cause:
15932 error    { Error: EPERM: operation not permitted, rename 'X:\dev\.misc\test-ts\node_modules\.staging\nyc-f51733ed\node_modules\snapdragon' -> 'X:\dev\.misc\test-ts\node_modules\.staging\snapdragon-5e10080e'
15932 error      errno: -4048,
15932 error      code: 'EPERM',
15932 error      syscall: 'rename',
15932 error      path:
15932 error       'X:\\dev\\.misc\\test-ts\\node_modules\\.staging\\nyc-f51733ed\\node_modules\\snapdragon',
15932 error      dest:
15932 error       'X:\\dev\\.misc\\test-ts\\node_modules\\.staging\\snapdragon-5e10080e' },
15932 error   stack:
15932 error    'Error: EPERM: operation not permitted, rename \'X:\\dev\\.misc\\test-ts\\node_modules\\.staging\\nyc-f51733ed\\node_modules\\snapdragon\' -> \'X:\\dev\\.misc\\test-ts\\node_modules\\.staging\\snapdragon-5e10080e\'',
15932 error   errno: -4048,
15932 error   code: 'EPERM',
15932 error   syscall: 'rename',
15932 error   path:
15932 error    'X:\\dev\\.misc\\test-ts\\node_modules\\.staging\\nyc-f51733ed\\node_modules\\snapdragon',
15932 error   dest:
15932 error    'X:\\dev\\.misc\\test-ts\\node_modules\\.staging\\snapdragon-5e10080e',
15932 error   parent: 'test-ts' }
15933 error The operation was rejected by your operating system.
15933 error It's possible that the file was already in use (by a text editor or antivirus),
15933 error or that you lack permissions to access it.
15933 error
15933 error If you believe this might be a permissions issue, please double-check the
15933 error permissions of the file and its containing directories, or try running
15933 error the command again as root/Administrator (though this is not recommended).
15934 verbose exit [ -4048, true ]

An in-range update of typescript is breaking the build 🚨

Version 2.3.1 of typescript just got published.

Branch Build failing 🚨
Dependency typescript
Current Version 2.3.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As typescript is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details - ❌ **continuous-integration/travis-ci/push** The Travis CI build failed [Details](https://travis-ci.org/bitjson/typescript-starter/builds/226523961)

Release Notes TypeScript 2.3

For release notes, check out the release announcement

For new features, check out the What's new in TypeScript 2.3.

For breaking changes, check out the Breaking changes in TypeScript 2.3 page.

For the complete list of fixed issues, check out the issues fixed in TypeScript 2.3 RC and after TypeScript 2.3 RC.

Download:

Special thanks to all contributors to this release:

  • Akinmade Bond
  • Anders Hejlsberg
  • Andy Hanson
  • Argelius Andreas
  • @arjunyel
  • Artem Roshko
  • Arthur Ozga
  • Bill Ticehurst
  • Christian Silver
  • Christophe Vidal
  • @cedvdb
  • Daniel Lehenbauer
  • Daniel Rosenwasser
  • Diullei Gomes
  • @e-cloud
  • Erik McClenney
  • @falsandtru
  • Hendrik Liebau
  • Herrington Darkholme
  • Igor Novozhilov
  • James Henry
  • Jason Jarrett
  • Jason Ramsay
  • Josh Goldberg
  • K. Preißer
  • Kagami Sascha Rosylight
  • Kanchalai Tanglertsampan
  • Klaus Meinhardt
  • Logan Mzz
  • Magnus Hiie
  • Matt Bierner
  • Matt McCutchen
  • Mike Busyrev
  • Mine Starks
  • Mohamed Hegazy
  • Natalie Coley
  • Nathan Shively-Sanders
  • Nico Kemnitz
  • Nicolas Henry
  • Oleg Mihailik
  • Ron Buckton
  • Ryan Cavanaugh
  • Soo Jae Hwang
  • Tuure Savuoja
  • Vadi Taslim
  • Vincent Bel
  • Vladimir Matveev
  • Zhengbo Li
Commits

The new version differs by 346 commits0.

  • 47e5569 Update LKG
  • 9ada915 Merge pull request #15381 from Microsoft/revert15104
  • fe0a307 Revert "Treat callback parameters as strictly covariant"
  • 96a3c91 Revert "Fix callback types to match covariantly"
  • 70bb2d3 Revert "Accept new baselines"
  • 3abd0c8 Revert "Add tests"
  • 42d6a9c Revert "Check callback return values bi-variantly"
  • d581bed Revert "Accept new baselines"
  • cf17be2 Revert "Add another test case"
  • e86512e Revert "Allow callbacks unioned with null and/or undefined"
  • 22647bb Revert "Update tests"
  • 8a85f4a Update LKG
  • 3c3b73e Merge branch 'master' into release-2.3
  • a0abadb Merge pull request #15320 from Microsoft/fixTypePredicateThisParameter
  • 5783435 Merge pull request #15330 from gcnew/exportConsts

There are 250 commits in total.

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

CircleCI testing on multiple node versions?

  • I'm submitting a ...
    [x] feature request

  • Summary

Is there an option for testing on multiple node versions in CircleCI? Do I add a few calls to nvm into the .circleci/config.yml? I'm coming from Travis where you list one or two node versions in an array and it runs on both in parallel.

EDIT: also, an AppVeyor option would be great for when CI needs to run on Windows. (for example, to catch stuff like the outstanding Windows bug I mentioned in #67)
EDIT2: ...and travis, in case you need free Mac testing.

use `--rootDir` in config files

  • I'm submitting a ...
    [X] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary
    This is rather a suggestion to prevent future bugs, whenever --outDir is used, I would recommend setting --rootDir, see https://github.com/Microsoft/TypeScript/wiki/FAQ#why-does---outdir-moves-output-after-adding-a-new-file for more details.

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

Use a semi-script-runner to remove yarn dependency from package.json

Currently you have stuff like "unit": "yarn build && nyc ava" in the package.json, which prevents people from running with npm only. Changing it to npm run build would just result in the exact same problem. There are however, multiple libraries made to solve this. I don't remember most of them, because I wrote my own a few months or so ago which you can find here: https://github.com/YoloDev/simple-scripts

However, being written by me, that one is horribly undocumented (see package.json for usage), the point is you can create scripts that run a list of other scripts in sequence like a really simple task runner. I would probably go find one of the other ones, but by all means if you like mine you are free to use it.

Task to deploy documentation to GitHub pages

It'd be great if there was a clean and mostly-automatic option for deploying the TypeDoc generated documentation to GitHub pages. Also should link to the example documentation from README.md.

Node.js application - simple server example

  • I'm submitting a ...
    [ ] bug report
    [X] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

Thanks for the tool! Great work!

If I choose Node.js application type during installation I have a library example in src folder.

What do you think about generate simple web server as example in src if user select Node.js application type?

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

message: 'nodegit_1 is not defined',

  • I'm submitting a ...
    [X] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

Step 1:

yarn add nodegit --save

Step 2:

yarn add @types/nodegit --save -D

Step 3:

import { Clone, Cred } from 'nodegit';

const cloneURL = '[email protected]:nodegit/test';
const localPath = require('path').join(__dirname, 'tmp');

    const cloneOptions = {
      fetchOpts: {
        callbacks: {
          certificateCheck: () => 1,
          credentials: (url: string, userName: string) => {
            return Cred.sshKeyFromAgent(userName);
          }
        }
      }
    };
const repo = await Clone.clone(cloneURL, localPath, cloneOptions);

I get following error:

  /Users/shiv/projects/myapp-cli/src/lib/create.ts:36                                                                  
   36:     const repo = await Clone.clone(cloneURL, localPath, cloneOptions);                  

  Rejected promise returned by test. Reason:

  ReferenceError {
    message: 'nodegit_1 is not defined',
  }

  Cli.seed (src/lib/create.ts:36:18)
  ava_1.test (src/tests/create.spec.ts:13:24)

What i'm missing here any prompt help will be appriciated

Require on Node.js

  • I'm submitting a ...
    [ ] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [x] question about how to use this project

  • Summary
    Hi there,
    I'm using the generated build within Node.js application.
    I've a typescript file (in src/lib) that exports a default class and several interfaces.
    When trying to require the CommonJS file, I have to do that:

const lib = require('my-lib').default;

How to handle javascript module and CommonJS ?

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
    microsoft/TypeScript#2719

Browser build & testing

Need to add an example of the library using functionality of a built-in Node.js module, while also providing a browser fallback.

Probably a sha256 method which just accepts a string and returns it's sha256 digest. In Node.js, it should use the (fast, native) built-in hash function. In the browser, it should fall back to hash.js.

The browser build can also replace the module build (for now), since ES6 modules are (currently) only able to be used by browser build systems. When a version of Node.js supports ES6 modules, we'll add the module build back.

The browser build should be tested with karma-ava or something similar. (Bonus: both builds will be fully-tested, so the language here can be revised.)

Lodash fp causes issues with watch process

  • I'm submitting a ...
    [X ] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary
    Using the map or reduce functions from lodash/fp leads to a strange behavior in the watch process, where the results of the tests will flash up briefly, and then the screen is immediately cleared. Normally is stays up until a new watch is triggered, which is necessary for review and debugging.

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

I've been building a library initialized via this project. Things were going well until I attempted to use lodash/fp. Using the map or reduce functions from that library leads to the screen clearing immediately as soon as tests finish when in watch mode (npm run watch). Can be recreated fairly easily by me by installing lodash + typings, then invoking a function like this from a test:

import { map } from 'lodash/fp';

export const mapFn = (): Array<number> => {
  const mapper = map((): number => {
    return 1;
  });

  return mapper(['a', 'b']);  
};

test like:

import { mapFn } from './utils';

test('foo', t => {
  const mapped = mapFn();
  console.log(mapped);
  t.pass();
});

The normal (non-fp) map and reduce do not cause this behavior.

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml
  • The new Node.js version is in-range for the engines in 1 of your package.json files, so that was left alone

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

package.json name prop not set during interactive config

  • I'm submitting a ...
    [x] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary
    The package.json name property is not set to the name entered during interactive config.

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

Can be recreated by starting a new project. The name prop typescript-starter spits out is always "typescript-starter". I would expect it to be the name I use during config, or possibly a slugified version of that name.

Not sure if this intentional, but it seems odd.

An in-range update of browserify is breaking the build 🚨

Version 14.3.0 of browserify just got published.

Branch Build failing 🚨
Dependency browserify
Current Version 14.2.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As browserify is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪


Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details
Commits

The new version differs by 4 commits .

  • cd01926 14.3.0
  • 08caf04 changelog
  • ad5060d Merge pull request #1710 from substack/https-browserify-1
  • 7c7b4d4 update https-browserify to ^1.0.0

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

"npx typescript-starter" doesn't work.

  • I'm submitting a ...
    [ ] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [x] question about how to use this project

  • Summary

when i run `npx typescript-starter':

D:\Projects>npx typescript-starter qizh-core
npx: installed 1 in 2.248s
The "path" argument must be of type string
npx: installed 351 in 37.594s
null

and then it opens a cli.js in my editor

[main 12:32:44] update#setState idle
[main 12:33:14] update#setState checking for updates
[main 12:33:14] update#setState idle

after i closed the file, the command just finished with nothing.

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
    _20180312123608

yarn test issue on win 10

  • I'm submitting a ...
    [ x] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary
    Trying to following initial setup here.
    yarn install - works great.
    yarn watch - gets stuck towards the end on what sort of looks like bad argument passing (see attached stacktrace)

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

$ yarn watch
yarn watch v0.21.3
$ yarn build && yarn build:tests -- --no-browser && concurrently -r --kill-others 'npm run --silent build:main -- -w' 'npm run --silent build:tests -- -w --no-browser' 'sleepms 2000 && ava --watch'
yarn build v0.21.3
$ trash build && yarn build:main && yarn build:module && yarn build:browser-deps && yarn build:browser && yarn build:browser-cjs && yarn build:resolve-sourcemaps
yarn build:main v0.21.3
$ tsc -p tsconfig.json
Done in 1.22s.
yarn build:module v0.21.3
$ tsc -p config/exports/tsconfig.module.json
Done in 1.29s.
yarn build:browser-deps v0.21.3
$ mkdirp build/temp && browserify node_modules/hash.js/lib/hash.js --standalone hash -o build/temp/hash.js
Done in 0.66s.
yarn build:browser v0.21.3
$ rollup -c config/exports/rollup.config.js -f es -o build/browser/index.js
Done in 0.68s.
yarn build:browser-cjs v0.21.3
$ rollup -c config/exports/rollup.config.js -f cjs -o build/browser/index.cjs.js
Done in 0.67s.
yarn build:resolve-sourcemaps v0.21.3
$ sorcery -i build/browser/index.js && sorcery -i build/browser/index.cjs.js
Done in 0.53s.
Done in 7.07s.
yarn build:tests v0.21.3
$ trash test && node config/exports/build-tests.js --no-browser
Done in 0.73s.
'np' is not recognized as an internal or external command,
operable program or batch file.
'run' is not recognized as an internal or external command,
operable program or batch file.
'-w'' is not recognized as an internal or external command,
operable program or batch file.
'np' is not recognized as an internal or external command,
operable program or batch file.
'run' is not recognized as an internal or external command,
operable program or batch file.
'--silent' is not recognized as an internal or external command,
operable program or batch file.
The filename, directory name, or volume label syntax is incorrect.
'-w' is not recognized as an internal or external command,
operable program or batch file.
'--no-browser'' is not recognized as an internal or external command,
operable program or batch file.
'sleepm' is not recognized as an internal or external command,
operable program or batch file.
'2000' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.

Import ava

  • I'm submitting a ...
    [x] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary
    I get this build error:

src/lib/number.spec.ts:2:10 - error TS2305: Module '".../node_modules/ava/index"' has no exported member 'test'.

2 import { test } from 'ava';
           ~~~~

The ava module code suggests that test should be imported like this: import test from 'ava';

How to execute tests for internal methods?

  • I'm submitting a ...
    [ ] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [x] question about how to use this project

  • Summary
    It is not clear how would I write and execute tests for methods and classes that are not exposed from the module?

Currently, you need to expose a function from a module to be able to run a test.

  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

use with deployable web app

  • I'm submitting a ...
    [ x ] question about how to use this project

  • Summary

Starter looks great for distributing a module. Can you make suggestions on using the starter for a deployable web app rather than for a module?

For example, my web app project has:

src/
- server (an express app)
- client (client-side browser app)
- common (modules common to the server and client apps)

cannot find module "build/main/index.js"

  • I'm submitting a ...
    [ ] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

Integration with Intern?

  • I'm submitting a ...
    [ ] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [x] question about how to use this project

  • Summary
    I am not able to integrate Intern with typescript-starter. What's the correct way to do it?

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

yarn clean breaks tslint

  • I'm submitting a ...
    [x] bug report

  • Summary
    Do the following:

  1. yarn install
  2. yarn test
  3. yarn clean
  4. 💥 yarn test

The yarn clean command is deleting files that tslint needs to work correctly. See the output below:

$ yarn test
yarn test v0.23.3
$ yarn lint && yarn unit && yarn check-coverage
yarn lint v0.23.3
$ tslint src/**/*.ts
module.js:472
    throw err;
    ^
Error: Cannot find module './test/parse'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/dgregoire/tmp/typescript-starter/node_modules/tslint/lib/test.js:28:13)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
error Command failed with exit code 1.
error Command failed with exit code 1.

This is due to known issues with how yarn clean works.

  • Other information

If I add a .yarnclean file up front that has these contents:

!node_modules/tslint/

Then running yarn clean does not delete the needed files and everything appears to work as expected.

Can't see test results in Windows 10

  • I'm submitting a ...
    [X] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

When running npm run watch, whenever my application compiles it briefly shows which of my tests errored, but then it detects some more file changes, recompiles and the errors are gone. I cannot see what went wrong in my tests, all that shows up are the type check errors, if any.

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

It is a Node app, not intended to run in the browser. Even with errors, this is all that the PowerShell shows after displaying errors for less than a second:

[20:29:48] File change detected. Starting incremental compilation...


[20:29:49] Compilation complete. Watching for file changes.

Explain purpose for separate builds in readme

I am a newbie switching from ES6 - babel - flow type - config to typescript. The project has been really helpful in wiring all the basic things.
I was wondering what is the use of typescript.module.json?

With the current config, I get a main folder and a module folder in my build folder. Which have almost the same generated code. The only difference being main folder also has an interface file. filename.d.ts

Thanks for the help.

UMD Support

  • I'm submitting a ...
    [ ] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ X] question about how to use this project

  • Summary
    Can we generate UMD code using this project?

Strict config breaks yarn watch

  • I'm submitting a ...
    [x] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary
    With a fresh clone, I run yarn watch and all is well.
    However, changing the config to use .strict instead of .flexible means that running yarn watch fails, evidently in part due to missing declaration files for hash.js which makes me wonder if it's related to the upgrade issue #36, as well as an import algorithm not being used.

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

Error output (sorry for the weird symbols):

yarn watch v0.24.5
$ yarn build && yarn build:tests -- --no-browser && concurrently -r --kill-others 'npm run --silent build:main -- -w' 'npm run --silent build:tests -- -w --no-browser' 'sleepms 2000 && ava --watch' 
yarn build v0.24.5
$ trash build && yarn build:main && yarn build:module && yarn build:browser-deps && yarn build:browser && yarn build:browser-cjs && yarn build:resolve-sourcemaps 
yarn build:main v0.24.5
$ tsc -p tsconfig.json 

�[100;30m3�[0m import hash from 'hash.js'
�[100;30m �[0m �[91m                 ~~~~~~~~~�[0m

src/adapters/crypto.browser.ts(3,18): �[91merror�[0m TS7016: Could not find
a declaration file for module 'hash.js'.
 '/Users/heatherbooker/dev/garbage/typescript-starter/node_modules/hash.js/lib/hash.js'
 implicitly has an 'any' type.
  Try `npm install @types/hash.js` if it exists or add a new
declaration (.d.ts) file containing `declare module 'hash.js';`


�[100;30m10�[0m export function createHash (algorithm: 'sha256') {
�[100;30m  �[0m �[91m                            ~~~~~~~~~�[0m

src/adapters/crypto.browser.ts(10,29): �[91merror�[0m TS6133: 'algorithm'
is declared but never used.

"Cannot find module 'path'" when running npm run watch

  • I'm submitting a ...
    [X] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

I have just created a typescript-starter project in my local machine (a Node application), but as soon as I try running npm run watch, I get a crash. node_modules/pkg-conf/index.js:1 crashes with "Error: Cannot find module 'path'".

  • Other information

I'm using Windows 10 x64 and Node 8.9.1. The latest crash I got was with these options, although I've got it using several other configurations as well:

Enter the new package name: test
What are you making? Node.js application
Enter the package description: Test
Will this project use npm or yarn? npm
More fun stuff: Enable tslint-immutable, Include VS Code debugging config, Include CircleCI config

The installation seems to end without errors, but as soon as I run npm run watch, I get the following:

[17:48:05] Starting compilation in watch mode...

[17:48:06] Found 0 errors. Watching for file changes.

C:\Users\David\test\node_modules\pkg-conf\index.js:1
Error: Cannot find module 'path'
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\David\test\node_modules\pkg-conf\index.js:2:14)
    at Module._compile (module.js:635:30)
    at Module.replacementCompile (C:\Users\David\test\node_modules\nyc\node_modules\append-transform\index.js:58:13)
    at module.exports (C:\Users\David\test\node_modules\nyc\node_modules\default-require-extensions\js.js:8:9)
    at C:\Users\David\test\node_modules\nyc\node_modules\append-transform\index.js:62:4
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:unit: `nyc --silent ava "--watch"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test:unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\David\AppData\Roaming\npm-cache\_logs\2018-07-08T16_48_07_024Z-debug.log
ERROR: "test:unit -- --watch" exited with 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] watch: `run-s clean build:main && run-p "build:main -- -w" "test:unit -- --watch"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] watch script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\David\AppData\Roaming\npm-cache\_logs\2018-07-08T16_48_07_122Z-debug.log

I'm also uploading the two log files from the crashes in case they're helpful.

2018-07-08T16_48_07_024Z-debug.log
2018-07-08T16_48_07_122Z-debug.log

Why not use `ts-node` to run tests?

  • I'm submitting a ...
    [ x ] question about the decisions made in the repository
    [ x ] question about how to use this project

  • Summary

Awesome and thank you for putting this project together.

Why not use ts-node to run tests (im doing this with mocha and understand ava is quite different) pros/con for tsc first vs using ts-node?

I have an express app that serves up the static files for the client side app. Suggestions on using your starter on both the browser apps and on the nodejs apps?

Supporting `npm ci` in CI configs

  • I'm submitting a ...
    [x] feature request

  • Summary

Have you thought about supporting the new npm ci command in CI configs?

I actually haven't used it much myself, but I think this does the trick:

if [ -f package-lock.json ] && [ npm ci --help 2>&1 >/dev/null ] ; then npm ci ; else npm install ; fi

An in-range update of hash.js is breaking the build 🚨

Version 1.1.0 of hash.js just got published.

Branch Build failing 🚨
Dependency hash.js
Current Version 1.0.3
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As hash.js is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.